CON parser cleanup: make labelcode save offsets to CON code instead of

pointers and make it into an int32_t*.

git-svn-id: https://svn.eduke32.com/eduke32@2152 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-12-04 21:20:17 +00:00
parent 0b7c08ce0e
commit 03000a52b9
4 changed files with 23 additions and 19 deletions

View file

@ -9230,7 +9230,7 @@ static void G_CompileScripts(void)
int32_t psm = pathsearchmode;
label = (char *)&sprite[0]; // V8: 16384*44/64 = 11264 V7: 4096*44/64 = 2816
labelcode = (intptr_t *)&sector[0]; // V8: 4096*40/4 = 40960 V7: 1024*40/4 = 10240
labelcode = (int32_t *)&sector[0]; // V8: 4096*40/4 = 40960 V7: 1024*40/4 = 10240
labeltype = (int32_t *)&wall[0]; // V8: 16384*32/4 = 131072 V7: 8192*32/4 = 65536
Bcorrectfilename(g_scriptNamePtr,0);
@ -9256,18 +9256,18 @@ static void G_CompileScripts(void)
else
{
char *newlabel;
intptr_t *newlabelcode;
int32_t *newlabelcode;
newlabel = (char *)Bmalloc(g_numLabels<<6);
newlabelcode = (intptr_t *)Bmalloc(g_numLabels*sizeof(intptr_t));
newlabel = Bmalloc(g_numLabels<<6);
newlabelcode = Bmalloc(g_numLabels*sizeof(int32_t));
if (!newlabel || !newlabelcode)
{
G_GameExit("Error: out of memory retaining labels\n");
}
copybuf(label, newlabel, (g_numLabels*64)/4);
copybuf(labelcode, newlabelcode, (g_numLabels*sizeof(intptr_t))/4);
Bmemcpy(newlabel, label, g_numLabels*64);
Bmemcpy(newlabelcode, labelcode, g_numLabels*sizeof(int32_t));
label = newlabel;
labelcode = newlabelcode;

View file

@ -1103,14 +1103,14 @@ static int32_t C_SetScriptSize(int32_t newsize)
int32_t osize = g_scriptSize;
char *scriptptrs;
char *newbitptr;
#if 0
for (i=MAXSECTORS-1; i>=0; i--)
if (labelcode[i] && labeltype[i] != LABEL_DEFINE)
{
j = (intptr_t)labelcode[i]-(intptr_t)&script[0];
labelcode[i] = (intptr_t)j;
}
#endif
scriptptrs = Bcalloc(1, g_scriptSize * sizeof(uint8_t));
for (i=g_scriptSize-1; i>=0; i--)
@ -1174,7 +1174,7 @@ static int32_t C_SetScriptSize(int32_t newsize)
if (g_parsingActorPtr)
g_parsingActorPtr = (intptr_t *)(script+oparsingActorPtr);
#if 0
for (i=MAXSECTORS-1; i>=0; i--)
{
if (labelcode[i] && labeltype[i] != LABEL_DEFINE)
@ -1183,7 +1183,7 @@ static int32_t C_SetScriptSize(int32_t newsize)
labelcode[i] = j;
}
}
#endif
for (i=(((newsize>=osize)?osize:newsize))-1; i>=0; i--)
if (scriptptrs[i])
{
@ -1676,6 +1676,9 @@ static int32_t C_GetNextValue(int32_t type)
bitptr[(g_scriptPtr-script)>>3] &= ~(BITPTR_POINTER<<((g_scriptPtr-script)&7));
#endif
if ((labeltype[i]&LABEL_DEFINE)==0)
*(g_scriptPtr++) = (intptr_t)(script + labelcode[i]);
else
*(g_scriptPtr++) = labelcode[i];
textptr += l;
return labeltype[i];
@ -1932,7 +1935,7 @@ static int32_t C_ParseCommand(int32_t loop)
{
C_GetNextLabelName();
g_scriptPtr--;
labelcode[g_numLabels] = (intptr_t) g_scriptPtr;
labelcode[g_numLabels] = g_scriptPtr-script;
labeltype[g_numLabels] = LABEL_STATE;
g_processingState = 1;
@ -1964,7 +1967,7 @@ static int32_t C_ParseCommand(int32_t loop)
{
if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1)
initprintf("%s:%d: debug: accepted state label `%s'.\n",g_szScriptFileName,g_lineNumber,label+(j<<6));
*g_scriptPtr = labelcode[j];
*g_scriptPtr = (intptr_t)(script+labelcode[j]);
#if 0
if (labelcode[j] >= (intptr_t)&script[0] && labelcode[j] < (intptr_t)&script[g_scriptSize])
bitptr[(g_scriptPtr-script)>>3] |= (BITPTR_POINTER<<((g_scriptPtr-script)&7));
@ -2308,7 +2311,7 @@ static int32_t C_ParseCommand(int32_t loop)
{
hash_add(&h_labels,label+(g_numLabels<<6),g_numLabels,0);
labeltype[g_numLabels] = LABEL_MOVE;
labelcode[g_numLabels++] = (intptr_t) g_scriptPtr;
labelcode[g_numLabels++] = g_scriptPtr-script;
}
for (j=1; j>=0; j--)
@ -2445,7 +2448,7 @@ static int32_t C_ParseCommand(int32_t loop)
{
labeltype[g_numLabels] = LABEL_AI;
hash_add(&h_labels,label+(g_numLabels<<6),g_numLabels,0);
labelcode[g_numLabels++] = (intptr_t) g_scriptPtr;
labelcode[g_numLabels++] = g_scriptPtr-script;
}
for (j=0; j<3; j++)
@ -2525,7 +2528,7 @@ static int32_t C_ParseCommand(int32_t loop)
if (i == -1)
{
labeltype[g_numLabels] = LABEL_ACTION;
labelcode[g_numLabels] = (intptr_t) g_scriptPtr;
labelcode[g_numLabels] = g_scriptPtr-script;
hash_add(&h_labels,label+(g_numLabels<<6),g_numLabels,0);
g_numLabels++;
}

View file

@ -112,8 +112,8 @@ int32_t screenpeek;
char ready2send;
int32_t vel, svel, angvel, horiz, ototalclock, g_actorRespawnTime=768, g_itemRespawnTime=768, g_groupFileHandle;
intptr_t *g_scriptPtr,*insptr,*labelcode;
int32_t *labeltype;
intptr_t *g_scriptPtr,*insptr;
int32_t *labelcode, *labeltype;
int32_t g_numLabels,g_numDefaultLabels;
intptr_t *actorscrptr[MAXTILES],*g_parsingActorPtr;
char *label;

View file

@ -122,7 +122,8 @@ G_EXTERN int32_t startofdynamicinterpolations;
G_EXTERN int32_t vel,svel,angvel,horiz,ototalclock,g_actorRespawnTime;
G_EXTERN int8_t multiwho,multipos,multiwhat,multiflag;
G_EXTERN intptr_t *actorscrptr[MAXTILES],*g_parsingActorPtr;
G_EXTERN intptr_t *g_scriptPtr,*insptr,*labelcode,*labeltype;
G_EXTERN intptr_t *g_scriptPtr,*insptr;
G_EXTERN int32_t *labelcode,*labeltype;
G_EXTERN intptr_t *script;
G_EXTERN map_t MapInfo[(MAXVOLUMES+1)*MAXLEVELS];
G_EXTERN playerdata_t g_player[MAXPLAYERS];