remove WorldApply
This commit is contained in:
@@ -29,24 +29,6 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
// TODO: get rid of this class
|
|
||||||
class WorldApply : public protocol::PacketHandler {
|
|
||||||
private:
|
|
||||||
game::World& m_World;
|
|
||||||
using protocol::PacketHandler::Handle;
|
|
||||||
|
|
||||||
public:
|
|
||||||
WorldApply(game::World& a_World) : m_World(a_World) {}
|
|
||||||
|
|
||||||
void Handle(const protocol::packets::WorldHeaderPacket& a_Header) override {
|
|
||||||
m_World.LoadMap(*a_Header);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Handle(const protocol::packets::WorldDataPacket& a_Data) override {
|
|
||||||
m_World.LoadMap(*a_Data);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void Save(const protocol::PacketBase& header, const protocol::PacketBase& data) {
|
void Save(const protocol::PacketBase& header, const protocol::PacketBase& data) {
|
||||||
auto comp = std::make_shared<sp::ZlibCompress>();
|
auto comp = std::make_shared<sp::ZlibCompress>();
|
||||||
|
|
||||||
@@ -67,19 +49,15 @@ game::WorldPtr GetWorld() {
|
|||||||
|
|
||||||
sp::MessageStream<protocol::PacketFactory> stream(std::move(out), std::move(comp));
|
sp::MessageStream<protocol::PacketFactory> stream(std::move(out), std::move(comp));
|
||||||
|
|
||||||
auto header = stream.ReadMessage(protocol::PacketID::WorldHeader);
|
auto header = stream.ReadConcreteMessage<protocol::packets::WorldHeaderPacket>();
|
||||||
auto data = stream.ReadMessage(protocol::PacketID::WorldData);
|
auto data = stream.ReadConcreteMessage<protocol::packets::WorldDataPacket>();
|
||||||
|
|
||||||
auto w = std::make_shared<game::World>();
|
auto w = std::make_shared<game::World>();
|
||||||
auto wa = std::make_shared<WorldApply>(*w);
|
|
||||||
|
|
||||||
protocol::PacketDispatcher d;
|
w->LoadMap(**header);
|
||||||
d.RegisterHandler(wa);
|
w->LoadMap(**data);
|
||||||
|
|
||||||
d.Dispatch(*header);
|
// Save(*header, *data);
|
||||||
d.Dispatch(*data);
|
|
||||||
|
|
||||||
Save(*header, *data);
|
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ add_rules("mode.debug", "mode.release")
|
|||||||
add_repositories("persson-repo https://git.ale-pri.com/Persson-dev/xmake-repo.git")
|
add_repositories("persson-repo https://git.ale-pri.com/Persson-dev/xmake-repo.git")
|
||||||
|
|
||||||
add_requires("imgui 1.92.0", {configs = {sdl3 = true, opengl3 = true}})
|
add_requires("imgui 1.92.0", {configs = {sdl3 = true, opengl3 = true}})
|
||||||
add_requires("libsdl3 3.2.16", "splib 2.3.0", "zlib", "glew", "fpm", "enet6")
|
add_requires("libsdl3 3.2.16", "splib 2.3.1", "zlib", "glew", "fpm", "enet6")
|
||||||
|
|
||||||
set_languages("c++17")
|
set_languages("c++17")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user