1
0
Fork 0

(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL

release/0.4.5
truelight 2004-08-11 21:35:52 +00:00
parent 6f8e7943c5
commit 0806a1ef75
4 changed files with 55 additions and 77 deletions

11
ai.c
View File

@ -1494,20 +1494,17 @@ static void AiStateWantNewRoute(Player *p)
r = (uint16)Random(); r = (uint16)Random();
dis = _patches.ai_disable_veh;
if ((dis & 0xF) == 0xF) return; // no available vehicles at all?
if (r < 0x7626) { if (r < 0x7626) {
if (dis&DISABLE_TRAINS) continue; if (_patches.ai_disable_veh_train) continue;
AiWantTrainRoute(p); AiWantTrainRoute(p);
} else if (r < 0xC4EA) { } else if (r < 0xC4EA) {
if (dis&DISABLE_ROADVEH) continue; if (_patches.ai_disable_veh_roadveh) continue;
AiWantRoadRoute(p); AiWantRoadRoute(p);
} else if (r < 0xD89B) { } else if (r < 0xD89B) {
if (dis&DISABLE_AIRCRAFT) continue; if (_patches.ai_disable_veh_aircraft) continue;
AiWantAircraftRoute(p); AiWantAircraftRoute(p);
} else { } else {
if (dis&DISABLE_SHIPS) continue; if (_patches.ai_disable_veh_ship) continue;
AiWantShipRoute(p); AiWantShipRoute(p);
} }

View File

@ -845,7 +845,10 @@ static const SettingDesc patch_settings[] = {
{"build_in_pause", SDT_BOOL, (void*)false, (void*)offsetof(Patches, build_in_pause)}, {"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)}, {"starting_date", SDT_UINT32, (void*)1950, (void*)offsetof(Patches, starting_date)},
{"colored_news_date", SDT_UINT32, (void*)2000, (void*)offsetof(Patches, colored_news_date)}, {"colored_news_date", SDT_UINT32, (void*)2000, (void*)offsetof(Patches, colored_news_date)},

View File

@ -669,7 +669,6 @@ enum {
PE_INT16 = 2, PE_INT16 = 2,
PE_UINT16 = 3, PE_UINT16 = 3,
PE_INT32 = 4, PE_INT32 = 4,
PE_BYTE = 5,
PF_0ISDIS = 1, PF_0ISDIS = 1,
PF_NOCOMMA = 2, PF_NOCOMMA = 2,
@ -719,10 +718,10 @@ static const PatchEntry _patches_vehicles[] = {
{PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_SERVINT_AIRCRAFT, &_patches.servint_aircraft, 30, 1200, 10}, {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_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_BOOL, 0, STR_CONFIG_PATCHES_AI_BUILDS_TRAINS, &_patches.ai_disable_veh_train},
{PE_BYTE, 0, STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH, &_patches.ai_disable_veh, 0x02}, {PE_BOOL, 0, STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH, &_patches.ai_disable_veh_roadveh},
{PE_BYTE, 0, STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT, &_patches.ai_disable_veh, 0x04}, {PE_BOOL, 0, STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT, &_patches.ai_disable_veh_aircraft},
{PE_BYTE, 0, STR_CONFIG_PATCHES_AI_BUILDS_SHIPS, &_patches.ai_disable_veh, 0x08}, {PE_BOOL, 0, STR_CONFIG_PATCHES_AI_BUILDS_SHIPS, &_patches.ai_disable_veh_ship},
}; };
static const PatchEntry _patches_stations[] = { static const PatchEntry _patches_stations[] = {
@ -770,7 +769,6 @@ static int32 ReadPE(const PatchEntry*pe)
case PE_INT16: return *(int16*)pe->variable; case PE_INT16: return *(int16*)pe->variable;
case PE_UINT16: return *(uint16*)pe->variable; case PE_UINT16: return *(uint16*)pe->variable;
case PE_INT32: return *(int32*)pe->variable; case PE_INT32: return *(int32*)pe->variable;
case PE_BYTE: return *(byte*)pe->variable;
default: default:
NOT_REACHED(); NOT_REACHED();
} }
@ -783,13 +781,6 @@ static void WritePE(const PatchEntry *pe, int32 val)
{ {
switch(pe->type) { switch(pe->type) {
case PE_BOOL: *(bool*)pe->variable = (bool)val; break; 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) case PE_UINT8: if ((uint8)val > (uint8)pe->max)
*(uint8*)pe->variable = (uint8)pe->max; *(uint8*)pe->variable = (uint8)pe->max;
@ -851,12 +842,6 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
if (pe->type == PE_BOOL) { 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); 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); 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 { } else {
DrawFrameRect(x+5, y+1, x+5+9, y+9, 3, clk == i*2+1 ? 0x20 : 0); 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); DrawFrameRect(x+15, y+1, x+15+9, y+9, 3, clk == i*2+2 ? 0x20 : 0);
@ -906,9 +891,6 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
case PE_BOOL: case PE_BOOL:
val ^= 1; val ^= 1;
break; break;
case PE_BYTE:
val ^= pe->min;
break;
case PE_UINT8: case PE_UINT8:
case PE_INT16: case PE_INT16:
case PE_UINT16: case PE_UINT16:

View File

@ -129,7 +129,10 @@ typedef struct Patches {
bool build_in_pause; // build while in pause mode bool build_in_pause; // build while in pause mode
bool bridge_pillars; // show bridge pillars for high bridges 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 starting_date; // starting date
uint32 colored_news_date; // when does newspaper become colored? uint32 colored_news_date; // when does newspaper become colored?
@ -149,13 +152,6 @@ typedef struct Patches {
} Patches; } Patches;
enum {
DISABLE_TRAINS = 1<<0,
DISABLE_ROADVEH = 1 << 1,
DISABLE_AIRCRAFT = 1 << 2,
DISABLE_SHIPS = 1 << 3,
};
VARDEF Patches _patches; VARDEF Patches _patches;