summaryrefslogtreecommitdiffstats
path: root/src/GlobalState.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-01-13 10:58:40 +0100
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-01-13 10:58:40 +0100
commitabe317e31bb9b9a88b0c88b1477a952240d1847f (patch)
treead9e706d4ecb3237b62a05bd3f408fdc87a7dcff /src/GlobalState.cpp
parentNew implementation of NC is using event-system (diff)
downloadAltCraft-abe317e31bb9b9a88b0c88b1477a952240d1847f.tar
AltCraft-abe317e31bb9b9a88b0c88b1477a952240d1847f.tar.gz
AltCraft-abe317e31bb9b9a88b0c88b1477a952240d1847f.tar.bz2
AltCraft-abe317e31bb9b9a88b0c88b1477a952240d1847f.tar.lz
AltCraft-abe317e31bb9b9a88b0c88b1477a952240d1847f.tar.xz
AltCraft-abe317e31bb9b9a88b0c88b1477a952240d1847f.tar.zst
AltCraft-abe317e31bb9b9a88b0c88b1477a952240d1847f.zip
Diffstat (limited to 'src/GlobalState.cpp')
-rw-r--r--src/GlobalState.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/GlobalState.cpp b/src/GlobalState.cpp
index f04bb35..57b42ea 100644
--- a/src/GlobalState.cpp
+++ b/src/GlobalState.cpp
@@ -64,6 +64,11 @@ void InitEvents() {
PUSH_EVENT("Disconnect", data);
});
+ listener.RegisterHandler("ReceivedPacket", [](const Event& eventData) {
+ std::shared_ptr<Packet> packet = eventData.get<std::shared_ptr<Packet>>();
+ gs->UpdatePacket(packet);
+ });
+
/*
* GameState Events
*/
@@ -88,7 +93,8 @@ void InitEvents() {
listener.RegisterHandler("SendChatMessage", [](const Event& eventData) {
auto message = eventData.get<std::string>();
- nc->SendPacket(std::make_shared<PacketChatMessageSB>(message));
+ auto packet = std::static_pointer_cast<Packet>(std::make_shared<PacketChatMessageSB>(message));
+ PUSH_EVENT("SendPacket",packet);
});
}
@@ -183,9 +189,6 @@ void GsExec() {
while (isRunning) {
try {
while (nc && gs) {
- nc->UpdatePacket();
-
- gs->UpdatePacket(nc.get());
listener.HandleAllEvents();
}
} catch (std::exception &e) {