From e577ef1ca0d44b35a20b7011dc9fc0eaa010bdc1 Mon Sep 17 00:00:00 2001 From: Meep-Eep Date: Thu, 29 Dec 2011 21:29:16 +0000 Subject: [PATCH] Change 'if' chain to switch. Now why didn't I use a switch in the first place? git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3720 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/uqm/flash.c | 51 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/sc2/src/uqm/flash.c b/sc2/src/uqm/flash.c index faf145dfc..79bddc206 100644 --- a/sc2/src/uqm/flash.c +++ b/sc2/src/uqm/flash.c @@ -275,37 +275,36 @@ Flash_process (FlashContext *context) now = GetTimeCounter (); - if (context->state == FlashState_fadeIn) + switch (context->state) { - if (now >= context->lastStateTime + context->fadeInTime) - { + case FlashState_fadeIn: + if (now >= context->lastStateTime + context->fadeInTime) + { + Flash_nextState (context); + context->lastStateTime = now; + } + context->lastFrameTime = now; + break; + case FlashState_on: + if (now < context->lastStateTime + context->onTime) + return; Flash_nextState (context); context->lastStateTime = now; - } - context->lastFrameTime = now; - } - else if (context->state == FlashState_on) - { - if (now < context->lastStateTime + context->onTime) - return; - Flash_nextState (context); - context->lastStateTime = now; - } - else if (context->state == FlashState_fadeOut) - { - if (now >= context->lastStateTime + context->fadeOutTime) - { + break; + case FlashState_fadeOut: + if (now >= context->lastStateTime + context->fadeOutTime) + { + Flash_nextState (context); + context->lastStateTime = now; + } + context->lastFrameTime = now; + break; + case FlashState_off: + if (now < context->lastStateTime + context->offTime) + return; Flash_nextState (context); context->lastStateTime = now; - } - context->lastFrameTime = now; - } - else /* context->state == FlashState_off */ - { - if (now < context->lastStateTime + context->offTime) - return; - Flash_nextState (context); - context->lastStateTime = now; + break; } Flash_drawCurrentFrame (context);