Created MAX_PACKET_SIZE
This commit is contained in:
@@ -31,4 +31,14 @@
|
|||||||
|
|
||||||
//NOTE: SerialPacket is defined in serial_packet_base.hpp
|
//NOTE: SerialPacket is defined in serial_packet_base.hpp
|
||||||
|
|
||||||
|
union MaxPacket {
|
||||||
|
CharacterPacket a;
|
||||||
|
ClientPacket b;
|
||||||
|
CombatPacket c;
|
||||||
|
EnemyPacket d;
|
||||||
|
RegionPacket e;
|
||||||
|
ServerPacket f;
|
||||||
|
};
|
||||||
|
constexpr int MAX_PACKET_SIZE = sizeof(MaxPacket);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -115,14 +115,29 @@ void ServerApplication::Init(int argc, char** argv) {
|
|||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
std::cout << "Startup completed successfully" << std::endl;
|
std::cout << "Startup completed successfully" << std::endl;
|
||||||
|
|
||||||
|
//-------------------------
|
||||||
|
//debugging
|
||||||
|
//-------------------------
|
||||||
|
|
||||||
|
std::cout << "Debugging dump:" << std::endl;
|
||||||
|
std::cout << "\tMAX_PACKET_SIZE:\t\t" << MAX_PACKET_SIZE << std::endl;
|
||||||
|
std::cout << "\tsizeof(SerialPacket):\t\t" << sizeof(SerialPacket) << std::endl;
|
||||||
|
std::cout << "\tsizeof(CharacterPacket):\t" << sizeof(CharacterPacket) << std::endl;
|
||||||
|
std::cout << "\t\tsizeof(Statistics):\t" << sizeof(Statistics) << std::endl;
|
||||||
|
std::cout << "\tsizeof(ClientPacket):\t\t" << sizeof(ClientPacket) << std::endl;
|
||||||
|
std::cout << "\tsizeof(CombatPacket):\t\t" << sizeof(CombatPacket) << std::endl;
|
||||||
|
std::cout << "\tsizeof(EnemyPacket):\t\t" << sizeof(EnemyPacket) << std::endl;
|
||||||
|
std::cout << "\tsizeof(RegionPacket):\t\t" << sizeof(RegionPacket) << std::endl;
|
||||||
|
std::cout << "\tsizeof(ServerPacket):\t\t" << sizeof(ServerPacket) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::Proc() {
|
void ServerApplication::Proc() {
|
||||||
SerialPacket packet;
|
char packetBuffer[MAX_PACKET_SIZE];
|
||||||
while(running) {
|
while(running) {
|
||||||
//suck in the waiting packets & process them
|
//suck in the waiting packets & process them
|
||||||
while(network.Receive(&packet)) {
|
while(network.Receive(reinterpret_cast<SerialPacket*>(packetBuffer))) {
|
||||||
HandlePacket(&packet);
|
HandlePacket(reinterpret_cast<SerialPacket*>(packetBuffer));
|
||||||
}
|
}
|
||||||
//update the internals
|
//update the internals
|
||||||
//TODO: update the internals i.e. player positions
|
//TODO: update the internals i.e. player positions
|
||||||
|
|||||||
Reference in New Issue
Block a user