Permalink
Browse files

- more direct native function calls.

  • Loading branch information...
coelckers committed Dec 4, 2018
1 parent 5e4b366 commit 062528e0e22d1aa05be2eee12433fc0def0a73b9
@@ -57,27 +57,24 @@ EXTERN_CVAR(Bool, sv_unlimited_pickup)
//===========================================================================
//
// This is only native so it can have some static storage for comparison.
//
//===========================================================================
static int StaticLastMessageTic;
static FString StaticLastMessage;
DEFINE_ACTION_FUNCTION(AInventory, PrintPickupMessage)
void PrintPickupMessage(bool localview, const FString &str)
{
PARAM_PROLOGUE;
PARAM_BOOL(localview);
PARAM_STRING(str);
if (str.IsNotEmpty() && localview && (StaticLastMessageTic != gametic || StaticLastMessage.Compare(str)))
{
StaticLastMessageTic = gametic;
StaticLastMessage = str;
const char *pstr = str.GetChars();
if (pstr[0] == '$') pstr = GStrings(pstr + 1);
if (pstr[0] != 0) Printf(PRINT_LOW, "%s\n", pstr);
StatusBar->FlashCrosshair();
}
return 0;
}
//===========================================================================
@@ -248,12 +248,6 @@ DSpotState *DSpotState::GetSpotState(bool create)
return SpotState;
}
DEFINE_ACTION_FUNCTION(DSpotState, GetSpotState)
{
PARAM_PROLOGUE;
ACTION_RETURN_OBJECT(DSpotState::GetSpotState());
}
//----------------------------------------------------------------------------
//
//
@@ -321,14 +315,6 @@ ASpecialSpot *DSpotState::GetNextInList(PClassActor *type, int skipcounter)
return NULL;
}
DEFINE_ACTION_FUNCTION(DSpotState, GetNextInList)
{
PARAM_SELF_PROLOGUE(DSpotState);
PARAM_CLASS(type, AActor);
PARAM_INT(skipcounter);
ACTION_RETURN_OBJECT(self->GetNextInList(type, skipcounter));
}
//----------------------------------------------------------------------------
//
//
@@ -342,18 +328,6 @@ ASpecialSpot *DSpotState::GetSpotWithMinMaxDistance(PClassActor *type, double x,
return NULL;
}
DEFINE_ACTION_FUNCTION(DSpotState, GetSpotWithMinMaxDistance)
{
PARAM_SELF_PROLOGUE(DSpotState);
PARAM_CLASS(type, AActor);
PARAM_FLOAT(x);
PARAM_FLOAT(y);
PARAM_FLOAT(mindist);
PARAM_FLOAT(maxdist);
ACTION_RETURN_OBJECT(self->GetSpotWithMinMaxDistance(type, x, y, mindist, maxdist));
}
//----------------------------------------------------------------------------
//
//
@@ -367,14 +341,6 @@ ASpecialSpot *DSpotState::GetRandomSpot(PClassActor *type, bool onlyonce)
return NULL;
}
DEFINE_ACTION_FUNCTION(DSpotState, GetRandomSpot)
{
PARAM_SELF_PROLOGUE(DSpotState);
PARAM_CLASS(type, AActor);
PARAM_BOOL(onlyonce);
ACTION_RETURN_POINTER(self->GetRandomSpot(type, onlyonce));
}
//----------------------------------------------------------------------------
//
//
@@ -243,21 +243,6 @@ DEFINE_ACTION_FUNCTION(ACustomInventory, CallStateChain)
ACTION_RETURN_BOOL(CallStateChain(self, affectee, state));
}
//==========================================================================
//
// GetPointer
//
// resolve AAPTR_*
//
//==========================================================================
DEFINE_ACTION_FUNCTION(AActor, GetPointer)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(ptr);
ACTION_RETURN_OBJECT(COPY_AAPTR(self, ptr));
}
//==========================================================================
//
// CheckClass
@@ -8530,7 +8530,12 @@ FxExpression *FxActionSpecialCall::Resolve(FCompileContext& ctx)
//
//==========================================================================
DEFINE_ACTION_FUNCTION(DObject, BuiltinCallLineSpecial)
void BuiltinCallLineSpecial(int special, AActor *activator, int arg1, int arg2, int arg3, int arg4, int arg5)
{
P_ExecuteSpecial(special, nullptr, activator, 0, arg1, arg2, arg3, arg4, arg5);
}
DEFINE_ACTION_FUNCTION_NATIVE(DObject, BuiltinCallLineSpecial, BuiltinCallLineSpecial)
{
PARAM_PROLOGUE;
PARAM_INT(special);
@@ -409,13 +409,6 @@ static FFlagDef MoreFlagDefs[] =
DEFINE_DUMMY_FLAG(SERVERSIDEONLY, false),
};
static FFlagDef InventoryFlagDefs[] =
{
// Inventory flags
DEFINE_DEPRECATED_FLAG(PICKUPFLASH),
DEFINE_DEPRECATED_FLAG(INTERHUBSTRIP),
};
static FFlagDef PlayerPawnFlagDefs[] =
{
// PlayerPawn flags
@@ -969,25 +962,6 @@ DEFINE_ACTION_FUNCTION(DObject, BAM)
ACTION_RETURN_INT(DAngle(ang).BAMs());
}
DEFINE_ACTION_FUNCTION(FStringTable, Localize)
{
PARAM_PROLOGUE;
PARAM_STRING(label);
PARAM_BOOL(prefixed);
if (!prefixed) ACTION_RETURN_STRING(GStrings(label));
if (label[0] != '$') ACTION_RETURN_STRING(label);
ACTION_RETURN_STRING(GStrings(&label[1]));
}
DEFINE_ACTION_FUNCTION(FStringStruct, Replace)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(s1);
PARAM_STRING(s2);
self->Substitute(s1, s2);
return 0;
}
FString FStringFormat(VM_ARGS, int offset)
{
PARAM_VA_POINTER(va_reginfo) // Get the hidden type information array
@@ -1203,124 +1177,3 @@ DEFINE_ACTION_FUNCTION(FStringStruct, AppendFormat)
return 0;
}
DEFINE_ACTION_FUNCTION(FStringStruct, Mid)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_UINT(pos);
PARAM_UINT(len);
FString s = self->Mid(pos, len);
ACTION_RETURN_STRING(s);
}
DEFINE_ACTION_FUNCTION(FStringStruct, Left)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_UINT(len);
FString s = self->Left(len);
ACTION_RETURN_STRING(s);
}
DEFINE_ACTION_FUNCTION(FStringStruct, Truncate)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_UINT(len);
self->Truncate(len);
return 0;
}
DEFINE_ACTION_FUNCTION(FStringStruct, Remove)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_UINT(index);
PARAM_UINT(remlen);
self->Remove(index, remlen);
return 0;
}
// CharAt and CharCodeAt is how JS does it, and JS is similar here in that it doesn't have char type as int.
DEFINE_ACTION_FUNCTION(FStringStruct, CharAt)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_INT(pos);
int slen = (int)self->Len();
if (pos < 0 || pos >= slen)
ACTION_RETURN_STRING("");
ACTION_RETURN_STRING(FString((*self)[pos]));
}
DEFINE_ACTION_FUNCTION(FStringStruct, CharCodeAt)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_INT(pos);
int slen = (int)self->Len();
if (pos < 0 || pos >= slen)
ACTION_RETURN_INT(0);
ACTION_RETURN_INT((*self)[pos]);
}
DEFINE_ACTION_FUNCTION(FStringStruct, Filter)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
ACTION_RETURN_STRING(strbin1(*self));
}
DEFINE_ACTION_FUNCTION(FStringStruct, IndexOf)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr);
PARAM_INT(startIndex);
ACTION_RETURN_INT(self->IndexOf(substr, startIndex));
}
DEFINE_ACTION_FUNCTION(FStringStruct, LastIndexOf)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr);
PARAM_INT(endIndex);
ACTION_RETURN_INT(self->LastIndexOfBroken(substr, endIndex));
}
DEFINE_ACTION_FUNCTION(FStringStruct, RightIndexOf)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr);
PARAM_INT(endIndex);
ACTION_RETURN_INT(self->LastIndexOf(substr, endIndex));
}
DEFINE_ACTION_FUNCTION(FStringStruct, ToUpper)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
self->ToUpper();
return 0;
}
DEFINE_ACTION_FUNCTION(FStringStruct, ToLower)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
self->ToLower();
return 0;
}
DEFINE_ACTION_FUNCTION(FStringStruct, ToInt)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_INT(base);
ACTION_RETURN_INT(self->ToLong(base));
}
DEFINE_ACTION_FUNCTION(FStringStruct, ToDouble)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
ACTION_RETURN_FLOAT(self->ToDouble());
}
DEFINE_ACTION_FUNCTION(FStringStruct, Split)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_POINTER(tokens, TArray<FString>);
PARAM_STRING(delimiter);
PARAM_INT(keepEmpty);
self->Split(*tokens, delimiter, static_cast<FString::EmptyTokenType>(keepEmpty));
return 0;
}
Oops, something went wrong.

0 comments on commit 062528e

Please sign in to comment.