Changeset - r20:996ccedb10a0
[Not reviewed]
master
0 4 0
truelight - 20 years ago 2004-08-11 21:35:52
truelight@openttd.org
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
4 files changed with 55 insertions and 77 deletions:
0 comments (0 inline, 0 general)
ai.c
Show inline comments
 
@@ -1491,26 +1491,23 @@ static void AiStateWantNewRoute(Player *
 
	i = 200;
 
	for(;;) {
 
		byte dis;
 

	
 
		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);
 
		}
 
		
 
		// got a route?
 
		if (p->ai.state != AIS_WANT_NEW_ROUTE)
 
			break;
settings.c
Show inline comments
 
@@ -842,13 +842,16 @@ static const SettingDesc patch_settings[
 
	{"new_pathfinding",  SDT_BOOL, (void*)false, (void*)offsetof(Patches, new_pathfinding)},
 
	{"pf_maxlength", SDT_UINT16, (void*)512, (void*)offsetof(Patches, pf_maxlength)},
 
	{"pf_maxdepth", SDT_UINT8, (void*)16, (void*)offsetof(Patches, pf_maxdepth)},
 

	
 
	{"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)},
 

	
 
	{"bridge_pillars",  SDT_BOOL, (void*)true, (void*)offsetof(Patches, bridge_pillars)},
 

	
settings_gui.c
Show inline comments
 
@@ -666,13 +666,12 @@ typedef struct PatchEntry {
 
enum {
 
	PE_BOOL = 0,
 
	PE_UINT8 = 1,
 
	PE_INT16 = 2,
 
	PE_UINT16 = 3,
 
	PE_INT32 = 4,
 
	PE_BYTE = 5,
 

	
 
	PF_0ISDIS = 1,
 
	PF_NOCOMMA = 2,
 
};
 

	
 
static const PatchEntry _patches_ui[] = {
 
@@ -716,16 +715,16 @@ static const PatchEntry _patches_vehicle
 

	
 
	{PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_SERVINT_TRAINS, &_patches.servint_trains, 30, 1200, 10},
 
	{PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_SERVINT_ROADVEH, &_patches.servint_roadveh, 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_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[] = {
 
	{PE_BOOL, 0, STR_CONFIG_PATCHES_JOINSTATIONS, &_patches.join_stations},
 
	{PE_BOOL, 0, STR_CONFIG_PATCHES_FULLLOADANY, &_patches.full_load_any},
 
	{PE_BOOL, 0, STR_CONFIG_PATCHES_SELECTGOODS, &_patches.selectgoods},
 
@@ -767,67 +766,59 @@ static int32 ReadPE(const PatchEntry*pe)
 
	switch(pe->type) {
 
	case PE_BOOL:   return *(bool*)pe->variable;
 
	case PE_UINT8:  return *(uint8*)pe->variable;
 
	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();
 
	}
 
  
 
	/* useless, but avoids compiler warning this way */
 
	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)
 
{
 
	uint i;
 
	switch(e->event) {
 
@@ -848,18 +839,12 @@ static void PatchesSelectionWndProc(Wind
 
		page = &_patches_page[WP(w,def_d).data_1];
 
		for(i=0,pe=page->entries; i!=page->num; i++,pe++) {
 
			bool disabled = false;
 
			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);
 
				DrawStringCentered(x+10, y+1, STR_6819, 0);
 
				DrawStringCentered(x+20, y+1, STR_681A, 0);
 

	
 
@@ -903,15 +888,12 @@ static void PatchesSelectionWndProc(Wind
 
				int32 val = ReadPE(pe), oval = val;
 

	
 
				switch(pe->type) {
 
				case PE_BOOL:
 
					val ^= 1;
 
					break;
 
				case PE_BYTE:
 
					val ^= pe->min;
 
					break;
 
				case PE_UINT8:
 
				case PE_INT16:
 
				case PE_UINT16:
 
				case PE_INT32:
 
					// don't allow too fast scrolling
 
					if ((w->flags4 & WF_TIMEOUT_MASK) > 2 << WF_TIMEOUT_SHL) {
variables.h
Show inline comments
 
@@ -126,13 +126,16 @@ typedef struct Patches {
 
	byte pf_maxdepth;				// maximum recursion depth when searching for a train route for new pathfinder
 
	uint16 pf_maxlength;		// maximum length when searching for a train route for new pathfinder
 

	
 
	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?
 

	
 
	bool keep_all_autosave;		// name the autosave in a different way.
 
	bool extra_dynamite;			// extra dynamite
 

	
 
@@ -146,19 +149,12 @@ typedef struct Patches {
 

	
 
	byte wait_oneway_signal;	//waitingtime in days before a oneway signal
 
	byte wait_twoway_signal;	//waitingtime in days before a twoway signal
 

	
 
} Patches;
 

	
 
enum {
 
	DISABLE_TRAINS = 1<<0,
 
	DISABLE_ROADVEH = 1 << 1,
 
	DISABLE_AIRCRAFT = 1 << 2,
 
	DISABLE_SHIPS = 1 << 3,
 
};
 

	
 
VARDEF Patches _patches;
 

	
 

	
 
typedef struct Cheat {
 
	bool been_used;	// has this cheat been used before?
 
	byte value;			// active?
0 comments (0 inline, 0 general)