From 2c2b811db0bdfe776f03fce1a9a8000545653907 Mon Sep 17 00:00:00 2001 From: TDRR Date: Tue, 17 Oct 2023 22:35:52 -0400 Subject: [PATCH] Add missing Zandronum functions. --- parse.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++ token.c | 1 + token.h | 1 + zdefs.acs | 13 ++++++ zspecial.acs | 37 ++++++++++++++++ 5 files changed, 168 insertions(+) diff --git a/parse.c b/parse.c index 52a0fa3..912fd38 100644 --- a/parse.c +++ b/parse.c @@ -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(); diff --git a/token.c b/token.c index c8613c8..2217bde 100644 --- a/token.c +++ b/token.c @@ -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])) diff --git a/token.h b/token.h index 388daa7..652dd06 100644 --- a/token.h +++ b/token.h @@ -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 ---------------------------------------------- diff --git a/zdefs.acs b/zdefs.acs index 3188cc1..4b14847 100644 --- a/zdefs.acs +++ b/zdefs.acs @@ -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 diff --git a/zspecial.acs b/zspecial.acs index 8c41d20..06805ab 100644 --- a/zspecial.acs +++ b/zspecial.acs @@ -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),