Server: Fix bugs

This commit is contained in:
David Markowitz 2023-10-06 02:54:59 -07:00
parent e10351bde6
commit 1847d03c7b
4 changed files with 53 additions and 4 deletions

View File

@ -22,6 +22,9 @@
#include "eConnectionType.h"
#include "eServerMessageType.h"
#include "eAuthMessageType.h"
#include "eMasterMessageType.h"
#include "PacketUtils.h"
#include "ZoneInstanceManager.h"
#include "Game.h"
namespace Game {
@ -115,7 +118,13 @@ int main(int argc, char** argv) {
//In world we'd update our other systems here.
//Check for packets here:
Game::server->ReceiveFromMaster(); //ReceiveFromMaster also handles the master packets if needed.
packet = Game::server->ReceiveFromMaster();
if (packet) {
HandlePacket(packet);
Game::server->DeallocatePacket(packet);
packet = nullptr;
}
packet = Game::server->Receive();
if (packet) {
HandlePacket(packet);
@ -185,6 +194,21 @@ void HandlePacket(Packet* packet) {
if (static_cast<eAuthMessageType>(packet->data[3]) == eAuthMessageType::LOGIN_REQUEST) {
AuthPackets::HandleLoginRequest(Game::server, packet);
}
} else if (static_cast<eConnectionType>(packet->data[1]) == eConnectionType::MASTER) {
switch (static_cast<eMasterMessageType>(packet->data[3])) {
case eMasterMessageType::REQUEST_ZONE_TRANSFER_RESPONSE: {
uint64_t requestID = PacketUtils::ReadU64(8, packet);
ZoneInstanceManager::Instance()->HandleRequestZoneTransferResponse(requestID, packet);
break;
}
case eMasterMessageType::SHUTDOWN: {
Game::shouldShutdown = true;
Game::logger->Log("AuthServer", "Got shutdown request from master, zone (%i), instance (%i)", Game::server->GetZoneID(), Game::server->GetInstanceID());
break;
}
}
}
}
}

View File

@ -25,6 +25,9 @@
//RakNet includes:
#include "RakNetDefines.h"
#include <MessageIdentifiers.h>
#include "eMasterMessageType.h"
#include "PacketUtils.h"
#include "ZoneInstanceManager.h"
namespace Game {
dLogger* logger = nullptr;
@ -139,7 +142,13 @@ int main(int argc, char** argv) {
//In world we'd update our other systems here.
//Check for packets here:
Game::server->ReceiveFromMaster(); //ReceiveFromMaster also handles the master packets if needed.
packet = Game::server->ReceiveFromMaster();
if (packet) {
HandlePacket(packet);
Game::server->DeallocatePacket(packet);
packet = nullptr;
}
packet = Game::server->Receive();
if (packet) {
HandlePacket(packet);
@ -207,7 +216,22 @@ void HandlePacket(Packet* packet) {
}
if (packet->length < 4) return; // Nothing left to process. Need 4 bytes to continue.
if (static_cast<eConnectionType>(packet->data[1]) == eConnectionType::MASTER) {
switch (static_cast<eMasterMessageType>(packet->data[3])) {
case eMasterMessageType::REQUEST_ZONE_TRANSFER_RESPONSE: {
uint64_t requestID = PacketUtils::ReadU64(8, packet);
ZoneInstanceManager::Instance()->HandleRequestZoneTransferResponse(requestID, packet);
break;
}
case eMasterMessageType::SHUTDOWN: {
Game::shouldShutdown = true;
Game::logger->Log("ChatServer", "Got shutdown request from master, zone (%i), instance (%i)", Game::server->GetZoneID(), Game::server->GetInstanceID());
break;
}
}
}
if (static_cast<eConnectionType>(packet->data[1]) == eConnectionType::CHAT_INTERNAL) {
switch (static_cast<eChatInternalMessageType>(packet->data[3])) {
case eChatInternalMessageType::PLAYER_ADDED_NOTIFICATION:

View File

@ -180,7 +180,7 @@ void InstanceManager::ReadyInstance(Instance* instance) {
const auto& zoneId = instance->GetZoneID();
Game::logger->Log("InstanceManager", "Responding to pending request %llu -> %i (%i)", request, zoneId.GetMapID(), zoneId.GetCloneID());
Game::logger->Log("InstanceManager", "%s", request.sysAddr.ToString());
MasterPackets::SendZoneTransferResponse(
Game::server,
request.sysAddr,

View File

@ -434,6 +434,7 @@ int main(int argc, char** argv) {
for (uint32_t curPacket = 0; curPacket < maxPacketsToProcess && timeSpent < maxPacketProcessingTime; curPacket++) {
packet = Game::server->Receive();
if (packet) {
Game::logger->Log("WorldServer", "packet sysAddr %s", packet->systemAddress.ToString());
auto t1 = std::chrono::high_resolution_clock::now();
HandlePacket(packet);
auto t2 = std::chrono::high_resolution_clock::now();