git-svn-id: https://svn.eduke32.com/eduke32@568 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2007-08-29 05:02:43 +00:00
parent eec7e1b2e0
commit f0264b1140
2 changed files with 19 additions and 17 deletions

View file

@ -1483,18 +1483,17 @@ static int parsecommand(void)
long ocasescriptptr = (unsigned)(casescriptptr-script); long ocasescriptptr = (unsigned)(casescriptptr-script);
long oparsing_event = (unsigned)(parsing_event-script); long oparsing_event = (unsigned)(parsing_event-script);
long oparsing_actor = (unsigned)(parsing_actor-script); long oparsing_actor = (unsigned)(parsing_actor-script);
long olabelcode[MAXSECTORS];
long *scriptptrs; long *scriptptrs;
Bmemset(&olabelcode,0,sizeof(olabelcode)); for (i=0;i<MAXSECTORS;i++)
for (j=0;j<labelcnt;j++)
{ {
if (labeltype[j] != LABEL_DEFINE) //== LABEL_STATE || labeltype[j] == LABEL_AI || labeltype[j] == LABEL_ACTION || labeltype[j] == LABEL_MOVE) if (labelcode[i] && labeltype[i] != LABEL_DEFINE)
olabelcode[j] = (long)(labelcode[j]-(long)script); {
labelcode[i] -= (long)&script[0];
}
} }
scriptptrs = Bcalloc(1, (g_ScriptSize+16) * sizeof(long)); scriptptrs = Bcalloc(1,g_ScriptSize * sizeof(long));
for (i=0;i<g_ScriptSize-1;i++) for (i=0;i<g_ScriptSize-1;i++)
{ {
if ((long)script[i] >= (long)(&script[0]) && (long)script[i] < (long)(&script[g_ScriptSize])) if ((long)script[i] >= (long)(&script[0]) && (long)script[i] < (long)(&script[g_ScriptSize]))
@ -1530,7 +1529,7 @@ static int parsecommand(void)
//initprintf("offset: %ld\n",(unsigned)(scriptptr-script)); //initprintf("offset: %ld\n",(unsigned)(scriptptr-script));
g_ScriptSize += 16384; g_ScriptSize += 16384;
initprintf("Increasing script buffer size to %ld bytes...\n",g_ScriptSize); initprintf("Increasing script buffer size to %ld bytes...\n",g_ScriptSize);
script = (long *)realloc(script, (g_ScriptSize+16) * sizeof(long)); script = (long *)realloc(script, g_ScriptSize * sizeof(long));
if (script == NULL) if (script == NULL)
{ {
@ -1549,11 +1548,11 @@ static int parsecommand(void)
if (parsing_actor != NULL) if (parsing_actor != NULL)
parsing_actor = (long *)(script+oparsing_actor); parsing_actor = (long *)(script+oparsing_actor);
for (j=0;j<labelcnt;j++) for (i=0;i<MAXSECTORS;i++)
{ {
if (labeltype[j] != LABEL_DEFINE)//== LABEL_STATE || labeltype[j] == LABEL_AI || labeltype[j] == LABEL_ACTION || labeltype[j] == LABEL_MOVE) if (labelcode[i] && labeltype[i] != LABEL_DEFINE)
{ {
labelcode[j] = (long)(script+olabelcode[j]); labelcode[i] += (long)&script[0];
} }
} }
@ -3420,7 +3419,7 @@ static int parsecommand(void)
transmultvars(2); transmultvars(2);
tempscrptr = scriptptr; tempscrptr = scriptptr;
offset = (unsigned)(tempscrptr-script); offset = (unsigned)(scriptptr-script);
scriptptr++; // Leave a spot for the fail location scriptptr++; // Leave a spot for the fail location
j = keyword(); j = keyword();
@ -3695,7 +3694,7 @@ static int parsecommand(void)
casecount=0; casecount=0;
if (tempscrptr) if (tempscrptr)
{ {
tempscrptr[0]= (unsigned)(scriptptr-script); // save 'end' location tempscrptr[0]= (long)scriptptr - (long)&script[0]; // save 'end' location
} }
else else
{ {
@ -3742,7 +3741,7 @@ repeatcase:
{ {
//AddLog("Adding value to script"); //AddLog("Adding value to script");
casescriptptr[casecount++]=j; // save value casescriptptr[casecount++]=j; // save value
casescriptptr[casecount]=(long)((long*)scriptptr-script); // save offset casescriptptr[casecount]=(long)((long*)scriptptr-&script[0]); // save offset
} }
// j = keyword(); // j = keyword();
//Bsprintf(g_szBuf,"case3: %.12s",textptr); //Bsprintf(g_szBuf,"case3: %.12s",textptr);
@ -3790,7 +3789,7 @@ repeatcase:
} }
if (casescriptptr) if (casescriptptr)
{ {
casescriptptr[0]=(long)(scriptptr-script); // save offset casescriptptr[0]=(long)(scriptptr-&script[0]); // save offset
} }
//Bsprintf(g_szBuf,"default: '%.22s'",textptr); //Bsprintf(g_szBuf,"default: '%.22s'",textptr);
//AddLog(g_szBuf); //AddLog(g_szBuf);
@ -4862,7 +4861,7 @@ void loadefs(const char *filenam)
// clearbufbyte(script,sizeof(script),0l); // JBF 20040531: yes? no? // clearbufbyte(script,sizeof(script),0l); // JBF 20040531: yes? no?
if (script != NULL) if (script != NULL)
Bfree(script); Bfree(script);
script = Bcalloc(1,sizeof(long)*(g_ScriptSize+16)); script = Bcalloc(1,g_ScriptSize * sizeof(long));
labelcnt = defaultlabelcnt = 0; labelcnt = defaultlabelcnt = 0;
scriptptr = script+1; scriptptr = script+1;
@ -4875,7 +4874,7 @@ void loadefs(const char *filenam)
Bstrcpy(compilefile, filenam); // JBF 20031130: Store currently compiling file name Bstrcpy(compilefile, filenam); // JBF 20031130: Store currently compiling file name
passone(); //Tokenize passone(); //Tokenize
*script = (long) scriptptr; //*script = (long) scriptptr;
Bfree(mptr); Bfree(mptr);
mptr = NULL; mptr = NULL;

View file

@ -267,6 +267,9 @@ int loadplayer(int spot)
if (kdfread(&g_ScriptSize,sizeof(g_ScriptSize),1,fil) != 1) goto corrupt; if (kdfread(&g_ScriptSize,sizeof(g_ScriptSize),1,fil) != 1) goto corrupt;
scriptptrs = Bcalloc(1,g_ScriptSize * sizeof(g_ScriptSize)); scriptptrs = Bcalloc(1,g_ScriptSize * sizeof(g_ScriptSize));
if (kdfread(&scriptptrs[0],sizeof(scriptptrs),g_ScriptSize,fil) != g_ScriptSize) goto corrupt; if (kdfread(&scriptptrs[0],sizeof(scriptptrs),g_ScriptSize,fil) != g_ScriptSize) goto corrupt;
if (script != NULL)
Bfree(script);
script = Bcalloc(1,g_ScriptSize * sizeof(long));
if (kdfread(&script[0],sizeof(script),g_ScriptSize,fil) != g_ScriptSize) goto corrupt; if (kdfread(&script[0],sizeof(script),g_ScriptSize,fil) != g_ScriptSize) goto corrupt;
for (i=0;i<g_ScriptSize;i++) for (i=0;i<g_ScriptSize;i++)
if (scriptptrs[i]) if (scriptptrs[i])