diff options
author | Maya <malte.hoermeyer@web.de> | 2022-11-13 04:01:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-13 03:01:14 +0000 |
commit | 23fda0b842560d2f3cf64ecf9a57d5ad2861e488 (patch) | |
tree | 9527c91bd744fb0562963e43e212c1bc5536847d /NorthstarDLL/miscserverscript.cpp | |
parent | d237401bb97c1fa2d6ee87220d49e4b3343e7201 (diff) | |
download | NorthstarLauncher-23fda0b842560d2f3cf64ecf9a57d5ad2861e488.tar.gz NorthstarLauncher-23fda0b842560d2f3cf64ecf9a57d5ad2861e488.zip |
Squirrel functions auto bind (#299)
* Add defines to auto add squirrel funcs
it brokey
* Make it Work
changed all squirrel function definitions to this system
* Add defines to auto add squirrel funcs
it brokey
Co-authored-by: Emma-Miler <27428383+emma-miler@users.noreply.github.com>
* Make it Work
changed all squirrel function definitions to this system
Co-authored-by: Emma-Miler <27428383+emma-miler@users.noreply.github.com>
* Formatting
* Good old Formatting commit
* HelloGecko
* Formatting Finalv2ForRealThisTime
* idk anymore
* i hate formatting
* Rename some
* Rename macro
* Change function names to more human-readable
* Revert to using old ScriptContext definition
* Formatting
Co-authored-by: RoyalBlue1 <realEmail@veryRealURL.com>
Co-authored-by: Emma-Miler <27428383+emma-miler@users.noreply.github.com>
Co-authored-by: Emma Miler <emma.pi@protonmail.com>
Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
Diffstat (limited to 'NorthstarDLL/miscserverscript.cpp')
-rw-r--r-- | NorthstarDLL/miscserverscript.cpp | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/NorthstarDLL/miscserverscript.cpp b/NorthstarDLL/miscserverscript.cpp index 758323ef..a8e7264b 100644 --- a/NorthstarDLL/miscserverscript.cpp +++ b/NorthstarDLL/miscserverscript.cpp @@ -8,22 +8,21 @@ #include <filesystem> -// void function NSEarlyWritePlayerPersistenceForLeave( entity player ) -SQRESULT SQ_EarlyWritePlayerPersistenceForLeave(HSquirrelVM* sqvm) +ADD_SQFUNC("void", NSEarlyWritePlayerPersistenceForLeave, "entity player", "", ScriptContext::SERVER) { - const R2::CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->getentity<R2::CBasePlayer>(sqvm, 1); + const R2::CBasePlayer* pPlayer = g_pSquirrel<context>->getentity<R2::CBasePlayer>(sqvm, 1); if (!pPlayer) { spdlog::warn("NSEarlyWritePlayerPersistenceForLeave got null player"); - g_pSquirrel<ScriptContext::SERVER>->pushbool(sqvm, false); + g_pSquirrel<context>->pushbool(sqvm, false); return SQRESULT_NOTNULL; } R2::CBaseClient* pClient = &R2::g_pClientArray[pPlayer->m_nPlayerIndex - 1]; if (g_pServerAuthentication->m_PlayerAuthenticationData.find(pClient) == g_pServerAuthentication->m_PlayerAuthenticationData.end()) { - g_pSquirrel<ScriptContext::SERVER>->pushbool(sqvm, false); + g_pSquirrel<context>->pushbool(sqvm, false); return SQRESULT_NOTNULL; } @@ -32,42 +31,30 @@ SQRESULT SQ_EarlyWritePlayerPersistenceForLeave(HSquirrelVM* sqvm) return SQRESULT_NULL; } -// bool function NSIsWritingPlayerPersistence() -SQRESULT SQ_IsWritingPlayerPersistence(HSquirrelVM* sqvm) +ADD_SQFUNC("bool", NSIsWritingPlayerPersistence, "", "", ScriptContext::SERVER) { - g_pSquirrel<ScriptContext::SERVER>->pushbool(sqvm, g_pMasterServerManager->m_bSavingPersistentData); + g_pSquirrel<context>->pushbool(sqvm, g_pMasterServerManager->m_bSavingPersistentData); return SQRESULT_NOTNULL; } -// bool function NSIsPlayerLocalPlayer( entity player ) -SQRESULT SQ_IsPlayerLocalPlayer(HSquirrelVM* sqvm) +ADD_SQFUNC("bool", NSIsPlayerLocalPlayer, "entity player", "", ScriptContext::SERVER) { const R2::CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->getentity<R2::CBasePlayer>(sqvm, 1); if (!pPlayer) { spdlog::warn("NSIsPlayerLocalPlayer got null player"); - g_pSquirrel<ScriptContext::SERVER>->pushbool(sqvm, false); + g_pSquirrel<context>->pushbool(sqvm, false); return SQRESULT_NOTNULL; } R2::CBaseClient* pClient = &R2::g_pClientArray[pPlayer->m_nPlayerIndex - 1]; - g_pSquirrel<ScriptContext::SERVER>->pushbool(sqvm, !strcmp(R2::g_pLocalPlayerUserID, pClient->m_UID)); + g_pSquirrel<context>->pushbool(sqvm, !strcmp(R2::g_pLocalPlayerUserID, pClient->m_UID)); return SQRESULT_NOTNULL; } -// bool function NSIsDedicated() -SQRESULT SQ_IsDedicated(HSquirrelVM* sqvm) +ADD_SQFUNC("bool", NSIsDedicated, "", "", ScriptContext::SERVER) { - g_pSquirrel<ScriptContext::SERVER>->pushbool(sqvm, IsDedicatedServer()); + g_pSquirrel<context>->pushbool(sqvm, IsDedicatedServer()); return SQRESULT_NOTNULL; } - -ON_DLL_LOAD_RELIESON("server.dll", MiscServerScriptCommands, ServerSquirrel, (CModule module)) -{ - g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration( - "void", "NSEarlyWritePlayerPersistenceForLeave", "entity player", "", SQ_EarlyWritePlayerPersistenceForLeave); - g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration("bool", "NSIsWritingPlayerPersistence", "", "", SQ_IsWritingPlayerPersistence); - g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration("bool", "NSIsPlayerLocalPlayer", "entity player", "", SQ_IsPlayerLocalPlayer); - g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration("bool", "NSIsDedicated", "", "", SQ_IsDedicated); -} |