From 936d78fefc193dec63723277ce36d7b603c77c71 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 10 Apr 2025 07:19:27 +0100 Subject: [PATCH] Codefix: Avoid uppercase characters in variable names. (#13985) --- src/ai/ai_instance.cpp | 2 +- src/airport_gui.cpp | 6 +- src/elrail.cpp | 72 +++++++------- src/game/game_instance.cpp | 2 +- src/network/network_content.cpp | 112 +++++++++++----------- src/network/network_content.h | 10 +- src/newgrf_industries.cpp | 26 ++--- src/newgrf_text.cpp | 10 +- src/news_gui.cpp | 12 +-- src/order_cmd.cpp | 14 +-- src/pathfinder/yapf/yapf_rail.cpp | 54 +++++------ src/pathfinder/yapf/yapf_road.cpp | 22 ++--- src/pathfinder/yapf/yapf_ship_regions.cpp | 4 +- src/picker_gui.cpp | 6 +- src/saveload/afterload.cpp | 14 +-- src/script/script_instance.cpp | 6 +- src/script/script_instance.hpp | 2 +- src/settings_gui.cpp | 4 +- src/ship_cmd.cpp | 4 +- src/timetable_gui.cpp | 4 +- src/town_cmd.cpp | 4 +- src/vehicle.cpp | 12 +-- 22 files changed, 201 insertions(+), 201 deletions(-) diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index 0c0b961cd7..07dcd40023 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -40,7 +40,7 @@ AIInstance::AIInstance() : void AIInstance::Initialize(AIInfo *info) { - this->versionAPI = info->GetAPIVersion(); + this->api_version = info->GetAPIVersion(); /* Register the AIController (including the "import" command) */ SQAIController_Register(this->engine); diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 24dec67dc8..6954317887 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -274,18 +274,18 @@ public: _selected_airport_index = Clamp(_selected_airport_index, -1, ac->GetSpecCount() - 1); /* Only when no valid airport was selected, we want to select the first airport. */ - bool selectFirstAirport = true; + bool select_first_airport = true; if (_selected_airport_index != -1) { const AirportSpec *as = ac->GetSpec(_selected_airport_index); if (as->IsAvailable()) { /* Ensure the airport layout is valid. */ _selected_airport_layout = Clamp(_selected_airport_layout, 0, static_cast(as->layouts.size() - 1)); - selectFirstAirport = false; + select_first_airport = false; this->UpdateSelectSize(); } } - if (selectFirstAirport) this->SelectFirstAvailableAirport(true); + if (select_first_airport) this->SelectFirstAvailableAirport(true); } void Close([[maybe_unused]] int data = 0) override diff --git a/src/elrail.cpp b/src/elrail.cpp index 4159ea815a..0188f16cc1 100644 --- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -295,10 +295,10 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) } TLG tlg = GetTLG(ti->tile); - uint8_t PCPstatus = 0; - uint8_t OverridePCP = 0; - uint8_t PPPpreferred[DIAGDIR_END]; - uint8_t PPPallowed[DIAGDIR_END]; + uint8_t pcp_status = 0; + uint8_t override_pcp = 0; + uint8_t ppp_preferred[DIAGDIR_END]; + uint8_t ppp_allowed[DIAGDIR_END]; /* Find which rail bits are present, and select the override points. * We don't draw a pylon: @@ -306,7 +306,7 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) * 2) on the "far" end of a bridge head (the one that connects to bridge middle), * because that one is drawn on the bridge. Exception is for length 0 bridges * which have no middle tiles */ - trackconfig[TS_HOME] = GetRailTrackBitsUniversal(ti->tile, &OverridePCP); + trackconfig[TS_HOME] = GetRailTrackBitsUniversal(ti->tile, &override_pcp); wireconfig[TS_HOME] = MaskWireBits(ti->tile, trackconfig[TS_HOME]); /* If a track bit is present that is not in the main direction, the track is level */ isflat[TS_HOME] = ((trackconfig[TS_HOME] & (TRACK_BIT_HORZ | TRACK_BIT_VERT)) != 0); @@ -343,8 +343,8 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) isflat[TS_NEIGHBOUR] = ((trackconfig[TS_NEIGHBOUR] & (TRACK_BIT_HORZ | TRACK_BIT_VERT)) != 0); - PPPpreferred[i] = 0xFF; // We start with preferring everything (end-of-line in any direction) - PPPallowed[i] = AllowedPPPonPCP[i]; + ppp_preferred[i] = 0xFF; // We start with preferring everything (end-of-line in any direction) + ppp_allowed[i] = AllowedPPPonPCP[i]; /* We cycle through all the existing tracks at a PCP and see what * PPPs we want to have, or may not have at all */ @@ -358,24 +358,24 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) /* We check whether the track in question (k) is present in the tile * (TrackSourceTile) */ - DiagDirection PCPpos = i; + DiagDirection pcp_pos = i; if (HasBit(wireconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) { /* track found, if track is in the neighbour tile, adjust the number * of the PCP for preferred/allowed determination*/ - PCPpos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i); - SetBit(PCPstatus, i); // This PCP is in use - PPPpreferred[i] &= PreferredPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; + pcp_pos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i); + SetBit(pcp_status, i); // This PCP is in use + ppp_preferred[i] &= PreferredPPPofTrackAtPCP[TracksAtPCP[i][k]][pcp_pos]; } if (HasBit(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) { - PPPallowed[i] &= ~DisallowedPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; + ppp_allowed[i] &= ~DisallowedPPPofTrackAtPCP[TracksAtPCP[i][k]][pcp_pos]; } } /* Deactivate all PPPs if PCP is not used */ - if (!HasBit(PCPstatus, i)) { - PPPpreferred[i] = 0; - PPPallowed[i] = 0; + if (!HasBit(pcp_status, i)) { + ppp_preferred[i] = 0; + ppp_allowed[i] = 0; } Foundation foundation = FOUNDATION_NONE; @@ -402,7 +402,7 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) * Level means that the slope is the same, or the track is flat */ if (tileh[TS_HOME] == tileh[TS_NEIGHBOUR] || (isflat[TS_HOME] && isflat[TS_NEIGHBOUR])) { for (uint k = 0; k < NUM_IGNORE_GROUPS; k++) { - if (PPPpreferred[i] == IgnoredPCP[k][tlg][i]) ClrBit(PCPstatus, i); + if (ppp_preferred[i] == IgnoredPCP[k][tlg][i]) ClrBit(pcp_status, i); } } @@ -410,7 +410,7 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) * In that case, we try the any of the allowed ones. if they don't exist either, don't draw * anything. Note that the preferred PPPs still contain the end-of-line markers. * Remove those (simply by ANDing with allowed, since these markers are never allowed) */ - if ((PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i]; + if ((ppp_allowed[i] & ppp_preferred[i]) != 0) ppp_allowed[i] &= ppp_preferred[i]; if (IsBridgeAbove(ti->tile)) { Track bridgetrack = GetBridgeAxis(ti->tile) == AXIS_X ? TRACK_X : TRACK_Y; @@ -418,16 +418,16 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) if ((height <= GetTileMaxZ(ti->tile) + 1) && (i == PCPpositions[bridgetrack][0] || i == PCPpositions[bridgetrack][1])) { - SetBit(OverridePCP, i); + SetBit(override_pcp, i); } } - if (PPPallowed[i] != 0 && HasBit(PCPstatus, i) && !HasBit(OverridePCP, i) && + if (ppp_allowed[i] != 0 && HasBit(pcp_status, i) && !HasBit(override_pcp, i) && (!IsRailStationTile(ti->tile) || CanStationTileHavePylons(ti->tile))) { for (Direction k = DIR_BEGIN; k < DIR_END; k++) { uint8_t temp = PPPorder[i][GetTLG(ti->tile)][k]; - if (HasBit(PPPallowed[i], temp)) { + if (HasBit(ppp_allowed[i], temp)) { uint x = ti->x + x_pcp_offsets[i] + x_ppp_offsets[temp]; uint y = ti->y + y_pcp_offsets[i] + y_ppp_offsets[temp]; @@ -474,15 +474,15 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) /* Drawing of pylons is finished, now draw the wires */ for (Track t : SetTrackBitIterator(wireconfig[TS_HOME])) { SpriteID wire_base = (t == halftile_track) ? wire_halftile : wire_normal; - uint8_t PCPconfig = HasBit(PCPstatus, PCPpositions[t][0]) + - (HasBit(PCPstatus, PCPpositions[t][1]) << 1); + uint8_t pcp_config = HasBit(pcp_status, PCPpositions[t][0]) + + (HasBit(pcp_status, PCPpositions[t][1]) << 1); const SortableSpriteStruct *sss; int tileh_selector = !(tileh[TS_HOME] % 3) * tileh[TS_HOME] / 3; // tileh for the slopes, 0 otherwise - assert(PCPconfig != 0); // We have a pylon on neither end of the wire, that doesn't work (since we have no sprites for that) + assert(pcp_config != 0); // We have a pylon on neither end of the wire, that doesn't work (since we have no sprites for that) assert(!IsSteepSlope(tileh[TS_HOME])); - sss = &RailCatenarySpriteData[Wires[tileh_selector][t][PCPconfig]]; + sss = &RailCatenarySpriteData[Wires[tileh_selector][t][pcp_config]]; /* * The "wire"-sprite position is inside the tile, i.e. 0 <= sss->?_offset < TILE_SIZE. @@ -541,22 +541,22 @@ void DrawRailCatenaryOnBridge(const TileInfo *ti) /* Finished with wires, draw pylons * every other tile needs a pylon on the northern end */ if (num % 2) { - DiagDirection PCPpos = (axis == AXIS_X ? DIAGDIR_NE : DIAGDIR_NW); - Direction PPPpos = (axis == AXIS_X ? DIR_NW : DIR_NE); - if (HasBit(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos); - uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos]; - uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos]; - AddSortableSpriteToDraw(pylon_base + pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_CATENARY), -1, -1); + DiagDirection pcp_pos = (axis == AXIS_X ? DIAGDIR_NE : DIAGDIR_NW); + Direction ppp_pos = (axis == AXIS_X ? DIR_NW : DIR_NE); + if (HasBit(tlg, (axis == AXIS_X ? 0 : 1))) ppp_pos = ReverseDir(ppp_pos); + uint x = ti->x + x_pcp_offsets[pcp_pos] + x_ppp_offsets[ppp_pos]; + uint y = ti->y + y_pcp_offsets[pcp_pos] + y_ppp_offsets[ppp_pos]; + AddSortableSpriteToDraw(pylon_base + pylon_sprites[ppp_pos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_CATENARY), -1, -1); } /* need a pylon on the southern end of the bridge */ if (GetTunnelBridgeLength(ti->tile, start) + 1 == length) { - DiagDirection PCPpos = (axis == AXIS_X ? DIAGDIR_SW : DIAGDIR_SE); - Direction PPPpos = (axis == AXIS_X ? DIR_NW : DIR_NE); - if (HasBit(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos); - uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos]; - uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos]; - AddSortableSpriteToDraw(pylon_base + pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_CATENARY), -1, -1); + DiagDirection pcp_pos = (axis == AXIS_X ? DIAGDIR_SW : DIAGDIR_SE); + Direction ppp_pos = (axis == AXIS_X ? DIR_NW : DIR_NE); + if (HasBit(tlg, (axis == AXIS_X ? 0 : 1))) ppp_pos = ReverseDir(ppp_pos); + uint x = ti->x + x_pcp_offsets[pcp_pos] + x_ppp_offsets[ppp_pos]; + uint y = ti->y + y_pcp_offsets[pcp_pos] + y_ppp_offsets[ppp_pos]; + AddSortableSpriteToDraw(pylon_base + pylon_sprites[ppp_pos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_CATENARY), -1, -1); } } diff --git a/src/game/game_instance.cpp b/src/game/game_instance.cpp index 8c30da998d..cb46650f57 100644 --- a/src/game/game_instance.cpp +++ b/src/game/game_instance.cpp @@ -35,7 +35,7 @@ GameInstance::GameInstance() : void GameInstance::Initialize(GameInfo *info) { - this->versionAPI = info->GetAPIVersion(); + this->api_version = info->GetAPIVersion(); /* Register the GameController */ SQGSController_Register(this->engine); diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index 4a347c6424..cc41d9e920 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -327,7 +327,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin /* If there's nothing to download, do nothing. */ if (files == 0) return; - this->isCancelled = false; + this->is_cancelled = false; if (fallback) { this->DownloadSelectedContentFallback(content); @@ -482,14 +482,14 @@ static inline ssize_t TransferOutFWrite(std::optional &file, const c bool ClientNetworkContentSocketHandler::Receive_SERVER_CONTENT(Packet &p) { - if (!this->curFile.has_value()) { - delete this->curInfo; + if (!this->cur_file.has_value()) { + delete this->cur_info; /* When we haven't opened a file this must be our first packet with metadata. */ - this->curInfo = new ContentInfo; - this->curInfo->type = (ContentType)p.Recv_uint8(); - this->curInfo->id = (ContentID)p.Recv_uint32(); - this->curInfo->filesize = p.Recv_uint32(); - this->curInfo->filename = p.Recv_string(NETWORK_CONTENT_FILENAME_LENGTH); + this->cur_info = new ContentInfo; + this->cur_info->type = (ContentType)p.Recv_uint8(); + this->cur_info->id = (ContentID)p.Recv_uint32(); + this->cur_info->filesize = p.Recv_uint32(); + this->cur_info->filename = p.Recv_string(NETWORK_CONTENT_FILENAME_LENGTH); if (!this->BeforeDownload()) { this->CloseConnection(); @@ -497,22 +497,22 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_CONTENT(Packet &p) } } else { /* We have a file opened, thus are downloading internal content */ - size_t toRead = p.RemainingBytesToTransfer(); - if (toRead != 0 && static_cast(p.TransferOut(TransferOutFWrite, std::ref(this->curFile))) != toRead) { + size_t to_read = p.RemainingBytesToTransfer(); + if (to_read != 0 && static_cast(p.TransferOut(TransferOutFWrite, std::ref(this->cur_file))) != to_read) { CloseWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD); ShowErrorMessage( GetEncodedString(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD), GetEncodedString(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD_FILE_NOT_WRITABLE), WL_ERROR); this->CloseConnection(); - this->curFile.reset(); + this->cur_file.reset(); return false; } - this->OnDownloadProgress(this->curInfo, (int)toRead); + this->OnDownloadProgress(this->cur_info, (int)to_read); - if (toRead == 0) this->AfterDownload(); + if (to_read == 0) this->AfterDownload(); } return true; @@ -524,16 +524,16 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_CONTENT(Packet &p) */ bool ClientNetworkContentSocketHandler::BeforeDownload() { - if (!this->curInfo->IsValid()) { - delete this->curInfo; - this->curInfo = nullptr; + if (!this->cur_info->IsValid()) { + delete this->cur_info; + this->cur_info = nullptr; return false; } - if (this->curInfo->filesize != 0) { + if (this->cur_info->filesize != 0) { /* The filesize is > 0, so we are going to download it */ - std::string filename = GetFullFilename(this->curInfo, true); - if (filename.empty() || !(this->curFile = FileHandle::Open(filename, "wb")).has_value()) { + std::string filename = GetFullFilename(this->cur_info, true); + if (filename.empty() || !(this->cur_file = FileHandle::Open(filename, "wb")).has_value()) { /* Unless that fails of course... */ CloseWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD); ShowErrorMessage( @@ -554,19 +554,19 @@ void ClientNetworkContentSocketHandler::AfterDownload() { /* We read nothing; that's our marker for end-of-stream. * Now gunzip the tar and make it known. */ - this->curFile.reset(); + this->cur_file.reset(); - if (GunzipFile(this->curInfo)) { - FioRemove(GetFullFilename(this->curInfo, true)); + if (GunzipFile(this->cur_info)) { + FioRemove(GetFullFilename(this->cur_info, true)); - Subdirectory sd = GetContentInfoSubDir(this->curInfo->type); + Subdirectory sd = GetContentInfoSubDir(this->cur_info->type); if (sd == NO_DIRECTORY) NOT_REACHED(); TarScanner ts; - std::string fname = GetFullFilename(this->curInfo, false); + std::string fname = GetFullFilename(this->cur_info, false); ts.AddFile(sd, fname); - if (this->curInfo->type == CONTENT_TYPE_BASE_MUSIC) { + if (this->cur_info->type == CONTENT_TYPE_BASE_MUSIC) { /* Music can't be in a tar. So extract the tar! */ ExtractTar(fname, BASESET_DIR); FioRemove(fname); @@ -576,7 +576,7 @@ void ClientNetworkContentSocketHandler::AfterDownload() EM_ASM(if (window["openttd_syncfs"]) openttd_syncfs()); #endif - this->OnDownloadComplete(this->curInfo->id); + this->OnDownloadComplete(this->cur_info->id); } else { ShowErrorMessage(GetEncodedString(STR_CONTENT_ERROR_COULD_NOT_EXTRACT), {}, WL_ERROR); } @@ -584,7 +584,7 @@ void ClientNetworkContentSocketHandler::AfterDownload() bool ClientNetworkContentSocketHandler::IsCancelled() const { - return this->isCancelled; + return this->is_cancelled; } /* Also called to just clean up the mess. */ @@ -594,14 +594,14 @@ void ClientNetworkContentSocketHandler::OnFailure() this->http_response.shrink_to_fit(); this->http_response_index = -2; - if (this->curFile.has_value()) { - this->OnDownloadProgress(this->curInfo, -1); + if (this->cur_file.has_value()) { + this->OnDownloadProgress(this->cur_info, -1); - this->curFile.reset(); + this->cur_file.reset(); } /* If we fail, download the rest via the 'old' system. */ - if (!this->isCancelled) { + if (!this->is_cancelled) { uint files, bytes; this->DownloadSelectedContent(files, bytes, true); @@ -633,19 +633,19 @@ void ClientNetworkContentSocketHandler::OnReceiveData(std::unique_ptr da if (data != nullptr) { /* We have data, so write it to the file. */ - if (fwrite(data.get(), 1, length, *this->curFile) != length) { + if (fwrite(data.get(), 1, length, *this->cur_file) != length) { /* Writing failed somehow, let try via the old method. */ this->OnFailure(); } else { /* Just received the data. */ - this->OnDownloadProgress(this->curInfo, (int)length); + this->OnDownloadProgress(this->cur_info, (int)length); } /* Nothing more to do now. */ return; } - if (this->curFile.has_value()) { + if (this->cur_file.has_value()) { /* We've finished downloading a file. */ this->AfterDownload(); } @@ -658,9 +658,9 @@ void ClientNetworkContentSocketHandler::OnReceiveData(std::unique_ptr da return; } - delete this->curInfo; + delete this->cur_info; /* When we haven't opened a file this must be our first packet with metadata. */ - this->curInfo = new ContentInfo; + this->cur_info = new ContentInfo; /** Check p for not being null and return calling OnFailure if that's not the case. */ #define check_not_null(p) { if ((p) == nullptr) { this->OnFailure(); return; } } @@ -678,19 +678,19 @@ void ClientNetworkContentSocketHandler::OnReceiveData(std::unique_ptr da /* Read the ID */ p = strchr(str, ','); check_and_terminate(p); - this->curInfo->id = (ContentID)atoi(str); + this->cur_info->id = (ContentID)atoi(str); /* Read the type */ str = p + 1; p = strchr(str, ','); check_and_terminate(p); - this->curInfo->type = (ContentType)atoi(str); + this->cur_info->type = (ContentType)atoi(str); /* Read the file size */ str = p + 1; p = strchr(str, ','); check_and_terminate(p); - this->curInfo->filesize = atoi(str); + this->cur_info->filesize = atoi(str); /* Read the URL */ str = p + 1; @@ -720,7 +720,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(std::unique_ptr da } /* Copy the string, without extension, to the filename. */ - this->curInfo->filename = std::move(filename); + this->cur_info->filename = std::move(filename); /* Request the next file. */ if (!this->BeforeDownload()) { @@ -742,18 +742,18 @@ void ClientNetworkContentSocketHandler::OnReceiveData(std::unique_ptr da ClientNetworkContentSocketHandler::ClientNetworkContentSocketHandler() : NetworkContentSocketHandler(), http_response_index(-2), - curFile(std::nullopt), - curInfo(nullptr), - isConnecting(false), - isCancelled(false) + cur_file(std::nullopt), + cur_info(nullptr), + is_connecting(false), + is_cancelled(false) { - this->lastActivity = std::chrono::steady_clock::now(); + this->last_activity = std::chrono::steady_clock::now(); } /** Clear up the mess ;) */ ClientNetworkContentSocketHandler::~ClientNetworkContentSocketHandler() { - delete this->curInfo; + delete this->cur_info; for (ContentInfo *ci : this->infos) delete ci; } @@ -769,15 +769,15 @@ public: void OnFailure() override { - _network_content_client.isConnecting = false; + _network_content_client.is_connecting = false; _network_content_client.OnConnect(false); } void OnConnect(SOCKET s) override { assert(_network_content_client.sock == INVALID_SOCKET); - _network_content_client.lastActivity = std::chrono::steady_clock::now(); - _network_content_client.isConnecting = false; + _network_content_client.last_activity = std::chrono::steady_clock::now(); + _network_content_client.is_connecting = false; _network_content_client.sock = s; _network_content_client.Reopen(); _network_content_client.OnConnect(true); @@ -789,10 +789,10 @@ public: */ void ClientNetworkContentSocketHandler::Connect() { - if (this->sock != INVALID_SOCKET || this->isConnecting) return; + if (this->sock != INVALID_SOCKET || this->is_connecting) return; - this->isCancelled = false; - this->isConnecting = true; + this->is_cancelled = false; + this->is_connecting = true; TCPConnecter::Create(NetworkContentServerConnectionString()); } @@ -817,7 +817,7 @@ NetworkRecvStatus ClientNetworkContentSocketHandler::CloseConnection(bool) */ void ClientNetworkContentSocketHandler::Cancel(void) { - this->isCancelled = true; + this->is_cancelled = true; this->CloseConnection(); } @@ -827,10 +827,10 @@ void ClientNetworkContentSocketHandler::Cancel(void) */ void ClientNetworkContentSocketHandler::SendReceive() { - if (this->sock == INVALID_SOCKET || this->isConnecting) return; + if (this->sock == INVALID_SOCKET || this->is_connecting) return; /* Close the connection to the content server after inactivity; there can still be downloads pending via HTTP. */ - if (std::chrono::steady_clock::now() > this->lastActivity + IDLE_TIMEOUT) { + if (std::chrono::steady_clock::now() > this->last_activity + IDLE_TIMEOUT) { this->CloseConnection(); return; } @@ -838,7 +838,7 @@ void ClientNetworkContentSocketHandler::SendReceive() if (this->CanSendReceive()) { if (this->ReceivePackets()) { /* Only update activity once a packet is received, instead of every time we try it. */ - this->lastActivity = std::chrono::steady_clock::now(); + this->last_activity = std::chrono::steady_clock::now(); } } diff --git a/src/network/network_content.h b/src/network/network_content.h index 2a693cc5f1..ee145ff6a4 100644 --- a/src/network/network_content.h +++ b/src/network/network_content.h @@ -74,11 +74,11 @@ protected: std::vector http_response; ///< The HTTP response to the requests we've been doing int http_response_index; ///< Where we are, in the response, with handling it - std::optional curFile; ///< Currently downloaded file - ContentInfo *curInfo; ///< Information about the currently downloaded file - bool isConnecting; ///< Whether we're connecting - bool isCancelled; ///< Whether the download has been cancelled - std::chrono::steady_clock::time_point lastActivity; ///< The last time there was network activity + std::optional cur_file; ///< Currently downloaded file + ContentInfo *cur_info; ///< Information about the currently downloaded file + bool is_connecting; ///< Whether we're connecting + bool is_cancelled; ///< Whether the download has been cancelled + std::chrono::steady_clock::time_point last_activity; ///< The last time there was network activity friend class NetworkContentConnecter; diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 9906ebe8f6..4caf09557d 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -107,47 +107,47 @@ static uint32_t GetClosestIndustry(TileIndex tile, IndustryType type, const Indu * Implementation of both var 67 and 68 * since the mechanism is almost the same, it is easier to regroup them on the same * function. - * @param param_setID parameter given to the callback, which is the set id, or the local id, in our terminology + * @param param_set_id parameter given to the callback, which is the set id, or the local id, in our terminology * @param layout_filter on what layout do we filter? * @param town_filter Do we filter on the same town as the current industry? * @param current Industry for which the inquiry is made * @return the formatted answer to the callback : rr(reserved) cc(count) dddd(manhattan distance of closest sister) */ -static uint32_t GetCountAndDistanceOfClosestInstance(uint8_t param_setID, uint8_t layout_filter, bool town_filter, const Industry *current) +static uint32_t GetCountAndDistanceOfClosestInstance(uint8_t param_set_id, uint8_t layout_filter, bool town_filter, const Industry *current) { - uint32_t GrfID = GetRegister(0x100); ///< Get the GRFID of the definition to look for in register 100h - IndustryType ind_index; + uint32_t grf_id = GetRegister(0x100); ///< Get the GRFID of the definition to look for in register 100h + IndustryType industry_type; uint32_t closest_dist = UINT32_MAX; uint8_t count = 0; /* Determine what will be the industry type to look for */ - switch (GrfID) { + switch (grf_id) { case 0: // this is a default industry type - ind_index = param_setID; + industry_type = param_set_id; break; case 0xFFFFFFFF: // current grf - GrfID = GetIndustrySpec(current->type)->grf_prop.grfid; + grf_id = GetIndustrySpec(current->type)->grf_prop.grfid; [[fallthrough]]; default: // use the grfid specified in register 100h - SetBit(param_setID, 7); // bit 7 means it is not an old type - ind_index = MapNewGRFIndustryType(param_setID, GrfID); + SetBit(param_set_id, 7); // bit 7 means it is not an old type + industry_type = MapNewGRFIndustryType(param_set_id, grf_id); break; } /* If the industry type is invalid, there is none and the closest is far away. */ - if (ind_index >= NUM_INDUSTRYTYPES) return 0 | 0xFFFF; + if (industry_type >= NUM_INDUSTRYTYPES) return 0 | 0xFFFF; if (layout_filter == 0 && !town_filter) { /* If the filter is 0, it could be because none was specified as well as being really a 0. * In either case, just do the regular var67 */ - closest_dist = GetClosestIndustry(current->location.tile, ind_index, current); - count = ClampTo(Industry::GetIndustryTypeCount(ind_index)); + closest_dist = GetClosestIndustry(current->location.tile, industry_type, current); + count = ClampTo(Industry::GetIndustryTypeCount(industry_type)); } else { /* Count only those who match the same industry type and layout filter * Unfortunately, we have to do it manually */ - for (const IndustryID &industry : Industry::industries[ind_index]) { + for (const IndustryID &industry : Industry::industries[industry_type]) { if (industry == current->index) continue; const Industry *i = Industry::Get(industry); diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index 5271f29716..3deb92a221 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -73,7 +73,7 @@ struct GRFTextEntry { static ReferenceThroughBaseContainer> _grf_text; -static uint8_t _currentLangID = GRFLX_ENGLISH; ///< by default, english is used. +static uint8_t _current_lang_id = GRFLX_ENGLISH; ///< by default, english is used. /** * Get the mapping from the NewGRF supplied ID to OpenTTD's internal ID. @@ -616,7 +616,7 @@ std::optional GetGRFStringFromGRFText(const GRFTextList &text_ /* Search the list of lang-strings of this stringid for current lang */ for (const auto &text : text_list) { - if (text.langid == _currentLangID) return text.text; + if (text.langid == _current_lang_id) return text.text; /* If the current string is English or American, set it as the * fallback language if the specific language isn't available. */ @@ -665,13 +665,13 @@ std::string_view GetGRFStringPtr(StringIndexInTab stringid) */ void SetCurrentGrfLangID(uint8_t language_id) { - _currentLangID = language_id; + _current_lang_id = language_id; } bool CheckGrfLangID(uint8_t lang_id, uint8_t grf_version) { if (grf_version < 7) { - switch (_currentLangID) { + switch (_current_lang_id) { case GRFLX_GERMAN: return (lang_id & GRFLB_GERMAN) != 0; case GRFLX_FRENCH: return (lang_id & GRFLB_FRENCH) != 0; case GRFLX_SPANISH: return (lang_id & GRFLB_SPANISH) != 0; @@ -679,7 +679,7 @@ bool CheckGrfLangID(uint8_t lang_id, uint8_t grf_version) } } - return (lang_id == _currentLangID || lang_id == GRFLX_UNSPECIFIED); + return (lang_id == _current_lang_id || lang_id == GRFLX_UNSPECIFIED); } /** diff --git a/src/news_gui.cpp b/src/news_gui.cpp index ab247fb7ae..f9ca7a3601 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -823,17 +823,17 @@ static void MoveToNextNewsItem() /** Delete a news item from the queue */ static std::list::iterator DeleteNewsItem(std::list::iterator ni) { - bool updateCurrentNews = (_forced_news == ni || _current_news == ni); - bool updateStatusbarNews = (_statusbar_news == ni); + bool update_current_news = (_forced_news == ni || _current_news == ni); + bool update_statusbar_news = (_statusbar_news == ni); - if (updateCurrentNews) { + if (update_current_news) { /* When we're the current news, go to the next older item first; * we just possibly made that the last news item. */ if (_current_news == ni) ++_current_news; if (_forced_news == ni) _forced_news = std::end(_news); } - if (updateStatusbarNews) { + if (update_statusbar_news) { /* When we're the current news, go to the next older item first; * we just possibly made that the last news item. */ ++_statusbar_news; @@ -842,13 +842,13 @@ static std::list::iterator DeleteNewsItem(std::list::iterato /* Delete the news from the news queue. */ ni = _news.erase(ni); - if (updateCurrentNews) { + if (update_current_news) { /* About to remove the currently forced item (shown as newspapers) || * about to remove the currently displayed item (newspapers) */ MoveToNextNewsItem(); } - if (updateStatusbarNews) { + if (update_statusbar_news) { /* About to remove the currently displayed item (ticker, or just a reminder) */ InvalidateWindowData(WC_STATUS_BAR, 0, SBI_NEWS_DELETED); // invalidate the statusbar MoveToNextTickerItem(); diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index f3d0f9a527..5ac05757b1 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -2011,21 +2011,21 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool if (v->dest_tile == 0 && TimerGameEconomy::date_fract != (v->index % Ticks::DAY_TICKS)) break; /* We need to search for the nearest depot (hangar). */ - ClosestDepot closestDepot = v->FindClosestDepot(); + ClosestDepot closest_depot = v->FindClosestDepot(); - if (closestDepot.found) { + if (closest_depot.found) { /* PBS reservations cannot reverse */ - if (pbs_look_ahead && closestDepot.reverse) return false; + if (pbs_look_ahead && closest_depot.reverse) return false; - v->SetDestTile(closestDepot.location); - v->current_order.SetDestination(closestDepot.destination); + v->SetDestTile(closest_depot.location); + v->current_order.SetDestination(closest_depot.destination); /* If there is no depot in front, reverse automatically (trains only) */ - if (v->type == VEH_TRAIN && closestDepot.reverse) Command::Do(DoCommandFlag::Execute, v->index, false); + if (v->type == VEH_TRAIN && closest_depot.reverse) Command::Do(DoCommandFlag::Execute, v->index, false); if (v->type == VEH_AIRCRAFT) { Aircraft *a = Aircraft::From(v); - if (a->state == FLYING && a->targetairport != closestDepot.destination) { + if (a->state == FLYING && a->targetairport != closest_depot.destination) { /* The aircraft is now heading for a different hangar than the next in the orders */ AircraftNextAirportPos_and_Order(a); } diff --git a/src/pathfinder/yapf/yapf_rail.cpp b/src/pathfinder/yapf/yapf_rail.cpp index 93ce81801e..39f6dffd6c 100644 --- a/src/pathfinder/yapf/yapf_rail.cpp +++ b/src/pathfinder/yapf/yapf_rail.cpp @@ -280,14 +280,14 @@ public: Node *n = Yapf().GetBestNode(); /* walk through the path back to the origin */ - Node *pNode = n; - while (pNode->parent != nullptr) { - pNode = pNode->parent; + Node *node = n; + while (node->parent != nullptr) { + node = node->parent; } /* if the origin node is our front vehicle tile/Trackdir then we didn't reverse * but we can also look at the cost (== 0 -> not reversed, == reverse_penalty -> reversed) */ - return FindDepotData(n->GetLastTile(), n->cost, pNode->cost != 0); + return FindDepotData(n->GetLastTile(), n->cost, node->cost != 0); } }; @@ -358,19 +358,19 @@ public: if (!Yapf().FindPath(v)) return false; /* Found a destination, set as reservation target. */ - Node *pNode = Yapf().GetBestNode(); - this->SetReservationTarget(pNode, pNode->GetLastTile(), pNode->GetLastTrackdir()); + Node *node = Yapf().GetBestNode(); + this->SetReservationTarget(node, node->GetLastTile(), node->GetLastTrackdir()); /* Walk through the path back to the origin. */ - Node *pPrev = nullptr; - while (pNode->parent != nullptr) { - pPrev = pNode; - pNode = pNode->parent; + Node *prev = nullptr; + while (node->parent != nullptr) { + prev = node; + node = node->parent; - this->FindSafePositionOnNode(pPrev); + this->FindSafePositionOnNode(prev); } - return dont_reserve || this->TryReservePath(nullptr, pNode->GetLastTile()); + return dont_reserve || this->TryReservePath(nullptr, node->GetLastTile()); } }; @@ -448,32 +448,32 @@ public: /* if path not found - return INVALID_TRACKDIR */ Trackdir next_trackdir = INVALID_TRACKDIR; - Node *pNode = Yapf().GetBestNode(); - if (pNode != nullptr) { + Node *node = Yapf().GetBestNode(); + if (node != nullptr) { /* reserve till end of path */ - this->SetReservationTarget(pNode, pNode->GetLastTile(), pNode->GetLastTrackdir()); + this->SetReservationTarget(node, node->GetLastTile(), node->GetLastTrackdir()); /* path was found or at least suggested * walk through the path back to the origin */ - Node *pPrev = nullptr; - while (pNode->parent != nullptr) { - pPrev = pNode; - pNode = pNode->parent; + Node *prev = nullptr; + while (node->parent != nullptr) { + prev = node; + node = node->parent; - this->FindSafePositionOnNode(pPrev); + this->FindSafePositionOnNode(prev); } /* If the best PF node has no parent, then there is no (valid) best next trackdir to return. * This occurs when the PF is called while the train is already at its destination. */ - if (pPrev == nullptr) return INVALID_TRACKDIR; + if (prev == nullptr) return INVALID_TRACKDIR; /* return trackdir from the best origin node (one of start nodes) */ - Node &best_next_node = *pPrev; + Node &best_next_node = *prev; next_trackdir = best_next_node.GetTrackdir(); if (reserve_track && path_found) { if (dest != nullptr) *dest = Yapf().GetBestNode()->GetLastTile(); - this->TryReservePath(target, pNode->GetLastTile()); + this->TryReservePath(target, node->GetLastTile()); } } @@ -513,13 +513,13 @@ public: /* path was found * walk through the path back to the origin */ - Node *pNode = Yapf().GetBestNode(); - while (pNode->parent != nullptr) { - pNode = pNode->parent; + Node *node = Yapf().GetBestNode(); + while (node->parent != nullptr) { + node = node->parent; } /* check if it was reversed origin */ - bool reversed = (pNode->cost != 0); + bool reversed = (node->cost != 0); return reversed; } }; diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp index b065274858..cacf74751d 100644 --- a/src/pathfinder/yapf/yapf_road.cpp +++ b/src/pathfinder/yapf/yapf_road.cpp @@ -391,22 +391,22 @@ public: /* if path not found - return INVALID_TRACKDIR */ Trackdir next_trackdir = INVALID_TRACKDIR; - Node *pNode = Yapf().GetBestNode(); - if (pNode != nullptr) { + Node *node = Yapf().GetBestNode(); + if (node != nullptr) { uint steps = 0; - for (Node *n = pNode; n->parent != nullptr; n = n->parent) steps++; + for (Node *n = node; n->parent != nullptr; n = n->parent) steps++; /* path was found or at least suggested * walk through the path back to its origin */ - while (pNode->parent != nullptr) { + while (node->parent != nullptr) { steps--; - if (pNode->GetIsChoice() && steps < YAPF_ROADVEH_PATH_CACHE_SEGMENTS) { - path_cache.emplace_back(pNode->GetTrackdir(), pNode->GetTile()); + if (node->GetIsChoice() && steps < YAPF_ROADVEH_PATH_CACHE_SEGMENTS) { + path_cache.emplace_back(node->GetTrackdir(), node->GetTile()); } - pNode = pNode->parent; + node = node->parent; } /* return trackdir from the best origin node (one of start nodes) */ - Node &best_next_node = *pNode; + Node &best_next_node = *node; assert(best_next_node.GetTile() == tile); next_trackdir = best_next_node.GetTrackdir(); @@ -449,11 +449,11 @@ public: /* find the best path */ if (!Yapf().FindPath(v)) return dist; - Node *pNode = Yapf().GetBestNode(); - if (pNode != nullptr) { + Node *node = Yapf().GetBestNode(); + if (node != nullptr) { /* path was found * get the path cost estimate */ - dist = pNode->GetCostEstimate(); + dist = node->GetCostEstimate(); } return dist; diff --git a/src/pathfinder/yapf/yapf_ship_regions.cpp b/src/pathfinder/yapf/yapf_ship_regions.cpp index 441cd1cda9..dad76757c1 100644 --- a/src/pathfinder/yapf/yapf_ship_regions.cpp +++ b/src/pathfinder/yapf/yapf_ship_regions.cpp @@ -164,13 +164,13 @@ protected: public: inline void PfFollowNode(Node &old_node) { - TVisitWaterRegionPatchCallBack visitFunc = [&](const WaterRegionPatchDesc &water_region_patch) + TVisitWaterRegionPatchCallBack visit_func = [&](const WaterRegionPatchDesc &water_region_patch) { Node &node = Yapf().CreateNewNode(); node.Set(&old_node, water_region_patch); Yapf().AddNewNode(node, TrackFollower{}); }; - VisitWaterRegionPatchNeighbours(old_node.key.water_region_patch, visitFunc); + VisitWaterRegionPatchNeighbours(old_node.key.water_region_patch, visit_func); } inline char TransportTypeChar() const { return '^'; } diff --git a/src/picker_gui.cpp b/src/picker_gui.cpp index 05107066fa..e2a116c6ff 100644 --- a/src/picker_gui.cpp +++ b/src/picker_gui.cpp @@ -175,11 +175,11 @@ void PickerWindow::ConstructWindow() this->CreateNestedTree(); /* Test if pickers should be active.*/ - bool isActive = this->callbacks.IsActive(); + bool is_active = this->callbacks.IsActive(); /* Functionality depends on widgets being present, not window class. */ - this->has_class_picker = isActive && this->GetWidget(WID_PW_CLASS_LIST) != nullptr && this->callbacks.HasClassChoice(); - this->has_type_picker = isActive && this->GetWidget(WID_PW_TYPE_MATRIX) != nullptr; + this->has_class_picker = is_active && this->GetWidget(WID_PW_CLASS_LIST) != nullptr && this->callbacks.HasClassChoice(); + this->has_type_picker = is_active && this->GetWidget(WID_PW_TYPE_MATRIX) != nullptr; if (this->has_class_picker) { this->GetWidget(WID_PW_CLASS_LIST)->SetToolTip(this->callbacks.GetClassTooltip()); diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index a61b41d476..23de2d9de1 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1769,8 +1769,8 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_81)) { for (auto t : Map::Iterate()) { if (GetTileType(t) == MP_TREES) { - TreeGround groundType = (TreeGround)GB(t.m2(), 4, 2); - if (groundType != TREE_GROUND_SNOW_DESERT) SB(t.m2(), 6, 2, 3); + TreeGround ground_type = (TreeGround)GB(t.m2(), 4, 2); + if (ground_type != TREE_GROUND_SNOW_DESERT) SB(t.m2(), 6, 2, 3); } } } @@ -3242,15 +3242,15 @@ bool AfterLoadGame() TileIndex cur_tile = rv->tile; if (!IsLevelCrossingTile(cur_tile)) continue; - ClosestDepot closestDepot = rv->FindClosestDepot(); + ClosestDepot closest_depot = rv->FindClosestDepot(); /* Try to find a depot with a distance limit of 512 tiles (Manhattan distance). */ - if (closestDepot.found && DistanceManhattan(rv->tile, closestDepot.location) < 512u) { + if (closest_depot.found && DistanceManhattan(rv->tile, closest_depot.location) < 512u) { /* Teleport all parts of articulated vehicles. */ for (RoadVehicle *u = rv; u != nullptr; u = u->Next()) { - u->tile = closestDepot.location; - int x = TileX(closestDepot.location) * TILE_SIZE + TILE_SIZE / 2; - int y = TileY(closestDepot.location) * TILE_SIZE + TILE_SIZE / 2; + u->tile = closest_depot.location; + int x = TileX(closest_depot.location) * TILE_SIZE + TILE_SIZE / 2; + int y = TileY(closest_depot.location) * TILE_SIZE + TILE_SIZE / 2; u->x_pos = x; u->y_pos = y; u->z_pos = GetSlopePixelZ(x, y, true); diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp index c600f94df7..ab38f5d977 100644 --- a/src/script/script_instance.cpp +++ b/src/script/script_instance.cpp @@ -128,16 +128,16 @@ bool ScriptInstance::LoadCompatibilityScript(std::string_view api_version, Subdi bool ScriptInstance::LoadCompatibilityScripts(Subdirectory dir, std::span api_versions) { /* Don't try to load compatibility scripts for the current version. */ - if (this->versionAPI == api_versions.back()) return true; + if (this->api_version == api_versions.back()) return true; - ScriptLog::Info(fmt::format("Downgrading API to be compatible with version {}", this->versionAPI)); + ScriptLog::Info(fmt::format("Downgrading API to be compatible with version {}", this->api_version)); /* Downgrade the API till we are the same version as the script. The last * entry in the list is always the current version, so skip that one. */ for (auto it = std::rbegin(api_versions) + 1; it != std::rend(api_versions); ++it) { if (!this->LoadCompatibilityScript(*it, dir)) return false; - if (*it == this->versionAPI) break; + if (*it == this->api_version) break; } return true; diff --git a/src/script/script_instance.hpp b/src/script/script_instance.hpp index 26ad6c7a7e..c871c432c1 100644 --- a/src/script/script_instance.hpp +++ b/src/script/script_instance.hpp @@ -253,7 +253,7 @@ public: protected: class Squirrel *engine = nullptr; ///< A wrapper around the squirrel vm. - std::string versionAPI{}; ///< Current API used by this script. + std::string api_version{}; ///< Current API used by this script. /** * Register all API functions to the VM. diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index f7b5bb8e41..7534f9616f 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -168,8 +168,8 @@ static void AddCustomRefreshRates() _refresh_rates.insert(_settings_client.gui.refresh_rate); /* Add all the refresh rates of all monitors connected to the machine. */ - std::vector monitorRates = VideoDriver::GetInstance()->GetListOfMonitorRefreshRates(); - std::copy(monitorRates.begin(), monitorRates.end(), std::inserter(_refresh_rates, _refresh_rates.end())); + std::vector monitor_rates = VideoDriver::GetInstance()->GetListOfMonitorRefreshRates(); + std::copy(monitor_rates.begin(), monitor_rates.end(), std::inserter(_refresh_rates, _refresh_rates.end())); } static const int SCALE_NMARKS = (MAX_INTERFACE_SCALE - MIN_INTERFACE_SCALE) / 25 + 1; // Show marks at 25% increments diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index c8bd310b5e..badc781ab0 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -168,7 +168,7 @@ static const Depot *FindClosestShipDepot(const Vehicle *v, uint max_distance) patches_to_search.pop_front(); /* Add neighbours of the current patch to the search queue. */ - TVisitWaterRegionPatchCallBack visitFunc = [&](const WaterRegionPatchDesc &water_region_patch) { + TVisitWaterRegionPatchCallBack visit_func = [&](const WaterRegionPatchDesc &water_region_patch) { /* Note that we check the max distance per axis, not the total distance. */ if (std::abs(water_region_patch.x - start_patch.x) > max_region_distance || std::abs(water_region_patch.y - start_patch.y) > max_region_distance) return; @@ -180,7 +180,7 @@ static const Depot *FindClosestShipDepot(const Vehicle *v, uint max_distance) } }; - VisitWaterRegionPatchNeighbours(current_node, visitFunc); + VisitWaterRegionPatchNeighbours(current_node, visit_func); } /* Step 2: Find the closest depot within the reachable Water Region Patches. */ diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index c3f7426c3f..ac46927b2d 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -501,7 +501,7 @@ struct TimetableWindow : Window { std::vector arr_dep(v->GetNumOrders()); const VehicleOrderID cur_order = v->cur_real_order_index % v->GetNumOrders(); - VehicleOrderID earlyID = BuildArrivalDepartureList(v, arr_dep) ? cur_order : (VehicleOrderID)INVALID_VEH_ORDER_ID; + VehicleOrderID early_id = BuildArrivalDepartureList(v, arr_dep) ? cur_order : (VehicleOrderID)INVALID_VEH_ORDER_ID; int selected = this->sel_index; Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); @@ -519,7 +519,7 @@ struct TimetableWindow : Window { if (arr_dep[i / 2].arrival != Ticks::INVALID_TICKS) { /* First set the offset and text colour based on the expected/scheduled mode and some other things. */ TimerGameTick::Ticks this_offset; - if (this->show_expected && i / 2 == earlyID) { + if (this->show_expected && i / 2 == early_id) { /* Show expected arrival. */ this_offset = 0; tc = TC_GREEN; diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 9687152692..50f868ba87 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2813,7 +2813,7 @@ static bool TryBuildTownHouse(Town *t, TileIndex tile) probs.emplace_back(hs.Index(), cur_prob); } - TileIndex baseTile = tile; + TileIndex base_tile = tile; while (probability_max > 0) { /* Building a multitile building can change the location of tile. @@ -2821,7 +2821,7 @@ static bool TryBuildTownHouse(Town *t, TileIndex tile) * its northern tile would be elsewhere. However, if the callback * fails we would be basing further work from the changed tile. * So a next 1x1 tile building could be built on the wrong tile. */ - tile = baseTile; + tile = base_tile; uint r = RandomRange(probability_max); uint i; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 9ab29f1f4d..04aaf7d225 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2615,9 +2615,9 @@ CommandCost Vehicle::SendToDepot(DoCommandFlags flags, DepotCommandFlags command return CommandCost(); } - ClosestDepot closestDepot = this->FindClosestDepot(); + ClosestDepot closest_depot = this->FindClosestDepot(); static const StringID no_depot[] = {STR_ERROR_UNABLE_TO_FIND_ROUTE_TO, STR_ERROR_UNABLE_TO_FIND_LOCAL_DEPOT, STR_ERROR_UNABLE_TO_FIND_LOCAL_DEPOT, STR_ERROR_CAN_T_SEND_AIRCRAFT_TO_HANGAR}; - if (!closestDepot.found) return CommandCost(no_depot[this->type]); + if (!closest_depot.found) return CommandCost(no_depot[this->type]); if (flags.Test(DoCommandFlag::Execute)) { if (this->current_order.IsType(OT_LOADING)) this->LeaveStation(); @@ -2627,19 +2627,19 @@ CommandCost Vehicle::SendToDepot(DoCommandFlags flags, DepotCommandFlags command SetBit(gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS); } - this->SetDestTile(closestDepot.location); - this->current_order.MakeGoToDepot(closestDepot.destination.ToDepotID(), ODTF_MANUAL); + this->SetDestTile(closest_depot.location); + this->current_order.MakeGoToDepot(closest_depot.destination.ToDepotID(), ODTF_MANUAL); if (!command.Test(DepotCommandFlag::Service)) this->current_order.SetDepotActionType(ODATFB_HALT); SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP); /* If there is no depot in front and the train is not already reversing, reverse automatically (trains only) */ - if (this->type == VEH_TRAIN && (closestDepot.reverse ^ HasBit(Train::From(this)->flags, VRF_REVERSING))) { + if (this->type == VEH_TRAIN && (closest_depot.reverse ^ HasBit(Train::From(this)->flags, VRF_REVERSING))) { Command::Do(DoCommandFlag::Execute, this->index, false); } if (this->type == VEH_AIRCRAFT) { Aircraft *a = Aircraft::From(this); - if (a->state == FLYING && a->targetairport != closestDepot.destination) { + if (a->state == FLYING && a->targetairport != closest_depot.destination) { /* The aircraft is now heading for a different hangar than the next in the orders */ AircraftNextAirportPos_and_Order(a); }