forked from rosebudai/OpenRCT2-Web
Convert most remaining C-style casts to C++-style ones (#11867)
This commit is contained in:
1 parent
7646f1b7e4
commit
9ef8d6da42
43 files changed
+126
-107
No files matched your search
@@ -452,7 +452,7 @@ static std::pair<rct_string_id, void*> widget_get_stringid_and_args(const rct_wi
|
||||
else
|
||||
{
|
||||
stringId = STR_STRING;
|
||||
formatArgs = (void*)&widget->string;
|
||||
formatArgs = reinterpret_cast<void*>(widget->string);
|
||||
}
|
||||
}
|
||||
return std::make_pair(stringId, formatArgs);
|
||||
|
||||
@@ -840,7 +840,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
else if (desc.Type == "dropdown")
|
||||
{
|
||||
widget.type = WWT_DROPDOWN;
|
||||
if (desc.SelectedIndex >= 0 && (size_t)desc.SelectedIndex < desc.Items.size())
|
||||
if (desc.SelectedIndex >= 0 && static_cast<size_t>(desc.SelectedIndex) < desc.Items.size())
|
||||
{
|
||||
widget.string = const_cast<utf8*>(desc.Items[desc.SelectedIndex].c_str());
|
||||
}
|
||||
|
||||
@@ -637,8 +637,7 @@ namespace OpenRCT2
|
||||
// which the window function doesn't like
|
||||
auto intent = Intent(WC_OBJECT_LOAD_ERROR);
|
||||
intent.putExtra(INTENT_EXTRA_PATH, path);
|
||||
// TODO: CAST-IMPROVEMENT-NEEDED
|
||||
intent.putExtra(INTENT_EXTRA_LIST, (void*)e.MissingObjects.data());
|
||||
intent.putExtra(INTENT_EXTRA_LIST, const_cast<rct_object_entry*>(e.MissingObjects.data()));
|
||||
intent.putExtra(INTENT_EXTRA_LIST_COUNT, static_cast<uint32_t>(e.MissingObjects.size()));
|
||||
|
||||
auto windowManager = _uiContext->GetWindowManager();
|
||||
|
||||
@@ -95,7 +95,7 @@ static bool TryClassifyAsS4(IStream* stream, ClassifiedFileInfo* result)
|
||||
uint64_t originalPosition = stream->GetPosition();
|
||||
try
|
||||
{
|
||||
size_t dataLength = (size_t)stream->GetLength();
|
||||
size_t dataLength = static_cast<size_t>(stream->GetLength());
|
||||
auto deleter_lambda = [dataLength](uint8_t* ptr) { Memory::FreeArray(ptr, dataLength); };
|
||||
std::unique_ptr<uint8_t, decltype(deleter_lambda)> data(stream->ReadArray<uint8_t>(dataLength), deleter_lambda);
|
||||
stream->SetPosition(originalPosition);
|
||||
@@ -132,7 +132,7 @@ static bool TryClassifyAsTD4_TD6(IStream* stream, ClassifiedFileInfo* result)
|
||||
uint64_t originalPosition = stream->GetPosition();
|
||||
try
|
||||
{
|
||||
size_t dataLength = (size_t)stream->GetLength();
|
||||
size_t dataLength = static_cast<size_t>(stream->GetLength());
|
||||
auto deleter_lambda = [dataLength](uint8_t* ptr) { Memory::FreeArray(ptr, dataLength); };
|
||||
std::unique_ptr<uint8_t, decltype(deleter_lambda)> data(stream->ReadArray<uint8_t>(dataLength), deleter_lambda);
|
||||
stream->SetPosition(originalPosition);
|
||||
|
||||
@@ -683,8 +683,7 @@ void save_game_as()
|
||||
|
||||
static int32_t compare_autosave_file_paths(const void* a, const void* b)
|
||||
{
|
||||
// TODO: CAST-IMPROVEMENT-NEEDED
|
||||
return strcmp(*(char**)a, *(char**)b);
|
||||
return strcmp(static_cast<const char*>(a), static_cast<const char*>(b));
|
||||
}
|
||||
|
||||
static void limit_autosave_count(const size_t numberOfFilesToKeep, bool processLandscapeFolder)
|
||||
|
||||
@@ -26,7 +26,7 @@ private:
|
||||
public:
|
||||
explicit PlatformEnvironment(DIRBASE_VALUES basePaths)
|
||||
{
|
||||
for (int32_t i = 0; i < DIRBASE_COUNT; i++)
|
||||
for (size_t i = 0; i < DIRBASE_COUNT; i++)
|
||||
{
|
||||
_basePath[i] = basePaths[i];
|
||||
}
|
||||
@@ -124,35 +124,38 @@ std::unique_ptr<IPlatformEnvironment> OpenRCT2::CreatePlatformEnvironment()
|
||||
|
||||
// Set default paths
|
||||
std::string basePaths[DIRBASE_COUNT];
|
||||
basePaths[(size_t)DIRBASE::OPENRCT2] = Platform::GetInstallPath();
|
||||
basePaths[(size_t)DIRBASE::USER] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_DATA), subDirectory);
|
||||
basePaths[(size_t)DIRBASE::CONFIG] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_CONFIG), subDirectory);
|
||||
basePaths[(size_t)DIRBASE::CACHE] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_CACHE), subDirectory);
|
||||
basePaths[(size_t)DIRBASE::DOCUMENTATION] = Platform::GetDocsPath();
|
||||
basePaths[static_cast<size_t>(DIRBASE::OPENRCT2)] = Platform::GetInstallPath();
|
||||
basePaths[static_cast<size_t>(DIRBASE::USER)] = Path::Combine(
|
||||
Platform::GetFolderPath(SPECIAL_FOLDER::USER_DATA), subDirectory);
|
||||
basePaths[static_cast<size_t>(DIRBASE::CONFIG)] = Path::Combine(
|
||||
Platform::GetFolderPath(SPECIAL_FOLDER::USER_CONFIG), subDirectory);
|
||||
basePaths[static_cast<size_t>(DIRBASE::CACHE)] = Path::Combine(
|
||||
Platform::GetFolderPath(SPECIAL_FOLDER::USER_CACHE), subDirectory);
|
||||
basePaths[static_cast<size_t>(DIRBASE::DOCUMENTATION)] = Platform::GetDocsPath();
|
||||
|
||||
// Override paths that have been specified via the command line
|
||||
if (!String::IsNullOrEmpty(gCustomRCT1DataPath))
|
||||
{
|
||||
basePaths[(size_t)DIRBASE::RCT1] = gCustomRCT1DataPath;
|
||||
basePaths[static_cast<size_t>(DIRBASE::RCT1)] = gCustomRCT1DataPath;
|
||||
}
|
||||
if (!String::IsNullOrEmpty(gCustomRCT2DataPath))
|
||||
{
|
||||
basePaths[(size_t)DIRBASE::RCT2] = gCustomRCT2DataPath;
|
||||
basePaths[static_cast<size_t>(DIRBASE::RCT2)] = gCustomRCT2DataPath;
|
||||
}
|
||||
if (!String::IsNullOrEmpty(gCustomOpenrctDataPath))
|
||||
{
|
||||
basePaths[(size_t)DIRBASE::OPENRCT2] = gCustomOpenrctDataPath;
|
||||
basePaths[static_cast<size_t>(DIRBASE::OPENRCT2)] = gCustomOpenrctDataPath;
|
||||
}
|
||||
if (!String::IsNullOrEmpty(gCustomUserDataPath))
|
||||
{
|
||||
basePaths[(size_t)DIRBASE::USER] = gCustomUserDataPath;
|
||||
basePaths[(size_t)DIRBASE::CONFIG] = gCustomUserDataPath;
|
||||
basePaths[(size_t)DIRBASE::CACHE] = gCustomUserDataPath;
|
||||
basePaths[static_cast<size_t>(DIRBASE::USER)] = gCustomUserDataPath;
|
||||
basePaths[static_cast<size_t>(DIRBASE::CONFIG)] = gCustomUserDataPath;
|
||||
basePaths[static_cast<size_t>(DIRBASE::CACHE)] = gCustomUserDataPath;
|
||||
}
|
||||
|
||||
if (basePaths[(size_t)DIRBASE::DOCUMENTATION].empty())
|
||||
if (basePaths[static_cast<size_t>(DIRBASE::DOCUMENTATION)].empty())
|
||||
{
|
||||
basePaths[(size_t)DIRBASE::DOCUMENTATION] = basePaths[static_cast<size_t>(DIRBASE::OPENRCT2)];
|
||||
basePaths[static_cast<size_t>(DIRBASE::DOCUMENTATION)] = basePaths[static_cast<size_t>(DIRBASE::OPENRCT2)];
|
||||
}
|
||||
|
||||
auto env = OpenRCT2::CreatePlatformEnvironment(basePaths);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
enum class DIRBASE : int32_t
|
||||
enum class DIRBASE : size_t
|
||||
{
|
||||
RCT1, // Base directory for original RollerCoaster Tycoon 1 content.
|
||||
RCT2, // Base directory for original RollerCoaster Tycoon 2 content.
|
||||
@@ -26,7 +26,7 @@ namespace OpenRCT2
|
||||
CACHE, // Base directory for OpenRCT2 cache files.
|
||||
DOCUMENTATION, // Base directory for OpenRCT2 doc files.
|
||||
};
|
||||
constexpr int32_t DIRBASE_COUNT = 7;
|
||||
constexpr size_t DIRBASE_COUNT = 7;
|
||||
using DIRBASE_VALUES = std::string[DIRBASE_COUNT];
|
||||
|
||||
enum class DIRID
|
||||
|
||||
@@ -305,7 +305,7 @@ private:
|
||||
if (it.element->GetType() != TILE_ELEMENT_TYPE_TRACK)
|
||||
continue;
|
||||
|
||||
if (it.element->AsTrack()->GetRideIndex() != (ride_id_t)_rideIndex)
|
||||
if (it.element->AsTrack()->GetRideIndex() != static_cast<ride_id_t>(_rideIndex))
|
||||
continue;
|
||||
|
||||
auto location = CoordsXYZD(
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace File
|
||||
}
|
||||
|
||||
fs.seekg(0, std::ios::end);
|
||||
auto fsize = (size_t)fs.tellg();
|
||||
auto fsize = static_cast<size_t>(fs.tellg());
|
||||
if (fsize > SIZE_MAX)
|
||||
{
|
||||
std::string message = String::StdFormat(
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Http
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, &wt);
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)wt.sizeleft);
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(wt.sizeleft));
|
||||
}
|
||||
|
||||
if (req.forceIPv4)
|
||||
@@ -114,9 +114,9 @@ namespace Http
|
||||
curl_easy_setopt(curl, CURLOPT_URL, req.url.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeData);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&res);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, static_cast<void*>(&res));
|
||||
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADERDATA, (void*)&res);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADERDATA, static_cast<void*>(&res));
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, OPENRCT2_USER_AGENT);
|
||||
|
||||
@@ -226,7 +226,10 @@ private:
|
||||
public:
|
||||
explicit vector_streambuf(const std::vector<T>& vec)
|
||||
{
|
||||
this->setg((char*)vec.data(), (char*)vec.data(), (char*)(vec.data() + vec.size()));
|
||||
this->setg(
|
||||
reinterpret_cast<char*>(const_cast<unsigned char*>(vec.data())),
|
||||
reinterpret_cast<char*>(const_cast<unsigned char*>(vec.data())),
|
||||
reinterpret_cast<char*>(const_cast<unsigned char*>(vec.data() + vec.size())));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -23,21 +23,21 @@ namespace Memory
|
||||
{
|
||||
template<typename T> static T* Allocate()
|
||||
{
|
||||
T* result = (T*)malloc(sizeof(T));
|
||||
T* result = static_cast<T*>(malloc(sizeof(T)));
|
||||
Guard::ArgumentNotNull(result, "Failed to allocate %zu bytes for %s", sizeof(T), typeid(T).name());
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T> static T* Allocate(size_t size)
|
||||
{
|
||||
T* result = (T*)malloc(size);
|
||||
T* result = static_cast<T*>(malloc(size));
|
||||
Guard::ArgumentNotNull(result, "Failed to allocate %zu bytes for %s", size, typeid(T).name());
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T> static T* AllocateArray(size_t count)
|
||||
{
|
||||
T* result = (T*)malloc(count * sizeof(T));
|
||||
T* result = static_cast<T*>(malloc(count * sizeof(T)));
|
||||
Guard::ArgumentNotNull(result, "Failed to allocate array of %zu * %s (%zu bytes)", count, typeid(T).name(), sizeof(T));
|
||||
return result;
|
||||
}
|
||||
@@ -47,11 +47,11 @@ namespace Memory
|
||||
T* result;
|
||||
if (ptr == nullptr)
|
||||
{
|
||||
result = (T*)malloc(size);
|
||||
result = static_cast<T*>(malloc(size));
|
||||
}
|
||||
else
|
||||
{
|
||||
result = (T*)realloc((void*)ptr, size);
|
||||
result = static_cast<T*>(realloc(reinterpret_cast<void*>(ptr), size));
|
||||
}
|
||||
Guard::ArgumentNotNull(result, "Failed to reallocate %x (%s) to have %zu bytes", ptr, typeid(T).name(), size);
|
||||
return result;
|
||||
@@ -62,11 +62,11 @@ namespace Memory
|
||||
T* result;
|
||||
if (ptr == nullptr)
|
||||
{
|
||||
result = (T*)malloc(count * sizeof(T));
|
||||
result = static_cast<T*>(malloc(count * sizeof(T)));
|
||||
}
|
||||
else
|
||||
{
|
||||
result = (T*)realloc((void*)ptr, count * sizeof(T));
|
||||
result = static_cast<T*>(realloc(reinterpret_cast<void*>(ptr), count * sizeof(T)));
|
||||
}
|
||||
Guard::ArgumentNotNull(
|
||||
result, "Failed to reallocate array at %x (%s) to have %zu entries", ptr, typeid(T).name(), count);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Numerics
|
||||
{
|
||||
static_assert(std::is_unsigned<_UIntType>::value, "result_type must be an unsigned integral type");
|
||||
using limits = typename std::numeric_limits<_UIntType>;
|
||||
return (((_UIntType)(x) << shift) | ((_UIntType)(x) >> (limits::digits - shift)));
|
||||
return ((static_cast<_UIntType>(x) << shift) | (static_cast<_UIntType>(x) >> (limits::digits - shift)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ namespace Numerics
|
||||
{
|
||||
static_assert(std::is_unsigned<_UIntType>::value, "result_type must be an unsigned integral type");
|
||||
using limits = std::numeric_limits<_UIntType>;
|
||||
return (((_UIntType)(x) >> shift) | ((_UIntType)(x) << (limits::digits - shift)));
|
||||
return ((static_cast<_UIntType>(x) >> shift) | (static_cast<_UIntType>(x) << (limits::digits - shift)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Random
|
||||
|
||||
template<typename _TIt> void generate(_TIt begin, _TIt end) const
|
||||
{
|
||||
std::copy_n(v.begin(), std::min((size_t)(end - begin), N), begin);
|
||||
std::copy_n(v.begin(), std::min(static_cast<size_t>(end - begin), N), begin);
|
||||
}
|
||||
|
||||
constexpr size_t size() const
|
||||
|
||||
@@ -454,7 +454,7 @@ namespace String
|
||||
|
||||
utf8* SkipBOM(utf8* buffer)
|
||||
{
|
||||
return const_cast<utf8*>(SkipBOM((const utf8*)buffer));
|
||||
return const_cast<utf8*>(SkipBOM(static_cast<const utf8*>(buffer)));
|
||||
}
|
||||
|
||||
const utf8* SkipBOM(const utf8* buffer)
|
||||
@@ -474,7 +474,7 @@ namespace String
|
||||
|
||||
codepoint_t GetNextCodepoint(utf8* ptr, utf8** nextPtr)
|
||||
{
|
||||
return GetNextCodepoint((const utf8*)ptr, (const utf8**)nextPtr);
|
||||
return GetNextCodepoint(static_cast<const utf8*>(ptr), const_cast<const utf8**>(nextPtr));
|
||||
}
|
||||
|
||||
codepoint_t GetNextCodepoint(const utf8* ptr, const utf8** nextPtr)
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
jclass zipClass = env->GetObjectClass(_zip);
|
||||
jmethodID fileCountMethod = env->GetMethodID(zipClass, "getNumFiles", "()I");
|
||||
|
||||
return (size_t)env->CallIntMethod(_zip, fileCountMethod);
|
||||
return static_cast<size_t>(env->CallIntMethod(_zip, fileCountMethod));
|
||||
}
|
||||
|
||||
std::string GetFileName(size_t index) const override
|
||||
|
||||
@@ -46,7 +46,7 @@ int32_t gfx_get_string_width_new_lined(utf8* text)
|
||||
int32_t codepoint;
|
||||
|
||||
int32_t maxWidth = 0;
|
||||
while ((codepoint = utf8_get_next(ch, (const utf8**)&nextCh)) != 0)
|
||||
while ((codepoint = utf8_get_next(ch, const_cast<const utf8**>(&nextCh))) != 0)
|
||||
{
|
||||
if (codepoint == FORMAT_NEWLINE || codepoint == FORMAT_NEWLINE_SMALLER)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ int32_t gfx_clip_string(utf8* text, int32_t width)
|
||||
utf8* nextCh = text;
|
||||
utf8* clipCh = text;
|
||||
int32_t codepoint;
|
||||
while ((codepoint = utf8_get_next(ch, (const utf8**)&nextCh)) != 0)
|
||||
while ((codepoint = utf8_get_next(ch, const_cast<const utf8**>(&nextCh))) != 0)
|
||||
{
|
||||
if (utf8_is_format_code(codepoint))
|
||||
{
|
||||
@@ -176,7 +176,7 @@ int32_t gfx_wrap_string(utf8* text, int32_t width, int32_t* outNumLines, int32_t
|
||||
utf8* nextCh;
|
||||
int32_t codepoint;
|
||||
int32_t numCharactersOnLine = 0;
|
||||
while ((codepoint = utf8_get_next(ch, (const utf8**)&nextCh)) != 0)
|
||||
while ((codepoint = utf8_get_next(ch, const_cast<const utf8**>(&nextCh))) != 0)
|
||||
{
|
||||
if (codepoint == ' ')
|
||||
{
|
||||
@@ -313,7 +313,7 @@ void draw_string_centred_raw(rct_drawpixelinfo* dpi, int32_t x, int32_t y, int32
|
||||
{
|
||||
ScreenCoordsXY screenCoords(dpi->x, dpi->y);
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
gfx_draw_string(dpi, (char*)"", COLOUR_BLACK, screenCoords);
|
||||
gfx_draw_string(dpi, "", COLOUR_BLACK, screenCoords);
|
||||
screenCoords = { x, y };
|
||||
gCurrentFontFlags = 0;
|
||||
|
||||
@@ -429,7 +429,7 @@ void gfx_draw_string_centred_wrapped_partial(
|
||||
ScreenCoordsXY screenCoords(dpi->x, dpi->y);
|
||||
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
gfx_draw_string(dpi, (char*)"", colour, screenCoords);
|
||||
gfx_draw_string(dpi, "", colour, screenCoords);
|
||||
format_string(buffer, 256, format, args);
|
||||
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
@@ -448,7 +448,7 @@ void gfx_draw_string_centred_wrapped_partial(
|
||||
utf8* ch = buffer;
|
||||
utf8* nextCh;
|
||||
int32_t codepoint;
|
||||
while ((codepoint = utf8_get_next(ch, (const utf8**)&nextCh)) != 0)
|
||||
while ((codepoint = utf8_get_next(ch, const_cast<const utf8**>(&nextCh))) != 0)
|
||||
{
|
||||
if (!utf8_is_format_code(codepoint))
|
||||
{
|
||||
|
||||
@@ -142,7 +142,7 @@ std::tuple<void*, size_t> ImageImporter::EncodeRLE(const int32_t* pixels, uint32
|
||||
{
|
||||
yOffsets[y] = static_cast<uint16_t>(dst - buffer);
|
||||
|
||||
auto previousCode = (RLECode*)nullptr;
|
||||
auto previousCode = static_cast<RLECode*>(nullptr);
|
||||
auto currentCode = reinterpret_cast<RLECode*>(dst);
|
||||
dst += 2;
|
||||
|
||||
|
||||
@@ -1497,7 +1497,7 @@ static void scrolling_text_set_bitmap_for_sprite(
|
||||
utf8* ch = text;
|
||||
while (true)
|
||||
{
|
||||
uint32_t codepoint = utf8_get_next(ch, (const utf8**)&ch);
|
||||
uint32_t codepoint = utf8_get_next(ch, const_cast<const utf8**>(&ch));
|
||||
|
||||
// If at the end of the string loop back to the start
|
||||
if (codepoint == 0)
|
||||
@@ -1567,7 +1567,7 @@ static void scrolling_text_set_bitmap_for_ttf(
|
||||
utf8* dstCh = text;
|
||||
utf8* ch = text;
|
||||
int32_t codepoint;
|
||||
while ((codepoint = utf8_get_next(ch, (const utf8**)&ch)) != 0)
|
||||
while ((codepoint = utf8_get_next(ch, const_cast<const utf8**>(&ch))) != 0)
|
||||
{
|
||||
if (utf8_is_format_code(codepoint))
|
||||
{
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Adapted from freetype.h in order to avoid C-style casts.
|
||||
|
||||
#define FT_LOAD_TARGET_ALT(x) (static_cast<FT_Int32>((x)&15) << 16)
|
||||
|
||||
/**
|
||||
* The following code is from SDL2_ttf (2 Jan 2017).
|
||||
* Taking just what was needed for OpenRCT2 with all SDL2 calls
|
||||
@@ -1530,9 +1534,9 @@ TTFSurface* TTF_RenderUTF8_Shaded(TTF_Font* font, const char* text, [[maybe_unus
|
||||
void TTF_SetFontHinting(TTF_Font* font, int hinting)
|
||||
{
|
||||
if (hinting == TTF_HINTING_LIGHT)
|
||||
font->hinting = FT_LOAD_TARGET_LIGHT;
|
||||
font->hinting = FT_LOAD_TARGET_ALT(FT_RENDER_MODE_LIGHT);
|
||||
else if (hinting == TTF_HINTING_MONO)
|
||||
font->hinting = FT_LOAD_TARGET_MONO;
|
||||
font->hinting = FT_LOAD_TARGET_ALT(FT_RENDER_MODE_MONO);
|
||||
else if (hinting == TTF_HINTING_NONE)
|
||||
font->hinting = FT_LOAD_NO_HINTING;
|
||||
else
|
||||
@@ -1543,9 +1547,9 @@ void TTF_SetFontHinting(TTF_Font* font, int hinting)
|
||||
|
||||
int TTF_GetFontHinting(const TTF_Font* font)
|
||||
{
|
||||
if (font->hinting == FT_LOAD_TARGET_LIGHT)
|
||||
if (font->hinting == FT_LOAD_TARGET_ALT(FT_RENDER_MODE_LIGHT))
|
||||
return TTF_HINTING_LIGHT;
|
||||
else if (font->hinting == FT_LOAD_TARGET_MONO)
|
||||
else if (font->hinting == FT_LOAD_TARGET_ALT(FT_RENDER_MODE_MONO))
|
||||
return TTF_HINTING_MONO;
|
||||
else if (font->hinting == FT_LOAD_NO_HINTING)
|
||||
return TTF_HINTING_NONE;
|
||||
|
||||
@@ -102,7 +102,7 @@ void chat_draw(rct_drawpixelinfo* dpi, uint8_t chatBackgroundColor)
|
||||
// Draw chat window
|
||||
if (gChatOpen)
|
||||
{
|
||||
inputLineHeight = chat_string_wrapped_get_height((void*)&inputLine, _chatWidth - 10);
|
||||
inputLineHeight = chat_string_wrapped_get_height(static_cast<void*>(&inputLine), _chatWidth - 10);
|
||||
_chatTop -= inputLineHeight;
|
||||
|
||||
for (int32_t i = 0; i < CHAT_HISTORY_SIZE; i++)
|
||||
@@ -114,7 +114,7 @@ void chat_draw(rct_drawpixelinfo* dpi, uint8_t chatBackgroundColor)
|
||||
|
||||
safe_strcpy(lineBuffer, chat_history_get(i), sizeof(lineBuffer));
|
||||
|
||||
int32_t lineHeight = chat_string_wrapped_get_height((void*)&lineCh, _chatWidth - 10);
|
||||
int32_t lineHeight = chat_string_wrapped_get_height(static_cast<void*>(&lineCh), _chatWidth - 10);
|
||||
_chatTop -= (lineHeight + 5);
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ void chat_draw(rct_drawpixelinfo* dpi, uint8_t chatBackgroundColor)
|
||||
|
||||
safe_strcpy(lineBuffer, chat_history_get(i), sizeof(lineBuffer));
|
||||
|
||||
stringHeight = chat_history_draw_string(dpi, (void*)&lineCh, ScreenCoordsXY(x, y), _chatWidth - 10) + 5;
|
||||
stringHeight = chat_history_draw_string(dpi, static_cast<void*>(&lineCh), ScreenCoordsXY(x, y), _chatWidth - 10) + 5;
|
||||
gfx_set_dirty_blocks(x, y - stringHeight, x + _chatWidth, y + 20);
|
||||
|
||||
if ((y - stringHeight) < 50)
|
||||
@@ -177,7 +177,7 @@ void chat_draw(rct_drawpixelinfo* dpi, uint8_t chatBackgroundColor)
|
||||
|
||||
lineCh = lineBuffer;
|
||||
inputLineHeight = gfx_draw_string_left_wrapped(
|
||||
dpi, (void*)&lineCh, x, y + 3, _chatWidth - 10, STR_STRING, TEXT_COLOUR_255);
|
||||
dpi, static_cast<void*>(&lineCh), x, y + 3, _chatWidth - 10, STR_STRING, TEXT_COLOUR_255);
|
||||
gfx_set_dirty_blocks(x, y, x + _chatWidth, y + inputLineHeight + 15);
|
||||
|
||||
// TODO: Show caret if the input text has multiple lines
|
||||
@@ -281,7 +281,7 @@ int32_t chat_history_draw_string(rct_drawpixelinfo* dpi, void* args, const Scree
|
||||
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
|
||||
gfx_draw_string(dpi, (char*)"", TEXT_COLOUR_255, { dpi->x, dpi->y });
|
||||
gfx_draw_string(dpi, "", TEXT_COLOUR_255, { dpi->x, dpi->y });
|
||||
char* buffer = gCommonStringFormatBuffer;
|
||||
format_string(buffer, 256, STR_STRING, args);
|
||||
|
||||
|
||||
@@ -737,7 +737,7 @@ static int32_t cc_set(InteractiveConsole& console, const arguments_t& argv)
|
||||
|
||||
if (argv[0] == "money" && invalidArguments(&invalidArgs, double_valid[0]))
|
||||
{
|
||||
money32 money = MONEY((int32_t)double_val[0], ((int32_t)(double_val[0] * 100)) % 100);
|
||||
money32 money = MONEY(static_cast<int32_t>(double_val[0]), (static_cast<int32_t>(double_val[0] * 100)) % 100);
|
||||
if (gCash != money)
|
||||
{
|
||||
auto setCheatAction = SetCheatAction(CheatType::SetMoney, money);
|
||||
@@ -772,7 +772,8 @@ static int32_t cc_set(InteractiveConsole& console, const arguments_t& argv)
|
||||
else if (argv[0] == "guest_initial_cash" && invalidArguments(&invalidArgs, double_valid[0]))
|
||||
{
|
||||
gGuestInitialCash = std::clamp(
|
||||
MONEY((int32_t)double_val[0], ((int32_t)(double_val[0] * 100)) % 100), MONEY(0, 0), MONEY(1000, 0));
|
||||
MONEY(static_cast<int32_t>(double_val[0]), (static_cast<int32_t>(double_val[0] * 100)) % 100), MONEY(0, 0),
|
||||
MONEY(1000, 0));
|
||||
console.Execute("get guest_initial_cash");
|
||||
}
|
||||
else if (argv[0] == "guest_initial_happiness" && invalidArguments(&invalidArgs, int_valid[0]))
|
||||
@@ -848,13 +849,15 @@ static int32_t cc_set(InteractiveConsole& console, const arguments_t& argv)
|
||||
else if (argv[0] == "land_rights_cost" && invalidArguments(&invalidArgs, double_valid[0]))
|
||||
{
|
||||
gLandPrice = std::clamp(
|
||||
MONEY((int32_t)double_val[0], ((int32_t)(double_val[0] * 100)) % 100), MONEY(0, 0), MONEY(200, 0));
|
||||
MONEY(static_cast<int32_t>(double_val[0]), (static_cast<int32_t>(double_val[0] * 100)) % 100), MONEY(0, 0),
|
||||
MONEY(200, 0));
|
||||
console.Execute("get land_rights_cost");
|
||||
}
|
||||
else if (argv[0] == "construction_rights_cost" && invalidArguments(&invalidArgs, double_valid[0]))
|
||||
{
|
||||
gConstructionRightsPrice = std::clamp(
|
||||
MONEY((int32_t)double_val[0], ((int32_t)(double_val[0] * 100)) % 100), MONEY(0, 0), MONEY(200, 0));
|
||||
MONEY(static_cast<int32_t>(double_val[0]), (static_cast<int32_t>(double_val[0] * 100)) % 100), MONEY(0, 0),
|
||||
MONEY(200, 0));
|
||||
console.Execute("get construction_rights_cost");
|
||||
}
|
||||
else if (argv[0] == "climate")
|
||||
|
||||
@@ -828,11 +828,14 @@ static void record_session(const paint_session* session, std::vector<paint_sessi
|
||||
// Mind the offset needs to be calculated against the original `session`, not `session_copy`
|
||||
for (auto& ps : session_copy->PaintStructs)
|
||||
{
|
||||
ps.basic.next_quadrant_ps = (paint_struct*)(ps.basic.next_quadrant_ps ? int(ps.basic.next_quadrant_ps - &session->PaintStructs[0].basic) : std::size(session->PaintStructs));
|
||||
ps.basic.next_quadrant_ps = reinterpret_cast<paint_struct*>(
|
||||
ps.basic.next_quadrant_ps ? int(ps.basic.next_quadrant_ps - &session->PaintStructs[0].basic)
|
||||
: std::size(session->PaintStructs));
|
||||
}
|
||||
for (auto& quad : session_copy->Quadrants)
|
||||
{
|
||||
quad = (paint_struct*)(quad ? int(quad - &session->PaintStructs[0].basic) : std::size(session->Quadrants));
|
||||
quad = reinterpret_cast<paint_struct*>(
|
||||
quad ? int(quad - &session->PaintStructs[0].basic) : std::size(session->Quadrants));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,8 +101,8 @@ const encoding_convert_entry RCT2ToUnicodeTable[] =
|
||||
|
||||
static int32_t encoding_search_compare(const void *pKey, const void *pEntry)
|
||||
{
|
||||
uint16_t key = *((uint16_t*)pKey);
|
||||
encoding_convert_entry *entry = (encoding_convert_entry*)pEntry;
|
||||
const uint16_t key = *reinterpret_cast<const uint16_t*>(pKey);
|
||||
const encoding_convert_entry *entry = static_cast<const encoding_convert_entry*>(pEntry);
|
||||
if (key < entry->code) return -1;
|
||||
if (key > entry->code) return 1;
|
||||
return 0;
|
||||
|
||||
@@ -139,7 +139,7 @@ std::string language_convert_string_to_tokens(const std::string_view& s)
|
||||
auto readPtr = input.c_str();
|
||||
while (true)
|
||||
{
|
||||
char32_t code = utf8_get_next(readPtr, (const utf8**)&readPtr);
|
||||
char32_t code = utf8_get_next(readPtr, const_cast<const utf8**>(&readPtr));
|
||||
if (code == 0)
|
||||
{
|
||||
break;
|
||||
|
||||
@@ -1088,7 +1088,7 @@ static void format_string_code(uint32_t format_code, char** dest, size_t* size,
|
||||
*args += sizeof(uintptr_t);
|
||||
|
||||
if (value != 0)
|
||||
format_append_string(dest, size, (char*)value);
|
||||
format_append_string(dest, size, reinterpret_cast<char*>(value));
|
||||
break;
|
||||
case FORMAT_MONTHYEAR:
|
||||
// Pop argument
|
||||
@@ -1318,7 +1318,7 @@ void format_string(utf8* dest, size_t size, rct_string_id format, const void* ar
|
||||
|
||||
utf8* end = dest;
|
||||
size_t left = size;
|
||||
format_string_part(&end, &left, format, (char**)&args);
|
||||
format_string_part(&end, &left, format, reinterpret_cast<char**>(const_cast<void**>(&args)));
|
||||
if (left == 0)
|
||||
{
|
||||
// Replace last character with null terminator
|
||||
@@ -1353,7 +1353,7 @@ void format_string_raw(utf8* dest, size_t size, const utf8* src, const void* arg
|
||||
|
||||
utf8* end = dest;
|
||||
size_t left = size;
|
||||
format_string_part_from_raw(&end, &left, src, (char**)&args);
|
||||
format_string_part_from_raw(&end, &left, src, reinterpret_cast<char**>(const_cast<void**>(&args)));
|
||||
if (left == 0)
|
||||
{
|
||||
// Replace last character with null terminator
|
||||
|
||||
@@ -179,7 +179,7 @@ void utf8_remove_formatting(utf8* string, bool allowColours)
|
||||
|
||||
while (true)
|
||||
{
|
||||
char32_t code = utf8_get_next(readPtr, (const utf8**)&readPtr);
|
||||
char32_t code = utf8_get_next(readPtr, const_cast<const utf8**>(&readPtr));
|
||||
|
||||
if (code == 0)
|
||||
{
|
||||
|
||||
@@ -1442,7 +1442,7 @@ void Network::Client_Send_AUTH(
|
||||
packet->WriteString(name.c_str());
|
||||
packet->WriteString(password.c_str());
|
||||
packet->WriteString(pubkey.c_str());
|
||||
assert(signature.size() <= (size_t)UINT32_MAX);
|
||||
assert(signature.size() <= static_cast<size_t>(UINT32_MAX));
|
||||
*packet << static_cast<uint32_t>(signature.size());
|
||||
packet->Write(signature.data(), signature.size());
|
||||
_serverConnection->AuthStatus = NETWORK_AUTH_REQUESTED;
|
||||
@@ -2611,7 +2611,9 @@ void Network::Client_Handle_GAMESTATE(NetworkConnection& connection, NetworkPack
|
||||
const uint8_t* data = packet.Read(dataSize);
|
||||
_serverGameState.Write(data, dataSize);
|
||||
|
||||
log_verbose("Received Game State %.02f%%", ((float)_serverGameState.GetLength() / (float)totalSize) * 100.0f);
|
||||
log_verbose(
|
||||
"Received Game State %.02f%%",
|
||||
(static_cast<float>(_serverGameState.GetLength()) / static_cast<float>(totalSize)) * 100.0f);
|
||||
|
||||
if (_serverGameState.GetLength() == totalSize)
|
||||
{
|
||||
@@ -2850,7 +2852,7 @@ void Network::Client_Handle_MAP([[maybe_unused]] NetworkConnection& connection,
|
||||
intent.putExtra(INTENT_EXTRA_CALLBACK, []() -> void { gNetwork.Close(); });
|
||||
context_open_intent(&intent);
|
||||
|
||||
std::memcpy(&chunk_buffer[offset], (void*)packet.Read(chunksize), chunksize);
|
||||
std::memcpy(&chunk_buffer[offset], const_cast<void*>(static_cast<const void*>(packet.Read(chunksize))), chunksize);
|
||||
if (offset + chunksize == size)
|
||||
{
|
||||
// Allow queue processing of game actions again.
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
template<typename T> NetworkPacket& operator<<(T value)
|
||||
{
|
||||
T swapped = ByteSwapBE(value);
|
||||
uint8_t* bytes = (uint8_t*)&swapped;
|
||||
uint8_t* bytes = reinterpret_cast<uint8_t*>(&swapped);
|
||||
Data->insert(Data->end(), bytes, bytes + sizeof(value));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -109,11 +109,11 @@ public:
|
||||
{
|
||||
if (_address.sa_family == AF_INET)
|
||||
{
|
||||
return ((sockaddr_in*)&_address)->sin_port;
|
||||
return reinterpret_cast<const sockaddr_in*>(&_address)->sin_port;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((sockaddr_in6*)&_address)->sin6_port;
|
||||
return reinterpret_cast<const sockaddr_in6*>(&_address)->sin6_port;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ void ImageTable::Read(IReadObjectContext* context, IStream* stream)
|
||||
rct_g1_element g1Element;
|
||||
|
||||
uintptr_t imageDataOffset = static_cast<uintptr_t>(stream->ReadValue<uint32_t>());
|
||||
g1Element.offset = (uint8_t*)(imageDataBase + imageDataOffset);
|
||||
g1Element.offset = reinterpret_cast<uint8_t*>(imageDataBase + imageDataOffset);
|
||||
|
||||
g1Element.width = stream->ReadValue<int16_t>();
|
||||
g1Element.height = stream->ReadValue<int16_t>();
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace ObjectJsonHelpers
|
||||
{
|
||||
if (GetBoolean(obj, item.first))
|
||||
{
|
||||
flags = (T)(flags | item.second);
|
||||
flags = static_cast<T>(flags | item.second);
|
||||
}
|
||||
}
|
||||
return flags;
|
||||
|
||||
@@ -59,8 +59,8 @@ int32_t object_entry_group_encoding[] = {
|
||||
bool object_entry_is_empty(const rct_object_entry* entry)
|
||||
{
|
||||
uint64_t a, b;
|
||||
std::memcpy(&a, (uint8_t*)entry, 8);
|
||||
std::memcpy(&b, (uint8_t*)entry + 8, 8);
|
||||
std::memcpy(&a, reinterpret_cast<const uint8_t*>(entry), 8);
|
||||
std::memcpy(&b, reinterpret_cast<const uint8_t*>(entry) + 8, 8);
|
||||
|
||||
if (a == 0xFFFFFFFFFFFFFFFF && b == 0xFFFFFFFFFFFFFFFF)
|
||||
return true;
|
||||
|
||||
@@ -722,14 +722,14 @@ void* object_manager_get_loaded_object_by_index(size_t index)
|
||||
{
|
||||
auto& objectManager = OpenRCT2::GetContext()->GetObjectManager();
|
||||
Object* loadedObject = objectManager.GetLoadedObject(index);
|
||||
return (void*)loadedObject;
|
||||
return static_cast<void*>(loadedObject);
|
||||
}
|
||||
|
||||
void* object_manager_get_loaded_object(const rct_object_entry* entry)
|
||||
{
|
||||
auto& objectManager = OpenRCT2::GetContext()->GetObjectManager();
|
||||
Object* loadedObject = objectManager.GetLoadedObject(entry);
|
||||
return (void*)loadedObject;
|
||||
return static_cast<void*>(loadedObject);
|
||||
}
|
||||
|
||||
ObjectEntryIndex object_manager_get_loaded_object_entry_index(const void* loadedObject)
|
||||
@@ -744,7 +744,7 @@ void* object_manager_load_object(const rct_object_entry* entry)
|
||||
{
|
||||
auto& objectManager = OpenRCT2::GetContext()->GetObjectManager();
|
||||
Object* loadedObject = objectManager.LoadObject(entry);
|
||||
return (void*)loadedObject;
|
||||
return static_cast<void*>(loadedObject);
|
||||
}
|
||||
|
||||
void object_manager_unload_objects(const rct_object_entry* entries, size_t count)
|
||||
|
||||
@@ -523,7 +523,8 @@ private:
|
||||
chunkHeader.encoding = object_entry_group_encoding[objectType];
|
||||
chunkHeader.length = static_cast<uint32_t>(dataSize);
|
||||
uint8_t* encodedDataBuffer = Memory::Allocate<uint8_t>(0x600000);
|
||||
size_t encodedDataSize = sawyercoding_write_chunk_buffer(encodedDataBuffer, (uint8_t*)data, chunkHeader);
|
||||
size_t encodedDataSize = sawyercoding_write_chunk_buffer(
|
||||
encodedDataBuffer, reinterpret_cast<const uint8_t*>(data), chunkHeader);
|
||||
|
||||
// Save to file
|
||||
try
|
||||
@@ -691,7 +692,7 @@ void* object_repository_load_object(const rct_object_entry* objectEntry)
|
||||
object->Load();
|
||||
}
|
||||
}
|
||||
return (void*)object;
|
||||
return static_cast<void*>(object);
|
||||
}
|
||||
|
||||
void scenario_translate(scenario_index_entry* scenarioEntry)
|
||||
@@ -786,7 +787,7 @@ bool object_entry_compare(const rct_object_entry* a, const rct_object_entry* b)
|
||||
|
||||
int32_t object_calculate_checksum(const rct_object_entry* entry, const void* data, size_t dataLength)
|
||||
{
|
||||
const uint8_t* entryBytePtr = (uint8_t*)entry;
|
||||
const uint8_t* entryBytePtr = reinterpret_cast<const uint8_t*>(entry);
|
||||
|
||||
uint32_t checksum = 0xF369A75B;
|
||||
checksum ^= entryBytePtr[0];
|
||||
@@ -797,7 +798,7 @@ int32_t object_calculate_checksum(const rct_object_entry* entry, const void* dat
|
||||
checksum = rol32(checksum, 11);
|
||||
}
|
||||
|
||||
uint8_t* dataBytes = (uint8_t*)data;
|
||||
const uint8_t* dataBytes = reinterpret_cast<const uint8_t*>(data);
|
||||
const size_t dataLength32 = dataLength - (dataLength & 31);
|
||||
for (size_t i = 0; i < 32; i++)
|
||||
{
|
||||
|
||||
@@ -150,7 +150,7 @@ static paint_struct* sub_9819_c(
|
||||
ps->var_29 = 0;
|
||||
ps->map_x = session->MapPosition.x;
|
||||
ps->map_y = session->MapPosition.y;
|
||||
ps->tileElement = (TileElement*)session->CurrentlyDrawnItem;
|
||||
ps->tileElement = reinterpret_cast<TileElement*>(const_cast<void*>(session->CurrentlyDrawnItem));
|
||||
|
||||
return ps;
|
||||
}
|
||||
@@ -817,7 +817,7 @@ paint_struct* sub_98196C(
|
||||
ps->var_29 = 0;
|
||||
ps->map_x = session->MapPosition.x;
|
||||
ps->map_y = session->MapPosition.y;
|
||||
ps->tileElement = (TileElement*)session->CurrentlyDrawnItem;
|
||||
ps->tileElement = reinterpret_cast<TileElement*>(const_cast<void*>(session->CurrentlyDrawnItem));
|
||||
|
||||
session->LastRootPS = ps;
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ void sprite_paint_setup(paint_session* session, const uint16_t x, const uint16_t
|
||||
{
|
||||
if (spr->generic.Is<Peep>())
|
||||
{
|
||||
Peep* peep = (Peep*)spr;
|
||||
const Peep* peep = reinterpret_cast<const Peep*>(spr);
|
||||
if (!(peep->type == PEEP_TYPE_STAFF && peep->staff_type == STAFF_TYPE_HANDYMAN))
|
||||
{
|
||||
continue;
|
||||
@@ -111,7 +111,7 @@ void sprite_paint_setup(paint_session* session, const uint16_t x, const uint16_t
|
||||
switch (spr->generic.sprite_identifier)
|
||||
{
|
||||
case SPRITE_IDENTIFIER_VEHICLE:
|
||||
vehicle_paint(session, (Vehicle*)spr, image_direction);
|
||||
vehicle_paint(session, reinterpret_cast<const Vehicle*>(spr), image_direction);
|
||||
#ifdef __ENABLE_LIGHTFX__
|
||||
if (lightfx_for_vehicles_is_available())
|
||||
{
|
||||
@@ -120,13 +120,13 @@ void sprite_paint_setup(paint_session* session, const uint16_t x, const uint16_t
|
||||
#endif
|
||||
break;
|
||||
case SPRITE_IDENTIFIER_PEEP:
|
||||
peep_paint(session, (Peep*)spr, image_direction);
|
||||
peep_paint(session, reinterpret_cast<const Peep*>(spr), image_direction);
|
||||
break;
|
||||
case SPRITE_IDENTIFIER_MISC:
|
||||
misc_paint(session, spr, image_direction);
|
||||
break;
|
||||
case SPRITE_IDENTIFIER_LITTER:
|
||||
litter_paint(session, (Litter*)spr, image_direction);
|
||||
litter_paint(session, reinterpret_cast<const Litter*>(spr), image_direction);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
|
||||
@@ -103,7 +103,7 @@ static void large_scenery_sign_fit_text(const utf8* str, rct_large_scenery_text*
|
||||
safe_strcpy(fitStr, str, bufLen);
|
||||
int32_t w = 0;
|
||||
uint32_t codepoint;
|
||||
while (w <= text->max_width && (codepoint = utf8_get_next(fitStrEnd, (const utf8**)&fitStrEnd)) != 0)
|
||||
while (w <= text->max_width && (codepoint = utf8_get_next(fitStrEnd, const_cast<const utf8**>(&fitStrEnd))) != 0)
|
||||
{
|
||||
if (height)
|
||||
{
|
||||
@@ -356,7 +356,7 @@ void large_scenery_paint(paint_session* session, uint8_t direction, uint16_t hei
|
||||
utf8* spacesrc = nullptr;
|
||||
utf8* spacedst = nullptr;
|
||||
int32_t w = 0;
|
||||
uint32_t codepoint = utf8_get_next(src, (const utf8**)&src);
|
||||
uint32_t codepoint = utf8_get_next(src, const_cast<const utf8**>(&src));
|
||||
do
|
||||
{
|
||||
w += large_scenery_sign_get_glyph(text, codepoint)->width;
|
||||
@@ -367,7 +367,7 @@ void large_scenery_paint(paint_session* session, uint8_t direction, uint16_t hei
|
||||
}
|
||||
} while (w <= text->max_width && (dst = utf8_write_codepoint(dst, codepoint)) != nullptr
|
||||
&& (srcold = src) != nullptr
|
||||
&& (codepoint = utf8_get_next(src, (const utf8**)&src)) != '\0');
|
||||
&& (codepoint = utf8_get_next(src, const_cast<const utf8**>(&src))) != '\0');
|
||||
src = srcold;
|
||||
if (spacesrc && codepoint)
|
||||
{
|
||||
|
||||
@@ -280,8 +280,9 @@ struct RCT12TileElement : public RCT12TileElementBase
|
||||
uint8_t pad_04[4];
|
||||
template<typename TType, RCT12TileElementType TClass> TType* as() const
|
||||
{
|
||||
// TODO: CAST-IMPROVEMENT-NEEDED
|
||||
return static_cast<RCT12TileElementType>(GetType()) == TClass ? (TType*)this : nullptr;
|
||||
return static_cast<RCT12TileElementType>(GetType()) == TClass
|
||||
? reinterpret_cast<TType*>(const_cast<RCT12TileElement*>(this))
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
RCT12SurfaceElement* AsSurface() const
|
||||
|
||||
@@ -178,7 +178,7 @@ void S6Exporter::Export()
|
||||
const rct_object_entry* entry = get_loaded_object_entry(i);
|
||||
void* entryData = get_loaded_object_chunk(i);
|
||||
// RCT2 uses (void *)-1 to mark NULL. Make sure it's written in a vanilla-compatible way.
|
||||
if (entryData == nullptr || entryData == (void*)-1)
|
||||
if (entryData == nullptr || entryData == reinterpret_cast<void*>(-1))
|
||||
{
|
||||
std::memset(&_s6.objects[i], 0xFF, sizeof(rct_object_entry));
|
||||
}
|
||||
|
||||
@@ -836,7 +836,7 @@ namespace OpenRCT2::Scripting
|
||||
{
|
||||
for (size_t i = 0; i < std::size(entry->vehicles); i++)
|
||||
{
|
||||
result.push_back(std::make_shared<ScRideObjectVehicle>((OBJECT_TYPE)_type, _index, i));
|
||||
result.push_back(std::make_shared<ScRideObjectVehicle>(static_cast<OBJECT_TYPE>(_type), _index, i));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1095,7 +1095,8 @@ void ScriptEngine::LoadSharedStorage()
|
||||
if (File::Exists(path))
|
||||
{
|
||||
auto data = File::ReadAllBytes(path);
|
||||
auto result = DuktapeTryParseJson(_context, std::string_view((const char*)data.data(), data.size()));
|
||||
auto result = DuktapeTryParseJson(
|
||||
_context, std::string_view(reinterpret_cast<const char*>(data.data()), data.size()));
|
||||
if (result)
|
||||
{
|
||||
_sharedStorage = std::move(*result);
|
||||
|
||||
@@ -105,8 +105,8 @@ struct TileElement : public TileElementBase
|
||||
|
||||
template<typename TType, TileElementType TClass> TType* as() const
|
||||
{
|
||||
// TODO: CAST-IMPROVEMENT-NEEDED
|
||||
return static_cast<TileElementType>(GetType()) == TClass ? (TType*)this : nullptr;
|
||||
return static_cast<TileElementType>(GetType()) == TClass ? reinterpret_cast<TType*>(const_cast<TileElement*>(this))
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Reference in new issue
Block a user