Import of core modularization plan (bug 3599).
This commit is contained in:
parent
850dbd62c6
commit
421b58f68e
@ -37,7 +37,7 @@
|
||||
#include "Logger.h"
|
||||
#include "ExtensionSys.h"
|
||||
#include <stdlib.h>
|
||||
#include "ThreadSupport.h"
|
||||
#include <IThreader.h>
|
||||
|
||||
#define DBPARSE_LEVEL_NONE 0
|
||||
#define DBPARSE_LEVEL_MAIN 1
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "sm_globals.h"
|
||||
#include "sm_memtable.h"
|
||||
#include "sm_trie_tpl.h"
|
||||
#include "ThreadSupport.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
using namespace SourceHook;
|
||||
|
@ -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
|
||||
@ -378,6 +378,14 @@ print_error:
|
||||
}
|
||||
|
||||
void Logger::LogError(const char *vafmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, vafmt);
|
||||
LogErrorEx(vafmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void Logger::LogErrorEx(const char *vafmt, va_list ap)
|
||||
{
|
||||
if (!m_Active)
|
||||
{
|
||||
@ -408,10 +416,7 @@ void Logger::LogError(const char *vafmt, ...)
|
||||
fprintf(fp, "L %s: Info (map \"%s\") (file \"errors_%04d%02d%02d.log\")\n", date, m_CurMapName.c_str(), curtime->tm_year + 1900, curtime->tm_mon + 1, curtime->tm_mday);
|
||||
m_ErrMapStart = true;
|
||||
}
|
||||
va_list ap;
|
||||
va_start(ap, vafmt);
|
||||
LogToOpenFileEx(fp, vafmt, ap);
|
||||
va_end(ap);
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
|
@ -75,6 +75,7 @@ public:
|
||||
void DisableLogging();
|
||||
void LogMessage(const char *msg, ...);
|
||||
void LogError(const char *msg, ...);
|
||||
void LogErrorEx(const char *msg, va_list ap);
|
||||
void LogFatal(const char *msg, ...);
|
||||
void LogToOpenFile(FILE *fp, const char *msg, ...);
|
||||
void LogToOpenFileEx(FILE *fp, const char *msg, va_list ap);
|
||||
|
@ -14,19 +14,19 @@ MMSOURCE17 = ../../mmsource-1.7
|
||||
|
||||
OBJECTS = AdminCache.cpp CDataPack.cpp ConCmdManager.cpp ConVarManager.cpp CoreConfig.cpp \
|
||||
Database.cpp DebugReporter.cpp EventManager.cpp GameConfigs.cpp HalfLife2.cpp Logger.cpp \
|
||||
MemoryUtils.cpp PlayerManager.cpp TextParsers.cpp TimerSys.cpp Translator.cpp UserMessages.cpp \
|
||||
MemoryUtils.cpp PlayerManager.cpp TimerSys.cpp Translator.cpp UserMessages.cpp \
|
||||
sm_autonatives.cpp sm_memtable.cpp sm_srvcmds.cpp sm_stringutil.cpp sm_trie.cpp \
|
||||
sourcemm_api.cpp sourcemod.cpp MenuStyle_Base.cpp MenuStyle_Valve.cpp MenuManager.cpp \
|
||||
MenuStyle_Radio.cpp ChatTriggers.cpp ADTFactory.cpp MenuVoting.cpp sm_crc32.cpp \
|
||||
frame_hooks.cpp concmd_cleaner.cpp Profiler.cpp PhraseCollection.cpp NextMap.cpp \
|
||||
NativeOwner.cpp
|
||||
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_float.cpp smn_functions.cpp smn_gameconfigs.cpp smn_halflife.cpp \
|
||||
smn_handles.cpp smn_keyvalues.cpp smn_banning.cpp smn_maplists.cpp \
|
||||
smn_lang.cpp smn_player.cpp smn_string.cpp smn_sorting.cpp smn_textparse.cpp smn_timers.cpp \
|
||||
smn_usermsgs.cpp smn_menus.cpp smn_database.cpp smn_vector.cpp smn_adt_array.cpp \
|
||||
smn_adt_trie.cpp smn_hudtext.cpp smn_adt_stack.cpp smn_nextmap.cpp
|
||||
smn_filesystem.cpp smn_functions.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 \
|
||||
smn_adt_trie.cpp smn_hudtext.cpp smn_nextmap.cpp
|
||||
OBJECTS += ExtensionSys.cpp \
|
||||
ForwardSys.cpp \
|
||||
HandleSys.cpp \
|
||||
@ -35,7 +35,6 @@ OBJECTS += ExtensionSys.cpp \
|
||||
PluginSys.cpp \
|
||||
ShareSys.cpp \
|
||||
NativeInvoker.cpp
|
||||
OBJECTS += thread/ThreadWorker.cpp thread/BaseWorker.cpp thread/PosixThreads.cpp ThreadSupport.cpp
|
||||
|
||||
##############################################
|
||||
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
|
||||
@ -85,7 +84,7 @@ endif
|
||||
CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4
|
||||
|
||||
LINK += $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a vstdlib_i486.so \
|
||||
tier0_i486.so -lpthread -static-libgcc
|
||||
tier0_i486.so -static-libgcc
|
||||
|
||||
INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/vstdlib \
|
||||
-I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I$(METAMOD) -I$(METAMOD)/sourcehook \
|
||||
@ -124,8 +123,6 @@ $(BIN_DIR)/%.o: %.c
|
||||
$(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
all: check
|
||||
mkdir -p $(BIN_DIR)/systems
|
||||
mkdir -p $(BIN_DIR)/thread
|
||||
ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so;
|
||||
ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so;
|
||||
$(MAKE) -f Makefile sourcemod
|
||||
@ -146,6 +143,5 @@ default: all
|
||||
|
||||
clean: check
|
||||
rm -rf $(BIN_DIR)/*.o
|
||||
rm -rf $(BIN_DIR)/systems/*.o
|
||||
rm -rf $(BIN_DIR)/thread/*.o
|
||||
rm -rf $(BIN_DIR)/$(BINARY)
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "ForwardSys.h"
|
||||
#include "sourcemm_api.h"
|
||||
#include "sourcemod.h"
|
||||
#include "TextParsers.h"
|
||||
#include "Logger.h"
|
||||
#include "ExtensionSys.h"
|
||||
#include "sm_srvcmds.h"
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "PlayerManager.h"
|
||||
#include "CoreConfig.h"
|
||||
#include <sm_queue.h>
|
||||
#include "ThreadSupport.h"
|
||||
#include <IThreader.h>
|
||||
|
||||
static IMutex *frame_mutex;
|
||||
static Queue<FrameAction> *frame_queue;
|
||||
|
@ -29,6 +29,9 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_CELLARRAY_H_
|
||||
#define _INCLUDE_SOURCEMOD_CELLARRAY_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -204,3 +207,6 @@ private:
|
||||
size_t m_AllocSize;
|
||||
size_t m_Size;
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE_SOURCEMOD_CELLARRAY_H_ */
|
||||
|
89
core/logic/Makefile
Normal file
89
core/logic/Makefile
Normal file
@ -0,0 +1,89 @@
|
||||
# (C)2004-2008 SourceMod Development Team
|
||||
# Makefile written by David "BAILOPAN" Anderson
|
||||
|
||||
SMSDK = ../..
|
||||
MMSOURCE17 = ../../../mmsource-1.7
|
||||
|
||||
#####################################
|
||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||
#####################################
|
||||
|
||||
BINARY = sourcemod.logic.so
|
||||
|
||||
OBJECTS = \
|
||||
common_logic.cpp \
|
||||
smn_adt_array.cpp \
|
||||
smn_sorting.cpp \
|
||||
smn_maplists.cpp \
|
||||
smn_adt_stack.cpp \
|
||||
thread/ThreadWorker.cpp \
|
||||
thread/BaseWorker.cpp \
|
||||
thread/PosixThreads.cpp \
|
||||
ThreadSupport.cpp \
|
||||
smn_float.cpp \
|
||||
TextParsers.cpp \
|
||||
smn_textparse.cpp
|
||||
|
||||
##############################################
|
||||
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
|
||||
##############################################
|
||||
|
||||
C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing
|
||||
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
|
||||
C_GCC4_FLAGS = -fvisibility=hidden
|
||||
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
|
||||
CPP = gcc
|
||||
|
||||
LINK += -lpthread -static-libgcc
|
||||
|
||||
INCLUDE += -I. -I$(MMSOURCE17)/core/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn
|
||||
|
||||
CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
|
||||
-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror \
|
||||
-Wno-uninitialized -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -DSM_DEFAULT_THREADER -m32 \
|
||||
-DSM_LOGIC
|
||||
CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
|
||||
|
||||
################################################
|
||||
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
|
||||
################################################
|
||||
|
||||
ifeq "$(DEBUG)" "true"
|
||||
BIN_DIR = Debug
|
||||
CFLAGS += $(C_DEBUG_FLAGS)
|
||||
else
|
||||
BIN_DIR = Release
|
||||
CFLAGS += $(C_OPT_FLAGS)
|
||||
endif
|
||||
|
||||
GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
|
||||
ifeq "$(GCC_VERSION)" "4"
|
||||
CFLAGS += $(C_GCC4_FLAGS)
|
||||
CPPFLAGS += $(CPP_GCC4_FLAGS)
|
||||
endif
|
||||
|
||||
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
|
||||
OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o)
|
||||
|
||||
$(BIN_DIR)/%.o: %.cpp
|
||||
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
|
||||
|
||||
$(BIN_DIR)/%.o: %.c
|
||||
$(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
all:
|
||||
mkdir -p $(BIN_DIR)/thread
|
||||
$(MAKE) -f Makefile sourcemod
|
||||
|
||||
sourcemod: $(OBJ_LINUX)
|
||||
$(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o $(BIN_DIR)/$(BINARY)
|
||||
|
||||
debug:
|
||||
$(MAKE) -f Makefile all DEBUG=true
|
||||
|
||||
default: all
|
||||
|
||||
clean:
|
||||
rm -rf $(BIN_DIR)/*.o
|
||||
rm -rf $(BIN_DIR)/thread/*.o
|
||||
rm -rf $(BIN_DIR)/$(BINARY)
|
@ -36,9 +36,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include "TextParsers.h"
|
||||
#include "ShareSys.h"
|
||||
#include "sm_stringutil.h"
|
||||
#include "LibrarySys.h"
|
||||
#include <ILibrarySys.h>
|
||||
|
||||
TextParsers g_TextParser;
|
||||
ITextParsers *textparsers = &g_TextParser;
|
||||
@ -71,7 +69,7 @@ TextParsers::TextParsers()
|
||||
|
||||
void TextParsers::OnSourceModAllInitialized()
|
||||
{
|
||||
g_ShareSys.AddInterface(NULL, this);
|
||||
sharesys->AddInterface(NULL, this);
|
||||
}
|
||||
|
||||
unsigned int TextParsers::GetUTF8CharBytes(const char *stream)
|
||||
@ -135,8 +133,8 @@ SMCError TextParsers::ParseSMCFile(const char *file,
|
||||
states->line = 0;
|
||||
states->col = 0;
|
||||
}
|
||||
g_LibSys.GetPlatformError(error, sizeof(error));
|
||||
UTIL_Format(buffer, maxsize, "File could not be opened: %s", error);
|
||||
libsys->GetPlatformError(error, sizeof(error));
|
||||
smcore.Format(buffer, maxsize, "File could not be opened: %s", error);
|
||||
return SMCError_StreamOpen;
|
||||
}
|
||||
|
||||
@ -145,7 +143,7 @@ SMCError TextParsers::ParseSMCFile(const char *file,
|
||||
fclose(fp);
|
||||
|
||||
errstr = GetSMCErrorString(result);
|
||||
UTIL_Format(buffer, maxsize, "%s", errstr != NULL ? errstr : "Unknown error");
|
||||
smcore.Format(buffer, maxsize, "%s", errstr != NULL ? errstr : "Unknown error");
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -196,7 +194,7 @@ SMCError TextParsers::ParseSMCStream(const char *stream,
|
||||
result = ParseStream_SMC(&rs, RawStreamReader, smc_listener, states);
|
||||
|
||||
const char *errstr = GetSMCErrorString(result);
|
||||
UTIL_Format(buffer, maxsize, "%s", errstr != NULL ? errstr : "Unknown error");
|
||||
smcore.Format(buffer, maxsize, "%s", errstr != NULL ? errstr : "Unknown error");
|
||||
|
||||
return result;
|
||||
}
|
@ -33,7 +33,7 @@
|
||||
#define _INCLUDE_SOURCEMOD_TEXTPARSERS_H_
|
||||
|
||||
#include <ITextParsers.h>
|
||||
#include "sm_globals.h"
|
||||
#include "common_logic.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
|
@ -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
|
||||
@ -28,10 +28,9 @@
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <sm_platform.h>
|
||||
#include "ThreadSupport.h"
|
||||
#include "sm_globals.h"
|
||||
#include "ShareSys.h"
|
||||
#include "common_logic.h"
|
||||
|
||||
#if defined PLATFORM_POSIX
|
||||
#include "thread/PosixThreads.h"
|
||||
@ -47,6 +46,7 @@ class RegThreadStuff : public SMGlobalClass
|
||||
public:
|
||||
void OnSourceModAllInitialized()
|
||||
{
|
||||
g_ShareSys.AddInterface(NULL, g_pThreader);
|
||||
sharesys->AddInterface(NULL, g_pThreader);
|
||||
}
|
||||
} s_RegThreadStuff;
|
||||
|
116
core/logic/common_logic.cpp
Normal file
116
core/logic/common_logic.cpp
Normal file
@ -0,0 +1,116 @@
|
||||
/**
|
||||
* vim: set ts=4 sw=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
#include <new>
|
||||
#include <stdlib.h>
|
||||
#include <sm_platform.h>
|
||||
#include <string.h>
|
||||
#include "common_logic.h"
|
||||
#include "ThreadSupport.h"
|
||||
#include "TextParsers.h"
|
||||
|
||||
sm_core_t smcore;
|
||||
IHandleSys *handlesys;
|
||||
IdentityToken_t *g_pCoreIdent;
|
||||
SMGlobalClass *SMGlobalClass::head = NULL;
|
||||
ISourceMod *g_pSM;
|
||||
ILibrarySys *libsys;
|
||||
ITextParsers *textparser = &g_TextParser;
|
||||
IVEngineServer *engine;
|
||||
IShareSys *sharesys;
|
||||
|
||||
static sm_logic_t logic =
|
||||
{
|
||||
NULL,
|
||||
g_pThreader
|
||||
};
|
||||
|
||||
static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
|
||||
{
|
||||
logic.head = SMGlobalClass::head;
|
||||
|
||||
memcpy(&smcore, core, sizeof(sm_core_t));
|
||||
memcpy(_logic, &logic, sizeof(sm_logic_t));
|
||||
|
||||
handlesys = core->handlesys;
|
||||
libsys = core->libsys;
|
||||
engine = core->engine;
|
||||
g_pCoreIdent = core->core_ident;
|
||||
g_pSM = core->sm;
|
||||
sharesys = core->sharesys;
|
||||
}
|
||||
|
||||
PLATFORM_EXTERN_C ITextParsers *get_textparsers()
|
||||
{
|
||||
return &g_TextParser;
|
||||
}
|
||||
|
||||
PLATFORM_EXTERN_C LogicInitFunction logic_load(uint32_t magic)
|
||||
{
|
||||
if (magic != SM_LOGIC_MAGIC)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return logic_init;
|
||||
}
|
||||
|
||||
void CoreNativesToAdd::OnSourceModAllInitialized()
|
||||
{
|
||||
smcore.AddNatives(m_NativeList);
|
||||
}
|
||||
|
||||
/* Overload a few things to prevent libstdc++ linking */
|
||||
#if defined __linux__ || defined __APPLE__
|
||||
extern "C" void __cxa_pure_virtual(void)
|
||||
{
|
||||
}
|
||||
|
||||
void *operator new(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *operator new[](size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void operator delete(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void * ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
#endif
|
||||
|
49
core/logic/common_logic.h
Normal file
49
core/logic/common_logic.h
Normal file
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_COMMON_LOGIC_H_
|
||||
#define _INCLUDE_SOURCEMOD_COMMON_LOGIC_H_
|
||||
|
||||
#include <IHandleSys.h>
|
||||
|
||||
#include "../sm_globals.h"
|
||||
#include "intercom.h"
|
||||
|
||||
extern sm_core_t smcore;
|
||||
extern IHandleSys *handlesys;
|
||||
extern ISourceMod *g_pSM;
|
||||
extern ILibrarySys *libsys;
|
||||
extern ITextParsers *textparser;
|
||||
extern IVEngineServer *engine;
|
||||
extern IShareSys *sharesys;
|
||||
|
||||
#endif /* _INCLUDE_SOURCEMOD_COMMON_LOGIC_H_ */
|
||||
|
98
core/logic/intercom.h
Normal file
98
core/logic/intercom.h
Normal file
@ -0,0 +1,98 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <sp_vm_api.h>
|
||||
#include <IHandleSys.h>
|
||||
#include <IShareSys.h>
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_INTERCOM_H_
|
||||
#define _INCLUDE_SOURCEMOD_INTERCOM_H_
|
||||
|
||||
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 - 0)
|
||||
|
||||
#if defined SM_LOGIC
|
||||
class IVEngineServer
|
||||
#else
|
||||
class IVEngineServer_Logic
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
virtual bool IsMapValid(const char *map) = 0;
|
||||
};
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
class ISourceMod;
|
||||
class ILibrarySys;
|
||||
class ITextParsers;
|
||||
class IThreader;
|
||||
}
|
||||
|
||||
class IVEngineServer;
|
||||
class ConVar;
|
||||
|
||||
struct sm_core_t
|
||||
{
|
||||
/* Objects */
|
||||
IHandleSys *handlesys;
|
||||
IdentityToken_t *core_ident;
|
||||
ISourceMod *sm;
|
||||
ILibrarySys *libsys;
|
||||
IVEngineServer *engine;
|
||||
IShareSys *sharesys;
|
||||
/* Functions */
|
||||
void (*AddNatives)(sp_nativeinfo_t* nlist);
|
||||
ConVar * (*FindConVar)(const char*);
|
||||
unsigned int (*strncopy)(char*, const char*, size_t);
|
||||
char * (*TrimWhitespace)(char *, size_t &);
|
||||
void (*LogError)(const char*, ...);
|
||||
const char * (*GetCvarString)(ConVar*);
|
||||
size_t (*Format)(char*, size_t, const char*, ...);
|
||||
};
|
||||
|
||||
struct sm_logic_t
|
||||
{
|
||||
SMGlobalClass *head;
|
||||
IThreader *threader;
|
||||
};
|
||||
|
||||
typedef void (*LogicInitFunction)(const sm_core_t *core, sm_logic_t *logic);
|
||||
typedef LogicInitFunction (*LogicLoadFunction)(uint32_t magic);
|
||||
typedef ITextParsers *(*GetITextParsers)();
|
||||
|
||||
#endif /* _INCLUDE_SOURCEMOD_INTERCOM_H_ */
|
||||
|
20
core/logic/msvc9/logic.sln
Executable file
20
core/logic/msvc9/logic.sln
Executable file
@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logic", "logic.vcproj", "{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
307
core/logic/msvc9/logic.vcproj
Executable file
307
core/logic/msvc9/logic.vcproj
Executable file
@ -0,0 +1,307 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="logic"
|
||||
ProjectGUID="{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}"
|
||||
RootNamespace="jitx86"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..;"$(MMSOURCE17)\core\sourcehook";..\..\..\public;..\..\..\public\sourcepawn"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;JITX86_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SM_DEFAULT_THREADER"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
EnableEnhancedInstructionSet="0"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\sourcepawn.jit.x86.dll"
|
||||
LinkIncremental="2"
|
||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories="..;"$(MMSOURCE17)\core\sourcehook";..\..\..\public;..\..\..\public\sourcepawn"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;JITX86_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SM_LOGIC;SM_DEFAULT_THREADER"
|
||||
RuntimeLibrary="0"
|
||||
EnableEnhancedInstructionSet="0"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\sourcemod.logic.dll"
|
||||
LinkIncremental="1"
|
||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMTD"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\common_logic.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_adt_array.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_adt_stack.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_float.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_maplists.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_sorting.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_textparse.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\TextParsers.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ThreadSupport.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\CellArray.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\common_logic.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\intercom.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\svn_version.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\TextParsers.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ThreadSupport.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\svn_version.tpl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\version.rc"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Threads"
|
||||
>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\thread\BaseWorker.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\thread\ThreadWorker.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\thread\WinThreads.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\thread\BaseWorker.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\thread\ThreadWorker.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\thread\WinThreads.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
@ -30,10 +30,8 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "sm_globals.h"
|
||||
#include "sm_stringutil.h"
|
||||
#include "common_logic.h"
|
||||
#include "CellArray.h"
|
||||
#include "HandleSys.h"
|
||||
|
||||
HandleType_t htCellArray;
|
||||
|
||||
@ -44,11 +42,11 @@ class CellArrayHelpers :
|
||||
public: //SMGlobalClass
|
||||
void OnSourceModAllInitialized()
|
||||
{
|
||||
htCellArray = g_HandleSys.CreateType("CellArray", this, 0, NULL, NULL, g_pCoreIdent, NULL);
|
||||
htCellArray = handlesys->CreateType("CellArray", this, 0, NULL, NULL, g_pCoreIdent, NULL);
|
||||
}
|
||||
void OnSourceModShutdown()
|
||||
{
|
||||
g_HandleSys.RemoveType(htCellArray, g_pCoreIdent);
|
||||
handlesys->RemoveType(htCellArray, g_pCoreIdent);
|
||||
}
|
||||
public: //IHandleTypeDispatch
|
||||
void OnHandleDestroy(HandleType_t type, void *object)
|
||||
@ -78,7 +76,7 @@ static cell_t CreateArray(IPluginContext *pContext, const cell_t *params)
|
||||
array->resize(params[2]);
|
||||
}
|
||||
|
||||
Handle_t hndl = g_HandleSys.CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL);
|
||||
Handle_t hndl = handlesys->CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL);
|
||||
if (!hndl)
|
||||
{
|
||||
delete array;
|
||||
@ -93,7 +91,7 @@ static cell_t ClearArray(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -110,7 +108,7 @@ static cell_t ResizeArray(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -130,7 +128,7 @@ static cell_t GetArraySize(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -145,7 +143,7 @@ static cell_t PushArrayCell(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -168,7 +166,7 @@ static cell_t PushArrayString(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -183,7 +181,7 @@ static cell_t PushArrayString(IPluginContext *pContext, const cell_t *params)
|
||||
char *str;
|
||||
pContext->LocalToString(params[2], &str);
|
||||
|
||||
strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t));
|
||||
smcore.strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t));
|
||||
|
||||
return (cell_t)(array->size() - 1);
|
||||
}
|
||||
@ -194,7 +192,7 @@ static cell_t PushArrayArray(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -226,7 +224,7 @@ static cell_t GetArrayCell(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -265,7 +263,7 @@ static cell_t GetArrayString(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -291,7 +289,7 @@ static cell_t GetArrayArray(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -324,7 +322,7 @@ static cell_t SetArrayCell(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -363,7 +361,7 @@ static cell_t SetArrayString(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -380,7 +378,7 @@ static cell_t SetArrayString(IPluginContext *pContext, const cell_t *params)
|
||||
char *str;
|
||||
pContext->LocalToString(params[3], &str);
|
||||
|
||||
return strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t));
|
||||
return smcore.strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t));
|
||||
}
|
||||
|
||||
static cell_t SetArrayArray(IPluginContext *pContext, const cell_t *params)
|
||||
@ -389,7 +387,7 @@ static cell_t SetArrayArray(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -422,7 +420,7 @@ static cell_t ShiftArrayUp(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -445,7 +443,7 @@ static cell_t RemoveFromArray(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -468,7 +466,7 @@ static cell_t SwapArrayItems(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -496,7 +494,7 @@ static cell_t CloneArray(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&oldArray))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&oldArray))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -504,7 +502,7 @@ static cell_t CloneArray(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
CellArray *array = oldArray->clone();
|
||||
|
||||
Handle_t hndl = g_HandleSys.CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL);
|
||||
Handle_t hndl = handlesys->CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL);
|
||||
if (!hndl)
|
||||
{
|
||||
delete array;
|
||||
@ -519,7 +517,7 @@ static cell_t FindStringInArray(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -546,7 +544,7 @@ static cell_t FindValueInArray(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
@ -30,10 +30,8 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "sm_globals.h"
|
||||
#include "sm_stringutil.h"
|
||||
#include "common_logic.h"
|
||||
#include "CellArray.h"
|
||||
#include "HandleSys.h"
|
||||
|
||||
HandleType_t htCellStack;
|
||||
|
||||
@ -44,11 +42,11 @@ class CellStackHelpers :
|
||||
public: //SMGlobalClass
|
||||
void OnSourceModAllInitialized()
|
||||
{
|
||||
htCellStack = g_HandleSys.CreateType("CellStack", this, 0, NULL, NULL, g_pCoreIdent, NULL);
|
||||
htCellStack = handlesys->CreateType("CellStack", this, 0, NULL, NULL, g_pCoreIdent, NULL);
|
||||
}
|
||||
void OnSourceModShutdown()
|
||||
{
|
||||
g_HandleSys.RemoveType(htCellStack, g_pCoreIdent);
|
||||
handlesys->RemoveType(htCellStack, g_pCoreIdent);
|
||||
}
|
||||
public: //IHandleTypeDispatch
|
||||
void OnHandleDestroy(HandleType_t type, void *object)
|
||||
@ -73,7 +71,7 @@ static cell_t CreateStack(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
CellArray *array = new CellArray(params[1]);
|
||||
|
||||
Handle_t hndl = g_HandleSys.CreateHandle(htCellStack, array, pContext->GetIdentity(), g_pCoreIdent, NULL);
|
||||
Handle_t hndl = handlesys->CreateHandle(htCellStack, array, pContext->GetIdentity(), g_pCoreIdent, NULL);
|
||||
if (!hndl)
|
||||
{
|
||||
delete array;
|
||||
@ -88,7 +86,7 @@ static cell_t PushStackCell(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -111,7 +109,7 @@ static cell_t PushStackString(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -126,7 +124,7 @@ static cell_t PushStackString(IPluginContext *pContext, const cell_t *params)
|
||||
char *str;
|
||||
pContext->LocalToString(params[2], &str);
|
||||
|
||||
strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t));
|
||||
smcore.strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t));
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -137,7 +135,7 @@ static cell_t PushStackArray(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -171,7 +169,7 @@ static cell_t PopStackCell(IPluginContext *pContext, const cell_t *params)
|
||||
cell_t *blk, *buffer;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -217,7 +215,7 @@ static cell_t PopStackString(IPluginContext *pContext, const cell_t *params)
|
||||
cell_t *blk, *pWritten;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -248,7 +246,7 @@ static cell_t PopStackArray(IPluginContext *pContext, const cell_t *params)
|
||||
CellArray *array;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -281,7 +279,7 @@ static cell_t IsStackEmpty(IPluginContext *pContext, const cell_t *params)
|
||||
CellArray *array;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
@ -32,7 +32,7 @@
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "sm_globals.h"
|
||||
#include "common_logic.h"
|
||||
|
||||
/****************************************
|
||||
* *
|
@ -30,17 +30,12 @@
|
||||
*/
|
||||
|
||||
#include <sh_list.h>
|
||||
#include "sm_globals.h"
|
||||
#include "sm_trie_tpl.h"
|
||||
#include <sm_trie_tpl.h>
|
||||
#include "common_logic.h"
|
||||
#include "CellArray.h"
|
||||
#include "convar.h"
|
||||
#include "sourcemm_api.h"
|
||||
#include "LibrarySys.h"
|
||||
#include "TextParsers.h"
|
||||
#include "sm_stringutil.h"
|
||||
#include "sourcemod.h"
|
||||
#include "Logger.h"
|
||||
#include "HandleSys.h"
|
||||
#include <ILibrarySys.h>
|
||||
#include <ITextParsers.h>
|
||||
#include <ISourceMod.h>
|
||||
|
||||
using namespace SourceHook;
|
||||
|
||||
@ -77,7 +72,7 @@ public:
|
||||
}
|
||||
void OnSourceModAllInitialized()
|
||||
{
|
||||
g_SourceMod.BuildPath(Path_SM, m_ConfigFile, sizeof(m_ConfigFile), "configs/maplists.cfg");
|
||||
g_pSM->BuildPath(Path_SM, m_ConfigFile, sizeof(m_ConfigFile), "configs/maplists.cfg");
|
||||
}
|
||||
void OnSourceModShutdown()
|
||||
{
|
||||
@ -94,13 +89,9 @@ public:
|
||||
pMapList->bIsCompat = true;
|
||||
pMapList->bIsPath = true;
|
||||
pMapList->last_modified_time = 0;
|
||||
strncopy(pMapList->name, name, sizeof(pMapList->name));
|
||||
smcore.strncopy(pMapList->name, name, sizeof(pMapList->name));
|
||||
pMapList->pArray = NULL;
|
||||
g_SourceMod.BuildPath(Path_Game,
|
||||
pMapList->path,
|
||||
sizeof(pMapList->path),
|
||||
"%s",
|
||||
file);
|
||||
g_pSM->BuildPath(Path_Game, pMapList->path, sizeof(pMapList->path), "%s", file);
|
||||
pMapList->serial = 0;
|
||||
m_ListLookup.insert(name, pMapList);
|
||||
m_MapLists.push_back(pMapList);
|
||||
@ -115,11 +106,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
g_SourceMod.BuildPath(Path_Game,
|
||||
path,
|
||||
sizeof(path),
|
||||
"%s",
|
||||
file);
|
||||
g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file);
|
||||
|
||||
/* If the path matches, don't reset the serial/time */
|
||||
if (strcmp(path, pMapList->path) == 0)
|
||||
@ -127,7 +114,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
strncopy(pMapList->path, path, sizeof(pMapList->path));
|
||||
smcore.strncopy(pMapList->path, path, sizeof(pMapList->path));
|
||||
pMapList->bIsPath = true;
|
||||
pMapList->last_modified_time = 0;
|
||||
pMapList->serial = 0;
|
||||
@ -139,7 +126,7 @@ public:
|
||||
time_t fileTime;
|
||||
SMCStates states = {0, 0};
|
||||
|
||||
fileFound = g_LibSys.FileTime(m_ConfigFile, FileTime_LastChange, &fileTime);
|
||||
fileFound = libsys->FileTime(m_ConfigFile, FileTime_LastChange, &fileTime);
|
||||
|
||||
/* If the file is found and hasn't changed, bail out now. */
|
||||
if (fileFound && fileTime == m_ConfigLastChanged)
|
||||
@ -156,7 +143,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
m_pMapCycleFile = icvar->FindVar("mapcyclefile");
|
||||
m_pMapCycleFile = smcore.FindConVar("mapcyclefile");
|
||||
|
||||
/* Dump everything we know about. */
|
||||
List<maplist_info_t *> compat;
|
||||
@ -166,12 +153,12 @@ public:
|
||||
maplist_info_t *pDefList = new maplist_info_t;
|
||||
|
||||
pDefList->bIsPath = true;
|
||||
strncopy(pDefList->name, "mapcyclefile", sizeof(pDefList->name));
|
||||
g_SourceMod.BuildPath(Path_Game,
|
||||
smcore.strncopy(pDefList->name, "mapcyclefile", sizeof(pDefList->name));
|
||||
g_pSM->BuildPath(Path_Game,
|
||||
pDefList->path,
|
||||
sizeof(pDefList->path),
|
||||
"%s",
|
||||
m_pMapCycleFile ? m_pMapCycleFile->GetString() : "mapcycle.txt");
|
||||
m_pMapCycleFile ? smcore.GetCvarString(m_pMapCycleFile) : "mapcycle.txt");
|
||||
pDefList->last_modified_time = 0;
|
||||
pDefList->pArray = NULL;
|
||||
pDefList->serial = 0;
|
||||
@ -182,19 +169,16 @@ public:
|
||||
/* Now parse the config file even if we don't know about it.
|
||||
* This will give us a nice error message.
|
||||
*/
|
||||
if ((error = g_TextParser.ParseFile_SMC(m_ConfigFile, this, &states))
|
||||
if ((error = textparser->ParseFile_SMC(m_ConfigFile, this, &states))
|
||||
!= SMCError_Okay)
|
||||
{
|
||||
const char *errmsg = g_TextParser.GetSMCErrorString(error);
|
||||
const char *errmsg = textparser->GetSMCErrorString(error);
|
||||
if (errmsg == NULL)
|
||||
{
|
||||
errmsg = "Unknown error";
|
||||
}
|
||||
g_Logger.LogError("[SM] Could not parse file \"%s\"", m_ConfigFile);
|
||||
g_Logger.LogError("[SM] Error on line %d (col %d): %s",
|
||||
states.line,
|
||||
states.col,
|
||||
errmsg);
|
||||
smcore.LogError("[SM] Could not parse file \"%s\"", m_ConfigFile);
|
||||
smcore.LogError("[SM] Error on line %d (col %d): %s", states.line, states.col, errmsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -249,7 +233,7 @@ public:
|
||||
m_pCurMapList = new maplist_info_t;
|
||||
|
||||
memset(m_pCurMapList, 0, sizeof(maplist_info_t));
|
||||
strncopy(m_pCurMapList->name, name, sizeof(m_pCurMapList->name));
|
||||
smcore.strncopy(m_pCurMapList->name, name, sizeof(m_pCurMapList->name));
|
||||
|
||||
m_CurState = MPS_MAPLIST;
|
||||
}
|
||||
@ -269,7 +253,7 @@ public:
|
||||
|
||||
if (strcmp(key, "file") == 0)
|
||||
{
|
||||
g_SourceMod.BuildPath(Path_Game,
|
||||
g_pSM->BuildPath(Path_Game,
|
||||
m_pCurMapList->path,
|
||||
sizeof(m_pCurMapList->path),
|
||||
"%s",
|
||||
@ -278,7 +262,7 @@ public:
|
||||
}
|
||||
else if (strcmp(key, "target") == 0)
|
||||
{
|
||||
strncopy(m_pCurMapList->path, value, sizeof(m_pCurMapList->path));
|
||||
smcore.strncopy(m_pCurMapList->path, value, sizeof(m_pCurMapList->path));
|
||||
m_pCurMapList->bIsPath = false;
|
||||
}
|
||||
|
||||
@ -369,9 +353,9 @@ public:
|
||||
|
||||
pNewArray = new CellArray(64);
|
||||
free_new_array = true;
|
||||
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "maps");
|
||||
g_pSM->BuildPath(Path_Game, path, sizeof(path), "maps");
|
||||
|
||||
if ((pDir = g_LibSys.OpenDirectory(path)) != NULL)
|
||||
if ((pDir = libsys->OpenDirectory(path)) != NULL)
|
||||
{
|
||||
char *ptr;
|
||||
cell_t *blk;
|
||||
@ -386,7 +370,7 @@ public:
|
||||
pDir->NextEntry();
|
||||
continue;
|
||||
}
|
||||
strncopy(buffer, pDir->GetEntryName(), sizeof(buffer));
|
||||
smcore.strncopy(buffer, pDir->GetEntryName(), sizeof(buffer));
|
||||
if ((ptr = strstr(buffer, ".bsp")) == NULL || ptr[4] != '\0')
|
||||
{
|
||||
pDir->NextEntry();
|
||||
@ -403,10 +387,10 @@ public:
|
||||
pDir->NextEntry();
|
||||
continue;
|
||||
}
|
||||
strncopy((char *)blk, buffer, 255);
|
||||
smcore.strncopy((char *)blk, buffer, 255);
|
||||
pDir->NextEntry();
|
||||
}
|
||||
g_LibSys.CloseDirectory(pDir);
|
||||
libsys->CloseDirectory(pDir);
|
||||
}
|
||||
|
||||
/* Remove the array if there were no items. */
|
||||
@ -461,7 +445,7 @@ public:
|
||||
{
|
||||
blk_dst = pUseArray->push();
|
||||
blk_src = pNewArray->at(i);
|
||||
strncopy((char *)blk_dst, (char *)blk_src, pUseArray->blocksize() * sizeof(cell_t));
|
||||
smcore.strncopy((char *)blk_dst, (char *)blk_src, pUseArray->blocksize() * sizeof(cell_t));
|
||||
}
|
||||
|
||||
/* Free resources if necessary. */
|
||||
@ -501,20 +485,20 @@ private:
|
||||
if (m_pMapCycleFile != NULL && strcmp(name, "mapcyclefile") == 0)
|
||||
{
|
||||
char path[PLATFORM_MAX_PATH];
|
||||
g_SourceMod.BuildPath(Path_Game,
|
||||
g_pSM->BuildPath(Path_Game,
|
||||
path,
|
||||
sizeof(path),
|
||||
"%s",
|
||||
m_pMapCycleFile ? m_pMapCycleFile->GetString() : "mapcycle.txt");
|
||||
m_pMapCycleFile ? smcore.GetCvarString(m_pMapCycleFile) : "mapcycle.txt");
|
||||
|
||||
if (strcmp(path, pMapList->path) != 0)
|
||||
{
|
||||
strncopy(pMapList->path, path, sizeof(pMapList->path));
|
||||
smcore.strncopy(pMapList->path, path, sizeof(pMapList->path));
|
||||
pMapList->last_modified_time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!g_LibSys.FileTime(pMapList->path, FileTime_LastChange, &last_time)
|
||||
if (!libsys->FileTime(pMapList->path, FileTime_LastChange, &last_time)
|
||||
|| last_time > pMapList->last_modified_time)
|
||||
{
|
||||
/* Reparse */
|
||||
@ -533,7 +517,7 @@ private:
|
||||
while (!feof(fp) && fgets(buffer, sizeof(buffer), fp) != NULL)
|
||||
{
|
||||
size_t len = strlen(buffer);
|
||||
char *ptr = UTIL_TrimWhitespace(buffer, len);
|
||||
char *ptr = smcore.TrimWhitespace(buffer, len);
|
||||
if (*ptr == '\0'
|
||||
|| *ptr == ';'
|
||||
|| strncmp(ptr, "//", 2) == 0)
|
||||
@ -546,7 +530,7 @@ private:
|
||||
}
|
||||
if ((blk = pMapList->pArray->push()) != NULL)
|
||||
{
|
||||
strncopy((char *)blk, ptr, 255);
|
||||
smcore.strncopy((char *)blk, ptr, 255);
|
||||
}
|
||||
}
|
||||
|
||||
@ -616,7 +600,7 @@ static cell_t LoadMapList(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(hndl, htCellArray, &sec, (void **)&pArray))
|
||||
if ((err = handlesys->ReadHandle(hndl, htCellArray, &sec, (void **)&pArray))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
|
||||
@ -635,7 +619,7 @@ static cell_t LoadMapList(IPluginContext *pContext, const cell_t *params)
|
||||
/* If the user wanted a new array, create it now. */
|
||||
if (hndl == BAD_HANDLE)
|
||||
{
|
||||
if ((hndl = g_HandleSys.CreateHandle(htCellArray, pNewArray, pContext->GetIdentity(), g_pCoreIdent, NULL))
|
||||
if ((hndl = handlesys->CreateHandle(htCellArray, pNewArray, pContext->GetIdentity(), g_pCoreIdent, NULL))
|
||||
== BAD_HANDLE)
|
||||
{
|
||||
*addr = -1;
|
@ -29,11 +29,10 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "sm_globals.h"
|
||||
#include <IHandleSys.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "HandleSys.h"
|
||||
#include <time.h>
|
||||
#include "common_logic.h"
|
||||
#include "CellArray.h"
|
||||
|
||||
/***********************************
|
||||
@ -448,7 +447,7 @@ static cell_t sm_SortADTArray(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&cArray))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&cArray))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
@ -535,7 +534,7 @@ static cell_t sm_SortADTArrayCustom(IPluginContext *pContext, const cell_t *para
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&cArray))
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&cArray))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
@ -29,9 +29,9 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "sm_globals.h"
|
||||
#include "common_logic.h"
|
||||
#include <ITextParsers.h>
|
||||
#include "HandleSys.h"
|
||||
#include <ISourceMod.h>
|
||||
|
||||
HandleType_t g_TypeSMC = 0;
|
||||
|
||||
@ -152,16 +152,16 @@ public:
|
||||
/* These cannot be cloned, because they are locked to a specific plugin.
|
||||
* However, we let anyone read them because we don't care.
|
||||
*/
|
||||
g_HandleSys.InitAccessDefaults(NULL, &sec);
|
||||
handlesys->InitAccessDefaults(NULL, &sec);
|
||||
sec.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY;
|
||||
sec.access[HandleAccess_Read] = 0;
|
||||
|
||||
g_TypeSMC = g_HandleSys.CreateType("SMCParser", this, 0, NULL, &sec, g_pCoreIdent, NULL);
|
||||
g_TypeSMC = handlesys->CreateType("SMCParser", this, 0, NULL, &sec, g_pCoreIdent, NULL);
|
||||
}
|
||||
|
||||
void OnSourceModShutdown()
|
||||
{
|
||||
g_HandleSys.RemoveType(g_TypeSMC, g_pCoreIdent);
|
||||
handlesys->RemoveType(g_TypeSMC, g_pCoreIdent);
|
||||
}
|
||||
|
||||
void OnHandleDestroy(HandleType_t type, void *object)
|
||||
@ -183,7 +183,7 @@ static cell_t SMC_CreateParser(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
ParseInfo *pInfo = new ParseInfo();
|
||||
|
||||
Handle_t hndl = g_HandleSys.CreateHandle(g_TypeSMC, pInfo, pContext->GetIdentity(), g_pCoreIdent, NULL);
|
||||
Handle_t hndl = handlesys->CreateHandle(g_TypeSMC, pInfo, pContext->GetIdentity(), g_pCoreIdent, NULL);
|
||||
|
||||
/* Should never happen */
|
||||
if (!hndl)
|
||||
@ -203,7 +203,7 @@ static cell_t SMC_SetParseStart(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
ParseInfo *parse;
|
||||
|
||||
if ((err=g_HandleSys.ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
|
||||
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
|
||||
@ -220,7 +220,7 @@ static cell_t SMC_SetParseEnd(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
ParseInfo *parse;
|
||||
|
||||
if ((err=g_HandleSys.ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
|
||||
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
|
||||
@ -237,7 +237,7 @@ static cell_t SMC_SetReaders(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
ParseInfo *parse;
|
||||
|
||||
if ((err=g_HandleSys.ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
|
||||
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
|
||||
@ -256,7 +256,7 @@ static cell_t SMC_SetRawLine(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
ParseInfo *parse;
|
||||
|
||||
if ((err=g_HandleSys.ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
|
||||
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
|
||||
@ -273,7 +273,7 @@ static cell_t SMC_ParseFile(IPluginContext *pContext, const cell_t *params)
|
||||
HandleError err;
|
||||
ParseInfo *parse;
|
||||
|
||||
if ((err=g_HandleSys.ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
|
||||
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
|
||||
@ -283,7 +283,7 @@ static cell_t SMC_ParseFile(IPluginContext *pContext, const cell_t *params)
|
||||
pContext->LocalToString(params[2], &file);
|
||||
|
||||
char path[PLATFORM_MAX_PATH];
|
||||
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "%s", file);
|
||||
g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file);
|
||||
|
||||
SMCStates states;
|
||||
SMCError p_err = textparsers->ParseFile_SMC(path, parse, &states);
|
44
core/logic/svn_version.h
Executable file
44
core/logic/svn_version.h
Executable file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod GeoIP Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Autogenerated by build scripts
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_GEOIP_VERSION_H_
|
||||
#define _INCLUDE_GEOIP_VERSION_H_
|
||||
|
||||
#define SM_BUILD_STRING "-dev"
|
||||
#define SM_BUILD_UNIQUEID "2650:5d34bc3edbfa" SM_BUILD_STRING
|
||||
#define SVN_FULL_VERSION "1.3.0" SM_BUILD_STRING
|
||||
#define SVN_FILE_VERSION 1,3,0,0
|
||||
|
||||
#endif //_INCLUDE_GEOIP_VERSION_H_
|
44
core/logic/svn_version.tpl
Executable file
44
core/logic/svn_version.tpl
Executable file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod GeoIP Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Autogenerated by build scripts
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_LOGIC_VERSION_H_
|
||||
#define _INCLUDE_LOGIC_VERSION_H_
|
||||
|
||||
#define SM_BUILD_STRING "$BUILD_STRING$"
|
||||
#define SM_BUILD_UNIQUEID "$BUILD_ID$" SM_BUILD_STRING
|
||||
#define SVN_FULL_VERSION "$PMAJOR$.$PMINOR$.$PREVISION$" SM_BUILD_STRING
|
||||
#define SVN_FILE_VERSION $PMAJOR$,$PMINOR$,$PREVISION$,0
|
||||
|
||||
#endif //_INCLUDE_LOGIC_VERSION_H_
|
104
core/logic/version.rc
Executable file
104
core/logic/version.rc
Executable file
@ -0,0 +1,104 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
//#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
#include "svn_version.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION SVN_FILE_VERSION
|
||||
PRODUCTVERSION SVN_FILE_VERSION
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "000004b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "SourceMod"
|
||||
VALUE "FileDescription", "SourceMod Core Logic"
|
||||
VALUE "FileVersion", SVN_FULL_VERSION
|
||||
VALUE "InternalName", "sourcemod"
|
||||
VALUE "LegalCopyright", "Copyright (c) 2004-2009, AlliedModders LLC"
|
||||
VALUE "OriginalFilename", "sourcemod.logic.dll"
|
||||
VALUE "ProductName", "SourceMod"
|
||||
VALUE "ProductVersion", SVN_FULL_VERSION
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x0, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
169
core/logic_bridge.cpp
Normal file
169
core/logic_bridge.cpp
Normal file
@ -0,0 +1,169 @@
|
||||
/**
|
||||
* vim: set ts=4 sw=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "sourcemod.h"
|
||||
#include "sourcemm_api.h"
|
||||
#include "sm_globals.h"
|
||||
#include "NativeOwner.h"
|
||||
#include "sm_autonatives.h"
|
||||
#include "logic/intercom.h"
|
||||
#include "LibrarySys.h"
|
||||
#include "HandleSys.h"
|
||||
#include "sm_stringutil.h"
|
||||
#include "Logger.h"
|
||||
#include "ShareSys.h"
|
||||
|
||||
static ILibrary *g_pLogic = NULL;
|
||||
static LogicInitFunction logic_init_fn;
|
||||
|
||||
IThreader *g_pThreader;
|
||||
ITextParsers *textparsers;
|
||||
|
||||
class VEngineServer_Logic : public IVEngineServer_Logic
|
||||
{
|
||||
public:
|
||||
virtual bool IsMapValid(const char *map)
|
||||
{
|
||||
return engine->IsMapValid(map);
|
||||
}
|
||||
};
|
||||
|
||||
static VEngineServer_Logic logic_engine;
|
||||
|
||||
static void add_natives(sp_nativeinfo_t *natives)
|
||||
{
|
||||
g_pCoreNatives->AddNatives(natives);
|
||||
}
|
||||
|
||||
static ConVar *find_convar(const char *name)
|
||||
{
|
||||
return icvar->FindVar(name);
|
||||
}
|
||||
|
||||
static void log_error(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
g_Logger.LogErrorEx(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static const char *get_cvar_string(ConVar* cvar)
|
||||
{
|
||||
return cvar->GetString();
|
||||
}
|
||||
|
||||
static sm_core_t core_bridge =
|
||||
{
|
||||
/* Objects */
|
||||
&g_HandleSys,
|
||||
NULL,
|
||||
&g_SourceMod,
|
||||
&g_LibSys,
|
||||
reinterpret_cast<IVEngineServer*>(&logic_engine),
|
||||
&g_ShareSys,
|
||||
/* Functions */
|
||||
add_natives,
|
||||
find_convar,
|
||||
strncopy,
|
||||
UTIL_TrimWhitespace,
|
||||
log_error,
|
||||
get_cvar_string,
|
||||
UTIL_Format
|
||||
};
|
||||
|
||||
void InitLogicBridge()
|
||||
{
|
||||
sm_logic_t logic;
|
||||
|
||||
core_bridge.core_ident = g_pCoreIdent;
|
||||
logic_init_fn(&core_bridge, &logic);
|
||||
|
||||
/* Add SMGlobalClass instances */
|
||||
SMGlobalClass* glob = SMGlobalClass::head;
|
||||
while (glob->m_pGlobalClassNext != NULL)
|
||||
{
|
||||
glob = glob->m_pGlobalClassNext;
|
||||
}
|
||||
assert(glob->m_pGlobalClassNext == NULL);
|
||||
glob->m_pGlobalClassNext = logic.head;
|
||||
|
||||
g_pThreader = logic.threader;
|
||||
}
|
||||
|
||||
bool StartLogicBridge(char *error, size_t maxlength)
|
||||
{
|
||||
char file[PLATFORM_MAX_PATH];
|
||||
|
||||
/* Now it's time to load the logic binary */
|
||||
g_SMAPI->PathFormat(file,
|
||||
sizeof(file),
|
||||
"%s/bin/sourcemod.logic." PLATFORM_LIB_EXT,
|
||||
g_SourceMod.GetSourceModPath());
|
||||
|
||||
char myerror[255];
|
||||
g_pLogic = g_LibSys.OpenLibrary(file, myerror, sizeof(myerror));
|
||||
|
||||
if (!g_pLogic)
|
||||
{
|
||||
if (error && maxlength)
|
||||
{
|
||||
UTIL_Format(error, maxlength, "failed to load %s: %s", file, myerror);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
LogicLoadFunction llf = (LogicLoadFunction)g_pLogic->GetSymbolAddress("logic_load");
|
||||
if (llf == NULL)
|
||||
{
|
||||
g_pLogic->CloseLibrary();
|
||||
if (error && maxlength)
|
||||
{
|
||||
UTIL_Format(error, maxlength, "could not find logic_load function");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
GetITextParsers getitxt = (GetITextParsers)g_pLogic->GetSymbolAddress("get_textparsers");
|
||||
textparsers = getitxt();
|
||||
|
||||
logic_init_fn = llf(SM_LOGIC_MAGIC);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ShutdownLogicBridge()
|
||||
{
|
||||
g_pLogic->CloseLibrary();
|
||||
}
|
||||
|
39
core/logic_bridge.h
Normal file
39
core/logic_bridge.h
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* vim: set ts=4 sw=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
#ifndef _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_
|
||||
#define _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_
|
||||
|
||||
void InitLogicBridge();
|
||||
bool StartLogicBridge(char *error, size_t maxlength);
|
||||
void ShutdownLogicBridge();
|
||||
|
||||
#endif /* _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_ */
|
||||
|
@ -1420,6 +1420,10 @@
|
||||
RelativePath="..\Logger.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\logic_bridge.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\MemoryUtils.cpp"
|
||||
>
|
||||
@ -1512,14 +1516,6 @@
|
||||
RelativePath="..\sourcemod.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\TextParsers.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ThreadSupport.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\TimerSys.cpp"
|
||||
>
|
||||
@ -1626,6 +1622,10 @@
|
||||
RelativePath="..\Logger.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\logic_bridge.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\MemoryUtils.h"
|
||||
>
|
||||
@ -1750,14 +1750,6 @@
|
||||
RelativePath="..\sourcemod.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\TextParsers.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ThreadSupport.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\TimerSys.h"
|
||||
>
|
||||
@ -1906,14 +1898,6 @@
|
||||
RelativePath="..\smn_admin.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_adt_array.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_adt_stack.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_adt_trie.cpp"
|
||||
>
|
||||
@ -1958,10 +1942,6 @@
|
||||
RelativePath="..\smn_filesystem.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_float.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_functions.cpp"
|
||||
>
|
||||
@ -1990,10 +1970,6 @@
|
||||
RelativePath="..\smn_lang.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_maplists.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_menus.cpp"
|
||||
>
|
||||
@ -2010,18 +1986,10 @@
|
||||
RelativePath="..\smn_profiler.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_sorting.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_string.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_textparse.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_timers.cpp"
|
||||
>
|
||||
@ -2045,42 +2013,6 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Threader"
|
||||
>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\thread\BaseWorker.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\thread\ThreadWorker.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\thread\WinThreads.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\thread\BaseWorker.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\thread\ThreadWorker.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\thread\WinThreads.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
|
@ -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
|
||||
@ -76,7 +76,11 @@ class SMGlobalClass
|
||||
friend class CExtensionManager;
|
||||
friend class PlayerManager;
|
||||
public:
|
||||
SMGlobalClass();
|
||||
SMGlobalClass()
|
||||
{
|
||||
m_pGlobalClassNext = SMGlobalClass::head;
|
||||
SMGlobalClass::head = this;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Called when SourceMod is initially loading
|
||||
@ -184,7 +188,7 @@ public:
|
||||
virtual void OnSourceModMaxPlayersChanged(int newvalue)
|
||||
{
|
||||
}
|
||||
private:
|
||||
public:
|
||||
SMGlobalClass *m_pGlobalClassNext;
|
||||
static SMGlobalClass *head;
|
||||
};
|
||||
@ -193,6 +197,16 @@ extern ISourcePawnEngine *g_pSourcePawn;
|
||||
extern ISourcePawnEngine2 *g_pSourcePawn2;
|
||||
extern IdentityToken_t *g_pCoreIdent;
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
class IThreader;
|
||||
class ITextParsers;
|
||||
}
|
||||
|
||||
extern IThreader *g_pThreader;
|
||||
extern ITextParsers *textparsers;
|
||||
|
||||
#include "sm_autonatives.h"
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_GLOBALS_H_
|
||||
|
||||
|
@ -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
|
||||
@ -49,6 +49,7 @@
|
||||
#include "DebugReporter.h"
|
||||
#include "Profiler.h"
|
||||
#include "frame_hooks.h"
|
||||
#include "logic_bridge.h"
|
||||
|
||||
SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
|
||||
SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false);
|
||||
@ -166,6 +167,11 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late
|
||||
g_LibSys.PathFormat(m_SMBaseDir, sizeof(m_SMBaseDir), "%s/%s", g_BaseDir.c_str(), basepath);
|
||||
g_LibSys.PathFormat(m_SMRelDir, sizeof(m_SMRelDir), "%s", basepath);
|
||||
|
||||
if (!StartLogicBridge(error, maxlength))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Initialize CoreConfig to get the SourceMod base path properly - this parses core.cfg */
|
||||
g_CoreConfig.Initialize();
|
||||
|
||||
@ -185,7 +191,7 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late
|
||||
{
|
||||
if (error && maxlength)
|
||||
{
|
||||
snprintf(error, maxlength, "%s (failed to load bin/sourcepawn.jit.x86.%s)",
|
||||
UTIL_Format(error, maxlength, "%s (failed to load bin/sourcepawn.jit.x86.%s)",
|
||||
myerror,
|
||||
PLATFORM_LIB_EXT);
|
||||
}
|
||||
@ -265,6 +271,8 @@ void SourceModBase::StartSourceMod(bool late)
|
||||
/* Make the global core identity */
|
||||
g_pCoreIdent = g_ShareSys.CreateCoreIdentity();
|
||||
|
||||
InitLogicBridge();
|
||||
|
||||
/* Notify! */
|
||||
SMGlobalClass *pBase = SMGlobalClass::head;
|
||||
while (pBase)
|
||||
@ -535,6 +543,7 @@ void SourceModBase::CloseSourceMod()
|
||||
}
|
||||
|
||||
/* Rest In Peace */
|
||||
ShutdownLogicBridge();
|
||||
ShutdownJIT();
|
||||
}
|
||||
|
||||
@ -731,8 +740,3 @@ int SourceModBase::GetPluginId()
|
||||
|
||||
SMGlobalClass *SMGlobalClass::head = NULL;
|
||||
|
||||
SMGlobalClass::SMGlobalClass()
|
||||
{
|
||||
m_pGlobalClassNext = SMGlobalClass::head;
|
||||
SMGlobalClass::head = this;
|
||||
}
|
||||
|
@ -152,6 +152,13 @@ namespace builder
|
||||
lib.has_platform_ext = true;
|
||||
libraries.Add(lib);
|
||||
|
||||
lib = new Library();
|
||||
lib.package_path = "addons/sourcemod/bin";
|
||||
lib.source_path = "core/logic";
|
||||
lib.binary_name = "sourcemod.logic";
|
||||
lib.vcproj_name = "logic";
|
||||
libraries.Add(lib);
|
||||
|
||||
lib = new Library();
|
||||
lib.package_path = "addons/sourcemod/bin";
|
||||
lib.source_path = "core";
|
||||
|
Loading…
Reference in New Issue
Block a user