1.1 --- a/core/sourcemod.cpp Fri Jan 19 01:50:42 2007 +0000
1.2 +++ b/core/sourcemod.cpp Fri Jan 19 02:14:50 2007 +0000
1.3 @@ -50,7 +50,7 @@
1.4 char file[PLATFORM_MAX_PATH];
1.5 char myerror[255];
1.6 g_SMAPI->PathFormat(file, sizeof(file), "%s/bin/sourcepawn.jit.x86.%s",
1.7 - GetSMBaseDir(),
1.8 + GetSourceModPath(),
1.9 PLATFORM_LIB_EXT
1.10 );
1.11
1.12 @@ -150,6 +150,9 @@
1.13 pBase->OnSourceModAllInitialized();
1.14 pBase = pBase->m_pGlobalClassNext;
1.15 }
1.16 +
1.17 + /* Add us now... */
1.18 + g_ShareSys.AddInterface(NULL, this);
1.19 }
1.20
1.21 bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
1.22 @@ -175,14 +178,12 @@
1.23 char config_path[PLATFORM_MAX_PATH];
1.24 char plugins_path[PLATFORM_MAX_PATH];
1.25
1.26 - g_SMAPI->PathFormat(config_path,
1.27 + BuildPath(Path_SM, config_path,
1.28 sizeof(config_path),
1.29 - "%s/configs/plugin_settings.cfg",
1.30 - GetSMBaseDir());
1.31 - g_SMAPI->PathFormat(plugins_path,
1.32 + "configs/plugin_settings.cfg");
1.33 + BuildPath(Path_SM, plugins_path,
1.34 sizeof(plugins_path),
1.35 - "%s/plugins",
1.36 - GetSMBaseDir());
1.37 + "plugins");
1.38
1.39 /* Run the first pass */
1.40 g_PluginSys.LoadAll_FirstPass(config_path, plugins_path);
1.41 @@ -197,6 +198,31 @@
1.42 g_Extensions.MarkAllLoaded();
1.43 }
1.44
1.45 +size_t SourceModBase::BuildPath(PathType type, char *buffer, size_t maxlength, char *format, ...)
1.46 +{
1.47 + char _buffer[PLATFORM_MAX_PATH+1];
1.48 + va_list ap;
1.49 +
1.50 + va_start(ap, format);
1.51 + vsnprintf(_buffer, PLATFORM_MAX_PATH, format, ap);
1.52 + va_end(ap);
1.53 +
1.54 + const char *base = NULL;
1.55 + if (type == Path_Game)
1.56 + {
1.57 + base = GetModPath();
1.58 + } else if (type == Path_SM) {
1.59 + base = GetSourceModPath();
1.60 + }
1.61 +
1.62 + if (base)
1.63 + {
1.64 + return g_LibSys.PathFormat(buffer, maxlength, "%s/%s", base, _buffer);
1.65 + } else {
1.66 + return g_LibSys.PathFormat(buffer, maxlength, "%s", _buffer);
1.67 + }
1.68 +}
1.69 +
1.70 void SourceModBase::CloseSourceMod()
1.71 {
1.72 /* Notify! */
1.73 @@ -219,12 +245,50 @@
1.74 ShutdownJIT();
1.75 }
1.76
1.77 -const char *SourceModBase::GetSMBaseDir()
1.78 +void SourceModBase::LogMessage(IExtension *pExt, const char *format, ...)
1.79 +{
1.80 + IExtensionInterface *pAPI = pExt->GetAPI();
1.81 + const char *tag = pAPI->GetExtensionTag();
1.82 + char buffer[2048];
1.83 + va_list ap;
1.84 +
1.85 + va_start(ap, format);
1.86 + vsnprintf(buffer, sizeof(buffer), format, ap);
1.87 + va_end(ap);
1.88 +
1.89 + if (tag)
1.90 + {
1.91 + g_Logger.LogMessage("[%s] %s", tag, buffer);
1.92 + } else {
1.93 + g_Logger.LogMessage("%s", buffer);
1.94 + }
1.95 +}
1.96 +
1.97 +void SourceModBase::LogError(IExtension *pExt, const char *format, ...)
1.98 +{
1.99 + IExtensionInterface *pAPI = pExt->GetAPI();
1.100 + const char *tag = pAPI->GetExtensionTag();
1.101 + char buffer[2048];
1.102 + va_list ap;
1.103 +
1.104 + va_start(ap, format);
1.105 + vsnprintf(buffer, sizeof(buffer), format, ap);
1.106 + va_end(ap);
1.107 +
1.108 + if (tag)
1.109 + {
1.110 + g_Logger.LogError("[%s] %s", tag, buffer);
1.111 + } else {
1.112 + g_Logger.LogError("%s", buffer);
1.113 + }
1.114 +}
1.115 +
1.116 +const char *SourceModBase::GetSourceModPath()
1.117 {
1.118 return m_SMBaseDir;
1.119 }
1.120
1.121 -const char *SourceModBase::GetBaseDir()
1.122 +const char *SourceModBase::GetModPath()
1.123 {
1.124 return g_BaseDir.c_str();
1.125 }