mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-12 19:28:21 +00:00
Fix the issue where we would create new worlds on ports that were still being used (#625)
* Wait for world to shutdown We need to wait for the message that the world has shutdown before shutting it down. * Dont sent people to dead instances * Added shutting down check Added check for isShuttingDown * Update when we remove from master
This commit is contained in:
parent
ef8c2a40f3
commit
b55606d41e
@ -280,7 +280,7 @@ bool InstanceManager::IsInstanceFull(Instance* instance, bool isFriendTransfer)
|
||||
|
||||
Instance * InstanceManager::FindInstance(LWOMAPID mapID, bool isFriendTransfer, LWOCLONEID cloneId) {
|
||||
for (Instance* i : m_Instances) {
|
||||
if (i && i->GetMapID() == mapID && i->GetCloneID() == cloneId && !IsInstanceFull(i, isFriendTransfer) && !i->GetIsPrivate() && !i->GetShutdownComplete()) {
|
||||
if (i && i->GetMapID() == mapID && i->GetCloneID() == cloneId && !IsInstanceFull(i, isFriendTransfer) && !i->GetIsPrivate() && !i->GetShutdownComplete() && !i->GetIsShuttingDown()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@ -290,7 +290,7 @@ Instance * InstanceManager::FindInstance(LWOMAPID mapID, bool isFriendTransfer,
|
||||
|
||||
Instance * InstanceManager::FindInstance(LWOMAPID mapID, LWOINSTANCEID instanceID) {
|
||||
for (Instance* i : m_Instances) {
|
||||
if (i && i->GetMapID() == mapID && i->GetInstanceID() == instanceID && !i->GetIsPrivate()) {
|
||||
if (i && i->GetMapID() == mapID && i->GetInstanceID() == instanceID && !i->GetIsPrivate() && !i->GetShutdownComplete() && !i->GetIsShuttingDown()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
m_PendingAffirmations = {};
|
||||
m_PendingRequests = {};
|
||||
m_Ready = false;
|
||||
m_IsShuttingDown = false;
|
||||
}
|
||||
|
||||
const std::string& GetIP() const { return m_IP; }
|
||||
@ -46,6 +47,8 @@ public:
|
||||
|
||||
bool GetIsReady() const { return m_Ready; }
|
||||
void SetIsReady(bool value) { m_Ready = value; }
|
||||
bool GetIsShuttingDown() const { return m_IsShuttingDown; }
|
||||
void SetIsShuttingDown(bool value) { m_IsShuttingDown = value; }
|
||||
std::vector<PendingInstanceRequest>& GetPendingRequests() { return m_PendingRequests; }
|
||||
std::vector<PendingInstanceRequest>& GetPendingAffirmations() { return m_PendingAffirmations; }
|
||||
|
||||
@ -82,6 +85,7 @@ private:
|
||||
std::vector<Player> m_Players;
|
||||
SystemAddress m_SysAddr;
|
||||
bool m_Ready;
|
||||
bool m_IsShuttingDown;
|
||||
std::vector<PendingInstanceRequest> m_PendingRequests;
|
||||
std::vector<PendingInstanceRequest> m_PendingAffirmations;
|
||||
|
||||
|
@ -311,7 +311,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
if (affirmTimeout == 1000) {
|
||||
instance->Shutdown();
|
||||
instance->SetShutdownComplete(true);
|
||||
instance->SetIsShuttingDown(true);
|
||||
|
||||
Game::im->RedirectPendingRequests(instance);
|
||||
}
|
||||
@ -358,6 +358,7 @@ void HandlePacket(Packet* packet) {
|
||||
Instance* instance =
|
||||
Game::im->GetInstanceBySysAddr(packet->systemAddress);
|
||||
if (instance) {
|
||||
Game::logger->Log("MasterServer", "Actually disconnected from zone %i clone %i instance %i port %i\n", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance->GetPort());
|
||||
Game::im->RemoveInstance(instance); //Delete the old
|
||||
}
|
||||
|
||||
@ -694,8 +695,8 @@ void HandlePacket(Packet* packet) {
|
||||
return;
|
||||
}
|
||||
|
||||
Game::logger->Log("MasterServer", "Got shutdown response\n");
|
||||
instance->SetShutdownComplete(true);
|
||||
Game::logger->Log("MasterServer", "Got shutdown response from zone %i clone %i instance %i port %i\n", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance->GetPort());
|
||||
instance->SetIsShuttingDown(true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user