mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-14 15:57:13 +00:00
The master server dropped a transfer request it started no instance for, so the world server never heard back and the player waited. It now answers the request with an empty address and the reason in place of the port: no room for another instance (max_instances), a zone that is not in the ZoneTable, or another reason. A request for a private zone that does not exist is answered the same way. The world server passes this on as a TRANSFER_TO_WORLD without an address, which the client shows as a failed map change, and leaves the character where it is. The auth server fails the login when there is no character select to send the player to. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
46 lines
1.6 KiB
C++
46 lines
1.6 KiB
C++
#ifndef __INSTANCELIMITS__H__
|
|
#define __INSTANCELIMITS__H__
|
|
|
|
#include <cstdint>
|
|
|
|
#include "eTransferFailure.h"
|
|
|
|
namespace InstanceLimits {
|
|
// The most world instances that run at once when the config does not say
|
|
constexpr uint32_t DefaultMaxInstances = 256;
|
|
|
|
enum class eNewInstance : uint8_t {
|
|
Allowed,
|
|
UnknownZone,
|
|
TooManyInstances
|
|
};
|
|
|
|
/**
|
|
* Whether a new world instance may be started for a zone.
|
|
* @param mapID the zone asked for, 0 is the character select and has no row in the ZoneTable
|
|
* @param isInZoneTable whether the ZoneTable has a row for the zone
|
|
* @param runningInstances the instances that run already
|
|
* @param maxInstances the most instances that may run at once, 0 for no limit
|
|
*/
|
|
constexpr eNewInstance CheckNewInstance(const uint32_t mapID, const bool isInZoneTable, const uint64_t runningInstances, const uint32_t maxInstances) {
|
|
// Players always have to be able to reach the character select
|
|
if (mapID == 0) return eNewInstance::Allowed;
|
|
if (!isInZoneTable) return eNewInstance::UnknownZone;
|
|
if (maxInstances != 0 && runningInstances >= maxInstances) return eNewInstance::TooManyInstances;
|
|
return eNewInstance::Allowed;
|
|
}
|
|
|
|
/**
|
|
* What the player who asked for the zone is told when no instance was started for it.
|
|
*/
|
|
constexpr eTransferFailure TransferFailure(const eNewInstance newInstance) {
|
|
switch (newInstance) {
|
|
case eNewInstance::UnknownZone: return eTransferFailure::MapLoad;
|
|
case eNewInstance::TooManyInstances: return eTransferFailure::NoServer;
|
|
default: return eTransferFailure::Other;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif //!__INSTANCELIMITS__H__
|