Add the "RIndexOf" method to FString, which works like String.lastIndexOf from JavaScript

RIndexOf returns the index where the substring starts, instead of the index where the substring ends - 1.

Deprecate the LastIndexOf method of StringStruct
This commit is contained in:
Kevin Caccamo 2018-08-22 03:52:11 -04:00 committed by Christoph Oelckers
commit 884de51b70
4 changed files with 56 additions and 5 deletions

View file

@ -327,7 +327,7 @@ static FFlagDef ActorFlagDefs[]=
DEFINE_FLAG(RF, INVISIBLE, AActor, renderflags),
DEFINE_FLAG(RF, FORCEYBILLBOARD, AActor, renderflags),
DEFINE_FLAG(RF, FORCEXYBILLBOARD, AActor, renderflags),
DEFINE_FLAG(RF, ROLLSPRITE, AActor, renderflags), // [marrub] roll the sprite billboard
DEFINE_FLAG(RF, ROLLSPRITE, AActor, renderflags), // [marrub] roll the sprite billboard
// [fgsfds] Flat sprites
DEFINE_FLAG(RF, FLATSPRITE, AActor, renderflags),
DEFINE_FLAG(RF, WALLSPRITE, AActor, renderflags),
@ -593,7 +593,7 @@ FFlagDef *FindFlag (const PClass *type, const char *part1, const char *part2, bo
//==========================================================================
//
// Gets the name of an actor flag
// Gets the name of an actor flag
//
//==========================================================================
@ -1273,6 +1273,14 @@ DEFINE_ACTION_FUNCTION(FStringStruct, LastIndexOf)
ACTION_RETURN_INT(self->LastIndexOf(substr, endIndex));
}
DEFINE_ACTION_FUNCTION(FStringStruct, RIndexOf)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr);
PARAM_INT_DEF(endIndex);
ACTION_RETURN_INT(self->RIndexOf(substr, endIndex));
}
DEFINE_ACTION_FUNCTION(FStringStruct, ToUpper)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);