Add name validation to tax counter actions to guard against ID collision with old servers

This commit is contained in:
DawnFire42 2026-08-07 18:43:53 -04:00
parent 08ec0cc5ee
commit 3f2bac9b57
No known key found for this signature in database
GPG key ID: 24BB855EE2911B33

View file

@ -1716,7 +1716,7 @@ void PlayerActions::sendIncCounter(int counterId, int delta)
void PlayerActions::actModifyTaxCounter(int counterId, int delta)
{
CounterState *state = player->getCounters().value(counterId, nullptr);
if (!state || !state->isActive()) {
if (!state || !state->isActive() || !CounterNames::isTaxCounter(state->getName())) {
return;
}
sendIncCounter(counterId, delta);
@ -1725,8 +1725,11 @@ void PlayerActions::actModifyTaxCounter(int counterId, int delta)
void PlayerActions::actToggleTaxCounter(int counterId)
{
CounterState *state = player->getCounters().value(counterId, nullptr);
if (!state || !CounterNames::isTaxCounter(state->getName())) {
return;
}
// Prevent disabling a counter with tax accumulated; player must reset to 0 first
if (!state || (state->isActive() && state->getValue() != 0)) {
if (state->isActive() && state->getValue() != 0) {
return;
}
Command_SetCounterActive cmd;