MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / ReplaceString

Function ReplaceString

core/logic/smn_string.cpp:452–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

450}
451
452static cell_t ReplaceString(IPluginContext *pContext, const cell_t *params)
453{
454 char *text, *search, *replace;
455 size_t maxlength;
456 bool caseSensitive;
457
458 pContext->LocalToString(params[1], &text);
459 pContext->LocalToString(params[3], &search);
460 pContext->LocalToString(params[4], &replace);
461 maxlength = (size_t)params[2];
462
463 /* Account for old binary plugins that won't pass the last parameter */
464 if (params[0] == 5)
465 {
466 caseSensitive = (bool)params[5];
467 }
468 else
469 {
470 caseSensitive = true;
471 }
472
473 if (search[0] == '\0')
474 {
475 return pContext->ThrowNativeError("Cannot replace searches of empty strings");
476 }
477
478 return UTIL_ReplaceAll(text, maxlength, search, replace, caseSensitive);
479}
480
481static cell_t ReplaceStringEx(IPluginContext *pContext, const cell_t *params)
482{

Callers

nothing calls this directly

Calls 1

UTIL_ReplaceAllFunction · 0.85

Tested by

no test coverage detected