mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 06:27:24 +00:00
Server: Fix bugs
This commit is contained in:
parent
e10351bde6
commit
1847d03c7b
@ -22,6 +22,9 @@
|
|||||||
#include "eConnectionType.h"
|
#include "eConnectionType.h"
|
||||||
#include "eServerMessageType.h"
|
#include "eServerMessageType.h"
|
||||||
#include "eAuthMessageType.h"
|
#include "eAuthMessageType.h"
|
||||||
|
#include "eMasterMessageType.h"
|
||||||
|
#include "PacketUtils.h"
|
||||||
|
#include "ZoneInstanceManager.h"
|
||||||
|
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
namespace Game {
|
namespace Game {
|
||||||
@ -115,7 +118,13 @@ int main(int argc, char** argv) {
|
|||||||
//In world we'd update our other systems here.
|
//In world we'd update our other systems here.
|
||||||
|
|
||||||
//Check for packets 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();
|
packet = Game::server->Receive();
|
||||||
if (packet) {
|
if (packet) {
|
||||||
HandlePacket(packet);
|
HandlePacket(packet);
|
||||||
@ -185,6 +194,21 @@ void HandlePacket(Packet* packet) {
|
|||||||
if (static_cast<eAuthMessageType>(packet->data[3]) == eAuthMessageType::LOGIN_REQUEST) {
|
if (static_cast<eAuthMessageType>(packet->data[3]) == eAuthMessageType::LOGIN_REQUEST) {
|
||||||
AuthPackets::HandleLoginRequest(Game::server, packet);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
//RakNet includes:
|
//RakNet includes:
|
||||||
#include "RakNetDefines.h"
|
#include "RakNetDefines.h"
|
||||||
#include <MessageIdentifiers.h>
|
#include <MessageIdentifiers.h>
|
||||||
|
#include "eMasterMessageType.h"
|
||||||
|
#include "PacketUtils.h"
|
||||||
|
#include "ZoneInstanceManager.h"
|
||||||
|
|
||||||
namespace Game {
|
namespace Game {
|
||||||
dLogger* logger = nullptr;
|
dLogger* logger = nullptr;
|
||||||
@ -115,7 +118,7 @@ int main(int argc, char** argv) {
|
|||||||
Game::server = new dServer(Game::config->GetValue("external_ip"), ourPort, 0, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::Chat, Game::config, &Game::shouldShutdown);
|
Game::server = new dServer(Game::config->GetValue("external_ip"), ourPort, 0, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::Chat, Game::config, &Game::shouldShutdown);
|
||||||
|
|
||||||
Game::chatFilter = new dChatFilter(Game::assetManager->GetResPath().string() + "/chatplus_en_us", bool(std::stoi(Game::config->GetValue("dont_generate_dcf"))));
|
Game::chatFilter = new dChatFilter(Game::assetManager->GetResPath().string() + "/chatplus_en_us", bool(std::stoi(Game::config->GetValue("dont_generate_dcf"))));
|
||||||
|
|
||||||
Game::randomEngine = std::mt19937(time(0));
|
Game::randomEngine = std::mt19937(time(0));
|
||||||
|
|
||||||
//Run it until server gets a kill message from Master:
|
//Run it until server gets a kill message from Master:
|
||||||
@ -139,7 +142,13 @@ int main(int argc, char** argv) {
|
|||||||
//In world we'd update our other systems here.
|
//In world we'd update our other systems here.
|
||||||
|
|
||||||
//Check for packets 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();
|
packet = Game::server->Receive();
|
||||||
if (packet) {
|
if (packet) {
|
||||||
HandlePacket(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 (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) {
|
if (static_cast<eConnectionType>(packet->data[1]) == eConnectionType::CHAT_INTERNAL) {
|
||||||
switch (static_cast<eChatInternalMessageType>(packet->data[3])) {
|
switch (static_cast<eChatInternalMessageType>(packet->data[3])) {
|
||||||
case eChatInternalMessageType::PLAYER_ADDED_NOTIFICATION:
|
case eChatInternalMessageType::PLAYER_ADDED_NOTIFICATION:
|
||||||
|
@ -180,7 +180,7 @@ void InstanceManager::ReadyInstance(Instance* instance) {
|
|||||||
const auto& zoneId = instance->GetZoneID();
|
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", "Responding to pending request %llu -> %i (%i)", request, zoneId.GetMapID(), zoneId.GetCloneID());
|
||||||
|
Game::logger->Log("InstanceManager", "%s", request.sysAddr.ToString());
|
||||||
MasterPackets::SendZoneTransferResponse(
|
MasterPackets::SendZoneTransferResponse(
|
||||||
Game::server,
|
Game::server,
|
||||||
request.sysAddr,
|
request.sysAddr,
|
||||||
|
@ -434,6 +434,7 @@ int main(int argc, char** argv) {
|
|||||||
for (uint32_t curPacket = 0; curPacket < maxPacketsToProcess && timeSpent < maxPacketProcessingTime; curPacket++) {
|
for (uint32_t curPacket = 0; curPacket < maxPacketsToProcess && timeSpent < maxPacketProcessingTime; curPacket++) {
|
||||||
packet = Game::server->Receive();
|
packet = Game::server->Receive();
|
||||||
if (packet) {
|
if (packet) {
|
||||||
|
Game::logger->Log("WorldServer", "packet sysAddr %s", packet->systemAddress.ToString());
|
||||||
auto t1 = std::chrono::high_resolution_clock::now();
|
auto t1 = std::chrono::high_resolution_clock::now();
|
||||||
HandlePacket(packet);
|
HandlePacket(packet);
|
||||||
auto t2 = std::chrono::high_resolution_clock::now();
|
auto t2 = std::chrono::high_resolution_clock::now();
|
||||||
|
Loading…
Reference in New Issue
Block a user