diff --git a/ai.c b/ai.c --- a/ai.c +++ b/ai.c @@ -1494,20 +1494,17 @@ static void AiStateWantNewRoute(Player * r = (uint16)Random(); - dis = _patches.ai_disable_veh; - if ((dis & 0xF) == 0xF) return; // no available vehicles at all? - if (r < 0x7626) { - if (dis&DISABLE_TRAINS) continue; + if (_patches.ai_disable_veh_train) continue; AiWantTrainRoute(p); } else if (r < 0xC4EA) { - if (dis&DISABLE_ROADVEH) continue; + if (_patches.ai_disable_veh_roadveh) continue; AiWantRoadRoute(p); } else if (r < 0xD89B) { - if (dis&DISABLE_AIRCRAFT) continue; + if (_patches.ai_disable_veh_aircraft) continue; AiWantAircraftRoute(p); } else { - if (dis&DISABLE_SHIPS) continue; + if (_patches.ai_disable_veh_ship) continue; AiWantShipRoute(p); } diff --git a/settings.c b/settings.c --- a/settings.c +++ b/settings.c @@ -845,7 +845,10 @@ static const SettingDesc patch_settings[ {"build_in_pause", SDT_BOOL, (void*)false, (void*)offsetof(Patches, build_in_pause)}, - {"ai_disable_veh", SDT_UINT8, (void*)0, (void*)offsetof(Patches, ai_disable_veh)}, + {"ai_disable_veh_train", SDT_BOOL, (void*)false, (void*)offsetof(Patches, ai_disable_veh_train)}, + {"ai_disable_veh_roadveh", SDT_BOOL, (void*)false, (void*)offsetof(Patches, ai_disable_veh_roadveh)}, + {"ai_disable_veh_aircraft", SDT_BOOL, (void*)false, (void*)offsetof(Patches, ai_disable_veh_aircraft)}, + {"ai_disable_veh_ship", SDT_BOOL, (void*)false, (void*)offsetof(Patches, ai_disable_veh_ship)}, {"starting_date", SDT_UINT32, (void*)1950, (void*)offsetof(Patches, starting_date)}, {"colored_news_date", SDT_UINT32, (void*)2000, (void*)offsetof(Patches, colored_news_date)}, diff --git a/settings_gui.c b/settings_gui.c --- a/settings_gui.c +++ b/settings_gui.c @@ -669,7 +669,6 @@ enum { PE_INT16 = 2, PE_UINT16 = 3, PE_INT32 = 4, - PE_BYTE = 5, PF_0ISDIS = 1, PF_NOCOMMA = 2, @@ -719,10 +718,10 @@ static const PatchEntry _patches_vehicle {PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_SERVINT_AIRCRAFT, &_patches.servint_aircraft, 30, 1200, 10}, {PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_SERVINT_SHIPS, &_patches.servint_ships, 30, 1200, 10}, - {PE_BYTE, 0, STR_CONFIG_PATCHES_AI_BUILDS_TRAINS, &_patches.ai_disable_veh, 0x01}, - {PE_BYTE, 0, STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH, &_patches.ai_disable_veh, 0x02}, - {PE_BYTE, 0, STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT, &_patches.ai_disable_veh, 0x04}, - {PE_BYTE, 0, STR_CONFIG_PATCHES_AI_BUILDS_SHIPS, &_patches.ai_disable_veh, 0x08}, + {PE_BOOL, 0, STR_CONFIG_PATCHES_AI_BUILDS_TRAINS, &_patches.ai_disable_veh_train}, + {PE_BOOL, 0, STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH, &_patches.ai_disable_veh_roadveh}, + {PE_BOOL, 0, STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT, &_patches.ai_disable_veh_aircraft}, + {PE_BOOL, 0, STR_CONFIG_PATCHES_AI_BUILDS_SHIPS, &_patches.ai_disable_veh_ship}, }; static const PatchEntry _patches_stations[] = { @@ -770,7 +769,6 @@ static int32 ReadPE(const PatchEntry*pe) case PE_INT16: return *(int16*)pe->variable; case PE_UINT16: return *(uint16*)pe->variable; case PE_INT32: return *(int32*)pe->variable; - case PE_BYTE: return *(byte*)pe->variable; default: NOT_REACHED(); } @@ -779,52 +777,45 @@ static int32 ReadPE(const PatchEntry*pe) return 0; } -static void WritePE(const PatchEntry *pe, int32 val) -{ - switch(pe->type) { - case PE_BOOL: *(bool*)pe->variable = (bool)val; break; - case PE_BYTE: if ((byte)val > (byte)pe->max) - *(byte*)pe->variable = (byte)pe->max; - else if ((byte)val < (byte)pe->min) - *(byte*)pe->variable = (byte)pe->min; - else - *(byte*)pe->variable = (byte)val; - break; - - case PE_UINT8: if ((uint8)val > (uint8)pe->max) - *(uint8*)pe->variable = (uint8)pe->max; - else if ((uint8)val < (uint8)pe->min) - *(uint8*)pe->variable = (uint8)pe->min; - else - *(uint8*)pe->variable = (uint8)val; - break; - - case PE_INT16: if ((int16)val > (int16)pe->max) - *(int16*)pe->variable = (int16)pe->max; - else if ((int16)val < (int16)pe->min) - *(int16*)pe->variable = (int16)pe->min; - else - *(int16*)pe->variable = (int16)val; - break; - - case PE_UINT16: if ((uint16)val > (uint16)pe->max) - *(uint16*)pe->variable = (uint16)pe->max; - else if ((uint16)val < (uint16)pe->min) - *(uint16*)pe->variable = (uint16)pe->min; - else - *(uint16*)pe->variable = (uint16)val; - break; - - case PE_INT32: if ((int32)val > (int32)pe->max) - *(int32*)pe->variable = (int32)pe->max; - else if ((int32)val < (int32)pe->min) - *(int32*)pe->variable = (int32)pe->min; - else - *(int32*)pe->variable = val; - break; - default: - NOT_REACHED(); - } +static void WritePE(const PatchEntry *pe, int32 val) +{ + switch(pe->type) { + case PE_BOOL: *(bool*)pe->variable = (bool)val; break; + + case PE_UINT8: if ((uint8)val > (uint8)pe->max) + *(uint8*)pe->variable = (uint8)pe->max; + else if ((uint8)val < (uint8)pe->min) + *(uint8*)pe->variable = (uint8)pe->min; + else + *(uint8*)pe->variable = (uint8)val; + break; + + case PE_INT16: if ((int16)val > (int16)pe->max) + *(int16*)pe->variable = (int16)pe->max; + else if ((int16)val < (int16)pe->min) + *(int16*)pe->variable = (int16)pe->min; + else + *(int16*)pe->variable = (int16)val; + break; + + case PE_UINT16: if ((uint16)val > (uint16)pe->max) + *(uint16*)pe->variable = (uint16)pe->max; + else if ((uint16)val < (uint16)pe->min) + *(uint16*)pe->variable = (uint16)pe->min; + else + *(uint16*)pe->variable = (uint16)val; + break; + + case PE_INT32: if ((int32)val > (int32)pe->max) + *(int32*)pe->variable = (int32)pe->max; + else if ((int32)val < (int32)pe->min) + *(int32*)pe->variable = (int32)pe->min; + else + *(int32*)pe->variable = val; + break; + default: + NOT_REACHED(); + } } static void PatchesSelectionWndProc(Window *w, WindowEvent *e) @@ -851,12 +842,6 @@ static void PatchesSelectionWndProc(Wind if (pe->type == PE_BOOL) { DrawFrameRect(x+5, y+1, x+15+9, y+9, (*(bool*)pe->variable)?6:4, (*(bool*)pe->variable)?0x20:0); SET_DPARAM16(0, *(bool*)pe->variable ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); - } else if (pe->type == PE_BYTE) { - bool enabled; - val = ReadPE(pe); - enabled = (byte)val & (byte)pe->min; - DrawFrameRect(x+5, y+1, x+15+9, y+9, enabled?6:4, enabled?0x20:0); - SET_DPARAM16(0, enabled ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); } else { DrawFrameRect(x+5, y+1, x+5+9, y+9, 3, clk == i*2+1 ? 0x20 : 0); DrawFrameRect(x+15, y+1, x+15+9, y+9, 3, clk == i*2+2 ? 0x20 : 0); @@ -906,9 +891,6 @@ static void PatchesSelectionWndProc(Wind case PE_BOOL: val ^= 1; break; - case PE_BYTE: - val ^= pe->min; - break; case PE_UINT8: case PE_INT16: case PE_UINT16: diff --git a/variables.h b/variables.h --- a/variables.h +++ b/variables.h @@ -129,7 +129,10 @@ typedef struct Patches { bool build_in_pause; // build while in pause mode bool bridge_pillars; // show bridge pillars for high bridges - byte ai_disable_veh; // mask of vehicle types to disable for ai + bool ai_disable_veh_train; // disable types for AI + bool ai_disable_veh_roadveh; // disable types for AI + bool ai_disable_veh_aircraft; // disable types for AI + bool ai_disable_veh_ship; // disable types for AI uint32 starting_date; // starting date uint32 colored_news_date; // when does newspaper become colored? @@ -149,13 +152,6 @@ typedef struct Patches { } Patches; -enum { - DISABLE_TRAINS = 1<<0, - DISABLE_ROADVEH = 1 << 1, - DISABLE_AIRCRAFT = 1 << 2, - DISABLE_SHIPS = 1 << 3, -}; - VARDEF Patches _patches;