From 0806a1ef751ddc7da59b3fc0ba33a1e74b69b659 Mon Sep 17 00:00:00 2001 From: truelight Date: Wed, 11 Aug 2004 21:35:52 +0000 Subject: (svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL --- settings_gui.c | 104 ++++++++++++++++++++++++--------------------------------- 1 file changed, 43 insertions(+), 61 deletions(-) (limited to 'settings_gui.c') diff --git a/settings_gui.c b/settings_gui.c index 6d5be51c3..9a654a654 100644 --- 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_vehicles[] = { {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(Window *w, WindowEvent *e) 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(Window *w, WindowEvent *e) case PE_BOOL: val ^= 1; break; - case PE_BYTE: - val ^= pe->min; - break; case PE_UINT8: case PE_INT16: case PE_UINT16: -- cgit v1.2.3-54-g00ecf