less serialize code

This commit is contained in:
2025-08-01 13:21:31 +02:00
parent fa663d0481
commit ced20ca991
15 changed files with 38 additions and 30 deletions

View File

@@ -61,7 +61,7 @@ class World {
TilePtr GetTilePtr(TileIndex index) const {
if (index == 0)
return nullptr;
return TilePtr(nullptr);
return m_TilePalette.at(index - 1);
}

View File

@@ -67,7 +67,7 @@ using TileFactory = sp::MessageFactory<Tile, AllTiles>;
class TileHandler : public sp::GenericHandler<AllTiles> {};
using TilePtr = std::shared_ptr<sp::SerializableMessage<TileFactory>>;
using TilePtr = sp::SerializableMessage<TileFactory>;
// typedef std::shared_ptr<Tile> TilePtr;
typedef std::vector<std::uint16_t> ChunkPalette;

View File

@@ -7,7 +7,6 @@
#include <memory>
#include <sp/common/GenericHandler.h>
#include <sp/io/SerializableMessage.h>
#include <sp/protocol/ConcreteMessage.h>
#include <sp/protocol/MessageDispatcher.h>
#include <sp/protocol/MessageFactory.h>
@@ -15,6 +14,8 @@
#include <td/common/NonCopyable.h>
#include <td/protocol/command/CommandData.h>
#include <sp/io/SerializableMessage.h>
namespace td {
namespace protocol {
@@ -58,9 +59,9 @@ using CommandDispatcher = sp::MessageDispatcher<CommandBase>;
using CommandFactory = sp::MessageFactory<CommandBase, AllCommands>;
using LockStep = std::vector<std::shared_ptr<CommandBase>>;
using CommandPtr = sp::SerializableMessage<CommandFactory>;
using CommandPtr = std::unique_ptr<sp::SerializableMessage<CommandFactory>>;
using LockStep = std::vector<CommandPtr>;
} // namespace protocol
} // namespace td

View File

@@ -74,7 +74,7 @@ struct BeginGame {
struct LockSteps {
std::uint16_t m_FirstFrameNumber;
Array<LockStep, LOCKSTEP_BUFFER_SIZE> m_LockSteps;
std::array<LockStep, LOCKSTEP_BUFFER_SIZE> m_LockSteps;
};
struct WorldHeader {

View File

@@ -40,8 +40,8 @@ namespace game {
sp::DataBuffer& operator<<(sp::DataBuffer& a_Buffer, const TeamCastle& a_Castle);
sp::DataBuffer& operator>>(sp::DataBuffer& a_Buffer, TeamCastle& a_Castle);
sp::DataBuffer& operator<<(sp::DataBuffer& a_Buffer, const ChunkPtr& a_Chunk);
sp::DataBuffer& operator>>(sp::DataBuffer& a_Buffer, ChunkPtr& a_Chunk);
sp::DataBuffer& operator<<(sp::DataBuffer& a_Buffer, const Spawn& a_Spawn);
sp::DataBuffer& operator>>(sp::DataBuffer& a_Buffer, Spawn& a_Spawn);
} // namespace game
} // namespace td

View File

@@ -28,7 +28,7 @@ class RealTimeSimulation {
* \brief Replay constructor
* \param a_StepTime in ms
*/
RealTimeSimulation(game::World& a_World, const GameHistory& a_History, std::uint64_t a_StepTime);
RealTimeSimulation(game::World& a_World, GameHistory&& a_History, std::uint64_t a_StepTime);
/**
* \brief Live update constructor (continuous game updates)