mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
Refactor. Add CoordsXY to data serialiser
This commit is contained in:
@@ -23,23 +23,6 @@
|
||||
#include "../world/Surface.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00663CB9
|
||||
*/
|
||||
static int32_t map_set_land_height_clear_func(
|
||||
TileElement** tile_element, [[maybe_unused]] int32_t x, [[maybe_unused]] int32_t y, [[maybe_unused]] uint8_t flags,
|
||||
[[maybe_unused]] money32* price)
|
||||
{
|
||||
if ((*tile_element)->GetType() == TILE_ELEMENT_TYPE_SURFACE)
|
||||
return 0;
|
||||
|
||||
if ((*tile_element)->GetType() == TILE_ELEMENT_TYPE_SMALL_SCENERY)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEFINE_GAME_ACTION(LandSetHeightAction, GAME_COMMAND_SET_LAND_HEIGHT, GameActionResult)
|
||||
{
|
||||
private:
|
||||
@@ -67,7 +50,7 @@ public:
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_coords.x) << DS_TAG(_coords.y) << DS_TAG(_height) << DS_TAG(_style);
|
||||
stream << DS_TAG(_coords) << DS_TAG(_height) << DS_TAG(_style);
|
||||
}
|
||||
|
||||
GameActionResult::Ptr Query() const override
|
||||
@@ -382,4 +365,21 @@ private:
|
||||
|
||||
map_invalidate_tile_full(_coords.x, _coords.y);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00663CB9
|
||||
*/
|
||||
static int32_t map_set_land_height_clear_func(
|
||||
TileElement * *tile_element, [[maybe_unused]] int32_t x, [[maybe_unused]] int32_t y, [[maybe_unused]] uint8_t flags,
|
||||
[[maybe_unused]] money32 * price)
|
||||
{
|
||||
if ((*tile_element)->GetType() == TILE_ELEMENT_TYPE_SURFACE)
|
||||
return 0;
|
||||
|
||||
if ((*tile_element)->GetType() == TILE_ELEMENT_TYPE_SMALL_SCENERY)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -321,3 +321,25 @@ template<> struct DataSerializerTraits<MapRange>
|
||||
stream->Write(coords, strlen(coords));
|
||||
}
|
||||
};
|
||||
|
||||
template<> struct DataSerializerTraits<CoordsXY>
|
||||
{
|
||||
static void encode(IStream* stream, const CoordsXY& coords)
|
||||
{
|
||||
stream->WriteValue(ByteSwapBE(coords.x));
|
||||
stream->WriteValue(ByteSwapBE(coords.y));
|
||||
}
|
||||
static void decode(IStream* stream, CoordsXY& coords)
|
||||
{
|
||||
auto x = ByteSwapBE(stream->ReadValue<int16_t>());
|
||||
auto y = ByteSwapBE(stream->ReadValue<int16_t>());
|
||||
coords = CoordsXY(x, y);
|
||||
}
|
||||
static void log(IStream* stream, const CoordsXY& coords)
|
||||
{
|
||||
char msg[128] = {};
|
||||
snprintf(msg, sizeof(msg), "CoordsXY(x = %d, y = %d)", coords.x, coords.y);
|
||||
|
||||
stream->Write(msg, strlen(msg));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user