mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-18 17:55:27 +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:
@@ -62,6 +62,9 @@ if(APPLE)
|
||||
add_dependencies(dGameTests dGameTestsLink)
|
||||
endif()
|
||||
|
||||
# InstanceLimits.h
|
||||
target_include_directories(dGameTests PRIVATE "${PROJECT_SOURCE_DIR}/dMasterServer")
|
||||
|
||||
# Local capture fixtures (tests/fixtures-local, never committed) are found from the source folder
|
||||
target_compile_definitions(dGameTests PRIVATE DLU_SOURCE_DIR="${PROJECT_SOURCE_DIR}")
|
||||
target_link_libraries(dGameTests ${COMMON_LIBRARIES} sqlite3 GTest::gtest_main
|
||||
|
||||
@@ -20,6 +20,7 @@ SET(DGAMEMESSAGES_TESTS
|
||||
"ClientMessagesTests.cpp"
|
||||
"LoadSequenceTests.cpp"
|
||||
"ChatRoutingTests.cpp"
|
||||
"InstanceLimitsTests.cpp"
|
||||
"TradeOfferTests.cpp"
|
||||
"VendorPricingTests.cpp")
|
||||
|
||||
|
||||
34
tests/dGameTests/dGameMessagesTests/InstanceLimitsTests.cpp
Normal file
34
tests/dGameTests/dGameMessagesTests/InstanceLimitsTests.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "InstanceLimits.h"
|
||||
|
||||
using InstanceLimits::CheckNewInstance;
|
||||
using InstanceLimits::eNewInstance;
|
||||
|
||||
TEST(InstanceLimitsTest, AZoneOfTheZoneTableIsStarted) {
|
||||
EXPECT_EQ(CheckNewInstance(1000, true, 0, 256), eNewInstance::Allowed);
|
||||
EXPECT_EQ(CheckNewInstance(1150, true, 255, 256), eNewInstance::Allowed);
|
||||
}
|
||||
|
||||
TEST(InstanceLimitsTest, AZoneTheZoneTableDoesNotHaveIsRefused) {
|
||||
EXPECT_EQ(CheckNewInstance(31337, false, 0, 256), eNewInstance::UnknownZone);
|
||||
EXPECT_EQ(CheckNewInstance(31337, false, 0, 0), eNewInstance::UnknownZone);
|
||||
// The unknown zone is the reason given, also when the limit is reached too
|
||||
EXPECT_EQ(CheckNewInstance(31337, false, 256, 256), eNewInstance::UnknownZone);
|
||||
}
|
||||
|
||||
TEST(InstanceLimitsTest, NoInstanceIsStartedPastTheLimit) {
|
||||
EXPECT_EQ(CheckNewInstance(1000, true, 256, 256), eNewInstance::TooManyInstances);
|
||||
EXPECT_EQ(CheckNewInstance(1000, true, 1000, 256), eNewInstance::TooManyInstances);
|
||||
EXPECT_EQ(CheckNewInstance(1000, true, 1, 1), eNewInstance::TooManyInstances);
|
||||
}
|
||||
|
||||
TEST(InstanceLimitsTest, ALimitOfZeroIsNoLimit) {
|
||||
EXPECT_EQ(CheckNewInstance(1000, true, 100000, 0), eNewInstance::Allowed);
|
||||
}
|
||||
|
||||
TEST(InstanceLimitsTest, TheCharacterSelectIsAlwaysStarted) {
|
||||
// Zone 0 has no row in the ZoneTable
|
||||
EXPECT_EQ(CheckNewInstance(0, false, 0, 256), eNewInstance::Allowed);
|
||||
EXPECT_EQ(CheckNewInstance(0, false, 256, 256), eNewInstance::Allowed);
|
||||
}
|
||||
Reference in New Issue
Block a user