Moved smn_functions to logic binary.

--HG--
rename : core/smn_functions.cpp => core/logic/smn_functions.cpp
This commit is contained in:
"David Anderson 2009-05-14 11:38:50 -04:00
parent fc003db139
commit cec339552e
10 changed files with 59 additions and 40 deletions

View File

@ -22,7 +22,7 @@ OBJECTS = AdminCache.cpp CDataPack.cpp ConCmdManager.cpp ConVarManager.cpp CoreC
NativeOwner.cpp logic_bridge.cpp
OBJECTS += smn_admin.cpp smn_bitbuffer.cpp smn_console.cpp smn_core.cpp \
smn_datapacks.cpp smn_entities.cpp smn_events.cpp smn_fakenatives.cpp \
smn_filesystem.cpp smn_functions.cpp smn_gameconfigs.cpp smn_halflife.cpp \
smn_filesystem.cpp smn_gameconfigs.cpp smn_halflife.cpp \
smn_handles.cpp smn_keyvalues.cpp smn_banning.cpp \
smn_lang.cpp smn_player.cpp smn_string.cpp smn_timers.cpp \
smn_usermsgs.cpp smn_menus.cpp smn_database.cpp smn_vector.cpp \

View File

@ -24,7 +24,8 @@ OBJECTS = \
TextParsers.cpp \
smn_textparse.cpp \
smn_adt_trie.cpp \
Profiler.cpp
Profiler.cpp \
smn_functions.cpp
##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###

View File

@ -47,6 +47,7 @@ IVEngineServer *engine;
IShareSys *sharesys;
IRootConsole *rootmenu;
IPluginManager *pluginsys;
IForwardManager *forwardsys;
static sm_logic_t logic =
{
@ -69,6 +70,7 @@ static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
sharesys = core->sharesys;
rootmenu = core->rootmenu;
pluginsys = core->pluginsys;
forwardsys = core->forwardsys;
}
PLATFORM_EXTERN_C ITextParsers *get_textparsers()

View File

@ -46,6 +46,7 @@ extern IVEngineServer *engine;
extern IShareSys *sharesys;
extern IRootConsole *rootmenu;
extern IPluginManager *pluginsys;
extern IForwardManager *forwardsys;
#endif /* _INCLUDE_SOURCEMOD_COMMON_LOGIC_H_ */

View File

@ -42,7 +42,7 @@ using namespace SourceMod;
* Add 1 to the RHS of this expression to bump the intercom file
* This is to prevent mismatching core/logic binaries
*/
#define SM_LOGIC_MAGIC (0x0F47C0DE - 1)
#define SM_LOGIC_MAGIC (0x0F47C0DE - 2)
#if defined SM_LOGIC
class IVEngineServer
@ -62,6 +62,7 @@ namespace SourceMod
class IThreader;
class IRootConsole;
class IPluginManager;
class IForwardManager;
}
class IVEngineServer;
@ -78,6 +79,7 @@ struct sm_core_t
IShareSys *sharesys;
IRootConsole *rootmenu;
IPluginManager *pluginsys;
IForwardManager *forwardsys;
/* Functions */
void (*AddNatives)(sp_nativeinfo_t* nlist);
ConVar * (*FindConVar)(const char*);

View File

@ -184,6 +184,10 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\smn_functions.cpp"
>
</File>
<File
RelativePath="..\smn_adt_trie.cpp"
>

View File

@ -29,10 +29,10 @@
* Version: $Id$
*/
#include "sm_globals.h"
#include "PluginSys.h"
#include "ForwardSys.h"
#include "HandleSys.h"
#include "common_logic.h"
#include <IPluginSys.h>
#include <IHandleSys.h>
#include <IForwardSys.h>
HandleType_t g_GlobalFwdType = 0;
HandleType_t g_PrivateFwdType = 0;
@ -52,36 +52,36 @@ public:
HandleAccess sec;
/* Set GlobalFwd handle access security */
g_HandleSys.InitAccessDefaults(NULL, &sec);
handlesys->InitAccessDefaults(NULL, &sec);
sec.access[HandleAccess_Read] = 0;
sec.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY | HANDLE_RESTRICT_OWNER;
/* Create 'GlobalFwd' handle type */
g_GlobalFwdType = g_HandleSys.CreateType("GlobalFwd", this, 0, NULL, &sec, g_pCoreIdent, NULL);
g_GlobalFwdType = handlesys->CreateType("GlobalFwd", this, 0, NULL, &sec, g_pCoreIdent, NULL);
/* Private forwards are cloneable */
sec.access[HandleAccess_Clone] = 0;
/* Create 'PrivateFwd' handle type */
g_PrivateFwdType = g_HandleSys.CreateType("PrivateFwd", this, g_GlobalFwdType, NULL, &sec, g_pCoreIdent, NULL);
g_PrivateFwdType = handlesys->CreateType("PrivateFwd", this, g_GlobalFwdType, NULL, &sec, g_pCoreIdent, NULL);
}
void OnSourceModShutdown()
{
g_HandleSys.RemoveType(g_PrivateFwdType, g_pCoreIdent);
g_HandleSys.RemoveType(g_GlobalFwdType, g_pCoreIdent);
handlesys->RemoveType(g_PrivateFwdType, g_pCoreIdent);
handlesys->RemoveType(g_GlobalFwdType, g_pCoreIdent);
}
void OnHandleDestroy(HandleType_t type, void *object)
{
IForward *pForward = static_cast<IForward *>(object);
g_Forwards.ReleaseForward(pForward);
forwardsys->ReleaseForward(pForward);
}
bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize)
{
*pSize = sizeof(CForward) + (((IForward *)object)->GetFunctionCount() * 12);
*pSize = sizeof(IForward*) + (((IForward *)object)->GetFunctionCount() * 12);
return true;
}
} g_ForwardNativeHelpers;
@ -112,9 +112,9 @@ static cell_t sm_GetFunctionByName(IPluginContext *pContext, const cell_t *param
if (hndl == 0)
{
pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else {
pPlugin = g_PluginSys.PluginFromHandle(hndl, &err);
pPlugin = pluginsys->PluginFromHandle(hndl, &err);
if (!pPlugin)
{
@ -155,9 +155,9 @@ static cell_t sm_CreateGlobalForward(IPluginContext *pContext, const cell_t *par
forwardParams[i - 3] = static_cast<ParamType>(*addr);
}
IForward *pForward = g_Forwards.CreateForward(name, static_cast<ExecType>(params[2]), count - 2, forwardParams);
IForward *pForward = forwardsys->CreateForward(name, static_cast<ExecType>(params[2]), count - 2, forwardParams);
return g_HandleSys.CreateHandle(g_GlobalFwdType, pForward, pContext->GetIdentity(), g_pCoreIdent, NULL);
return handlesys->CreateHandle(g_GlobalFwdType, pForward, pContext->GetIdentity(), g_pCoreIdent, NULL);
}
static cell_t sm_CreateForward(IPluginContext *pContext, const cell_t *params)
@ -177,9 +177,9 @@ static cell_t sm_CreateForward(IPluginContext *pContext, const cell_t *params)
forwardParams[i - 2] = static_cast<ParamType>(*addr);
}
IChangeableForward *pForward = g_Forwards.CreateForwardEx(NULL, static_cast<ExecType>(params[1]), count - 1, forwardParams);
IChangeableForward *pForward = forwardsys->CreateForwardEx(NULL, static_cast<ExecType>(params[1]), count - 1, forwardParams);
return g_HandleSys.CreateHandle(g_PrivateFwdType, pForward, pContext->GetIdentity(), g_pCoreIdent, NULL);
return handlesys->CreateHandle(g_PrivateFwdType, pForward, pContext->GetIdentity(), g_pCoreIdent, NULL);
}
static cell_t sm_GetForwardFunctionCount(IPluginContext *pContext, const cell_t *params)
@ -188,7 +188,7 @@ static cell_t sm_GetForwardFunctionCount(IPluginContext *pContext, const cell_t
HandleError err;
IForward *pForward;
if ((err=g_HandleSys.ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid forward handle %x (error %d)", hndl, err);
@ -205,7 +205,7 @@ static cell_t sm_AddToForward(IPluginContext *pContext, const cell_t *params)
IChangeableForward *pForward;
IPlugin *pPlugin;
if ((err=g_HandleSys.ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
@ -213,9 +213,9 @@ static cell_t sm_AddToForward(IPluginContext *pContext, const cell_t *params)
if (plHandle == 0)
{
pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else {
pPlugin = g_PluginSys.PluginFromHandle(plHandle, &err);
pPlugin = pluginsys->PluginFromHandle(plHandle, &err);
if (!pPlugin)
{
@ -241,7 +241,7 @@ static cell_t sm_RemoveFromForward(IPluginContext *pContext, const cell_t *param
IChangeableForward *pForward;
IPlugin *pPlugin;
if ((err=g_HandleSys.ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
@ -249,9 +249,9 @@ static cell_t sm_RemoveFromForward(IPluginContext *pContext, const cell_t *param
if (plHandle == 0)
{
pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else {
pPlugin = g_PluginSys.PluginFromHandle(plHandle, &err);
pPlugin = pluginsys->PluginFromHandle(plHandle, &err);
if (!pPlugin)
{
@ -277,7 +277,7 @@ static cell_t sm_RemoveAllFromForward(IPluginContext *pContext, const cell_t *pa
IChangeableForward *pForward;
IPlugin *pPlugin;
if ((err=g_HandleSys.ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
@ -285,9 +285,9 @@ static cell_t sm_RemoveAllFromForward(IPluginContext *pContext, const cell_t *pa
if (plHandle == 0)
{
pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else {
pPlugin = g_PluginSys.PluginFromHandle(plHandle, &err);
pPlugin = pluginsys->PluginFromHandle(plHandle, &err);
if (!pPlugin)
{
@ -310,9 +310,9 @@ static cell_t sm_CallStartFunction(IPluginContext *pContext, const cell_t *param
if (hndl == 0)
{
pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else {
pPlugin = g_PluginSys.PluginFromHandle(hndl, &err);
pPlugin = pluginsys->PluginFromHandle(hndl, &err);
if (!pPlugin)
{
@ -344,7 +344,7 @@ static cell_t sm_CallStartForward(IPluginContext *pContext, const cell_t *params
hndl = static_cast<Handle_t>(params[1]);
if ((err=g_HandleSys.ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid forward handle %x (error %d)", hndl, err);

View File

@ -42,6 +42,7 @@
#include "Logger.h"
#include "ShareSys.h"
#include "sm_srvcmds.h"
#include "ForwardSys.h"
static ILibrary *g_pLogic = NULL;
static LogicInitFunction logic_init_fn;
@ -95,6 +96,7 @@ static sm_core_t core_bridge =
&g_ShareSys,
&g_RootMenu,
&g_PluginSys,
&g_Forwards,
/* Functions */
add_natives,
find_convar,

View File

@ -1930,10 +1930,6 @@
RelativePath="..\smn_filesystem.cpp"
>
</File>
<File
RelativePath="..\smn_functions.cpp"
>
</File>
<File
RelativePath="..\smn_gameconfigs.cpp"
>

View File

@ -1,8 +1,8 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@ -38,10 +38,11 @@
*/
#include <IShareSys.h>
#include <IHandleSys.h>
#include <sp_vm_api.h>
#define SMINTERFACE_PLUGINSYSTEM_NAME "IPluginManager"
#define SMINTERFACE_PLUGINSYSTEM_VERSION 2
#define SMINTERFACE_PLUGINSYSTEM_VERSION 3
/** Context user slot 3 is used Core for holding an IPluginContext pointer. */
#define SM_CONTEXTVAR_USER 3
@ -353,7 +354,17 @@ namespace SourceMod
* @param listener Pointer to a listener.
*/
virtual void RemovePluginsListener(IPluginsListener *listener) =0;
/**
* @brief Converts a Handle to an IPlugin if possible.
*
* @param handle Handle.
* @param err Error, set on failure (otherwise undefined).
* @return IPlugin pointer, or NULL on failure.
*/
virtual IPlugin *PluginFromHandle(Handle_t handle, HandleError *err) =0;
};
}
#endif //_INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_