Commits

Andrey Lesnikov committed e40820b

ui_sdl: get_last_event_index(): Small update.

  • Participants
  • Parent commits 0baaaa7

Comments (0)

Files changed (1)

 
 static int
 get_last_event_index (Event e){
-  int n;
-  if(e.t == E_ENDTURN
-  || e.t == E_DEATH
-  || e.t == E_TRANSPORT_IN
-  || e.t == E_TRANSPORT_OUT
-  || e.t == E_CHANGE_TILE
-  || e.t == E_ROTATE)
-    n = 0;
-  else if(e.t == E_MOVE || e.t == E_MELEE)
-    n = steps;
-  else if(e.t == E_RANGE){
-    Mcrd a = id2unit(e.e.range.a)->m;
-    Mcrd b = id2unit(e.e.range.d)->m;
-    n = mdist(a, b) * steps / 2;
-  }else{
-    die("ui_sdl: get_last_event_index(): "
-        "unknow event '%d'.\n", e.t);
+  switch(e.t){
+    case E_ENDTURN:
+    case E_DEATH:
+    case E_TRANSPORT_IN:
+    case E_TRANSPORT_OUT:
+    case E_CHANGE_TILE:
+    case E_ROTATE:
+      return(0);
+    case E_MOVE:
+    case E_MELEE:
+      return(steps);
+    case E_RANGE: {
+      Mcrd a = id2unit(e.e.range.a)->m;
+      Mcrd b = id2unit(e.e.range.d)->m;
+      return(mdist(a, b) * steps / 2);
+    }
+    default:
+      die("ui_sdl: get_last_event_index(): "
+          "unknow event '%d'.\n", e.t);
   }
-  return(n);
+  return(0);
 }
 
 static void