Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing Zandronum functions. #97

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions token.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
1 change: 1 addition & 0 deletions token.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----------------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions zdefs.acs
Original file line number Diff line number Diff line change
Expand Up @@ -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
37 changes: 37 additions & 0 deletions zspecial.acs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down