Skip to content

Commit 157b55c

Browse files
committed
Forgot to return in onPlayerDeath in a case-path
- Added onPickupRespawn event
1 parent e137ddf commit 157b55c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

VCMP-LUA/vcmpWrap/EventManager/EventManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ std::unordered_map<std::string, std::vector<sol::function>> EventManager::m_Hand
5151
/*** PICKUPS ***/
5252
{"onPickupPickAttempt", {}},
5353
{"onPickupPicked", {}},
54+
{"onPickupRespawn", {}},
5455

5556
/*** CHECKPOINTS ***/
5657
{"onCheckpointEnter", {}},

VCMP-LUA/vcmpWrap/vcmpCallbacks.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ void RegisterVCMPCallbacks() {
349349
spdlog::error(e.what());
350350
}
351351
}
352+
return;
352353
}
353354

354355
auto handlers = EventManager::GetHandlers("onPlayerKill");
@@ -1092,6 +1093,30 @@ void RegisterVCMPCallbacks() {
10921093
}
10931094
};
10941095

1096+
g_Calls->OnPickupRespawn = [](int32_t pickupId) {
1097+
spdlog::debug("OnPickupRespawn");
1098+
1099+
auto handlers = EventManager::GetHandlers("onPickupRespawn");
1100+
if (handlers.size() == 0) return;
1101+
try {
1102+
Pickup* pickup = Pickup::Get(pickupId);
1103+
for (auto fn : handlers) {
1104+
sol::function_result r = fn(pickup);
1105+
if (!r.valid()) {
1106+
sol::error e = r;
1107+
spdlog::error("Event callback error: {}", e.what());
1108+
}
1109+
if (EventManager::m_bWasEventCancelled) {
1110+
EventManager::cancelEvent();
1111+
break;
1112+
}
1113+
}
1114+
}
1115+
catch (sol::error e) {
1116+
spdlog::error(e.what());
1117+
}
1118+
};
1119+
10951120
/*** CHECKPOINT ***/
10961121
g_Calls->OnCheckpointEntered = [](int32_t checkPointId, int32_t playerId) {
10971122
spdlog::debug("OnCheckpointEntered");

0 commit comments

Comments
 (0)