forked from rosebudai/OpenRCT2-Web
Apply some refactoring
This commit is contained in:
1 parent
386a399a51
commit
06afeeda9a
60 files changed
+221
-292
No files matched your search
@@ -30,7 +30,7 @@ using namespace OpenRCT2::Audio;
|
||||
using namespace OpenRCT2::Ui;
|
||||
|
||||
/**
|
||||
* Main entry point for non-Windows sytems. Windows instead uses its own DLL proxy.
|
||||
* Main entry point for non-Windows systems. Windows instead uses its own DLL proxy.
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
int NormalisedMain(int argc, const char * * argv)
|
||||
|
||||
@@ -655,7 +655,7 @@ void window_guest_set_page(rct_window* w, sint32 page){
|
||||
w->selected_list_item = -1;
|
||||
|
||||
rct_viewport* viewport = w->viewport;
|
||||
w->viewport = 0;
|
||||
w->viewport = nullptr;
|
||||
if (viewport){
|
||||
viewport->width = 0;
|
||||
}
|
||||
@@ -748,7 +748,7 @@ void window_guest_viewport_init(rct_window* w){
|
||||
|
||||
viewport_flags = w->viewport->flags;
|
||||
w->viewport->width = 0;
|
||||
w->viewport = 0;
|
||||
w->viewport = nullptr;
|
||||
|
||||
viewport_update_pointers();
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ static void window_install_track_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
rct_string_id friendlyTrackName;
|
||||
|
||||
void * objectEntry = object_manager_load_object(&td6->vehicle_object);
|
||||
if (objectEntry != NULL)
|
||||
if (objectEntry != nullptr)
|
||||
{
|
||||
sint32 groupIndex = object_manager_get_loaded_object_entry_index(objectEntry);
|
||||
rideName = get_ride_naming(td6->type, get_ride_entry(groupIndex));
|
||||
|
||||
@@ -217,7 +217,7 @@ rct_window *window_loadsave_open(sint32 type, const char *defaultName)
|
||||
}
|
||||
break;
|
||||
case LOADSAVETYPE_IMAGE:
|
||||
openrct2_assert(isSave == false, "Cannot save images through loadsave window");
|
||||
openrct2_assert(!isSave, "Cannot save images through loadsave window");
|
||||
w->widgets[WIDX_TITLE].text = STR_FILE_DIALOG_TITLE_LOAD_HEIGHTMAP;
|
||||
if (window_loadsave_get_dir(gConfigGeneral.last_save_track_directory, path, "", sizeof(path))) {
|
||||
window_loadsave_populate_list(w, false, path, ".bmp;.png");
|
||||
|
||||
@@ -1088,8 +1088,8 @@ static void window_mapgen_simplex_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
gfx_draw_string_left(dpi, STR_COMMA16, &_simplex_high, textColour, w->x + w->widgets[WIDX_SIMPLEX_HIGH].left + 1, w->y + w->widgets[WIDX_SIMPLEX_HIGH].top + 1);
|
||||
gfx_draw_string_left(dpi, STR_WINDOW_OBJECTIVE_VALUE_RATING, &_simplex_base_freq, textColour, w->x + w->widgets[WIDX_SIMPLEX_BASE_FREQ].left + 1, w->y + w->widgets[WIDX_SIMPLEX_BASE_FREQ].top + 1);
|
||||
gfx_draw_string_left(dpi, STR_COMMA16, &_simplex_octaves, textColour, w->x + w->widgets[WIDX_SIMPLEX_OCTAVES].left + 1, w->y + w->widgets[WIDX_SIMPLEX_OCTAVES].top + 1);
|
||||
gfx_draw_string_left(dpi, STR_TERRAIN_LABEL, NULL, textColour, w->x + 5, w->y + w->widgets[WIDX_SIMPLEX_RANDOM_TERRAIN_CHECKBOX].top + 1);
|
||||
gfx_draw_string_left(dpi, STR_MAPGEN_OPTION_PLACE_TREES, NULL, textColour, w->x + 5, w->y + w->widgets[WIDX_SIMPLEX_PLACE_TREES_CHECKBOX].top + 1);
|
||||
gfx_draw_string_left(dpi, STR_TERRAIN_LABEL, nullptr, textColour, w->x + 5, w->y + w->widgets[WIDX_SIMPLEX_RANDOM_TERRAIN_CHECKBOX].top + 1);
|
||||
gfx_draw_string_left(dpi, STR_MAPGEN_OPTION_PLACE_TREES, nullptr, textColour, w->x + 5, w->y + w->widgets[WIDX_SIMPLEX_PLACE_TREES_CHECKBOX].top + 1);
|
||||
|
||||
// The practical map size is 2 lower than the technical map size
|
||||
LocationXY16 mapSizeArgs = MakeXY16(_mapSize - 2, _mapSize - 2);
|
||||
|
||||
@@ -399,7 +399,7 @@ void window_staff_set_page(rct_window* w, sint32 page)
|
||||
w->frame_no = 0;
|
||||
|
||||
rct_viewport* viewport = w->viewport;
|
||||
w->viewport = 0;
|
||||
w->viewport = nullptr;
|
||||
if (viewport){
|
||||
viewport->width = 0;
|
||||
}
|
||||
@@ -1219,7 +1219,7 @@ void window_staff_viewport_init(rct_window* w){
|
||||
|
||||
viewport_flags = w->viewport->flags;
|
||||
w->viewport->width = 0;
|
||||
w->viewport = 0;
|
||||
w->viewport = nullptr;
|
||||
|
||||
viewport_update_pointers();
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ namespace OpenRCT2
|
||||
#endif
|
||||
}
|
||||
gScenarioTicks = 0;
|
||||
util_srand((uint32)time(0));
|
||||
util_srand((uint32)time(nullptr));
|
||||
input_reset_place_obj_modifier();
|
||||
viewport_init_all();
|
||||
game_init_all(150);
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace Editor
|
||||
*/
|
||||
static bool ReadS6(const char * path)
|
||||
{
|
||||
ParkLoadResult * loadResult = NULL;
|
||||
ParkLoadResult * loadResult = nullptr;
|
||||
const char * extension = path_get_extension(path);
|
||||
if (_stricmp(extension, ".sc6") == 0)
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
static ParkLoadResult CreateUnsupportedRCTCflag(uint8 classic_flag);
|
||||
|
||||
private:
|
||||
ParkLoadResult(PARK_LOAD_ERROR error);
|
||||
explicit ParkLoadResult(PARK_LOAD_ERROR error);
|
||||
ParkLoadResult(PARK_LOAD_ERROR error, const std::vector<rct_object_entry> &missingObjects);
|
||||
ParkLoadResult(PARK_LOAD_ERROR error, const uint8 flag);
|
||||
};
|
||||
|
||||
@@ -594,17 +594,17 @@ namespace Config
|
||||
|
||||
static const utf8 * searchLocations[] =
|
||||
{
|
||||
"C:\\GOG Games\\RollerCoaster Tycoon 2 Triple Thrill Pack",
|
||||
"C:\\Program Files\\Atari\\RollerCoaster Tycoon 2",
|
||||
"C:\\Program Files\\GalaxyClient\\Games\\RollerCoaster Tycoon 2 Triple Thrill Pack",
|
||||
"C:\\Program Files\\Infogrames\\RollerCoaster Tycoon 2",
|
||||
"C:\\Program Files\\Infogrames Interactive\\RollerCoaster Tycoon 2",
|
||||
"C:\\Program Files\\Steam\\steamapps\\common\\Rollercoaster Tycoon 2",
|
||||
"C:\\Program Files (x86)\\Atari\\RollerCoaster Tycoon 2",
|
||||
"C:\\Program Files (x86)\\GalaxyClient\\Games\\RollerCoaster Tycoon 2 Triple Thrill Pack",
|
||||
"C:\\Program Files (x86)\\Infogrames\\RollerCoaster Tycoon 2",
|
||||
"C:\\Program Files (x86)\\Infogrames Interactive\\RollerCoaster Tycoon 2",
|
||||
"C:\\Program Files (x86)\\Steam\\steamapps\\common\\Rollercoaster Tycoon 2"
|
||||
R"(C:\GOG Games\RollerCoaster Tycoon 2 Triple Thrill Pack)",
|
||||
R"(C:\Program Files\Atari\RollerCoaster Tycoon 2)",
|
||||
R"(C:\Program Files\GalaxyClient\Games\RollerCoaster Tycoon 2 Triple Thrill Pack)",
|
||||
R"(C:\Program Files\Infogrames\RollerCoaster Tycoon 2)",
|
||||
R"(C:\Program Files\Infogrames Interactive\RollerCoaster Tycoon 2)",
|
||||
R"(C:\Program Files\Steam\steamapps\common\Rollercoaster Tycoon 2)",
|
||||
R"(C:\Program Files (x86)\Atari\RollerCoaster Tycoon 2)",
|
||||
R"(C:\Program Files (x86)\GalaxyClient\Games\RollerCoaster Tycoon 2 Triple Thrill Pack)",
|
||||
R"(C:\Program Files (x86)\Infogrames\RollerCoaster Tycoon 2)",
|
||||
R"(C:\Program Files (x86)\Infogrames Interactive\RollerCoaster Tycoon 2)",
|
||||
R"(C:\Program Files (x86)\Steam\steamapps\common\Rollercoaster Tycoon 2)"
|
||||
};
|
||||
|
||||
for (const utf8 * location : searchLocations)
|
||||
@@ -715,11 +715,7 @@ extern "C"
|
||||
{
|
||||
utf8 path[MAX_PATH];
|
||||
config_get_default_path(path, sizeof(path));
|
||||
if (config_save(path))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return config_save(path);
|
||||
}
|
||||
|
||||
bool config_find_or_browse_install_directory()
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <initializer_list>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "../core/String.hpp"
|
||||
|
||||
@@ -26,8 +27,8 @@ struct ConfigEnumEntry
|
||||
std::string Key;
|
||||
T Value;
|
||||
|
||||
ConfigEnumEntry(const std::string &key, T value)
|
||||
: Key(key),
|
||||
ConfigEnumEntry(std::string key, T value)
|
||||
: Key(std::move(key)),
|
||||
Value(value)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -77,43 +77,21 @@ namespace Collections
|
||||
template<typename TCollection>
|
||||
static bool Contains(TCollection &collection, const char * item, bool ignoreCase = false)
|
||||
{
|
||||
if (ignoreCase)
|
||||
{
|
||||
return Contains(collection, item,
|
||||
[](const char * a, const char * b)
|
||||
{
|
||||
return String::Equals(a, b, true);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return Contains(collection, item,
|
||||
[](const char * a, const char * b)
|
||||
{
|
||||
return String::Equals(a, b, false);
|
||||
});
|
||||
}
|
||||
return Contains(collection, item,
|
||||
[ignoreCase](const char * a, const char * b)
|
||||
{
|
||||
return String::Equals(a, b, ignoreCase);
|
||||
});
|
||||
}
|
||||
|
||||
template<typename TCollection>
|
||||
static size_t IndexOf(TCollection &collection, const char * item, bool ignoreCase = false)
|
||||
{
|
||||
if (ignoreCase)
|
||||
{
|
||||
return IndexOf(collection, item,
|
||||
[](const char * a, const char * b)
|
||||
{
|
||||
return String::Equals(a, b, true);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return IndexOf(collection, item,
|
||||
[](const char * a, const char * b)
|
||||
{
|
||||
return String::Equals(a, b, false);
|
||||
});
|
||||
}
|
||||
return IndexOf(collection, item,
|
||||
[ignoreCase](const char * a, const char * b)
|
||||
{
|
||||
return String::Equals(a, b, ignoreCase);
|
||||
});
|
||||
}
|
||||
|
||||
template<typename TCollection>
|
||||
|
||||
@@ -149,7 +149,7 @@ protected:
|
||||
private:
|
||||
ScanResult Scan() const
|
||||
{
|
||||
DirectoryStats stats;
|
||||
DirectoryStats stats {};
|
||||
std::vector<std::string> files;
|
||||
for (const auto directory : SearchPaths)
|
||||
{
|
||||
|
||||
@@ -285,9 +285,8 @@ void draw_string_centred_raw(rct_drawpixelinfo *dpi, sint32 x, sint32 y, sint32
|
||||
|
||||
const utf8 *ch = text;
|
||||
const utf8 *nextCh = 0;
|
||||
sint32 codepoint = 0;
|
||||
|
||||
while ((codepoint = utf8_get_next(ch, (const utf8**)&nextCh)) != 0) {
|
||||
while ((utf8_get_next(ch, &nextCh)) != 0) {
|
||||
ch = nextCh;
|
||||
}
|
||||
text = (char*)(ch + 1);
|
||||
|
||||
@@ -868,7 +868,7 @@ static FT_Error Load_Glyph(TTF_Font* font, uint16 ch, c_glyph* cached, int want)
|
||||
|
||||
/* The pixmap is a little hard, we have to add and clamp */
|
||||
for (row = dst->rows - 1; row >= 0; --row) {
|
||||
pixmap = (uint8*)dst->buffer + row * dst->pitch;
|
||||
pixmap = dst->buffer + row * dst->pitch;
|
||||
for (offset = 1; offset <= font->glyph_overhang; ++offset) {
|
||||
for (col = dst->width - 1; col > 0; --col) {
|
||||
if (mono) {
|
||||
|
||||
@@ -435,12 +435,12 @@ void input_window_position_begin(rct_window *w, rct_widgetindex widgetIndex, sin
|
||||
_dragWidget.widget_index = widgetIndex;
|
||||
}
|
||||
|
||||
static void input_window_position_continue(rct_window *w, sint32 wdx, sint32 wdy, sint32 x, sint32 y)
|
||||
static void input_window_position_continue(rct_window *w, sint32 lastX, sint32 lastY, sint32 newX, sint32 newY)
|
||||
{
|
||||
sint32 snapProximity;
|
||||
|
||||
snapProximity = (w->flags & WF_NO_SNAPPING) ? 0 : gConfigGeneral.window_snap_proximity;
|
||||
window_move_and_snap(w, x - wdx, y - wdy, snapProximity);
|
||||
window_move_and_snap(w, newX - lastX, newY - lastY, snapProximity);
|
||||
}
|
||||
|
||||
static void input_window_position_end(rct_window *w, sint32 x, sint32 y)
|
||||
|
||||
@@ -235,8 +235,7 @@ void screenshot_giant()
|
||||
|
||||
// Get a free screenshot path
|
||||
char path[MAX_PATH];
|
||||
sint32 index;
|
||||
if ((index = screenshot_get_next_path(path, MAX_PATH)) == -1) {
|
||||
if (screenshot_get_next_path(path, MAX_PATH) == -1) {
|
||||
log_error("Giant screenshot failed, unable to find a suitable destination path.");
|
||||
context_show_error(STR_SCREENSHOT_FAILED, STR_NONE);
|
||||
return;
|
||||
|
||||
@@ -23,7 +23,7 @@ currency_descriptor CurrencyDescriptors[CURRENCY_END] = {
|
||||
{ "GBP", 10, CURRENCY_PREFIX, "\xC2\xA3", CURRENCY_SUFFIX, "GBP", STR_POUNDS }, // British Pound
|
||||
{ "USD", 10, CURRENCY_PREFIX, "$", CURRENCY_PREFIX, "$", STR_DOLLARS }, // US Dollar
|
||||
{ "FRF", 10, CURRENCY_SUFFIX, "F", CURRENCY_SUFFIX, "F", STR_FRANC }, // French Franc
|
||||
{ "DEM", 10, CURRENCY_PREFIX, "DM", CURRENCY_PREFIX, "DM", STR_DEUTSCHMARK }, // Deutschmark
|
||||
{ "DEM", 10, CURRENCY_PREFIX, "DM", CURRENCY_PREFIX, "DM", STR_DEUTSCHE_MARK }, // Deutsche Mark
|
||||
{ "JPY", 1000, CURRENCY_PREFIX, "\xC2\xA5", CURRENCY_SUFFIX, "YEN", STR_YEN }, // Japanese Yen
|
||||
{ "ESP", 10, CURRENCY_SUFFIX, "Pts", CURRENCY_SUFFIX, "Pts", STR_PESETA }, // Spanish Peseta
|
||||
{ "ITL", 1000, CURRENCY_PREFIX, "L", CURRENCY_PREFIX, "L", STR_LIRA }, // Italian Lira
|
||||
|
||||
@@ -1766,7 +1766,7 @@ enum {
|
||||
STR_POUNDS = 2334,
|
||||
STR_DOLLARS = 2335,
|
||||
STR_FRANC = 2336,
|
||||
STR_DEUTSCHMARK = 2337,
|
||||
STR_DEUTSCHE_MARK = 2337,
|
||||
STR_YEN = 2338,
|
||||
STR_PESETA = 2339,
|
||||
STR_LIRA = 2340,
|
||||
@@ -3564,7 +3564,7 @@ enum {
|
||||
STR_TILE_INSPECTOR_PATH_NAME = 5942,
|
||||
STR_TILE_INSPECTOR_PATH_ADDITIONS = 5943,
|
||||
STR_TILE_INSPECTOR_PATH_ADDITIONS_NONE = 5944,
|
||||
STR_TILE_INSPECTOR_PATH_CONECTED_EDGES = 5945,
|
||||
STR_TILE_INSPECTOR_PATH_CONNECTED_EDGES = 5945,
|
||||
STR_TILE_INSPECTOR_TRACK_RIDE_TYPE = 5946,
|
||||
STR_TILE_INSPECTOR_TRACK_RIDE_ID = 5947,
|
||||
STR_TILE_INSPECTOR_TRACK_RIDE_NAME = 5948,
|
||||
|
||||
@@ -107,11 +107,10 @@ sint32 utf8_get_codepoint_length(sint32 codepoint)
|
||||
*/
|
||||
sint32 utf8_length(const utf8 *text)
|
||||
{
|
||||
sint32 codepoint;
|
||||
const utf8 *ch = text;
|
||||
|
||||
sint32 count = 0;
|
||||
while ((codepoint = utf8_get_next(ch, &ch)) != 0) {
|
||||
while (utf8_get_next(ch, &ch) != 0) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
|
||||
@@ -47,7 +47,7 @@ struct HttpRequest2
|
||||
size_t Size = 0;
|
||||
union
|
||||
{
|
||||
char * Buffer = 0;
|
||||
char * Buffer = nullptr;
|
||||
json_t * Json;
|
||||
} Body;
|
||||
|
||||
@@ -151,7 +151,7 @@ static http_response_t *http_request(const HttpRequest2 &request)
|
||||
CURL *curl;
|
||||
CURLcode curlResult;
|
||||
http_response_t *response;
|
||||
read_buffer readBuffer = { 0 };
|
||||
read_buffer readBuffer = { nullptr };
|
||||
write_buffer writeBuffer;
|
||||
|
||||
curl = curl_easy_init();
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#define ACTION_COOLDOWN_TIME_PLACE_SCENERY 20
|
||||
#define ACTION_COOLDOWN_TIME_DEMOLISH_RIDE 1000
|
||||
|
||||
static rct_peep* _pickup_peep = 0;
|
||||
static rct_peep* _pickup_peep = nullptr;
|
||||
static sint32 _pickup_peep_old_x = LOCATION_NULL;
|
||||
|
||||
#ifndef DISABLE_NETWORK
|
||||
@@ -94,7 +94,7 @@ Network::Network()
|
||||
last_ping_sent_time = 0;
|
||||
_commandId = 0;
|
||||
_actionId = 0;
|
||||
client_command_handlers.resize(NETWORK_COMMAND_MAX, 0);
|
||||
client_command_handlers.resize(NETWORK_COMMAND_MAX, nullptr);
|
||||
client_command_handlers[NETWORK_COMMAND_AUTH] = &Network::Client_Handle_AUTH;
|
||||
client_command_handlers[NETWORK_COMMAND_MAP] = &Network::Client_Handle_MAP;
|
||||
client_command_handlers[NETWORK_COMMAND_CHAT] = &Network::Client_Handle_CHAT;
|
||||
@@ -111,7 +111,7 @@ Network::Network()
|
||||
client_command_handlers[NETWORK_COMMAND_GAMEINFO] = &Network::Client_Handle_GAMEINFO;
|
||||
client_command_handlers[NETWORK_COMMAND_TOKEN] = &Network::Client_Handle_TOKEN;
|
||||
client_command_handlers[NETWORK_COMMAND_OBJECTS] = &Network::Client_Handle_OBJECTS;
|
||||
server_command_handlers.resize(NETWORK_COMMAND_MAX, 0);
|
||||
server_command_handlers.resize(NETWORK_COMMAND_MAX, nullptr);
|
||||
server_command_handlers[NETWORK_COMMAND_AUTH] = &Network::Server_Handle_AUTH;
|
||||
server_command_handlers[NETWORK_COMMAND_CHAT] = &Network::Server_Handle_CHAT;
|
||||
server_command_handlers[NETWORK_COMMAND_GAMECMD] = &Network::Server_Handle_GAMECMD;
|
||||
@@ -593,17 +593,16 @@ const char* Network::FormatChat(NetworkPlayer* fromplayer, const char* text)
|
||||
|
||||
void Network::SendPacketToClients(NetworkPacket& packet, bool front, bool gameCmd)
|
||||
{
|
||||
for (auto it = client_connection_list.begin(); it != client_connection_list.end(); it++) {
|
||||
|
||||
for (auto &client_connection : client_connection_list) {
|
||||
if (gameCmd) {
|
||||
// If marked as game command we can not send the packet to connections that are not fully connected.
|
||||
// Sending the packet would cause the client to store a command that is behind the tick where he starts,
|
||||
// which would be essentially never executed. The clients do not require commands before the server has not sent the map data.
|
||||
if ((*it)->Player == nullptr) {
|
||||
if (client_connection->Player == nullptr) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
(*it)->QueuePacket(NetworkPacket::Duplicate(packet), front);
|
||||
client_connection->QueuePacket(NetworkPacket::Duplicate(packet), front);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -657,14 +656,14 @@ void Network::CheckDesynchronizaton()
|
||||
|
||||
void Network::KickPlayer(sint32 playerId)
|
||||
{
|
||||
for(auto it = client_connection_list.begin(); it != client_connection_list.end(); it++) {
|
||||
if ((*it)->Player->Id == playerId) {
|
||||
for (auto &client_connection : client_connection_list) {
|
||||
if (client_connection->Player->Id == playerId) {
|
||||
// Disconnect the client gracefully
|
||||
(*it)->SetLastDisconnectReason(STR_MULTIPLAYER_KICKED);
|
||||
client_connection->SetLastDisconnectReason(STR_MULTIPLAYER_KICKED);
|
||||
char str_disconnect_msg[256];
|
||||
format_string(str_disconnect_msg, 256, STR_MULTIPLAYER_KICKED_REASON, nullptr);
|
||||
Server_Send_SETDISCONNECTMSG(*(*it), str_disconnect_msg);
|
||||
(*it)->Socket->Disconnect();
|
||||
Server_Send_SETDISCONNECTMSG(*client_connection, str_disconnect_msg);
|
||||
client_connection->Socket->Disconnect();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -780,8 +779,8 @@ void Network::SaveGroups()
|
||||
|
||||
json_t * jsonGroupsCfg = json_object();
|
||||
json_t * jsonGroups = json_array();
|
||||
for (auto it = group_list.begin(); it != group_list.end(); it++) {
|
||||
json_array_append_new(jsonGroups, (*it)->ToJson());
|
||||
for (auto &group : group_list) {
|
||||
json_array_append_new(jsonGroups, group->ToJson());
|
||||
}
|
||||
json_object_set_new(jsonGroupsCfg, "default_group", json_integer(default_group));
|
||||
json_object_set_new(jsonGroupsCfg, "groups", jsonGroups);
|
||||
@@ -941,7 +940,7 @@ void Network::BeginServerLog()
|
||||
void Network::AppendServerLog(const std::string &s)
|
||||
{
|
||||
if (gConfigNetwork.log_server_actions) {
|
||||
AppendLog(_serverLogPath.c_str(), s);
|
||||
AppendLog(_serverLogPath, s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -986,10 +985,10 @@ void Network::Client_Send_OBJECTS(const std::vector<std::string> &objects)
|
||||
log_verbose("client requests %u objects", uint32(objects.size()));
|
||||
std::unique_ptr<NetworkPacket> packet(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_OBJECTS << (uint32)objects.size();
|
||||
for (uint32 i = 0; i < objects.size(); i++)
|
||||
for (const auto &object : objects)
|
||||
{
|
||||
log_verbose("client requests object %s", objects[i].c_str());
|
||||
packet->Write((const uint8 *)objects[i].c_str(), 8);
|
||||
log_verbose("client requests object %s", object.c_str());
|
||||
packet->Write((const uint8 *) object.c_str(), 8);
|
||||
}
|
||||
server_connection->QueuePacket(std::move(packet));
|
||||
}
|
||||
@@ -1007,11 +1006,10 @@ void Network::Server_Send_OBJECTS(NetworkConnection& connection, const std::vect
|
||||
log_verbose("Server sends objects list with %u items", objects.size());
|
||||
std::unique_ptr<NetworkPacket> packet(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_OBJECTS << (uint32)objects.size();
|
||||
for (size_t i = 0; i < objects.size(); i++)
|
||||
{
|
||||
log_verbose("Object %.8s (checksum %x)", objects[i]->ObjectEntry.name, objects[i]->ObjectEntry.checksum);
|
||||
packet->Write((const uint8 *)objects[i]->ObjectEntry.name, 8);
|
||||
*packet << objects[i]->ObjectEntry.checksum << objects[i]->ObjectEntry.flags;
|
||||
for (auto object : objects) {
|
||||
log_verbose("Object %.8s (checksum %x)", object->ObjectEntry.name, object->ObjectEntry.checksum);
|
||||
packet->Write((const uint8 *) object->ObjectEntry.name, 8);
|
||||
*packet << object->ObjectEntry.checksum << object->ObjectEntry.flags;
|
||||
}
|
||||
connection.QueuePacket(std::move(packet));
|
||||
}
|
||||
@@ -1215,8 +1213,8 @@ void Network::Server_Send_PLAYERLIST()
|
||||
{
|
||||
std::unique_ptr<NetworkPacket> packet(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_PLAYERLIST << (uint8)player_list.size();
|
||||
for (uint32 i = 0; i < player_list.size(); i++) {
|
||||
player_list[i]->Write(*packet);
|
||||
for (auto &player : player_list) {
|
||||
player->Write(*packet);
|
||||
}
|
||||
SendPacketToClients(*packet);
|
||||
}
|
||||
@@ -1233,8 +1231,8 @@ void Network::Server_Send_PING()
|
||||
last_ping_sent_time = platform_get_ticks();
|
||||
std::unique_ptr<NetworkPacket> packet(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_PING;
|
||||
for (auto it = client_connection_list.begin(); it != client_connection_list.end(); it++) {
|
||||
(*it)->PingTime = platform_get_ticks();
|
||||
for (auto &client_connection : client_connection_list) {
|
||||
client_connection->PingTime = platform_get_ticks();
|
||||
}
|
||||
SendPacketToClients(*packet, true);
|
||||
}
|
||||
@@ -1243,8 +1241,8 @@ void Network::Server_Send_PINGLIST()
|
||||
{
|
||||
std::unique_ptr<NetworkPacket> packet(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_PINGLIST << (uint8)player_list.size();
|
||||
for (size_t i = 0; i < player_list.size(); i++) {
|
||||
*packet << player_list[i]->Id << player_list[i]->Ping;
|
||||
for (auto &player : player_list) {
|
||||
*packet << player->Id << player->Ping;
|
||||
}
|
||||
SendPacketToClients(*packet);
|
||||
}
|
||||
@@ -1297,8 +1295,8 @@ void Network::Server_Send_GROUPLIST(NetworkConnection& connection)
|
||||
{
|
||||
std::unique_ptr<NetworkPacket> packet(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_GROUPLIST << (uint8)group_list.size() << default_group;
|
||||
for (uint32 i = 0; i < group_list.size(); i++) {
|
||||
group_list[i]->Write(*packet);
|
||||
for (auto &group : group_list) {
|
||||
group->Write(*packet);
|
||||
}
|
||||
connection.QueuePacket(std::move(packet));
|
||||
}
|
||||
@@ -1485,7 +1483,7 @@ void Network::EnqueueGameAction(const GameAction *action)
|
||||
|
||||
void Network::AddClient(ITcpSocket * socket)
|
||||
{
|
||||
auto connection = std::unique_ptr<NetworkConnection>(new NetworkConnection); // change to make_unique in c++14
|
||||
auto connection = std::make_unique<NetworkConnection>();
|
||||
connection->Socket = socket;
|
||||
char addr[128];
|
||||
snprintf(addr, sizeof(addr), "Client joined from %s", socket->GetHostName());
|
||||
@@ -1552,7 +1550,7 @@ NetworkPlayer* Network::AddPlayer(const utf8 *name, const std::string &keyhash)
|
||||
// Check if the key is registered
|
||||
const NetworkUser * networkUser = _userManager.GetUserByHash(keyhash);
|
||||
|
||||
player = std::unique_ptr<NetworkPlayer>(new NetworkPlayer); // change to make_unique in c++14
|
||||
player = std::make_unique<NetworkPlayer>();
|
||||
player->Id = newid;
|
||||
player->KeyHash = keyhash;
|
||||
if (networkUser == nullptr) {
|
||||
@@ -1565,7 +1563,7 @@ NetworkPlayer* Network::AddPlayer(const utf8 *name, const std::string &keyhash)
|
||||
player->SetName(networkUser->Name);
|
||||
}
|
||||
} else {
|
||||
player = std::unique_ptr<NetworkPlayer>(new NetworkPlayer); // change to make_unique in c++14
|
||||
player = std::make_unique<NetworkPlayer>();
|
||||
player->Id = newid;
|
||||
player->Group = GetDefaultGroup();
|
||||
player->SetName(String::Trim(std::string(name)));
|
||||
|
||||
@@ -26,9 +26,9 @@ sint32 NetworkActions::FindCommand(sint32 command)
|
||||
{
|
||||
auto it = std::find_if(Actions.begin(), Actions.end(), [&command](NetworkAction const &action)
|
||||
{
|
||||
for (auto it2 = action.Commands.begin(); it2 != action.Commands.end(); it2++)
|
||||
for (int currentCommand : action.Commands)
|
||||
{
|
||||
if ((*it2) == command)
|
||||
if (currentCommand == command)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -46,11 +46,7 @@ sint32 NetworkActions::FindCommandByPermissionName(const std::string &permission
|
||||
{
|
||||
auto it = std::find_if(Actions.begin(), Actions.end(), [&permission_name](NetworkAction const &action)
|
||||
{
|
||||
if (action.PermissionName == permission_name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return action.PermissionName == permission_name;
|
||||
});
|
||||
if (it != Actions.end())
|
||||
{
|
||||
|
||||
@@ -33,10 +33,7 @@ NetworkConnection::NetworkConnection()
|
||||
NetworkConnection::~NetworkConnection()
|
||||
{
|
||||
delete Socket;
|
||||
if (_lastDisconnectReason)
|
||||
{
|
||||
delete[] _lastDisconnectReason;
|
||||
}
|
||||
delete[] _lastDisconnectReason;
|
||||
}
|
||||
|
||||
sint32 NetworkConnection::ReadPacket()
|
||||
@@ -104,11 +101,7 @@ bool NetworkConnection::SendPacket(NetworkPacket& packet)
|
||||
{
|
||||
packet.BytesTransferred += sent;
|
||||
}
|
||||
if (packet.BytesTransferred == tosend.size())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return packet.BytesTransferred == tosend.size();
|
||||
}
|
||||
|
||||
void NetworkConnection::QueuePacket(std::unique_ptr<NetworkPacket> packet, bool front)
|
||||
@@ -119,7 +112,7 @@ void NetworkConnection::QueuePacket(std::unique_ptr<NetworkPacket> packet, bool
|
||||
if (front)
|
||||
{
|
||||
// If the first packet was already partially sent add new packet to second position
|
||||
if (_outboundPackets.size() > 0 && _outboundPackets.front()->BytesTransferred > 0)
|
||||
if (!_outboundPackets.empty() && _outboundPackets.front()->BytesTransferred > 0)
|
||||
{
|
||||
auto it = _outboundPackets.begin();
|
||||
it++; // Second position
|
||||
@@ -139,7 +132,7 @@ void NetworkConnection::QueuePacket(std::unique_ptr<NetworkPacket> packet, bool
|
||||
|
||||
void NetworkConnection::SendQueuedPackets()
|
||||
{
|
||||
while (_outboundPackets.size() > 0 && SendPacket(*(_outboundPackets.front()).get()))
|
||||
while (!_outboundPackets.empty() && SendPacket(*_outboundPackets.front()))
|
||||
{
|
||||
_outboundPackets.remove(_outboundPackets.front());
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ bool NetworkGroup::CanPerformAction(size_t index) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (ActionsAllowed[byte] & (1 << bit)) ? true : false;
|
||||
return (ActionsAllowed[byte] & (1 << bit)) != 0;
|
||||
}
|
||||
|
||||
bool NetworkGroup::CanPerformCommand(sint32 command) const
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Twitch
|
||||
|
||||
static AudienceMember FromJson(json_t * json)
|
||||
{
|
||||
AudienceMember member = { 0 };
|
||||
AudienceMember member = { nullptr };
|
||||
|
||||
if (!json_is_object(json)) return member;
|
||||
json_t * name = json_object_get(json, "name");
|
||||
@@ -461,7 +461,7 @@ namespace Twitch
|
||||
}
|
||||
|
||||
// Rename non-named peeps to followers that aren't currently in the park.
|
||||
if (members.size() > 0)
|
||||
if (!members.empty())
|
||||
{
|
||||
size_t memberIndex = SIZE_MAX;
|
||||
FOR_ALL_GUESTS(spriteIndex, peep)
|
||||
|
||||
@@ -140,7 +140,6 @@ public:
|
||||
|
||||
void Client_Send_TOKEN();
|
||||
void Client_Send_AUTH(const char* name, const char* password, const char *pubkey, const char *sig, size_t sigsize);
|
||||
void Client_Send_AUTH(const char* name, const char* password, const char *pubkey);
|
||||
void Server_Send_AUTH(NetworkConnection& connection);
|
||||
void Server_Send_TOKEN(NetworkConnection& connection);
|
||||
void Server_Send_MAP(NetworkConnection* connection = nullptr);
|
||||
@@ -186,7 +185,7 @@ private:
|
||||
void RemoveClient(std::unique_ptr<NetworkConnection>& connection);
|
||||
NetworkPlayer* AddPlayer(const utf8 *name, const std::string &keyhash);
|
||||
std::string MakePlayerNameUnique(const std::string &name);
|
||||
void PrintError();
|
||||
|
||||
const char* GetMasterServerUrl();
|
||||
std::string GenerateAdvertiseKey();
|
||||
void SetupDefaultGroups();
|
||||
|
||||
@@ -116,8 +116,7 @@ rct_large_scenery_tile * LargeSceneryObject::ReadTiles(IStream * stream)
|
||||
{
|
||||
auto tiles = std::vector<rct_large_scenery_tile>();
|
||||
|
||||
uint16 tilesEndMarker;
|
||||
while ((tilesEndMarker = stream->ReadValue<uint16>()) != 0xFFFF)
|
||||
while (stream->ReadValue<uint16>() != 0xFFFF)
|
||||
{
|
||||
stream->Seek(-2, STREAM_SEEK_CURRENT);
|
||||
auto tile = stream->ReadValue<rct_large_scenery_tile>();
|
||||
|
||||
@@ -40,7 +40,7 @@ struct rct_drawpixelinfo;
|
||||
|
||||
interface IReadObjectContext
|
||||
{
|
||||
virtual ~IReadObjectContext() { }
|
||||
virtual ~IReadObjectContext() = default;
|
||||
|
||||
virtual void LogWarning(uint32 code, const utf8 * text) abstract;
|
||||
virtual void LogError(uint32 code, const utf8 * text) abstract;
|
||||
|
||||
@@ -425,7 +425,7 @@ private:
|
||||
sceneryEntry->path_bit.scenery_tab_id = GetPrimarySceneryGroupEntryIndex(loadedObject);
|
||||
break;
|
||||
case OBJECT_TYPE_SCENERY_SETS:
|
||||
auto sgObject = static_cast<SceneryGroupObject *>(loadedObject);
|
||||
auto sgObject = dynamic_cast<SceneryGroupObject *>(loadedObject);
|
||||
sgObject->UpdateEntryIndexes();
|
||||
break;
|
||||
}
|
||||
@@ -440,7 +440,7 @@ private:
|
||||
|
||||
uint8 GetPrimarySceneryGroupEntryIndex(Object * loadedObject)
|
||||
{
|
||||
auto sceneryObject = static_cast<SceneryObject *>(loadedObject);
|
||||
auto sceneryObject = dynamic_cast<SceneryObject *>(loadedObject);
|
||||
const rct_object_entry * primarySGEntry = sceneryObject->GetPrimarySceneryGroup();
|
||||
Object * sgObject = GetLoadedObject(primarySGEntry);
|
||||
|
||||
|
||||
@@ -118,8 +118,7 @@ void SceneryGroupObject::ReadItems(IStream * stream)
|
||||
{
|
||||
auto items = std::vector<rct_object_entry>();
|
||||
|
||||
uint8 endMarker;
|
||||
while ((endMarker = stream->ReadValue<uint8>()) != 0xFF)
|
||||
while (stream->ReadValue<uint8>() != 0xFF)
|
||||
{
|
||||
stream->Seek(-1, STREAM_SEEK_CURRENT);
|
||||
rct_object_entry entry = stream->ReadValue<rct_object_entry>();
|
||||
|
||||
@@ -27,7 +27,7 @@ private:
|
||||
|
||||
public:
|
||||
explicit SceneryObject(const rct_object_entry &entry) : Object(entry) { }
|
||||
virtual ~SceneryObject() { }
|
||||
virtual ~SceneryObject() = default;
|
||||
|
||||
const rct_object_entry * GetPrimarySceneryGroup() { return &_primarySceneryGroupEntry; }
|
||||
|
||||
|
||||
@@ -74,19 +74,19 @@ static void paint_session_init(paint_session * session, rct_drawpixelinfo * dpi)
|
||||
session->Unk140E9A8 = dpi;
|
||||
session->EndOfPaintStructArray = &session->PaintStructs[4000 - 1];
|
||||
session->NextFreePaintStruct = session->PaintStructs;
|
||||
session->UnkF1AD28 = NULL;
|
||||
session->UnkF1AD2C = NULL;
|
||||
session->UnkF1AD28 = nullptr;
|
||||
session->UnkF1AD2C = nullptr;
|
||||
for (sint32 i = 0; i < MAX_PAINT_QUADRANTS; i++)
|
||||
{
|
||||
session->Quadrants[i] = NULL;
|
||||
session->Quadrants[i] = nullptr;
|
||||
}
|
||||
session->QuadrantBackIndex = -1;
|
||||
session->QuadrantFrontIndex = 0;
|
||||
session->PSStringHead = NULL;
|
||||
session->LastPSString = NULL;
|
||||
session->WoodenSupportsPrependTo = NULL;
|
||||
session->CurrentlyDrawnItem = NULL;
|
||||
session->SurfaceElement = NULL;
|
||||
session->PSStringHead = nullptr;
|
||||
session->LastPSString = nullptr;
|
||||
session->WoodenSupportsPrependTo = nullptr;
|
||||
session->CurrentlyDrawnItem = nullptr;
|
||||
session->SurfaceElement = nullptr;
|
||||
}
|
||||
|
||||
static void paint_session_add_ps_to_quadrant(paint_session * session, paint_struct * ps, sint32 positionHash)
|
||||
@@ -105,7 +105,7 @@ static void paint_session_add_ps_to_quadrant(paint_session * session, paint_stru
|
||||
*/
|
||||
static paint_struct * sub_9819_c(paint_session * session, uint32 image_id, LocationXYZ16 offset, LocationXYZ16 boundBoxSize, LocationXYZ16 boundBoxOffset, uint8 rotation)
|
||||
{
|
||||
if (session->NextFreePaintStruct >= session->EndOfPaintStructArray) return NULL;
|
||||
if (session->NextFreePaintStruct >= session->EndOfPaintStructArray) return nullptr;
|
||||
paint_struct * ps = &session->NextFreePaintStruct->basic;
|
||||
|
||||
ps->image_id = image_id;
|
||||
@@ -144,10 +144,10 @@ static paint_struct * sub_9819_c(paint_session * session, uint32 image_id, Locat
|
||||
|
||||
rct_drawpixelinfo * dpi = session->Unk140E9A8;
|
||||
|
||||
if (right <= dpi->x)return NULL;
|
||||
if (top <= dpi->y)return NULL;
|
||||
if (left >= dpi->x + dpi->width)return NULL;
|
||||
if (bottom >= dpi->y + dpi->height)return NULL;
|
||||
if (right <= dpi->x)return nullptr;
|
||||
if (top <= dpi->y)return nullptr;
|
||||
if (left >= dpi->x + dpi->width)return nullptr;
|
||||
if (bottom >= dpi->y + dpi->height)return nullptr;
|
||||
|
||||
|
||||
// This probably rotates the variables so they're relative to rotation 0.
|
||||
@@ -182,8 +182,8 @@ static paint_struct * sub_9819_c(paint_session * session, uint32 image_id, Locat
|
||||
ps->flags = 0;
|
||||
ps->bound_box_x = boundBoxOffset.x + session->SpritePosition.x;
|
||||
ps->bound_box_y = boundBoxOffset.y + session->SpritePosition.y;
|
||||
ps->attached_ps = NULL;
|
||||
ps->var_20 = NULL;
|
||||
ps->attached_ps = nullptr;
|
||||
ps->var_20 = nullptr;
|
||||
ps->sprite_type = session->InteractionType;
|
||||
ps->var_29 = 0;
|
||||
ps->map_x = session->MapPosition.x;
|
||||
@@ -342,7 +342,7 @@ paint_struct * paint_arrange_structs_helper(paint_struct * ps_next, uint16 quadr
|
||||
{
|
||||
ps = ps_next;
|
||||
ps_next = ps_next->next_quadrant_ps;
|
||||
if (ps_next == NULL) return ps;
|
||||
if (ps_next == nullptr) return ps;
|
||||
} while (quadrantIndex > ps_next->quadrant_index);
|
||||
|
||||
// Cache the last visited node so we don't have to walk the whole list again
|
||||
@@ -351,7 +351,7 @@ paint_struct * paint_arrange_structs_helper(paint_struct * ps_next, uint16 quadr
|
||||
ps_temp = ps;
|
||||
do {
|
||||
ps = ps->next_quadrant_ps;
|
||||
if (ps == NULL) break;
|
||||
if (ps == nullptr) break;
|
||||
|
||||
if (ps->quadrant_index > quadrantIndex + 1)
|
||||
{
|
||||
@@ -374,7 +374,7 @@ paint_struct * paint_arrange_structs_helper(paint_struct * ps_next, uint16 quadr
|
||||
while (true)
|
||||
{
|
||||
ps_next = ps->next_quadrant_ps;
|
||||
if (ps_next == NULL) return ps_cache;
|
||||
if (ps_next == nullptr) return ps_cache;
|
||||
if (ps_next->quadrant_flags & PAINT_QUADRANT_FLAG_BIGGER) return ps_cache;
|
||||
if (ps_next->quadrant_flags & PAINT_QUADRANT_FLAG_IDENTICAL) break;
|
||||
ps = ps_next;
|
||||
@@ -398,7 +398,7 @@ paint_struct * paint_arrange_structs_helper(paint_struct * ps_next, uint16 quadr
|
||||
{
|
||||
ps = ps_next;
|
||||
ps_next = ps_next->next_quadrant_ps;
|
||||
if (ps_next == NULL) break;
|
||||
if (ps_next == nullptr) break;
|
||||
if (ps_next->quadrant_flags & PAINT_QUADRANT_FLAG_BIGGER) break;
|
||||
if (!(ps_next->quadrant_flags & PAINT_QUADRANT_FLAG_NEXT)) continue;
|
||||
|
||||
@@ -436,21 +436,21 @@ paint_struct paint_session_arrange(paint_session * session)
|
||||
{
|
||||
paint_struct psHead = { 0 };
|
||||
paint_struct * ps = &psHead;
|
||||
ps->next_quadrant_ps = NULL;
|
||||
ps->next_quadrant_ps = nullptr;
|
||||
uint32 quadrantIndex = session->QuadrantBackIndex;
|
||||
if (quadrantIndex != UINT32_MAX)
|
||||
{
|
||||
do
|
||||
{
|
||||
paint_struct * ps_next = session->Quadrants[quadrantIndex];
|
||||
if (ps_next != NULL)
|
||||
if (ps_next != nullptr)
|
||||
{
|
||||
ps->next_quadrant_ps = ps_next;
|
||||
do
|
||||
{
|
||||
ps = ps_next;
|
||||
ps_next = ps_next->next_quadrant_ps;
|
||||
} while (ps_next != NULL);
|
||||
} while (ps_next != nullptr);
|
||||
}
|
||||
} while (++quadrantIndex <= session->QuadrantFrontIndex);
|
||||
|
||||
@@ -739,7 +739,7 @@ extern "C"
|
||||
* @param bound_box_length_z (ah)
|
||||
* @param z_offset (dx)
|
||||
* @param rotation (ebp)
|
||||
* @return (ebp) paint_struct on success (CF == 0), NULL on failure (CF == 1)
|
||||
* @return (ebp) paint_struct on success (CF == 0), nullptr on failure (CF == 1)
|
||||
*/
|
||||
paint_struct * sub_98196C(
|
||||
paint_session * session,
|
||||
@@ -752,12 +752,12 @@ extern "C"
|
||||
assert((uint16)bound_box_length_x == (sint16)bound_box_length_x);
|
||||
assert((uint16)bound_box_length_y == (sint16)bound_box_length_y);
|
||||
|
||||
session->UnkF1AD28 = 0;
|
||||
session->UnkF1AD2C = NULL;
|
||||
session->UnkF1AD28 = nullptr;
|
||||
session->UnkF1AD2C = nullptr;
|
||||
|
||||
if (session->NextFreePaintStruct >= session->EndOfPaintStructArray)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
paint_struct *ps = &session->NextFreePaintStruct->basic;
|
||||
@@ -833,16 +833,16 @@ extern "C"
|
||||
|
||||
rct_drawpixelinfo *dpi = session->Unk140E9A8;
|
||||
|
||||
if (right <= dpi->x) return NULL;
|
||||
if (top <= dpi->y) return NULL;
|
||||
if (left >= (dpi->x + dpi->width)) return NULL;
|
||||
if (bottom >= (dpi->y + dpi->height)) return NULL;
|
||||
if (right <= dpi->x) return nullptr;
|
||||
if (top <= dpi->y) return nullptr;
|
||||
if (left >= (dpi->x + dpi->width)) return nullptr;
|
||||
if (bottom >= (dpi->y + dpi->height)) return nullptr;
|
||||
|
||||
ps->flags = 0;
|
||||
ps->bound_box_x = coord_3d.x;
|
||||
ps->bound_box_y = coord_3d.y;
|
||||
ps->attached_ps = NULL;
|
||||
ps->var_20 = NULL;
|
||||
ps->attached_ps = nullptr;
|
||||
ps->var_20 = nullptr;
|
||||
ps->sprite_type = session->InteractionType;
|
||||
ps->var_29 = 0;
|
||||
ps->map_x = session->MapPosition.x;
|
||||
@@ -888,7 +888,7 @@ extern "C"
|
||||
* @param bound_box_offset_y (0x009DEA54)
|
||||
* @param bound_box_offset_z (0x009DEA56)
|
||||
* @param rotation (ebp)
|
||||
* @return (ebp) paint_struct on success (CF == 0), NULL on failure (CF == 1)
|
||||
* @return (ebp) paint_struct on success (CF == 0), nullptr on failure (CF == 1)
|
||||
*/
|
||||
paint_struct * sub_98197C(
|
||||
paint_session * session,
|
||||
@@ -899,16 +899,16 @@ extern "C"
|
||||
sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z,
|
||||
uint32 rotation)
|
||||
{
|
||||
session->UnkF1AD28 = 0;
|
||||
session->UnkF1AD2C = NULL;
|
||||
session->UnkF1AD28 = nullptr;
|
||||
session->UnkF1AD2C = nullptr;
|
||||
|
||||
LocationXYZ16 offset = { x_offset, y_offset, z_offset };
|
||||
LocationXYZ16 boundBoxSize = { bound_box_length_x, bound_box_length_y, bound_box_length_z };
|
||||
LocationXYZ16 boundBoxOffset = { bound_box_offset_x, bound_box_offset_y, bound_box_offset_z };
|
||||
paint_struct * ps = sub_9819_c(session, image_id, offset, boundBoxSize, boundBoxOffset, rotation);
|
||||
|
||||
if (ps == NULL) {
|
||||
return NULL;
|
||||
if (ps == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
session->UnkF1AD28 = ps;
|
||||
@@ -955,7 +955,7 @@ extern "C"
|
||||
* @param bound_box_offset_y (0x009DEA54)
|
||||
* @param bound_box_offset_z (0x009DEA56)
|
||||
* @param rotation (ebp)
|
||||
* @return (ebp) paint_struct on success (CF == 0), NULL on failure (CF == 1)
|
||||
* @return (ebp) paint_struct on success (CF == 0), nullptr on failure (CF == 1)
|
||||
*/
|
||||
paint_struct * sub_98198C(
|
||||
paint_session * session,
|
||||
@@ -969,16 +969,16 @@ extern "C"
|
||||
assert((uint16)bound_box_length_x == (sint16)bound_box_length_x);
|
||||
assert((uint16)bound_box_length_y == (sint16)bound_box_length_y);
|
||||
|
||||
session->UnkF1AD28 = 0;
|
||||
session->UnkF1AD2C = NULL;
|
||||
session->UnkF1AD28 = nullptr;
|
||||
session->UnkF1AD2C = nullptr;
|
||||
|
||||
LocationXYZ16 offset = { x_offset, y_offset, z_offset };
|
||||
LocationXYZ16 boundBoxSize = { bound_box_length_x, bound_box_length_y, bound_box_length_z };
|
||||
LocationXYZ16 boundBoxOffset = { bound_box_offset_x, bound_box_offset_y, bound_box_offset_z };
|
||||
paint_struct * ps = sub_9819_c(session, image_id, offset, boundBoxSize, boundBoxOffset, rotation);
|
||||
|
||||
if (ps == NULL) {
|
||||
return NULL;
|
||||
if (ps == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
session->UnkF1AD28 = ps;
|
||||
@@ -1001,7 +1001,7 @@ extern "C"
|
||||
* @param bound_box_offset_y (0x009DEA54)
|
||||
* @param bound_box_offset_z (0x009DEA56)
|
||||
* @param rotation (ebp)
|
||||
* @return (ebp) paint_struct on success (CF == 0), NULL on failure (CF == 1)
|
||||
* @return (ebp) paint_struct on success (CF == 0), nullptr on failure (CF == 1)
|
||||
*/
|
||||
paint_struct * sub_98199C(
|
||||
paint_session * session,
|
||||
@@ -1015,7 +1015,7 @@ extern "C"
|
||||
assert((uint16)bound_box_length_x == (sint16)bound_box_length_x);
|
||||
assert((uint16)bound_box_length_y == (sint16)bound_box_length_y);
|
||||
|
||||
if (session->UnkF1AD28 == NULL)
|
||||
if (session->UnkF1AD28 == nullptr)
|
||||
{
|
||||
return sub_98197C(session,
|
||||
image_id,
|
||||
@@ -1032,9 +1032,9 @@ extern "C"
|
||||
LocationXYZ16 boundBoxOffset = { bound_box_offset_x, bound_box_offset_y, bound_box_offset_z };
|
||||
paint_struct * ps = sub_9819_c(session, image_id, offset, boundBox, boundBoxOffset, rotation);
|
||||
|
||||
if (ps == NULL)
|
||||
if (ps == nullptr)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
paint_struct *old_ps = session->UnkF1AD28;
|
||||
@@ -1055,7 +1055,7 @@ extern "C"
|
||||
*/
|
||||
bool paint_attach_to_previous_attach(paint_session * session, uint32 image_id, uint16 x, uint16 y)
|
||||
{
|
||||
if (session->UnkF1AD2C == NULL)
|
||||
if (session->UnkF1AD2C == nullptr)
|
||||
{
|
||||
return paint_attach_to_previous_ps(session, image_id, x, y);
|
||||
}
|
||||
@@ -1072,7 +1072,7 @@ extern "C"
|
||||
|
||||
attached_paint_struct * ebx = session->UnkF1AD2C;
|
||||
|
||||
ps->next = NULL;
|
||||
ps->next = nullptr;
|
||||
ebx->next = ps;
|
||||
|
||||
session->UnkF1AD2C = ps;
|
||||
@@ -1104,7 +1104,7 @@ extern "C"
|
||||
ps->flags = 0;
|
||||
|
||||
paint_struct * masterPs = session->UnkF1AD28;
|
||||
if (masterPs == NULL)
|
||||
if (masterPs == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1160,7 +1160,7 @@ extern "C"
|
||||
|
||||
session->NextFreePaintStruct++;
|
||||
|
||||
if (session->LastPSString == NULL)
|
||||
if (session->LastPSString == nullptr)
|
||||
{
|
||||
session->PSStringHead = ps;
|
||||
}
|
||||
@@ -1195,7 +1195,7 @@ extern "C"
|
||||
}
|
||||
|
||||
gfx_draw_string_with_y_offsets(&dpi2, buffer, COLOUR_BLACK, ps->x, ps->y, (sint8 *)ps->y_offsets, forceSpriteFont);
|
||||
} while ((ps = ps->next) != NULL);
|
||||
} while ((ps = ps->next) != nullptr);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace OpenRCT2
|
||||
sint32 _frames = 0;
|
||||
|
||||
public:
|
||||
Painter(Ui::IUiContext * uiContext);
|
||||
explicit Painter(Ui::IUiContext * uiContext);
|
||||
void Paint(Drawing::IDrawingEngine * de);
|
||||
|
||||
private:
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct paint_session paint_session;
|
||||
|
||||
@@ -34,6 +34,6 @@ extern "C" {
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1642,7 +1642,7 @@ static void peep_check_cant_find_ride(rct_peep * peep)
|
||||
*
|
||||
* rct2: 0x69C2D0
|
||||
* Check if cant find exit.
|
||||
*/
|
||||
*/
|
||||
static void peep_check_cant_find_exit(rct_peep * peep)
|
||||
{
|
||||
if (!(peep->peep_flags & PEEP_FLAGS_LEAVING_PARK))
|
||||
@@ -2790,10 +2790,10 @@ static void peep_update_ride_sub_state_0(rct_peep * peep)
|
||||
money16 ridePrice = ride_get_price(ride);
|
||||
if (ridePrice != 0)
|
||||
{
|
||||
if (!(peep->item_standard_flags & PEEP_ITEM_VOUCHER) || !(peep->voucher_type == VOUCHER_TYPE_RIDE_FREE) ||
|
||||
!(peep->voucher_arguments == peep->current_ride))
|
||||
if (!(peep->item_standard_flags & PEEP_ITEM_VOUCHER) ||
|
||||
peep->voucher_type != VOUCHER_TYPE_RIDE_FREE ||
|
||||
peep->voucher_arguments != peep->current_ride)
|
||||
{
|
||||
|
||||
if (peep->cash_in_pocket <= 0)
|
||||
{
|
||||
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_SPENT_MONEY, 0xFF);
|
||||
@@ -3087,7 +3087,6 @@ static void peep_update_ride_sub_state_1(rct_peep * peep)
|
||||
}
|
||||
|
||||
peep->sub_state = 4;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3136,8 +3135,7 @@ static void peep_go_to_ride_exit(rct_peep * peep, Ride * ride, sint16 x, sint16
|
||||
peep->destination_tolerence = 2;
|
||||
|
||||
peep->sprite_direction = exit_direction * 8;
|
||||
peep->sub_state = 8;
|
||||
return;
|
||||
peep->sub_state = 8;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6181,8 +6179,6 @@ static void peep_update_walking_break_scenery(rct_peep * peep)
|
||||
map_invalidate_tile_zoom1(peep->next_x, peep->next_y, (tile_element->base_height << 3) + 32, tile_element->base_height << 3);
|
||||
|
||||
peep->angriness = 16;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -10540,8 +10536,6 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep
|
||||
}
|
||||
#endif // defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -708,16 +708,16 @@ enum
|
||||
* applied in tautology if statements.
|
||||
*/
|
||||
#define FOR_ALL_PEEPS(sprite_index, peep) \
|
||||
for (sprite_index = gSpriteListHead[SPRITE_LIST_PEEP]; sprite_index != SPRITE_INDEX_NULL; sprite_index = peep->next) \
|
||||
if ((peep = GET_PEEP(sprite_index)) != NULL || 1)
|
||||
for ((sprite_index) = gSpriteListHead[SPRITE_LIST_PEEP]; (sprite_index) != SPRITE_INDEX_NULL; (sprite_index) = peep->next) \
|
||||
if (((peep) = GET_PEEP(sprite_index)) != NULL || 1)
|
||||
|
||||
#define FOR_ALL_GUESTS(sprite_index, peep) \
|
||||
FOR_ALL_PEEPS(sprite_index, peep) \
|
||||
if (peep->type == PEEP_TYPE_GUEST)
|
||||
if ((peep)->type == PEEP_TYPE_GUEST)
|
||||
|
||||
#define FOR_ALL_STAFF(sprite_index, peep) \
|
||||
FOR_ALL_PEEPS(sprite_index, peep) \
|
||||
if (peep->type == PEEP_TYPE_STAFF)
|
||||
if ((peep)->type == PEEP_TYPE_STAFF)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
IStream * const _stream = nullptr;
|
||||
|
||||
public:
|
||||
SawyerChunkReader(IStream * stream);
|
||||
explicit SawyerChunkReader(IStream * stream);
|
||||
|
||||
/**
|
||||
* Skips the next chunk in the stream without decoding or reading its data
|
||||
|
||||
@@ -34,7 +34,7 @@ private:
|
||||
IStream * const _stream = nullptr;
|
||||
|
||||
public:
|
||||
SawyerChunkWriter(IStream * stream);
|
||||
explicit SawyerChunkWriter(IStream * stream);
|
||||
|
||||
/**
|
||||
* Writes a chunk to the stream.
|
||||
|
||||
@@ -177,7 +177,7 @@ public:
|
||||
|
||||
auto missingObjects = _objectManager->GetInvalidObjects(_s6.objects);
|
||||
|
||||
if (missingObjects.size() > 0)
|
||||
if (!missingObjects.empty())
|
||||
{
|
||||
return ParkLoadResult::CreateMissingObjects(missingObjects);
|
||||
}
|
||||
|
||||
@@ -1944,8 +1944,7 @@ void game_command_remove_track(sint32 * eax,
|
||||
*edi & 0xFFFF,
|
||||
(*ebx >> 8) & 0xFF,
|
||||
*ebx & 0xFF
|
||||
);
|
||||
return;
|
||||
);
|
||||
}
|
||||
|
||||
static uint8 maze_element_get_segment_bit(uint16 x, uint16 y)
|
||||
|
||||
@@ -94,7 +94,7 @@ rct_track_td6 * track_design_open(const utf8 * path)
|
||||
{
|
||||
log_error("Track checksum failed. %s", path);
|
||||
free(buffer);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Decode the track data
|
||||
@@ -102,7 +102,7 @@ rct_track_td6 * track_design_open(const utf8 * path)
|
||||
size_t decodedLength = sawyercoding_decode_td6(buffer, decoded, bufferLength);
|
||||
free(buffer);
|
||||
decoded = (uint8 *) realloc(decoded, decodedLength);
|
||||
if (decoded == NULL)
|
||||
if (decoded == nullptr)
|
||||
{
|
||||
log_error("failed to realloc");
|
||||
}
|
||||
@@ -111,24 +111,24 @@ rct_track_td6 * track_design_open(const utf8 * path)
|
||||
rct_track_td6 * td6 = track_design_open_from_buffer(decoded, decodedLength);
|
||||
free(decoded);
|
||||
|
||||
if (td6 != NULL)
|
||||
if (td6 != nullptr)
|
||||
{
|
||||
td6->name = track_repository_get_name_from_path(path);
|
||||
return td6;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static rct_track_td6 * track_design_open_from_td4(uint8 * src, size_t srcLength)
|
||||
{
|
||||
rct_track_td4 * td4 = (rct_track_td4 *) calloc(1, sizeof(rct_track_td4));
|
||||
if (td4 == NULL)
|
||||
if (td4 == nullptr)
|
||||
{
|
||||
log_error("Unable to allocate memory for TD4 data.");
|
||||
SafeFree(td4);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint8 version = (src[7] >> 2) & 3;
|
||||
@@ -137,11 +137,11 @@ static rct_track_td6 * track_design_open_from_td4(uint8 * src, size_t srcLength)
|
||||
memcpy(td4, src, 0x38);
|
||||
td4->elementsSize = srcLength - 0x38;
|
||||
td4->elements = malloc(td4->elementsSize);
|
||||
if (td4->elements == NULL)
|
||||
if (td4->elements == nullptr)
|
||||
{
|
||||
log_error("Unable to allocate memory for TD4 element data.");
|
||||
SafeFree(td4);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
memcpy(td4->elements, src + 0x38, td4->elementsSize);
|
||||
}
|
||||
@@ -150,11 +150,11 @@ static rct_track_td6 * track_design_open_from_td4(uint8 * src, size_t srcLength)
|
||||
memcpy(td4, src, 0xC4);
|
||||
td4->elementsSize = srcLength - 0xC4;
|
||||
td4->elements = malloc(td4->elementsSize);
|
||||
if (td4->elements == NULL)
|
||||
if (td4->elements == nullptr)
|
||||
{
|
||||
log_error("Unable to allocate memory for TD4 element data.");
|
||||
SafeFree(td4);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
memcpy(td4->elements, src + 0xC4, td4->elementsSize);
|
||||
}
|
||||
@@ -162,15 +162,15 @@ static rct_track_td6 * track_design_open_from_td4(uint8 * src, size_t srcLength)
|
||||
{
|
||||
log_error("Unsupported track design.");
|
||||
SafeFree(td4);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rct_track_td6 * td6 = (rct_track_td6 *) calloc(1, sizeof(rct_track_td6));
|
||||
if (td6 == NULL)
|
||||
if (td6 == nullptr)
|
||||
{
|
||||
log_error("Unable to allocate memory for TD6 data.");
|
||||
SafeFree(td4);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
td6->type = RCT1::GetRideType(td4->type);
|
||||
@@ -188,13 +188,13 @@ static rct_track_td6 * track_design_open_from_td4(uint8 * src, size_t srcLength)
|
||||
if (td4->type == RIDE_TYPE_MAZE)
|
||||
{
|
||||
const char * name = RCT1::GetRideTypeObject(td4->type);
|
||||
assert(name != NULL);
|
||||
assert(name != nullptr);
|
||||
memcpy(vehicleObject.name, name, Math::Min(String::SizeOf(name), (size_t)8));
|
||||
}
|
||||
else
|
||||
{
|
||||
const char * name = RCT1::GetVehicleObject(td4->vehicle_type);
|
||||
assert(name != NULL);
|
||||
assert(name != nullptr);
|
||||
memcpy(vehicleObject.name, name, Math::Min(String::SizeOf(name), (size_t)8));
|
||||
}
|
||||
memcpy(&td6->vehicle_object, &vehicleObject, sizeof(rct_object_entry));
|
||||
@@ -336,23 +336,23 @@ static rct_track_td6 * track_design_open_from_buffer(uint8 * src, size_t srcLeng
|
||||
else if (version != 2)
|
||||
{
|
||||
log_error("Unsupported track design.");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rct_track_td6 * td6 = (rct_track_td6 *) calloc(1, sizeof(rct_track_td6));
|
||||
if (td6 == NULL)
|
||||
if (td6 == nullptr)
|
||||
{
|
||||
log_error("Unable to allocate memory for TD6 data.");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
memcpy(td6, src, 0xA3);
|
||||
td6->elementsSize = srcLength - 0xA3;
|
||||
td6->elements = malloc(td6->elementsSize);
|
||||
if (td6->elements == NULL)
|
||||
if (td6->elements == nullptr)
|
||||
{
|
||||
free(td6);
|
||||
log_error("Unable to allocate memory for TD6 element data.");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
memcpy(td6->elements, src + 0xA3, td6->elementsSize);
|
||||
|
||||
@@ -393,7 +393,7 @@ static void td6_set_element_helper_pointers(rct_track_td6 * td6)
|
||||
uintptr_t sceneryElementsStart;
|
||||
if (td6->type == RIDE_TYPE_MAZE)
|
||||
{
|
||||
td6->track_elements = NULL;
|
||||
td6->track_elements = nullptr;
|
||||
td6->maze_elements = (rct_td6_maze_element *) td6->elements;
|
||||
|
||||
rct_td6_maze_element * maze = td6->maze_elements;
|
||||
@@ -404,7 +404,7 @@ static void td6_set_element_helper_pointers(rct_track_td6 * td6)
|
||||
}
|
||||
else
|
||||
{
|
||||
td6->maze_elements = NULL;
|
||||
td6->maze_elements = nullptr;
|
||||
td6->track_elements = (rct_td6_track_element *) td6->elements;
|
||||
|
||||
rct_td6_track_element * track = td6->track_elements;
|
||||
@@ -427,7 +427,7 @@ static void td6_set_element_helper_pointers(rct_track_td6 * td6)
|
||||
|
||||
void track_design_dispose(rct_track_td6 * td6)
|
||||
{
|
||||
if (td6 != NULL)
|
||||
if (td6 != nullptr)
|
||||
{
|
||||
free(td6->elements);
|
||||
free(td6->name);
|
||||
@@ -1104,7 +1104,7 @@ track_design_place_scenery(rct_td6_scenery_element * scenery_start, uint8 rideIn
|
||||
|
||||
rct_tile_element * tile_element = map_get_path_element_at(mapCoord.x / 32, mapCoord.y / 32, z);
|
||||
|
||||
if (tile_element == NULL)
|
||||
if (tile_element == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1479,7 +1479,7 @@ static bool track_design_place_ride(rct_track_td6 * td6, sint16 x, sint16 y, sin
|
||||
}
|
||||
|
||||
rct_tile_element * tileElement = map_get_surface_element_at(tile.x >> 5, tile.y >> 5);
|
||||
if (tileElement == NULL)
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1691,7 +1691,7 @@ sint32 place_virtual_track(rct_track_td6 * td6, uint8 ptdOperation, bool placeSc
|
||||
|
||||
// Scenery elements
|
||||
rct_td6_scenery_element * scenery = td6->scenery_elements;
|
||||
if (track_place_success && scenery != NULL)
|
||||
if (track_place_success && scenery != nullptr)
|
||||
{
|
||||
if (!track_design_place_scenery(
|
||||
scenery,
|
||||
@@ -1837,7 +1837,7 @@ static money32 place_track_design(sint16 x, sint16 y, sint16 z, uint8 flags, uin
|
||||
}
|
||||
|
||||
rct_track_td6 * td6 = gActiveTrackDesign;
|
||||
if (td6 == NULL)
|
||||
if (td6 == nullptr)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
@@ -1858,7 +1858,7 @@ static money32 place_track_design(sint16 x, sint16 y, sint16 z, uint8 flags, uin
|
||||
if (RideGroupManager::RideTypeHasRideGroups(td6->type) && entryIndex == 0xFF)
|
||||
{
|
||||
const ObjectRepositoryItem * ori = object_repository_find_object_by_name(rideEntryObject->name);
|
||||
if (ori != NULL)
|
||||
if (ori != nullptr)
|
||||
{
|
||||
uint8 rideGroupIndex = ori->RideGroupIndex;
|
||||
const RideGroup * td6RideGroup = RideGroupManager::RideGroupFind(td6->type, rideGroupIndex);
|
||||
@@ -2178,7 +2178,7 @@ void track_design_draw_preview(rct_track_td6 * td6, uint8 * pixels)
|
||||
{
|
||||
// Make a copy of the map
|
||||
map_backup * mapBackup = track_design_preview_backup_map();
|
||||
if (mapBackup == NULL)
|
||||
if (mapBackup == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2282,7 +2282,7 @@ void track_design_draw_preview(rct_track_td6 * td6, uint8 * pixels)
|
||||
static map_backup * track_design_preview_backup_map()
|
||||
{
|
||||
map_backup * backup = (map_backup *) malloc(sizeof(map_backup));
|
||||
if (backup != NULL)
|
||||
if (backup != nullptr)
|
||||
{
|
||||
memcpy(
|
||||
backup->tile_elements,
|
||||
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
static constexpr auto PATTERN = "*.td4;*.td6";
|
||||
|
||||
public:
|
||||
TrackDesignFileIndex(IPlatformEnvironment * env) :
|
||||
explicit TrackDesignFileIndex(IPlatformEnvironment * env) :
|
||||
FileIndex("track design index",
|
||||
MAGIC_NUMBER,
|
||||
VERSION,
|
||||
@@ -141,16 +141,14 @@ private:
|
||||
std::vector<TrackRepositoryItem> _items;
|
||||
|
||||
public:
|
||||
TrackDesignRepository(IPlatformEnvironment * env)
|
||||
explicit TrackDesignRepository(IPlatformEnvironment * env)
|
||||
: _env(env),
|
||||
_fileIndex(env)
|
||||
{
|
||||
Guard::ArgumentNotNull(env);
|
||||
}
|
||||
|
||||
virtual ~TrackDesignRepository() final
|
||||
{
|
||||
}
|
||||
~TrackDesignRepository() = default;
|
||||
|
||||
size_t GetCount() const override
|
||||
{
|
||||
@@ -291,7 +289,7 @@ public:
|
||||
{
|
||||
_items.clear();
|
||||
auto trackDesigns = _fileIndex.LoadOrBuild();
|
||||
for (auto td : trackDesigns)
|
||||
for (const auto &td : trackDesigns)
|
||||
{
|
||||
_items.push_back(td);
|
||||
}
|
||||
|
||||
@@ -225,12 +225,7 @@ static void paint_reverse_freefall_rc_station(paint_session * session, uint8 rid
|
||||
sint32 height, rct_tile_element * tileElement)
|
||||
{
|
||||
Ride * ride = get_ride(rideIndex);
|
||||
const rct_ride_entrance_definition * entranceStyle = &RideEntranceDefinitions[ride->entrance_style];
|
||||
uint32 imageId = entranceStyle->base_image_id;
|
||||
if (!(session->TrackColours[SCHEME_MISC] & (1 << 29)))
|
||||
{
|
||||
imageId &= 0x7FFFF;
|
||||
}
|
||||
uint32 imageId;
|
||||
|
||||
if (direction == 0 || direction == 2)
|
||||
{
|
||||
|
||||
@@ -122,9 +122,6 @@ static void paint_observation_tower_base(paint_session * session, uint8 rideInde
|
||||
sint32 blockedSegments = 0;
|
||||
switch (trackSequence)
|
||||
{
|
||||
case 0:
|
||||
blockedSegments = SEGMENTS_ALL;
|
||||
break;
|
||||
case 1:
|
||||
blockedSegments = SEGMENT_B8 | SEGMENT_C8 | SEGMENT_B4 | SEGMENT_CC | SEGMENT_BC;
|
||||
break;
|
||||
|
||||
@@ -80,7 +80,7 @@ static void ride_ratings_update_state_5();
|
||||
static void ride_ratings_begin_proximity_loop();
|
||||
static void ride_ratings_calculate(Ride *ride);
|
||||
static void ride_ratings_calculate_value(Ride *ride);
|
||||
static void ride_ratings_score_close_proximity(rct_tile_element *tileElement);
|
||||
static void ride_ratings_score_close_proximity(rct_tile_element *inputTileElement);
|
||||
|
||||
static void ride_ratings_add(rating_tuple * rating, sint32 excitement, sint32 intensity, sint32 nausea);
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ void vehicle_visual_river_rapids(paint_session * session, sint32 x, sint32 image
|
||||
if (session->Unk140E9A8->zoom_level < 2 && vehicle->num_peeps > 0)
|
||||
{
|
||||
// Draw peeps: (this particular vehicle doesn't sort them back to front like others so the back ones sometimes clip, but
|
||||
// thats how the original does it...)
|
||||
// that's how the original does it...)
|
||||
sint32 peeps = ((ecx / 8) + 0) & 3;
|
||||
image_id = (baseImage_id + ((peeps + 1) * 72)) |
|
||||
SPRITE_ID_PALETTE_COLOUR_2(vehicle->peep_tshirt_colours[0], vehicle->peep_tshirt_colours[1]);
|
||||
|
||||
@@ -58,7 +58,7 @@ private:
|
||||
LocationXY32 _viewCentreLocation = { 0 };
|
||||
|
||||
public:
|
||||
TitleSequencePlayer(IScenarioRepository * scenarioRepository)
|
||||
explicit TitleSequencePlayer(IScenarioRepository * scenarioRepository)
|
||||
{
|
||||
Guard::ArgumentNotNull(scenarioRepository);
|
||||
|
||||
|
||||
@@ -289,8 +289,6 @@ static size_t encode_chunk_rle(const uint8 *src_buffer, uint8 *dst_buffer, size_
|
||||
*dst++ = count - 1;
|
||||
memcpy(dst, src_norm_start, count);
|
||||
dst += count;
|
||||
src_norm_start += count;
|
||||
count = 0;
|
||||
}
|
||||
return dst - dst_buffer;
|
||||
}
|
||||
|
||||
@@ -470,7 +470,7 @@ static void window_ride_construction_exit_click(rct_window *w);
|
||||
|
||||
static void window_ride_construction_draw_track_piece(
|
||||
rct_window *w, rct_drawpixelinfo *dpi,
|
||||
sint32 rideIndex, sint32 trackType, sint32 trackRotation, sint32 unknown,
|
||||
sint32 rideIndex, sint32 trackType, sint32 trackDirection, sint32 unknown,
|
||||
sint32 width, sint32 height
|
||||
);
|
||||
static void window_ride_construction_update_enabled_track_pieces();
|
||||
@@ -1679,7 +1679,7 @@ static void window_ride_construction_construct(rct_window *w)
|
||||
);
|
||||
if (_trackPlaceCost == MONEY32_UNDEFINED) {
|
||||
if (network_get_mode() == NETWORK_MODE_CLIENT)
|
||||
game_command_callback = 0; // don't do callback if we can't afford the track piece
|
||||
game_command_callback = nullptr; // don't do callback if we can't afford the track piece
|
||||
window_ride_construction_update_active_elements();
|
||||
return;
|
||||
}
|
||||
@@ -2495,8 +2495,7 @@ static bool sub_6CA2DF_get_track_element(uint8 *trackElement) {
|
||||
}
|
||||
|
||||
if (curve <= 8) {
|
||||
for (sint32 i = 0; i < (sint32)Util::CountOf(gTrackDescriptors); i++) {
|
||||
track_descriptor trackDescriptor = gTrackDescriptors[i];
|
||||
for (auto trackDescriptor : gTrackDescriptors) {
|
||||
if (trackDescriptor.track_curve != curve) continue;
|
||||
if (trackDescriptor.starts_diagonal != startsDiagonal) continue;
|
||||
if (trackDescriptor.slope_start != startSlope) continue;
|
||||
|
||||
@@ -1713,7 +1713,7 @@ static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
// Path connections
|
||||
x = w->x + w->widgets[WIDX_GROUPBOX_DETAILS].left + 7;
|
||||
y = w->y + w->widgets[WIDX_PATH_CHECK_EDGE_W].top;
|
||||
gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_PATH_CONECTED_EDGES, nullptr, COLOUR_DARK_GREEN, x, y);
|
||||
gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_PATH_CONNECTED_EDGES, nullptr, COLOUR_DARK_GREEN, x, y);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void window_error_open(rct_string_id title, rct_string_id message);
|
||||
rct_window * window_error_open(rct_string_id title, rct_string_id message);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ extern uint32 windowTileInspectorTileX;
|
||||
extern uint32 windowTileInspectorTileY;
|
||||
extern sint32 windowTileInspectorElementCount;
|
||||
|
||||
void window_tile_inspector_set_page(rct_window *w, const tile_inspector_page page);
|
||||
void window_tile_inspector_set_page(rct_window *w, tile_inspector_page page);
|
||||
void window_tile_inspector_auto_set_buttons(rct_window *w);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -151,7 +151,7 @@ static money32 BannerSetColour(sint16 x, sint16 y, uint8 baseHeight, uint8 direc
|
||||
break;
|
||||
} while (!tile_element_is_last_for_tile(tileElement++));
|
||||
|
||||
if (found == false)
|
||||
if (!found)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ static money32 BannerPlace(sint16 x, sint16 y, uint8 pathBaseHeight, uint8 direc
|
||||
break;
|
||||
} while (!tile_element_is_last_for_tile(tileElement++));
|
||||
|
||||
if (pathFound == false)
|
||||
if (!pathFound)
|
||||
{
|
||||
gGameCommandErrorText = STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS;
|
||||
return MONEY32_UNDEFINED;
|
||||
@@ -378,7 +378,7 @@ static money32 BannerSetStyle(uint8 bannerIndex, uint8 colour, uint8 textColour,
|
||||
sint32 colourCodepoint = FORMAT_COLOUR_CODE_START + banner->text_colour;
|
||||
|
||||
utf8 buffer[256];
|
||||
format_string(buffer, 256, banner->string_idx, 0);
|
||||
format_string(buffer, 256, banner->string_idx, nullptr);
|
||||
sint32 firstCodepoint = utf8_get_next(buffer, nullptr);
|
||||
if (firstCodepoint >= FORMAT_COLOUR_CODE_START && firstCodepoint <= FORMAT_COLOUR_CODE_END)
|
||||
{
|
||||
@@ -430,9 +430,8 @@ extern "C"
|
||||
*/
|
||||
void banner_init()
|
||||
{
|
||||
for (sint32 i = 0; i < MAX_BANNERS; i++)
|
||||
{
|
||||
gBanners[i].type = BANNER_NULL;
|
||||
for (auto &banner : gBanners) {
|
||||
banner.type = BANNER_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -511,9 +511,9 @@ extern "C"
|
||||
|
||||
void reset_park_entrance()
|
||||
{
|
||||
for (sint32 i = 0; i < MAX_PARK_ENTRANCES; i++)
|
||||
for (auto &parkEntrance : gParkEntrances)
|
||||
{
|
||||
gParkEntrances[i].x = LOCATION_NULL;
|
||||
parkEntrance.x = LOCATION_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ static money32 SmallSceneryRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 qu
|
||||
break;
|
||||
} while (!tile_element_is_last_for_tile(tileElement++));
|
||||
|
||||
if (sceneryFound == false)
|
||||
if (!sceneryFound)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -152,12 +152,7 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry * wall,
|
||||
trackBlock = &TrackBlocks[trackType][sequence];
|
||||
z = TrackCoordinates[trackType].z_end;
|
||||
z = trackElement->base_height + ((z - trackBlock->z) * 8);
|
||||
if (z != z0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return z == z0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,7 +87,7 @@ static const uint8 BaseTerrain[] = { TERRAIN_GRASS, TERRAIN_SAND, TERRAIN_SAND_L
|
||||
#define BLOB_HEIGHT 255
|
||||
|
||||
static void mapgen_place_trees();
|
||||
static void mapgen_set_water_level(sint32 height);
|
||||
static void mapgen_set_water_level(sint32 waterLevel);
|
||||
static void mapgen_blobs(sint32 count, sint32 lowSize, sint32 highSize, sint32 lowHeight, sint32 highHeight);
|
||||
static void mapgen_blob(sint32 cx, sint32 cy, sint32 size, sint32 height);
|
||||
static void mapgen_smooth_height(sint32 iterations);
|
||||
|
||||
@@ -150,7 +150,6 @@ void reset_sprite_list()
|
||||
}
|
||||
_spriteFlashingList[i] = false;
|
||||
previous_spr = spr;
|
||||
spr++;
|
||||
}
|
||||
|
||||
gSpriteListCount[SPRITE_LIST_NULL] = MAX_SPRITES;
|
||||
|
||||
@@ -51,9 +51,9 @@ bool gTestColor = true;
|
||||
Verbosity _verbosity = NORMAL;
|
||||
|
||||
static bool CStringEquals(const char *lhs, const char *rhs) {
|
||||
if (lhs == NULL) return rhs == NULL;
|
||||
if (lhs == nullptr) return rhs == nullptr;
|
||||
|
||||
if (rhs == NULL) return false;
|
||||
if (rhs == nullptr) return false;
|
||||
|
||||
return strcmp(lhs, rhs) == 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user