1
0
Fork 0

(svn r3654) Turn another if-cascade into a switch

release/0.5
tron 2006-02-22 21:35:45 +00:00
parent 9a364389cb
commit ae02bd6506
1 changed files with 26 additions and 28 deletions

View File

@ -336,36 +336,34 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
_error_message = STR_5009_LEVEL_LAND_OR_WATER_REQUIRED; _error_message = STR_5009_LEVEL_LAND_OR_WATER_REQUIRED;
if (ti.tileh != 0 && ti.z >= ti_start.z) return CMD_ERROR; if (ti.tileh != 0 && ti.z >= ti_start.z) return CMD_ERROR;
// Find ship below switch (ti.type){
if (ti.type == MP_WATER && !EnsureNoVehicle(ti.tile)) { case MP_WATER:
_error_message = STR_980E_SHIP_IN_THE_WAY; if (!EnsureNoVehicle(ti.tile)) {
return CMD_ERROR; _error_message = STR_980E_SHIP_IN_THE_WAY;
} return CMD_ERROR;
}
if (ti.map5 > 1) goto not_valid_below;
m5 = 0xC8;
break;
if (ti.type == MP_WATER) { case MP_RAILWAY:
if (ti.map5 > 1) goto not_valid_below; if (ti.map5 != (direction == 0 ? 2 : 1)) goto not_valid_below;
m5 = 0xC8; m5 = 0xE0;
} else if (ti.type == MP_RAILWAY) { break;
if (direction == 0) {
if (ti.map5 != 2) goto not_valid_below; case MP_STREET:
} else { if (ti.map5 != (direction == 0 ? 5 : 10)) goto not_valid_below;
if (ti.map5 != 1) goto not_valid_below; m5 = 0xE8;
} break;
m5 = 0xE0;
} else if (ti.type == MP_STREET) { default:
if (direction == 0) {
if (ti.map5 != 5) goto not_valid_below;
} else {
if (ti.map5 != 10) goto not_valid_below;
}
m5 = 0xE8;
} else {
not_valid_below:; not_valid_below:;
/* try and clear the middle landscape */ /* try and clear the middle landscape */
ret = DoCommandByTile(ti.tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); ret = DoCommandByTile(ti.tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR; if (CmdFailed(ret)) return CMD_ERROR;
cost += ret; cost += ret;
m5 = 0xC0; m5 = 0xC0;
break;
} }
/* do middle part of bridge */ /* do middle part of bridge */