Skip to content

Commit

Permalink
Merge branch 'main' into fix/multiple-mod-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alystrasz authored Oct 17, 2024
2 parents 4b143d7 + 27e1711 commit 01281e7
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 41 deletions.
1 change: 0 additions & 1 deletion primedev/Northstar.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ add_library(
"core/memalloc.cpp"
"core/memalloc.h"
"core/sourceinterface.cpp"
"core/sourceinterface.h"
"core/tier0.cpp"
"core/tier0.h"
"core/tier1.cpp"
Expand Down
1 change: 0 additions & 1 deletion primedev/core/convar/convar.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once
#include "core/sourceinterface.h"
#include "core/math/color.h"
#include "cvar.h"
#include "concommand.h"
Expand Down
4 changes: 2 additions & 2 deletions primedev/core/filesystem/rpakfilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,15 @@ void PakLoadManager::UnloadDependentPaks(PakHandle handle)
static void HandlePakAliases(std::string& originalPath)
{
// convert the pak being loaded to its aliased one, e.g. aliasing mp_hub_timeshift => sp_hub_timeshift
for (int64_t i = g_pModManager->m_LoadedMods.size() - 1; i > PakHandle::INVALID; i--)
for (int64_t i = g_pModManager->m_LoadedMods.size() - 1; i > -1; i--)
{
Mod* mod = &g_pModManager->m_LoadedMods[i];
if (!mod->m_bEnabled)
continue;

if (mod->RpakAliases.find(originalPath) != mod->RpakAliases.end())
{
originalPath = (mod->m_ModDirectory / "paks" / mod->RpakAliases[originalPath]).string();
originalPath = mod->RpakAliases[originalPath];
return;
}
}
Expand Down
1 change: 0 additions & 1 deletion primedev/core/sourceinterface.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "sourceinterface.h"
#include "logging/sourceconsole.h"

// really wanted to do a modular callback system here but honestly couldn't be bothered so hardcoding stuff for now: todo later
Expand Down
32 changes: 0 additions & 32 deletions primedev/core/sourceinterface.h

This file was deleted.

6 changes: 6 additions & 0 deletions primedev/core/tier1.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

#define CREATEINTERFACE_PROCNAME "CreateInterface"

enum class InterfaceStatus : int
{
IFACE_OK = 0,
IFACE_FAILED,
};

typedef void* (*CreateInterfaceFn)(const char* pName, int* pReturnCode);

CMemory Sys_GetFactoryPtr(const std::string& svModuleName, const std::string& svFact);
1 change: 0 additions & 1 deletion primedev/logging/sourceconsole.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once
#include "core/sourceinterface.h"
#include "spdlog/sinks/base_sink.h"
#include <map>

Expand Down
1 change: 1 addition & 0 deletions primedev/plugins/interfaces/IPluginId.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum class PluginString : int
enum class PluginField : int
{
CONTEXT = 0,
COLOR = 1,
};

// an interface that is required from every plugin to query data about it
Expand Down
1 change: 1 addition & 0 deletions primedev/plugins/interfaces/interface.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <string.h>
#include "core/tier1.h"
#include "interface.h"

InterfaceReg* s_pInterfaceRegs;
Expand Down
1 change: 1 addition & 0 deletions primedev/plugins/interfaces/sys/ISys.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "core/tier1.h"
#include "plugins/interfaces/interface.h"
#include "ISys.h"
#include "plugins/plugins.h"
Expand Down
11 changes: 9 additions & 2 deletions primedev/plugins/plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "pluginmanager.h"
#include "squirrel/squirrel.h"
#include "util/wininfo.h"
#include "core/sourceinterface.h"
#include "logging/logging.h"
#include "dedicated/dedicated.h"

Expand All @@ -24,6 +23,7 @@ bool isValidSquirrelIdentifier(std::string s)

Plugin::Plugin(std::string path)
: m_location(path)
, m_logColor(NS::Colors::PLUGIN)
{
HMODULE pluginModule = GetModuleHandleA(path.c_str());

Expand Down Expand Up @@ -70,6 +70,13 @@ Plugin::Plugin(std::string path)
m_runOnServer = context & PluginContext::DEDICATED;
m_runOnClient = context & PluginContext::CLIENT;

int64_t logColor = m_pluginId->GetField(PluginField::COLOR);
// Apply custom colour if plugin has specified one
if ((logColor & 0xFFFFFF) != 0)
{
m_logColor = Color((int)(logColor & 0xFF), (int)((logColor >> 8) & 0xFF), (int)((logColor >> 16) & 0xFF));
}

if (!name)
{
NS::log::PLUGINSYS->error("Could not load name of plugin at '{}'", path);
Expand Down Expand Up @@ -106,7 +113,7 @@ Plugin::Plugin(std::string path)
return;
}

m_logger = std::make_shared<ColoredLogger>(m_logName, NS::Colors::PLUGIN);
m_logger = std::make_shared<ColoredLogger>(m_logName, m_logColor);
RegisterLogger(m_logger);

if (IsDedicatedServer() && !m_runOnServer)
Expand Down
3 changes: 2 additions & 1 deletion primedev/plugins/plugins.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "core/sourceinterface.h"
#include "core/tier1.h"
#include "plugins/interfaces/interface.h"
#include "plugins/interfaces/IPluginId.h"
#include "plugins/interfaces/IPluginCallbacks.h"
Expand All @@ -20,6 +20,7 @@ class Plugin
std::string m_location; // path of the dll
bool m_runOnServer;
bool m_runOnClient;
Color m_logColor;

public:
HMODULE m_handle;
Expand Down

0 comments on commit 01281e7

Please sign in to comment.