Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/StarNetPackets.cpp
diff options
context:
space:
mode:
authorErodeesFleurs <3353309908@qq.com>2024-03-19 12:46:50 +0800
committerErodeesFleurs <3353309908@qq.com>2024-03-19 12:46:50 +0800
commitb85637783352db64970722c904c702ef81a40635 (patch)
tree06d224f39f95dc17249af4e7727a5ba1e01bce16 /source/game/StarNetPackets.cpp
parent17ea975970d8f2be994bb1c8e7646f9c8a6c4647 (diff)
add sendPacket lua context
Diffstat (limited to 'source/game/StarNetPackets.cpp')
-rw-r--r--source/game/StarNetPackets.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/game/StarNetPackets.cpp b/source/game/StarNetPackets.cpp
index 12b1c74..26203d6 100644
--- a/source/game/StarNetPackets.cpp
+++ b/source/game/StarNetPackets.cpp
@@ -167,6 +167,22 @@ PacketPtr createPacket(PacketType type) {
}
}
+PacketPtr createPacket(PacketType type, JsonArray const& args) {
+ switch (type) {
+ case PacketType::Pause: return make_shared<PausePacket>(args[0].toBool());
+ case PacketType::ServerInfo: return make_shared<ServerInfoPacket>(args[0].toUInt(), args[1].toUInt());
+ case PacketType::GiveItem: return make_shared<GiveItemPacket>(ItemDescriptor(args[0]));
+ case PacketType::UpdateTileProtection: return make_shared<UpdateTileProtectionPacket>(args[0].toUInt(), args[1].toBool());
+ case PacketType::SetDungeonGravity: return make_shared<SetDungeonGravityPacket>(args[0].toUInt(), args[0].toFloat());
+ case PacketType::SetDungeonBreathable: return make_shared<SetDungeonBreathablePacket>(args[0].toUInt(), args[0].toBool());
+ case PacketType::SetPlayerStart: return make_shared<SetPlayerStartPacket>(Vec2F{args[0].toArray()[0].toFloat(), args[0].toArray()[0].toFloat()}, args[1].toBool());
+ case PacketType::EntityMessage: return make_shared<EntityMessagePacket>(EntityId(args[0].toUInt()), args[1].toString(), args[2].toArray(), Uuid(args[3].toString()));
+ case PacketType::UpdateWorldProperties: return make_shared<UpdateWorldPropertiesPacket>(args[0].toObject());
+ default:
+ throw StarPacketException(strf("Unrecognized packet type {}", (unsigned int)type));
+ }
+}
+
ProtocolRequestPacket::ProtocolRequestPacket()
: requestProtocolVersion(0) {}