Minor fixes

This commit is contained in:
Michał Janiszewski authored and Michael Steenbeek committed 2018-05-11 15:38:30 +02:00
1 parent cb162edcfe
commit 0a92e74ced
30 files changed
+70 -101

No files matched your search

+1 -1
View File
@@ -437,7 +437,7 @@ namespace OpenRCT2
bool LoadParkFromStream(IStream * stream, const std::string &path, bool loadTitleScreenFirstOnFail) final override
{
ClassifiedFileInfo info;
ClassifiedFileInfo info{};
if (TryClassifyFile(stream, &info))
{
if (info.Type == FILE_TYPE::SAVED_GAME ||
+4 -12
View File
@@ -117,22 +117,14 @@ namespace ParkImporter
bool ExtensionIsRCT1(const std::string &extension)
{
if (String::Equals(extension, ".sc4", true) ||
String::Equals(extension, ".sv4", true))
{
return true;
}
return false;
return String::Equals(extension, ".sc4", true) ||
String::Equals(extension, ".sv4", true);
}
bool ExtensionIsScenario(const std::string &extension)
{
if (String::Equals(extension, ".sc4", true) ||
String::Equals(extension, ".sc6", true))
{
return true;
}
return false;
return String::Equals(extension, ".sc4", true) ||
String::Equals(extension, ".sc6", true);
}
}
+1 -2
View File
@@ -28,8 +28,7 @@
#include "GameAction.h"
GameActionResult::GameActionResult()
{
}
= default;
GameActionResult::GameActionResult(GA_ERROR error, rct_string_id message)
{
+1 -5
View File
@@ -463,11 +463,7 @@ namespace CommandLine
}
else if (shortOption[1] != '\0')
{
if (!ParseOptionValue(option, &shortOption[1]))
{
return false;
}
return true;
return ParseOptionValue(option, &shortOption[1]);
}
}
+1
View File
@@ -23,6 +23,7 @@
#include "../platform/platform.h"
#include "../localisation/Language.h"
#include "../core/Console.hpp"
#include "../core/Guard.hpp"
#include "../core/Memory.hpp"
#include "../core/Path.hpp"
#include "../core/String.hpp"
+1 -1
View File
@@ -47,7 +47,7 @@ static exitcode_t HandleUri(const std::string &uri)
{
exitcode_t result = EXITCODE_CONTINUE;
auto args = String::Split(uri, "/");
if (args.size() > 0)
if (!args.empty())
{
#ifndef DISABLE_NETWORK
std::string arg = args[0];
+1 -1
View File
@@ -135,7 +135,7 @@ namespace File
}
free(pathW);
#else
struct stat statInfo;
struct stat statInfo{};
if (stat(path.c_str(), &statInfo) == 0)
{
lastModified = statInfo.st_mtime;
+4 -4
View File
@@ -66,7 +66,7 @@ private:
{
std::string Path;
std::vector<DirectoryChild> Listing;
sint32 Index;
sint32 Index{};
};
// Options
@@ -75,7 +75,7 @@ private:
bool _recurse;
// State
bool _started;
bool _started{};
std::stack<DirectoryState> _directoryStack;
// Current
@@ -132,7 +132,7 @@ public:
PushState(_rootPath);
}
while (_directoryStack.size() != 0)
while (!_directoryStack.empty())
{
DirectoryState * state = &_directoryStack.top();
state->Index++;
@@ -337,7 +337,7 @@ private:
String::Set(path, pathSize, directory);
Path::Append(path, pathSize, node->d_name);
struct stat statInfo;
struct stat statInfo{};
sint32 statRes = stat(path, &statInfo);
if (statRes != -1)
{
+2
View File
@@ -15,6 +15,8 @@
#pragma endregion
#include <cassert>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include "../common.h"
+1 -1
View File
@@ -154,7 +154,7 @@ static void scrolling_text_format(utf8 *dst, size_t size, rct_draw_scroll_text *
extern bool TempForScrollText;
#define SCROLL_POS(x, y) ((y * 64) + x)
#define SCROLL_POS(x, y) (((y) * 64) + (x))
// clang-format off
static constexpr const sint16 _scrollpos0[] = {
+2 -2
View File
@@ -66,8 +66,8 @@ in the result FT_Bitmap after the FT_Render_Glyph() call. */
#define NUM_GRAYS 256
/* Handy routines for converting from fixed point */
#define FT_FLOOR(X) ((X & -64) / 64)
#define FT_CEIL(X) (((X + 63) & -64) / 64)
#define FT_FLOOR(X) (((X) & -64) / 64)
#define FT_CEIL(X) ((((X) + 63) & -64) / 64)
#define CACHED_METRICS 0x10
#define CACHED_BITMAP 0x01
+2 -2
View File
@@ -39,8 +39,8 @@ class StaticLayout
{
private:
utf8string _buffer;
TextPaint _paint;
sint32 _lineCount;
TextPaint _paint{};
sint32 _lineCount{};
sint32 _lineHeight;
sint32 _maxWidth;
+1 -3
View File
@@ -471,9 +471,7 @@ X8DrawingContext::X8DrawingContext(X8DrawingEngine * engine)
}
X8DrawingContext::~X8DrawingContext()
{
}
= default;
IDrawingEngine * X8DrawingContext::GetEngine()
{
+4 -4
View File
@@ -304,7 +304,7 @@ UIThemeWindowEntry UIThemeWindowEntry::FromJson(const WindowThemeDesc * wtDesc,
uint8 numColours = (uint8)json_array_size(jsonColours);
numColours = Math::Min(numColours, wtDesc->NumColours);
UIThemeWindowEntry result;
UIThemeWindowEntry result { };
result.WindowClass = wtDesc->WindowClass;
result.Theme = wtDesc->DefaultTheme;
@@ -524,7 +524,7 @@ namespace ThemeManager
NumPredefinedThemes = 0;
for (auto predefinedTheme : PredefinedThemes)
{
AvailableTheme theme;
AvailableTheme theme {};
theme.Name = predefinedTheme.Theme->Name;
outThemes->push_back(std::move(theme));
@@ -538,7 +538,7 @@ namespace ThemeManager
auto fileInfo = scanner->GetFileInfo();
auto name = Path::GetFileNameWithoutExtension(std::string(fileInfo->Name));
AvailableTheme theme;
AvailableTheme theme {};
theme.Name = name;
theme.Path = GetThemeFileName(theme.Name);
outThemes->push_back(std::move(theme));
@@ -747,7 +747,7 @@ uint8 theme_get_colour(rct_windowclass wc, uint8 index)
void theme_set_colour(rct_windowclass wc, uint8 index, colour_t colour)
{
UIThemeWindowEntry entry;
UIThemeWindowEntry entry { };
entry.WindowClass = wc;
auto currentEntry = (UIThemeWindowEntry *)ThemeManager::CurrentTheme->GetEntry(wc);
+1 -6
View File
@@ -123,12 +123,7 @@ static bool news_item_is_current_old()
remove_time = 256;
}
if (news_item_get(0)->Ticks >= remove_time)
{
return true;
}
return false;
return news_item_get(0)->Ticks >= remove_time;
}
/**
+2 -2
View File
@@ -668,7 +668,7 @@ bool Network::CheckSRAND(uint32 tick, uint32 srand0)
server_srand0_tick = 0;
// Check that the server and client sprite hashes match
const char *client_sprite_hash = sprite_checksum();
const bool sprites_mismatch = server_sprite_hash[0] != '\0' && strcmp(client_sprite_hash, server_sprite_hash);
const bool sprites_mismatch = server_sprite_hash[0] != '\0' && strcmp(client_sprite_hash, server_sprite_hash) != 0;
// Check PRNG values and sprite hashes, if exist
if ((srand0 != server_srand0) || sprites_mismatch) {
#ifdef DEBUG_DESYNC
@@ -1956,7 +1956,7 @@ void Network::Server_Handle_AUTH(NetworkConnection& connection, NetworkPacket& p
connection.AuthStatus = NETWORK_AUTH_BADNAME;
} else
if (!passwordless) {
if ((!password || strlen(password) == 0) && _password.size() > 0) {
if ((!password || strlen(password) == 0) && !_password.empty()) {
connection.AuthStatus = NETWORK_AUTH_REQUIREPASSWORD;
} else
if (password && _password != password) {
+1 -1
View File
@@ -58,7 +58,7 @@ public:
private:
std::list<std::unique_ptr<NetworkPacket>> _outboundPackets;
uint32 _lastPacketTime;
uint32 _lastPacketTime{};
utf8 * _lastDisconnectReason = nullptr;
bool SendPacket(NetworkPacket &packet);
+1 -2
View File
@@ -26,8 +26,7 @@ NetworkGroup::NetworkGroup()
}
NetworkGroup::~NetworkGroup()
{
}
= default;
NetworkGroup NetworkGroup::FromJson(const json_t * json)
{
+1 -1
View File
@@ -25,7 +25,7 @@
class NetworkGroup final
{
public:
std::array<uint8, 8> ActionsAllowed;
std::array<uint8, 8> ActionsAllowed{};
uint8 Id = 0;
static NetworkGroup FromJson(const json_t * json);
+4 -2
View File
@@ -19,14 +19,16 @@
#include "NetworkTypes.h"
#include "NetworkPacket.h"
#include <memory>
std::unique_ptr<NetworkPacket> NetworkPacket::Allocate()
{
return std::unique_ptr<NetworkPacket>(new NetworkPacket); // change to make_unique in c++14
return std::make_unique<NetworkPacket>(); // change to make_unique in c++14
}
std::unique_ptr<NetworkPacket> NetworkPacket::Duplicate(NetworkPacket &packet)
{
return std::unique_ptr<NetworkPacket>(new NetworkPacket(packet)); // change to make_unique in c++14
return std::make_unique<NetworkPacket>(packet); // change to make_unique in c++14
}
uint8 * NetworkPacket::GetData()
+8 -6
View File
@@ -24,6 +24,9 @@
#include <thread>
// clang-format off
// MSVC: include <math.h> here otherwise PI gets defined twice
#include <cmath>
#ifdef _WIN32
// winsock2 must be included before windows.h
#include <winsock2.h>
@@ -91,8 +94,7 @@ private:
public:
TcpSocket()
{
}
= default;
~TcpSocket() override
{
@@ -125,7 +127,7 @@ public:
throw std::runtime_error("Socket not closed.");
}
sockaddr_storage ss;
sockaddr_storage ss { };
sint32 ss_len;
if (!ResolveAddress(address, port, &ss, &ss_len))
{
@@ -185,7 +187,7 @@ public:
{
throw std::runtime_error("Socket not listening.");
}
struct sockaddr_storage client_addr;
struct sockaddr_storage client_addr { };
socklen_t client_len = sizeof(struct sockaddr_storage);
ITcpSocket * tcpSocket = nullptr;
@@ -238,7 +240,7 @@ public:
// Resolve address
_status = SOCKET_STATUS_RESOLVING;
sockaddr_storage ss;
sockaddr_storage ss { };
sint32 ss_len;
if (!ResolveAddress(address, port, &ss, &ss_len))
{
@@ -290,7 +292,7 @@ public:
#pragma warning(disable : 4548) // expression before comma has no effect; expected expression with side-effect
FD_SET(_socket, &writeFD);
#pragma warning(pop)
timeval timeout;
timeval timeout { };
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select((sint32)(_socket + 1), nullptr, &writeFD, nullptr, &timeout) > 0)
+1 -1
View File
@@ -242,7 +242,7 @@ private:
uint32 server_tick = 0;
uint32 server_srand0 = 0;
uint32 server_srand0_tick = 0;
char server_sprite_hash[EVP_MAX_MD_SIZE + 1];
char server_sprite_hash[EVP_MAX_MD_SIZE + 1]{};
uint8 player_id = 0;
std::list<std::unique_ptr<NetworkConnection>> client_connection_list;
std::multiset<GameCommand> game_command_queue;
+1 -1
View File
@@ -136,7 +136,7 @@ class Object
{
private:
char * _identifier;
rct_object_entry _objectEntry;
rct_object_entry _objectEntry{};
StringTable _stringTable;
ImageTable _imageTable;
+1 -1
View File
@@ -63,7 +63,7 @@ void StringTable::Read(IReadObjectContext * context, IStream * stream, uint8 id)
(rct2LanguageId <= RCT2_LANGUAGE_ID_PORTUGUESE) ?
RCT2ToOpenRCT2LanguageId[rct2LanguageId] :
LANGUAGE_UNDEFINED;
StringTableEntry entry;
StringTableEntry entry { };
entry.Id = id;
entry.LanguageId = languageId;
+1 -1
View File
@@ -2047,7 +2047,7 @@ void rct_peep::UpdateAnswering()
{
return;
}
if (current_ride != rideEntranceExitElement->properties.entrance.ride_index)
return;
+11 -11
View File
@@ -122,18 +122,18 @@ private:
EntryList _waterEntry;
// Lookup tables for converting from RCT1 hard coded types to the new dynamic object entries
uint8 _rideTypeToRideEntryMap[RCT1_RIDE_TYPE_COUNT];
uint8 _vehicleTypeToRideEntryMap[RCT1_VEHICLE_TYPE_COUNT];
uint8 _smallSceneryTypeToEntryMap[256];
uint8 _largeSceneryTypeToEntryMap[256];
uint8 _wallTypeToEntryMap[256];
uint8 _pathTypeToEntryMap[24];
uint8 _pathAdditionTypeToEntryMap[16];
uint8 _sceneryThemeTypeToEntryMap[24];
uint8 _rideTypeToRideEntryMap[RCT1_RIDE_TYPE_COUNT]{};
uint8 _vehicleTypeToRideEntryMap[RCT1_VEHICLE_TYPE_COUNT]{};
uint8 _smallSceneryTypeToEntryMap[256]{};
uint8 _largeSceneryTypeToEntryMap[256]{};
uint8 _wallTypeToEntryMap[256]{};
uint8 _pathTypeToEntryMap[24]{};
uint8 _pathAdditionTypeToEntryMap[16]{};
uint8 _sceneryThemeTypeToEntryMap[24]{};
// Research
uint8 _researchRideEntryUsed[MAX_RIDE_OBJECTS];
uint8 _researchRideTypeUsed[RCT1_RIDE_TYPE_COUNT];
uint8 _researchRideEntryUsed[MAX_RIDE_OBJECTS]{};
uint8 _researchRideTypeUsed[RCT1_RIDE_TYPE_COUNT]{};
// Scenario repository - used for determining scenario name
IScenarioRepository * _scenarioRepository = GetScenarioRepository();
@@ -206,7 +206,7 @@ public:
CreateAvailableObjectMappings();
auto missingObjects = GetInvalidObjects();
if (missingObjects.size() > 0)
if (!missingObjects.empty())
{
return ParkLoadResult::CreateMissingObjects(missingObjects);
}
+1 -1
View File
@@ -44,7 +44,7 @@ public:
void ExportRide(rct2_ride * dst, const Ride * src);
private:
rct_s6_data _s6;
rct_s6_data _s6{};
void Save(IStream * stream, bool isScenario);
static uint32 GetLoanHash(money32 initialCash, money32 bankLoan, uint32 maxBankLoan);
+2 -10
View File
@@ -2279,22 +2279,14 @@ bool track_element_is_covered(sint32 trackElementType)
bool track_element_is_booster(uint8 rideType, uint8 trackType)
{
// Boosters share their ID with the Spinning Control track.
if (rideType != RIDE_TYPE_STEEL_WILD_MOUSE && trackType == TRACK_ELEM_BOOSTER)
{
return true;
}
return false;
return rideType != RIDE_TYPE_STEEL_WILD_MOUSE && trackType == TRACK_ELEM_BOOSTER;
}
bool track_element_has_speed_setting(uint8 trackType)
{
// This does not check if the element is really a Spinning Control track instead of a booster,
// but this does not cause problems.
if (trackType == TRACK_ELEM_BRAKES || trackType == TRACK_ELEM_BOOSTER)
{
return true;
}
return false;
return trackType == TRACK_ELEM_BRAKES || trackType == TRACK_ELEM_BOOSTER;
}
uint8 track_element_get_seat_rotation(const rct_tile_element * tileElement)
+2 -2
View File
@@ -54,7 +54,7 @@ std::string GetNameFromTrackPath(const std::string &path)
{
std::string name = Path::GetFileNameWithoutExtension(path);
//The track name should be the file name until the first instance of a dot
name = name.substr(0, name.find_first_of("."));
name = name.substr(0, name.find_first_of('.'));
return name;
}
@@ -149,7 +149,7 @@ public:
Guard::ArgumentNotNull(env);
}
~TrackDesignRepository() = default;
~TrackDesignRepository() override = default;
size_t GetCount() const override
{
+6 -15
View File
@@ -90,7 +90,7 @@ static void vehicle_kill_all_passengers(rct_vehicle * vehicle);
static bool vehicle_can_depart_synchronised(rct_vehicle * vehicle);
#define NO_SCREAM 254
#define VEHICLE_INVALID_ID -1
#define VEHICLE_INVALID_ID (-1)
#define VEHICLE_MAX_SPIN_SPEED 1536
#define VEHICLE_MAX_SPIN_SPEED_FOR_STOPPING 700
@@ -1832,7 +1832,7 @@ static void vehicle_update_measurements(rct_vehicle * vehicle)
rct_tile_element * tile_element = map_get_surface_element_at({x, y});
// If vehicle above ground.
if (tile_element->base_height * 8 <= z)
if (tile_element->base_height * 8 <= z)
{
// Set tile_element to first element. Since elements aren't always ordered by base height,
// we must start at the first element and iterate through each tile element.
@@ -1866,7 +1866,7 @@ static void vehicle_update_measurements(rct_vehicle * vehicle)
cover_found = true;
break;
}
// Iterate through each tile_element.
// Iterate through each tile_element.
} while (!tile_element_is_last_for_tile(tile_element++));
if (cover_found == false)
@@ -3163,11 +3163,7 @@ static bool vehicle_next_tower_element_is_top(rct_vehicle * vehicle)
return true;
}
if (track_element_get_type(tileElement + 2) == TRACK_ELEM_TOWER_SECTION)
{
return false;
}
return true;
return track_element_get_type(tileElement + 2) != TRACK_ELEM_TOWER_SECTION;
}
/**
@@ -7511,12 +7507,7 @@ static bool loc_6DB38B(rct_vehicle * vehicle, rct_tile_element * tileElement)
sint32 trackType = track_element_get_type(tileElement);
sint32 vangleStart = TrackDefinitions[trackType].vangle_start;
if (vangleStart != _vehicleVAngleEndF64E36 || bankStart != _vehicleBankEndF64E37)
{
return false;
}
return true;
return !(vangleStart != _vehicleVAngleEndF64E36 || bankStart != _vehicleBankEndF64E37);
}
static void loc_6DB481(rct_vehicle * vehicle)
@@ -9521,7 +9512,7 @@ static void vehicle_update_track_motion_powered_ride_acceleration(rct_vehicle *
uint16 trackType = vehicle->track_direction >> 2;
if (trackType == TRACK_ELEM_LEFT_QUARTER_TURN_1_TILE)
{
{
speedModifier = (vehicle->var_CD == 5) ? HALF_SPEED : THREE_QUARTER_SPEED;
}
else if (trackType == TRACK_ELEM_RIGHT_QUARTER_TURN_1_TILE)