mirror of https://github.com/OpenTTD/OpenTTD
(svn r6258) Reduce the number of induction variables and inner scopes for clarity
parent
cd8f1cc63d
commit
32d26ef6b8
|
@ -469,51 +469,42 @@ void ShowRoadVehViewWindow(const Vehicle *v)
|
||||||
|
|
||||||
static void DrawNewRoadVehWindow(Window *w)
|
static void DrawNewRoadVehWindow(Window *w)
|
||||||
{
|
{
|
||||||
if (w->window_number == 0)
|
EngineID selected_id;
|
||||||
w->disabled_state = 1 << 5;
|
EngineID e;
|
||||||
|
uint count;
|
||||||
|
int pos;
|
||||||
|
int sel;
|
||||||
|
int y;
|
||||||
|
|
||||||
// setup scroller
|
if (w->window_number == 0) w->disabled_state = 1 << 5;
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
int num = NUM_ROAD_ENGINES;
|
|
||||||
const Engine *e = GetEngine(ROAD_ENGINES_INDEX);
|
|
||||||
|
|
||||||
do {
|
count = 0;
|
||||||
if (HASBIT(e->player_avail, _local_player))
|
for (e = ROAD_ENGINES_INDEX; e < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; e++) {
|
||||||
count++;
|
if (HASBIT(GetEngine(e)->player_avail, _local_player)) count++;
|
||||||
} while (++e,--num);
|
|
||||||
SetVScrollCount(w, count);
|
|
||||||
}
|
}
|
||||||
|
SetVScrollCount(w, count);
|
||||||
|
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
|
|
||||||
{
|
y = 15;
|
||||||
int num = NUM_ROAD_ENGINES;
|
sel = WP(w,buildtrain_d).sel_index;
|
||||||
const Engine *e = GetEngine(ROAD_ENGINES_INDEX);
|
pos = w->vscroll.pos;
|
||||||
int x = 1;
|
selected_id = INVALID_ENGINE;
|
||||||
int y = 15;
|
for (e = ROAD_ENGINES_INDEX; e < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; e++) {
|
||||||
int sel = WP(w,buildtrain_d).sel_index;
|
if (!HASBIT(GetEngine(e)->player_avail, _local_player)) continue;
|
||||||
int pos = w->vscroll.pos;
|
if (sel == 0) selected_id = e;
|
||||||
EngineID engine_id = ROAD_ENGINES_INDEX;
|
|
||||||
EngineID selected_id = INVALID_ENGINE;
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (HASBIT(e->player_avail, _local_player)) {
|
|
||||||
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+59, y+2, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10);
|
DrawString(60, y + 2, GetCustomEngineName(e), sel == 0 ? 0xC : 0x10);
|
||||||
DrawRoadVehEngine(x+29, y+6, engine_id, GetEnginePalette(engine_id, _local_player));
|
DrawRoadVehEngine(30, y + 6, e, GetEnginePalette(e, _local_player));
|
||||||
y += 14;
|
y += 14;
|
||||||
}
|
}
|
||||||
sel--;
|
sel--;
|
||||||
}
|
}
|
||||||
} while (++engine_id, ++e,--num);
|
|
||||||
|
|
||||||
WP(w,buildtrain_d).sel_engine = selected_id;
|
WP(w,buildtrain_d).sel_engine = selected_id;
|
||||||
if (selected_id != INVALID_ENGINE) {
|
if (selected_id != INVALID_ENGINE) {
|
||||||
DrawRoadVehPurchaseInfo(2, w->widget[4].top + 1, selected_id);
|
DrawRoadVehPurchaseInfo(2, w->widget[4].top + 1, selected_id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
|
|
Loading…
Reference in New Issue