(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes

nothing spectacular, just some stuff, which piled up
replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
tron 19 years ago
parent 0163870006
commit 2cc2154ad2

@ -118,7 +118,7 @@ int32 AI_DoCommand(uint tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
/** /**
* Run 1 tick of the AI. Don't overdo it, keep it realistic. * Run 1 tick of the AI. Don't overdo it, keep it realistic.
*/ */
void AI_RunTick(byte player) static void AI_RunTick(byte player)
{ {
extern void AiNewDoGameLoop(Player *p); extern void AiNewDoGameLoop(Player *p);

@ -436,14 +436,13 @@ do_change_service_int:
DeleteWindow(w); DeleteWindow(w);
break; break;
case WE_ON_EDIT_TEXT: { case WE_ON_EDIT_TEXT:
if (e->edittext.str[0] != '\0') { if (e->edittext.str[0] != '\0') {
_cmd_text = e->edittext.str; _cmd_text = e->edittext.str;
DoCommandP(0, w->window_number, 0, NULL, DoCommandP(0, w->window_number, 0, NULL,
CMD_NAME_VEHICLE | CMD_MSG(STR_A031_CAN_T_NAME_AIRCRAFT)); CMD_NAME_VEHICLE | CMD_MSG(STR_A031_CAN_T_NAME_AIRCRAFT));
} }
} break; break;
} }
} }

@ -126,14 +126,13 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
errmsg = INVALID_STRING_ID; errmsg = INVALID_STRING_ID;
// only query bridge building possibility once, result is the same for all bridges! // only query bridge building possibility once, result is the same for all bridges!
// returns CMD_ERROR on failure, and priCe on success // returns CMD_ERROR on failure, and price on success
ret = DoCommandByTile(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE); ret = DoCommandByTile(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
if (ret == CMD_ERROR) { if (ret == CMD_ERROR) {
errmsg = _error_message; errmsg = _error_message;
} } else {
// check which bridges can be built // check which bridges can be built
else {
int bridge_len; // length of the middle parts of the bridge int bridge_len; // length of the middle parts of the bridge
int tot_bridgedata_len; // total length of bridge int tot_bridgedata_len; // total length of bridge
@ -144,7 +143,6 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
tot_bridgedata_len = CalcBridgeLenCostFactor(tot_bridgedata_len); tot_bridgedata_len = CalcBridgeLenCostFactor(tot_bridgedata_len);
for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) { // loop for all bridgetypes for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) { // loop for all bridgetypes
if (CheckBridge_Stuff(bridge_type, bridge_len)) { if (CheckBridge_Stuff(bridge_type, bridge_len)) {
const Bridge *b = &_bridge[bridge_type]; const Bridge *b = &_bridge[bridge_type];
// bridge is accepted, add to list // bridge is accepted, add to list

@ -1001,4 +1001,3 @@ void StartupDisasters(void)
{ {
ResetDisasterDelay(); ResetDisasterDelay();
} }

@ -105,7 +105,7 @@ typedef void OnButtonClick(Window *w);
static OnButtonClick * const _build_docks_button_proc[] = { static OnButtonClick * const _build_docks_button_proc[] = {
BuildDocksClick_Canal, BuildDocksClick_Canal,
BuildDocksClick_Lock, BuildDocksClick_Lock,
0, NULL,
BuildDocksClick_Demolish, BuildDocksClick_Demolish,
BuildDocksClick_Depot, BuildDocksClick_Depot,
BuildDocksClick_Dock, BuildDocksClick_Dock,
@ -120,9 +120,9 @@ static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
DrawWindowWidgets(w); DrawWindowWidgets(w);
break; break;
case WE_CLICK: { case WE_CLICK:
if (e->click.widget - 3 >= 0 && e->click.widget != 5) _build_docks_button_proc[e->click.widget - 3](w); if (e->click.widget - 3 >= 0 && e->click.widget != 5) _build_docks_button_proc[e->click.widget - 3](w);
} break; break;
case WE_KEYPRESS: { case WE_KEYPRESS: {
switch(e->keypress.keycode) { switch(e->keypress.keycode) {

@ -19,7 +19,8 @@ static uint GetSlopeZ_Dummy(const TileInfo* ti)
return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z; return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
} }
static uint GetSlopeTileh_Dummy(const TileInfo *ti) { static uint GetSlopeTileh_Dummy(const TileInfo* ti)
{
return ti->tileh; return ti->tileh;
} }
@ -81,4 +82,3 @@ const TileTypeProcs _tile_type_dummy_procs = {
NULL, /* vehicle_leave_tile_proc */ NULL, /* vehicle_leave_tile_proc */
GetSlopeTileh_Dummy, /* get_slope_tileh_proc */ GetSlopeTileh_Dummy, /* get_slope_tileh_proc */
}; };

@ -673,7 +673,7 @@ static void AddInflation(void)
static void PlayersPayInterest(void) static void PlayersPayInterest(void)
{ {
Player *p; const Player* p;
int interest = _economy.interest_rate * 54; int interest = _economy.interest_rate * 54;
FOR_ALL_PLAYERS(p) { FOR_ALL_PLAYERS(p) {

@ -632,7 +632,8 @@ int GetCustomEngineSprite(EngineID engine, const Vehicle *v, byte direction)
* @param v The wagon to check * @param v The wagon to check
* @return true if it is using an override, false otherwise * @return true if it is using an override, false otherwise
*/ */
bool UsesWagonOverride(const Vehicle *v) { bool UsesWagonOverride(const Vehicle* v)
{
assert(v->type == VEH_Train); assert(v->type == VEH_Train);
return GetWagonOverrideSpriteSet(v->engine_type, v->u.rail.first_engine) != NULL; return GetWagonOverrideSpriteSet(v->engine_type, v->u.rail.first_engine) != NULL;
} }

@ -180,5 +180,3 @@ void FioOpenFile(int slot, const char *filename)
_fio.handles[slot] = f; _fio.handles[slot] = f;
FioSeekToFile(slot << 24); FioSeekToFile(slot << 24);
} }

10
gfx.c

@ -115,7 +115,7 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo)
void GfxFillRect(int left, int top, int right, int bottom, int color) void GfxFillRect(int left, int top, int right, int bottom, int color)
{ {
DrawPixelInfo *dpi = _cur_dpi; const DrawPixelInfo* dpi = _cur_dpi;
Pixel *dst; Pixel *dst;
const int otop = top; const int otop = top;
const int oleft = left; const int oleft = left;
@ -167,7 +167,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int color)
static void GfxSetPixel(int x, int y, int color) static void GfxSetPixel(int x, int y, int color)
{ {
DrawPixelInfo *dpi = _cur_dpi; const DrawPixelInfo* dpi = _cur_dpi;
if ((x-=dpi->left) < 0 || x>=dpi->width || (y-=dpi->top)<0 || y>=dpi->height) if ((x-=dpi->left) < 0 || x>=dpi->width || (y-=dpi->top)<0 || y>=dpi->height)
return; return;
dpi->dst_ptr[y * dpi->pitch + x] = color; dpi->dst_ptr[y * dpi->pitch + x] = color;
@ -426,7 +426,7 @@ static uint32 FormatStringLinebreaks(char *str, int maxw)
} }
num++; num++;
str[-1] = 0; str[-1] = '\0';
} }
} }
@ -1361,7 +1361,7 @@ typedef void (*BlitZoomFunc)(BlitterParams *bp);
static void GfxMainBlitter(const Sprite* sprite, int x, int y, int mode) static void GfxMainBlitter(const Sprite* sprite, int x, int y, int mode)
{ {
DrawPixelInfo *dpi = _cur_dpi; const DrawPixelInfo* dpi = _cur_dpi;
int start_x, start_y; int start_x, start_y;
byte info; byte info;
BlitterParams bp; BlitterParams bp;
@ -1871,7 +1871,7 @@ void MarkWholeScreenDirty(void)
SetDirtyBlocks(0, 0, _screen.width, _screen.height); SetDirtyBlocks(0, 0, _screen.width, _screen.height);
} }
bool FillDrawPixelInfo(DrawPixelInfo *n, DrawPixelInfo *o, int left, int top, int width, int height) bool FillDrawPixelInfo(DrawPixelInfo* n, const DrawPixelInfo* o, int left, int top, int width, int height)
{ {
int t; int t;

@ -76,7 +76,7 @@ void MarkWholeScreenDirty(void);
void GfxInitPalettes(void); void GfxInitPalettes(void);
bool FillDrawPixelInfo(DrawPixelInfo *n, DrawPixelInfo *o, int left, int top, int width, int height); bool FillDrawPixelInfo(DrawPixelInfo* n, const DrawPixelInfo* o, int left, int top, int width, int height);
/* window.c */ /* window.c */
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom); void DrawOverlappedWindowForAll(int left, int top, int right, int bottom);

@ -403,7 +403,8 @@ static uint GetSlopeZ_Industry(const TileInfo* ti)
return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z; return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
} }
static uint GetSlopeTileh_Industry(const TileInfo *ti) { static uint GetSlopeTileh_Industry(const TileInfo* ti)
{
return 0; return 0;
} }
@ -1008,7 +1009,7 @@ static void PlantFarmField(TileIndex tile)
SetupFarmFieldFence(tile + TileDiffXY(0, size_y - 1), size_x, type, 0); SetupFarmFieldFence(tile + TileDiffXY(0, size_y - 1), size_x, type, 0);
} }
static void MaybePlantFarmField(Industry *i) static void MaybePlantFarmField(const Industry* i)
{ {
TileIndex tile; TileIndex tile;
@ -1402,7 +1403,7 @@ do_clear:
static bool CheckIfTooCloseToIndustry(TileIndex tile, int type) static bool CheckIfTooCloseToIndustry(TileIndex tile, int type)
{ {
Industry *i; const Industry* i;
const IndustrySpec *spec; const IndustrySpec *spec;
spec = &_industry_spec[type]; spec = &_industry_spec[type];
@ -2022,4 +2023,3 @@ static void Load_INDY(void)
const ChunkHandler _industry_chunk_handlers[] = { const ChunkHandler _industry_chunk_handlers[] = {
{ 'INDY', Save_INDY, Load_INDY, CH_ARRAY | CH_LAST}, { 'INDY', Save_INDY, Load_INDY, CH_ARRAY | CH_LAST},
}; };

@ -186,21 +186,21 @@ uint GetSlopeZ(int x, int y)
// direction=true: check for foundation in east and south corner // direction=true: check for foundation in east and south corner
// direction=false: check for foundation in west and south corner // direction=false: check for foundation in west and south corner
static bool hasFoundation(TileInfo *ti, bool direction) static bool hasFoundation(const TileInfo* ti, bool direction)
{ {
bool south, other; // southern corner and east/west corner bool south, other; // southern corner and east/west corner
uint slope = _tile_type_procs[ti->type]->get_slope_tileh_proc(ti); uint slope = _tile_type_procs[ti->type]->get_slope_tileh_proc(ti);
uint tileh = ti->tileh; uint tileh = ti->tileh;
if(slope==0 && slope!=tileh) tileh=15; if (slope == 0 && slope != tileh) tileh = 15;
south = (tileh & 2) != (slope & 2); south = (tileh & 2) != (slope & 2);
if(direction) if (direction) {
other = (tileh & 4) != (slope & 4); other = (tileh & 4) != (slope & 4);
else } else {
other = (tileh & 1) != (slope & 1); other = (tileh & 1) != (slope & 1);
}
return south || other; return south || other;
} }
void DrawFoundation(TileInfo *ti, uint f) void DrawFoundation(TileInfo *ti, uint f)

@ -450,4 +450,3 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size);
#endif #endif
#endif /* LZOCONF_H */ #endif /* LZOCONF_H */

@ -71,7 +71,7 @@ void HandleOnEditText(WindowEvent *e)
DoCommandP(0, id, 0, NULL, CMD_RENAME_SIGN | CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME)); DoCommandP(0, id, 0, NULL, CMD_RENAME_SIGN | CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME));
break; break;
case 1: /* Rename a waypoint */ case 1: /* Rename a waypoint */
if (*b == 0) return; if (*b == '\0') return;
DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME)); DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME));
break; break;
#ifdef ENABLE_NETWORK #ifdef ENABLE_NETWORK
@ -944,7 +944,7 @@ static void ToolbarZoomOutClick(Window *w)
static void ToolbarBuildRailClick(Window *w) static void ToolbarBuildRailClick(Window *w)
{ {
Player *p = GetPlayer(_local_player); const Player* p = GetPlayer(_local_player);
Window *w2; Window *w2;
w2 = PopupMainToolbMenu(w, 457, 19, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes); w2 = PopupMainToolbMenu(w, 457, 19, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes);
WP(w2,menu_d).sel_index = _last_built_railtype; WP(w2,menu_d).sel_index = _last_built_railtype;

@ -39,7 +39,6 @@ void AllocateMap(uint size_x, uint size_y)
_map_size = size_x * size_y; _map_size = size_x * size_y;
_map_tile_mask = _map_size - 1; _map_tile_mask = _map_size - 1;
// free/malloc uses less memory than realloc.
free(_m); free(_m);
_m = malloc(_map_size * sizeof(*_m)); _m = malloc(_map_size * sizeof(*_m));
@ -111,9 +110,8 @@ uint ScaleByMapSize1D(uint n)
// the result will be tile + TileDiffXY(addx, addy) // the result will be tile + TileDiffXY(addx, addy)
uint TileAddWrap(TileIndex tile, int addx, int addy) uint TileAddWrap(TileIndex tile, int addx, int addy)
{ {
uint x, y; uint x = TileX(tile) + addx;
x = TileX(tile) + addx; uint y = TileY(tile) + addy;
y = TileY(tile) + addy;
// Are we about to wrap? // Are we about to wrap?
if (x < MapMaxX() && y < MapMaxY()) if (x < MapMaxX() && y < MapMaxY())
@ -170,4 +168,3 @@ uint DistanceFromEdge(TileIndex tile)
const uint minh = xh < yh ? xh : yh; const uint minh = xh < yh ? xh : yh;
return minl < minh ? minl : minh; return minl < minh ? minl : minh;
} }

@ -29,8 +29,6 @@ typedef struct Tile {
extern Tile* _m; extern Tile* _m;
void InitMap(uint log_x, uint log_y);
void AllocateMap(uint size_x, uint size_y); void AllocateMap(uint size_x, uint size_y);
// binary logarithm of the map size, try to avoid using this one // binary logarithm of the map size, try to avoid using this one

@ -72,4 +72,3 @@ uint32 RandomMT(void)
void SeedMT(uint32 seed) {} void SeedMT(uint32 seed) {}
#endif /* MERSENNE_TWISTER */ #endif /* MERSENNE_TWISTER */

@ -1969,5 +1969,3 @@ lookbehind_overrun:
#endif #endif
/***** End of minilzo.c *****/ /***** End of minilzo.c *****/

@ -99,4 +99,3 @@ lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len,
#endif #endif
#endif /* MINILZO_H */ #endif /* MINILZO_H */

@ -4,6 +4,7 @@
#include "openttd.h" #include "openttd.h"
#include "currency.h" #include "currency.h"
#include "functions.h" #include "functions.h"
#include "news.h"
#include "player.h" #include "player.h"
#include "string.h" #include "string.h"
#include "table/strings.h" #include "table/strings.h"
@ -19,7 +20,6 @@
#include "variables.h" #include "variables.h"
extern void StartupEconomy(void); extern void StartupEconomy(void);
extern void InitNewsItemStructs(void);
char _name_array[512][32]; char _name_array[512][32];

@ -75,4 +75,3 @@ const HalMusicDriver _os2_music_driver = {
OS2MidiIsSongPlaying, OS2MidiIsSongPlaying,
OS2MidiSetVolume, OS2MidiSetVolume,
}; };

@ -375,5 +375,3 @@ const HalMusicDriver _qtime_music_driver = {
SongIsPlaying, SongIsPlaying,
SetVolume, SetVolume,
}; };

@ -12,4 +12,3 @@
extern const HalMusicDriver _qtime_music_driver; extern const HalMusicDriver _qtime_music_driver;
#endif /* !MUSIC_MACOSX_QUICKTIME_H */ #endif /* !MUSIC_MACOSX_QUICKTIME_H */

@ -44,7 +44,8 @@ static void Win32MidiSetVolume(byte vol)
SetEvent(_midi.wait_obj); SetEvent(_midi.wait_obj);
} }
static MCIERROR CDECL MidiSendCommand(const char *cmd, ...) { static MCIERROR CDECL MidiSendCommand(const char* cmd, ...)
{
va_list va; va_list va;
char buf[512]; char buf[512];

@ -20,7 +20,10 @@ void NetworkServer_Tick(bool send_frame);
void NetworkServerMonthlyLoop(void); void NetworkServerMonthlyLoop(void);
void NetworkServerYearlyLoop(void); void NetworkServerYearlyLoop(void);
static inline const char* GetPlayerIP(const NetworkClientInfo *ci) {return inet_ntoa(*(struct in_addr *)&ci->client_ip);} static inline const char* GetPlayerIP(const NetworkClientInfo* ci)
{
return inet_ntoa(*(const struct in_addr*)&ci->client_ip);
}
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */

@ -46,4 +46,3 @@ extern GRFFile *_first_grffile;
void LoadNewGRF(uint load_index, uint file_index); void LoadNewGRF(uint load_index, uint file_index);
#endif /* NEWGRF_H */ #endif /* NEWGRF_H */

@ -225,7 +225,7 @@ md_continue_here:;
} }
static void ParseResolution(int res[2], char *s) static void ParseResolution(int res[2], const char* s)
{ {
char *t = strchr(s, 'x'); char *t = strchr(s, 'x');
if (t == NULL) { if (t == NULL) {

@ -18,9 +18,9 @@
#include "depot.h" #include "depot.h"
#include "waypoint.h" #include "waypoint.h"
static int OrderGetSel(Window *w) static int OrderGetSel(const Window* w)
{ {
Vehicle *v = GetVehicle(w->window_number); const Vehicle* v = GetVehicle(w->window_number);
int num = WP(w,order_d).sel; int num = WP(w,order_d).sel;
if (num < 0 || num > v->num_orders) if (num < 0 || num > v->num_orders)
@ -113,7 +113,6 @@ static void DrawOrdersWindow(Window *w)
SETBIT(w->disabled_state, 8); /* full load */ SETBIT(w->disabled_state, 8); /* full load */
SETBIT(w->disabled_state, 9); /* unload */ SETBIT(w->disabled_state, 9); /* unload */
SETBIT(w->disabled_state, 10); /* transfer */ SETBIT(w->disabled_state, 10); /* transfer */
} }
SetDParam(0, v->string_id); SetDParam(0, v->string_id);

@ -633,4 +633,3 @@ void CSleep(int milliseconds)
{ {
delay(milliseconds); delay(milliseconds);
} }

@ -915,4 +915,3 @@ void NewTrainPathfind(TileIndex tile, TileIndex dest, byte direction, NTPEnumPro
NTPEnum(&tpf, tile, direction); NTPEnum(&tpf, tile, direction);
} }

@ -1263,4 +1263,3 @@ static void Load_PLYR(void)
const ChunkHandler _player_chunk_handlers[] = { const ChunkHandler _player_chunk_handlers[] = {
{ 'PLYR', Save_PLYR, Load_PLYR, CH_ARRAY | CH_LAST}, { 'PLYR', Save_PLYR, Load_PLYR, CH_ARRAY | CH_LAST},
}; };

@ -143,4 +143,3 @@ RailType GetTileRailType(TileIndex tile, Trackdir trackdir)
} }
return type; return type;
} }

@ -270,7 +270,7 @@ static inline byte SignalOnTrack(Track track) {
static inline RailTileType GetRailTileType(TileIndex tile) static inline RailTileType GetRailTileType(TileIndex tile)
{ {
assert(IsTileType(tile, MP_RAILWAY)); assert(IsTileType(tile, MP_RAILWAY));
return (_m[tile].m5 & RAIL_TILE_TYPE_MASK); return _m[tile].m5 & RAIL_TILE_TYPE_MASK;
} }
/** /**
@ -598,4 +598,3 @@ void DrawTrackBits(TileInfo *ti, TrackBits track, bool earth, bool snow, bool fl
void DrawTrainDepotSprite(int x, int y, int image, RailType railtype); void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
void DrawDefaultWaypointSprite(int x, int y, RailType railtype); void DrawDefaultWaypointSprite(int x, int y, RailType railtype);
#endif /* RAIL_H */ #endif /* RAIL_H */

@ -451,6 +451,7 @@ int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
SetTileOwner(tile, OWNER_NONE); SetTileOwner(tile, OWNER_NONE);
_m[tile].m5 = _m[tile].m5 & 0xC7; _m[tile].m5 = _m[tile].m5 & 0xC7;
break; break;
case MP_STREET: case MP_STREET:
if (!IsLevelCrossing(tile)) return CMD_ERROR; if (!IsLevelCrossing(tile)) return CMD_ERROR;
@ -472,8 +473,8 @@ int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
SetTileOwner(tile, _m[tile].m3); SetTileOwner(tile, _m[tile].m3);
_m[tile].m2 = 0; _m[tile].m2 = 0;
break; break;
case MP_RAILWAY:
case MP_RAILWAY:
if (!IsPlainRailTile(tile)) if (!IsPlainRailTile(tile))
return CMD_ERROR; return CMD_ERROR;
@ -502,6 +503,7 @@ int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
goto skip_mark_dirty; goto skip_mark_dirty;
} }
break; break;
default: default:
assert(0); assert(0);
} }
@ -677,8 +679,7 @@ int32 CmdBuildTrainDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
!_patches.build_on_slopes || !_patches.build_on_slopes ||
IsSteepTileh(tileh) || IsSteepTileh(tileh) ||
!CanBuildDepotByTileh(p2, tileh) !CanBuildDepotByTileh(p2, tileh)
) )) {
) {
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
} }
@ -1783,7 +1784,7 @@ bool SignalVehicleCheck(TileIndex tile, uint track)
static void SetSignalsAfterProc(TrackPathFinder *tpf) static void SetSignalsAfterProc(TrackPathFinder *tpf)
{ {
SetSignalsData *ssd = tpf->userdata; SetSignalsData *ssd = tpf->userdata;
TrackPathFinderLink *link; const TrackPathFinderLink* link;
uint offs; uint offs;
uint i; uint i;
@ -2125,11 +2126,11 @@ static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode)
static void ClickTile_Track(TileIndex tile) static void ClickTile_Track(TileIndex tile)
{ {
if (IsTileDepotType(tile, TRANSPORT_RAIL)) if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
ShowTrainDepotWindow(tile); ShowTrainDepotWindow(tile);
else if (IsRailWaypoint(_m[tile].m5)) } else if (IsRailWaypoint(_m[tile].m5)) {
ShowRenameWaypointWindow(GetWaypointByTile(tile)); ShowRenameWaypointWindow(GetWaypointByTile(tile));
}
} }
static void GetTileDesc_Track(TileIndex tile, TileDesc *td) static void GetTileDesc_Track(TileIndex tile, TileDesc *td)

@ -124,4 +124,3 @@ const RailtypeInfo _railtypes[] = {
24, 24,
}, },
}; };

@ -745,7 +745,8 @@ typedef struct DrawRoadSeqStruct {
#include "table/road_land.h" #include "table/road_land.h"
uint GetRoadFoundation(uint tileh, uint bits) { uint GetRoadFoundation(uint tileh, uint bits)
{
int i; int i;
// normal level sloped building // normal level sloped building
if ((~_valid_tileh_slopes_road[1][tileh] & bits) == 0) if ((~_valid_tileh_slopes_road[1][tileh] & bits) == 0)

@ -487,13 +487,13 @@ static void NewRoadVehWndProc(Window *w, WindowEvent *e)
} }
break; break;
case WE_ON_EDIT_TEXT: { case WE_ON_EDIT_TEXT:
if (e->edittext.str[0] != '\0') { if (e->edittext.str[0] != '\0') {
_cmd_text = e->edittext.str; _cmd_text = e->edittext.str;
DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL, DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL,
CMD_RENAME_ENGINE | CMD_MSG(STR_9037_CAN_T_RENAME_ROAD_VEHICLE)); CMD_RENAME_ENGINE | CMD_MSG(STR_9037_CAN_T_RENAME_ROAD_VEHICLE));
} }
} break; break;
case WE_RESIZE: { case WE_RESIZE: {
if (e->sizing.diff.y == 0) if (e->sizing.diff.y == 0)

@ -1111,11 +1111,11 @@ static uint ReferenceToInt(const void *obj, SLRefType rt)
switch (rt) { switch (rt) {
case REF_VEHICLE_OLD: // Old vehicles we save as new onces case REF_VEHICLE_OLD: // Old vehicles we save as new onces
case REF_VEHICLE: return ((Vehicle *)obj)->index + 1; case REF_VEHICLE: return ((const Vehicle*)obj)->index + 1;
case REF_STATION: return ((Station *)obj)->index + 1; case REF_STATION: return ((const Station*)obj)->index + 1;
case REF_TOWN: return ((Town *)obj)->index + 1; case REF_TOWN: return ((const Town*)obj)->index + 1;
case REF_ORDER: return ((Order *)obj)->index + 1; case REF_ORDER: return ((const Order*)obj)->index + 1;
case REF_ROADSTOPS: return ((RoadStop *)obj)->index + 1; case REF_ROADSTOPS: return ((const RoadStop*)obj)->index + 1;
default: NOT_REACHED(); default: NOT_REACHED();
} }

@ -486,7 +486,7 @@ static char *MakeScreenshotName(const char *ext)
if (_game_mode == GM_EDITOR || _local_player == OWNER_SPECTATOR) { if (_game_mode == GM_EDITOR || _local_player == OWNER_SPECTATOR) {
sprintf(_screenshot_name, "screenshot"); sprintf(_screenshot_name, "screenshot");
} else { } else {
Player *p = &_players[_local_player]; const Player* p = GetPlayer(_local_player);
SetDParam(0, p->name_1); SetDParam(0, p->name_1);
SetDParam(1, p->name_2); SetDParam(1, p->name_2);
SetDParam(2, _date); SetDParam(2, _date);

@ -690,7 +690,6 @@ static const PatchEntry _patches_construction[] = {
{PE_BOOL, 0, STR_CONFIG_PATCHES_SMALL_AIRPORTS, "always_small_airport", &_patches.always_small_airport, 0, 0, 0, NULL}, {PE_BOOL, 0, STR_CONFIG_PATCHES_SMALL_AIRPORTS, "always_small_airport", &_patches.always_small_airport, 0, 0, 0, NULL},
{PE_UINT8, PF_PLAYERBASED, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY, "drag_signals_density", &_patches.drag_signals_density, 1, 20, 1, NULL}, {PE_UINT8, PF_PLAYERBASED, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY, "drag_signals_density", &_patches.drag_signals_density, 1, 20, 1, NULL},
{PE_BOOL, 0, STR_CONFIG_AUTO_PBS_PLACEMENT, "auto_pbs_placement", &_patches.auto_pbs_placement, 1, 20, 1, NULL}, {PE_BOOL, 0, STR_CONFIG_AUTO_PBS_PLACEMENT, "auto_pbs_placement", &_patches.auto_pbs_placement, 1, 20, 1, NULL},
}; };
static const PatchEntry _patches_vehicles[] = { static const PatchEntry _patches_vehicles[] = {
@ -734,7 +733,6 @@ static const PatchEntry _patches_stations[] = {
{PE_UINT8, 0, STR_CONFIG_PATCHES_STATION_SPREAD, "station_spread", &_patches.station_spread, 4, 64, 1, &InvalidateStationBuildWindow}, {PE_UINT8, 0, STR_CONFIG_PATCHES_STATION_SPREAD, "station_spread", &_patches.station_spread, 4, 64, 1, &InvalidateStationBuildWindow},
{PE_BOOL, 0, STR_CONFIG_PATCHES_SERVICEATHELIPAD, "service_at_helipad", &_patches.serviceathelipad, 0, 0, 0, NULL}, {PE_BOOL, 0, STR_CONFIG_PATCHES_SERVICEATHELIPAD, "service_at_helipad", &_patches.serviceathelipad, 0, 0, 0, NULL},
{PE_BOOL, 0, STR_CONFIG_PATCHES_CATCHMENT, "modified_catchment", &_patches.modified_catchment, 0, 0, 0, NULL}, {PE_BOOL, 0, STR_CONFIG_PATCHES_CATCHMENT, "modified_catchment", &_patches.modified_catchment, 0, 0, 0, NULL},
}; };
static const PatchEntry _patches_economy[] = { static const PatchEntry _patches_economy[] = {

@ -256,14 +256,13 @@ do_change_service_int:
DeleteWindow(w); DeleteWindow(w);
break; break;
case WE_ON_EDIT_TEXT: { case WE_ON_EDIT_TEXT:
if (e->edittext.str[0] != '\0') { if (e->edittext.str[0] != '\0') {
_cmd_text = e->edittext.str; _cmd_text = e->edittext.str;
DoCommandP(0, w->window_number, 0, NULL, DoCommandP(0, w->window_number, 0, NULL,
CMD_NAME_VEHICLE | CMD_MSG(STR_9832_CAN_T_NAME_SHIP)); CMD_NAME_VEHICLE | CMD_MSG(STR_9832_CAN_T_NAME_SHIP));
} }
} break; break;
} }
} }
@ -406,13 +405,13 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
} }
break; break;
case WE_ON_EDIT_TEXT: { case WE_ON_EDIT_TEXT:
if (e->edittext.str[0] != '\0') { if (e->edittext.str[0] != '\0') {
_cmd_text = e->edittext.str; _cmd_text = e->edittext.str;
DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL, DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL,
CMD_RENAME_ENGINE | CMD_MSG(STR_9839_CAN_T_RENAME_SHIP_TYPE)); CMD_RENAME_ENGINE | CMD_MSG(STR_9839_CAN_T_RENAME_SHIP_TYPE));
} }
} break; break;
case WE_RESIZE: case WE_RESIZE:
w->vscroll.cap += e->sizing.diff.y / 24; w->vscroll.cap += e->sizing.diff.y / 24;

@ -968,9 +968,9 @@ static void ExtraViewPortWndProc(Window *w, WindowEvent *e)
WP(w2, vp_d).scrollpos_y = y - (w2->viewport->virtual_height - w->viewport->virtual_height) / 2; WP(w2, vp_d).scrollpos_y = y - (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
} break; } break;
case 8: { /* inverse location button (move this view to same spot as main view) 'Copy Location' */ case 8: { /* inverse location button (move this view to same spot as main view) 'Copy Location' */
const Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0); const Window* w2 = FindWindowById(WC_MAIN_WINDOW, 0);
int x = WP(w2, vp_d).scrollpos_x; int x = WP(w2, const vp_d).scrollpos_x;
int y = WP(w2, vp_d).scrollpos_y; int y = WP(w2, const vp_d).scrollpos_y;
WP(w, vp_d).scrollpos_x = x + (w2->viewport->virtual_width - w->viewport->virtual_width) / 2; WP(w, vp_d).scrollpos_x = x + (w2->viewport->virtual_width - w->viewport->virtual_width) / 2;
WP(w, vp_d).scrollpos_y = y + (w2->viewport->virtual_height - w->viewport->virtual_height) / 2; WP(w, vp_d).scrollpos_y = y + (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;

@ -19,7 +19,7 @@ typedef struct DrawTileSeqStruct {
typedef struct DrawTileSprites { typedef struct DrawTileSprites {
SpriteID ground_sprite; SpriteID ground_sprite;
DrawTileSeqStruct const *seq; const DrawTileSeqStruct* seq;
} DrawTileSprites; } DrawTileSprites;
// Iterate through all DrawTileSeqStructs in DrawTileSprites. // Iterate through all DrawTileSeqStructs in DrawTileSprites.

@ -4,6 +4,7 @@
#include "openttd.h" #include "openttd.h"
#include "debug.h" #include "debug.h"
#include "functions.h" #include "functions.h"
#include "macros.h"
#include "spritecache.h" #include "spritecache.h"
#include "table/sprites.h" #include "table/sprites.h"
#include "fileio.h" #include "fileio.h"
@ -334,7 +335,7 @@ static void* AllocSprite(size_t mem_req)
/* Align this to an uint32 boundary. This also makes sure that the 2 least /* Align this to an uint32 boundary. This also makes sure that the 2 least
* bits are not used, so we could use those for other things. */ * bits are not used, so we could use those for other things. */
mem_req = (mem_req + sizeof(uint32) - 1) & ~(sizeof(uint32) - 1); mem_req = ALIGN(mem_req, sizeof(uint32));
for (;;) { for (;;) {
MemBlock* s; MemBlock* s;

@ -315,7 +315,8 @@ static inline bool IsBuoy(const Station* st)
return st->had_vehicle_of_type & HVOT_BUOY; /* XXX: We should really ditch this ugly coding and switch to something sane... */ return st->had_vehicle_of_type & HVOT_BUOY; /* XXX: We should really ditch this ugly coding and switch to something sane... */
} }
static inline bool IsBuoyTile(TileIndex tile) { static inline bool IsBuoyTile(TileIndex tile)
{
return IsTileType(tile, MP_STATION) && _m[tile].m5 == 0x52; return IsTileType(tile, MP_STATION) && _m[tile].m5 == 0x52;
} }

@ -3222,4 +3222,3 @@ const ChunkHandler _station_chunk_handlers[] = {
{ 'STNS', Save_STNS, Load_STNS, CH_ARRAY }, { 'STNS', Save_STNS, Load_STNS, CH_ARRAY },
{ 'ROAD', Save_ROADSTOP, Load_ROADSTOP, CH_ARRAY | CH_LAST}, { 'ROAD', Save_ROADSTOP, Load_ROADSTOP, CH_ARRAY | CH_LAST},
}; };

@ -1122,4 +1122,3 @@ void InitializeLanguagePacks(void)
if (!ReadLanguagePack(def)) if (!ReadLanguagePack(def))
error("can't read language pack '%s'", dl->ent[def].file); error("can't read language pack '%s'", dl->ent[def].file);
} }

@ -478,5 +478,3 @@ static const AiDefaultBlockData * const _airport_default_block_data[] = {
_airportdata_ai_1, // country airport _airportdata_ai_1, // country airport
NULL NULL
}; };

@ -773,5 +773,3 @@ static const uint32 * const _bridge_poles_table[] = {
_bridge_sprite_table_11_poles, _bridge_sprite_table_11_poles,
_bridge_sprite_table_12_poles _bridge_sprite_table_12_poles
}; };

@ -60,4 +60,3 @@ static const SpriteID _clear_land_sprites_3[8] = {
0x11B3, 0x11B3,
0x11C6, 0x11C6,
}; };

@ -165,4 +165,3 @@ static const SpriteID _slopes_spriteindexes_3[] = {
SPR_SLOPES_BASE, SPR_SLOPES_BASE+73, SPR_SLOPES_BASE, SPR_SLOPES_BASE+73,
0xffff, 0xffff,
}; };

@ -87,7 +87,7 @@ enum Sprites {
SPR_SHADOW_CELL = 1004, SPR_SHADOW_CELL = 1004,
/* Sliced view shadow cells */ /* Sliced view shadow cells */
/* Maybe we have differen ones in the future */ /* Maybe we have different ones in the future */
SPR_MAX_SLICE = SPR_OPENTTD_BASE + 71, SPR_MAX_SLICE = SPR_OPENTTD_BASE + 71,
SPR_MIN_SLICE = SPR_OPENTTD_BASE + 71, SPR_MIN_SLICE = SPR_OPENTTD_BASE + 71,

@ -62,4 +62,3 @@ static const DrawTrackSeqStruct* const _track_depot_layout_table[] = {
_track_waypoint_table_0, _track_waypoint_table_0,
_track_waypoint_table_1, _track_waypoint_table_1,
}; };

@ -221,4 +221,3 @@ static const PalSpriteID _tree_layout_sprite[164+(79-48+1)][4] = {
}; };
#endif /* TREE_LAND_H */ #endif /* TREE_LAND_H */

@ -39,14 +39,14 @@ static TextMessage _text_message_list[MAX_CHAT_MESSAGES];
TileIndex _animated_tile_list[256]; TileIndex _animated_tile_list[256];
int _textmessage_width = 0; static int _textmessage_width = 0;
bool _textmessage_dirty = true; static bool _textmessage_dirty = true;
bool _textmessage_visible = false; static bool _textmessage_visible = false;
const int _textmessage_box_left = 10; // Pixels from left static const int _textmessage_box_left = 10; // Pixels from left
const int _textmessage_box_y = 150; // Height of box static const int _textmessage_box_y = 150; // Height of box
const int _textmessage_box_bottom = 30; // Pixels from bottom static const int _textmessage_box_bottom = 30; // Pixels from bottom
const int _textmessage_box_max_width = 400; // Max width of box static const int _textmessage_box_max_width = 400; // Max width of box
static Pixel _textmessage_backup[150 * 400]; // (y * max_width) static Pixel _textmessage_backup[150 * 400]; // (y * max_width)
@ -379,5 +379,3 @@ static void SaveLoad_ANIT(void)
const ChunkHandler _animated_tile_chunk_handlers[] = { const ChunkHandler _animated_tile_chunk_handlers[] = {
{ 'ANIT', SaveLoad_ANIT, SaveLoad_ANIT, CH_RIFF | CH_LAST}, { 'ANIT', SaveLoad_ANIT, SaveLoad_ANIT, CH_RIFF | CH_LAST},
}; };

@ -1561,7 +1561,7 @@ static void TownActionAdvertise(Town *t, int action)
static void TownActionRoadRebuild(Town *t, int action) static void TownActionRoadRebuild(Town *t, int action)
{ {
Player *p; const Player* p;
t->road_build_months = 6; t->road_build_months = 6;

@ -273,13 +273,13 @@ static void TownViewWndProc(Window *w, WindowEvent *e)
} }
break; break;
case WE_ON_EDIT_TEXT: { case WE_ON_EDIT_TEXT:
if (e->edittext.str[0] != '\0') { if (e->edittext.str[0] != '\0') {
_cmd_text = e->edittext.str; _cmd_text = e->edittext.str;
DoCommandP(0, w->window_number, 0, NULL, DoCommandP(0, w->window_number, 0, NULL,
CMD_RENAME_TOWN | CMD_MSG(STR_2008_CAN_T_RENAME_TOWN)); CMD_RENAME_TOWN | CMD_MSG(STR_2008_CAN_T_RENAME_TOWN));
} }
} break; break;
} }
} }
@ -525,5 +525,3 @@ void ShowTownDirectory(void)
w->resize.height = w->height - 10 * 6; // minimum of 10 items in the list, each item 10 high w->resize.height = w->height - 10 * 6; // minimum of 10 items in the list, each item 10 high
} }
} }

@ -1283,13 +1283,13 @@ do_change_service_int:
DeleteWindow(w); DeleteWindow(w);
break; break;
case WE_ON_EDIT_TEXT: { case WE_ON_EDIT_TEXT:
if (e->edittext.str[0] != '\0') { if (e->edittext.str[0] != '\0') {
_cmd_text = e->edittext.str; _cmd_text = e->edittext.str;
DoCommandP(0, w->window_number, 0, NULL, DoCommandP(0, w->window_number, 0, NULL,
CMD_NAME_VEHICLE | CMD_MSG(STR_8866_CAN_T_NAME_TRAIN)); CMD_NAME_VEHICLE | CMD_MSG(STR_8866_CAN_T_NAME_TRAIN));
} }
} break; break;
} }
} }

@ -344,7 +344,8 @@ static uint GetSlopeZ_Trees(const TileInfo* ti)
return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z; return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
} }
static uint GetSlopeTileh_Trees(const TileInfo *ti) { static uint GetSlopeTileh_Trees(const TileInfo* ti)
{
return ti->tileh; return ti->tileh;
} }

@ -305,7 +305,6 @@ bool UpdateSignalsOnSegment(TileIndex tile, byte direction);
void SetSignalsOnBothDir(TileIndex tile, byte track); void SetSignalsOnBothDir(TileIndex tile, byte track);
Vehicle *CheckClickOnVehicle(const ViewPort *vp, int x, int y); Vehicle *CheckClickOnVehicle(const ViewPort *vp, int x, int y);
//uint GetVehicleWeight(Vehicle *v);
void DecreaseVehicleValue(Vehicle *v); void DecreaseVehicleValue(Vehicle *v);
void CheckVehicleBreakdown(Vehicle *v); void CheckVehicleBreakdown(Vehicle *v);
@ -395,9 +394,7 @@ static inline bool IsValidVehicle(const Vehicle *v)
*/ */
static inline bool IsVehicleIndex(uint index) static inline bool IsVehicleIndex(uint index)
{ {
if (index < GetVehiclePoolSize()) return true; return index < GetVehiclePoolSize();
return false;
} }
/* Returns order 'index' of a vehicle or NULL when it doesn't exists */ /* Returns order 'index' of a vehicle or NULL when it doesn't exists */
@ -448,9 +445,6 @@ VARDEF VehicleID _new_roadveh_id;
VARDEF uint16 _aircraft_refit_capacity; VARDEF uint16 _aircraft_refit_capacity;
VARDEF byte _cmd_build_rail_veh_score; VARDEF byte _cmd_build_rail_veh_score;
// for each player, for each vehicle type, keep a list of the vehicles.
//VARDEF Vehicle *_vehicle_arr[8][4];
#define INVALID_VEHICLE 0xFFFF #define INVALID_VEHICLE 0xFFFF
#define INVALID_ENGINE 0xFFFF #define INVALID_ENGINE 0xFFFF

@ -744,4 +744,3 @@ const TileTypeProcs _tile_type_water_procs = {
NULL, /* vehicle_leave_tile_proc */ NULL, /* vehicle_leave_tile_proc */
GetSlopeTileh_Water, /* get_slope_tileh_proc */ GetSlopeTileh_Water, /* get_slope_tileh_proc */
}; };

@ -159,7 +159,7 @@ int GetWidgetFromPos(const Window *w, int x, int y)
void DrawWindowWidgets(const Window *w) void DrawWindowWidgets(const Window *w)
{ {
const Widget *wi; const Widget *wi;
DrawPixelInfo *dpi = _cur_dpi; const DrawPixelInfo* dpi = _cur_dpi;
Rect r; Rect r;
uint32 cur_click, cur_disabled, cur_hidden; uint32 cur_click, cur_disabled, cur_hidden;

Loading…
Cancel
Save