mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-13 07:58:04 +00:00
- removed the hash table for the labels.
Again, the old code doesn't have it and it'd complicate porting over the code.
This commit is contained in:
parent
4a5953adb4
commit
1cedacb7f4
4 changed files with 31 additions and 31 deletions
|
@ -54,6 +54,7 @@ int parsing_state;
|
||||||
extern char tempbuf[];
|
extern char tempbuf[];
|
||||||
extern intptr_t* scriptptr;
|
extern intptr_t* scriptptr;
|
||||||
extern int* labelcode;
|
extern int* labelcode;
|
||||||
|
extern intptr_t* apScript;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -205,7 +206,7 @@ int findlabel(const char* text)
|
||||||
{
|
{
|
||||||
if (strcmp(label + (j << 6), text) == 0)
|
if (strcmp(label + (j << 6), text) == 0)
|
||||||
{
|
{
|
||||||
return labelcode[j];
|
return j;// labelcode[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -347,7 +348,12 @@ static void popscriptvalue()
|
||||||
{
|
{
|
||||||
script.Pop();
|
script.Pop();
|
||||||
}
|
}
|
||||||
static int scriptoffset(
|
|
||||||
|
void pushlabeladdress()
|
||||||
|
{
|
||||||
|
labelcode.Push(script.Size());
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// Helpers to write to the old script buffer while using the new interface. Allows to test the parser before implementing the rest.
|
// Helpers to write to the old script buffer while using the new interface. Allows to test the parser before implementing the rest.
|
||||||
|
@ -380,6 +386,13 @@ static void popscriptvalue()
|
||||||
scriptptr--;
|
scriptptr--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pushlabeladdress()
|
||||||
|
{
|
||||||
|
labelcode[labelcnt++] = int(scriptptr - apScript);
|
||||||
|
labelcnt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -581,13 +594,13 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
} while (*textptr != '*' || *(textptr + 1) != '/');
|
} while (*textptr != '*' || *(textptr + 1) != '/');
|
||||||
textptr += 2;
|
textptr += 2;
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
case concmd_state:
|
case concmd_state:
|
||||||
if (parsing_actor == 0 && parsing_state == 0)
|
if (parsing_actor == 0 && parsing_state == 0)
|
||||||
{
|
{
|
||||||
getlabel();
|
getlabel();
|
||||||
popscriptvalue();
|
popscriptvalue();
|
||||||
labelcode[labelcnt] = addrof(scriptptr);
|
pushlabeladdress();
|
||||||
labelcnt++;
|
|
||||||
|
|
||||||
parsing_state = 1;
|
parsing_state = 1;
|
||||||
|
|
||||||
|
@ -604,9 +617,10 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) State '%s' not found.\n", fn, line_number, label + (labelcnt << 6));
|
Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) State '%s' not found.\n", fn, line_number, label + (labelcnt << 6));
|
||||||
errorcount++;
|
errorcount++;
|
||||||
}
|
}
|
||||||
appendscriptvalue(lnum);
|
appendscriptvalue(labelcode[lnum]);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
#if 0
|
||||||
case concmd_sound:
|
case concmd_sound:
|
||||||
case concmd_globalsound:
|
case concmd_globalsound:
|
||||||
case concmd_soundonce:
|
case concmd_soundonce:
|
||||||
|
|
|
@ -73,7 +73,6 @@ extern intptr_t const * insptr;
|
||||||
extern void VM_ScriptInfo(intptr_t const *ptr, int range);
|
extern void VM_ScriptInfo(intptr_t const *ptr, int range);
|
||||||
|
|
||||||
extern hashtable_t h_gamevars;
|
extern hashtable_t h_gamevars;
|
||||||
extern hashtable_t h_labels;
|
|
||||||
|
|
||||||
extern int32_t g_aimAngleVarID; // var ID of "AUTOAIMANGLE"
|
extern int32_t g_aimAngleVarID; // var ID of "AUTOAIMANGLE"
|
||||||
extern int32_t g_angRangeVarID; // var ID of "ANGRANGE"
|
extern int32_t g_angRangeVarID; // var ID of "ANGRANGE"
|
||||||
|
|
|
@ -6531,7 +6531,6 @@ static void G_Cleanup(void)
|
||||||
Gv_Clear();
|
Gv_Clear();
|
||||||
|
|
||||||
hash_free(&h_gamevars);
|
hash_free(&h_gamevars);
|
||||||
hash_free(&h_labels);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -50,6 +50,7 @@ void skiptoendofline();
|
||||||
void skipwhitespace();
|
void skipwhitespace();
|
||||||
void skipblockcomment();
|
void skipblockcomment();
|
||||||
bool skipcomments();
|
bool skipcomments();
|
||||||
|
int findlabel(const char* text);
|
||||||
|
|
||||||
|
|
||||||
#define LINE_NUMBER (line_number << 12)
|
#define LINE_NUMBER (line_number << 12)
|
||||||
|
@ -135,14 +136,9 @@ char *bitptr; // pointer to bitmap of which bytecode positions contain pointers
|
||||||
#define BITPTR_IS_POINTER(x) (bitptr[(x)>>3] & (1<<((x) &7)))
|
#define BITPTR_IS_POINTER(x) (bitptr[(x)>>3] & (1<<((x) &7)))
|
||||||
|
|
||||||
hashtable_t h_gamevars = { MAXGAMEVARS >> 1, NULL };
|
hashtable_t h_gamevars = { MAXGAMEVARS >> 1, NULL };
|
||||||
hashtable_t h_labels = { 11264>>1, NULL };
|
|
||||||
|
|
||||||
static hashtable_t * const tables[] = {
|
static hashtable_t * const tables[] = {
|
||||||
&h_labels, &h_gamevars
|
&h_gamevars
|
||||||
};
|
|
||||||
|
|
||||||
static hashtable_t * const tables_free [] = {
|
|
||||||
&h_labels
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void C_InitHashes()
|
void C_InitHashes()
|
||||||
|
@ -574,7 +570,7 @@ static void C_GetNextVarType(int32_t type)
|
||||||
{
|
{
|
||||||
//try looking for a define instead
|
//try looking for a define instead
|
||||||
Bstrcpy(tempbuf,LAST_LABEL);
|
Bstrcpy(tempbuf,LAST_LABEL);
|
||||||
id = hash_find(&h_labels,tempbuf);
|
id = findlabel(tempbuf);
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_TRUE(id>=0 /*&& labeltype[id] & LABEL_DEFINE*/))
|
if (EDUKE32_PREDICT_TRUE(id>=0 /*&& labeltype[id] & LABEL_DEFINE*/))
|
||||||
{
|
{
|
||||||
|
@ -651,7 +647,7 @@ static int32_t C_GetNextValue_()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t i = hash_find(&h_labels,tempbuf);
|
int32_t i = findlabel(tempbuf);
|
||||||
|
|
||||||
if (i>=0)
|
if (i>=0)
|
||||||
{
|
{
|
||||||
|
@ -989,14 +985,13 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_add(&h_labels,label+(labelcnt<<6),labelcnt,0);
|
|
||||||
labelcnt++;
|
labelcnt++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
C_GetNextLabelName();
|
C_GetNextLabelName();
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_FALSE((j = hash_find(&h_labels,label+(labelcnt<<6))) < 0))
|
if (EDUKE32_PREDICT_FALSE((j = findlabel(label+(labelcnt<<6))) < 0))
|
||||||
{
|
{
|
||||||
C_ReportError(-1);
|
C_ReportError(-1);
|
||||||
Printf("%s:%d: error: state `%s' not found.\n",g_scriptFileName,line_number,label+(labelcnt<<6));
|
Printf("%s:%d: error: state `%s' not found.\n",g_scriptFileName,line_number,label+(labelcnt<<6));
|
||||||
|
@ -1121,7 +1116,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
|
|
||||||
C_GetNextValue(LABEL_DEFINE);
|
C_GetNextValue(LABEL_DEFINE);
|
||||||
|
|
||||||
i = hash_find(&h_labels,label+(labelcnt<<6));
|
i = findlabel(label+(labelcnt<<6));
|
||||||
if (i>=0)
|
if (i>=0)
|
||||||
{
|
{
|
||||||
// if (i >= g_numDefaultLabels)
|
// if (i >= g_numDefaultLabels)
|
||||||
|
@ -1135,7 +1130,6 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hash_add(&h_labels,label+(labelcnt<<6),labelcnt,0);
|
|
||||||
//labeltype[labelcnt] = LABEL_DEFINE;
|
//labeltype[labelcnt] = LABEL_DEFINE;
|
||||||
labelcode[labelcnt++] = *(scriptptr-1);
|
labelcode[labelcnt++] = *(scriptptr-1);
|
||||||
//if (*(scriptptr-1) >= 0 && *(scriptptr-1) < MAXTILES && g_dynamicTileMapping)
|
//if (*(scriptptr-1) >= 0 && *(scriptptr-1) < MAXTILES && g_dynamicTileMapping)
|
||||||
|
@ -1195,14 +1189,13 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_FALSE((i = hash_find(&h_labels,label+(labelcnt<<6))) >= 0))
|
if (EDUKE32_PREDICT_FALSE((i = findlabel(label+(labelcnt<<6))) >= 0))
|
||||||
{
|
{
|
||||||
g_warningCnt++;
|
g_warningCnt++;
|
||||||
Printf("%s:%d: warning: duplicate move `%s' ignored.\n",g_scriptFileName,line_number,label+(labelcnt<<6));
|
Printf("%s:%d: warning: duplicate move `%s' ignored.\n",g_scriptFileName,line_number,label+(labelcnt<<6));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hash_add(&h_labels,label+(labelcnt<<6),labelcnt,0);
|
|
||||||
//labeltype[labelcnt] = LABEL_MOVE;
|
//labeltype[labelcnt] = LABEL_MOVE;
|
||||||
labelcode[labelcnt++] = scriptptr-apScript;
|
labelcode[labelcnt++] = scriptptr-apScript;
|
||||||
}
|
}
|
||||||
|
@ -1310,7 +1303,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = hash_find(&h_labels,label+(labelcnt<<6));
|
i = findlabel(label+(labelcnt<<6));
|
||||||
if (EDUKE32_PREDICT_FALSE(i>=0))
|
if (EDUKE32_PREDICT_FALSE(i>=0))
|
||||||
{
|
{
|
||||||
g_warningCnt++;
|
g_warningCnt++;
|
||||||
|
@ -1319,7 +1312,6 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//labeltype[labelcnt] = LABEL_AI;
|
//labeltype[labelcnt] = LABEL_AI;
|
||||||
hash_add(&h_labels,label+(labelcnt<<6),labelcnt,0);
|
|
||||||
labelcode[labelcnt++] = scriptptr-apScript;
|
labelcode[labelcnt++] = scriptptr-apScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1383,7 +1375,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = hash_find(&h_labels,label+(labelcnt<<6));
|
i = findlabel(label+(labelcnt<<6));
|
||||||
if (EDUKE32_PREDICT_FALSE(i>=0))
|
if (EDUKE32_PREDICT_FALSE(i>=0))
|
||||||
{
|
{
|
||||||
g_warningCnt++;
|
g_warningCnt++;
|
||||||
|
@ -1393,7 +1385,6 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
{
|
{
|
||||||
//labeltype[labelcnt] = LABEL_ACTION;
|
//labeltype[labelcnt] = LABEL_ACTION;
|
||||||
labelcode[labelcnt] = scriptptr-apScript;
|
labelcode[labelcnt] = scriptptr-apScript;
|
||||||
hash_add(&h_labels,label+(labelcnt<<6),labelcnt,0);
|
|
||||||
labelcnt++;
|
labelcnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1438,7 +1429,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
}
|
}
|
||||||
g_szCurrentBlockName[j] = 0;
|
g_szCurrentBlockName[j] = 0;
|
||||||
|
|
||||||
j = hash_find(&h_labels, g_szCurrentBlockName);
|
j = findlabel(g_szCurrentBlockName);
|
||||||
|
|
||||||
//if (j != -1)
|
//if (j != -1)
|
||||||
// labeltype[j] |= LABEL_ACTOR;
|
// labeltype[j] |= LABEL_ACTOR;
|
||||||
|
@ -2215,7 +2206,7 @@ ifvar:
|
||||||
|
|
||||||
// Ideally we could keep the value of i from C_GetNextValue() instead of having to hash_find() again.
|
// Ideally we could keep the value of i from C_GetNextValue() instead of having to hash_find() again.
|
||||||
// This depends on tempbuf remaining in place after C_GetNextValue():
|
// This depends on tempbuf remaining in place after C_GetNextValue():
|
||||||
j = hash_find(&h_labels, tempbuf);
|
j = findlabel(tempbuf);
|
||||||
|
|
||||||
k = scriptptr[-1];
|
k = scriptptr[-1];
|
||||||
if ((unsigned)k >= MAXSOUNDS - 1)
|
if ((unsigned)k >= MAXSOUNDS - 1)
|
||||||
|
@ -2553,9 +2544,6 @@ void C_Compile(const char *fileName)
|
||||||
Printf("Script compiled in %dms, %ld bytes%s\n", timerGetTicks() - startcompiletime,
|
Printf("Script compiled in %dms, %ld bytes%s\n", timerGetTicks() - startcompiletime,
|
||||||
(unsigned long)(scriptptr-apScript), C_ScriptVersionString(g_scriptVersion));
|
(unsigned long)(scriptptr-apScript), C_ScriptVersionString(g_scriptVersion));
|
||||||
|
|
||||||
for (auto *i : tables_free)
|
|
||||||
hash_free(i);
|
|
||||||
|
|
||||||
//freehashnames();
|
//freehashnames();
|
||||||
freesoundhashnames();
|
freesoundhashnames();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue