@@ -1012,14 +1012,13 @@ static void SubsidyMonthlyHandler(void)
Station *st;
uint n;
FoundRoute fr;
bool modified = false;
for(s=_subsidies; s != endof(_subsidies); s++) {
if (s->cargo_type == CT_INVALID)
continue;
if (s->cargo_type == CT_INVALID) continue;
if (s->age == 12-1) {
pair = SetupSubsidyDecodeParam(s, 1);
AddNewsItem(STR_202E_OFFER_OF_SUBSIDY_EXPIRED, NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_SUBSIDIES, 0), pair.a, pair.b);
s->cargo_type = CT_INVALID;
modified = true;
@@ -220,14 +220,13 @@ void GenerateWorld(int mode, uint size_x
StartupEngines();
StartupDisasters();
_generating_world = false;
// No need to run the tile loop in the scenario editor.
if (mode != GW_EMPTY) {
for(i=0x500; i!=0; i--)
RunTileLoop();
for (i = 0x500; i != 0; i--) RunTileLoop();
}
ResetObjectToPlace();
void DeleteName(StringID id)
@@ -1373,14 +1373,15 @@ static void SaveLoadDlgWndProc(Window *w
/* In the editor set up the vehicle engines correctly (date might have changed) */
if (_game_mode == GM_EDITOR) StartupEngines();
break;
case WE_DESTROY:
// pause is only used in single-player, non-editor mode, non menu mode
if(!_networking && (_game_mode != GM_EDITOR) && (_game_mode != GM_MENU))
if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
FiosFreeSavegameList();
CLRBIT(_no_scroll, SCROLL_SAVE);
case WE_RESIZE: {
/* Widget 2 and 3 have to go with halve speed, make it so obiwan */
uint diff = e->sizing.diff.x / 2;
@@ -373,14 +373,13 @@ static byte GeneratePlayerColor(void)
byte colors[16], pcolor, t2;
int i,j,n;
uint32 r;
Player *p;
// Initialize array
for(i=0; i!=16; i++)
colors[i] = i;
for (i = 0; i != 16; i++) colors[i] = i;
// And randomize it
n = 100;
do {
r = Random();
COLOR_SWAP(GB(r, 0, 4), GB(r, 4, 4));
@@ -1250,13 +1249,14 @@ static const SaveLoad _player_ai_build_r
SLE_VAR(AiBuildRec,buildcmd_b, SLE_UINT8),
SLE_VAR(AiBuildRec,direction, SLE_UINT8),
SLE_VAR(AiBuildRec,cargo, SLE_UINT8),
SLE_END()
};
static void SaveLoad_PLYR(Player *p) {
static void SaveLoad_PLYR(Player* p)
{
int i;
SlObject(p, _player_desc);
// Write AI?
if (!IS_HUMAN_PLAYER(p->index)) {
@@ -775,17 +775,15 @@ static void SlSaveChunks(void)
*/
static const ChunkHandler *SlFindChunkHandler(uint32 id)
const ChunkHandler *ch;
const ChunkHandler *const *chsc;
for (chsc = _sl.chs; (ch=*chsc++) != NULL;) {
while(true) {
if (ch->id == id)
return ch;
if (ch->flags & CH_LAST)
for (;;) {
if (ch->id == id) return ch;
if (ch->flags & CH_LAST) break;
ch++;
return NULL;
@@ -427,12 +427,13 @@ static bool load_intlist(const char *str
static void make_intlist(char *buf, void *array, int nelems, int type)
int i, v = 0;
byte *p = (byte*)array;
for(i=0; i!=nelems; i++) {
switch(type) {
case SDT_INT8 >> 4: v = *(int8*)p; p += 1; break;
case SDT_UINT8 >> 4:v = *(byte*)p; p += 1; break;
case SDT_INT16 >> 4:v = *(int16*)p; p += 2; break;
case SDT_UINT16 >> 4:v = *(uint16*)p; p += 2; break;
@@ -301,14 +301,13 @@ static int TranslateArgumentIdx(int arg)
static void EmitWordList(char **words, int nw)
int i,j;
PutByte(nw);
for(i=0; i<nw; i++)
PutByte(strlen(words[i]));
for (i = 0; i < nw; i++) PutByte(strlen(words[i]));
for(i=0; i<nw; i++) {
for(j=0; words[i][j]; j++)
PutByte(words[i][j]);
@@ -362,14 +361,13 @@ static void EmitGender(char *buf, int va
if (buf[0] == '=') {
buf++;
// This is a {G=DER} command
for(nw=0; ;nw++) {
if (nw >= 8)
Fatal("G argument '%s' invalid", buf);
if (nw >= 8) Fatal("G argument '%s' invalid", buf);
if (!strcmp(buf, _genders[nw]))
// now nw contains the gender index
PutByte(0x87);
@@ -463,12 +463,13 @@ static int DeterminePluralForm(int32 n)
static const char *ParseStringChoice(const char *b, uint form, char *dst, int *dstlen)
//<NUM> {Length of each string} {each string}
uint n = (byte)*b++;
uint pos,i, mylen=0,mypos=0;
for(i=pos=0; i!=n; i++) {
uint len = (byte)*b++;
if (i == form) {
mypos = pos;
mylen = len;
@@ -1170,14 +1170,13 @@ static bool CheckFree2x2Area(Town *t1, T
{1 - 1, 1 - 0}
for(i=0; i!=4; i++) {
tile += ToTileIndexDiff(_tile_add[i]);
if (GetTileSlope(tile, NULL))
return false;
if (GetTileSlope(tile, NULL)) return false;
if (CmdFailed(DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER | DC_FORCETEST, CMD_LANDSCAPE_CLEAR)))
return true;
@@ -2211,13 +2211,13 @@ static bool CheckReverseTrain(Vehicle *v
if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE))
reverse_best = true;
else
reverse_best = false;
} else {
fd.best_bird_dist = (uint)-1;
fd.best_track_dist = (uint)-1;
NewTrainPathfind(v->tile, v->dest_tile, reverse ^ i, (NTPEnumProc*)NtpCallbFindStation, &fd);
if (best_track != -1) {
@@ -1005,14 +1005,20 @@ static void DrawBridgePillars(const Tile
if (IsSteepTileh(ti->tileh)) {
if (!(ti->tileh & p[2])) front_height += 8;
if (!(ti->tileh & p[3])) back_height += 8;
for(; z>=front_height || z>=back_height; z=z-8) {
if (z>=front_height) AddSortableSpriteToDraw(image, x,y, p[4], p[5], 0x28, z); // front facing pillar
if (z>=back_height && z<i-8) AddSortableSpriteToDraw(image, x - p[6], y - p[7], p[4], p[5], 0x28, z); // back facing pillar
if (z >= front_height) {
// front facing pillar
AddSortableSpriteToDraw(image, x,y, p[4], p[5], 0x28, z);
if (z >= back_height && z < i - 8) {
// back facing pillar
AddSortableSpriteToDraw(image, x - p[6], y - p[7], p[4], p[5], 0x28, z);
uint GetBridgeFoundation(uint tileh, byte direction)
@@ -1942,14 +1942,13 @@ byte GetDirectionTowards(const Vehicle *
Trackdir GetVehicleTrackdir(const Vehicle* v)
if (v->vehstatus & VS_CRASHED) return 0xFF;
switch(v->type)
switch (v->type) {
case VEH_Train:
if (v->u.rail.track == 0x80) /* We'll assume the train is facing outwards */
return DiagdirToDiagTrackdir(GetDepotDirection(v->tile, TRANSPORT_RAIL)); /* Train in depot */
if (v->u.rail.track == 0x40) /* train in tunnel, so just use his direction and assume a diagonal track */
return DiagdirToDiagTrackdir((v->direction >> 1) & 3);
@@ -706,13 +706,13 @@ static void Win32GdiMainLoop(void)
MSG mesg;
uint32 next_tick = GetTickCount() + 30, cur_ticks;
_wnd.running = true;
while (PeekMessage(&mesg, NULL, 0, 0, PM_REMOVE)) {
InteractiveRandom(); // randomness
TranslateMessage(&mesg);
DispatchMessage(&mesg);
if (_exit_game) return;
@@ -138,13 +138,13 @@ static void GetFileInfo(DebugFileInfo *d
FILETIME write_time;
uint32 crc = (uint32)-1;
file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, 0);
if (file != INVALID_HANDLE_VALUE) {
if (ReadFile(file, buffer, sizeof(buffer), &numread, NULL) == 0 ||
numread == 0)
filesize += numread;
crc = CalcCRC(buffer, numread, crc);
Status change: