diff --git a/server/account_data.hpp b/common/gameplay/account_data.hpp similarity index 100% rename from server/account_data.hpp rename to common/gameplay/account_data.hpp diff --git a/server/character_data.hpp b/common/gameplay/character_data.hpp similarity index 90% rename from server/character_data.hpp rename to common/gameplay/character_data.hpp index 4da307f..642c34a 100644 --- a/server/character_data.hpp +++ b/common/gameplay/character_data.hpp @@ -28,6 +28,11 @@ #include "statistics.hpp" #include +#include + +//the speeds that the characters move +constexpr double CHARACTER_WALKING_SPEED = 140; +constexpr double CHARACTER_WALKING_MOD = 1.0/sqrt(2.0); struct CharacterData { //metadata diff --git a/server/client_data.hpp b/common/gameplay/client_data.hpp similarity index 97% rename from server/client_data.hpp rename to common/gameplay/client_data.hpp index d67a1ea..7410b08 100644 --- a/server/client_data.hpp +++ b/common/gameplay/client_data.hpp @@ -26,7 +26,6 @@ struct ClientData { IPaddress address = {0,0}; - static int uidCounter; }; #endif diff --git a/server/combat_data.hpp b/common/gameplay/combat_data.hpp similarity index 98% rename from server/combat_data.hpp rename to common/gameplay/combat_data.hpp index 4fe73d2..c76520b 100644 --- a/server/combat_data.hpp +++ b/common/gameplay/combat_data.hpp @@ -46,8 +46,6 @@ struct CombatData { //time interval Clock::time_point lastTick = Clock::now(); - - static int uidCounter; }; #endif diff --git a/server/enemy_data.hpp b/common/gameplay/enemy_data.hpp similarity index 98% rename from server/enemy_data.hpp rename to common/gameplay/enemy_data.hpp index 16f3f21..48a5fa4 100644 --- a/server/enemy_data.hpp +++ b/common/gameplay/enemy_data.hpp @@ -43,8 +43,6 @@ struct EnemyData { //NOTE: these are lost when unloaded int tableIndex; int atbGauge = 0; - - static int uidCounter; }; #endif diff --git a/server/server_application.hpp b/server/server_application.hpp index c8453ac..0437e1b 100644 --- a/server/server_application.hpp +++ b/server/server_application.hpp @@ -117,6 +117,9 @@ private: //misc bool running = true; ConfigUtility config; + int clientUID = 0; + int combatUID = 0; + int enemyUID = 0; }; #endif diff --git a/server/server_connections.cpp b/server/server_connections.cpp index 4b3bf0f..0027b6c 100644 --- a/server/server_connections.cpp +++ b/server/server_connections.cpp @@ -47,7 +47,7 @@ void ServerApplication::HandleJoinRequest(SerialPacket packet) { newClient.address = packet.meta.srcAddress; //load the user account - int accountIndex = LoadUserAccount(packet.clientInfo.username, ClientData::uidCounter); + int accountIndex = LoadUserAccount(packet.clientInfo.username, clientUID); if (accountIndex < 0) { //TODO: send rejection packet std::cerr << "Error: Account already loaded: " << accountIndex << std::endl; @@ -65,7 +65,7 @@ void ServerApplication::HandleJoinRequest(SerialPacket packet) { //send the client their info packet.meta.type = SerialPacket::Type::JOIN_RESPONSE; - packet.clientInfo.clientIndex = ClientData::uidCounter; + packet.clientInfo.clientIndex = clientUID; packet.clientInfo.accountIndex = accountIndex; packet.clientInfo.characterIndex = characterIndex; @@ -85,7 +85,7 @@ void ServerApplication::HandleJoinRequest(SerialPacket packet) { //TODO: don't send anything to a certain client until they send the OK (the sync packet? or ignore client side?) //finished this routine - clientMap[ClientData::uidCounter++] = newClient; + clientMap[clientUID++] = newClient; std::cout << "Connect, total: " << clientMap.size() << std::endl; } diff --git a/server/server_internals.cpp b/server/server_internals.cpp index f8624eb..d75c9c3 100644 --- a/server/server_internals.cpp +++ b/server/server_internals.cpp @@ -27,14 +27,6 @@ #include #include -//------------------------- -//Define the various UIDs -//------------------------- - -int ClientData::uidCounter = 0; -int CombatData::uidCounter = 0; -int EnemyData::uidCounter = 0; - //------------------------- //Define the public members //-------------------------