mirror of https://github.com/OpenTTD/OpenTTD
(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 linebreaksrelease/0.4.5
parent
1b498bca57
commit
e295e46e3e
|
@ -88,7 +88,7 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
|
|||
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
|
||||
|
|
|
@ -32,7 +32,7 @@ typedef struct AirportFTAClass {
|
|||
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;
|
||||
|
||||
|
|
86
console.c
86
console.c
|
@ -207,9 +207,9 @@ void IConsoleInit()
|
|||
}
|
||||
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");
|
||||
|
@ -269,16 +269,16 @@ 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;
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ void IConsoleCmdBufferNavigate(signed char direction)
|
|||
_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;
|
||||
|
@ -314,7 +314,7 @@ void IConsolePrint(byte color_code, byte* string)
|
|||
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);
|
||||
|
@ -354,19 +354,19 @@ 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);
|
||||
|
@ -390,7 +390,7 @@ void IConsoleCmdRegister(byte * name, void * addr)
|
|||
}
|
||||
}
|
||||
|
||||
void* IConsoleCmdGet(byte * name)
|
||||
void* IConsoleCmdGet(const byte * name)
|
||||
{
|
||||
_iconsole_cmd * item;
|
||||
|
||||
|
@ -402,14 +402,14 @@ void* IConsoleCmdGet(byte * name)
|
|||
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]='*';
|
||||
|
@ -436,7 +436,7 @@ void IConsoleVarRegister(byte * name, void * addr, byte type)
|
|||
}
|
||||
}
|
||||
|
||||
void IConsoleVarMemRegister(byte * name, byte type)
|
||||
void IConsoleVarMemRegister(byte * name, byte type) /* XXX TRON */
|
||||
{
|
||||
_iconsole_var * item;
|
||||
item = IConsoleVarAlloc(type);
|
||||
|
@ -444,7 +444,7 @@ void IConsoleVarMemRegister(byte * name, byte type)
|
|||
}
|
||||
|
||||
|
||||
void IConsoleVarInsert(_iconsole_var * var, byte * name)
|
||||
void IConsoleVarInsert(_iconsole_var * var, const byte * name)
|
||||
{
|
||||
byte * _new;
|
||||
_iconsole_var * item;
|
||||
|
@ -456,7 +456,7 @@ void IConsoleVarInsert(_iconsole_var * var, byte * name)
|
|||
// 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]='*';
|
||||
|
@ -474,7 +474,7 @@ void IConsoleVarInsert(_iconsole_var * var, byte * name)
|
|||
}
|
||||
|
||||
|
||||
_iconsole_var * IConsoleVarGet(byte * name)
|
||||
_iconsole_var * IConsoleVarGet(const byte * name)
|
||||
{
|
||||
_iconsole_var * item;
|
||||
|
||||
|
@ -551,13 +551,12 @@ _iconsole_var * IConsoleVarAlloc(byte type)
|
|||
|
||||
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;
|
||||
|
||||
|
@ -567,52 +566,40 @@ void IConsoleVarSetString(_iconsole_var * var, byte * string)
|
|||
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
|
||||
|
@ -686,7 +673,7 @@ void IConsoleVarDump(_iconsole_var * var, byte * dump_desc)
|
|||
// * 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);
|
||||
|
@ -706,7 +693,7 @@ void IConsoleVarHook(byte * name, byte type, void * proc)
|
|||
|
||||
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;
|
||||
|
@ -717,12 +704,13 @@ bool IConsoleVarHookHandle(_iconsole_var * hook_var, byte type)
|
|||
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);
|
||||
|
@ -753,6 +741,9 @@ bool IConsoleCmdHookHandle(_iconsole_cmd * hook_cmd, byte type)
|
|||
case ICONSOLE_HOOK_ACCESS:
|
||||
proc = hook_cmd->hook_access;
|
||||
break;
|
||||
default:
|
||||
proc = NULL;
|
||||
break;
|
||||
}
|
||||
if (proc == NULL) return true;
|
||||
return proc(hook_cmd);
|
||||
|
@ -1115,7 +1106,8 @@ void IConsoleCmdExec(byte * cmdstr)
|
|||
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;
|
||||
|
@ -1135,7 +1127,7 @@ void IConsoleCmdExec(byte * cmdstr)
|
|||
IConsoleCmdHookHandle(cmd,ICONSOLE_HOOK_BEFORE_EXEC);
|
||||
result = function(c,tokens,tokentypes);
|
||||
IConsoleCmdHookHandle(cmd,ICONSOLE_HOOK_AFTER_EXEC);
|
||||
} else {
|
||||
} else
|
||||
execution_mode=255;
|
||||
}
|
||||
|
||||
|
|
24
console.h
24
console.h
|
@ -47,7 +47,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
// --------------- //
|
||||
void * addr;
|
||||
byte * name;
|
||||
const byte * name;
|
||||
byte type;
|
||||
// -------------- //
|
||||
void * hook_access;
|
||||
|
@ -85,31 +85,31 @@ 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 *** //
|
||||
|
||||
|
@ -119,8 +119,8 @@ void IConsoleCmdExec(byte * cmdstr);
|
|||
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);
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ DEF_CONSOLE_CMD_HOOK(ConCmdHookNoNetwork)
|
|||
return true;
|
||||
}
|
||||
|
||||
#if 0 /* Not used atm */
|
||||
DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetwork)
|
||||
{
|
||||
if (_networking) {
|
||||
|
@ -47,6 +48,7 @@ DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetwork)
|
|||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetClient)
|
||||
{
|
||||
|
@ -275,7 +277,7 @@ DEF_CONSOLE_CMD(ConListVariables)
|
|||
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 {
|
||||
|
@ -300,7 +302,7 @@ DEF_CONSOLE_CMD(ConListDumpVariables)
|
|||
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 {
|
||||
|
@ -346,6 +348,8 @@ void IConsoleStdLibRegister()
|
|||
|
||||
#ifdef _DEBUG
|
||||
IConsoleDebugLibRegister();
|
||||
#else
|
||||
(void)ConResetTile; // Silence warning, this is only used in _DEBUG
|
||||
#endif
|
||||
|
||||
// functions [please add them alphabeticaly]
|
||||
|
|
|
@ -1016,8 +1016,8 @@ static StringID GetPerformanceTitleFromValue(uint v)
|
|||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
|
2
hal.h
2
hal.h
|
@ -135,7 +135,7 @@ 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
|
||||
|
|
|
@ -392,8 +392,8 @@ 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) {
|
||||
|
@ -437,7 +437,7 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
|
|||
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);
|
||||
|
|
6
macros.h
6
macros.h
|
@ -203,18 +203,18 @@ static INLINE void swap_tile(TileIndex *a, TileIndex *b) { TileIndex t = *a; *a
|
|||
|
||||
|
||||
#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);
|
||||
}
|
||||
|
|
|
@ -963,7 +963,7 @@ static void BuildFileList()
|
|||
|
||||
static void DrawFiosTexts()
|
||||
{
|
||||
char *path;
|
||||
const char *path;
|
||||
StringID str;
|
||||
|
||||
str = FiosGetDescText(&path);
|
||||
|
|
|
@ -1520,7 +1520,7 @@ static void DrawTile_Track(TileInfo *ti)
|
|||
|
||||
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
|
||||
|
@ -1566,11 +1566,11 @@ void DrawTrainDepotSprite(int x, int y, int image, int railtype)
|
|||
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;
|
||||
|
|
|
@ -810,9 +810,9 @@ static void DrawTile_Road(TileInfo *ti)
|
|||
|
||||
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)
|
||||
|
@ -840,10 +840,10 @@ void DrawRoadDepotSprite(int x, int y, int 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;
|
||||
|
|
|
@ -422,7 +422,7 @@ 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) {
|
||||
|
@ -464,7 +464,7 @@ static size_t SlCalcObjLength(void *object, const void *desc)
|
|||
|
||||
void SlObject(void *object, const void *desc)
|
||||
{
|
||||
byte *d = (byte*)desc;
|
||||
const byte *d = (const byte*)desc;
|
||||
void *ptr;
|
||||
uint cmd,conv;
|
||||
|
||||
|
|
4
sdl.c
4
sdl.c
|
@ -212,9 +212,9 @@ 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] = {
|
||||
|
|
17
settings.c
17
settings.c
|
@ -325,9 +325,9 @@ static void ini_free(IniFile *ini)
|
|||
struct SettingDesc {
|
||||
const char *name;
|
||||
int flags;
|
||||
void *def;
|
||||
const void *def;
|
||||
void *ptr;
|
||||
void *b;
|
||||
const void *b;
|
||||
|
||||
};
|
||||
|
||||
|
@ -493,7 +493,7 @@ static void make_manyofmany(char *buf, const char *many, uint32 x)
|
|||
*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;
|
||||
|
@ -532,11 +532,11 @@ static void *string_to_val(const SettingDesc *desc, const char *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++) {
|
||||
|
@ -603,11 +603,12 @@ static void load_setting_desc(IniFile *ini, const SettingDesc *desc, void *grpna
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -883,7 +884,7 @@ static const SettingDesc patch_settings[] = {
|
|||
{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)
|
||||
{
|
||||
|
|
|
@ -1743,13 +1743,13 @@ static void DrawTile_Station(TileInfo *ti)
|
|||
|
||||
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) {
|
||||
|
@ -1760,7 +1760,7 @@ static void DrawTile_Station(TileInfo *ti)
|
|||
|
||||
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;
|
||||
|
@ -1785,13 +1785,13 @@ void StationPickerDrawSprite(int x, int y, int railtype, int image)
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -54,9 +54,8 @@ 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);
|
||||
|
|
|
@ -712,7 +712,7 @@ void write_langfile(const char *filename, int show_todo)
|
|||
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++);
|
||||
}
|
||||
}
|
||||
|
|
10
town_gui.c
10
town_gui.c
|
@ -354,15 +354,15 @@ 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);
|
||||
|
@ -376,8 +376,8 @@ static int CDECL TownNameSorter(const void *a, const void *b)
|
|||
|
||||
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;
|
||||
|
|
4
ttd.c
4
ttd.c
|
@ -279,10 +279,10 @@ void LoadDriver(int driver, const char *name)
|
|||
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;
|
||||
}
|
||||
|
|
4
unix.c
4
unix.c
|
@ -279,7 +279,7 @@ 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)
|
||||
{
|
||||
*path = _fios_path[0] ? _fios_path : "/";
|
||||
|
||||
|
@ -360,7 +360,7 @@ bool FileExists(const char *filename)
|
|||
|
||||
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)
|
||||
|
|
|
@ -84,11 +84,11 @@ static void DrawTile_Unmovable(TileInfo *ti)
|
|||
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;
|
||||
|
|
|
@ -383,10 +383,10 @@ static void DrawWaterStuff(TileInfo *ti, const byte *t, uint32 palette, uint bas
|
|||
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;
|
||||
|
@ -429,10 +429,10 @@ void DrawShipDepotSprite(int x, int y, int image)
|
|||
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);
|
||||
}
|
||||
|
|
4
win32.c
4
win32.c
|
@ -1741,7 +1741,7 @@ 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)
|
||||
{
|
||||
char root[4];
|
||||
DWORD spc, bps, nfc, tnc;
|
||||
|
@ -1812,7 +1812,7 @@ bool FileExists(const char *filename)
|
|||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue