From d50cf5b91e98bce38632e25b330bb9368d141cb8 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Wed, 3 Sep 2014 00:45:08 +1000 Subject: [PATCH] Fixed shoddy packet typing --- client/scenes/in_world.cpp | 5 +++-- client/scenes/in_world.hpp | 2 +- common/network/serial_utility.cpp | 2 ++ server/server_application.hpp | 4 ++-- server/server_logic.cpp | 4 ++-- server/server_methods.cpp | 6 +++--- todo.txt | 13 +++++-------- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/client/scenes/in_world.cpp b/client/scenes/in_world.cpp index f78103f..ac7b255 100644 --- a/client/scenes/in_world.cpp +++ b/client/scenes/in_world.cpp @@ -271,7 +271,7 @@ void InWorld::KeyUp(SDL_KeyboardEvent const& key) { void InWorld::HandlePacket(SerialPacket* const argPacket) { switch(argPacket->type) { case SerialPacketType::DISCONNECT: - HandleDisconnect(argPacket); + HandleDisconnect(static_cast(argPacket)); break; case SerialPacketType::CHARACTER_NEW: HandleCharacterNew(static_cast(argPacket)); @@ -292,7 +292,8 @@ void InWorld::HandlePacket(SerialPacket* const argPacket) { } } -void InWorld::HandleDisconnect(SerialPacket* const argPacket) { +void InWorld::HandleDisconnect(ClientPacket* const argPacket) { + //TODO: More needed in the disconnection SetNextScene(SceneList::CLEANUP); } diff --git a/client/scenes/in_world.hpp b/client/scenes/in_world.hpp index 517b86a..633ffc0 100644 --- a/client/scenes/in_world.hpp +++ b/client/scenes/in_world.hpp @@ -75,7 +75,7 @@ protected: //Network handlers void HandlePacket(SerialPacket* const); - void HandleDisconnect(SerialPacket* const); + void HandleDisconnect(ClientPacket* const); void HandleCharacterNew(CharacterPacket* const); void HandleCharacterDelete(CharacterPacket* const); void HandleCharacterUpdate(CharacterPacket* const); diff --git a/common/network/serial_utility.cpp b/common/network/serial_utility.cpp index f43d312..6f70999 100644 --- a/common/network/serial_utility.cpp +++ b/common/network/serial_utility.cpp @@ -40,6 +40,8 @@ void deserialCopy(void** buffer, void* data, int size) { *buffer = reinterpret_cast(*buffer) + size; } +//DOCS: The server and client MUST use the correct packet types + //main switch functions void serializePacket(void* buffer, SerialPacketBase* packet) { switch(packet->type) { diff --git a/server/server_application.hpp b/server/server_application.hpp index ecd08ab..acccb5c 100644 --- a/server/server_application.hpp +++ b/server/server_application.hpp @@ -61,10 +61,10 @@ private: void HandlePacket(SerialPacket* const); //basic connections - void HandleBroadcastRequest(SerialPacket* const); + void HandleBroadcastRequest(ServerPacket* const); void HandleJoinRequest(ClientPacket* const); void HandleDisconnect(ClientPacket* const); - void HandleShutdown(SerialPacket* const); + void HandleShutdown(ClientPacket* const); //map management void HandleRegionRequest(RegionPacket* const); diff --git a/server/server_logic.cpp b/server/server_logic.cpp index 94cc258..8fa450f 100644 --- a/server/server_logic.cpp +++ b/server/server_logic.cpp @@ -179,7 +179,7 @@ void ServerApplication::HandlePacket(SerialPacket* const argPacket) { switch(argPacket->type) { //basic connections case SerialPacketType::BROADCAST_REQUEST: - HandleBroadcastRequest(static_cast(argPacket)); + HandleBroadcastRequest(static_cast(argPacket)); break; case SerialPacketType::JOIN_REQUEST: HandleJoinRequest(static_cast(argPacket)); @@ -188,7 +188,7 @@ void ServerApplication::HandlePacket(SerialPacket* const argPacket) { HandleDisconnect(static_cast(argPacket)); break; case SerialPacketType::SHUTDOWN: - HandleShutdown(static_cast(argPacket)); + HandleShutdown(static_cast(argPacket)); break; //map management diff --git a/server/server_methods.cpp b/server/server_methods.cpp index d993b83..9a6beba 100644 --- a/server/server_methods.cpp +++ b/server/server_methods.cpp @@ -27,7 +27,7 @@ //basic connections //------------------------- -void ServerApplication::HandleBroadcastRequest(SerialPacket* const argPacket) { +void ServerApplication::HandleBroadcastRequest(ServerPacket* const argPacket) { //send the server's data ServerPacket newPacket; @@ -102,7 +102,7 @@ void ServerApplication::HandleDisconnect(ClientPacket* const argPacket) { std::cout << "Disconnection, " << clientMap.size() << " clients and " << accountMgr.GetContainer()->size() << " accounts total" << std::endl; } -void ServerApplication::HandleShutdown(SerialPacket* const argPacket) { +void ServerApplication::HandleShutdown(ClientPacket* const argPacket) { //TODO: authenticate who is shutting the server down /*Pseudocode: if sender's account -> admin is not true then @@ -115,7 +115,7 @@ void ServerApplication::HandleShutdown(SerialPacket* const argPacket) { running = false; //disconnect all clients - SerialPacket newPacket; + ClientPacket newPacket; newPacket.type = SerialPacketType::DISCONNECT; PumpPacket(&newPacket); diff --git a/todo.txt b/todo.txt index 74cae7e..8e455b3 100644 --- a/todo.txt +++ b/todo.txt @@ -1,16 +1,13 @@ -TODO: Sort out the *_cast<> stuff -TODO: encapsulate the data structures -TODO: Ping-pong and keep alive system +TODO: Heartbeat systems +TODO: Rejection messages TODO: Move the statistics into their own SQL table, instead of duplicating the structure a dozen times TODO: Get the rooms working, even if only via hotkeys -TODO: Rejection messages -TODO: Move the map system into it's own namespace -TODO: The TileSheet class should implement the surface itself - TODO: Fix shoddy movement + +TODO: Move the map system into it's own namespace? +TODO: The TileSheet class should implement the surface itself TODO: make the whole thing more fault tolerant TODO: Authentication -TODO: server is slaved to the client TODO: Time delay for requesting region packets TODO: command line parameters overriding config.cfg settings