Changeset - r222:4409829eb08f
[Not reviewed]
master
1 39 0
darkvater - 20 years ago 2004-09-12 21:49:38
darkvater@openttd.org
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
-CodeLayout: Remove trailing spaces and Windows linebreaks
25 files changed with 114 insertions and 118 deletions:
0 comments (0 inline, 0 general)
airport.c
Show inline comments
 
@@ -85,13 +85,13 @@ static void AirportFTAClass_Constructor(
 
	Airport->nofterminals = nofterminals;
 
	Airport->nofterminalgroups = nofterminalgroups;
 
	Airport->nofhelipads = nofhelipads;
 
	Airport->nofhelipadgroups = nofhelipadgroups;
 
	Airport->acc_planes = acc_planes;
 
	Airport->entry_point = entry_point;
 
	Airport->airport_depots = (uint16*)depots;
 
	Airport->airport_depots = (const uint16*)depots;
 

	
 

	
 
	// build the state machine
 
	AirportBuildAutomata(Airport, FA);
 
		DEBUG(misc, 1) ("#Elements %2d; #Terminals %2d in %d group(s); #Helipads %2d in %d group(s)", Airport->nofelements,
 
				  Airport->nofterminals, Airport->nofterminalgroups, Airport->nofhelipads, Airport->nofhelipadgroups);
airport.h
Show inline comments
 
@@ -29,13 +29,13 @@ typedef struct AirportFTAClass {
 
	byte nofterminals;					// number of terminals this airport has
 
	byte nofterminalgroups;			// terminals belong to so many groups (MAX is the nofterminals)
 
	byte nofhelipads;						// number of helipads this airport has
 
	byte nofhelipadgroups;			// helipads belong to so many groups (MAX is the nofhelipads)
 
	byte entry_point;						// when an airplane arrives at this airport, enter it at position entry_point
 
	byte acc_planes;						// accept airplanes or helicopters or both
 
	uint16 *airport_depots;			// gives the position of the depots on the airports
 
	const uint16 *airport_depots;	// gives the position of the depots on the airports
 
	struct AirportFTA *layout;	// state machine for airport
 
} AirportFTAClass;
 

	
 
// internal structure used in openttd - Finite sTate mAchine --> FTA
 
typedef struct AirportFTA {
 
	byte position;										// the position that an airplane is at
console.c
Show inline comments
 
@@ -204,15 +204,15 @@ void IConsoleInit()
 
	for (i=0;i<80;i++) {
 
		_iconsole_buffer[i]=NULL;
 
		_iconsole_cbuffer[i]=0;
 
		}
 
	IConsoleStdLibRegister();
 
	#if defined(WITH_REV)
 
	IConsolePrintF(13,"OpenTTD Game Console Revision 3 - %s",_openttd_revision);
 
	IConsolePrintF(13,"OpenTTD Game Console Revision 4 - %s",_openttd_revision);
 
	#else
 
	IConsolePrint(13,"OpenTTD Game Console Revision 3");
 
	IConsolePrint(13,"OpenTTD Game Console Revision 4");
 
	#endif
 
	IConsolePrint(12,"---------------------------------");
 
	IConsolePrint(12,"use \"help\" for more info");
 
	IConsolePrint(12,"");
 
	IConsoleClearCommand();
 
	IConsoleCmdBufferAdd("");
 
@@ -266,22 +266,22 @@ void IConsoleClose()
 

	
 
void IConsoleOpen()
 
{
 
	if (_iconsole_mode==ICONSOLE_CLOSED) IConsoleSwitch();
 
}
 

	
 
void IConsoleCmdBufferAdd(byte * cmd)
 
void IConsoleCmdBufferAdd(const byte * cmd)
 
{
 
	int i;
 
	if (_iconsole_cmdbufferpos != 19) return;
 
	if (_iconsole_cmdbuffer[18]!=NULL) free(_iconsole_cmdbuffer[18]);
 
	for (i=18; i>0; i--) _iconsole_cmdbuffer[i]=_iconsole_cmdbuffer[i-1];
 
	i=strlen((char *)cmd);
 
	i=strlen(cmd);
 
	_iconsole_cmdbuffer[0]=malloc(i+1);
 
	memset(((void *)_iconsole_cmdbuffer[0]),0,i+1);
 
	memcpy(((void *)_iconsole_cmdbuffer[0]),(void *)cmd,i);
 
	memcpy(((void *)_iconsole_cmdbuffer[0]),cmd,i);
 
	_iconsole_cmdbuffer[0][i]=0;
 
	_iconsole_cmdbufferpos = 19;
 
}
 

	
 
void IConsoleCmdBufferNavigate(signed char direction)
 
{
 
@@ -300,24 +300,24 @@ void IConsoleCmdBufferNavigate(signed ch
 
	_iconsole_cmdbufferpos = i;
 
	IConsoleClearCommand();
 
	memcpy((void *)_iconsole_cmdline,(void *)_iconsole_cmdbuffer[i],strlen(_iconsole_cmdbuffer[i]));
 
	_iconsole_cmdpos =strlen(_iconsole_cmdbuffer[i]);
 
}
 

	
 
void IConsolePrint(byte color_code, byte* string)
 
void IConsolePrint(byte color_code, const byte* string)
 
{
 
	byte * _ex;
 
	byte * _new;
 
	byte _exc;
 
	byte _newc;
 
	int i,j;
 

	
 
	if (!_iconsole_inited) return;
 

	
 
	_newc=color_code;
 
	i=strlen((char *)string);
 
	i=strlen(string);
 
	_new=malloc(i+1);
 
	memset(_new,0,i+1);
 
	memcpy(_new,string,i);
 

	
 
	for (j=0;j<i;j++) {
 
		if (_new[j]<0x1F) _new[j]=0x20;
 
@@ -351,25 +351,25 @@ void CDECL IConsolePrintF(byte color_cod
 

	
 
void IConsoleDebug(byte* string)
 
{
 
	if (_stdlib_developer>1) IConsolePrintF(_iconsole_color_debug, "DEBUG: %s", string);
 
}
 

	
 
void IConsoleError(byte* string)
 
void IConsoleError(const byte* string)
 
{
 
	if (_stdlib_developer>0) IConsolePrintF(_iconsole_color_error, "ERROR: %s", string);
 
}
 

	
 
void IConsoleCmdRegister(byte * name, void * addr)
 
void IConsoleCmdRegister(const byte * name, void * addr)
 
{
 
	byte * _new;
 
	_iconsole_cmd * item;
 
	_iconsole_cmd * item_new;
 
	int i;
 

	
 
		i=strlen((char *)name);
 
	i=strlen(name);
 
		_new=malloc(i+1);
 
		memset(_new,0,i+1);
 
		memcpy(_new,name,i);
 

	
 
	item_new = malloc(sizeof(_iconsole_cmd));
 

	
 
@@ -387,32 +387,32 @@ void IConsoleCmdRegister(byte * name, vo
 
		} else {
 
		while (item->_next != NULL) { item = item->_next; };
 
		item->_next = item_new;
 
		}
 
}
 

	
 
void* IConsoleCmdGet(byte * name)
 
void* IConsoleCmdGet(const byte * name)
 
{
 
	_iconsole_cmd * item;
 

	
 
	item = _iconsole_cmds;
 
	while (item != NULL) {
 
		if (strcmp(item->name,name)==0) return item;
 
		item = item->_next;
 
		}
 
	return NULL;
 
}
 

	
 
void IConsoleVarRegister(byte * name, void * addr, byte type)
 
void IConsoleVarRegister(const byte * name, void * addr, byte type)
 
{
 
	byte * _new;
 
	_iconsole_var * item;
 
	_iconsole_var * item_new;
 
	int i;
 

	
 
		i=strlen((char *)name)+1;
 
	i=strlen(name)+1;
 
		_new=malloc(i+1);
 
		memset(_new,0,i+1);
 
		_new[0]='*';
 
		memcpy(_new+1,name,i);
 

	
 
	item_new = malloc(sizeof(_iconsole_var));
 
@@ -433,33 +433,33 @@ void IConsoleVarRegister(byte * name, vo
 
		} else {
 
		while (item->_next != NULL) { item = item->_next; };
 
		item->_next = item_new;
 
		}
 
}
 

	
 
void IConsoleVarMemRegister(byte * name, byte type)
 
void IConsoleVarMemRegister(byte * name, byte type) /* XXX TRON */
 
{
 
	_iconsole_var * item;
 
	item = IConsoleVarAlloc(type);
 
	IConsoleVarInsert(item,name);
 
}
 

	
 

	
 
void IConsoleVarInsert(_iconsole_var * var, byte * name)
 
void IConsoleVarInsert(_iconsole_var * var, const byte * name)
 
{
 
	byte * _new;
 
	_iconsole_var * item;
 
	_iconsole_var * item_new;
 
	int i;
 

	
 
	item_new = var;
 

	
 
	// dont allow to build variable rings
 
	if (item_new->_next != NULL) return;
 

	
 
		i=strlen((char *)name)+1;
 
	i=strlen(name)+1;
 
		_new=malloc(i+1);
 
		memset(_new,0,i+1);
 
		_new[0]='*';
 
		memcpy(_new+1,name,i);
 

	
 
	item_new->name  = _new;
 
@@ -471,13 +471,13 @@ void IConsoleVarInsert(_iconsole_var * v
 
		while (item->_next != NULL) { item = item->_next; };
 
		item->_next = item_new;
 
	}
 
}
 

	
 

	
 
_iconsole_var * IConsoleVarGet(byte * name)
 
_iconsole_var * IConsoleVarGet(const byte * name)
 
{
 
	_iconsole_var * item;
 

	
 
	item = _iconsole_vars;
 
	while (item != NULL) {
 
		if (strcmp(item->name,name)==0) return item;
 
@@ -548,74 +548,61 @@ void IConsoleVarInsert(_iconsole_var * v
 
	return item;
 
}
 

	
 

	
 
void IConsoleVarFree(_iconsole_var * var)
 
{
 
	if (var ->_malloc) {
 
	if (var->_malloc)
 
		free(var ->addr);
 
		}
 
	free(var);
 
}
 

	
 
void IConsoleVarSetString(_iconsole_var * var, byte * string)
 
void IConsoleVarSetString(_iconsole_var * var, const byte * string)
 
{
 
	int l;
 

	
 
	if (string == NULL) return;
 

	
 
	if (var->_malloc) {
 
		free(var->addr);
 
		}
 

	
 
	l=strlen((char *) string);
 
	l=strlen(string);
 
	var->addr=malloc(l+1);
 
	var->_malloc=true;
 
	memset(var->addr,0,l);
 
	memcpy((void *) var->addr,(void *) string, l);
 
	memcpy(var->addr, string, l);
 
	((byte *)var->addr)[l]=0;
 
	}
 

	
 
	void IConsoleVarSetValue(_iconsole_var * var, int value) {
 
	switch (var->type) {
 
			case ICONSOLE_VAR_BOOLEAN:
 
					{
 
					(*(bool *)var->addr)=(value!=0);
 
					}
 
					*(bool *)var->addr = (value != 0);
 
					break;
 
			case ICONSOLE_VAR_BYTE:
 
					{
 
					(*(byte *)var->addr)=value;
 
					}
 
					*(byte *)var->addr = value;
 
					break;
 
			case ICONSOLE_VAR_UINT16:
 
					{
 
					(*(unsigned short *)var->addr)=value;
 
					}
 
					*(unsigned short *)var->addr = value;
 
					break;
 
			case ICONSOLE_VAR_UINT32:
 
					{
 
					(*(unsigned int *)var->addr)=value;
 
					}
 
					*(unsigned int *)var->addr = value;
 
					break;
 
			case ICONSOLE_VAR_INT16:
 
					{
 
					(*(signed short *)var->addr)=value;
 
					}
 
					*(signed short *)var->addr = value;
 
					break;
 
			case ICONSOLE_VAR_INT32:
 
					{
 
					(*(signed int *)var->addr)=value;
 
					}
 
					*(signed int *)var->addr = value;
 
					break;
 
			default:
 
					break;
 
			}
 
}
 

	
 
void IConsoleVarDump(_iconsole_var * var, byte * dump_desc)
 
void IConsoleVarDump(_iconsole_var * var, const byte * dump_desc)
 
{
 
	byte var_b; // TYPE BYTE
 
	unsigned short var_ui16; // TYPE UINT16
 
	unsigned int var_ui32; // TYPE UINT32
 
	signed short var_i16; // TYPE INT16
 
	signed int var_i32; // TYPE INT32
 
@@ -683,13 +670,13 @@ void IConsoleVarDump(_iconsole_var * var
 
}
 

	
 
// * ************************* * //
 
// * hooking code              * //
 
// * ************************* * //
 

	
 
void IConsoleVarHook(byte * name, byte type, void * proc)
 
void IConsoleVarHook(const byte * name, byte type, void * proc)
 
{
 
	_iconsole_var * hook_var;
 
	hook_var = IConsoleVarGet(name);
 
	if (hook_var == NULL) return;
 
	switch (type) {
 
	case ICONSOLE_HOOK_BEFORE_CHANGE:
 
@@ -703,29 +690,30 @@ void IConsoleVarHook(byte * name, byte t
 
		break;
 
	}
 
}
 

	
 
bool IConsoleVarHookHandle(_iconsole_var * hook_var, byte type)
 
{
 
	bool (*proc)(_iconsole_var * hook_var);
 
	bool (*proc)(_iconsole_var * hook_var) = NULL;
 
	switch (type) {
 
	case ICONSOLE_HOOK_BEFORE_CHANGE:
 
		proc = hook_var->hook_before_change;
 
		break;
 
	case ICONSOLE_HOOK_AFTER_CHANGE:
 
		proc = hook_var->hook_after_change;
 
		break;
 
	case ICONSOLE_HOOK_ACCESS:
 
		proc = hook_var->hook_access;
 
		break;
 
	default: return true;
 
	}
 
	if (proc == NULL) return true;
 

	
 
	return proc(hook_var);
 
}
 

	
 
void IConsoleCmdHook(byte * name, byte type, void * proc)
 
void IConsoleCmdHook(const byte * name, byte type, void * proc)
 
{
 
	_iconsole_cmd * hook_cmd;
 
	hook_cmd = IConsoleCmdGet(name);
 
	if (hook_cmd == NULL) return;
 
	switch (type) {
 
	case ICONSOLE_HOOK_AFTER_EXEC:
 
@@ -750,12 +738,15 @@ bool IConsoleCmdHookHandle(_iconsole_cmd
 
	case ICONSOLE_HOOK_BEFORE_EXEC:
 
		proc = hook_cmd->hook_before_exec;
 
		break;
 
	case ICONSOLE_HOOK_ACCESS:
 
		proc = hook_cmd->hook_access;
 
		break;
 
	default:
 
		proc = NULL;
 
		break;
 
	}
 
	if (proc == NULL) return true;
 
	return proc(hook_cmd);
 
}
 

	
 
void IConsoleCmdExec(byte * cmdstr)
 
@@ -1112,13 +1103,14 @@ void IConsoleCmdExec(byte * cmdstr)
 
		}
 
		break;
 
	case 3:
 
	case 4:
 
		{
 
		// execute command with result or assign a variable
 
			if (execution_mode==3) if (IConsoleCmdHookHandle(cmd,ICONSOLE_HOOK_ACCESS)) {
 
			if (execution_mode==3) {
 
				if (IConsoleCmdHookHandle(cmd,ICONSOLE_HOOK_ACCESS)) {
 
			int i;
 
			int diff;
 
			void * temp;
 
			byte temp2;
 

	
 
			// tokenshifting
 
@@ -1132,13 +1124,13 @@ void IConsoleCmdExec(byte * cmdstr)
 
				tokens[19]=temp;
 
				tokentypes[19]=temp2;
 
				}
 
			IConsoleCmdHookHandle(cmd,ICONSOLE_HOOK_BEFORE_EXEC);
 
			result = function(c,tokens,tokentypes);
 
			IConsoleCmdHookHandle(cmd,ICONSOLE_HOOK_AFTER_EXEC);
 
			} else {
 
				} else
 
				execution_mode=255;
 
			}
 

	
 
		if (IConsoleVarHookHandle(var,ICONSOLE_HOOK_ACCESS)) if (result!=NULL) {
 
			if (result ->type != var -> type) {
 
				IConsoleError("variable type missmatch");
console.h
Show inline comments
 
@@ -44,13 +44,13 @@ typedef struct {
 
	void * _next;
 
	} _iconsole_cmd;
 

	
 
typedef struct {
 
	// --------------- //
 
	void * addr;
 
	byte * name;
 
	const byte * name;
 
	byte type;
 
	// -------------- //
 
	void * hook_access;
 
	void * hook_before_change;
 
	void * hook_after_change;
 
	// -------------- //
 
@@ -82,47 +82,47 @@ void IConsoleFree();
 
void IConsoleResize();
 
void IConsoleSwitch();
 
void IConsoleClose();
 
void IConsoleOpen();
 

	
 
// ** console cmd buffer ** //
 
void IConsoleCmdBufferAdd(byte * cmd);
 
void IConsoleCmdBufferAdd(const byte *cmd);
 
void IConsoleCmdBufferNavigate(signed char direction);
 

	
 
// ** console output ** //
 
void IConsolePrint(byte color_code, byte* string);
 
void IConsolePrint(byte color_code, const byte* string);
 
void CDECL IConsolePrintF(byte color_code, const char *s, ...);
 
void IConsoleDebug(byte* string);
 
void IConsoleError(byte* string);
 
void IConsoleError(const byte* string);
 

	
 
// *** Commands *** //
 

	
 
void IConsoleCmdRegister(byte * name, void * addr);
 
void IConsoleCmdRegister(const byte * name, void * addr);
 
void* IConsoleCmdGetAddr(byte * name);
 

	
 
// *** Variables *** //
 

	
 
void IConsoleVarRegister(byte * name, void * addr, byte type);
 
void IConsoleVarRegister(const byte * name, void * addr, byte type);
 
void IConsoleVarMemRegister(byte * name, byte type);
 
void IConsoleVarInsert(_iconsole_var * var, byte * name);
 
_iconsole_var * IConsoleVarGet(byte * name);
 
void IConsoleVarInsert(_iconsole_var * var, const byte * name);
 
_iconsole_var * IConsoleVarGet(const byte * name);
 
_iconsole_var * IConsoleVarAlloc(byte type);
 
void IConsoleVarFree(_iconsole_var * var);
 
void IConsoleVarSetString(_iconsole_var * var, byte * string);
 
void IConsoleVarSetString(_iconsole_var * var, const byte * string);
 
void IConsoleVarSetValue(_iconsole_var * var, int value);
 
void IConsoleVarDump(_iconsole_var * var, byte * dump_desc);
 
void IConsoleVarDump(_iconsole_var * var, const byte * dump_desc);
 

	
 
// *** Parser *** //
 

	
 
void IConsoleCmdExec(byte * cmdstr);
 

	
 
// ** console std lib ** //
 
void IConsoleStdLibRegister();
 

	
 
// ** hook code ** //
 
void IConsoleVarHook(byte * name, byte type, void * proc);
 
void IConsoleCmdHook(byte * name, byte type, void * proc);
 
void IConsoleVarHook(const byte * name, byte type, void * proc);
 
void IConsoleCmdHook(const byte * name, byte type, void * proc);
 
bool IConsoleVarHookHandle(_iconsole_var * hook_var, byte type);
 
bool IConsoleCmdHookHandle(_iconsole_cmd * hook_cmd, byte type);
 

	
 

	
 
#endif /* CONSOLE_H */
console_cmds.c
Show inline comments
 
@@ -36,20 +36,22 @@ DEF_CONSOLE_CMD_HOOK(ConCmdHookNoNetwork
 
		IConsoleError("this command is forbidden in multiplayer");
 
		return false;
 
		}
 
	return true;
 
}
 
 
#if 0 /* Not used atm */
 
DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetwork)
 
{
 
	if (_networking) {
 
		IConsoleError("this variable is forbidden in multiplayer");
 
		return false;
 
		}
 
	return true;
 
}
 
#endif
 
 
DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetClient)
 
{
 
	if (!_networking_server) {
 
		IConsoleError("this variable only makes sense for a network server");
 
		return false;
 
@@ -272,13 +274,13 @@ DEF_CONSOLE_CMD(ConListVariables)
 
	if (argv[1]!=NULL) l = strlen((char *) argv[1]);
 
 
	item = _iconsole_vars;
 
	while (item != NULL) {
 
		if (argv[1]!=NULL) {
 
 
			if (memcmp((void *) item->name, (void *) argv[1],l)==0)
 
			if (memcmp(item->name, argv[1],l)==0)
 
					IConsolePrintF(_iconsole_color_default,"%s",item->name);
 
 
			} else {
 
 
			IConsolePrintF(_iconsole_color_default,"%s",item->name);
 
 
@@ -297,13 +299,13 @@ DEF_CONSOLE_CMD(ConListDumpVariables)
 
	if (argv[1]!=NULL) l = strlen((char *) argv[1]);
 
 
	item = _iconsole_vars;
 
	while (item != NULL) {
 
		if (argv[1]!=NULL) {
 
 
			if (memcmp((void *) item->name, (void *) argv[1],l)==0)
 
			if (memcmp(item->name, argv[1],l)==0)
 
					IConsoleVarDump(item,NULL);
 
 
			} else {
 
 
			IConsoleVarDump(item,NULL);
 
 
@@ -343,12 +345,14 @@ void IConsoleStdLibRegister()
 
	// stdlib
 
	extern byte _stdlib_developer;
 
	extern bool _stdlib_con_developer;
 
 
#ifdef _DEBUG
 
	IConsoleDebugLibRegister();
 
#else
 
	(void)ConResetTile; // Silence warning, this is only used in _DEBUG
 
#endif
 
 
	// functions [please add them alphabeticaly]
 
#ifdef ENABLE_NETWORK
 
	IConsoleCmdRegister("connect",ConNetworkConnect);
 
	IConsoleCmdHook("connect",ICONSOLE_HOOK_ACCESS,ConCmdHookNoNetwork);
console_cmds.h
Show inline comments
 
deleted file
graph_gui.c
Show inline comments
 
@@ -1013,14 +1013,14 @@ static const StringID _performance_title
 
static StringID GetPerformanceTitleFromValue(uint v)
 
{
 
	return _performance_titles[minu(v, 1000) >> 6];
 
}
 

	
 
static int CDECL _perf_hist_comp(const void *elem1, const void *elem2 ) {
 
	Player *p1 = *(Player**)elem1;
 
	Player *p2 = *(Player**)elem2;
 
	const Player *p1 = *(const Player* const *)elem1;
 
	const Player *p2 = *(const Player* const *)elem2;
 
	int32 v = p2->old_economy[1].performance_history - p1->old_economy[1].performance_history;
 
	return (v!=0) | (v >> (sizeof(int32)*8-1));
 
}
 

	
 
static void CompanyLeagueWndProc(Window *w, WindowEvent *e)
 
{
hal.h
Show inline comments
 
@@ -132,13 +132,13 @@ FiosItem *FiosGetScenarioList(int *num, 
 
void FiosFreeSavegameList();
 
// Browse to. Returns a filename w/path if we reached a file.
 
char *FiosBrowseTo(const FiosItem *item);
 
// Get descriptive texts.
 
// Returns a path as well as a
 
//  string describing the path.
 
StringID FiosGetDescText(char **path);
 
StringID FiosGetDescText(const char **path);
 
// Delete a name
 
void FiosDelete(const char *name);
 
// Make a filename from a name
 
void FiosMakeSavegameName(char *buf, const char *name);
 

	
 
void CreateConsole();
industry_gui.c
Show inline comments
 
@@ -389,14 +389,14 @@ static byte _last_industry_idx;
 
static byte _industry_sort_order;
 

	
 
static int CDECL GeneralIndustrySorter(const void *a, const void *b)
 
{
 
	char buf1[96];
 
	byte val;
 
	Industry *i = DEREF_INDUSTRY(*(byte*)a);
 
	Industry *j = DEREF_INDUSTRY(*(byte*)b);
 
	Industry *i = DEREF_INDUSTRY(*(const byte*)a);
 
	Industry *j = DEREF_INDUSTRY(*(const byte*)b);
 
	int r = 0;
 

	
 
	switch (_industry_sort_order >> 1) {
 
	/* case 0: Sort by Name (handled later) */
 
	case 1: /* Sort by Type */
 
		r = i->type - j->type;
 
@@ -434,13 +434,13 @@ static int CDECL GeneralIndustrySorter(c
 

	
 
	// default to string sorting if they are otherwise equal
 
	if (r == 0) {
 
		SET_DPARAM32(0, i->town->townnameparts);
 
		GetString(buf1, i->town->townnametype);
 

	
 
		if ( (val=*(byte*)b) != _last_industry_idx) {
 
		if ( (val=*(const byte*)b) != _last_industry_idx) {
 
			_last_industry_idx = val;
 
			SET_DPARAM32(0, j->town->townnameparts);
 
			GetString(_bufcache, j->town->townnametype);
 
		}
 
		r = strcmp(buf1, _bufcache);
 
	}
macros.h
Show inline comments
 
@@ -200,24 +200,24 @@ static INLINE void swap_uint16(uint16 *a
 
static INLINE void swap_int16(int16 *a, int16 *b) { int16 t = *a; *a = *b; *b = t; }
 
static INLINE void swap_tile(TileIndex *a, TileIndex *b) { TileIndex t = *a; *a = *b; *b = t; }
 

	
 

	
 

	
 
#if defined(TTD_LITTLE_ENDIAN)
 
#	define READ_LE_UINT16(b) (*(uint16*)(b))
 
#	define READ_LE_UINT16(b) (*(const uint16*)(b))
 
#	define ADD_WORD(x) (x)&0xFF, ((x) >> 8)&0xFF
 
#	define ADD_DWORD(x) (x)&0xFF, ((x) >> 8)&0xFF, ((x) >> 16)&0xFF, ((x) >> 24)&0xFF
 
#elif defined(TTD_BIG_ENDIAN)
 
	static INLINE uint16 READ_LE_UINT16(const void *b) {
 
		return ((byte*)b)[0] + (((byte*)b)[1] << 8);
 
		return ((const byte*)b)[0] + (((const byte*)b)[1] << 8);
 
	}
 
#	define ADD_WORD(x) ((x) >> 8)&0xFF, (x)&0xFF
 
#	define ADD_DWORD(x) ((x) >> 24)&0xFF, ((x) >> 16)&0xFF, ((x) >> 8)&0xFF,  (x)&0xFF
 
#endif
 

	
 
static INLINE void WRITE_LE_UINT16(const void *b, uint16 x) {
 
static INLINE void WRITE_LE_UINT16(void *b, uint16 x) {
 
	((byte*)b)[0] = (byte)x;
 
	((byte*)b)[1] = (byte)(x >> 8);
 
}
 

	
 
#define MAX_DETOUR 6
 

	
misc_gui.c
Show inline comments
 
@@ -960,13 +960,13 @@ static void BuildFileList()
 
	else
 
		_fios_list = FiosGetSavegameList(&_fios_num, _saveload_mode);
 
}
 

	
 
static void DrawFiosTexts()
 
{
 
	char *path;
 
	const char *path;
 
	StringID str;
 

	
 
	str = FiosGetDescText(&path);
 
	if (str != 0)
 
		DrawString(2, 37, str, 0);
 
	DoDrawString(path, 2, 27, 16);
rail_cmd.c
Show inline comments
 
@@ -1517,13 +1517,13 @@ static void DrawTile_Track(TileInfo *ti)
 
			return;
 

	
 
		if (ti->tileh != 0) { DrawFoundation(ti, ti->tileh); }
 

	
 
		s = _track_depot_layout_table[m5 & 0x3F];
 

	
 
		image = *(uint16*)s;
 
		image = *(const uint16*)s;
 
		if (image & 0x8000) image = (image & 0x7FFF) + tracktype_offs;
 

	
 
		// adjust ground tile for desert
 
		// (don't adjust for arctic, because snow in depots looks weird)
 
		if ((_map2[ti->tile] & RAIL_MAP2LO_GROUND_MASK)==RAIL_GROUND_ICE_DESERT && _opt.landscape == LT_DESERT)
 
		{
 
@@ -1563,17 +1563,17 @@ void DrawTrainDepotSprite(int x, int y, 
 

	
 
	t = _track_depot_layout_table[image];
 

	
 
	x+=33;
 
	y+=17;
 

	
 
	img = *(uint16*)t;
 
	img = *(const uint16*)t;
 
	if (img & 0x8000) img = (img & 0x7FFF) + railtype;
 
	DrawSprite(img, x, y);
 

	
 
	for(dtss = (DrawTrackSeqStruct *)(t + sizeof(uint16)); dtss->image != 0; dtss++) {
 
	for(dtss = (const DrawTrackSeqStruct *)(t + sizeof(uint16)); dtss->image != 0; dtss++) {
 
		Point pt = RemapCoords(dtss->subcoord_x, dtss->subcoord_y, 0);
 
		image = dtss->image;
 
		if (image & 0x8000) image |= ormod;
 
		DrawSprite(image + railtype, x + pt.x, y + pt.y);
 
	}
 
}
road_cmd.c
Show inline comments
 
@@ -807,15 +807,15 @@ static void DrawTile_Road(TileInfo *ti)
 
		player = _map_owner[ti->tile];
 
		if (player < MAX_PLAYERS)
 
			ormod = PLAYER_SPRITE_COLOR(player);
 

	
 
		s = _road_display_datas[ti->map5 & 0xF];
 

	
 
		DrawGroundSprite(*(uint32*)s);
 
		DrawGroundSprite(*(const uint32*)s);
 
		s += sizeof(uint32);
 
		drss = (DrawRoadSeqStruct*)s;
 
		drss = (const DrawRoadSeqStruct*)s;
 

	
 
		while ((image=drss->image) != 0) {
 
			if (image & 0x8000)
 
				image |= ormod;
 
			if (!(_display_opt & DO_TRANS_BUILDINGS)) // show transparent depots
 
				image = (image & 0x3FFF) | 0x3224000;
 
@@ -837,16 +837,16 @@ void DrawRoadDepotSprite(int x, int y, i
 

	
 
	t = _road_display_datas[image];
 

	
 
	x+=33;
 
	y+=17;
 

	
 
	DrawSprite(*(uint32*)t, x, y);
 
	DrawSprite(*(const uint32*)t, x, y);
 
	t += sizeof(uint32);
 

	
 
	for(dtss = (DrawRoadSeqStruct *)t; dtss->image != 0; dtss++) {
 
	for(dtss = (const DrawRoadSeqStruct *)t; dtss->image != 0; dtss++) {
 
		Point pt = RemapCoords(dtss->subcoord_x, dtss->subcoord_y, 0);
 

	
 
		image = dtss->image;
 
		if (image & 0x8000)
 
			image |= ormod;
 

	
saveload.c
Show inline comments
 
@@ -419,13 +419,13 @@ void SlArray(void *array, uint length, u
 

	
 
// Calculate the size of an object.
 
static size_t SlCalcObjLength(void *object, const void *desc)
 
{
 
	size_t length = 0;
 
	uint cmd,conv;
 
	byte *d = (byte*)desc;
 
	const byte *d = (const byte*)desc;
 

	
 
	// Need to determine the length and write a length tag.
 
	while (true) {
 
		cmd = (d[0] >> 4);
 
		if (cmd < 8) {
 
			conv = d[2];
 
@@ -461,13 +461,13 @@ static size_t SlCalcObjLength(void *obje
 
	}
 
	return length;
 
}
 

	
 
void SlObject(void *object, const void *desc)
 
{
 
	byte *d = (byte*)desc;
 
	const byte *d = (const byte*)desc;
 
	void *ptr;
 
	uint cmd,conv;
 

	
 
	// Automatically calculate the length?
 
	if (_sl.need_length != NL_NONE) {
 
		SlSetLength(SlCalcObjLength(object, d));
sdl.c
Show inline comments
 
@@ -209,15 +209,15 @@ static void DrawSurfaceToScreen()
 
		}
 
	}
 
}
 

	
 
static int CDECL compare_res(const void *pa, const void *pb)
 
{
 
	int x = ((uint16*)pa)[0] - ((uint16*)pb)[0];
 
	int x = ((const uint16*)pa)[0] - ((const uint16*)pb)[0];
 
	if (x) return x;
 
	return ((uint16*)pa)[1] - ((uint16*)pb)[1];
 
	return ((const uint16*)pa)[1] - ((const uint16*)pb)[1];
 
}
 

	
 
static const uint16 default_resolutions[][2] = {
 
	{640,480},
 
	{800,600},
 
	{1024,768},
settings.c
Show inline comments
 
@@ -322,15 +322,15 @@ static void ini_free(IniFile *ini)
 
	pool_free(&ini->pool);
 
}
 

	
 
struct SettingDesc {
 
	const char *name;
 
	int flags;
 
	void *def;
 
	const void *def;
 
	void *ptr;
 
	void *b;
 
	const void *b;
 

	
 
};
 

	
 
static int lookup_oneofmany(const char *many, const char *one, int onelen)
 
{
 
	const char *s;
 
@@ -490,13 +490,13 @@ static void make_manyofmany(char *buf, c
 
		}
 
		if (*many == '|') many++;
 
	} while (++i, x>>=1);
 
	*buf = 0;
 
}
 

	
 
static void *string_to_val(const SettingDesc *desc, const char *str)
 
static const void *string_to_val(const SettingDesc *desc, const char *str)
 
{
 
	unsigned long val;
 
	char *end;
 

	
 
	switch(desc->flags & 0xF) {
 
	case SDT_INTX:
 
@@ -529,17 +529,17 @@ static void *string_to_val(const Setting
 
		return (void*)str;
 
	}
 

	
 
	return NULL;
 
}
 

	
 
static void load_setting_desc(IniFile *ini, const SettingDesc *desc, void *grpname, void *base)
 
static void load_setting_desc(IniFile *ini, const SettingDesc *desc, const void *grpname, void *base)
 
{
 
	IniGroup *group_def = ini_getgroup(ini, grpname, -1), *group;
 
	IniItem *item;
 
	void *p;
 
	const void *p;
 
	void *ptr;
 

	
 
	for (;desc->name;desc++) {
 
		// group override?
 
		const char *s = strchr(desc->name, '.');
 
		if (s) {
 
@@ -600,17 +600,18 @@ static void load_setting_desc(IniFile *i
 
		default:
 
			NOT_REACHED();
 
		}
 
	}
 
}
 

	
 
static void save_setting_desc(IniFile *ini, const SettingDesc *desc, void *grpname, void *base)
 
static void save_setting_desc(IniFile *ini, const SettingDesc *desc, const void *grpname, void *base)
 
{
 
	IniGroup *group_def = NULL, *group;
 
	IniItem *item;
 
	void *p, *ptr;
 
	const void *p;
 
	void *ptr;
 
	int i = 0;
 
	char buf[512]; // setting buffer
 
	const char *s;
 

	
 
	for (;desc->name;desc++) {
 
		if (desc->flags & SDT_NOSAVE)
 
@@ -880,13 +881,13 @@ static const SettingDesc patch_settings[
 

	
 
	{"drag_signals_density",SDT_UINT8,	(void*)4,			(void*)offsetof(Patches, drag_signals_density), NULL},
 

	
 
	{NULL,									0,					NULL,					NULL,																						NULL}
 
};
 

	
 
typedef void SettingDescProc(IniFile *ini, const SettingDesc *desc, void *grpname, void *base);
 
typedef void SettingDescProc(IniFile *ini, const SettingDesc *desc, const void *grpname, void *base);
 

	
 
static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc)
 
{
 
	proc(ini, misc_settings,		"misc",			NULL);
 
	proc(ini, win32_settings,		"win32",		NULL);
 
	proc(ini, network_settings, "network",	NULL);
station_cmd.c
Show inline comments
 
@@ -1740,30 +1740,30 @@ static void DrawTile_Station(TileInfo *t
 
	// don't show foundation for docks (docks are between 76 (0x4C) and 81 (0x51))
 
	if (ti->tileh != 0 && (ti->map5 < 0x4C || ti->map5 > 0x51))
 
		DrawFoundation(ti, ti->tileh);
 

	
 
	t = _station_display_datas[ti->map5];
 

	
 
	image = *(uint32*)t;
 
	image = *(const uint32*)t;
 
	t += sizeof(uint32);
 
	if (image & 0x8000)
 
		image |= image_or_modificator;
 
	DrawGroundSprite(image + base_img);
 

	
 
	for(dtss = (DrawTileSeqStruct *)t; (byte)dtss->delta_x != 0x80; dtss++) {
 
	for(dtss = (const DrawTileSeqStruct *)t; (byte)dtss->delta_x != 0x80; dtss++) {
 
		if ((byte)dtss->delta_z != 0x80) {
 
			image =	dtss->image + base_img;
 
			if (_display_opt & DO_TRANS_BUILDINGS) {
 
				if (image&0x8000) image |= image_or_modificator;
 
			} else {
 
				image = (image & 0x3FFF) | 0x03224000;
 
			}
 

	
 
			AddSortableSpriteToDraw(image, ti->x + dtss->delta_x, ti->y + dtss->delta_y, dtss->width, dtss->height, dtss->unk, ti->z + dtss->delta_z);
 
		} else {
 
			image = *(uint32*)&dtss->height + base_img; /* endian ok */
 
			image = *(const uint32*)&dtss->height + base_img; /* endian ok */
 

	
 
			if (_display_opt & DO_TRANS_BUILDINGS) {
 
				if (image&0x8000) image |= image_or_modificator;
 
			} else {
 
				image = (image & 0x3FFF) | 0x03224000;
 
			}
 
@@ -1782,19 +1782,19 @@ void StationPickerDrawSprite(int x, int 
 
	railtype *= TRACKTYPE_SPRITE_PITCH;
 

	
 
	ormod = PLAYER_SPRITE_COLOR(_local_player);
 

	
 
	t = _station_display_datas[image];
 

	
 
	img = *(uint32*)t;
 
	img = *(const uint32*)t;
 
	t += sizeof(uint32);
 
	if (img & 0x8000)
 
		img |= ormod;
 
	DrawSprite(img, x, y);
 

	
 
	for(dtss = (DrawTileSeqStruct *)t; (byte)dtss->delta_x != 0x80; dtss++) {
 
	for(dtss = (const DrawTileSeqStruct *)t; (byte)dtss->delta_x != 0x80; dtss++) {
 
		Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);
 
		DrawSprite((dtss->image | ormod) + railtype, x + pt.x, y + pt.y);
 
	}
 
}
 

	
 
static uint GetSlopeZ_Station(TileInfo *ti)
station_gui.c
Show inline comments
 
@@ -51,15 +51,14 @@ static char _bufcache[64];
 
static uint16 _last_station_idx;
 

	
 
static int CDECL StationNameSorter(const void *a, const void *b)
 
{
 
	char buf1[64];
 
	Station *st;
 
	SortStruct *cmp1, *cmp2;
 
	cmp1 = (SortStruct*)a;
 
	cmp2 = (SortStruct*)b;
 
	const SortStruct *cmp1 = (const SortStruct*)a;
 
	const SortStruct *cmp2 = (const SortStruct*)b;
 

	
 
	st = DEREF_STATION(cmp1->index);
 
	SET_DPARAM16(0, st->town->townnametype);
 
	SET_DPARAM32(1, st->town->townnameparts);
 
	GetString(buf1, st->string_id);
 

	
strgen/strgen.c
Show inline comments
 
@@ -709,13 +709,13 @@ void write_langfile(const char *filename
 
				str = s + 2 + strlen(s + 1);
 

	
 
				if (show_todo && s[0]) {
 
					if (show_todo == 2) {
 
						fprintf(stderr, "Warning:%s: String '%s' is untranslated\n", filename, s + 1);
 
					} else {
 
						char *s = "<TODO> ";
 
						const char *s = "<TODO> ";
 
						while(*s) put_byte(*s++);
 
					}
 
				}
 

	
 
				for(;;) {
 
					cs = parse_command_string(&str, param, s[0] ? "english.lng" : filename);
town_gui.c
Show inline comments
 
@@ -351,21 +351,21 @@ static uint _num_town_sort;
 
static char _bufcache[64];
 
static byte _last_town_idx;
 

	
 
static int CDECL TownNameSorter(const void *a, const void *b)
 
{
 
	char buf1[64];
 
	Town *t;
 
	const Town *t;
 
	byte val;
 
	int r;
 

	
 
	t = DEREF_TOWN(*(byte*)a);
 
	t = DEREF_TOWN(*(const byte*)a);
 
	SET_DPARAM32(0, t->townnameparts);
 
	GetString(buf1, t->townnametype);
 

	
 
	if ( (val=*(byte*)b) != _last_town_idx) {
 
	if ( (val=*(const byte*)b) != _last_town_idx) {
 
		_last_town_idx = val;
 
		t = DEREF_TOWN(val);
 
		SET_DPARAM32(0, t->townnameparts);
 
		GetString(_bufcache, t->townnametype);
 
	}
 

	
 
@@ -373,14 +373,14 @@ static int CDECL TownNameSorter(const vo
 
	if (_town_sort_order & 1) r = -r;
 
	return r;
 
}
 

	
 
static int CDECL TownPopSorter(const void *a, const void *b)
 
{
 
	Town *ta = DEREF_TOWN(*(byte*)a);
 
	Town *tb = DEREF_TOWN(*(byte*)b);
 
	const Town *ta = DEREF_TOWN(*(const byte*)a);
 
	const Town *tb = DEREF_TOWN(*(const byte*)b);
 
	int r = ta->population - tb->population;
 
	if (_town_sort_order & 1) r = -r;
 
	return r;
 
}
 

	
 
static void MakeSortedTownList()
ttd.c
Show inline comments
 
@@ -276,16 +276,16 @@ void LoadDriver(int driver, const char *
 
		}
 
		dd = GetDriverByName(dc->descs, buffer);
 
		if (dd == NULL)
 
			error("No such %s driver: %s\n", dc->name, buffer);
 
	}
 
	var = dc->var;
 
	if (*var != NULL) ((HalCommonDriver*)*var)->stop();
 
	if (*var != NULL) ((const HalCommonDriver*)*var)->stop();
 
	*var = NULL;
 
	drv = dd->drv;
 
	if ((err=((HalCommonDriver*)drv)->start(parms)) != NULL)
 
	if ((err=((const HalCommonDriver*)drv)->start(parms)) != NULL)
 
		error("Unable to load driver %s(%s). The error was: %s\n", dd->name, dd->longname, err);
 
	*var = drv;
 
}
 

	
 
void PrintDriverList()
 
{
unix.c
Show inline comments
 
@@ -276,13 +276,13 @@ char *FiosBrowseTo(const FiosItem *item)
 
	return NULL;
 
}
 

	
 
// Get descriptive texts.
 
// Returns a path as well as a
 
//  string describing the path.
 
StringID FiosGetDescText(char **path)
 
StringID FiosGetDescText(const char **path)
 
{
 
	*path = _fios_path[0] ? _fios_path : "/";
 

	
 
#if defined(__linux__)
 
	{
 
	struct statvfs s;
 
@@ -357,13 +357,13 @@ bool FileExists(const char *filename)
 
{
 
	return access(filename, 0) == 0;
 
}
 

	
 
static int LanguageCompareFunc(const void *a, const void *b)
 
{
 
	return strcmp(*(char**)a, *(char**)b);
 
	return strcmp(*(const char* const *)a, *(const char* const *)b);
 
}
 

	
 
int GetLanguageList(char **languages, int max)
 
{
 
	DIR *dir;
 
	struct dirent *dirent;
unmovable_cmd.c
Show inline comments
 
@@ -81,17 +81,17 @@ static void DrawTile_Unmovable(TileInfo 
 

	
 
		if (ti->tileh) DrawFoundation(ti, ti->tileh);
 

	
 
		ormod = PLAYER_SPRITE_COLOR(_map_owner[ti->tile]);
 

	
 
		t = _unmovable_display_datas[ti->map5 & 0x7F];
 
		DrawGroundSprite(*(uint16*)t | ormod);
 
		DrawGroundSprite(*(const uint16*)t | ormod);
 

	
 
		t += sizeof(uint16);
 

	
 
		for(dtss = (DrawTileSeqStruct *)t; (byte)dtss->delta_x != 0x80; dtss++) {
 
		for(dtss = (const DrawTileSeqStruct *)t; (byte)dtss->delta_x != 0x80; dtss++) {
 
			image =	dtss->image;
 
			if (_display_opt & DO_TRANS_BUILDINGS) {
 
				image |= ormod;
 
			} else {
 
				image = (image & 0x3FFF) | 0x03224000;
 
			}
water_cmd.c
Show inline comments
 
@@ -380,16 +380,16 @@ typedef struct LocksDrawTileStruct {
 

	
 
static void DrawWaterStuff(TileInfo *ti, const byte *t, uint32 palette, uint base)
 
{
 
	const WaterDrawTileStruct *wdts;
 
	uint32 image;
 

	
 
	DrawGroundSprite(*(uint16*)t);
 
	DrawGroundSprite(*(const uint16*)t);
 
	t += sizeof(uint16);
 

	
 
	for(wdts = (WaterDrawTileStruct *)t; (byte)wdts->delta_x != 0x80; wdts++) {
 
	for(wdts = (const WaterDrawTileStruct *)t; (byte)wdts->delta_x != 0x80; wdts++) {
 
		image =	wdts->image + base;
 
		if (_display_opt & DO_TRANS_BUILDINGS) {
 
			image |= palette;
 
		} else {
 
			image = (image & 0x3FFF) | 0x03224000;
 
		}
 
@@ -426,16 +426,16 @@ static void DrawTile_Water(TileInfo *ti)
 
void DrawShipDepotSprite(int x, int y, int image)
 
{
 
	const byte *t;
 
	const WaterDrawTileStruct *wdts;
 

	
 
	t = _shipdepot_display_seq[image];
 
	DrawSprite(*(uint16*)t, x, y);
 
	DrawSprite(*(const uint16*)t, x, y);
 
	t += sizeof(uint16);
 

	
 
	for(wdts = (WaterDrawTileStruct *)t; (byte)wdts->delta_x != 0x80; wdts++) {
 
	for(wdts = (const WaterDrawTileStruct *)t; (byte)wdts->delta_x != 0x80; wdts++) {
 
		Point pt = RemapCoords(wdts->delta_x, wdts->delta_y, wdts->delta_z);
 
		DrawSprite(wdts->image + PLAYER_SPRITE_COLOR(_local_player), x + pt.x, y + pt.y);
 
	}
 
}
 

	
 

	
win32.c
Show inline comments
 
@@ -1738,13 +1738,13 @@ char *FiosBrowseTo(const FiosItem *item)
 
	return NULL;
 
}
 

	
 
// Get descriptive texts.
 
// Returns a path as well as a
 
//  string describing the path.
 
StringID FiosGetDescText(char **path)
 
StringID FiosGetDescText(const char **path)
 
{
 
	char root[4];
 
	DWORD spc, bps, nfc, tnc;
 
	*path = _fios_path;
 

	
 
	root[0] = _fios_path[0];
 
@@ -1809,13 +1809,13 @@ bool FileExists(const char *filename)
 
	CloseHandle(hand);
 
	return true;
 
}
 

	
 
static int CDECL LanguageCompareFunc(const void *a, const void *b)
 
{
 
	return strcmp(*(char**)a, *(char**)b);
 
	return strcmp(*(const char* const *)a, *(const char* const *)b);
 
}
 

	
 
int GetLanguageList(char **languages, int max)
 
{
 
	HANDLE hand;
 
	int num = 0;
0 comments (0 inline, 0 general)