diff options
49 files changed, 206 insertions, 177 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index fcdc33f4e..c39be771a 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -148,8 +148,7 @@ static bool HaveHangarInOrderList(Aircraft *v) const Station *st = Station::Get(order->station); if (st->owner == v->owner && (st->facilities & FACIL_AIRPORT)) { /* If an airport doesn't have a hangar, skip it */ - if (st->Airport()->nof_depots != 0) - return true; + if (st->Airport()->nof_depots != 0) return true; } } @@ -261,8 +260,9 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin } UnitID unit_num = (flags & DC_AUTOREPLACE) ? 0 : GetFreeUnitNumber(VEH_AIRCRAFT); - if (unit_num > _settings_game.vehicle.max_aircraft) + if (unit_num > _settings_game.vehicle.max_aircraft) { return_cmd_error(STR_ERROR_TOO_MANY_VEHICLES_IN_GAME); + } if (flags & DC_EXEC) { Aircraft *v = new Aircraft(); // aircraft @@ -372,8 +372,9 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0); SetWindowDirty(WC_COMPANY, v->owner); - if (IsLocalCompany()) + if (IsLocalCompany()) { InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Aircraft window + } Company::Get(_current_company)->num_engines[eid]++; } @@ -571,11 +572,12 @@ static void HelicopterTickHandler(Aircraft *v) } } } else { - if (u->cur_speed == 0) + if (u->cur_speed == 0) { u->cur_speed = 0x70; - - if (u->cur_speed >= 0x50) + } + if (u->cur_speed >= 0x50) { u->cur_speed--; + } } int tick = ++u->tick_counter; @@ -727,8 +729,9 @@ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE, /* updates statusbar only if speed have changed to save CPU time */ if (spd != v->cur_speed) { v->cur_speed = spd; - if (_settings_client.gui.vehicle_speed) + if (_settings_client.gui.vehicle_speed) { SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); + } } /* Adjust distance moved by plane speed setting */ @@ -1144,8 +1147,9 @@ static void HandleBrokenAircraft(Aircraft *v) v->breakdown_ctr = 1; v->vehstatus |= VS_AIRCRAFT_BROKEN; - if (v->breakdowns_since_last_service != 255) + if (v->breakdowns_since_last_service != 255) { v->breakdowns_since_last_service++; + } SetWindowDirty(WC_VEHICLE_VIEW, v->index); SetWindowDirty(WC_VEHICLE_DETAILS, v->index); } diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index c75ad7df0..a2bec2870 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -324,8 +324,9 @@ DEF_CONSOLE_CMD(ConRemove) const char *file = argv[1]; const FiosItem *item = GetFiosItem(file); if (item != NULL) { - if (!FiosDelete(item->name)) + if (!FiosDelete(item->name)) { IConsolePrintF(CC_ERROR, "%s: Failed to delete file", file); + } } else { IConsolePrintF(CC_ERROR, "%s: No such file or directory.", file); } @@ -889,8 +890,9 @@ DEF_CONSOLE_CMD(ConExec) IConsoleCmdExec(cmdline); } - if (ferror(script_file)) + if (ferror(script_file)) { IConsoleError("Encountered errror while trying to read from script file"); + } _script_running = false; FioFCloseFile(script_file); diff --git a/src/debug.cpp b/src/debug.cpp index 85c42bdaf..a13cb0efa 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -142,11 +142,12 @@ void SetDebugString(const char *s) /* check debugging levels */ p = NULL; - for (i = debug_level; i != endof(debug_level); ++i) + for (i = debug_level; i != endof(debug_level); ++i) { if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) { p = i->level; break; } + } if (*s == '=') s++; v = strtoul(s, &end, 0); diff --git a/src/economy.cpp b/src/economy.cpp index 305bbfa1e..02422835d 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -192,8 +192,9 @@ int UpdateCompanyRatingAndValue(Company *c, bool update) _score_part[owner][SCORE_VEHICLES] = num; /* Don't allow negative min_profit to show */ - if (min_profit > 0) + if (min_profit > 0) { _score_part[owner][SCORE_MIN_PROFIT] = ClampToI32(min_profit); + } } /* Count stations */ @@ -561,8 +562,7 @@ static void CompaniesGenStatistics() } cur_company.Restore(); - if (!HasBit(1 << 0 | 1 << 3 | 1 << 6 | 1 << 9, _cur_month)) - return; + if (!HasBit(1 << 0 | 1 << 3 | 1 << 6 | 1 << 9, _cur_month)) return; FOR_ALL_COMPANIES(c) { memmove(&c->old_economy[1], &c->old_economy[0], sizeof(c->old_economy) - sizeof(c->old_economy[0])); diff --git a/src/engine.cpp b/src/engine.cpp index a814613f1..beb755df5 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -747,8 +747,9 @@ void EnginesMonthlyLoop() e->flags |= ENGINE_EXCLUSIVE_PREVIEW; /* Do not introduce new rail wagons */ - if (!IsWagon(e->index)) + if (!IsWagon(e->index)) { e->preview_company_rank = 1; // Give to the company with the highest rating. + } } } } diff --git a/src/fileio.cpp b/src/fileio.cpp index 788fc7cfe..46d28b848 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -164,10 +164,9 @@ static inline void FioCloseFile(int slot) void FioCloseAll() { - int i; - - for (i = 0; i != lengthof(_fio.handles); i++) + for (int i = 0; i != lengthof(_fio.handles); i++) { FioCloseFile(i); + } } #if defined(LIMITED_FDS) diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 7c358145b..80db06454 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -263,7 +263,7 @@ static const char *GetEnglishFontName(const ENUMLOGFONTEX *logfont) font_name[length] = '\0'; if ((platformId == 1 && languageId == 0) || // Macintosh English - (platformId == 3 && languageId == 0x0409)) { // Microsoft English (US) + (platformId == 3 && languageId == 0x0409)) { // Microsoft English (US) ret_font_name = font_name; break; } @@ -467,8 +467,8 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i CFRelease(font_name); /* Skip some inappropriate or ugly looking fonts that have better alternatives. */ if (strncmp(name, "Courier", 7) == 0 || strncmp(name, "Apple Symbols", 13) == 0 || - strncmp(name, ".Aqua", 5) == 0 || strncmp(name, "LastResort", 10) == 0 || - strncmp(name, "GB18030 Bitmap", 14) == 0) continue; + strncmp(name, ".Aqua", 5) == 0 || strncmp(name, "LastResort", 10) == 0 || + strncmp(name, "GB18030 Bitmap", 14) == 0) continue; /* Save result. */ strecpy(settings->small_font, name, lastof(settings->small_font)); diff --git a/src/gfx.cpp b/src/gfx.cpp index e394ad64b..4180be1d6 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1757,8 +1757,9 @@ static void SwitchAnimatedCursor() void CursorTick() { - if (_cursor.animate_timeout != 0 && --_cursor.animate_timeout == 0) + if (_cursor.animate_timeout != 0 && --_cursor.animate_timeout == 0) { SwitchAnimatedCursor(); + } } void SetMouseCursor(CursorID sprite, PaletteID pal) diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index b4419d337..f95db2ec8 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -360,8 +360,7 @@ protected: GfxFillRect(r.left, y, r.right, y, GRAPH_AXIS_LINE_COLOUR); /* Find the largest value that will be drawn. */ - if (this->num_on_x_axis == 0) - return; + if (this->num_on_x_axis == 0) return; assert(this->num_on_x_axis > 0); assert(this->num_dataset > 0); diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index b9508084e..98214bcbd 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -244,8 +244,9 @@ static void IndustryDrawToffeeQuarry(const TileInfo *ti) if (IsIndustryCompleted(ti->tile)) { x = _industry_anim_offs_toffee[GetIndustryAnimationState(ti->tile)]; - if (x == 0xFF) + if (x == 0xFF) { x = 0; + } } AddChildSpriteScreen(SPR_IT_TOFFEE_QUARRY_SHOVEL, PAL_NONE, 22 - x, 24 + x); @@ -670,8 +671,7 @@ static void AnimateTile_Industry(TileIndex tile) case GFX_GOLD_MINE_TOWER_ANIMATED: { int state = _tick_counter & 0x7FF; - if ((state -= 0x400) < 0) - return; + if ((state -= 0x400) < 0) return; if (state < 0x1A0) { if (state < 0x20 || state >= 0x180) { @@ -680,11 +680,9 @@ static void AnimateTile_Industry(TileIndex tile) SetIndustryAnimationState(tile, m | 0x40); SndPlayTileFx(SND_0B_MINING_MACHINERY, tile); } - if (state & 7) - return; + if (state & 7) return; } else { - if (state & 3) - return; + if (state & 3) return; } m = (GetIndustryAnimationState(tile) + 1) | 0x40; if (m > 0xC2) m = 0xC0; @@ -693,8 +691,7 @@ static void AnimateTile_Industry(TileIndex tile) } else if (state >= 0x200 && state < 0x3A0) { int i; i = (state < 0x220 || state >= 0x380) ? 7 : 3; - if (state & i) - return; + if (state & i) return; m = (GetIndustryAnimationState(tile) & 0xBF) - 1; if (m < 0x80) m = 0x82; @@ -972,8 +969,7 @@ static void PlantFarmField(TileIndex tile, IndustryID industry) int type; if (_settings_game.game_creation.landscape == LT_ARCTIC) { - if (GetTileZ(tile) + TILE_HEIGHT * 2 >= GetSnowLine()) - return; + if (GetTileZ(tile) + TILE_HEIGHT * 2 >= GetSnowLine()) return; } /* determine field size */ @@ -1066,8 +1062,9 @@ static void ChopLumberMillTrees(Industry *i) if (!IsIndustryCompleted(tile)) return; ///< Can't proceed if not completed - if (CircularTileSearch(&tile, 40, SearchLumberMillTrees, NULL)) ///< 40x40 tiles to search + if (CircularTileSearch(&tile, 40, SearchLumberMillTrees, NULL)) { ///< 40x40 tiles to search i->produced_cargo_waiting[0] = min(0xffff, i->produced_cargo_waiting[0] + 45); ///< Found a tree, add according value to waiting cargo + } } static void ProduceIndustryGoods(Industry *i) @@ -1430,8 +1427,7 @@ static bool CheckCanTerraformSurroundingTiles(TileIndex tile, uint height, int i TILE_LOOP(tile_walk, size_x, size_y, tile) { curh = TileHeight(tile_walk); /* Is the tile clear? */ - if ((GetTileType(tile_walk) != MP_CLEAR) && (GetTileType(tile_walk) != MP_TREES)) - return false; + if ((GetTileType(tile_walk) != MP_CLEAR) && (GetTileType(tile_walk) != MP_TREES)) return false; /* Don't allow too big of a change if this is the sub-tile check */ if (internal != 0 && Delta(curh, height) > 1) return false; @@ -1440,8 +1436,9 @@ static bool CheckCanTerraformSurroundingTiles(TileIndex tile, uint height, int i * has to be correct too (in level, or almost in level) * else you get a chain-reaction of terraforming. */ if (internal == 0 && curh != height) { - if (TileX(tile_walk) == 0 || TileY(tile_walk) == 0 || !CheckCanTerraformSurroundingTiles(tile_walk + TileDiffXY(-1, -1), height, internal + 1)) + if (TileX(tile_walk) == 0 || TileY(tile_walk) == 0 || !CheckCanTerraformSurroundingTiles(tile_walk + TileDiffXY(-1, -1), height, internal + 1)) { return false; + } } } @@ -2279,8 +2276,9 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) /* Prevent production to overflow or Oil Rig passengers to be over-"produced" */ new_prod = Clamp(new_prod, 1, 255); - if (((indspec->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0) && j == 1) + if (((indspec->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0) && j == 1) { new_prod = Clamp(new_prod, 0, 16); + } /* Do not stop closing the industry when it has the lowest possible production rate */ if (new_prod == old_prod && old_prod > 1) { diff --git a/src/landscape.cpp b/src/landscape.cpp index ea3199422..77cfbe516 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -837,8 +837,9 @@ static void CreateDesertOrRainForest() TileIndex t = AddTileIndexDiffCWrap(tile, *data); if (t != INVALID_TILE && (TileHeight(t) >= 4 || IsTileType(t, MP_WATER))) break; } - if (data == endof(_make_desert_or_rainforest_data)) + if (data == endof(_make_desert_or_rainforest_data)) { SetTropicZone(tile, TROPICZONE_DESERT); + } } for (uint i = 0; i != 256; i++) { @@ -857,8 +858,9 @@ static void CreateDesertOrRainForest() TileIndex t = AddTileIndexDiffCWrap(tile, *data); if (t != INVALID_TILE && IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_DESERT)) break; } - if (data == endof(_make_desert_or_rainforest_data)) + if (data == endof(_make_desert_or_rainforest_data)) { SetTropicZone(tile, TROPICZONE_RAINFOREST); + } } } diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 09ef1b275..4bcf82c14 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -180,8 +180,7 @@ void ZoomInOrOutToCursorWindow(bool in, Window *w) if (_game_mode != GM_MENU) { ViewPort *vp = w->viewport; - if ((in && vp->zoom == ZOOM_LVL_MIN) || (!in && vp->zoom == ZOOM_LVL_MAX)) - return; + if ((in && vp->zoom == ZOOM_LVL_MIN) || (!in && vp->zoom == ZOOM_LVL_MAX)) return; Point pt = GetTileZoomCenterWindow(in, w); if (pt.x != -1) { diff --git a/src/misc/binaryheap.hpp b/src/misc/binaryheap.hpp index 65c026ac0..944032cac 100644 --- a/src/misc/binaryheap.hpp +++ b/src/misc/binaryheap.hpp @@ -87,8 +87,9 @@ protected: /* while children are valid */ while (child <= this->items) { /* choose the smaller child */ - if (child < this->items && *this->data[child + 1] < *this->data[child]) + if (child < this->items && *this->data[child + 1] < *this->data[child]) { child++; + } /* is it smaller than our parent? */ if (!(*this->data[child] < *item)) { /* the smaller child is still bigger or same as parent => we are done */ diff --git a/src/misc/blob.hpp b/src/misc/blob.hpp index ed75ca5ab..d77a1b9d8 100644 --- a/src/misc/blob.hpp +++ b/src/misc/blob.hpp @@ -263,12 +263,14 @@ public: tmp->capacity = new_size - (header_size + tail_reserve); /* copy existing data */ - if (tmp->items != 0) + if (tmp->items != 0) { memcpy(tmp + 1, data, tmp->items); + } /* replace our block with new one */ - if (Capacity() > 0) + if (Capacity() > 0) { RawFree(&Hdr()); + } Init(tmp); } diff --git a/src/misc/crc32.hpp b/src/misc/crc32.hpp index af7eac4c4..a4b0eefc4 100644 --- a/src/misc/crc32.hpp +++ b/src/misc/crc32.hpp @@ -22,8 +22,9 @@ struct CCrc32 uint8 *begin = (uint8*)pBuffer; uint8 *end = begin + nCount; - for (uint8 *cur = begin; cur < end; cur++) + for (uint8 *cur = begin; cur < end; cur++) { crc = (crc >> 8) ^ pTable[cur[0] ^ (uint8)(crc & 0xff)]; + } crc ^= 0xffffffff; return crc; diff --git a/src/mixer.cpp b/src/mixer.cpp index 7742c55a1..401a9c0ba 100644 --- a/src/mixer.cpp +++ b/src/mixer.cpp @@ -157,12 +157,13 @@ void MxMixSamples(void *buffer, uint samples) MixerChannel *MxAllocateChannel() { MixerChannel *mc; - for (mc = _channels; mc != endof(_channels); mc++) + for (mc = _channels; mc != endof(_channels); mc++) { if (!mc->active) { free(mc->memory); mc->memory = NULL; return mc; } + } return NULL; } diff --git a/src/network/network.cpp b/src/network/network.cpp index aad7e7ae6..32f4a70e6 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -264,9 +264,9 @@ uint NetworkCalculateLag(const NetworkClientSocket *cs) /* This client has missed his ACK packet after 1 DAY_TICKS.. * so we increase his lag for every frame that passes! * The packet can be out by a max of _net_frame_freq */ - if (cs->last_frame_server + DAY_TICKS + _settings_client.network.frame_freq < _frame_counter) + if (cs->last_frame_server + DAY_TICKS + _settings_client.network.frame_freq < _frame_counter) { lag += _frame_counter - (cs->last_frame_server + DAY_TICKS + _settings_client.network.frame_freq); - + } return lag; } diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 64b86c151..3178df8d2 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -166,9 +166,9 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR)(NetworkClientSocket *cs, Netw if (new_cs->status > STATUS_AUTHORIZED && new_cs != cs) { /* Some errors we filter to a more general error. Clients don't have to know the real * reason a joining failed. */ - if (error == NETWORK_ERROR_NOT_AUTHORIZED || error == NETWORK_ERROR_NOT_EXPECTED || error == NETWORK_ERROR_WRONG_REVISION) + if (error == NETWORK_ERROR_NOT_AUTHORIZED || error == NETWORK_ERROR_NOT_EXPECTED || error == NETWORK_ERROR_WRONG_REVISION) { error = NETWORK_ERROR_ILLEGAL_PACKET; - + } SEND_COMMAND(PACKET_SERVER_ERROR_QUIT)(new_cs, cs->client_id, error); } } @@ -274,8 +274,9 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WELCOME) /* Transmit info about all the active clients */ FOR_ALL_CLIENT_SOCKETS(new_cs) { - if (new_cs != cs && new_cs->status > STATUS_AUTHORIZED) + if (new_cs != cs && new_cs->status > STATUS_AUTHORIZED) { SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, new_cs->GetInfo()); + } } /* Also send the info of the server */ return SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, NetworkFindClientInfoFromClientID(CLIENT_ID_SERVER)); @@ -1076,8 +1077,9 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co if ((ClientID)dest == CLIENT_ID_SERVER) { ci = NetworkFindClientInfoFromClientID(from_id); /* Display the text locally, and that is it */ - if (ci != NULL) + if (ci != NULL) { NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColour(ci->client_playas), false, ci->client_name, msg, data); + } } else { /* Else find the client to send the message to */ FOR_ALL_CLIENT_SOCKETS(cs) { @@ -1093,8 +1095,9 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co if (from_id == CLIENT_ID_SERVER) { ci = NetworkFindClientInfoFromClientID(from_id); ci_to = NetworkFindClientInfoFromClientID((ClientID)dest); - if (ci != NULL && ci_to != NULL) + if (ci != NULL && ci_to != NULL) { NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColour(ci->client_playas), true, ci_to->client_name, msg, data); + } } else { FOR_ALL_CLIENT_SOCKETS(cs) { if (cs->client_id == from_id) { @@ -1156,8 +1159,9 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co SEND_COMMAND(PACKET_SERVER_CHAT)(cs, action, from_id, false, msg, data); } ci = NetworkFindClientInfoFromClientID(from_id); - if (ci != NULL) + if (ci != NULL) { NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColour(ci->client_playas), false, ci->client_name, msg, data); + } break; } } diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp index eb4f8b99b..9d5ce98a2 100644 --- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -532,8 +532,7 @@ static void NetworkUDPAdvertiseThread(void *pntr) void NetworkUDPAdvertise() { /* Check if we should send an advertise */ - if (!_networking || !_network_server || !_network_udp_server || !_settings_client.network.server_advertise) - return; + if (!_networking || !_network_server || !_network_udp_server || !_settings_client.network.server_advertise) return; if (_network_need_advertise) { _network_need_advertise = false; @@ -541,13 +540,12 @@ void NetworkUDPAdvertise() } else { /* Only send once every ADVERTISE_NORMAL_INTERVAL ticks */ if (_network_advertise_retries == 0) { - if ((_network_last_advertise_frame + ADVERTISE_NORMAL_INTERVAL) > _frame_counter) - return; + if ((_network_last_advertise_frame + ADVERTISE_NORMAL_INTERVAL) > _frame_counter) return; + _network_advertise_retries = ADVERTISE_RETRY_TIMES; } - if ((_network_last_advertise_frame + ADVERTISE_RETRY_INTERVAL) > _frame_counter) - return; + if ((_network_last_advertise_frame + ADVERTISE_RETRY_INTERVAL) > _frame_counter) return; } _network_advertise_retries--; diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index 5fb4d587d..5b4fd268c 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -195,8 +195,7 @@ void SetCustomStationSpec(StationSpec *statspec) const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station) { assert(sclass < STAT_CLASS_MAX); - if (station < _station_classes[sclass].stations) - return _station_classes[sclass].spec[station]; + if (station < _station_classes[sclass].stations) return _station_classes[sclass].spec[station]; /* If the custom station isn't defined any more, then the GRF file * probably was not loaded. */ diff --git a/src/openttd.cpp b/src/openttd.cpp index b15f38aa2..0d8bead6b 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -239,8 +239,9 @@ struct MyGetOptData { static int MyGetOpt(MyGetOptData *md) { char *s = md->cont; - if (s != NULL) + if (s != NULL) { goto md_continue_here; + } for (;;) { if (--md->numleft < 0) return -1; @@ -263,8 +264,7 @@ md_continue_here:; /* It comes as a separate arg. Check if out of args? */ if (--md->numleft < 0 || *(t = *md->argv) == '-') { /* Check if item is optional? */ - if (r[2] != ':') - return -2; + if (r[2] != ':') return -2; md->numleft++; t = NULL; } else { @@ -645,10 +645,11 @@ int ttd_main(int argc, char *argv[]) DEBUG(misc, 1, "Loading blitter..."); if (blitter == NULL && _ini_blitter != NULL) blitter = strdup(_ini_blitter); - if (BlitterFactoryBase::SelectBlitter(blitter) == NULL) + if (BlitterFactoryBase::SelectBlitter(blitter) == NULL) { StrEmpty(blitter) ? usererror("Failed to autoprobe blitter") : usererror("Failed to select requested blitter '%s'; does it exist?", blitter); + } free(blitter); DEBUG(driver, 1, "Loading drivers..."); diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 25b9162ad..800c4aca9 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -252,9 +252,9 @@ Order *OrderList::GetOrderAt(int index) const Order *order = this->first; - while (order != NULL && index-- > 0) + while (order != NULL && index-- > 0) { order = order->next; - + } return order; } @@ -686,8 +686,9 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 if (sel_ord <= u->cur_order_index) { uint cur = u->cur_order_index + 1; /* Check if we don't go out of bound */ - if (cur < u->GetNumOrders()) + if (cur < u->GetNumOrders()) { u->cur_order_index = cur; + } } /* Update any possible open window of the vehicle */ InvalidateVehicleOrder(u, INVALID_VEH_ORDER_ID | (sel_ord << 8)); @@ -752,8 +753,7 @@ CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 if (ret.Failed()) return ret; /* If we did not select an order, we maybe want to de-clone the orders */ - if (sel_ord >= v->GetNumOrders()) - return DecloneOrder(v, flags); + if (sel_ord >= v->GetNumOrders()) return DecloneOrder(v, flags); order = v->GetOrder(sel_ord); if (order == NULL) return CMD_ERROR; @@ -764,8 +764,7 @@ CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 Vehicle *u = v->FirstShared(); DeleteOrderWarnings(u); for (; u != NULL; u = u->NextShared()) { - if (sel_ord < u->cur_order_index) - u->cur_order_index--; + if (sel_ord < u->cur_order_index) u->cur_order_index--; assert(v->orders.list == u->orders.list); @@ -1480,8 +1479,7 @@ void CheckOrders(const Vehicle *v) if (v->vehstatus & VS_CRASHED) return; /* Do nothing for stopped vehicles if setting is '1' */ - if (_settings_client.gui.order_review_system == 1 && (v->vehstatus & VS_STOPPED)) - return; + if (_settings_client.gui.order_review_system == 1 && (v->vehstatus & VS_STOPPED)) return; /* do nothing we we're not the first vehicle in a share-chain */ if (v->FirstShared() != v) return; @@ -1595,8 +1593,7 @@ bool VehicleHasDepotOrders(const Vehicle *v) const Order *order; FOR_VEHICLE_ORDERS(v, order) { - if (order->IsType(OT_GOTO_DEPOT)) - return true; + if (order->IsType(OT_GOTO_DEPOT)) return true; } return false; diff --git a/src/order_gui.cpp b/src/order_gui.cpp index a815cdca4..5edcaa108 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -509,7 +509,7 @@ private: if (this->vehicle->GetNumOrders() != 0 && _ctrl_pressed == 0) return false; if (DoCommandP(this->vehicle->tile, this->vehicle->index | (u->index << 16), _ctrl_pressed ? CO_SHARE : CO_COPY, - _ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_COPY_ORDER_LIST))) { + _ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_COPY_ORDER_LIST))) { this->selected_order = -1; ResetObjectToPlace(); } diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp index 7656f7c26..fb0cbe57c 100644 --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -152,8 +152,9 @@ static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename) uint32 crc = (uint32)-1; for (;;) { - if (ReadFile(file, buffer, sizeof(buffer), &numread, NULL) == 0 || numread == 0) + if (ReadFile(file, buffer, sizeof(buffer), &numread, NULL) == 0 || numread == 0) { break; + } filesize += numread; crc = CalcCRC(buffer, numread, crc); } diff --git a/src/pathfinder/npf/aystar.cpp b/src/pathfinder/npf/aystar.cpp index a4ea8f70c..581b76921 100644 --- a/src/pathfinder/npf/aystar.cpp +++ b/src/pathfinder/npf/aystar.cpp @@ -167,8 +167,9 @@ static int AyStarMain_Loop(AyStar *aystar) /* Check for end node and if found, return that code */ if (aystar->EndNodeCheck(aystar, current) == AYSTAR_FOUND_END_NODE) { - if (aystar->FoundEndNode != NULL) + if (aystar->FoundEndNode != NULL) { aystar->FoundEndNode(aystar, current); + } free(current); return AYSTAR_FOUND_END_NODE; } diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp index 62eb0f4e4..3944e5ce4 100644 --- a/src/pathfinder/npf/npf.cpp +++ b/src/pathfinder/npf/npf.cpp @@ -168,8 +168,9 @@ static int32 NPFCalcStationOrTileHeuristic(AyStar *as, AyStarNode *current, Open uint dist; /* for train-stations, we are going to aim for the closest station tile */ - if (as->user_data[NPF_TYPE] != TRANSPORT_WATER && fstd->station_index != INVALID_STATION) + if (as->user_data[NPF_TYPE] != TRANSPORT_WATER && fstd->station_index != INVALID_STATION) { to = CalcClosestStationTile(fstd->station_index, from, fstd->station_type); + } if (as->user_data[NPF_TYPE] == TRANSPORT_ROAD) { /* Since roads only have diagonal pieces, we use manhattan distance here */ @@ -314,11 +315,13 @@ static int32 NPFWaterPathCost(AyStar *as, AyStarNode *current, OpenListNode *par cost = _trackdir_length[trackdir]; // Should be different for diagonal tracks - if (IsBuoyTile(current->tile) && IsDiagonalTrackdir(trackdir)) + if (IsBuoyTile(current->tile) && IsDiagonalTrackdir(trackdir)) { cost += _settings_game.pf.npf.npf_buoy_penalty; // A small penalty for going over buoys + } - if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction)) + if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction)) { cost += _settings_game.pf.npf.npf_water_curve_penalty; + } /* @todo More penalties? */ @@ -373,8 +376,9 @@ static int32 NPFRoadPathCost(AyStar *as, AyStarNode *current, OpenListNode *pare /* Check for turns. Road vehicles only really drive diagonal, turns are * represented by non-diagonal tracks */ - if (!IsDiagonalTrackdir(current->direction)) + if (!IsDiagonalTrackdir(current->direction)) { cost += _settings_game.pf.npf.npf_road_curve_penalty; + } NPFMarkTile(tile); DEBUG(npf, 4, "Calculating G for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), cost); @@ -502,15 +506,17 @@ static int32 NPFRailPathCost(AyStar *as, AyStarNode *current, OpenListNode *pare /* HACK: We create a new_node here so we can call EndNodeCheck. Ugly as hell * of course... */ new_node.path.node = *current; - if (as->EndNodeCheck(as, &new_node) == AYSTAR_FOUND_END_NODE && NPFGetFlag(current, NPF_FLAG_LAST_SIGNAL_RED)) + if (as->EndNodeCheck(as, &new_node) == AYSTAR_FOUND_END_NODE && NPFGetFlag(current, NPF_FLAG_LAST_SIGNAL_RED)) { cost += _settings_game.pf.npf.npf_rail_lastred_penalty; + } /* Check for slope */ cost += NPFSlopeCost(current); /* Check for turns */ - if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction)) + if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction)) { cost += _settings_game.pf.npf.npf_rail_curve_penalty; + } /* TODO, with realistic acceleration, also the amount of straight track between * curves should be taken into account, as this affects the speed limit. */ @@ -933,9 +939,10 @@ static void NPFFollowTrack(AyStar *aystar, OpenListNode *current) /* Tile with signals? */ if (IsTileType(dst_tile, MP_RAILWAY) && GetRailTileType(dst_tile) == RAIL_TILE_SIGNALS) { - if (HasSignalOnTrackdir(dst_tile, ReverseTrackdir(dst_trackdir)) && !HasSignalOnTrackdir(dst_tile, dst_trackdir) && IsOnewaySignal(dst_tile, TrackdirToTrack(dst_trackdir))) + if (HasSignalOnTrackdir(dst_tile, ReverseTrackdir(dst_trackdir)) && !HasSignalOnTrackdir(dst_tile, dst_trackdir) && IsOnewaySignal(dst_tile, TrackdirToTrack(dst_trackdir))) { /* If there's a one-way signal not pointing towards us, stop going in this direction. */ break; + } } { /* We've found ourselves a neighbour :-) */ diff --git a/src/pathfinder/yapf/yapf_rail.cpp b/src/pathfinder/yapf/yapf_rail.cpp index 4365ac50f..1fd6cfa0c 100644 --- a/src/pathfinder/yapf/yapf_rail.cpp +++ b/src/pathfinder/yapf/yapf_rail.cpp @@ -176,8 +176,9 @@ public: if (target != NULL) target->okay = true; - if (Yapf().CanUseGlobalCache(*m_res_node)) + if (Yapf().CanUseGlobalCache(*m_res_node)) { YapfNotifyTrackLayoutChange(INVALID_TILE, INVALID_TRACK); + } return true; } diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index eedfe7546..e866046a5 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -562,8 +562,9 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, cost.AddCost(RailClearCost(GetRailType(tile))); /* Charge extra to remove signals on the track, if they are there */ - if (HasSignalOnTrack(tile, track)) + if (HasSignalOnTrack(tile, track)) { cost.AddCost(DoCommand(tile, track, 0, flags, CMD_REMOVE_SIGNALS)); + } if (flags & DC_EXEC) { if (HasReservedTracks(tile, trackbit)) { @@ -703,12 +704,10 @@ static CommandCost ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileInd } /* validate the direction */ - while ( - (trdx <= 0 && dx > 0) || - (trdx >= 0 && dx < 0) || - (trdy <= 0 && dy > 0) || - (trdy >= 0 && dy < 0) - ) { + while ((trdx <= 0 && dx > 0) || + (trdx >= 0 && dx < 0) || + (trdy <= 0 && dy > 0) || + (trdy >= 0 && dy < 0)) { if (!HasBit(*trackdir, 3)) { // first direction is invalid, try the other SetBit(*trackdir, 3); // reverse the direction trdx = -trdx; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 1cd17d441..4a3101491 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1072,14 +1072,14 @@ public: int x = _settings_client.gui.station_numtracks; int y = _settings_client.gui.station_platlength; if (_railstation.orientation == AXIS_X) Swap(x, y); - if (!_remove_button_clicked) + if (!_remove_button_clicked) { SetTileSelectSize(x, y); + } } int rad = (_settings_game.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED; - if (_settings_client.gui.station_show_coverage) - SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); + if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); for (uint bits = 0; bits < 7; bits++) { bool disable = bits >= _settings_game.station.station_spread; @@ -1335,9 +1335,8 @@ public: /* Check station availability callback */ statspec = GetCustomStationSpec(_railstation.station_class, y); - if (statspec != NULL && - HasBit(statspec->callback_mask, CBM_STATION_AVAIL) && - GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) return; + if (statspec != NULL && HasBit(statspec->callback_mask, CBM_STATION_AVAIL) && + GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) return; _railstation.station_type = y; diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 63bc8f41f..35d17b7bb 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -601,8 +601,9 @@ static void HandleBrokenRoadVeh(RoadVehicle *v) v->breakdown_ctr = 1; v->cur_speed = 0; - if (v->breakdowns_since_last_service != 255) + if (v->breakdowns_since_last_service != 255) { v->breakdowns_since_last_service++; + } v->MarkDirty(); SetWindowDirty(WC_VEHICLE_VIEW, v->index); @@ -646,8 +647,9 @@ static void StartRoadVehSound(const RoadVehicle *v) { if (!PlayVehicleSound(v, VSE_START)) { SoundID s = RoadVehInfo(v->engine_type)->sfx; - if (s == SND_19_BUS_START_PULL_AWAY && (v->tick_counter & 3) == 0) + if (s == SND_19_BUS_START_PULL_AWAY && (v->tick_counter & 3) == 0) { s = SND_1A_BUS_START_PULL_AWAY_WITH_HORN; + } SndPlayVehicleFx(s, v); } } diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index b768e33ef..56cb20a3c 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -638,8 +638,9 @@ bool AfterLoadGame() * a company does not exist yet. So create one here. * 1 exeption: network-games. Those can have 0 companies * But this exeption is not true for non dedicated network_servers! */ - if (!Company::IsValidID(COMPANY_FIRST) && (!_networking || (_networking && _network_server && !_network_dedicated))) + if (!Company::IsValidID(COMPANY_FIRST) && (!_networking || (_networking && _network_server && !_network_dedicated))) { DoStartupNewCompany(false); + } /* Fix the cache for cargo payments. */ CargoPayment *cp; diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index 0bef6045a..cabbcb0ac 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -993,8 +993,9 @@ static bool LoadOldCompany(LoadgameState *ls, int num) if (num == 0) { /* If the first company has no name, make sure we call it UNNAMED */ - if (c->name_1 == 0) + if (c->name_1 == 0) { c->name_1 = STR_SV_UNNAMED; + } } else { /* Beside some multiplayer maps (1 on 1), which we don't official support, * all other companys are an AI.. mark them as such */ diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index c44703157..ac37c9566 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -409,8 +409,9 @@ static uint SlReadSimpleGamma() i &= ~0x40; if (HasBit(i, 5)) { i &= ~0x20; - if (HasBit(i, 4)) + if (HasBit(i, 4)) { SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Unsupported gamma"); + } i = (i << 8) | SlReadByte(); } i = (i << 8) | SlReadByte(); @@ -538,8 +539,9 @@ void SlSetLength(size_t length) break; case CH_ARRAY: assert(_sl.last_array_index <= _sl.array_index); - while (++_sl.last_array_index <= _sl.array_index) + while (++_sl.last_array_index <= _sl.array_index) { SlWriteArrayLength(1); + } SlWriteArrayLength(length + 1); break; case CH_SPARSE_ARRAY: @@ -1520,8 +1522,7 @@ static size_t ReadZlib() /* inflate the data */ r = inflate(&_z, 0); - if (r == Z_STREAM_END) - break; + if (r == Z_STREAM_END) break; if (r != Z_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "inflate() failed"); } while (_z.avail_out); @@ -1569,8 +1570,8 @@ static void WriteZlibLoop(z_streamp z, byte *p, size_t len, int mode) if ((n = sizeof(buf) - z->avail_out) != 0) { if (fwrite(buf, n, 1, _sl.fh) != 1) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE); } - if (r == Z_STREAM_END) - break; + if (r == Z_STREAM_END) break; + if (r != Z_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "zlib returned error code"); } while (z->avail_in || !z->avail_out); } diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index f8786d49e..45eb2293b 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -733,8 +733,9 @@ void Load_VEHS() } /* Old savegames used 'last_station_visited = 0xFF' */ - if (CheckSavegameVersion(5) && v->last_station_visited == 0xFF) + if (CheckSavegameVersion(5) && v->last_station_visited == 0xFF) { v->last_station_visited = INVALID_STATION; + } if (CheckSavegameVersion(5)) { /* Convert the current_order.type (which is a mix of type and flags, because diff --git a/src/screenshot.cpp b/src/screenshot.cpp index 983c416cb..7755c7410 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -307,8 +307,9 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user y += n; /* write them to png */ - for (i = 0; i != n; i++) + for (i = 0; i != n; i++) { png_write_row(png_ptr, (png_bytep)buff + i * w * bpp); + } } while (y != h); png_write_end(png_ptr, info_ptr); @@ -356,8 +357,7 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user DEBUG(misc, 0, "Can't convert a 32bpp screenshot to PCX format. Please pick another format."); return false; } - if (pixelformat != 8 || w == 0) - return false; + if (pixelformat != 8 || w == 0) return false; f = fopen(name, "wb"); if (f == NULL) return false; @@ -413,12 +413,13 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user uint8 ch = bufp[j]; if (ch != runchar || runcount >= 0x3f) { - if (runcount > 1 || (runchar & 0xC0) == 0xC0) + if (runcount > 1 || (runchar & 0xC0) == 0xC0) { if (fputc(0xC0 | runcount, f) == EOF) { free(buff); fclose(f); return false; } + } if (fputc(runchar, f) == EOF) { free(buff); fclose(f); @@ -431,12 +432,13 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user } /* write remaining bytes.. */ - if (runcount > 1 || (runchar & 0xC0) == 0xC0) + if (runcount > 1 || (runchar & 0xC0) == 0xC0) { if (fputc(0xC0 | runcount, f) == EOF) { free(buff); fclose(f); return false; } + } if (fputc(runchar, f) == EOF) { free(buff); fclose(f); diff --git a/src/sdl.cpp b/src/sdl.cpp index 9bbf34c27..949766772 100644 --- a/src/sdl.cpp +++ b/src/sdl.cpp @@ -67,10 +67,12 @@ SDLProcs sdl_proc; static const char *LoadSdlDLL() { - if (sdl_proc.SDL_Init != NULL) + if (sdl_proc.SDL_Init != NULL) { return NULL; - if (!LoadLibraryList((Function *)(void *)&sdl_proc, sdl_files)) + } + if (!LoadLibraryList((Function *)(void *)&sdl_proc, sdl_files)) { return "Unable to load sdl.dll"; + } return NULL; } @@ -86,11 +88,9 @@ const char *SdlOpen(uint32 x) } #endif if (_sdl_usage++ == 0) { - if (SDL_CALL SDL_Init(x | SDL_INIT_NOPARACHUTE) == -1) - return SDL_CALL SDL_GetError(); + if (SDL_CALL SDL_Init(x | SDL_INIT_NOPARACHUTE) == -1) return SDL_CALL SDL_GetError(); } else if (x != 0) { - if (SDL_CALL SDL_InitSubSystem(x) == -1) - return SDL_CALL SDL_GetError(); + if (SDL_CALL SDL_InitSubSystem(x) == -1) return SDL_CALL SDL_GetError(); } return NULL; @@ -98,8 +98,9 @@ const char *SdlOpen(uint32 x) void SdlClose(uint32 x) { - if (x != 0) + if (x != 0) { SDL_CALL SDL_QuitSubSystem(x); + } if (--_sdl_usage == 0) { SDL_CALL SDL_Quit(); } diff --git a/src/settings.cpp b/src/settings.cpp index b2bbd3622..b696ed7dc 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -107,8 +107,7 @@ static int LookupOneOfMany(const char *many, const char *one, size_t onelen = 0) if (onelen == 0) onelen = strlen(one); /* check if it's an integer */ - if (*one >= '0' && *one <= '9') - return strtoul(one, NULL, 0); + if (*one >= '0' && *one <= '9') return strtoul(one, NULL, 0); idx = 0; for (;;) { @@ -348,10 +347,8 @@ static const void *StringToVal(const SettingDescBase *desc, const char *orig_str return 0; } case SDT_BOOLX: - if (strcmp(str, "true") == 0 || strcmp(str, "on") == 0 || strcmp(str, "1") == 0) - return (void*)true; - if (strcmp(str, "false") == 0 || strcmp(str, "off") == 0 || strcmp(str, "0") == 0) - return (void*)false; + if (strcmp(str, "true") == 0 || strcmp(str, "on") == 0 || strcmp(str, "1") == 0) return (void*)true; + if (strcmp(str, "false") == 0 || strcmp(str, "off") == 0 || strcmp(str, "0") == 0) return (void*)false; ShowInfoF("ini: invalid setting value '%s' for '%s'", str, desc->name); break; diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index d231f7a9a..195f9158e 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -166,8 +166,9 @@ Money Ship::GetRunningCost() const void Ship::OnNewDay() { - if ((++this->day_counter & 7) == 0) + if ((++this->day_counter & 7) == 0) { DecreaseVehicleValue(this); + } CheckVehicleBreakdown(this); AgeVehicle(this); @@ -212,8 +213,9 @@ static void HandleBrokenShip(Vehicle *v) v->breakdown_ctr = 1; v->cur_speed = 0; - if (v->breakdowns_since_last_service != 255) + if (v->breakdowns_since_last_service != 255) { v->breakdowns_since_last_service++; + } v->MarkDirty(); SetWindowDirty(WC_VEHICLE_VIEW, v->index); @@ -337,8 +339,9 @@ static bool ShipAccelerate(Vehicle *v) /* updates statusbar only if speed have changed to save CPU time */ if (spd != v->cur_speed) { v->cur_speed = spd; - if (_settings_client.gui.vehicle_speed) + if (_settings_client.gui.vehicle_speed) { SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); + } } /* Convert direction-indepenent speed into direction-dependent speed. (old movement method) */ @@ -626,8 +629,7 @@ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 unit_num = (flags & DC_AUTOREPLACE) ? 0 : GetFreeUnitNumber(VEH_SHIP); - if (!Vehicle::CanAllocateItem() || unit_num > _settings_game.vehicle.max_ships) - return_cmd_error(STR_ERROR_TOO_MANY_VEHICLES_IN_GAME); + if (!Vehicle::CanAllocateItem() || unit_num > _settings_game.vehicle.max_ships) return_cmd_error(STR_ERROR_TOO_MANY_VEHICLES_IN_GAME); if (flags & DC_EXEC) { int x; diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp index 335daa1a2..82b680f47 100644 --- a/src/spriteloader/grf.cpp +++ b/src/spriteloader/grf.cpp @@ -161,8 +161,9 @@ bool SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, } /* Make sure to mark all transparent pixels transparent on the alpha channel too */ - for (int i = 0; i < sprite->width * sprite->height; i++) + for (int i = 0; i < sprite->width * sprite->height; i++) { if (sprite->data[i].m != 0) sprite->data[i].a = 0xFF; + } return true; } diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 3f7b9f1c6..55bedff47 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1155,8 +1155,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 if (st != NULL) { /* Reuse an existing station. */ - if (st->owner != _current_company) - return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_STATION); + if (st->owner != _current_company) return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_STATION); if (st->train_station.tile != INVALID_TILE) { /* check if we want to expanding an already existing station? */ diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index d71f545a8..817faab16 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -524,8 +524,9 @@ static void HandlePragma(char *str) strecpy(_lang_isocode, str + 8, lastof(_lang_isocode)); } else if (!memcmp(str, "plural ", 7)) { _lang_pluralform = atoi(str + 7); - if (_lang_pluralform >= lengthof(_plural_forms)) + if (_lang_pluralform >= lengthof(_plural_forms)) { error("Invalid pluralform %d", _lang_pluralform); + } } else if (!memcmp(str, "textdir ", 8)) { if (!memcmp(str + 8, "ltr", 3)) { _lang_textdir = TD_LTR; diff --git a/src/strings.cpp b/src/strings.cpp index fbd1daf0f..90019a495 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -113,13 +113,15 @@ char *GetStringWithArgs(char *buffr, uint string, int64 *argv, const char *last) switch (tab) { case 4: - if (index >= 0xC0) + if (index >= 0xC0) { return GetSpecialTownNameString(buffr, index - 0xC0, GetInt32(&argv), last); + } break; case 14: - if (index >= 0xE4) + if (index >= 0xE4) { return GetSpecialNameString(buffr, index - 0xE4, argv, last); + } break; case 15: diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index d994e8da5..b2c81b153 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -757,7 +757,7 @@ static bool IsNeighborRoadTile(TileIndex tile, const DiagDirection dir, uint dis /* Test for roadbit parallel to dir and facing towards the middle axis */ if (IsValidTile(tile + cur) && - GetTownRoadBits(TILE_ADD(tile, cur)) & DiagDirToRoadBits((pos & 2) ? dir : ReverseDiagDir(dir))) return true; + GetTownRoadBits(TILE_ADD(tile, cur)) & DiagDirToRoadBits((pos & 2) ? dir : ReverseDiagDir(dir))) return true; } return false; } @@ -1232,8 +1232,9 @@ static int GrowTownAtRoad(Town *t, TileIndex tile) /* Exclude the source position from the bitmask * and return if no more road blocks available */ cur_rb &= ~DiagDirToRoadBits(ReverseDiagDir(target_dir)); - if (cur_rb == ROAD_NONE) + if (cur_rb == ROAD_NONE) { return _grow_town_result; + } /* Select a random bit from the blockmask, walk a step * and continue the search from there. */ @@ -2508,16 +2509,13 @@ uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t) const TownActions cur = (TownActions)(1 << i); /* Is the company not able to bribe ? */ - if (cur == TACT_BRIBE && (!_settings_game.economy.bribe || t->ratings[cid] >= RATING_BRIBE_MAXIMUM)) - continue; + if (cur == TACT_BRIBE && (!_settings_game.economy.bribe || t->ratings[cid] >= RATING_BRIBE_MAXIMUM)) continue; /* Is the company not able to buy exclusive rights ? */ - if (cur == TACT_BUY_RIGHTS && !_settings_game.economy.exclusive_rights) - continue; + if (cur == TACT_BUY_RIGHTS && !_settings_game.economy.exclusive_rights) continue; /* Is the company not able to build a statue ? */ - if (cur == TACT_BUILD_STATUE && HasBit(t->statues, cid)) - continue; + if (cur == TACT_BUILD_STATUE && HasBit(t->statues, cid)) continue; if (avail >= _town_action_costs[i] * _price[PR_TOWN_ACTION] >> 8) { buttons |= cur; @@ -2615,11 +2613,10 @@ static void UpdateTownGrowRate(Town *t) } if (_settings_game.game_creation.landscape == LT_ARCTIC) { - if (TilePixelHeight(t->xy) >= GetSnowLine() && t->act_food == 0 && t->population > 90) - return; + if (TilePixelHeight(t->xy) >= GetSnowLine() && t->act_food == 0 && t->population > 90) return; + } else if (_settings_game.game_creation.landscape == LT_TROPIC) { - if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->act_food == 0 || t->act_water == 0) && t->population > 60) - return; + if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->act_food == 0 || t->act_water == 0) && t->population > 60) return; } /* Use the normal growth rate values if new buildings have been funded in @@ -2630,8 +2627,9 @@ static void UpdateTownGrowRate(Town *t) if (t->larger_town) m /= 2; t->growth_rate = m / (t->num_houses / 50 + 1); - if (m <= t->grow_counter) + if (m <= t->grow_counter) { t->grow_counter = m; + } SetBit(t->flags, TOWN_IS_FUNDED); } @@ -2850,8 +2848,9 @@ void TownsMonthlyLoop() FOR_ALL_TOWNS(t) { if (t->road_build_months != 0) t->road_build_months--; - if (t->exclusive_counter != 0) + if (t->exclusive_counter != 0) { if (--t->exclusive_counter == 0) t->exclusivity = INVALID_COMPANY; + } UpdateTownGrowRate(t); UpdateTownAmounts(t); diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index c252f1f0b..4e19212f5 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -206,7 +206,7 @@ void Train::ConsistChanged(bool same_length) } if (rvi_v->pow_wag_power != 0 && rvi_u->railveh_type == RAILVEH_WAGON && - UsesWagonOverride(u) && !HasBit(u->tcache.cached_vis_effect, 7)) { + UsesWagonOverride(u) && !HasBit(u->tcache.cached_vis_effect, 7)) { /* wagon is powered */ SetBit(u->flags, VRF_POWEREDWAGON); // cache 'powered' status } else { @@ -2862,8 +2862,9 @@ int Train::UpdateSpeed() this->subspeed = (byte)spd; { int tempmax = this->max_speed; - if (this->cur_speed > this->max_speed) + if (this->cur_speed > this->max_speed) { tempmax = this->cur_speed - (this->cur_speed / 10) - 1; + } this->cur_speed = spd = Clamp(this->cur_speed + ((int)spd >> 8), 0, tempmax); } @@ -3587,8 +3588,9 @@ static void HandleBrokenTrain(Train *v) v->breakdown_ctr = 1; v->cur_speed = 0; - if (v->breakdowns_since_last_service != 255) + if (v->breakdowns_since_last_service != 255) { v->breakdowns_since_last_service++; + } v->MarkDirty(); SetWindowDirty(WC_VEHICLE_VIEW, v->index); diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 18d11593d..5d021f965 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -100,8 +100,9 @@ public: uint i; for (i = TTW_WIDGET_BEGIN; i < TTW_WIDGET_END; i++) { const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(i); - if (IsInsideBS(pt.x, nwid->pos_x, nwid->current_x)) + if (IsInsideBS(pt.x, nwid->pos_x, nwid->current_x)) { break; + } } if (i == TTW_WIDGET_LOADING || i == TTW_WIDGET_END) return; diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 3cad201a9..af3e264bc 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -334,8 +334,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u if (ret.Failed()) return ret; cost = ret; - if (terraform_cost_north.Failed() || (terraform_cost_north.GetCost() != 0 && !allow_on_slopes)) - return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION); + if (terraform_cost_north.Failed() || (terraform_cost_north.GetCost() != 0 && !allow_on_slopes)) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION); cost.AddCost(terraform_cost_north); /* Try and clear the end landscape */ @@ -344,8 +343,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u cost.AddCost(ret); /* false - end tile slope check */ - if (terraform_cost_south.Failed() || (terraform_cost_south.GetCost() != 0 && !allow_on_slopes)) - return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION); + if (terraform_cost_south.Failed() || (terraform_cost_south.GetCost() != 0 && !allow_on_slopes)) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION); cost.AddCost(terraform_cost_south); if (transport_type == TRANSPORT_WATER && (tileh_start == SLOPE_FLAT || tileh_end == SLOPE_FLAT)) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION); diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp index 0e256ee6e..ff89b909e 100644 --- a/src/unmovable_cmd.cpp +++ b/src/unmovable_cmd.cpp @@ -286,8 +286,9 @@ static CommandCost ClearTile_Unmovable(TileIndex tile, DoCommandFlag flags) } /* checks if you're allowed to remove unmovable things */ - if (_game_mode != GM_EDITOR && _current_company != OWNER_WATER && ((flags & DC_AUTO) || !_cheats.magic_bulldozer.value) ) - return_cmd_error(flags & DC_AUTO ? STR_ERROR_OBJECT_IN_THE_WAY : INVALID_STRING_ID); + if (_game_mode != GM_EDITOR && _current_company != OWNER_WATER && ((flags & DC_AUTO) || !_cheats.magic_bulldozer.value)) { + return_cmd_error((flags & DC_AUTO) ? STR_ERROR_OBJECT_IN_THE_WAY : INVALID_STRING_ID); + } if (IsStatue(tile)) { if (flags & DC_AUTO) return_cmd_error(STR_ERROR_OBJECT_IN_THE_WAY); diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 673d50be1..34129fc05 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -689,8 +689,7 @@ static bool AllocateDibSection(int w, int h) if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals"); - if (w == _screen.width && h == _screen.height) - return false; + if (w == _screen.width && h == _screen.height) return false; _screen.width = w; _screen.pitch = (bpp == 8) ? Align(w, 4) : w; @@ -822,8 +821,8 @@ void VideoDriver_Win32::MakeDirty(int left, int top, int width, int height) static void CheckPaletteAnim() { - if (_pal_count_dirty == 0) - return; + if (_pal_count_dirty == 0) return; + InvalidateRect(_wnd.main_wnd, NULL, FALSE); } diff --git a/src/viewport.cpp b/src/viewport.cpp index 1d7b94c3d..99afa1ddb 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1057,7 +1057,7 @@ static void ViewportAddLandscape() _tile_type_procs[tt]->draw_tile_proc(&ti); if ((x_cur == (int)MapMaxX() * TILE_SIZE && IsInsideMM(y_cur, 0, MapMaxY() * TILE_SIZE + 1)) || - (y_cur == (int)MapMaxY() * TILE_SIZE && IsInsideMM(x_cur, 0, MapMaxX() * TILE_SIZE + 1))) { + (y_cur == (int)MapMaxY() * TILE_SIZE && IsInsideMM(x_cur, 0, MapMaxX() * TILE_SIZE + 1))) { TileIndex tile = TileVirtXY(x_cur, y_cur); ti.tile = tile; ti.tileh = GetTileSlope(tile, &ti.z); @@ -1875,8 +1875,7 @@ bool ScrollWindowTo(int x, int y, int z, Window *w, bool instant) Point pt = MapXYZToViewport(w->viewport, x, y, z); w->viewport->follow_vehicle = INVALID_VEHICLE; - if (w->viewport->dest_scrollpos_x == pt.x && w->viewport->dest_scrollpos_y == pt.y) - return false; + if (w->viewport->dest_scrollpos_x == pt.x && w->viewport->dest_scrollpos_y == pt.y) return false; if (instant) { w->viewport->scrollpos_x = pt.x; @@ -2713,8 +2712,9 @@ void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowC _thd.window_class = window_class; _thd.window_number = window_num; - if (mode == HT_SPECIAL) // special tools, like tunnels or docks start with presizing mode + if (mode == HT_SPECIAL) { // special tools, like tunnels or docks start with presizing mode VpStartPreSizing(); + } if ((icon & ANIMCURSOR_FLAG) != 0) { SetAnimatedMouseCursor(_animcursors[icon & ~ANIMCURSOR_FLAG]); |