mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-19 02:05:28 +00:00
fix: the master server only starts instances of zones in the ZoneTable
A transfer or private zone request started a world server for whatever map ID it named, and for as many instances as were asked for. A new instance now needs a row in the ZoneTable for its zone, and no more than max_instances (masterconfig.ini, 256 by default, 0 for no limit) run at once. The character select has no row and is always started. A request that gets no instance is logged and dropped. Before, the handlers went on to use the missing instance. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
32
dMasterServer/InstanceLimits.h
Normal file
32
dMasterServer/InstanceLimits.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef __INSTANCELIMITS__H__
|
||||
#define __INSTANCELIMITS__H__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
#endif //!__INSTANCELIMITS__H__
|
||||
Reference in New Issue
Block a user