Moved datapack natives from core to logic (bug 4406 part 10, r=ds).

--HG--
rename : core/smn_datapacks.cpp => core/logic/smn_datapacks.cpp
This commit is contained in:
David Anderson 2010-05-14 21:16:35 -07:00
parent c188491289
commit 96f6cdf677
5 changed files with 25 additions and 23 deletions

View File

@ -71,7 +71,6 @@ for i in SM.sdkInfo:
'EventManager.cpp', 'EventManager.cpp',
'MenuStyle_Radio.cpp', 'MenuStyle_Radio.cpp',
'sm_autonatives.cpp', 'sm_autonatives.cpp',
'smn_datapacks.cpp',
'sm_srvcmds.cpp', 'sm_srvcmds.cpp',
'ConsoleDetours.cpp' 'ConsoleDetours.cpp'
] ]

View File

@ -26,7 +26,7 @@ OBJECTS += smn_bitbuffer.cpp smn_console.cpp smn_core.cpp \
smn_datapacks.cpp smn_entities.cpp smn_events.cpp smn_fakenatives.cpp \ smn_datapacks.cpp smn_entities.cpp smn_events.cpp smn_fakenatives.cpp \
smn_filesystem.cpp smn_gameconfigs.cpp smn_halflife.cpp \ smn_filesystem.cpp smn_gameconfigs.cpp smn_halflife.cpp \
smn_keyvalues.cpp smn_player.cpp \ smn_keyvalues.cpp smn_player.cpp \
smn_usermsgs.cpp smn_menus.cpp smn_database.cpp smn_vector.cpp \ smn_usermsgs.cpp smn_menus.cpp smn_vector.cpp \
smn_hudtext.cpp smn_nextmap.cpp smn_hudtext.cpp smn_nextmap.cpp
OBJECTS += ExtensionSys.cpp \ OBJECTS += ExtensionSys.cpp \
ForwardSys.cpp \ ForwardSys.cpp \

View File

@ -41,6 +41,7 @@ files = [
'smn_lang.cpp', 'smn_lang.cpp',
'smn_string.cpp', 'smn_string.cpp',
'smn_handles.cpp', 'smn_handles.cpp',
'smn_datapacks.cpp',
'sm_crc32.cpp' 'sm_crc32.cpp'
] ]
if AMBuild.target['platform'] == 'windows': if AMBuild.target['platform'] == 'windows':

View File

@ -37,6 +37,7 @@ OBJECTS = \
smn_lang.cpp \ smn_lang.cpp \
smn_string.cpp \ smn_string.cpp \
smn_handles.cpp \ smn_handles.cpp \
smn_datapacks.cpp \
smn_players.cpp smn_players.cpp
############################################## ##############################################

View File

@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 sw=4 tw=99 noet :
* ============================================================================= * =============================================================================
* SourceMod * SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
@ -29,9 +29,10 @@
* Version: $Id$ * Version: $Id$
*/ */
#include "sm_globals.h" #include "common_logic.h"
#include "HandleSys.h" #include <IHandleSys.h>
#include "CDataPack.h" #include <IDataPack.h>
#include <ISourceMod.h>
HandleType_t g_DataPackType; HandleType_t g_DataPackType;
@ -45,35 +46,35 @@ public:
HandleAccess hacc; HandleAccess hacc;
TypeAccess tacc; TypeAccess tacc;
g_HandleSys.InitAccessDefaults(&tacc, &hacc); handlesys->InitAccessDefaults(&tacc, &hacc);
tacc.access[HTypeAccess_Create] = true; tacc.access[HTypeAccess_Create] = true;
tacc.access[HTypeAccess_Inherit] = true; tacc.access[HTypeAccess_Inherit] = true;
tacc.ident = g_pCoreIdent; tacc.ident = g_pCoreIdent;
hacc.access[HandleAccess_Read] = HANDLE_RESTRICT_OWNER; hacc.access[HandleAccess_Read] = HANDLE_RESTRICT_OWNER;
g_DataPackType = g_HandleSys.CreateType("DataPack", this, 0, &tacc, &hacc, g_pCoreIdent, NULL); g_DataPackType = handlesys->CreateType("DataPack", this, 0, &tacc, &hacc, g_pCoreIdent, NULL);
} }
void OnSourceModShutdown() void OnSourceModShutdown()
{ {
g_HandleSys.RemoveType(g_DataPackType, g_pCoreIdent); handlesys->RemoveType(g_DataPackType, g_pCoreIdent);
g_DataPackType = 0; g_DataPackType = 0;
} }
void OnHandleDestroy(HandleType_t type, void *object) void OnHandleDestroy(HandleType_t type, void *object)
{ {
g_SourceMod.FreeDataPack(reinterpret_cast<IDataPack *>(object)); g_pSM->FreeDataPack(reinterpret_cast<IDataPack *>(object));
} }
}; };
static cell_t smn_CreateDataPack(IPluginContext *pContext, const cell_t *params) static cell_t smn_CreateDataPack(IPluginContext *pContext, const cell_t *params)
{ {
IDataPack *pDataPack = g_SourceMod.CreateDataPack(); IDataPack *pDataPack = g_pSM->CreateDataPack();
if (!pDataPack) if (!pDataPack)
{ {
return 0; return 0;
} }
return g_HandleSys.CreateHandle(g_DataPackType, pDataPack, pContext->GetIdentity(), g_pCoreIdent, NULL); return handlesys->CreateHandle(g_DataPackType, pDataPack, pContext->GetIdentity(), g_pCoreIdent, NULL);
} }
static cell_t smn_WritePackCell(IPluginContext *pContext, const cell_t *params) static cell_t smn_WritePackCell(IPluginContext *pContext, const cell_t *params)
@ -86,7 +87,7 @@ static cell_t smn_WritePackCell(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack)) if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@ -107,7 +108,7 @@ static cell_t smn_WritePackFloat(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack)) if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@ -129,7 +130,7 @@ static cell_t smn_WritePackString(IPluginContext *pContext, const cell_t *params
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack)) if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@ -157,7 +158,7 @@ static cell_t smn_ReadPackCell(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack)) if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@ -181,7 +182,7 @@ static cell_t smn_ReadPackFloat(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack)) if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@ -205,7 +206,7 @@ static cell_t smn_ReadPackString(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack)) if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@ -232,7 +233,7 @@ static cell_t smn_ResetPack(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack)) if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@ -257,7 +258,7 @@ static cell_t smn_GetPackPosition(IPluginContext *pContext, const cell_t *params
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack)) if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@ -276,7 +277,7 @@ static cell_t smn_SetPackPosition(IPluginContext *pContext, const cell_t *params
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack)) if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);
@ -300,7 +301,7 @@ static cell_t smn_IsPackReadable(IPluginContext *pContext, const cell_t *params)
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack)) if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid data pack handle %x (error %d)", hndl, herr);