2 * vim: set ts=4 sw=4 tw=99 noet:
3 * =============================================================================
5 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
33 #include <sm_platform.h>
36 #include "common_logic.h"
37 #include "TextParsers.h"
40 #include "MemoryUtils.h"
41 #include "stringutil.h"
42 #include "ThreadSupport.h"
43 #include "Translator.h"
44 #include "GameConfigs.h"
45 #include "DebugReporter.h"
46 #include "PluginSys.h"
48 #include "NativeOwner.h"
49 #include "HandleSys.h"
50 #include "ExtensionSys.h"
51 #include "ForwardSys.h"
54 IHandleSys *handlesys = &g_HandleSys;
55 IdentityToken_t *g_pCoreIdent;
56 SMGlobalClass *SMGlobalClass::head = NULL;
59 ITextParsers *textparser = &g_TextParser;
60 IVEngineServer *engine;
61 IShareSys *sharesys = &g_ShareSys;
62 IRootConsole *rootmenu;
63 IPluginManager *pluginsys = g_PluginSys.GetOldAPI();
64 IForwardManager *forwardsys = &g_Forwards;
65 ITimerSystem *timersys;
66 ServerGlobals serverGlobals;
67 IPlayerManager *playerhelpers;
68 IAdminSystem *adminsys;
69 IGameHelpers *gamehelpers;
70 ISourcePawnEngine *g_pSourcePawn;
71 ISourcePawnEngine2 *g_pSourcePawn2;
72 CNativeOwner g_CoreNatives;
73 IScriptManager *scripts = &g_PluginSys;
75 static void AddCorePhraseFile(const char *filename)
77 g_pCorePhrases->AddPhraseFile(filename);
80 static IGameConfig *GetCoreGameConfig()
85 // Defined in smn_filesystem.cpp.
86 extern bool OnLogPrint(const char *msg);
88 static void GenerateError(IPluginContext *ctx, cell_t idx, int err, const char *msg, ...)
92 g_DbgReporter.GenerateErrorVA(ctx, idx, err, msg, ap);
96 static void AddNatives(sp_nativeinfo_t *natives)
98 g_CoreNatives.AddNatives(natives);
101 static void DumpHandles(void (*dumpfn)(const char *fmt, ...))
103 g_HandleSys.Dump(dumpfn);
106 static sm_logic_t logic =
117 UTIL_DecodeHexString,
133 static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
135 logic.head = SMGlobalClass::head;
137 memcpy(&smcore, core, sizeof(sm_core_t));
138 memcpy(_logic, &logic, sizeof(sm_logic_t));
139 memcpy(&serverGlobals, core->serverGlobals, sizeof(ServerGlobals));
141 libsys = core->libsys;
142 engine = core->engine;
144 rootmenu = core->rootmenu;
145 timersys = core->timersys;
146 playerhelpers = core->playerhelpers;
147 adminsys = core->adminsys;
148 gamehelpers = core->gamehelpers;
149 g_pSourcePawn = *core->spe1;
150 g_pSourcePawn2 = *core->spe2;
151 SMGlobalClass::head = core->listeners;
153 g_ShareSys.Initialize();
154 g_pCoreIdent = g_ShareSys.CreateCoreIdentity();
156 _logic->core_ident = g_pCoreIdent;
159 PLATFORM_EXTERN_C ITextParsers *get_textparsers()
161 return &g_TextParser;
164 PLATFORM_EXTERN_C LogicInitFunction logic_load(uint32_t magic)
166 if (magic != SM_LOGIC_MAGIC)
174 void CoreNativesToAdd::OnSourceModAllInitialized()
176 g_CoreNatives.AddNatives(m_NativeList);
179 /* Overload a few things to prevent libstdc++ linking */
180 #if defined __linux__ || defined __APPLE__
181 extern "C" void __cxa_pure_virtual(void)
185 void *operator new(size_t size)
190 void *operator new[](size_t size)
195 void operator delete(void *ptr)
200 void operator delete[](void * ptr)