From 7aa0bdf48b8f27389ad69c4299b8d910398c43d5 Mon Sep 17 00:00:00 2001 From: truelight Date: Sat, 11 Sep 2004 09:55:19 +0000 Subject: [PATCH] (svn r202) -Codechange: I missed some files with trailing spaces.. this should be all ;) --- industry_cmd.c | 120 ++++++++++++++++---------------- misc.c | 36 +++++----- pathfind.h | 2 +- players.c | 58 ++++++++-------- queue.c | 8 +-- queue.h | 2 +- rail_cmd.c | 182 ++++++++++++++++++++++++------------------------- rail_gui.c | 64 ++++++++--------- resource.h | 2 +- road_cmd.c | 92 ++++++++++++------------- 10 files changed, 283 insertions(+), 283 deletions(-) diff --git a/industry_cmd.c b/industry_cmd.c index 96ee9d98cf..922e5d1cbe 100644 --- a/industry_cmd.c +++ b/industry_cmd.c @@ -194,7 +194,7 @@ static void IndustryDrawTileProc1(TileInfo *ti) if (!(_map_owner[ti->tile] & 0x80)) return; - + d = &_draw_industry_spec1[_map3_lo[ti->tile]]; AddChildSpriteScreen(0x12A7 + d->image_1, d->x, 0); @@ -203,14 +203,14 @@ static void IndustryDrawTileProc1(TileInfo *ti) AddChildSpriteScreen(0x12B0 + image - 1, 8, 41); if ( (image = d->image_3) != 0) - AddChildSpriteScreen(0x12AC + image - 1, + AddChildSpriteScreen(0x12AC + image - 1, _drawtile_proc1_x[image-1], _drawtile_proc1_y[image-1]); } static void IndustryDrawTileProc2(TileInfo *ti) { int x = 0; - + if (_map_owner[ti->tile] & 0x80) { x = _industry_anim_offs[_map3_lo[ti->tile]]; if ( (byte)x == 0xFF) @@ -224,7 +224,7 @@ static void IndustryDrawTileProc2(TileInfo *ti) static void IndustryDrawTileProc3(TileInfo *ti) { if (_map_owner[ti->tile] & 0x80) { - AddChildSpriteScreen(0x128B, 5, + AddChildSpriteScreen(0x128B, 5, _industry_anim_offs_2[_map3_lo[ti->tile]]); } AddChildSpriteScreen(0x30B928A, 3, 67); @@ -254,7 +254,7 @@ static void DrawCoalPlantSparkles(TileInfo *ti) if (image & 0x80) { image = (image >> 2) & 0x1F; if (image != 0 && image < 7) { - AddChildSpriteScreen(image + 0x806, + AddChildSpriteScreen(image + 0x806, _coal_plant_sparkles_x[image-1], _coal_plant_sparkles_y[image-1] ); @@ -305,11 +305,11 @@ static void DrawTile_Industry(TileInfo *ti) if (image&0x8000 && (image & 0xFFFF0000) == 0) image |= ormod; - + if (!(_display_opt & DO_TRANS_BUILDINGS)) image = (image & 0x3FFF) | 0x3224000; - - AddSortableSpriteToDraw(image, + + AddSortableSpriteToDraw(image, ti->x | (dits->subtile_xy>>4), ti->y | (dits->subtile_xy&0xF), (dits->width_height>>4)+1, @@ -321,7 +321,7 @@ static void DrawTile_Industry(TileInfo *ti) return; } - /* TTDBUG: strange code here, return if AddSortableSpriteToDraw failed? */ + /* TTDBUG: strange code here, return if AddSortableSpriteToDraw failed? */ { int proc; if ((proc=dits->proc-1) >= 0 ) @@ -406,15 +406,15 @@ int32 CmdDestroyIndustry(int x, int y, uint32 flags, uint32 p1, uint32 p2) // check if you're allowed to remove the industry. Minimum amount // of ratings to remove the industry depends on difficulty setting - if (!CheckforTownRating(tile, flags, t, INDUSTRY_REMOVE)) + if (!CheckforTownRating(tile, flags, t, INDUSTRY_REMOVE)) return CMD_ERROR; - + if (flags & DC_EXEC) { DeleteIndustry(i); CreateEffectVehicleAbove(x + 8,y + 8, 2, EV_DEMOLISH); ChangeTownRating(t, -1500, -1000); // penalty is 1500 } - + return (_price.build_industry >> 5) * _industry_type_costs[i->type]*2; } */ @@ -435,7 +435,7 @@ void TransportIndustryGoods(uint tile) byte m5; i = DEREF_INDUSTRY(_map2[tile]); - + type = i->type; cw = min(i->cargo_waiting[0], 255); if (cw > _industry_min_cargo[type]/* && i->produced_cargo[0] != 0xFF*/) { @@ -459,9 +459,9 @@ void TransportIndustryGoods(uint tile) cw = min(i->cargo_waiting[1], 255); if (cw > _industry_min_cargo[type]) { i->cargo_waiting[1] -= cw; - + if (_economy.fluct <= 0) cw = (cw + 1) >> 1; - + i->last_mo_production[1] += cw; am = MoveGoodsToStation(i->xy, i->width, i->height, i->produced_cargo[1], cw); @@ -478,7 +478,7 @@ static void AnimateTile_Industry(uint tile) case 174: if ((_tick_counter & 1) == 0) { m = _map3_lo[tile] + 1; - + switch(m & 7) { case 2: SndPlayTileFx(45, tile); break; case 6: SndPlayTileFx(41, tile); break; @@ -497,7 +497,7 @@ static void AnimateTile_Industry(uint tile) case 165: if ((_tick_counter & 3) == 0) { m = _map3_lo[tile]; - + if (_industry_anim_offs[m] == 0xFF) { SndPlayTileFx(48, tile); } @@ -556,7 +556,7 @@ static void AnimateTile_Industry(uint tile) _map3_hi[tile] = 0; DeleteAnimatedTile(tile); } - _map3_lo[tile] = m; + _map3_lo[tile] = m; MarkTileDirtyByTile(tile); } break; @@ -581,7 +581,7 @@ static void AnimateTile_Industry(uint tile) if (m == 4 && (m=0,++n) == 32+1 && (n=30,b)) { _map_owner[tile] = 0x83; _map5[tile] = 29; - DeleteAnimatedTile(tile); + DeleteAnimatedTile(tile); } else { _map5[tile] = n; _map_owner[tile] = (_map_owner[tile] & ~3) | m; @@ -648,7 +648,7 @@ static void MakeIndustryTileBigger(uint tile, byte size) size = (size + 1) & 3; if (size == 3) size |= 0x80; _map_owner[tile] = size | b; - + MarkTileDirtyByTile(tile); if (!(_map_owner[tile] & 0x80)) @@ -692,7 +692,7 @@ static void TileLoopIndustryCase161(uint tile) }; SndPlayTileFx(46, tile); - + dir = Random() & 3; v = CreateEffectVehicleAbove( @@ -783,7 +783,7 @@ static void TileLoop_Industry(uint tile) break; case 49: { - CreateEffectVehicleAbove(GET_TILE_X(tile)*16 + 6, GET_TILE_Y(tile)*16 + 6, 43, EV_SMOKE_3); + CreateEffectVehicleAbove(GET_TILE_X(tile)*16 + 6, GET_TILE_Y(tile)*16 + 6, 43, EV_SMOKE_3); } break; @@ -800,8 +800,8 @@ static void TileLoop_Industry(uint tile) case 161: TileLoopIndustryCase161(tile); - break; - + break; + case 165: AddAnimatedTile(tile); break; @@ -840,7 +840,7 @@ static void ChangeTileOwner_Industry(uint tile, byte old_player, byte new_player void DeleteIndustry(Industry *i) { int index = i - _industries; - + BEGIN_TILE_LOOP(tile_cur, i->width, i->height, i->xy); if (IS_TILETYPE(tile_cur, MP_INDUSTRY)) { if (_map2[tile_cur] == (byte)index) { @@ -850,7 +850,7 @@ void DeleteIndustry(Industry *i) DeleteOilRig(tile_cur); } END_TILE_LOOP(tile_cur, i->width, i->height, i->xy); - + i->xy = 0; _industry_sort_dirty = true; DeleteSubsidyWithIndustry(index); @@ -894,9 +894,9 @@ static void SetupFarmFieldFence(uint tile, int size, byte type, int direction) do { tile = TILE_MASK(tile); - + if (IS_TILETYPE(tile, MP_CLEAR) || IS_TILETYPE(tile, MP_TREES)) { - + or = type; if (or == 1 && (uint16)Random() <= 9362) or = 2; @@ -908,7 +908,7 @@ static void SetupFarmFieldFence(uint tile, int size, byte type, int direction) } _map3_hi[tile] = (_map3_hi[tile] & and) | or; } - + tile += direction ? TILE_XY(0,1) : TILE_XY(1,0); } while (--size); } @@ -933,7 +933,7 @@ static void PlantFarmField(uint tile) /* offset tile to match size */ tile = tile - TILE_XY(size_x>>1, size_y>>1); - + /* check the amount of bad tiles */ count = 0; BEGIN_TILE_LOOP(cur_tile, size_x, size_y, tile) @@ -952,15 +952,15 @@ static void PlantFarmField(uint tile) BEGIN_TILE_LOOP(cur_tile, size_x, size_y, tile) cur_tile = TILE_MASK(cur_tile); if (!IsBadFarmFieldTile2(cur_tile)) { - ModifyTile(cur_tile, - MP_SETTYPE(MP_CLEAR) | + ModifyTile(cur_tile, + MP_SETTYPE(MP_CLEAR) | MP_MAP2_CLEAR | MP_MAP3LO | MP_MAP3HI_CLEAR | MP_MAPOWNER | MP_MAP5, type2, /* map3_lo */ OWNER_NONE, /* map_owner */ type); /* map5 */ } END_TILE_LOOP(cur_tile, size_x, size_y, tile) - + type = 3; if (_opt.landscape != LT_HILLY && _opt.landscape != LT_DESERT) { type = _plantfarmfield_type[Random() & 0xF]; @@ -979,13 +979,13 @@ static void MaybePlantFarmField(Industry *i) tile = TileAddWrap(i->xy, ((i->width>>1) + Random() % 31 - 16), ((i->height>>1) + Random() % 31 - 16)); if (tile != TILE_WRAPPED) PlantFarmField(tile); - } + } } static void ChopLumberMillTrees(Industry *i) { static const TileIndexDiff _chop_dir[4] = { TILE_XY(0,1), TILE_XY(1,0), TILE_XY(0,-1), TILE_XY(-1,0) }; - + uint tile = i->xy; int dir, a, j; @@ -1096,9 +1096,9 @@ void OnTick_Industry() _industry_sound_ctr++; if (_industry_sound_ctr == 75) { - SndPlayTileFx(55, _industry_sound_tile); + SndPlayTileFx(55, _industry_sound_tile); } else if (_industry_sound_ctr == 160) { - _industry_sound_ctr = 0; + _industry_sound_ctr = 0; SndPlayTileFx(54, _industry_sound_tile); } } @@ -1134,7 +1134,7 @@ extern bool _ignore_restrictions; static bool CheckNewIndustry_Oilwell(uint tile, int type) { int x,y; - + if(_ignore_restrictions && _game_mode == GM_EDITOR) return true; @@ -1230,7 +1230,7 @@ static Town *CheckMultipleIndustryInTown(uint tile, int type) Industry *i; t = ClosestTownFromTile(tile, (uint)-1); - + if (_patches.multiple_industry_per_town) return t; @@ -1285,9 +1285,9 @@ static bool CheckIfIndustryTilesAreFree(uint tile, const IndustryTileTable *it, continue; return false; } - + FindLandscapeHeightByTile(&ti, cur_tile); - + if (it->map5 == 0xFF) { if (ti.type != MP_WATER || ti.tileh != 0) return false; @@ -1310,7 +1310,7 @@ static bool CheckIfIndustryTilesAreFree(uint tile, const IndustryTileTable *it, if (bits & 0x10) return false; - + t = ~ti.tileh; if (bits & 1 && (t & (1+8))) @@ -1344,7 +1344,7 @@ static bool CheckIfIndustryTilesAreFree(uint tile, const IndustryTileTable *it, if (ti.type != MP_HOUSE) { _error_message = STR_0316_CAN_ONLY_BE_BUILT_IN_TOWNS; return false; - } + } } else { do_clear: if (DoCommandByTile(cur_tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR) == CMD_ERROR) @@ -1366,7 +1366,7 @@ static bool CheckIfTooCloseToIndustry(uint tile, int type) // accepting industries won't be close, not even with patch if (_patches.same_industry_close && (spec->accepts_cargo[0] == 0xFF) ) return true; - + for(i=_industries; i != endof(_industries); i++) { // check if an industry that accepts the same goods is nearby if (i->xy != 0 && @@ -1451,7 +1451,7 @@ static void DoCreateNewIndustry(Industry *i, uint tile, int type, const Industry if (_generating_world == 0) i->total_production[0] = i->total_production[1] = 0; - + i->prod_level = 0x10; do { @@ -1512,7 +1512,7 @@ int32 CmdBuildIndustry(int x, int y, uint32 flags, uint32 p1, uint32 p2) if ((t=CheckMultipleIndustryInTown(tile, p1)) == NULL) return CMD_ERROR; - + num = spec->num_table; itt = spec->table; @@ -1530,7 +1530,7 @@ int32 CmdBuildIndustry(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (flags & DC_EXEC) DoCreateNewIndustry(i, tile, p1, it, t, 0x10); - + return (_price.build_industry >> 5) * _industry_type_costs[p1]; } @@ -1567,7 +1567,7 @@ Industry *CreateNewIndustry(uint tile, int type) return NULL; DoCreateNewIndustry(i, tile, type, it, t, 0x10); - + return i; } @@ -1590,7 +1590,7 @@ static void PlaceInitialIndustry(byte type, int amount) int i = 2000; do { if (CreateNewIndustry(TILE_MASK(Random()), type) != NULL) - break; + break; } while (--i != 0); } while (--num); } @@ -1627,7 +1627,7 @@ static void ExtChangeIndustryProduction(Industry *i) change = old = i->production_rate[j]; if (CHANCE16R(20,1024,r))change -= ((RandomRange(50) + 10)*old) >> 8; if (CHANCE16I(20+(i->pct_transported[j]*20>>8),1024,r>>16)) change += ((RandomRange(50) + 10)*old) >> 8; - + // make sure it doesn't exceed 255 or goes below 0 change = clamp(change, 0, 255); if (change == old) { @@ -1640,14 +1640,14 @@ static void ExtChangeIndustryProduction(Industry *i) if (change >= _industry_spec[i->type].production_rate[j]/4) closeit = false; - + mag = abs(percent); if (mag >= 10) { SET_DPARAM16(3, mag); SET_DPARAM16(0,_cargoc.names_s[i->produced_cargo[j]]); SET_DPARAM16(1, i->town->index); SET_DPARAM16(2, i->type + STR_4802_COAL_MINE); - AddNewsItem(percent>=0 ? STR_INDUSTRY_PROD_GOUP : STR_INDUSTRY_PROD_GODOWN, + AddNewsItem(percent>=0 ? STR_INDUSTRY_PROD_GOUP : STR_INDUSTRY_PROD_GODOWN, NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_ECONOMY, 0), i->xy + TILE_XY(1,1), 0); } @@ -1666,13 +1666,13 @@ static void ExtChangeIndustryProduction(Industry *i) static void UpdateIndustryStatistics(Industry *i) { byte pct; - - if (i->produced_cargo[0] != 0xFF) { + + if (i->produced_cargo[0] != 0xFF) { pct = 0; if (i->last_mo_production[0] != 0) { i->last_prod_year = _cur_year; pct = min(i->last_mo_transported[0] * 256 / i->last_mo_production[0],255); - } + } i->pct_transported[0] = pct; i->total_production[0] = i->last_mo_production[0]; @@ -1687,7 +1687,7 @@ static void UpdateIndustryStatistics(Industry *i) if (i->last_mo_production[1] != 0) { i->last_prod_year = _cur_year; pct = min(i->last_mo_transported[1] * 256 / i->last_mo_production[1],255); - } + } i->pct_transported[1] = pct; i->total_production[1] = i->last_mo_production[1]; @@ -1747,7 +1747,7 @@ static void MaybeCloseIndustry(Industry *i) uint32 r; StringID str; int type = i->type; - + if (_industry_close_mode[type] == 1) { /* decrease or increase */ if (type == IT_OIL_WELL && _opt.landscape == LT_NORMAL) goto decrease_production; @@ -1759,14 +1759,14 @@ static void MaybeCloseIndustry(Industry *i) byte b; i->prod_level <<= 1; - + b = i->production_rate[0]*2; if (i->production_rate[0] >= 128) b=255; i->production_rate[0] = b; b = i->production_rate[1]*2; if (i->production_rate[1] >= 128) b=255; i->production_rate[1] = b; - + str = _industry_prod_up_strings[type]; goto add_news; } @@ -1782,7 +1782,7 @@ decrease_production: str = _industry_prod_down_strings[type]; goto add_news; } - } + } } else if (_industry_close_mode[type] > 1) { /* maybe close */ if ( (byte)(_cur_year - i->last_prod_year) >= 5 && CHANCE16(1,2)) { diff --git a/misc.c b/misc.c index 8b41dfc3f6..b15ca7e1b7 100644 --- a/misc.c +++ b/misc.c @@ -95,7 +95,7 @@ void InitializeGame() _date_fract = 0; _cur_tileloop_tile = 0; _vehicle_id_ctr_day = 0; - + { uint starting = ConvertIntDate(_patches.starting_date); if ( starting == (uint)-1) starting = 10958; @@ -119,7 +119,7 @@ void InitializeGame() InitializeTrees(); InitializeStations(); InitializeIndustries(); - + InitializeNameMgr(); InitializeVehiclesGuiList(); InitializeTrains(); @@ -153,7 +153,7 @@ void GenerateWorld(int mode) } else { GenerateLandscape(); GenerateClearTile(); - + // only generate towns, tree and industries in newgame mode. if (mode == 0) { GenerateTowns(); @@ -163,7 +163,7 @@ void GenerateWorld(int mode) } } - // These are probably pointless when inside the scenario editor. + // These are probably pointless when inside the scenario editor. StartupPlayers(); StartupEngines(); StartupDisasters(); @@ -211,7 +211,7 @@ byte *GetName(int id, byte *buff) void InitializeCheats() { - memset(&_cheats, 0, sizeof(Cheats)); + memset(&_cheats, 0, sizeof(Cheats)); } @@ -250,7 +250,7 @@ StringID AllocateName(const byte *name, byte skip) for(i=0; (dst[i] = name[i]) != 0 && ++i != 32; ) {} dst[31] = 0; - + return free_item | 0x7800 | (skip << 8); } @@ -319,7 +319,7 @@ void ConvertDayToYMD(YearMonthDay *ymd, uint16 date) } ymd->year = yr; - + x = _month_date_from_year_day[rem]; ymd->month = x >> 5; ymd->day = x & 0x1F; @@ -331,7 +331,7 @@ void ConvertDayToYMD(YearMonthDay *ymd, uint16 date) uint ConvertYMDToDay(uint year, uint month, uint day) { uint rem; - + // day in the year rem = _accum_days_for_month[month] + day - 1; @@ -355,11 +355,11 @@ uint ConvertIntDate(uint date) if (IS_INT_INSIDE(date, 1920, 2090 + 1)) { year = date - 1920; } else if (IS_INT_INSIDE(date, 192001, 209012+1)) { - month = date % 100 - 1; + month = date % 100 - 1; year = date / 100 - 1920; } else if (IS_INT_INSIDE(date, 19200101, 20901231+1)) { day = date % 100; date /= 100; - month = date % 100 - 1; + month = date % 100 - 1; year = date / 100 - 1920; } else if (IS_INT_INSIDE(date, 2091, 65536)) return date; @@ -405,7 +405,7 @@ void InitializeLandscapeVariables(bool only_constants) for(i=0; i!=NUM_CARGO; i++) { _cargoc.sprites[i] = lpd->sprites[i]; - + str = lpd->names[i]; _cargoc.names_s[i] = str; _cargoc.names_p[i] = (str += 0x20); @@ -413,7 +413,7 @@ void InitializeLandscapeVariables(bool only_constants) _cargoc.names_long_p[i] = (str += 0x20); _cargoc.names_short[i] = (str += 0x20); _cargoc.weights[i] = lpd->weights[i]; - + if (!only_constants) { _cargo_payment_rates[i] = lpd->initial_cargo_payment[i]; _cargo_payment_rates_frac[i] = 0; @@ -427,7 +427,7 @@ void InitializeLandscapeVariables(bool only_constants) // distance in Manhattan metric uint GetTileDist(TileIndex xy1, TileIndex xy2) { - return myabs(GET_TILE_X(xy1) - GET_TILE_X(xy2)) + + return myabs(GET_TILE_X(xy1) - GET_TILE_X(xy2)) + myabs(GET_TILE_Y(xy1) - GET_TILE_Y(xy2)); } @@ -536,7 +536,7 @@ void IncreaseDate() /* increase day, and check if a new day is there? */ _tick_counter++; - + if ( (_date_fract += 885) >= 885) return; @@ -582,7 +582,7 @@ void IncreaseDate() return; _cur_year = ymd.year; - /* yes, call various yearly loops */ + /* yes, call various yearly loops */ PlayersYearlyLoop(); TrainsYearlyLoop(); @@ -648,14 +648,14 @@ static void Save_NAME() if (*b) { SlSetArrayIndex(i); SlArray(b, strlen(b), SLE_UINT8); - } + } } } static void Load_NAME() { int index; - + while ((index = SlIterateArray()) != -1) { SlArray(_name_array[index],SlGetFieldLength(),SLE_UINT8); } @@ -679,7 +679,7 @@ static const byte _game_opt_desc[] = { // Save load game options static void SaveLoad_OPTS() { - SlObject(&_opt, _game_opt_desc); + SlObject(&_opt, _game_opt_desc); } diff --git a/pathfind.h b/pathfind.h index 2f947cab68..07f42753e4 100644 --- a/pathfind.h +++ b/pathfind.h @@ -36,7 +36,7 @@ struct TrackPathFinder { TPFEnumProc *enum_proc; void *userdata; - + RememberData rd; int the_dir; diff --git a/players.c b/players.c index 020b0d0f6a..1101d1a70d 100644 --- a/players.c +++ b/players.c @@ -13,7 +13,7 @@ extern void StartupEconomy(); static const SpriteID cheeks_table[4] = { - 0x325, 0x326, + 0x325, 0x326, 0x390, 0x3B0, }; @@ -60,10 +60,10 @@ void DrawPlayerFace(uint32 face, int color, int x, int y) if (!(flag & 2)) { if (!(flag & 1)) { - DrawSprite(high+((val1 * 12 >> 4) + 0x832B), x, y); + DrawSprite(high+((val1 * 12 >> 4) + 0x832B), x, y); } else { DrawSprite(high+(val1 + 0x8337), x, y); - } + } } else { if (!(flag & 1)) { DrawSprite(high+((val1 * 11 >> 4) + 0x839A), x, y); @@ -80,11 +80,11 @@ void DrawPlayerFace(uint32 face, int color, int x, int y) if (!(flag&1)) { val2 = ((val&0xF) * 15 >> 4); - + if (val2 < 3) { DrawSprite((flag&2 ? 0x397 : 0x367) + val2, x, y); /* skip the rest */ - goto skip_mouth; + goto skip_mouth; } val2 -= 3; @@ -148,7 +148,7 @@ void DrawPlayerFace(uint32 face, int color, int x, int y) } else { DrawSprite(0x378 + ((val&3)*3>>2), x, y); DrawSprite(0x37B + ((val>>2)&3), x, y); - + val >>= 4; if (val < 3) { DrawSprite((flag&2 ? 0x3D1 : 0x37F) + val, x, y); @@ -198,14 +198,14 @@ static void SubtractMoneyFromAnyPlayer(Player *p, int32 cost) { p->money64 -= cost; UpdatePlayerMoney32(p); - + p->yearly_expenses[0][_yearly_expenses_type] += cost; if ( ( 1 << _yearly_expenses_type ) & (1<<7|1<<8|1<<9|1<<10)) p->cur_economy.income -= cost; else if (( 1 << _yearly_expenses_type ) & (1<<2|1<<3|1<<4|1<<5|1<<6|1<<11)) p->cur_economy.expenses -= cost; - + InvalidatePlayerWindows(p); } @@ -236,13 +236,13 @@ void UpdatePlayerMoney32(Player *p) else if (p->money64 > 2000000000) p->player_money = 2000000000; else - p->player_money = (int32)p->money64; + p->player_money = (int32)p->money64; } void GetNameOfOwner(byte owner, uint tile) { SET_DPARAM8(2, owner); - + if (owner != OWNER_TOWN) { if (owner >= 8) SET_DPARAM16(0, STR_0150_SOMEONE); @@ -274,10 +274,10 @@ bool CheckTileOwnership(uint tile) { byte owner = _map_owner[tile]; assert(owner <= OWNER_WATER); - if (owner == _current_player) + if (owner == _current_player) return true; _error_message = STR_013B_OWNED_BY; - + // no need to get the name of the owner unless we're the local player (saves some time) if (_current_player == _local_player) GetNameOfOwner(owner, tile); @@ -330,11 +330,11 @@ set_name:; return; } bad_town_name:; - + if (p->president_name_1 == SPECSTR_PRESIDENT_NAME) { str = SPECSTR_ANDCO_NAME; strp = p->president_name_2; - goto set_name; + goto set_name; } else { str = SPECSTR_ANDCO_NAME; strp = Random(); @@ -371,7 +371,7 @@ static byte GeneratePlayerColor() do { for(j=0; j!=15; j++) { if (_color_sort[colors[j]] < _color_sort[colors[j+1]]) { - COLOR_SWAP(j,j+1); + COLOR_SWAP(j,j+1); } } } while (--i); @@ -382,7 +382,7 @@ static byte GeneratePlayerColor() for(i=0; i!=16; i++) if (colors[i] == pcolor) { colors[i] = 0xFF; - t2 = _color_similar_1[pcolor]; + t2 = _color_similar_1[pcolor]; if (t2 == 0xFF) break; for(i=0; i!=15; i++) { if (colors[i] == t2) { @@ -391,7 +391,7 @@ static byte GeneratePlayerColor() } } - t2 = _color_similar_2[pcolor]; + t2 = _color_similar_2[pcolor]; if (t2 == 0xFF) break; for(i=0; i!=15; i++) { if (colors[i] == t2) { @@ -422,7 +422,7 @@ restart:; p->president_name_2 = Random(); p->president_name_1 = SPECSTR_PRESIDENT_NAME; - + SET_DPARAM32(0, p->president_name_2); GetString(buffer, p->president_name_1); if (strlen(buffer) >= 32 || GetStringWidth(buffer) >= 94) @@ -464,7 +464,7 @@ Player *DoStartupNewPlayer(bool is_ai) p = AllocatePlayer(); if (p == NULL) return NULL; - + index = p->index; // Make a color @@ -472,7 +472,7 @@ Player *DoStartupNewPlayer(bool is_ai) _player_colors[index] = p->player_color; p->name_1 = STR_SV_UNNAMED; p->is_active = true; - + p->money64 = p->player_money = p->current_loan = 100000; p->is_ai = is_ai; @@ -501,7 +501,7 @@ static void MaybeStartNewPlayer() { uint n; Player *p; - + // count number of competitors n = 0; for(p=_players; p!=endof(_players); p++) @@ -511,7 +511,7 @@ static void MaybeStartNewPlayer() // when there's a lot of computers in game, the probability that a new one starts is lower if (n < (uint)_opt.diff.max_no_competitors && n < RandomRange(_opt.diff.max_no_competitors + 2)) DoStartupNewPlayer(true); - + // The next AI starts like the difficulty setting said, with +2 month max _next_competitor_start = _opt.diff.competitor_start_time * 90 * DAY_TICKS + RandomRange(60 * DAY_TICKS) + 1; } @@ -531,20 +531,20 @@ void OnTick_Players() if (_game_mode == GM_EDITOR) return; - + p = DEREF_PLAYER(_cur_player_tick_index); _cur_player_tick_index = (_cur_player_tick_index + 1) % MAX_PLAYERS; if (p->name_1 != 0) GenerateCompanyName(p); if (_game_mode != GM_MENU && !--_next_competitor_start) { - MaybeStartNewPlayer(); + MaybeStartNewPlayer(); } } void RunOtherPlayersLoop() { Player *p; - + _is_ai_player = true; FOR_ALL_PLAYERS(p) { @@ -634,7 +634,7 @@ int32 CmdPlayerCtrl(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (!(flags & DC_EXEC)) return 0; - + switch(p1 & 0xff) { case 0: // make new player p = DoStartupNewPlayer(false); @@ -672,7 +672,7 @@ static const byte _player_desc[] = { SLE_VAR(Player,president_name_2,SLE_UINT32), SLE_VAR(Player,face, SLE_UINT32), - + // money was changed to a 64 bit field in savegame version 1. SLE_CONDVAR(Player,money64, SLE_VAR_I64 | SLE_FILE_I32, 0, 0), SLE_CONDVAR(Player,money64, SLE_INT64, 1, 255), @@ -722,7 +722,7 @@ static const byte _player_economy_desc[] = { SLE_VAR(PlayerEconomyEntry,delivered_cargo, SLE_INT32), SLE_VAR(PlayerEconomyEntry,performance_history, SLE_INT32), - + SLE_END() }; @@ -817,7 +817,7 @@ static void Load_PLYR() { int index; while ((index = SlIterateArray()) != -1) { - Player *p = DEREF_PLAYER(index); + Player *p = DEREF_PLAYER(index); p->is_ai = (index != 0); SaveLoad_PLYR(p); _player_colors[index] = p->player_color; diff --git a/queue.c b/queue.c index 6817467a10..8c88542eff 100644 --- a/queue.c +++ b/queue.c @@ -150,7 +150,7 @@ void InsSort_Clear(Queue* q, bool free_values) { prev = node; node = node->next; free(prev); - + } q->data.inssort.first = NULL; } @@ -283,7 +283,7 @@ bool BinaryHeap_Push(Queue* q, void* item, int priority) { if (q->data.binaryheap.size == q->data.binaryheap.max_size) return false; assert(q->data.binaryheap.size < q->data.binaryheap.max_size); - + if (q->data.binaryheap.elements[q->data.binaryheap.size >> BINARY_HEAP_BLOCKSIZE_BITS] == NULL) { /* The currently allocated blocks are full, allocate a new one */ assert((q->data.binaryheap.size & BINARY_HEAP_BLOCKSIZE_MASK) == 0); @@ -466,14 +466,14 @@ void delete_Hash(Hash* h, bool free_values) { if (h->buckets_in_use[i]) { HashNode* node; /* Free the first value */ - if (free_values) + if (free_values) free(h->buckets[i].value); node = h->buckets[i].next; while (node != NULL) { HashNode* prev = node; node = node->next; /* Free the value */ - if (free_values) + if (free_values) free(prev->value); /* Free the node */ free(prev); diff --git a/queue.h b/queue.h index b83ff39374..bd011a742c 100644 --- a/queue.h +++ b/queue.h @@ -51,7 +51,7 @@ struct Queue{ Queue_ClearProc* clear; /* Frees the queue, by reclaiming all memory allocated by it. After * this it is no longer usable. If free_items is true, any remaining - * items are free()'d too. + * items are free()'d too. */ Queue_FreeProc* free; diff --git a/rail_cmd.c b/rail_cmd.c index d4dc81725e..1d14caf2de 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -42,7 +42,7 @@ enum { /* These values are bitmasks for the map5 byte */ * 11 ????dd => Depot * * abcdef is a bitmask, which contains ones for all present tracks. Below the - * value for each track is given. + * value for each track is given. */ /* 4 @@ -52,7 +52,7 @@ enum { /* These values are bitmasks for the map5 byte */ * | \ / | * | \ / | * 16| \ |32 - * | / \2 | + * | / \2 | * | / \ | * | / \ | * |/ \| @@ -62,7 +62,7 @@ enum { /* These values are bitmasks for the map5 byte */ // Constants for lower part of Map2 byte. -enum RailMap2Lower4 { +enum RailMap2Lower4 { RAIL_MAP2LO_GROUND_MASK = 0xF, RAIL_GROUND_BROWN = 0, RAIL_GROUND_GREEN = 1, @@ -81,7 +81,7 @@ enum RailMap2Lower4 { /* MAP2 byte: abcd???? => Signal On? Same coding as map3lo - * MAP3LO byte: abcd???? => Signal Exists? + * MAP3LO byte: abcd???? => Signal Exists? * a and b are for diagonals, upper and left, * one for each direction. (ie a == NE->SW, b == * SW->NE, or v.v., I don't know. b and c are @@ -91,7 +91,7 @@ enum RailMap2Lower4 { * MAP5: 00abcdef => rail * 01abcdef => rail w/ signals * 10uuuuuu => unused - * 11uuuudd => rail depot + * 11uuuudd => rail depot */ static bool CheckTrackCombination(byte map5, byte trackbits, byte flags) @@ -99,7 +99,7 @@ static bool CheckTrackCombination(byte map5, byte trackbits, byte flags) _error_message = STR_1001_IMPOSSIBLE_TRACK_COMBINATION; if ((map5&RAIL_TYPE_MASK) == RAIL_TYPE_SIGNALS) { - + if (map5 & trackbits) { _error_message = STR_1007_ALREADY_BUILT; return false; @@ -112,11 +112,11 @@ static bool CheckTrackCombination(byte map5, byte trackbits, byte flags) _error_message = STR_1007_ALREADY_BUILT; if (map5 & trackbits) return false; - + // Computer players are not allowed to intersect pieces of rail. if (!(flags&DC_NO_RAIL_OVERLAP)) return true; - + map5 |= trackbits; return (map5 == (RAIL_BIT_UPPER|RAIL_BIT_LOWER) || map5 == (RAIL_BIT_LEFT|RAIL_BIT_RIGHT)); } else { @@ -138,12 +138,12 @@ static const byte _valid_tileh_slopes[4][15] = { 0, RAIL_BIT_DIAG2, RAIL_BIT_LOWER, - + RAIL_BIT_LOWER, RAIL_BIT_DIAG2, 0, RAIL_BIT_LEFT, - + RAIL_BIT_DIAG1, RAIL_BIT_UPPER, RAIL_BIT_RIGHT, @@ -177,7 +177,7 @@ static const byte _valid_tileh_slopes[4][15] = { RAIL_BIT_LEFT, RAIL_BIT_LOWER, RAIL_BIT_DIAG2|RAIL_BIT_LEFT|RAIL_BIT_LOWER, - + RAIL_BIT_RIGHT, RAIL_BIT_DIAG1|RAIL_BIT_DIAG2|RAIL_BIT_UPPER|RAIL_BIT_LOWER|RAIL_BIT_LEFT|RAIL_BIT_RIGHT, RAIL_BIT_DIAG1|RAIL_BIT_RIGHT|RAIL_BIT_LOWER, @@ -213,7 +213,7 @@ uint GetRailFoundation(uint tileh, uint bits) if ((~_valid_tileh_slopes[1][tileh] & bits) == 0) return tileh; - if ( ((i=0, tileh == 1) || (i+=2, tileh == 2) || (i+=2, tileh == 4) || (i+=2, tileh == 8)) && (bits == RAIL_BIT_DIAG1 || (i++, bits == RAIL_BIT_DIAG2))) + if ( ((i=0, tileh == 1) || (i+=2, tileh == 2) || (i+=2, tileh == 4) || (i+=2, tileh == 8)) && (bits == RAIL_BIT_DIAG1 || (i++, bits == RAIL_BIT_DIAG2))) return i + 15; return 0; @@ -234,10 +234,10 @@ static uint32 CheckRailSlope(int tileh, uint rail_bits, uint existing, uint tile // no special foundation if ((~_valid_tileh_slopes[0][tileh] & rail_bits) == 0) return 0; - + if (((~_valid_tileh_slopes[1][tileh] & rail_bits) == 0) || // whole tile is leveled up ((rail_bits == RAIL_BIT_DIAG1 || rail_bits == RAIL_BIT_DIAG2) && (tileh == 1 || tileh == 2 || tileh == 4 || tileh == 8))) { // partly up - return existing ? 0 : _price.terraform; + return existing ? 0 : _price.terraform; } } return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); @@ -266,7 +266,7 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2) tile = ti.tile; // allow building rail under bridge - if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) + if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) return CMD_ERROR; if (ti.type == MP_TUNNELBRIDGE) { @@ -311,7 +311,7 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2) return _price.build_rail; ModifyTile(tile, - MP_SETTYPE(MP_STREET) | + MP_SETTYPE(MP_STREET) | MP_MAP3LO | MP_MAP3HI | MP_MAPOWNER_CURRENT | MP_MAP5, _map_owner[tile], /* map3_lo */ p1, /* map3_hi */ @@ -326,7 +326,7 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2) } else if (ti.type == MP_RAILWAY) { /* BUILD ON RAILWAY CODE */ - if (_map_owner[tile] != _current_player || (byte)(_map3_lo[tile]&0xF) != rail_type) + if (_map_owner[tile] != _current_player || (byte)(_map3_lo[tile]&0xF) != rail_type) goto need_clear; if (!CheckTrackCombination(ti.map5, rail_bit, (byte)flags)) return CMD_ERROR; @@ -396,7 +396,7 @@ static const byte _signals_table_other[] = { }; static const byte _signals_table_both[] = { - 0xC0, 0xC0, 0xC0, 0x30, 0xC0, 0x30, 0, 0, // both directions combined + 0xC0, 0xC0, 0xC0, 0x30, 0xC0, 0x30, 0, 0, // both directions combined 0xC0, 0xC0, 0xC0, 0x30, 0xC0, 0x30, 0, 0 }; @@ -426,7 +426,7 @@ int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2) return CMD_ERROR; // allow building rail under bridge - if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) + if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) return CMD_ERROR; if (ti.type == MP_TUNNELBRIDGE) { @@ -441,7 +441,7 @@ int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (!(flags & DC_EXEC)) return _price.remove_rail; - + _map_owner[tile] = OWNER_NONE; _map5[tile] = ti.map5 & 0xC7; } else if (ti.type == MP_STREET) { @@ -497,7 +497,7 @@ int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2) skip_mark_dirty:; SetSignalsOnBothDir(tile, (byte)p2); - + return _price.remove_rail; } @@ -506,7 +506,7 @@ static const struct { int8 yinc[16]; byte initial[16]; } _railbit = {{ -// 0 1 2 3 4 5 +// 0 1 2 3 4 5 16, 0,-16, 0, 16, 0, 0, 0, -16, 0, 0, 16, 0,-16, 0, 0, },{ @@ -537,7 +537,7 @@ int32 CmdBuildRailroadTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (flags & DC_EXEC) SndPlayTileFx(0x1E, TILE_FROM_XY(x,y)); - + /* unpack end point */ sx = (p1 & 0xFFFF) & ~0xF; sy = (p1 >> 16) & ~0xF; @@ -558,10 +558,10 @@ int32 CmdBuildRailroadTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2) x += _railbit.xinc[railbit]; y += _railbit.yinc[railbit]; - + // toggle railbit for the diagonal tiles if (railbit & 0x6) railbit ^= 1; - } + } if (total_cost == 0) return CMD_ERROR; @@ -587,7 +587,7 @@ int32 CmdRemoveRailroadTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (flags & DC_EXEC) SndPlayTileFx(0x1E, TILE_FROM_XY(x,y)); - + /* unpack start point */ sx = (p1 & 0xFFFF) & ~0xF; sy = (p1 >> 16) & ~0xF; @@ -603,7 +603,7 @@ int32 CmdRemoveRailroadTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2) y += _railbit.yinc[railbit]; // toggle railbit for the diagonal tiles if (railbit & 0x6) railbit ^= 1; - } + } if (total_cost == 0) return CMD_ERROR; @@ -643,14 +643,14 @@ int32 CmdBuildTrainDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (flags & DC_EXEC) { if (_current_player == _local_player) _last_built_train_depot_tile = (TileIndex)tile; - - ModifyTile(tile, + + ModifyTile(tile, MP_SETTYPE(MP_RAILWAY) | MP_MAP3LO | MP_MAPOWNER_CURRENT | MP_MAP5, p1, /* map3_lo */ p2 | RAIL_TYPE_DEPOT /* map5 */ ); - + dep->xy = tile; dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index; @@ -688,7 +688,7 @@ static Checkpoint *FindDeletedCheckpointCloseTo(uint tile) for(cp = _checkpoints; cp != endof(_checkpoints); cp++) { if (cp->deleted && cp->xy) { - cur_dist = GetTileDist(tile, cp->xy); + cur_dist = GetTileDist(tile, cp->xy); if (cur_dist < thres) { thres = cur_dist; best = cp; @@ -714,7 +714,7 @@ int32 CmdBuildTrainCheckpoint(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (!CheckTileOwnership(tile)) return CMD_ERROR; - + if (!EnsureNoVehicle(tile)) return CMD_ERROR; tileh = GetTileSlope(tile, NULL); @@ -733,10 +733,10 @@ int32 CmdBuildTrainCheckpoint(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (flags & DC_EXEC) { ModifyTile(tile, MP_MAP5, RAIL_TYPE_CHECKPOINT | dir); - + cp->deleted = 0; cp->xy = tile; - + if (cp->town_or_string == 0) MakeDefaultCheckpointName(cp); else RedrawCheckpointSign(cp); UpdateCheckpointSign(cp); RedrawCheckpointSign(cp); @@ -848,13 +848,13 @@ int32 CmdBuildSignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) byte m5; int32 cost; int track = p1 & 0x7; - + assert(track >= 0 && track < 6); // only 6 possible track-combinations - + SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); tile = TILE_FROM_XY(x,y); - + if (!EnsureNoVehicle(tile)) return CMD_ERROR; @@ -867,7 +867,7 @@ int32 CmdBuildSignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) // check rail combination { byte m = m5 & RAIL_BIT_MASK; - if (m != RAIL_BIT_DIAG1 && m != RAIL_BIT_DIAG2 && m != RAIL_BIT_UPPER && m != RAIL_BIT_LOWER && + if (m != RAIL_BIT_DIAG1 && m != RAIL_BIT_DIAG2 && m != RAIL_BIT_UPPER && m != RAIL_BIT_LOWER && m != RAIL_BIT_LEFT && m != RAIL_BIT_RIGHT && m != (RAIL_BIT_UPPER|RAIL_BIT_LOWER) && m != (RAIL_BIT_LEFT|RAIL_BIT_RIGHT)) return CMD_ERROR; } @@ -886,7 +886,7 @@ int32 CmdBuildSignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) } if (flags & DC_EXEC) { - + if (!(m5 & RAIL_TYPE_SIGNALS)) { // if there are no signals yet present on the track _map5[tile] |= RAIL_TYPE_SIGNALS; // change into signals @@ -925,7 +925,7 @@ int32 CmdBuildSignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) // convert between signal<->semaphores when dragging HASBIT(p1, 3) ? SETBIT(_map3_hi[tile], 2) : CLRBIT(_map3_hi[tile], 2); } - + MarkTileDirtyByTile(tile); SetSignalsOnBothDir(tile, track); } @@ -972,13 +972,13 @@ int32 CmdBuildManySignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) * the other side alone */ switch (signals) { case 0x20: case 8: /* east corner (N-S), south corner (W-E) */ - if (_map3_lo[tile]&0x30) + if (_map3_lo[tile]&0x30) signals = _map3_lo[tile]&0x30; else signals = 0x30 | (_map3_lo[tile]&0xC0); break; case 0x10: case 4: /* west corner (N-S), north corner (W-E) */ - if (_map3_lo[tile]&0xC0) + if (_map3_lo[tile]&0xC0) signals = _map3_lo[tile]&0xC0; else signals = 0xC0 | (_map3_lo[tile]&0x30); @@ -1001,7 +1001,7 @@ int32 CmdBuildManySignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) ********** * railbit - direction of autorail * semaphores - semaphores or signals - * signals - is there a signal/semaphore on the first tile, copy its style (two-way/single-way) + * signals - is there a signal/semaphore on the first tile, copy its style (two-way/single-way) and convert all others to semaphore/signal * mode - 1 remove signals, 0 build signals */ signal_ctr = total_cost = 0; @@ -1026,9 +1026,9 @@ int32 CmdBuildManySignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) break; x += _railbit.xinc[railbit]; - y += _railbit.yinc[railbit]; + y += _railbit.yinc[railbit]; signal_ctr++; - + // toggle railbit for the diagonal tiles (|, -- tracks) if (railbit & 0x6) railbit ^= 1; } @@ -1050,7 +1050,7 @@ int32 CmdRemoveSignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) FindLandscapeHeight(&ti, x, y); tile = ti.tile; - + /* No vehicle behind. */ if (!EnsureNoVehicle(tile)) return CMD_ERROR; @@ -1073,18 +1073,18 @@ int32 CmdRemoveSignals(int x, int y, uint32 flags, uint32 p1, uint32 p2) _map5[tile] &= ~RAIL_TYPE_SIGNALS; _map2[tile] &= ~0xF0; CLRBIT(_map3_hi[tile], 2); // remove any possible semaphores - + /* TTDBUG: this code contains a bug, if a tile contains 2 signals - * on separate tracks, it won't work properly for the 2nd track */ - SetSignalsOnBothDir(tile, FIND_FIRST_BIT(bits & RAIL_BIT_MASK)); + * on separate tracks, it won't work properly for the 2nd track */ + SetSignalsOnBothDir(tile, FIND_FIRST_BIT(bits & RAIL_BIT_MASK)); MarkTileDirtyByTile(tile); } - + return _price.remove_signals; } -typedef int32 DoConvertRailProc(uint tile, uint totype, bool exec); +typedef int32 DoConvertRailProc(uint tile, uint totype, bool exec); static int32 DoConvertRail(uint tile, uint totype, bool exec) { @@ -1120,7 +1120,7 @@ int32 CmdConvertRail(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) sy = GET_TILE_Y(p1)*16; if (ex < sx) intswap(ex, sx); if (ey < sy) intswap(ey, sy); - + money = GetAvailableMoneyForCommand(); ret = false; cost = 0; @@ -1128,13 +1128,13 @@ int32 CmdConvertRail(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) for(y=sy; y<=ey; y+=16) { uint tile = TILE_FROM_XY(x,y); DoConvertRailProc *p; - + if (IS_TILETYPE(tile, MP_RAILWAY)) p = DoConvertRail; else if (IS_TILETYPE(tile, MP_STATION)) p = DoConvertStationRail; else if (IS_TILETYPE(tile, MP_STREET)) p = DoConvertStreetRail; else if (IS_TILETYPE(tile, MP_TUNNELBRIDGE)) p = DoConvertTunnelBridgeRail; else continue; - + ret = p(tile, p2, false); if (ret == CMD_ERROR) continue; cost += ret; @@ -1185,7 +1185,7 @@ static int32 ClearTile_Track(uint tile, byte flags) { } cost = 0; - + if ( (m5 & RAIL_TYPE_MASK) == RAIL_TYPE_NORMAL) { regular_track:; @@ -1245,7 +1245,7 @@ static const SpriteID _signal_base_sprites[16] = { 0x1323, 0x1333, 0x1343, - + 0x13C6, 0x13D6, 0x13E6, @@ -1283,7 +1283,7 @@ static void DrawTrackFence_NW(TileInfo *ti) image = 0x51B; } } - AddSortableSpriteToDraw(image | _drawtile_track_palette, + AddSortableSpriteToDraw(image | _drawtile_track_palette, ti->x, ti->y+1, 16, 1, 4, ti->z); } @@ -1296,7 +1296,7 @@ static void DrawTrackFence_SE(TileInfo *ti) image = 0x51B; } } - AddSortableSpriteToDraw(image | _drawtile_track_palette, + AddSortableSpriteToDraw(image | _drawtile_track_palette, ti->x, ti->y+15, 16, 1, 4, ti->z); } @@ -1315,7 +1315,7 @@ static void DrawTrackFence_NE(TileInfo *ti) image = 0x51C; } } - AddSortableSpriteToDraw(image | _drawtile_track_palette, + AddSortableSpriteToDraw(image | _drawtile_track_palette, ti->x+1, ti->y, 1, 16, 4, ti->z); } @@ -1328,7 +1328,7 @@ static void DrawTrackFence_SW(TileInfo *ti) image = 0x51C; } } - AddSortableSpriteToDraw(image | _drawtile_track_palette, + AddSortableSpriteToDraw(image | _drawtile_track_palette, ti->x+15, ti->y, 1, 16, 4, ti->z); } @@ -1383,21 +1383,21 @@ typedef void DetailedTrackProc(TileInfo *ti); DetailedTrackProc * const _detailed_track_proc[16] = { DetTrackDrawProc_Null, DetTrackDrawProc_Null, - + DrawTrackFence_NW, DrawTrackFence_SE, DrawTrackFence_NW_SE, - + DrawTrackFence_NE, DrawTrackFence_SW, DrawTrackFence_NE_SW, - + DrawTrackFence_NS_1, DrawTrackFence_NS_2, - + DrawTrackFence_WE_1, DrawTrackFence_WE_2, - + DetTrackDrawProc_Null, DetTrackDrawProc_Null, DetTrackDrawProc_Null, @@ -1418,7 +1418,7 @@ static void DrawTile_Track(TileInfo *ti) bool special; m5 &= RAIL_BIT_MASK; - + special = false; // select the sprite to use based on the map5 byte. @@ -1429,10 +1429,10 @@ static void DrawTile_Track(TileInfo *ti) (image++, m5 == RAIL_BIT_RIGHT) || (image++, m5 == RAIL_BIT_LEFT) || (image++, m5 == (RAIL_BIT_DIAG1|RAIL_BIT_DIAG2)) || - + (image = 0x40B, m5 == (RAIL_BIT_UPPER|RAIL_BIT_LOWER)) || (image++, m5 == (RAIL_BIT_LEFT|RAIL_BIT_RIGHT)) || - + (special=true, false) || (image = 0x3FA, !(m5 & (RAIL_BIT_RIGHT|RAIL_BIT_UPPER|RAIL_BIT_DIAG1))) || @@ -1444,7 +1444,7 @@ static void DrawTile_Track(TileInfo *ti) if (ti->tileh != 0) { int f = GetRailFoundation(ti->tileh, ti->map5 & 0x3F); if (f) DrawFoundation(ti, f); - + // default sloped sprites.. if (ti->tileh != 0) image = _track_sloped_sprites[ti->tileh - 1] + 0x3F3; } @@ -1515,7 +1515,7 @@ static void DrawTile_Track(TileInfo *ti) if (!(m5 & (RAIL_TYPE_MASK&~RAIL_TYPE_SPECIAL))) return; - + if (ti->tileh != 0) { DrawFoundation(ti, ti->tileh); } s = _track_depot_layout_table[m5 & 0x3F]; @@ -1541,9 +1541,9 @@ static void DrawTile_Track(TileInfo *ti) if (image & 0x8000) image |= _drawtile_track_palette; image += tracktype_offs; - if (!(_display_opt & DO_TRANS_BUILDINGS)) + if (!(_display_opt & DO_TRANS_BUILDINGS)) image = (image & 0x3FFF) | 0x3224000; - AddSortableSpriteToDraw(image, ti->x | drss->subcoord_x, + AddSortableSpriteToDraw(image, ti->x | drss->subcoord_x, ti->y | drss->subcoord_y, drss->width, drss->height, 0x17, ti->z); drss++; } @@ -1567,7 +1567,7 @@ void DrawTrainDepotSprite(int x, int y, int image, int railtype) y+=17; img = *(uint16*)t; - if (img & 0x8000) img = (img & 0x7FFF) + railtype; + if (img & 0x8000) img = (img & 0x7FFF) + railtype; DrawSprite(img, x, y); for(dtss = (DrawTrackSeqStruct *)(t + sizeof(uint16)); dtss->image != 0; dtss++) { @@ -1586,7 +1586,7 @@ typedef struct SetSignalsData { int cur_stack; bool stop; bool has_presignal; - + // presignal info int presignal_exits; int presignal_exits_free; @@ -1607,7 +1607,7 @@ static bool SetSignalsEnumProc(uint tile, SetSignalsData *ssd, int track, uint l if (IS_TILETYPE(tile, MP_RAILWAY)) { if ((_map5[tile]&RAIL_TYPE_MASK) == RAIL_TYPE_SIGNALS) { if ((_map3_lo[tile] & _signals_table_both[track]) != 0) { - + // is the signal pointing in to the segment existing? if ((_map3_lo[tile] & _signals_table[track]) != 0) { // yes, add the signal to the list of signals @@ -1620,7 +1620,7 @@ static bool SetSignalsEnumProc(uint tile, SetSignalsData *ssd, int track, uint l // remember if this block has a presignal. ssd->has_presignal |= (_map3_hi[tile]&1); } - + // is this an exit signal that points out from the segment? if ((_map3_hi[tile]&2) && _map3_lo[tile]&_signals_table_other[track]) { ssd->presignal_exits++; @@ -1644,7 +1644,7 @@ static void SetSignalsAfterProc(TrackPathFinder *tpf) TrackPathFinderLink *link; ssd->stop = false; - + // for each train, check if it is in the segment. // then we know that the signal should be red. FOR_ALL_VEHICLES(v) { @@ -1653,9 +1653,9 @@ static void SetSignalsAfterProc(TrackPathFinder *tpf) tile = v->tile; if (v->u.rail.track == 0x40) { tile = GetVehicleOutOfTunnelTile(v); } - + hash = PATHFIND_HASH_TILE(tile); - + val = tpf->hash_head[hash]; if (val == 0) continue; @@ -1723,7 +1723,7 @@ static void ChangeSignalStates(SetSignalsData *ssd) make_red: // turn red if ( (bit&m2) == 0 ) - continue; + continue; } else { // turn green if ( (bit&m2) != 0 ) @@ -1741,7 +1741,7 @@ make_red: printf("NUM_SSD_STACK too small\n"); } } - + // it changed, so toggle it _map2[tile] = m2 ^ bit; MarkTileDirtyByTile(tile); @@ -1767,7 +1767,7 @@ bool UpdateSignalsOnSegment(uint tile, byte direction) // remember the result only for the first iteration. if (result < 0) result = ssd.stop; - + // if any exit signals were changed, we need to keep going to modify the stuff behind those. if(!ssd.cur_stack) break; @@ -1776,7 +1776,7 @@ bool UpdateSignalsOnSegment(uint tile, byte direction) tile = ssd.next_tile[--ssd.cur_stack]; direction = ssd.next_dir[ssd.cur_stack]; } - + return (bool)result; } @@ -1789,7 +1789,7 @@ void SetSignalsOnBothDir(uint tile, byte track) UpdateSignalsOnSegment(tile, _search_dir_2[track]); } -uint GetSlopeZ_Track(TileInfo *ti) +uint GetSlopeZ_Track(TileInfo *ti) { uint z = ti->z; int th = ti->tileh; @@ -1815,7 +1815,7 @@ uint GetSlopeZ_Track(TileInfo *ti) return z; } -uint GetSlopeTileh_Track(TileInfo *ti) +uint GetSlopeTileh_Track(TileInfo *ti) { // check if it's a foundation if (ti->tileh != 0) { @@ -1882,7 +1882,7 @@ static void TileLoop_Track(uint tile) if (m2 != RAIL_GROUND_BROWN) { /* wait until bottom is green */ /* determine direction of fence */ rail = _map5[tile] & RAIL_BIT_MASK; - + if (rail == RAIL_BIT_UPPER) { a2 = RAIL_GROUND_FENCE_HORIZ1; } else if (rail == RAIL_BIT_LOWER) { @@ -1898,7 +1898,7 @@ static void TileLoop_Track(uint tile) if (!IS_TILETYPE(tile + TILE_XY(0,-1), MP_RAILWAY) || owner != _map_owner[tile + TILE_XY(0,-1)] || (_map5[tile + TILE_XY(0,-1)]==RAIL_BIT_UPPER || _map5[tile + TILE_XY(0,-1)]==RAIL_BIT_LEFT)) - a2 = RAIL_GROUND_FENCE_NW; + a2 = RAIL_GROUND_FENCE_NW; } if ( (!(rail&(RAIL_BIT_DIAG2|RAIL_BIT_LOWER|RAIL_BIT_RIGHT)) && (rail&RAIL_BIT_DIAG1)) || rail==(RAIL_BIT_UPPER|RAIL_BIT_LEFT)) { @@ -1984,7 +1984,7 @@ static void ClickTile_Track(uint tile) ShowTrainDepotWindow(tile); else if (IS_RAIL_CHECKPOINT(_map5[tile])) ShowRenameCheckpointWindow(&_checkpoints[GetCheckpointByTile(tile)]); - + } static void GetTileDesc_Track(uint tile, TileDesc *td) @@ -2017,7 +2017,7 @@ static void ChangeTileOwner_Track(uint tile, byte old_player, byte new_player) { if (_map_owner[tile] != old_player) return; - + if (new_player != 255) { _map_owner[tile] = new_player; } else { @@ -2036,14 +2036,14 @@ uint32 VehicleEnter_Track(Vehicle *v, uint tile, int x, int y) { byte fract_coord; int dir; - + // this routine applies only to trains in depot tiles if (v->type != VEH_Train || !IS_RAIL_DEPOT(_map5[tile])) return 0; /* depot direction */ dir = _map5[tile] & RAIL_DEPOT_DIR; - + fract_coord = (x & 0xF) + ((y & 0xF) << 4); if (_fractcoords_behind[dir] == fract_coord) { /* make sure a train is not entering the tile from behind */ diff --git a/rail_gui.c b/rail_gui.c index b69d68e2ed..369936ba08 100644 --- a/rail_gui.c +++ b/rail_gui.c @@ -34,8 +34,8 @@ static void CcPlaySound1E(bool success, uint tile, uint32 p1, uint32 p2) static void GenericPlaceRail(uint tile, int cmd) { DoCommandP(tile, _cur_railtype, cmd, CcPlaySound1E, - _remove_button_clicked ? - CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) | CMD_AUTO | CMD_NO_WATER : + _remove_button_clicked ? + CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) | CMD_AUTO | CMD_NO_WATER : CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) | CMD_AUTO | CMD_NO_WATER ); } @@ -76,7 +76,7 @@ static void PlaceExtraDepotRail(uint tile, uint16 extra) if (b & 0xC0 || !(b & (extra >> 8))) return; - DoCommandP(tile, _cur_railtype, extra & 0xFF, NULL, CMD_BUILD_SINGLE_RAIL | CMD_AUTO | CMD_NO_WATER); + DoCommandP(tile, _cur_railtype, extra & 0xFF, NULL, CMD_BUILD_SINGLE_RAIL | CMD_AUTO | CMD_NO_WATER); } static const uint16 _place_depot_extra[12] = { @@ -101,12 +101,12 @@ static void CcDepot(bool success, uint tile, uint32 p1, uint32 p2) PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]); PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]); } - } + } } static void PlaceRail_Depot(uint tile) { - DoCommandP(tile, _cur_railtype, _build_depot_direction, CcDepot, + DoCommandP(tile, _cur_railtype, _build_depot_direction, CcDepot, CMD_BUILD_TRAIN_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_100E_CAN_T_BUILD_TRAIN_DEPOT)); } @@ -252,12 +252,12 @@ static const SpriteID _depot_cursors[] = { static void BuildRailClick_Depot(Window *w) { - if (HandlePlacePushButton(w, 11, _depot_cursors[_cur_railtype], 1, PlaceRail_Depot)) ShowBuildTrainDepotPicker(); + if (HandlePlacePushButton(w, 11, _depot_cursors[_cur_railtype], 1, PlaceRail_Depot)) ShowBuildTrainDepotPicker(); } static void BuildRailClick_Station(Window *w) { - if (HandlePlacePushButton(w, 12, 0x514, 1, PlaceRail_Station)) ShowStationBuilder(); + if (HandlePlacePushButton(w, 12, 0x514, 1, PlaceRail_Station)) ShowStationBuilder(); } static void BuildRailClick_AutoSignals(Window *w) @@ -281,10 +281,10 @@ static void BuildRailClick_Remove(Window *w) return; SetWindowDirty(w); SndPlayFx(0x13); - + _thd.make_square_red = !!((w->click_state ^= (1 << 16)) & (1<<16)); _remove_button_clicked = (w->click_state & (1 << 16)) != 0; - + // handle station builder if( w->click_state & (1 << 12) ) { @@ -313,8 +313,8 @@ static void BuildRailClick_Convert(Window *w) static void DoRailroadTrack(int mode) { - DoCommandP(TILE_FROM_XY(_thd.selstart.x, _thd.selstart.y), PACK_POINT(_thd.selend.x, _thd.selend.y), (mode << 4) | _cur_railtype, NULL, - _remove_button_clicked ? + DoCommandP(TILE_FROM_XY(_thd.selstart.x, _thd.selstart.y), PACK_POINT(_thd.selend.x, _thd.selend.y), (mode << 4) | _cur_railtype, NULL, + _remove_button_clicked ? CMD_REMOVE_RAILROAD_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) : CMD_BUILD_RAILROAD_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) ); @@ -335,11 +335,11 @@ static const BestFitStruct _bestfit[] = { {0, M(0,1+8+16), M(2,1+4+32), 0}, // diag1 track {1, M(3,2+8+32), M(1,2+4+16), 0}, // diag2 track - + // one edge with rail {0, M(0,1), 0, 0}, // diag1 track {0, M(2,1), 0, 0}, // diag1 track - + {1, M(1,2), 0, 0}, // diag2 track {1, M(3,2), 0, 0}, // diag2 track @@ -394,7 +394,7 @@ int GetBestFit1x1(int x, int y) }; tile += _tile_inc[i]; m[i] = 0; - if (IS_TILETYPE(tile, MP_RAILWAY) && _map5[tile] < 0x80) + if (IS_TILETYPE(tile, MP_RAILWAY) && _map5[tile] < 0x80) m[i] = _map5[tile]&0x3F; // handle tracks under bridge @@ -449,7 +449,7 @@ static bool Check2x1AutoRail(int mode) int sxpy = (thd->selend.x & 0xF) + (thd->selend.y & 0xF); int fxmy = _tile_fract_coords.x - _tile_fract_coords.y; int sxmy = (thd->selend.x & 0xF) - (thd->selend.y & 0xF); - + switch(mode) { case 0: if (fxpy >= 20 && sxpy <= 12) { SwapSelection(); DoRailroadTrack(0); return true; } @@ -459,7 +459,7 @@ static bool Check2x1AutoRail(int mode) case 1: if (fxmy > 3 && sxmy < -3) { SwapSelection(); DoRailroadTrack(0); return true; } if (fxpy <= 12 && sxpy >= 20) { DoRailroadTrack(0); return true; } - break; + break; case 2: if (fxmy > 3 && sxmy < -3) { DoRailroadTrack(3); return true; } @@ -484,7 +484,7 @@ static void HandleAutodirPlacement() if (thd->drawstyle == HT_RECT) { int dx = thd->selstart.x - (thd->selend.x&~0xF); int dy = thd->selstart.y - (thd->selend.y&~0xF); - + if (dx == 0 && dy == 0 ) { // 1x1 tile bit = GetBestFit1x1(thd->selend.x, thd->selend.y); @@ -521,12 +521,12 @@ static void HandleAutoSignalPlacement() int dx = thd->selstart.x - (thd->selend.x&~0xF); int dy = thd->selstart.y - (thd->selend.y&~0xF); - + if (dx == 0 && dy == 0 ) // 1x1 tile signals GenericPlaceSignals(TILE_FROM_XY(thd->selend.x, thd->selend.y)); else { // signals have been dragged if (thd->drawstyle == HT_RECT) { // X,Y direction - if (dx == 0) + if (dx == 0) mode = VPM_FIX_X; else if (dy == 0) mode = VPM_FIX_Y; @@ -543,12 +543,12 @@ static void HandleAutoSignalPlacement() /* _patches.drag_signals_density is given as a parameter such that each user in a network * game can specify his/her own signal density */ - DoCommandP(TILE_FROM_XY(thd->selstart.x, thd->selstart.y), TILE_FROM_XY(thd->selend.x, thd->selend.y), - (mode << 4) | (_remove_button_clicked + (_ctrl_pressed ? 8 : 0)) | (trackstat << 8) | (_patches.drag_signals_density << 24), - CcPlaySound1E, + DoCommandP(TILE_FROM_XY(thd->selstart.x, thd->selstart.y), TILE_FROM_XY(thd->selend.x, thd->selend.y), + (mode << 4) | (_remove_button_clicked + (_ctrl_pressed ? 8 : 0)) | (trackstat << 8) | (_patches.drag_signals_density << 24), + CcPlaySound1E, (_remove_button_clicked ? CMD_BUILD_MANY_SIGNALS | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) : - CMD_BUILD_MANY_SIGNALS | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE) ) ); - } + CMD_BUILD_MANY_SIGNALS | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE) ) ); + } } static OnButtonClick * const _build_railroad_button_proc[] = { @@ -805,7 +805,7 @@ void ShowBuildRailToolbar(int index, int button) // don't recreate the window if we're clicking on a button and the window exists. if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) { - DeleteWindowById(WC_BUILD_TOOLBAR, 0); + DeleteWindowById(WC_BUILD_TOOLBAR, 0); _cur_railtype = (byte)index; w = AllocateWindowDesc(_build_rr_desc[index]); } @@ -848,7 +848,7 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) { } bits |= (1<<20) << (_station_show_coverage); w->click_state = bits; - + if (_railstation.dragdrop) { SetTileSelectSize(1, 1); } else { @@ -858,12 +858,12 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) { if(!_remove_button_clicked) SetTileSelectSize(x, y); } - + if (_station_show_coverage) SetTileSelectBigSize(-4, -4, 8, 8); DrawWindowWidgets(w); - + StationPickerDrawSprite(39, 42, _cur_railtype, 2); StationPickerDrawSprite(107, 42, _cur_railtype, 3); @@ -874,7 +874,7 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) { DrawStationCoverageAreaText(2, 166, (uint)-1); } break; - + case WE_CLICK: { switch(e->click.widget) { case 0: @@ -927,7 +927,7 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) { break; } } break; - + case WE_MOUSELOOP: { if (WP(w,def_d).close) { DeleteWindow(w); @@ -1013,7 +1013,7 @@ static void BuildTrainDepotWndProc(Window *w, WindowEvent *e) break; } } break; - + case WE_MOUSELOOP: if (WP(w,def_d).close) DeleteWindow(w); @@ -1047,7 +1047,7 @@ static void ShowBuildTrainDepotPicker() void InitializeRailGui() { - _build_depot_direction = 3; + _build_depot_direction = 3; _railstation.numtracks = 1; _railstation.platlength = 1; _railstation.dragdrop = true; diff --git a/resource.h b/resource.h index 3ace9d8544..03ad8b488a 100644 --- a/resource.h +++ b/resource.h @@ -4,7 +4,7 @@ // // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 104 diff --git a/road_cmd.c b/road_cmd.c index b4e9774da9..e6e1fa76a0 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -25,7 +25,7 @@ bool HasTileRoadAt(uint tile, int i) switch(GET_TILETYPE(tile)) { case MP_STREET: b = _map5[tile]; - + if ((b & 0xF0) == 0) { } else if ((b & 0xF0) == 0x10) { b = (b&8)?5:10; @@ -34,7 +34,7 @@ bool HasTileRoadAt(uint tile, int i) } else return false; break; - + case MP_STATION: b = _map5[tile]; if (!IS_BYTE_INSIDE(b, 0x43, 0x43+8)) @@ -93,7 +93,7 @@ static bool CheckAllowRemoveRoad(uint tile, uint br, bool *edge_road) if (blocks&0x2A && HasTileRoadAt(TILE_ADDXY(tile, 0, 1), 0)) n |= 4; if (blocks&0x19 && HasTileRoadAt(TILE_ADDXY(tile, 1, 0), 3)) n |= 2; if (blocks&0x16 && HasTileRoadAt(TILE_ADDXY(tile, 0,-1), 2)) n |= 1; - + // If 0 or 1 bits are set in n, or if no bits that match the bits to remove, // then allow it if ((n & (n-1)) != 0 && (n & br) != 0) { @@ -136,17 +136,17 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) int32 cost; uint tile; Town *t; - /* true if the roadpiece was always removeable, + /* true if the roadpiece was always removeable, false if it was a center piece. Affects town ratings drop */ bool edge_road; - + SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); FindLandscapeHeight(&ti, x, y); tile = ti.tile; t = ClosestTownFromTile(tile, (uint)-1); // needed for town rating penalty - + // allow deleting road under bridge if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) return CMD_ERROR; @@ -190,26 +190,26 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) // limit the bits to delete to the existing bits. if ((c &= ti.map5) == 0) goto return_error; - + // calculate the cost t2 = c; cost = 0; do { - if (t2&1) cost += _price.remove_road; + if (t2&1) cost += _price.remove_road; } while(t2>>=1); - + // check if you're allowed to remove the street owned by a town - // removal allowance depends on difficulty setting + // removal allowance depends on difficulty setting if(_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR) { - if (!CheckforTownRating(tile, flags, t, ROAD_REMOVE)) + if (!CheckforTownRating(tile, flags, t, ROAD_REMOVE)) return CMD_ERROR; } - + if (flags & DC_EXEC) { - // checks if the owner is town than decrease town rating by 50 until you have + // checks if the owner is town than decrease town rating by 50 until you have // a "Poor" town rating if(_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR) - ChangeTownRating(t, -_road_remove_cost[(byte)edge_road], -100); + ChangeTownRating(t, -_road_remove_cost[(byte)edge_road], -100); _map5[tile] ^= c; if ((_map5[tile]&0xF) == 0) @@ -218,12 +218,12 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) MarkTileDirtyByTile(tile); } - return cost; + return cost; } else if (!(ti.map5 & 0xE0)) { byte c; if (!(ti.map5 & 8)) { - c = 2; + c = 2; if (p1 & 5) goto return_error; } else { c = 1; @@ -232,7 +232,7 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) cost = _price.remove_road * 2; if (flags & DC_EXEC) { - ModifyTile(tile, + ModifyTile(tile, MP_SETTYPE(MP_RAILWAY) | MP_MAP2_CLEAR | MP_MAP3LO | MP_MAP3HI_CLEAR | MP_MAP5, _map3_hi[tile] & 0xF, /* map3_lo */ @@ -257,7 +257,7 @@ enum { ROAD_NE = 8, // NE road track ROAD_ALL = (ROAD_NW | ROAD_SW | ROAD_SE | ROAD_NE) }; - + static const byte _valid_tileh_slopes_road[3][15] = { // set of normal ones { @@ -266,9 +266,9 @@ static const byte _valid_tileh_slopes_road[3][15] = { ROAD_NW | ROAD_SE, 0, 0, ROAD_NW | ROAD_SE, 0, 0, // 9, 10, 11 ROAD_SW | ROAD_NE, 0, 0 - }, + }, // allowed road for an evenly raised platform - { + { 0, ROAD_SW | ROAD_NW, ROAD_SW | ROAD_SE, @@ -299,7 +299,7 @@ static const byte _valid_tileh_slopes_road[3][15] = { }; -static uint32 CheckRoadSlope(int tileh, byte *pieces, byte existing) +static uint32 CheckRoadSlope(int tileh, byte *pieces, byte existing) { if (!(tileh & 0x10)) { byte road_bits = *pieces | existing; @@ -310,10 +310,10 @@ static uint32 CheckRoadSlope(int tileh, byte *pieces, byte existing) if (tileh != 0) *pieces |= _valid_tileh_slopes_road[0][tileh]; return 0; // no extra cost } - + // foundation is used. Whole tile is leveled up if ((~_valid_tileh_slopes_road[1][tileh] & road_bits) == 0) { - return existing ? 0 : _price.terraform; + return existing ? 0 : _price.terraform; } // partly leveled up tile, only if there's no road on that tile @@ -337,7 +337,7 @@ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) int32 cost; byte pieces = (byte)p1, existing = 0; uint tile; - + SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); FindLandscapeHeight(&ti, x, y); @@ -557,7 +557,7 @@ int32 CmdRemoveLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) uint bits = (p2 & 4) ? ROAD_SE | ROAD_NW : ROAD_SW | ROAD_NE; if (tile == end_tile && !(p2&2)) bits &= ROAD_NW | ROAD_NE; if (tile == start_tile && (p2&1)) bits &= ROAD_SE | ROAD_SW; - + // try to remove the halves. if (bits) { ret = DoCommandByTile(tile, bits, 0, flags, CMD_REMOVE_ROAD); @@ -578,7 +578,7 @@ int32 CmdRemoveLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) return cost; } -/* Build a road depot +/* Build a road depot * p1 - direction (0-3) * p2 - unused */ @@ -612,7 +612,7 @@ int32 CmdBuildRoadDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (dep == NULL) return CMD_ERROR; - if (flags & DC_EXEC) { + if (flags & DC_EXEC) { if (_current_player == _local_player) _last_built_road_depot_tile = (TileIndex)tile; @@ -665,10 +665,10 @@ static int32 ClearTile_Road(uint tile, byte flags) { ret = DoCommandByTile(tile, (m5&8)?5:10, 0, flags, CMD_REMOVE_ROAD); if (ret == CMD_ERROR) return CMD_ERROR; - + if (flags & DC_EXEC) { DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); - } + } return ret; } else { @@ -703,7 +703,7 @@ uint GetRoadFoundation(uint tileh, uint bits) { return tileh; // inclined sloped building - if ( ((i=0, tileh == 1) || (i+=2, tileh == 2) || (i+=2, tileh == 4) || (i+=2, tileh == 8)) && + if ( ((i=0, tileh == 1) || (i+=2, tileh == 2) || (i+=2, tileh == 4) || (i+=2, tileh == 8)) && ((bits == (ROAD_SW | ROAD_NE)) || (i++, bits == (ROAD_NW | ROAD_SE)))) return i + 15; @@ -723,7 +723,7 @@ const byte _road_sloped_sprites[14] = { static void DrawTile_Road(TileInfo *ti) { - uint32 image; + uint32 image; byte m2; const byte *s; @@ -733,7 +733,7 @@ static void DrawTile_Road(TileInfo *ti) if (ti->tileh != 0) { int f = GetRoadFoundation(ti->tileh, ti->map5 & 0xF); if (f) DrawFoundation(ti, f); - + // default sloped sprites.. if (ti->tileh != 0) { image = _road_sloped_sprites[ti->tileh - 1] + 0x53F; @@ -747,7 +747,7 @@ static void DrawTile_Road(TileInfo *ti) m2 = _map2[ti->tile] & 7; if (m2 == 0) image |= 0x3178000; - + if (_map3_hi[ti->tile] & 0x80) { image += 19; } else if (m2 > 1 && m2 != 6) { @@ -766,7 +766,7 @@ static void DrawTile_Road(TileInfo *ti) } drts = (const DrawRoadTileStruct*)_road_display_table[m2][ti->map5 & 0xF]; - + while ((image = drts->image) != 0) { int x = ti->x | drts->subcoord_x; int y = ti->y | drts->subcoord_y; @@ -800,7 +800,7 @@ static void DrawTile_Road(TileInfo *ti) uint32 ormod; int player; const DrawRoadSeqStruct *drss; - + if (ti->tileh != 0) { DrawFoundation(ti, ti->tileh); } ormod = 0x315; @@ -809,7 +809,7 @@ static void DrawTile_Road(TileInfo *ti) ormod = PLAYER_SPRITE_COLOR(player); s = _road_display_datas[ti->map5 & 0xF]; - + DrawGroundSprite(*(uint32*)s); s += sizeof(uint32); drss = (DrawRoadSeqStruct*)s; @@ -818,7 +818,7 @@ static void DrawTile_Road(TileInfo *ti) if (image & 0x8000) image |= ormod; - AddSortableSpriteToDraw(image, ti->x | drss->subcoord_x, + AddSortableSpriteToDraw(image, ti->x | drss->subcoord_x, ti->y | drss->subcoord_y, drss->width, drss->height, 0x14, ti->z); drss++; } @@ -843,7 +843,7 @@ void DrawRoadDepotSprite(int x, int y, int image) for(dtss = (DrawRoadSeqStruct *)t; dtss->image != 0; dtss++) { Point pt = RemapCoords(dtss->subcoord_x, dtss->subcoord_y, 0); - + image = dtss->image; if (image & 0x8000) image |= ormod; @@ -933,7 +933,7 @@ static void TileLoop_Road(uint tile) { Town *t; int grp; - + if (_opt.landscape == LT_HILLY) { // Fix snow style if the road is above the snowline if ((_map3_hi[tile] & 0x80) != ((GetTileZ(tile) > _opt.snow_line) ? 0x80 : 0x00)) { @@ -961,14 +961,14 @@ static void TileLoop_Road(uint tile) } grp = GetTownRadiusGroup(t, tile); - + // Show an animation to indicate road work - if (t->road_build_months != 0 && + if (t->road_build_months != 0 && !(GetTileDist(t->xy, tile) >= 8 && grp==0) && (_map5[tile]==5 || _map5[tile]==10)) { if (GetTileSlope(tile, NULL) == 0 && EnsureNoVehicle(tile) && CHANCE16(1,20)) { _map2[tile] = ((_map2[tile]&7) <= 1) ? 6 : 7; - + SndPlayTileFx(0x1F,tile); CreateEffectVehicleAbove( GET_TILE_X(tile) * 16 + 7, @@ -987,7 +987,7 @@ static void TileLoop_Road(uint tile) if (b == p[0]) return; - + if (b == p[1]) { b = p[0]; } else if (b == 0) { @@ -1000,7 +1000,7 @@ static void TileLoop_Road(uint tile) } } else { // Handle road work - + byte b = _map2[tile]; if (b < 0x80) { _map2[tile] = b + 8; @@ -1040,10 +1040,10 @@ static uint32 GetTileTrackStatus_Road(uint tile, TransportType mode) { /* Crossing */ uint32 r = 0x101; if (b&8) r <<= 1; - + if (b&4) { r *= 0x10001; - } + } return r; } else if ((b&0xF0) == 0x20) { /* Depot */