mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-04-26 16:46:31 +00:00
fix: sys addr for private zones (#1760)
* fix: sys addr for private zones * Initialize variables in Instance
This commit is contained in:
parent
99f6cf2d92
commit
f5c212fb86
@ -273,6 +273,16 @@ Instance* InstanceManager::FindInstance(LWOMAPID mapID, LWOINSTANCEID instanceID
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Instance* InstanceManager::FindInstanceWithPrivate(LWOMAPID mapID, LWOINSTANCEID instanceID) {
|
||||||
|
for (Instance* i : m_Instances) {
|
||||||
|
if (i && i->GetMapID() == mapID && i->GetInstanceID() == instanceID && !i->GetShutdownComplete() && !i->GetIsShuttingDown()) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
Instance* InstanceManager::CreatePrivateInstance(LWOMAPID mapID, LWOCLONEID cloneID, const std::string& password) {
|
Instance* InstanceManager::CreatePrivateInstance(LWOMAPID mapID, LWOCLONEID cloneID, const std::string& password) {
|
||||||
auto* instance = FindPrivateInstance(password);
|
auto* instance = FindPrivateInstance(password);
|
||||||
|
|
||||||
|
@ -76,25 +76,25 @@ public:
|
|||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_IP;
|
std::string m_IP{};
|
||||||
uint32_t m_Port;
|
uint32_t m_Port{};
|
||||||
LWOZONEID m_ZoneID;
|
LWOZONEID m_ZoneID{};
|
||||||
int m_MaxClientsSoftCap;
|
int m_MaxClientsSoftCap{};
|
||||||
int m_MaxClientsHardCap;
|
int m_MaxClientsHardCap{};
|
||||||
int m_CurrentClientCount;
|
int m_CurrentClientCount{};
|
||||||
std::vector<Player> m_Players;
|
std::vector<Player> m_Players{};
|
||||||
SystemAddress m_SysAddr;
|
SystemAddress m_SysAddr{};
|
||||||
bool m_Ready;
|
bool m_Ready{};
|
||||||
bool m_IsShuttingDown;
|
bool m_IsShuttingDown{};
|
||||||
std::vector<PendingInstanceRequest> m_PendingRequests;
|
std::vector<PendingInstanceRequest> m_PendingRequests{};
|
||||||
std::vector<PendingInstanceRequest> m_PendingAffirmations;
|
std::vector<PendingInstanceRequest> m_PendingAffirmations{};
|
||||||
|
|
||||||
uint32_t m_AffirmationTimeout;
|
uint32_t m_AffirmationTimeout{};
|
||||||
|
|
||||||
bool m_IsPrivate;
|
bool m_IsPrivate{};
|
||||||
std::string m_Password;
|
std::string m_Password{};
|
||||||
|
|
||||||
bool m_Shutdown;
|
bool m_Shutdown{};
|
||||||
|
|
||||||
//Private functions:
|
//Private functions:
|
||||||
};
|
};
|
||||||
@ -125,6 +125,7 @@ public:
|
|||||||
|
|
||||||
Instance* FindInstance(LWOMAPID mapID, bool isFriendTransfer, LWOCLONEID cloneId = 0);
|
Instance* FindInstance(LWOMAPID mapID, bool isFriendTransfer, LWOCLONEID cloneId = 0);
|
||||||
Instance* FindInstance(LWOMAPID mapID, LWOINSTANCEID instanceID);
|
Instance* FindInstance(LWOMAPID mapID, LWOINSTANCEID instanceID);
|
||||||
|
Instance* FindInstanceWithPrivate(LWOMAPID mapID, LWOINSTANCEID instanceID);
|
||||||
|
|
||||||
Instance* CreatePrivateInstance(LWOMAPID mapID, LWOCLONEID cloneID, const std::string& password);
|
Instance* CreatePrivateInstance(LWOMAPID mapID, LWOCLONEID cloneID, const std::string& password);
|
||||||
Instance* FindPrivateInstance(const std::string& password);
|
Instance* FindPrivateInstance(const std::string& password);
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "Server.h"
|
#include "Server.h"
|
||||||
#include "CDZoneTableTable.h"
|
#include "CDZoneTableTable.h"
|
||||||
#include "eGameMasterLevel.h"
|
#include "eGameMasterLevel.h"
|
||||||
|
#include "StringifiedEnum.h"
|
||||||
|
|
||||||
#ifdef DARKFLAME_PLATFORM_UNIX
|
#ifdef DARKFLAME_PLATFORM_UNIX
|
||||||
|
|
||||||
@ -556,7 +557,7 @@ void HandlePacket(Packet* packet) {
|
|||||||
Instance* in = Game::im->GetInstance(zoneID, false, zoneClone);
|
Instance* in = Game::im->GetInstance(zoneID, false, zoneClone);
|
||||||
|
|
||||||
for (auto* instance : Game::im->GetInstances()) {
|
for (auto* instance : Game::im->GetInstances()) {
|
||||||
LOG("Instance: %i/%i/%i -> %i", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance == in);
|
LOG("Instance: %i/%i/%i -> %i %s", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance == in, instance->GetSysAddr().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in && !in->GetIsReady()) //Instance not ready, make a pending request
|
if (in && !in->GetIsReady()) //Instance not ready, make a pending request
|
||||||
@ -597,15 +598,10 @@ void HandlePacket(Packet* packet) {
|
|||||||
if (!Game::im->IsPortInUse(theirPort)) {
|
if (!Game::im->IsPortInUse(theirPort)) {
|
||||||
Instance* in = new Instance(theirIP.string, theirPort, theirZoneID, theirInstanceID, 0, 12, 12);
|
Instance* in = new Instance(theirIP.string, theirPort, theirZoneID, theirInstanceID, 0, 12, 12);
|
||||||
|
|
||||||
SystemAddress copy;
|
in->SetSysAddr(packet->systemAddress);
|
||||||
copy.binaryAddress = packet->systemAddress.binaryAddress;
|
|
||||||
copy.port = packet->systemAddress.port;
|
|
||||||
|
|
||||||
in->SetSysAddr(copy);
|
|
||||||
Game::im->AddInstance(in);
|
Game::im->AddInstance(in);
|
||||||
} else {
|
} else {
|
||||||
auto instance = Game::im->FindInstance(
|
auto* instance = Game::im->FindInstanceWithPrivate(theirZoneID, static_cast<LWOINSTANCEID>(theirInstanceID));
|
||||||
theirZoneID, static_cast<uint16_t>(theirInstanceID));
|
|
||||||
if (instance) {
|
if (instance) {
|
||||||
instance->SetSysAddr(packet->systemAddress);
|
instance->SetSysAddr(packet->systemAddress);
|
||||||
}
|
}
|
||||||
@ -613,22 +609,14 @@ void HandlePacket(Packet* packet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (theirServerType == ServerType::Chat) {
|
if (theirServerType == ServerType::Chat) {
|
||||||
SystemAddress copy;
|
chatServerMasterPeerSysAddr = packet->systemAddress;
|
||||||
copy.binaryAddress = packet->systemAddress.binaryAddress;
|
|
||||||
copy.port = packet->systemAddress.port;
|
|
||||||
|
|
||||||
chatServerMasterPeerSysAddr = copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theirServerType == ServerType::Auth) {
|
if (theirServerType == ServerType::Auth) {
|
||||||
SystemAddress copy;
|
authServerMasterPeerSysAddr = packet->systemAddress;
|
||||||
copy.binaryAddress = packet->systemAddress.binaryAddress;
|
|
||||||
copy.port = packet->systemAddress.port;
|
|
||||||
|
|
||||||
authServerMasterPeerSysAddr = copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("Received server info, instance: %i port: %i", theirInstanceID, theirPort);
|
LOG("Received %s server info, instance: %i port: %i", StringifiedEnum::ToString(theirServerType).data(), theirInstanceID, theirPort);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -692,7 +680,7 @@ void HandlePacket(Packet* packet) {
|
|||||||
if (instance) {
|
if (instance) {
|
||||||
instance->AddPlayer(Player());
|
instance->AddPlayer(Player());
|
||||||
} else {
|
} else {
|
||||||
printf("Instance missing? What?");
|
LOG("Instance missing? What?");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -733,8 +721,8 @@ void HandlePacket(Packet* packet) {
|
|||||||
inStream.Read<char>(character);
|
inStream.Read<char>(character);
|
||||||
password += character;
|
password += character;
|
||||||
}
|
}
|
||||||
|
auto* newInst = Game::im->CreatePrivateInstance(mapId, cloneId, password.c_str());
|
||||||
Game::im->CreatePrivateInstance(mapId, cloneId, password.c_str());
|
LOG("Creating private zone %i/%i/%i with password %s", newInst->GetMapID(), newInst->GetCloneID(), newInst->GetInstanceID(), password.c_str());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -835,11 +823,10 @@ void HandlePacket(Packet* packet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case MessageType::Master::SHUTDOWN_RESPONSE: {
|
case MessageType::Master::SHUTDOWN_RESPONSE: {
|
||||||
RakNet::BitStream inStream(packet->data, packet->length, false);
|
CINSTREAM_SKIP_HEADER;
|
||||||
uint64_t header = inStream.Read(header);
|
|
||||||
|
|
||||||
auto* instance = Game::im->GetInstanceBySysAddr(packet->systemAddress);
|
auto* instance = Game::im->GetInstanceBySysAddr(packet->systemAddress);
|
||||||
|
LOG("Got shutdown response from %s", packet->systemAddress.ToString());
|
||||||
if (instance == nullptr) {
|
if (instance == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user