C-CON: Clean up pointer handling in the parser so we have less to re-offset in C_SetScriptSize. Also fixes bugs in r5093 and/or r5097.

git-svn-id: https://svn.eduke32.com/eduke32@5521 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2016-01-08 01:33:01 +00:00
parent 1807aec2a7
commit 5d9b8a2bb1
7 changed files with 59 additions and 76 deletions

View file

@ -295,7 +295,6 @@ extern int32_t block_deletesprite;
extern int32_t g_noEnemies; extern int32_t g_noEnemies;
extern int32_t otherp; extern int32_t otherp;
extern int32_t ticrandomseed; extern int32_t ticrandomseed;
extern intptr_t *g_parsingActorPtr;
extern projectile_t SpriteProjectile[MAXSPRITES]; extern projectile_t SpriteProjectile[MAXSPRITES];

View file

@ -52,8 +52,8 @@ static int32_t g_checkingIfElse, g_processingState, g_lastKeyword = -1;
// The pointer to the start of the case table in a switch statement. // The pointer to the start of the case table in a switch statement.
// First entry is 'default' code. // First entry is 'default' code.
static intptr_t *g_caseScriptPtr=NULL; static intptr_t *g_caseScriptPtr;
static intptr_t *previous_event=NULL; static intptr_t previous_event;
static int32_t g_numCases = 0; static int32_t g_numCases = 0;
static int32_t g_checkingSwitch = 0, g_currentEvent = -1; static int32_t g_checkingSwitch = 0, g_currentEvent = -1;
static int32_t g_labelsOnly = 0, g_skipKeywordCheck = 0, g_dynamicTileMapping = 0, g_dynamicSoundMapping = 0; static int32_t g_labelsOnly = 0, g_skipKeywordCheck = 0, g_dynamicTileMapping = 0, g_dynamicSoundMapping = 0;
@ -70,8 +70,10 @@ weapondata_t g_playerWeapon[MAXPLAYERS][MAX_WEAPONS];
#endif #endif
#if !defined LUNATIC #if !defined LUNATIC
static intptr_t *g_parsingEventPtr=NULL; static intptr_t g_parsingActorPtr;
static intptr_t *g_parsingEventBreakPtr=NULL; static intptr_t g_parsingEventPtr;
static intptr_t g_parsingEventBreakPtr;
static intptr_t apScriptGameEventEnd[MAXGAMEEVENTS];
static char *textptr; static char *textptr;
#endif #endif
@ -1277,10 +1279,7 @@ static int32_t g_ifElseAborted;
static int32_t C_SetScriptSize(int32_t newsize) static int32_t C_SetScriptSize(int32_t newsize)
{ {
intptr_t oscriptPtr = (unsigned)(g_scriptPtr-script); intptr_t const oscript = (intptr_t)script;
intptr_t ocaseScriptPtr = (unsigned)(g_caseScriptPtr-script);
intptr_t oparsingEventPtr = (unsigned)(g_parsingEventPtr-script);
intptr_t oparsingActorPtr = (unsigned)(g_parsingActorPtr-script);
intptr_t *newscript; intptr_t *newscript;
intptr_t i, j; intptr_t i, j;
int32_t osize = g_scriptSize; int32_t osize = g_scriptSize;
@ -1308,7 +1307,6 @@ static int32_t C_SetScriptSize(int32_t newsize)
G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), script, P2I_FWD_NON0); G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), script, P2I_FWD_NON0);
G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), script, P2I_FWD_NON0); G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), script, P2I_FWD_NON0);
G_Util_PtrToIdx(apScriptGameEvent, MAXGAMEEVENTS, script, P2I_FWD_NON0);
initprintf("Resizing code buffer to %d*%d bytes\n",newsize, (int32_t)sizeof(intptr_t)); initprintf("Resizing code buffer to %d*%d bytes\n",newsize, (int32_t)sizeof(intptr_t));
@ -1332,16 +1330,10 @@ static int32_t C_SetScriptSize(int32_t newsize)
} }
g_scriptSize = newsize; g_scriptSize = newsize;
g_scriptPtr = (intptr_t *)(script+oscriptPtr); g_scriptPtr = script + (intptr_t)g_scriptPtr - oscript;
if (g_caseScriptPtr) if (g_caseScriptPtr)
g_caseScriptPtr = (intptr_t *)(script+ocaseScriptPtr); g_caseScriptPtr = script + (intptr_t)g_caseScriptPtr - oscript;
if (g_parsingEventPtr)
g_parsingEventPtr = (intptr_t *)(script+oparsingEventPtr);
if (g_parsingActorPtr)
g_parsingActorPtr = (intptr_t *)(script+oparsingActorPtr);
for (i=(((newsize>=osize)?osize:newsize))-1; i>=0; i--) for (i=(((newsize>=osize)?osize:newsize))-1; i>=0; i--)
if (scriptptrs[i]) if (scriptptrs[i])
@ -1352,7 +1344,6 @@ static int32_t C_SetScriptSize(int32_t newsize)
G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), script, P2I_BACK_NON0); G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), script, P2I_BACK_NON0);
G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), script, P2I_BACK_NON0); G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), script, P2I_BACK_NON0);
G_Util_PtrToIdx(apScriptGameEvent, MAXGAMEEVENTS, script, P2I_BACK_NON0);
Bfree(scriptptrs); Bfree(scriptptrs);
return 0; return 0;
@ -1418,7 +1409,7 @@ static int32_t C_SkipComments(void)
initprintf("%s:%d: debug: EOF in comment!\n",g_szScriptFileName,g_lineNumber); initprintf("%s:%d: debug: EOF in comment!\n",g_szScriptFileName,g_lineNumber);
C_ReportError(-1); C_ReportError(-1);
initprintf("%s:%d: error: found `/*' with no `*/'.\n",g_szScriptFileName,g_lineNumber); initprintf("%s:%d: error: found `/*' with no `*/'.\n",g_szScriptFileName,g_lineNumber);
g_parsingActorPtr = NULL; g_processingState = g_numBraces = 0; g_parsingActorPtr = g_processingState = g_numBraces = 0;
g_numCompilerErrors++; g_numCompilerErrors++;
continue; continue;
} }
@ -2782,9 +2773,10 @@ static void C_FillEventBreakStackWithJump(intptr_t *breakPtr, intptr_t destinati
{ {
while (breakPtr) while (breakPtr)
{ {
breakPtr = script + (intptr_t)breakPtr;
intptr_t const tempPtr = *breakPtr; intptr_t const tempPtr = *breakPtr;
*breakPtr = destination; *breakPtr = destination;
breakPtr = (intptr_t*)tempPtr; breakPtr = (intptr_t *)tempPtr;
} }
} }
@ -2817,7 +2809,7 @@ static int32_t C_ParseCommand(int32_t loop)
} }
goto DO_DEFSTATE; goto DO_DEFSTATE;
case CON_STATE: case CON_STATE:
if (g_parsingActorPtr == NULL && g_processingState == 0) if (!g_parsingActorPtr && g_processingState == 0)
{ {
DO_DEFSTATE: DO_DEFSTATE:
C_GetNextLabelName(); C_GetNextLabelName();
@ -3345,7 +3337,7 @@ DO_DEFSTATE:
g_numBraces = 0; g_numBraces = 0;
g_scriptPtr--; g_scriptPtr--;
g_parsingActorPtr = g_scriptPtr; g_parsingActorPtr = g_scriptPtr - script;
if (tw == CON_USERACTOR) if (tw == CON_USERACTOR)
{ {
@ -3390,12 +3382,12 @@ DO_DEFSTATE:
if (tw == CON_EVENTLOADACTOR) if (tw == CON_EVENTLOADACTOR)
{ {
g_tile[*g_scriptPtr].loadPtr = g_parsingActorPtr; g_tile[*g_scriptPtr].loadPtr = script + g_parsingActorPtr;
g_checkingIfElse = 0; g_checkingIfElse = 0;
continue; continue;
} }
g_tile[*g_scriptPtr].execPtr = g_parsingActorPtr; g_tile[*g_scriptPtr].execPtr = script + g_parsingActorPtr;
if (tw == CON_USERACTOR) if (tw == CON_USERACTOR)
{ {
@ -3411,8 +3403,8 @@ DO_DEFSTATE:
for (j=0; j<4; j++) for (j=0; j<4; j++)
{ {
bitptr[(g_parsingActorPtr+j-script)>>3] &= ~(1<<((g_parsingActorPtr+j-script)&7)); bitptr[(intptr_t)((intptr_t *)g_parsingActorPtr+j)>>3] &= ~(1<<((intptr_t)((intptr_t *)g_parsingActorPtr+j)&7));
*(g_parsingActorPtr+j) = 0; *((script+j)+g_parsingActorPtr) = 0;
if (j == 3) if (j == 3)
{ {
j = 0; j = 0;
@ -3455,9 +3447,9 @@ DO_DEFSTATE:
break; break;
} }
if (*(g_scriptPtr-1) >= (intptr_t)&script[0] && *(g_scriptPtr-1) < (intptr_t)&script[g_scriptSize]) if (*(g_scriptPtr-1) >= (intptr_t)&script[0] && *(g_scriptPtr-1) < (intptr_t)&script[g_scriptSize])
bitptr[(g_parsingActorPtr+j-script)>>3] |= (BITPTR_POINTER<<((g_parsingActorPtr+j-script)&7)); bitptr[(intptr_t)((intptr_t *)g_parsingActorPtr+j)>>3] |= (BITPTR_POINTER<<((intptr_t)((intptr_t *)g_parsingActorPtr+j)&7));
else bitptr[(g_parsingActorPtr+j-script)>>3] &= ~(1<<((g_parsingActorPtr+j-script)&7)); else bitptr[(intptr_t)((intptr_t *)g_parsingActorPtr+j)>>3] &= ~(1<<((intptr_t)((intptr_t *)g_parsingActorPtr+j)&7));
*(g_parsingActorPtr+j) = *(g_scriptPtr-1); *((script+j)+g_parsingActorPtr) = *(g_scriptPtr-1);
} }
} }
g_checkingIfElse = 0; g_checkingIfElse = 0;
@ -3473,8 +3465,7 @@ DO_DEFSTATE:
g_numBraces = 0; g_numBraces = 0;
g_scriptPtr--; g_scriptPtr--;
g_parsingEventPtr = g_scriptPtr; g_parsingEventPtr = g_parsingActorPtr = g_scriptPtr - script;
g_parsingActorPtr = g_scriptPtr;
C_SkipComments(); C_SkipComments();
j = 0; j = 0;
@ -3510,12 +3501,11 @@ DO_DEFSTATE:
} }
else // if (tw == CON_APPENDEVENT) else // if (tw == CON_APPENDEVENT)
{ {
intptr_t const destination = g_parsingEventPtr - script; intptr_t *previous_event_end = script + apScriptGameEventEnd[j];
intptr_t *previous_event_end = apScriptGameEventEnd[j]; *(previous_event_end++) = CON_JUMP | (g_lineNumber << 12);
*(previous_event_end++) = CON_JUMP;
*(previous_event_end++) = MAXGAMEVARS; *(previous_event_end++) = MAXGAMEVARS;
C_FillEventBreakStackWithJump((intptr_t*)*previous_event_end, destination); C_FillEventBreakStackWithJump((intptr_t *)*previous_event_end, g_parsingEventPtr);
*(previous_event_end++) = destination; *(previous_event_end++) = g_parsingEventPtr;
} }
g_checkingIfElse = 0; g_checkingIfElse = 0;
@ -4351,7 +4341,7 @@ DO_DEFSTATE:
} }
case CON_SPRITEFLAGS: case CON_SPRITEFLAGS:
if (g_parsingActorPtr == NULL && g_processingState == 0) if (!g_parsingActorPtr && g_processingState == 0)
{ {
g_scriptPtr--; g_scriptPtr--;
@ -4536,7 +4526,7 @@ DO_DEFSTATE:
case CON_ROTATESPRITE16: case CON_ROTATESPRITE16:
case CON_ROTATESPRITE: case CON_ROTATESPRITE:
if (EDUKE32_PREDICT_FALSE(g_parsingEventPtr == NULL && g_processingState == 0)) if (EDUKE32_PREDICT_FALSE(!g_parsingEventPtr && g_processingState == 0))
{ {
C_ReportError(ERROR_EVENTONLY); C_ReportError(ERROR_EVENTONLY);
g_numCompilerErrors++; g_numCompilerErrors++;
@ -4552,7 +4542,7 @@ DO_DEFSTATE:
continue; continue;
case CON_ROTATESPRITEA: case CON_ROTATESPRITEA:
if (EDUKE32_PREDICT_FALSE(g_parsingEventPtr == NULL && g_processingState == 0)) if (EDUKE32_PREDICT_FALSE(!g_parsingEventPtr && g_processingState == 0))
{ {
C_ReportError(ERROR_EVENTONLY); C_ReportError(ERROR_EVENTONLY);
g_numCompilerErrors++; g_numCompilerErrors++;
@ -4563,7 +4553,7 @@ DO_DEFSTATE:
case CON_SHOWVIEW: case CON_SHOWVIEW:
case CON_SHOWVIEWUNBIASED: case CON_SHOWVIEWUNBIASED:
if (EDUKE32_PREDICT_FALSE(g_parsingEventPtr == NULL && g_processingState == 0)) if (EDUKE32_PREDICT_FALSE(!g_parsingEventPtr && g_processingState == 0))
{ {
C_ReportError(ERROR_EVENTONLY); C_ReportError(ERROR_EVENTONLY);
g_numCompilerErrors++; g_numCompilerErrors++;
@ -4644,7 +4634,7 @@ DO_DEFSTATE:
case CON_DIGITALNUMBER: case CON_DIGITALNUMBER:
case CON_DIGITALNUMBERZ: case CON_DIGITALNUMBERZ:
case CON_SCREENTEXT: case CON_SCREENTEXT:
if (EDUKE32_PREDICT_FALSE(g_parsingEventPtr == NULL && g_processingState == 0)) if (EDUKE32_PREDICT_FALSE(!g_parsingEventPtr && g_processingState == 0))
{ {
C_ReportError(ERROR_EVENTONLY); C_ReportError(ERROR_EVENTONLY);
g_numCompilerErrors++; g_numCompilerErrors++;
@ -4678,7 +4668,7 @@ DO_DEFSTATE:
case CON_MYOSPAL: case CON_MYOSPAL:
case CON_MYOSX: case CON_MYOSX:
case CON_MYOSPALX: case CON_MYOSPALX:
if (EDUKE32_PREDICT_FALSE(g_parsingEventPtr == NULL && g_processingState == 0)) if (EDUKE32_PREDICT_FALSE(!g_parsingEventPtr && g_processingState == 0))
{ {
C_ReportError(ERROR_EVENTONLY); C_ReportError(ERROR_EVENTONLY);
g_numCompilerErrors++; g_numCompilerErrors++;
@ -5758,7 +5748,7 @@ repeatcase:
case CON_ENDEVENT: case CON_ENDEVENT:
if (EDUKE32_PREDICT_FALSE(g_parsingEventPtr == NULL)) if (EDUKE32_PREDICT_FALSE(!g_parsingEventPtr))
{ {
C_ReportError(-1); C_ReportError(-1);
initprintf("%s:%d: error: found `endevent' without open `onevent'.\n",g_szScriptFileName,g_lineNumber); initprintf("%s:%d: error: found `endevent' without open `onevent'.\n",g_szScriptFileName,g_lineNumber);
@ -5775,48 +5765,46 @@ repeatcase:
g_numCompilerErrors++; g_numCompilerErrors++;
} }
// if event has already been declared then put a jump in instead // if event has already been declared then put a jump in instead
if (EDUKE32_PREDICT_FALSE((intptr_t)previous_event)) if (previous_event)
{ {
intptr_t const destination = previous_event - script;
g_scriptPtr--; g_scriptPtr--;
*(g_scriptPtr++) = CON_JUMP; *(g_scriptPtr++) = CON_JUMP | (g_lineNumber << 12);
*(g_scriptPtr++) = MAXGAMEVARS; *(g_scriptPtr++) = MAXGAMEVARS;
*(g_scriptPtr++) = destination; *(g_scriptPtr++) = previous_event;
*(g_scriptPtr++) = CON_ENDEVENT; *(g_scriptPtr++) = CON_ENDEVENT | (g_lineNumber << 12);
previous_event = NULL;
C_FillEventBreakStackWithJump(g_parsingEventBreakPtr, destination); C_FillEventBreakStackWithJump((intptr_t *)g_parsingEventBreakPtr, previous_event);
previous_event = 0;
} }
else else
{ {
// pad space for the next potential appendevent // pad space for the next potential appendevent
apScriptGameEventEnd[g_currentEvent] = g_scriptPtr-1; apScriptGameEventEnd[g_currentEvent] = (g_scriptPtr-1)-script;
g_parsingEventPtr = (intptr_t*)(g_scriptPtr - script - 1); *(g_scriptPtr++) = CON_ENDEVENT | (g_lineNumber << 12);
*(g_scriptPtr++) = CON_ENDEVENT; *(g_scriptPtr++) = g_parsingEventBreakPtr;
*(g_scriptPtr++) = (intptr_t)g_parsingEventBreakPtr; *(g_scriptPtr++) = CON_ENDEVENT | (g_lineNumber << 12);
*(g_scriptPtr++) = CON_ENDEVENT;
} }
g_parsingEventBreakPtr = g_parsingEventPtr = g_parsingActorPtr = NULL; g_parsingEventBreakPtr = g_parsingEventPtr = g_parsingActorPtr = 0;
g_currentEvent = -1; g_currentEvent = -1;
Bsprintf(g_szCurrentBlockName,"(none)"); Bsprintf(g_szCurrentBlockName,"(none)");
continue; continue;
case CON_ENDA: case CON_ENDA:
if (EDUKE32_PREDICT_FALSE(g_parsingActorPtr == NULL || g_parsingEventPtr)) if (EDUKE32_PREDICT_FALSE(!g_parsingActorPtr || g_parsingEventPtr))
{ {
C_ReportError(-1); C_ReportError(-1);
initprintf("%s:%d: error: found `enda' without open `actor'.\n",g_szScriptFileName,g_lineNumber); initprintf("%s:%d: error: found `enda' without open `actor'.\n",g_szScriptFileName,g_lineNumber);
g_numCompilerErrors++; g_numCompilerErrors++;
g_parsingEventPtr = NULL; g_parsingEventPtr = 0;
} }
if (EDUKE32_PREDICT_FALSE(g_numBraces != 0)) if (EDUKE32_PREDICT_FALSE(g_numBraces != 0))
{ {
C_ReportError(g_numBraces > 0 ? ERROR_OPENBRACKET : ERROR_CLOSEBRACKET); C_ReportError(g_numBraces > 0 ? ERROR_OPENBRACKET : ERROR_CLOSEBRACKET);
g_numCompilerErrors++; g_numCompilerErrors++;
} }
g_parsingActorPtr = NULL; g_parsingActorPtr = 0;
Bsprintf(g_szCurrentBlockName,"(none)"); Bsprintf(g_szCurrentBlockName,"(none)");
continue; continue;
@ -5837,10 +5825,10 @@ repeatcase:
else if (g_parsingEventPtr) else if (g_parsingEventPtr)
{ {
g_scriptPtr--; g_scriptPtr--;
*(g_scriptPtr++) = CON_JUMP; *(g_scriptPtr++) = CON_JUMP | (g_lineNumber << 12);
*(g_scriptPtr++) = MAXGAMEVARS; *(g_scriptPtr++) = MAXGAMEVARS;
*g_scriptPtr = (intptr_t)g_parsingEventBreakPtr; *g_scriptPtr = g_parsingEventBreakPtr;
g_parsingEventBreakPtr = g_scriptPtr++; g_parsingEventBreakPtr = g_scriptPtr++ - script;
} }
continue; continue;
@ -6137,6 +6125,7 @@ void C_Compile(const char *filenam)
int32_t i; int32_t i;
Bmemset(apScriptGameEvent, 0, sizeof(apScriptGameEvent)); Bmemset(apScriptGameEvent, 0, sizeof(apScriptGameEvent));
Bmemset(apScriptGameEventEnd, 0, sizeof(apScriptGameEventEnd));
for (i=MAXTILES-1; i>=0; i--) for (i=MAXTILES-1; i>=0; i--)
Bmemset(&g_tile[i], 0, sizeof(tiledata_t)); Bmemset(&g_tile[i], 0, sizeof(tiledata_t));
@ -6259,14 +6248,15 @@ void C_Compile(const char *filenam)
{ {
for (i = 0; i < MAXEVENTS; ++i) for (i = 0; i < MAXEVENTS; ++i)
{ {
intptr_t *eventEnd = apScriptGameEventEnd[i]; intptr_t *eventEnd = script + apScriptGameEventEnd[i];
if (eventEnd) if (eventEnd)
{ {
// C_FillEventBreakStackWithEndEvent // C_FillEventBreakStackWithEndEvent
intptr_t *breakPtr = (intptr_t*)*(eventEnd + 2); intptr_t *breakPtr = (intptr_t*)*(eventEnd + 2);
while (breakPtr) while (breakPtr)
{ {
*(breakPtr-2) = CON_ENDEVENT; breakPtr = script + (intptr_t)breakPtr;
*(breakPtr-2) = CON_ENDEVENT | (g_lineNumber << 12);
breakPtr = (intptr_t*)*breakPtr; breakPtr = (intptr_t*)*breakPtr;
} }
} }

View file

@ -79,8 +79,7 @@ enum QuickStructureAccess_t {
extern int32_t g_iStructVarIDs; extern int32_t g_iStructVarIDs;
extern intptr_t *apScriptGameEvent[MAXGAMEEVENTS]; extern intptr_t apScriptGameEvent[MAXGAMEEVENTS];
extern intptr_t *apScriptGameEventEnd[MAXGAMEEVENTS];
#endif #endif
extern int32_t otherp; extern int32_t otherp;

View file

@ -139,8 +139,7 @@ static void VM_DeleteSprite(int32_t iActor, int32_t iPlayer)
A_DeleteSprite(iActor); A_DeleteSprite(iActor);
} }
intptr_t *apScriptGameEvent[MAXGAMEEVENTS]; intptr_t apScriptGameEvent[MAXGAMEEVENTS];
intptr_t *apScriptGameEventEnd[MAXGAMEEVENTS];
// May recurse, e.g. through EVENT_XXX -> ... -> EVENT_KILLIT // May recurse, e.g. through EVENT_XXX -> ... -> EVENT_KILLIT
#ifdef LUNATIC #ifdef LUNATIC
@ -182,7 +181,7 @@ FORCE_INLINE int32_t VM_EventCommon_(const int32_t iEventID, const int32_t iActo
g_currentEventExec = iEventID; g_currentEventExec = iEventID;
intptr_t const *oinsptr = insptr; intptr_t const *oinsptr = insptr;
insptr = apScriptGameEvent[iEventID]; insptr = script + apScriptGameEvent[iEventID];
const vmstate_t vm_backup = vm; const vmstate_t vm_backup = vm;
vm = tempvm; vm = tempvm;

View file

@ -66,7 +66,7 @@ static inline int32_t VM_HaveEvent(int32_t iEventID)
#ifdef LUNATIC #ifdef LUNATIC
return L_IsInitialized(&g_ElState) && El_HaveEvent(iEventID); return L_IsInitialized(&g_ElState) && El_HaveEvent(iEventID);
#else #else
return apScriptGameEvent[iEventID]!=NULL; return !!apScriptGameEvent[iEventID];
#endif #endif
} }

View file

@ -202,7 +202,6 @@ int32_t Gv_ReadSave(int32_t fil, int32_t newbehav)
// Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__); // Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__);
// AddLog(g_szBuf); // AddLog(g_szBuf);
if (kdfread(apScriptGameEvent,sizeof(apScriptGameEvent),1,fil) != 1) goto corrupt; if (kdfread(apScriptGameEvent,sizeof(apScriptGameEvent),1,fil) != 1) goto corrupt;
G_Util_PtrToIdx(apScriptGameEvent, MAXGAMEEVENTS, script, P2I_BACK_NON0);
// Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__); // Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__);
// AddLog(g_szBuf); // AddLog(g_szBuf);
@ -317,9 +316,7 @@ void Gv_WriteSave(FILE *fil, int32_t newbehav)
dfwrite(aGameArrays[i].plValues, GAR_ELTSZ * aGameArrays[i].size, 1, fil); dfwrite(aGameArrays[i].plValues, GAR_ELTSZ * aGameArrays[i].size, 1, fil);
} }
G_Util_PtrToIdx(apScriptGameEvent, MAXGAMEEVENTS, script, P2I_FWD_NON0);
dfwrite(apScriptGameEvent,sizeof(apScriptGameEvent),1,fil); dfwrite(apScriptGameEvent,sizeof(apScriptGameEvent),1,fil);
G_Util_PtrToIdx(apScriptGameEvent, MAXGAMEEVENTS, script, P2I_BACK_NON0);
for (int i=0; i<(MAXVOLUMES*MAXLEVELS); i++) for (int i=0; i<(MAXVOLUMES*MAXLEVELS); i++)
if (MapInfo[i].savedstate != NULL) if (MapInfo[i].savedstate != NULL)

View file

@ -117,7 +117,6 @@ G_EXTERN int32_t playerswhenstarted;
G_EXTERN int32_t screenpeek; G_EXTERN int32_t screenpeek;
G_EXTERN int32_t startofdynamicinterpolations; G_EXTERN int32_t startofdynamicinterpolations;
G_EXTERN int32_t ototalclock; G_EXTERN int32_t ototalclock;
G_EXTERN intptr_t *g_parsingActorPtr;
G_EXTERN intptr_t *g_scriptPtr; G_EXTERN intptr_t *g_scriptPtr;
G_EXTERN int32_t *labelcode,*labeltype; G_EXTERN int32_t *labelcode,*labeltype;
G_EXTERN intptr_t *script; G_EXTERN intptr_t *script;