diff --git a/core/AMBuilder b/core/AMBuilder index 82ed608a..04180f3f 100644 --- a/core/AMBuilder +++ b/core/AMBuilder @@ -48,7 +48,6 @@ for i in SM.sdkInfo: 'LibrarySys.cpp', 'PlayerManager.cpp', 'smn_gameconfigs.cpp', - 'smn_string.cpp', 'TimerSys.cpp', 'CoreConfig.cpp', 'Logger.cpp', diff --git a/core/Makefile b/core/Makefile index 4fe69aed..c6978f36 100644 --- a/core/Makefile +++ b/core/Makefile @@ -25,8 +25,7 @@ OBJECTS = AdminCache.cpp CDataPack.cpp ConCmdManager.cpp ConVarManager.cpp CoreC OBJECTS += 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_gameconfigs.cpp smn_halflife.cpp \ - smn_handles.cpp smn_keyvalues.cpp \ - smn_player.cpp smn_string.cpp \ + smn_handles.cpp smn_keyvalues.cpp smn_player.cpp \ smn_usermsgs.cpp smn_menus.cpp smn_database.cpp smn_vector.cpp \ smn_hudtext.cpp smn_nextmap.cpp OBJECTS += ExtensionSys.cpp \ diff --git a/core/logic/AMBuilder b/core/logic/AMBuilder index 2b897eb9..94742e28 100644 --- a/core/logic/AMBuilder +++ b/core/logic/AMBuilder @@ -39,6 +39,7 @@ files = [ 'Translator.cpp', 'PhraseCollection.cpp', 'smn_lang.cpp', + 'smn_string.cpp', 'sm_crc32.cpp' ] if AMBuild.target['platform'] == 'windows': diff --git a/core/logic/Makefile b/core/logic/Makefile index 4147ce95..3366abf3 100644 --- a/core/logic/Makefile +++ b/core/logic/Makefile @@ -35,6 +35,7 @@ OBJECTS = \ Translator.cpp \ PhraseCollection.cpp \ smn_lang.cpp \ + smn_string.cpp \ smn_players.cpp ############################################## diff --git a/core/logic/intercom.h b/core/logic/intercom.h index 91bf0af3..da75227b 100644 --- a/core/logic/intercom.h +++ b/core/logic/intercom.h @@ -42,7 +42,7 @@ using namespace SourceMod; * Add 1 to the RHS of this expression to bump the intercom file * This is to prevent mismatching core/logic binaries */ -#define SM_LOGIC_MAGIC (0x0F47C0DE - 11) +#define SM_LOGIC_MAGIC (0x0F47C0DE - 12) #if defined SM_LOGIC class IVEngineServer @@ -110,6 +110,7 @@ struct sm_core_t void (*GenerateError)(IPluginContext *, cell_t, int, const char *, ...); bool (*gnprintf)(char *, size_t, const char *, IPhraseCollection *, void **, unsigned int, unsigned int &, size_t *, const char **); + size_t (*atcprintf)(char *, size_t, const char *, IPluginContext *, const cell_t *, int *); /* Data */ ServerGlobals *serverGlobals; }; diff --git a/core/smn_string.cpp b/core/logic/smn_string.cpp similarity index 91% rename from core/smn_string.cpp rename to core/logic/smn_string.cpp index c26d1650..e9419b0c 100644 --- a/core/smn_string.cpp +++ b/core/logic/smn_string.cpp @@ -1,5 +1,5 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ============================================================================= * SourceMod * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. @@ -29,13 +29,12 @@ * Version: $Id$ */ +#include "common_logic.h" #include #include -#include "sm_globals.h" -#include "sm_stringutil.h" #include #include -#include "logic_bridge.h" +#include "stringutil.h" inline const char *_strstr(const char *str, const char *substr) { @@ -69,7 +68,7 @@ static cell_t sm_contain(IPluginContext *pCtx, const cell_t *params) pCtx->LocalToString(params[1], &str); pCtx->LocalToString(params[2], &substr); - func = (params[3]) ? _strstr : logicore.stristr; + func = (params[3]) ? _strstr : stristr; const char *pos = func(str, substr); if (pos) { @@ -142,7 +141,7 @@ static cell_t sm_numtostr(IPluginContext *pCtx, const cell_t *params) { char *str; pCtx->LocalToString(params[2], &str); - size_t res = UTIL_Format(str, params[3], "%d", params[1]); + size_t res = smcore.Format(str, params[3], "%d", params[1]); return static_cast(res); } @@ -175,7 +174,7 @@ static cell_t sm_floattostr(IPluginContext *pCtx, const cell_t *params) { char *str; pCtx->LocalToString(params[2], &str); - size_t res = UTIL_Format(str, params[3], "%f", sp_ctof(params[1])); + size_t res = smcore.Format(str, params[3], "%f", sp_ctof(params[1])); return static_cast(res); } @@ -188,7 +187,7 @@ static cell_t sm_formatex(IPluginContext *pCtx, const cell_t *params) pCtx->LocalToString(params[1], &buf); pCtx->LocalToString(params[3], &fmt); - res = atcprintf(buf, static_cast(params[2]), fmt, pCtx, params, &arg); + res = smcore.atcprintf(buf, static_cast(params[2]), fmt, pCtx, params, &arg); return static_cast(res); } @@ -257,7 +256,7 @@ static cell_t sm_format(IPluginContext *pCtx, const cell_t *params) } buf = (copy) ? __copy_buf : destbuf; - res = atcprintf(buf, maxlen, fmt, pCtx, params, &arg); + res = smcore.atcprintf(buf, maxlen, fmt, pCtx, params, &arg); if (copy) { @@ -307,7 +306,7 @@ static cell_t sm_vformat(IPluginContext *pContext, const cell_t *params) pContext->LocalToString(params[3], &format); - size_t total = atcprintf(destination, maxlen, format, pContext, local_params, &vargPos); + size_t total = smcore.atcprintf(destination, maxlen, format, pContext, local_params, &vargPos); /* Perform copy-on-write if we need to */ if (copy) @@ -514,7 +513,7 @@ static cell_t ReplaceString(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Cannot replace searches of empty strings"); } - return logicore.ReplaceAll(text, maxlength, search, replace, caseSensitive); + return UTIL_ReplaceAll(text, maxlength, search, replace, caseSensitive); } static cell_t ReplaceStringEx(IPluginContext *pContext, const cell_t *params) @@ -546,7 +545,7 @@ static cell_t ReplaceStringEx(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Cannot replace searches of empty strings"); } - char *ptr = logicore.ReplaceEx(text, maxlength, search, searchLen, replace, replaceLen, caseSensitive); + char *ptr = UTIL_ReplaceEx(text, maxlength, search, searchLen, replace, replaceLen, caseSensitive); if (ptr == NULL) { diff --git a/core/logic_bridge.cpp b/core/logic_bridge.cpp index b67790bb..d6b3525a 100644 --- a/core/logic_bridge.cpp +++ b/core/logic_bridge.cpp @@ -137,6 +137,7 @@ static sm_core_t core_bridge = UTIL_Format, generate_error, gnprintf, + atcprintf, &serverGlobals };