Add missing Zandronum functions.

This commit is contained in:
TDRR 2023-10-17 22:35:52 -04:00 committed by Rachael Alexanderson
parent 6de579093d
commit 2c2b811db0
5 changed files with 168 additions and 0 deletions

116
parse.c
View file

@ -101,6 +101,7 @@ static void LeadingStrcpy(void);
static void LeadingPrint(void);
static void LeadingHudMessage(void);
static void LeadingMorphActor(void);
static void LeadingLumpReadArray(void);
static void LeadingVarAssign(symbolNode_t *sym);
static pcd_t GetAssignPCD(tokenType_t token, symbolType_t symbol);
static void LeadingInternFunc(symbolNode_t *sym);
@ -1392,6 +1393,14 @@ static boolean ProcessStatement(statement_t owner)
TK_NextTokenMustBe(TK_SEMICOLON, ERR_MISSING_SEMICOLON);
TK_NextToken();
break;
case TK_LUMPREADARRAY:
LeadingLumpReadArray();
PC_AppendCmd(PCD_DROP);
TK_NextTokenMustBe(TK_SEMICOLON, ERR_MISSING_SEMICOLON);
TK_NextToken();
break;
case TK_IF:
LeadingIf();
break;
@ -2619,6 +2628,109 @@ static void LeadingMorphActor(void)
PC_AppendCmd(PCD_MORPHACTOR);
}
//==========================================================================
//
// LumpReadOnCharRange
//
//==========================================================================
static U_BYTE LumpReadOnCharRange(void)
{
symbolNode_t *sym;
TK_NextToken();
sym = SpeculateSymbol(tk_String, NO);
if((sym->type != SY_MAPARRAY) && (sym->type != SY_WORLDARRAY)
&& (sym->type != SY_GLOBALARRAY) && (sym->type != SY_SCRIPTARRAY))
{
ERR_Error(ERR_NOT_AN_ARRAY, YES, sym->name);
}
PC_AppendPushVal(sym->info.array.index);
if(sym->type == SY_SCRIPTARRAY)
{
return 162;
}
else if(sym->type == SY_MAPARRAY)
{
return 163;
}
else if(sym->type == SY_WORLDARRAY)
{
return 164;
}
else
{
return 165;
}
}
//==========================================================================
//
// LeadingLumpReadArray
//
// LumpReadArray(int lump, int pos, Array dest, int index)
//
//==========================================================================
static void LeadingLumpReadArray(void)
{
U_BYTE funcIndex = 0;
int i = 0;
MS_Message(MSG_DEBUG, "---- LeadingLumpReadArray ----\n");
TK_NextTokenMustBe(TK_LPAREN, ERR_MISSING_LPAREN);
if(TK_NextToken() == TK_CONST)
{
TK_NextTokenMustBe(TK_COLON, ERR_MISSING_COLON);
ERR_Error(ERR_NO_DIRECT_VER, YES, NULL);
TK_NextToken();
}
if(tk_Token == TK_RPAREN)
{
ERR_Error(ERR_MISSING_PARAM, YES);
}
else
{
TK_Undo(); // Adjust for first expression
do
{
if(i == 5)
{
ERR_Error(ERR_BAD_ARG_COUNT, YES);
TK_SkipTo(TK_SEMICOLON);
TK_Undo();
return;
}
TK_NextToken();
if(tk_Token != TK_COMMA)
{
if(i == 2)
{
funcIndex = LumpReadOnCharRange();
}
else
{
EvalExpression();
}
}
i++;
} while(tk_Token == TK_COMMA);
}
if(i < 3)
{
ERR_Error(ERR_BAD_ARG_COUNT, YES);
}
TK_TokenMustBe(TK_RPAREN, ERR_MISSING_RPAREN);
PC_AppendCmd(PCD_CALLFUNC);
PC_AppendByte(i);
PC_AppendWord(funcIndex);
}
//==========================================================================
//
// LeadingCreateTranslation
@ -3922,6 +4034,10 @@ static void ExprFactor(void)
LeadingMorphActor();
TK_NextToken();
break;
case TK_LUMPREADARRAY:
LeadingLumpReadArray();
TK_NextToken();
break;
default:
ERR_Error(ERR_BAD_EXPR, YES);
TK_NextToken();

View file

@ -202,6 +202,7 @@ static struct keyword_s
{ "kill", TK_KILL }, // [JM]
{ "reopen", TK_REOPEN }, // [Nash]
{ "morphactor", TK_MORPHACTOR }, // [Dasperal]
{ "lumpreadarray", TK_LUMPREADARRAY }, // [TDRR]
};
#define NUM_KEYWORDS (sizeof(Keywords)/sizeof(Keywords[0]))

View file

@ -139,6 +139,7 @@ typedef enum
TK_REOPEN, // 'reopen' [Nash]
TK_ATSIGN, // '@'
TK_MORPHACTOR, // 'morphactor' [Dasperal]
TK_LUMPREADARRAY, // 'lumpreadarray' [TDRR]
} tokenType_t;
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------

View file

@ -1168,3 +1168,16 @@
#define AMLS_InterTeleport 11
#define AMLS_UnexploredSecret 12
#define AMLS_Portal 13
// Lump reading stuff.
#define LUMP_OPEN_FULLPATH 1
#define LUMP_READ_BYTE 0
#define LUMP_READ_UBYTE 1
#define LUMP_READ_SHORT 2
#define LUMP_READ_USHORT 3
#define LUMP_READ_INT 4
#define LUMP_READ_FLOAT 5
#define LUMP_INFO_SIZE 0
#define LUMP_INFO_NAME 1

View file

@ -413,6 +413,43 @@ special
-123:BeginDBTransaction(0),
-124:EndDBTransaction(0),
-125:GetDBEntries(1),
-126:NamedRequestScriptPuke(1,5),
-127:SystemTime(0),
-128:GetTimeProperty(2,3),
-129:Strftime(2,3),
-130:SetDeadSpectator(2),
-131:SetActivatorToPlayer(1),
-132:SetCurrentGamemode(1),
-133:GetCurrentGamemode(0),
-134:SetGamemodeLimit(2),
-135:SetPlayerClass(3),
-136:SetPlayerChasecam(2),
-137:GetPlayerChasecam(1),
-138:SetPlayerScore(3),
-139:GetPlayerScore(2),
-140:InDemoMode(0),
-144:ExecuteClientScript(2,6),
-145:NamedExecuteClientScript(2,6),
-146:SendNetworkString(2,3),
-147:NamedSendNetworkString(2,3),
-148:GetChatMessage(2),
-149:GetMapRotationSize(0),
-150:GetMapRotationInfo(2),
-151:GetCurrentMapPosition(0),
-152:GetEventResult(0),
-153:GetActorSectorLocation(2),
-154:ChangeTeamScore(3,4),
-155:SetGameplaySetting(2),
-156:SetCustomPlayerValue(3),
-157:GetCustomPlayerValue(2),
-158:ResetCustomDataToDefault(2),
-159:LumpOpen(1,3),
-160:LumpRead(2,3),
-161:LumpReadString(2,3),
// LumpReadArray is a set of 4 functions, whose definition is
// built-in to ACC. So 162-165 are used up function indices.
-166:LumpGetInfo(2),
-167:LumpClose(1),
// -1xx are reserved for Zandronum
-200:CheckClass(1),