From 864cc11463a50f718259484708673e2ced4b29ce Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 29 Jul 2011 22:07:28 +0000 Subject: [PATCH] maint 1: refactor 3 redundant instances of the same code into G_ResetInterpolations() git-svn-id: https://svn.eduke32.com/eduke32@1949 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/gameexec.c | 55 ++---------- polymer/eduke32/source/premap.h | 1 + polymer/eduke32/source/savegame.c | 135 +++++++++++------------------- 3 files changed, 59 insertions(+), 132 deletions(-) diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 4563c63d5..121380a04 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -4783,11 +4783,11 @@ nullquote: continue; case CON_JUMP: - insptr++; - { - int32_t j = Gv_GetVarX(*insptr++); - insptr = (intptr_t *)(j+script); - } + insptr++; + { + int32_t j = Gv_GetVarX(*insptr++); + insptr = (intptr_t *)(j+script); + } continue; default: @@ -5066,7 +5066,7 @@ void G_RestoreMapState(mapstate_t *save) { if (save != NULL) { - int32_t i, k, x; + int32_t i, x; intptr_t j; char phealth[MAXPLAYERS]; @@ -5181,48 +5181,7 @@ void G_RestoreMapState(mapstate_t *save) } } - // TODO: sync with TROR special interpolations? (e.g. upper floor of subway) - g_numInterpolations = 0; - startofdynamicinterpolations = 0; - - k = headspritestat[STAT_EFFECTOR]; - while (k >= 0) - { - switch (sprite[k].lotag) - { - case 31: - G_SetInterpolation(§or[sprite[k].sectnum].floorz); - break; - case 32: - G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); - break; - case 25: - G_SetInterpolation(§or[sprite[k].sectnum].floorz); - G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); - break; - case 17: - G_SetInterpolation(§or[sprite[k].sectnum].floorz); - G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); - break; - case 0: - case 5: - case 6: - case 11: - case 14: - case 15: - case 16: - case 26: - case 30: - Sect_SetInterpolation(sprite[k].sectnum); - break; - } - - k = nextspritestat[k]; - } - - for (i=g_numInterpolations-1; i>=0; i--) bakipos[i] = *curipos[i]; - for (i = g_animateCount-1; i>=0; i--) - G_SetInterpolation(animateptr[i]); + G_ResetInterpolations(); Net_ResetPrediction(); diff --git a/polymer/eduke32/source/premap.h b/polymer/eduke32/source/premap.h index 0b45aee1d..e75fe3ede 100644 --- a/polymer/eduke32/source/premap.h +++ b/polymer/eduke32/source/premap.h @@ -47,5 +47,6 @@ void P_ResetStatus(int32_t snum); void P_ResetWeapons(int32_t snum); void G_ClearFIFO(void); void G_SetupCamTile(int32_t i,int32_t wn); +void G_ResetInterpolations(void); #endif diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index 2cff0c7a8..799debefd 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -30,6 +30,54 @@ extern char *bitptr; #define BITPTR_POINTER 1 +// TODO: sync with TROR special interpolations? (e.g. upper floor of subway) +void G_ResetInterpolations(void) +{ + int32_t k, i; + + g_numInterpolations = 0; + startofdynamicinterpolations = 0; + + k = headspritestat[STAT_EFFECTOR]; + while (k >= 0) + { + switch (sprite[k].lotag) + { + case 31: + G_SetInterpolation(§or[sprite[k].sectnum].floorz); + break; + case 32: + G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); + break; + case 25: + G_SetInterpolation(§or[sprite[k].sectnum].floorz); + G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); + break; + case 17: + G_SetInterpolation(§or[sprite[k].sectnum].floorz); + G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); + break; + case 0: + case 5: + case 6: + case 11: + case 14: + case 15: + case 16: + case 26: + case 30: + Sect_SetInterpolation(sprite[k].sectnum); + break; + } + + k = nextspritestat[k]; + } + + for (i=g_numInterpolations-1; i>=0; i--) bakipos[i] = *curipos[i]; + for (i = g_animateCount-1; i>=0; i--) + G_SetInterpolation(animateptr[i]); +} + void ReadSaveGameHeaders(void) { int32_t dummy,j; @@ -128,7 +176,6 @@ corrupt: int32_t G_LoadPlayer(int32_t spot) { - int32_t k; char fn[13]; char mpfn[13]; char *fnptr, *scriptptrs; @@ -304,7 +351,7 @@ int32_t G_LoadPlayer(int32_t spot) if (kdfread(&g_scriptSize,sizeof(g_scriptSize),1,fil) != 1) goto corrupt; if (!g_scriptSize) goto corrupt; -// scriptptrs = Bcalloc(1,g_scriptSize * sizeof(scriptptrs)); + Bfree(bitptr); bitptr = Bcalloc(1,(((g_scriptSize+7)>>3)+1) * sizeof(uint8_t)); if (kdfread(&bitptr[0],sizeof(uint8_t),(g_scriptSize+7)>>3,fil) != ((g_scriptSize+7)>>3)) goto corrupt; @@ -554,47 +601,7 @@ int32_t G_LoadPlayer(int32_t spot) } } - g_numInterpolations = 0; - startofdynamicinterpolations = 0; - - k = headspritestat[STAT_EFFECTOR]; - while (k >= 0) - { - switch (sprite[k].lotag) - { - case 31: - G_SetInterpolation(§or[sprite[k].sectnum].floorz); - break; - case 32: - G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); - break; - case 25: - G_SetInterpolation(§or[sprite[k].sectnum].floorz); - G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); - break; - case 17: - G_SetInterpolation(§or[sprite[k].sectnum].floorz); - G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); - break; - case 0: - case 5: - case 6: - case 11: - case 14: - case 15: - case 16: - case 26: - case 30: - Sect_SetInterpolation(sprite[k].sectnum); - break; - } - - k = nextspritestat[k]; - } - - for (i=g_numInterpolations-1; i>=0; i--) bakipos[i] = *curipos[i]; - for (i = g_animateCount-1; i>=0; i--) - G_SetInterpolation(animateptr[i]); + G_ResetInterpolations(); g_showShareware = 0; everyothertime = 0; @@ -2258,47 +2265,7 @@ static void postloadplayer1() #endif //5 - g_numInterpolations = 0; - startofdynamicinterpolations = 0; - - i = headspritestat[STAT_EFFECTOR]; - while (i >= 0) - { - switch (sprite[i].lotag) - { - case 31: - G_SetInterpolation(§or[sprite[i].sectnum].floorz); - break; - case 32: - G_SetInterpolation(§or[sprite[i].sectnum].ceilingz); - break; - case 25: - G_SetInterpolation(§or[sprite[i].sectnum].floorz); - G_SetInterpolation(§or[sprite[i].sectnum].ceilingz); - break; - case 17: - G_SetInterpolation(§or[sprite[i].sectnum].floorz); - G_SetInterpolation(§or[sprite[i].sectnum].ceilingz); - break; - case 0: - case 5: - case 6: - case 11: - case 14: - case 15: - case 16: - case 26: - case 30: - Sect_SetInterpolation(sprite[i].sectnum); - break; - } - - i = nextspritestat[i]; - } - - for (i=g_numInterpolations-1; i>=0; i--) bakipos[i] = *curipos[i]; - for (i = g_animateCount-1; i>=0; i--) - G_SetInterpolation(animateptr[i]); + G_ResetInterpolations(); //6 g_showShareware = 0;