From bb822b7638d5ae9bc4499ff76edc74f3741e6518 Mon Sep 17 00:00:00 2001 From: cat_or_not <41955154+catornot@users.noreply.github.com> Date: Sun, 5 Nov 2023 20:21:50 -0500 Subject: Plugins v3 (#472) - nuked presence logic ( moved to the discord rpc plugin ) - more exposed sq functions - exposed dll addresses - `g_pCVar` is exposed - added "userdata" to plugin's async call - added runframe to plugins --- NorthstarDLL/shared/gamepresence.cpp | 79 ------------------------------------ NorthstarDLL/shared/gamepresence.h | 47 --------------------- 2 files changed, 126 deletions(-) delete mode 100644 NorthstarDLL/shared/gamepresence.cpp delete mode 100644 NorthstarDLL/shared/gamepresence.h (limited to 'NorthstarDLL/shared') diff --git a/NorthstarDLL/shared/gamepresence.cpp b/NorthstarDLL/shared/gamepresence.cpp deleted file mode 100644 index 11cb7ade..00000000 --- a/NorthstarDLL/shared/gamepresence.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "gamepresence.h" -#include "plugins/pluginbackend.h" -#include "plugins/plugins.h" -#include "dedicated/dedicated.h" -#include "server/serverpresence.h" -#include "masterserver/masterserver.h" -#include "squirrel/squirrel.h" - -GameStatePresence* g_pGameStatePresence; - -GameStatePresence::GameStatePresence() -{ - g_pServerPresence->AddPresenceReporter(&m_GameStateServerPresenceReporter); -} - -void GameStateServerPresenceReporter::RunFrame(double flCurrentTime, const ServerPresence* pServerPresence) -{ - g_pGameStatePresence->id = pServerPresence->m_sServerId; - g_pGameStatePresence->name = pServerPresence->m_sServerName; - g_pGameStatePresence->description = pServerPresence->m_sServerDesc; - g_pGameStatePresence->password = pServerPresence->m_Password; - - g_pGameStatePresence->map = pServerPresence->m_MapName; - g_pGameStatePresence->playlist = pServerPresence->m_PlaylistName; - g_pGameStatePresence->currentPlayers = pServerPresence->m_iPlayerCount; - g_pGameStatePresence->maxPlayers = pServerPresence->m_iMaxPlayers; - - g_pGameStatePresence->isLocal = !IsDedicatedServer(); -} - -void GameStatePresence::RunFrame() -{ - if (g_pSquirrel->m_pSQVM != nullptr && g_pSquirrel->m_pSQVM->sqvm != nullptr) - g_pSquirrel->Call("NorthstarCodeCallback_GenerateUIPresence"); - - if (g_pSquirrel->m_pSQVM != nullptr && g_pSquirrel->m_pSQVM->sqvm != nullptr) - { - auto test = g_pSquirrel->Call("NorthstarCodeCallback_GenerateGameState"); - } - g_pPluginCommunicationhandler->GeneratePresenceObjects(); -} - -ADD_SQFUNC("void", NSPushGameStateData, "GameStateStruct gamestate", "", ScriptContext::CLIENT) -{ - SQStructInstance* structInst = g_pSquirrel->m_pSQVM->sqvm->_stackOfCurrentFunction[1]._VAL.asStructInstance; - g_pGameStatePresence->map = structInst->data[0]._VAL.asString->_val; - g_pGameStatePresence->mapDisplayname = structInst->data[1]._VAL.asString->_val; - g_pGameStatePresence->playlist = structInst->data[2]._VAL.asString->_val; - g_pGameStatePresence->playlistDisplayname = structInst->data[3]._VAL.asString->_val; - - g_pGameStatePresence->currentPlayers = structInst->data[4]._VAL.asInteger; - g_pGameStatePresence->maxPlayers = structInst->data[5]._VAL.asInteger; - g_pGameStatePresence->ownScore = structInst->data[6]._VAL.asInteger; - g_pGameStatePresence->otherHighestScore = structInst->data[7]._VAL.asInteger; - g_pGameStatePresence->maxScore = structInst->data[8]._VAL.asInteger; - g_pGameStatePresence->timestampEnd = ceil(structInst->data[9]._VAL.asFloat); - - if (g_pMasterServerManager->m_currentServer) - { - g_pGameStatePresence->id = g_pMasterServerManager->m_currentServer->id; - g_pGameStatePresence->name = g_pMasterServerManager->m_currentServer->name; - g_pGameStatePresence->description = g_pMasterServerManager->m_currentServer->description; - g_pGameStatePresence->password = g_pMasterServerManager->m_sCurrentServerPassword; - } - - return SQRESULT_NOTNULL; -} - -ADD_SQFUNC("void", NSPushUIPresence, "UIPresenceStruct presence", "", ScriptContext::UI) -{ - SQStructInstance* structInst = g_pSquirrel->m_pSQVM->sqvm->_stackOfCurrentFunction[1]._VAL.asStructInstance; - - g_pGameStatePresence->isLoading = structInst->data[0]._VAL.asInteger; - g_pGameStatePresence->isLobby = structInst->data[1]._VAL.asInteger; - g_pGameStatePresence->loadingLevel = structInst->data[2]._VAL.asString->_val; - g_pGameStatePresence->uiMap = structInst->data[3]._VAL.asString->_val; - - return SQRESULT_NOTNULL; -} diff --git a/NorthstarDLL/shared/gamepresence.h b/NorthstarDLL/shared/gamepresence.h deleted file mode 100644 index 439ec65c..00000000 --- a/NorthstarDLL/shared/gamepresence.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include "server/serverpresence.h" - -class GameStateServerPresenceReporter : public ServerPresenceReporter -{ - void RunFrame(double flCurrentTime, const ServerPresence* pServerPresence); -}; - -class GameStatePresence -{ - public: - std::string id; - std::string name; - std::string description; - std::string password; // NOTE: May be empty - - bool isServer; - bool isLocal = false; - bool isLoading; - bool isLobby; - std::string loadingLevel; - - std::string uiMap; - - std::string map; - std::string mapDisplayname; - std::string playlist; - std::string playlistDisplayname; - - int currentPlayers; - int maxPlayers; - - int ownScore; - int otherHighestScore; // NOTE: The highest score OR the second highest score if we have the highest - int maxScore; - - int timestampEnd; - - GameStatePresence(); - void RunFrame(); - - protected: - GameStateServerPresenceReporter m_GameStateServerPresenceReporter; -}; - -extern GameStatePresence* g_pGameStatePresence; -- cgit v1.2.3