1
0
Fork 0

(svn r6205) -CodeChange : use a switch case instead of a cascade of if

-CodeChange : rename var Engine *e to Engine *eng, since we have WindowEvent *e in same fnct
-CodeChange : fix a broken tabulation on a switch case. SOme breathing spaces too
release/0.5
belugas 2006-08-29 00:17:47 +00:00
parent 27cee58ab8
commit 5771cd10f9
3 changed files with 112 additions and 104 deletions

View File

@ -233,16 +233,24 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
case WE_PLACE_DRAG: { case WE_PLACE_DRAG: {
int sel_method; int sel_method;
if (e->place.userdata == 1) { switch (e->place.userdata) {
case 1:
sel_method = VPM_FIX_X; sel_method = VPM_FIX_X;
_place_road_flag = (_place_road_flag & ~2) | ((e->place.pt.y & 8) >> 2); _place_road_flag = (_place_road_flag & ~2) | ((e->place.pt.y & 8) >> 2);
} else if (e->place.userdata == 2) { break;
case 2:
sel_method = VPM_FIX_Y; sel_method = VPM_FIX_Y;
_place_road_flag = (_place_road_flag & ~2) | ((e->place.pt.x & 8) >> 2); _place_road_flag = (_place_road_flag & ~2) | ((e->place.pt.x & 8) >> 2);
} else if (e->place.userdata == 4) { break;
case 4:
sel_method = VPM_X_AND_Y; sel_method = VPM_X_AND_Y;
} else { break;
default:
sel_method = VPM_X_OR_Y; sel_method = VPM_X_OR_Y;
break;
} }
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, sel_method); VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, sel_method);

View File

@ -328,11 +328,11 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
{ {
int count = 0; int count = 0;
int num = NUM_SHIP_ENGINES; int num = NUM_SHIP_ENGINES;
const Engine *e = GetEngine(SHIP_ENGINES_INDEX); const Engine *eng = GetEngine(SHIP_ENGINES_INDEX);
do { do {
if (HASBIT(e->player_avail, _local_player)) count++; if (HASBIT(eng->player_avail, _local_player)) count++;
} while (++e,--num); } while (++eng,--num);
SetVScrollCount(w, count); SetVScrollCount(w, count);
} }
@ -340,7 +340,7 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
{ {
int num = NUM_SHIP_ENGINES; int num = NUM_SHIP_ENGINES;
const Engine *e = GetEngine(SHIP_ENGINES_INDEX); const Engine *eng = GetEngine(SHIP_ENGINES_INDEX);
int x = 2; int x = 2;
int y = 15; int y = 15;
int sel = WP(w,buildtrain_d).sel_index; int sel = WP(w,buildtrain_d).sel_index;
@ -349,7 +349,7 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
EngineID selected_id = INVALID_ENGINE; EngineID selected_id = INVALID_ENGINE;
do { do {
if (HASBIT(e->player_avail, _local_player)) { if (HASBIT(eng->player_avail, _local_player)) {
if (sel==0) selected_id = engine_id; if (sel==0) selected_id = engine_id;
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
DrawString(x+75, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10); DrawString(x+75, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10);
@ -358,7 +358,7 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
} }
sel--; sel--;
} }
} while (++engine_id, ++e,--num); } while (++engine_id, ++eng,--num);
WP(w,buildtrain_d).sel_engine = selected_id; WP(w,buildtrain_d).sel_engine = selected_id;