mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Add string comparison funcs for ACS
This commit is contained in:
parent
5cc8aa004b
commit
bc3d9d9cf7
3 changed files with 89 additions and 5 deletions
|
|
@ -1019,12 +1019,90 @@ bool CallFunc_EndLog(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word
|
|||
(void)argV;
|
||||
(void)argC;
|
||||
|
||||
if (ACS_ActivatorIsLocal(thread) == true)
|
||||
{
|
||||
CONS_Printf("%s\n", thread->printBuf.data());
|
||||
thread->printBuf.drop();
|
||||
return false;
|
||||
}
|
||||
|
||||
thread->printBuf.drop();
|
||||
/*--------------------------------------------------
|
||||
bool CallFunc_strcmp(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC)
|
||||
|
||||
ACS wrapper for strcmp.
|
||||
--------------------------------------------------*/
|
||||
static int ACS_strcmp(ACSVM::String *a, ACSVM::String *b)
|
||||
{
|
||||
for (char const *sA = a->str, *sB = b->str; ; ++sA, ++sB)
|
||||
{
|
||||
char cA = *sA, cB = *sB;
|
||||
|
||||
if (cA != cB)
|
||||
{
|
||||
return (cA < cB) ? -1 : 1;
|
||||
}
|
||||
|
||||
if (!cA)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CallFunc_strcmp(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC)
|
||||
{
|
||||
ACSVM::MapScope *map = NULL;
|
||||
|
||||
ACSVM::String *strA = nullptr;
|
||||
ACSVM::String *strB = nullptr;
|
||||
|
||||
(void)argC;
|
||||
|
||||
map = thread->scopeMap;
|
||||
|
||||
strA = map->getString(argV[0]);
|
||||
strB = map->getString(argV[1]);
|
||||
|
||||
thread->dataStk.push(ACS_strcmp(strA, strB));
|
||||
return false;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
bool CallFunc_strcasecmp(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC)
|
||||
|
||||
ACS wrapper for strcasecmp / stricmp.
|
||||
--------------------------------------------------*/
|
||||
static int ACS_strcasecmp(ACSVM::String *a, ACSVM::String *b)
|
||||
{
|
||||
for (char const *sA = a->str, *sB = b->str; ; ++sA, ++sB)
|
||||
{
|
||||
char cA = std::tolower(*sA), cB = std::tolower(*sB);
|
||||
|
||||
if (cA != cB)
|
||||
{
|
||||
return (cA < cB) ? -1 : 1;
|
||||
}
|
||||
|
||||
if (!cA)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CallFunc_strcasecmp(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC)
|
||||
{
|
||||
ACSVM::MapScope *map = NULL;
|
||||
|
||||
ACSVM::String *strA = nullptr;
|
||||
ACSVM::String *strB = nullptr;
|
||||
|
||||
(void)argC;
|
||||
|
||||
map = thread->scopeMap;
|
||||
|
||||
strA = map->getString(argV[0]);
|
||||
strB = map->getString(argV[1]);
|
||||
|
||||
thread->dataStk.push(ACS_strcasecmp(strA, strB));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,9 @@ bool CallFunc_PlayerRings(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM:
|
|||
bool CallFunc_PlayerScore(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
|
||||
bool CallFunc_EndLog(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
|
||||
|
||||
bool CallFunc_strcmp(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
|
||||
bool CallFunc_strcasecmp(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
|
||||
|
||||
bool CallFunc_CountEnemies(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
|
||||
bool CallFunc_CountPushables(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
|
||||
bool CallFunc_HaveUnlockableTrigger(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
|
||||
|
|
|
|||
|
|
@ -144,6 +144,9 @@ Environment::Environment()
|
|||
//addFuncDataACS0( 7, addCallFunc(CallFunc_GetSideUDMFInt));
|
||||
//addFuncDataACS0( 8, addCallFunc(CallFunc_GetSideUDMFFixed));
|
||||
|
||||
addFuncDataACS0( 100, addCallFunc(CallFunc_strcmp));
|
||||
addFuncDataACS0( 101, addCallFunc(CallFunc_strcasecmp));
|
||||
|
||||
addFuncDataACS0( 300, addCallFunc(CallFunc_CountEnemies));
|
||||
addFuncDataACS0( 301, addCallFunc(CallFunc_CountPushables));
|
||||
addFuncDataACS0( 302, addCallFunc(CallFunc_HaveUnlockableTrigger));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue