fix(activity): timer names with '_' and restarting a running timer

ActivityManager split the timer name on '_', so a name such as the
shooting gallery's Super_Charge_Timer never reached the script. Strip
the prefix instead. Starting a timer under a running name now starts it
over (ActivityTimerSet) instead of running two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-27 21:25:15 -06:00
parent d0a8f6f950
commit c1b9e1aec9

View File

@@ -132,6 +132,8 @@ void ActivityManager::GetLeaderboardData(Entity* self, const LWOOBJID playerID,
void ActivityManager::ActivityTimerStart(Entity* self, const std::string& timerName, const float_t updateInterval,
const float_t stopTime) {
// ActivityTimerSet with a name that is running starts that timer over
ActivityTimerStop(self, timerName);
auto* timer = new ActivityTimer{ timerName, updateInterval, stopTime };
activeTimers.push_back(timer);
@@ -204,9 +206,10 @@ std::string ActivityManager::GetPrefixedName(const std::string& name) const {
}
void ActivityManager::OnTimerDone(Entity* self, std::string timerName) {
auto nameSplit = GeneralUtils::SplitString(timerName, '_');
if (nameSplit.size() > 1 && nameSplit.at(0) == TimerPrefix) {
const auto& activityTimerName = nameSplit.at(1);
// The name after the prefix, as it was given (it may have '_' in it: sg_cannon.lua's Super_Charge_Timer)
const auto prefix = TimerPrefix + "_";
if (timerName.size() > prefix.size() && timerName.starts_with(prefix)) {
const auto activityTimerName = timerName.substr(prefix.size());
auto* timer = GetTimer(activityTimerName);
if (timer != nullptr) {