diff --git a/src/acs/call-funcs.cpp b/src/acs/call-funcs.cpp index cf1e87d3a..de4e166ae 100644 --- a/src/acs/call-funcs.cpp +++ b/src/acs/call-funcs.cpp @@ -1351,3 +1351,45 @@ bool CallFunc_EncoreMode(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM:: thread->dataStk.push(encoremode); return false; } + +/*-------------------------------------------------- + bool CallFunc_PodiumPosition(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) + + Returns the best position of all non-CPU players. +--------------------------------------------------*/ +bool CallFunc_PodiumPosition(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) +{ + UINT8 ret = MAXPLAYERS; + INT32 i; + + (void)argV; + (void)argC; + + for (i = 0; i < MAXPLAYERS; i++) + { + player_t *player = NULL; + + if (playeringame[i] == false) + { + continue; + } + + player = &players[i]; + + if (player->spectator == true) + { + continue; + } + + if (player->bot == true) + { + continue; + } + + ret = std::min(ret, player->position); + } + + thread->dataStk.push(ret); + return false; +} + diff --git a/src/acs/call-funcs.hpp b/src/acs/call-funcs.hpp index c4215b5e0..5ca20e915 100644 --- a/src/acs/call-funcs.hpp +++ b/src/acs/call-funcs.hpp @@ -85,4 +85,6 @@ bool CallFunc_PlayerLap(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::W bool CallFunc_LowestLap(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_EncoreMode(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); +bool CallFunc_PodiumPosition(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); + #endif // __SRB2_ACS_CALL_FUNCS_HPP__ diff --git a/src/acs/environment.cpp b/src/acs/environment.cpp index ab7a67811..d656a3503 100644 --- a/src/acs/environment.cpp +++ b/src/acs/environment.cpp @@ -163,6 +163,7 @@ Environment::Environment() addFuncDataACS0( 309, addCallFunc(CallFunc_EncoreMode)); addFuncDataACS0( 500, addCallFunc(CallFunc_CameraWait)); + addFuncDataACS0( 501, addCallFunc(CallFunc_PodiumPosition)); } ACSVM::Thread *Environment::allocThread()