Move string natives from logic to core (bug 4406 part 8, r=fyren).
--HG-- rename : core/smn_string.cpp => core/logic/smn_string.cpp
This commit is contained in:
parent
d80191df3d
commit
85bedca236
@ -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',
|
||||
|
@ -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 \
|
||||
|
@ -39,6 +39,7 @@ files = [
|
||||
'Translator.cpp',
|
||||
'PhraseCollection.cpp',
|
||||
'smn_lang.cpp',
|
||||
'smn_string.cpp',
|
||||
'sm_crc32.cpp'
|
||||
]
|
||||
if AMBuild.target['platform'] == 'windows':
|
||||
|
@ -35,6 +35,7 @@ OBJECTS = \
|
||||
Translator.cpp \
|
||||
PhraseCollection.cpp \
|
||||
smn_lang.cpp \
|
||||
smn_string.cpp \
|
||||
smn_players.cpp
|
||||
|
||||
##############################################
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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 <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "sm_globals.h"
|
||||
#include "sm_stringutil.h"
|
||||
#include <ITextParsers.h>
|
||||
#include <ctype.h>
|
||||
#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<cell_t>(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<cell_t>(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<size_t>(params[2]), fmt, pCtx, params, &arg);
|
||||
res = smcore.atcprintf(buf, static_cast<size_t>(params[2]), fmt, pCtx, params, &arg);
|
||||
|
||||
return static_cast<cell_t>(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)
|
||||
{
|
@ -137,6 +137,7 @@ static sm_core_t core_bridge =
|
||||
UTIL_Format,
|
||||
generate_error,
|
||||
gnprintf,
|
||||
atcprintf,
|
||||
&serverGlobals
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user