forked from rosebudai/OpenRCT2-Web
Remove some redundant casts and fix rct_sprite::AsDuck()
This commit is contained in:
1 parent
c8c9bf70a7
commit
d481cca2ed
15 files changed
+33
-35
No files matched your search
@@ -138,8 +138,6 @@ static void window_track_place_clear_mini_preview()
|
||||
std::fill(_window_track_place_mini_preview.begin(), _window_track_place_mini_preview.end(), PALETTE_INDEX_TRANSPARENT);
|
||||
}
|
||||
|
||||
#define swap(x, y) x = x ^ y; y = x ^ y; x = x ^ y;
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006CFCA0
|
||||
|
||||
@@ -544,7 +544,7 @@ static sint32 game_check_affordability(sint32 cost)
|
||||
return cost;
|
||||
if (gUnk141F568 & 0xF0)
|
||||
return cost;
|
||||
if (cost <= (sint32) gCash)
|
||||
if (cost <= gCash)
|
||||
return cost;
|
||||
|
||||
set_format_arg(0, uint32, cost);
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Imaging
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
|
||||
|
||||
// Return the output data
|
||||
*pixels = (uint8*)pngPixels;
|
||||
*pixels = pngPixels;
|
||||
if (width != nullptr) *width = pngWidth;
|
||||
if (height != nullptr) *height = pngHeight;
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ void park_importer_load_from_stream(void * stream_c, const utf8 * hintPath_c)
|
||||
bool isScenario = ParkImporter::ExtensionIsScenario(hintPath);
|
||||
|
||||
auto parkImporter = std::unique_ptr<IParkImporter>(ParkImporter::Create(hintPath));
|
||||
parkImporter->LoadFromStream((IStream *)stream, isScenario);
|
||||
parkImporter->LoadFromStream(stream, isScenario);
|
||||
parkImporter->Import();
|
||||
}
|
||||
|
||||
|
||||
@@ -700,7 +700,7 @@ void FASTCALL gfx_draw_sprite_palette_set_software(rct_drawpixelinfo *dpi, sint3
|
||||
|
||||
dest_start_x >>= zoom_level;
|
||||
|
||||
uint8* dest_pointer = (uint8*)dpi->bits;
|
||||
uint8* dest_pointer = dpi->bits;
|
||||
// Move the pointer to the start point of the destination
|
||||
dest_pointer += ((dpi->width >> zoom_level) + dpi->pitch) * dest_start_y + dest_start_x;
|
||||
|
||||
|
||||
@@ -438,10 +438,10 @@ void X8DrawingEngine::DrawDirtyBlocks(uint32 x, uint32 y, uint32 columns, uint32
|
||||
uint8 * screenDirtyBlocks = _dirtyGrid.Blocks;
|
||||
|
||||
// Unset dirty blocks
|
||||
for (uint32 top = y; top < y + (uint32)rows; top++)
|
||||
for (uint32 top = y; top < y + rows; top++)
|
||||
{
|
||||
uint32 topOffset = top * dirtyBlockColumns;
|
||||
for (uint32 left = x; left < x + (uint32)columns; left++)
|
||||
for (uint32 left = x; left < x + columns; left++)
|
||||
{
|
||||
screenDirtyBlocks[topOffset + left] = 0;
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ const char* Network::FormatChat(NetworkPlayer* fromplayer, const char* text)
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_WHITE);
|
||||
char* ptrtext = lineCh;
|
||||
safe_strcpy(lineCh, text, 800);
|
||||
utf8_remove_format_codes((utf8*)ptrtext, true);
|
||||
utf8_remove_format_codes(ptrtext, true);
|
||||
return formatted;
|
||||
}
|
||||
|
||||
@@ -1070,7 +1070,7 @@ void Network::Server_Send_AUTH(NetworkConnection& connection)
|
||||
new_playerid = connection.Player->Id;
|
||||
}
|
||||
std::unique_ptr<NetworkPacket> packet(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_AUTH << (uint32)connection.AuthStatus << (uint8)new_playerid;
|
||||
*packet << (uint32)NETWORK_COMMAND_AUTH << (uint32)connection.AuthStatus << new_playerid;
|
||||
if (connection.AuthStatus == NETWORK_AUTH_BADVERSION) {
|
||||
packet->WriteString(NETWORK_STREAM_ID);
|
||||
}
|
||||
@@ -1180,7 +1180,7 @@ void Network::Server_Send_CHAT(const char* text)
|
||||
void Network::Client_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp, uint8 callback)
|
||||
{
|
||||
std::unique_ptr<NetworkPacket> packet(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)gCurrentTicks << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED)
|
||||
*packet << (uint32)NETWORK_COMMAND_GAMECMD << gCurrentTicks << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED)
|
||||
<< ecx << edx << esi << edi << ebp << callback;
|
||||
server_connection->QueuePacket(std::move(packet));
|
||||
}
|
||||
@@ -1188,7 +1188,7 @@ void Network::Client_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx
|
||||
void Network::Server_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp, uint8 playerid, uint8 callback)
|
||||
{
|
||||
std::unique_ptr<NetworkPacket> packet(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)gCurrentTicks << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED)
|
||||
*packet << (uint32)NETWORK_COMMAND_GAMECMD << gCurrentTicks << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED)
|
||||
<< ecx << edx << esi << edi << ebp << playerid << callback;
|
||||
SendPacketToClients(*packet, false, true);
|
||||
}
|
||||
@@ -1210,7 +1210,7 @@ void Network::Client_Send_GAME_ACTION(const GameAction *action)
|
||||
DataSerialiser stream(true);
|
||||
action->Serialise(stream);
|
||||
|
||||
*packet << (uint32)NETWORK_COMMAND_GAME_ACTION << (uint32)gCurrentTicks << action->GetType() << stream;
|
||||
*packet << (uint32)NETWORK_COMMAND_GAME_ACTION << gCurrentTicks << action->GetType() << stream;
|
||||
|
||||
server_connection->QueuePacket(std::move(packet));
|
||||
}
|
||||
@@ -1222,7 +1222,7 @@ void Network::Server_Send_GAME_ACTION(const GameAction *action)
|
||||
DataSerialiser stream(true);
|
||||
action->Serialise(stream);
|
||||
|
||||
*packet << (uint32)NETWORK_COMMAND_GAME_ACTION << (uint32)gCurrentTicks << action->GetType() << stream;
|
||||
*packet << (uint32)NETWORK_COMMAND_GAME_ACTION << gCurrentTicks << action->GetType() << stream;
|
||||
|
||||
SendPacketToClients(*packet);
|
||||
}
|
||||
@@ -1238,7 +1238,7 @@ void Network::Server_Send_TICK()
|
||||
last_tick_sent_time = ticks;
|
||||
|
||||
std::unique_ptr<NetworkPacket> packet(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_TICK << (uint32)gCurrentTicks << (uint32)gScenarioSrand0;
|
||||
*packet << (uint32)NETWORK_COMMAND_TICK << gCurrentTicks << gScenarioSrand0;
|
||||
uint32 flags = 0;
|
||||
// Simple counter which limits how often a sprite checksum gets sent.
|
||||
// This can get somewhat expensive, so we don't want to push it every tick in release,
|
||||
@@ -1877,7 +1877,7 @@ void Network::Server_Handle_AUTH(NetworkConnection& connection, NetworkPacket& p
|
||||
const char* gameversion = packet.ReadString();
|
||||
const char* name = packet.ReadString();
|
||||
const char* password = packet.ReadString();
|
||||
const char *pubkey = (const char *)packet.ReadString();
|
||||
const char *pubkey = packet.ReadString();
|
||||
uint32 sigsize;
|
||||
packet >> sigsize;
|
||||
if (pubkey == nullptr) {
|
||||
@@ -2737,7 +2737,7 @@ void network_chat_show_server_greeting()
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_GREEN);
|
||||
char* ptrtext = lineCh;
|
||||
safe_strcpy(lineCh, greeting, CHAT_INPUT_SIZE - 24); // Limit to 1000 characters so we don't overflow the buffer
|
||||
utf8_remove_format_codes((utf8*)ptrtext, true);
|
||||
utf8_remove_format_codes(ptrtext, true);
|
||||
chat_history_add(greeting_formatted);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ public:
|
||||
{
|
||||
const char * bufferStart = (const char *)buffer + totalSent;
|
||||
size_t remainingSize = size - totalSent;
|
||||
sint32 sentBytes = send(_socket, (const char *)bufferStart, (sint32)remainingSize, FLAG_NO_PIPE);
|
||||
sint32 sentBytes = send(_socket, bufferStart, (sint32)remainingSize, FLAG_NO_PIPE);
|
||||
if (sentBytes == SOCKET_ERROR)
|
||||
{
|
||||
return totalSent;
|
||||
|
||||
@@ -340,12 +340,12 @@ void RideObject::SetRepositoryItem(ObjectRepositoryItem * item) const
|
||||
item->RideFlags = flags;
|
||||
|
||||
// Find the first non-null ride type, to be used when checking the ride group
|
||||
uint8 rideTypeIdx = ride_entry_get_first_non_null_ride_type((rct_ride_entry *)&_legacyType);
|
||||
uint8 rideTypeIdx = ride_entry_get_first_non_null_ride_type(&_legacyType);
|
||||
|
||||
// Determines the ride group. Will fall back to 0 if there is none found.
|
||||
uint8 rideGroupIndex = 0;
|
||||
|
||||
const RideGroup * rideGroup = RideGroupManager::GetRideGroup(rideTypeIdx, (rct_ride_entry *)&_legacyType);
|
||||
const RideGroup * rideGroup = RideGroupManager::GetRideGroup(rideTypeIdx, &_legacyType);
|
||||
|
||||
// If the ride group is nullptr, the track type does not have ride groups.
|
||||
if (rideGroup != nullptr)
|
||||
|
||||
@@ -979,8 +979,8 @@ paint_struct * sub_98198C(
|
||||
sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z,
|
||||
uint32 rotation)
|
||||
{
|
||||
assert((uint16)bound_box_length_x == (sint16)bound_box_length_x);
|
||||
assert((uint16)bound_box_length_y == (sint16)bound_box_length_y);
|
||||
assert((uint16)bound_box_length_x == bound_box_length_x);
|
||||
assert((uint16)bound_box_length_y == bound_box_length_y);
|
||||
|
||||
session->UnkF1AD28 = nullptr;
|
||||
session->UnkF1AD2C = nullptr;
|
||||
|
||||
@@ -9983,7 +9983,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep
|
||||
* current search path ends here.
|
||||
* Return without updating the parameters (best result so far). */
|
||||
if ((_peepPathFindHistory[0].location.x == (uint8)(x >> 5)) && (_peepPathFindHistory[0].location.y == (uint8)(y >> 5)) &&
|
||||
(_peepPathFindHistory[0].location.z == (uint8)z))
|
||||
(_peepPathFindHistory[0].location.z == z))
|
||||
{
|
||||
#if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2
|
||||
if (gPathFindDebug)
|
||||
@@ -10398,7 +10398,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep
|
||||
{
|
||||
if ((_peepPathFindHistory[junctionNum].location.x == (uint8)(x >> 5)) &&
|
||||
(_peepPathFindHistory[junctionNum].location.y == (uint8)(y >> 5)) &&
|
||||
(_peepPathFindHistory[junctionNum].location.z == (uint8)z))
|
||||
(_peepPathFindHistory[junctionNum].location.z == z))
|
||||
{
|
||||
pathLoop = true;
|
||||
break;
|
||||
@@ -10459,7 +10459,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep
|
||||
* search path, so add the junction to the history. */
|
||||
_peepPathFindHistory[_peepPathFindNumJunctions].location.x = (uint8)(x >> 5);
|
||||
_peepPathFindHistory[_peepPathFindNumJunctions].location.y = (uint8)(y >> 5);
|
||||
_peepPathFindHistory[_peepPathFindNumJunctions].location.z = (uint8)z;
|
||||
_peepPathFindHistory[_peepPathFindNumJunctions].location.z = z;
|
||||
// .direction take is added below.
|
||||
|
||||
_peepPathFindNumJunctions--;
|
||||
@@ -10763,7 +10763,7 @@ sint32 peep_pathfind_choose_direction(sint16 x, sint16 y, uint8 z, rct_peep * pe
|
||||
* is placed in element 0 */
|
||||
_peepPathFindHistory[0].location.x = (uint8)(x >> 5);
|
||||
_peepPathFindHistory[0].location.y = (uint8)(y >> 5);
|
||||
_peepPathFindHistory[0].location.z = (uint8)z;
|
||||
_peepPathFindHistory[0].location.z = z;
|
||||
_peepPathFindHistory[0].direction = 0xF;
|
||||
|
||||
uint16 score = 0xFFFF;
|
||||
|
||||
@@ -62,7 +62,7 @@ char * strndup(const char * src, size_t size)
|
||||
|
||||
dst = (char *)memcpy(dst, src, len);
|
||||
dst[len] = '\0';
|
||||
return (char *)dst;
|
||||
return dst;
|
||||
}
|
||||
#endif // !((defined (_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700))
|
||||
|
||||
|
||||
@@ -3781,7 +3781,7 @@ static bool ride_is_valid_lift_hill_speed(Ride *ride, sint32 speed)
|
||||
return speed >= minSpeed && speed <= maxSpeed;
|
||||
}
|
||||
|
||||
static bool ride_is_valid_num_circuits(Ride *ride, sint32 numCircuits)
|
||||
static bool ride_is_valid_num_circuits(sint32 numCircuits)
|
||||
{
|
||||
sint32 minNumCircuits = 1;
|
||||
sint32 maxNumCircuits = gCheatsFastLiftHill ? 255 : 20;
|
||||
@@ -3924,7 +3924,7 @@ static money32 ride_set_setting(uint8 rideIndex, uint8 setting, uint8 value, uin
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (!ride_is_valid_num_circuits(ride, value)) {
|
||||
if (!ride_is_valid_num_circuits(value)) {
|
||||
log_warning("Invalid number of circuits.");
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
@@ -4921,7 +4921,7 @@ static void vehicle_update_rotating(rct_vehicle * vehicle)
|
||||
timeToSpriteMap = Rotation3TimeToSpriteMaps[vehicle->sub_state];
|
||||
}
|
||||
|
||||
sint32 time = (sint16)vehicle->current_time;
|
||||
sint32 time = vehicle->current_time;
|
||||
if (_vehicleBreakdown == BREAKDOWN_CONTROL_FAILURE)
|
||||
{
|
||||
time += (ride->breakdown_sound_modifier >> 6) + 1;
|
||||
@@ -5462,8 +5462,7 @@ static void vehicle_update_crash(rct_vehicle * vehicle)
|
||||
|
||||
invalidate_sprite_2((rct_sprite *)curVehicle);
|
||||
|
||||
LocationXYZ16 curPosition = { static_cast<sint16>(curVehicle->x), static_cast<sint16>(curVehicle->y),
|
||||
static_cast<sint16>(curVehicle->z) };
|
||||
LocationXYZ16 curPosition = {curVehicle->x, curVehicle->y, curVehicle->z};
|
||||
|
||||
curPosition.x += (sint8)(curVehicle->crash_x >> 8);
|
||||
curPosition.y += (sint8)(curVehicle->crash_y >> 8);
|
||||
@@ -9446,7 +9445,7 @@ loc_6DCEFF:
|
||||
|
||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING)
|
||||
{
|
||||
vehicle->spin_speed = Math::Clamp(static_cast<sint16>(-VEHICLE_MAX_SPIN_SPEED_WATER_RIDE), (sint16)vehicle->spin_speed, static_cast<sint16>(VEHICLE_MAX_SPIN_SPEED_WATER_RIDE));
|
||||
vehicle->spin_speed = Math::Clamp(static_cast<sint16>(-VEHICLE_MAX_SPIN_SPEED_WATER_RIDE), vehicle->spin_speed, static_cast<sint16>(VEHICLE_MAX_SPIN_SPEED_WATER_RIDE));
|
||||
}
|
||||
|
||||
if (vehicle->vehicle_sprite_type != 0)
|
||||
@@ -9562,7 +9561,8 @@ static void vehicle_update_track_motion_powered_ride_acceleration(rct_vehicle *
|
||||
|
||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING)
|
||||
{
|
||||
vehicle->spin_speed = Math::Clamp(static_cast<sint16>(-VEHICLE_MAX_SPIN_SPEED_WATER_RIDE), (sint16)vehicle->spin_speed, static_cast<sint16>(VEHICLE_MAX_SPIN_SPEED_WATER_RIDE));
|
||||
vehicle->spin_speed = Math::Clamp(static_cast<sint16>(-VEHICLE_MAX_SPIN_SPEED_WATER_RIDE),
|
||||
vehicle->spin_speed, static_cast<sint16>(VEHICLE_MAX_SPIN_SPEED_WATER_RIDE));
|
||||
}
|
||||
|
||||
if (vehicle->vehicle_sprite_type != 0)
|
||||
|
||||
@@ -88,7 +88,7 @@ rct_duck * rct_sprite::AsDuck()
|
||||
rct_duck * result = nullptr;
|
||||
if (IsDuck())
|
||||
{
|
||||
return (rct_duck *)result;
|
||||
return (rct_duck *)this;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user