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
This commit is contained in:
helixhorned 2011-07-29 22:07:28 +00:00
parent e9b15edd25
commit 864cc11463
3 changed files with 59 additions and 132 deletions

View file

@ -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(&sector[sprite[k].sectnum].floorz);
break;
case 32:
G_SetInterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case 25:
G_SetInterpolation(&sector[sprite[k].sectnum].floorz);
G_SetInterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case 17:
G_SetInterpolation(&sector[sprite[k].sectnum].floorz);
G_SetInterpolation(&sector[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();

View file

@ -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

View file

@ -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(&sector[sprite[k].sectnum].floorz);
break;
case 32:
G_SetInterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case 25:
G_SetInterpolation(&sector[sprite[k].sectnum].floorz);
G_SetInterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case 17:
G_SetInterpolation(&sector[sprite[k].sectnum].floorz);
G_SetInterpolation(&sector[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(&sector[sprite[k].sectnum].floorz);
break;
case 32:
G_SetInterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case 25:
G_SetInterpolation(&sector[sprite[k].sectnum].floorz);
G_SetInterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case 17:
G_SetInterpolation(&sector[sprite[k].sectnum].floorz);
G_SetInterpolation(&sector[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(&sector[sprite[i].sectnum].floorz);
break;
case 32:
G_SetInterpolation(&sector[sprite[i].sectnum].ceilingz);
break;
case 25:
G_SetInterpolation(&sector[sprite[i].sectnum].floorz);
G_SetInterpolation(&sector[sprite[i].sectnum].ceilingz);
break;
case 17:
G_SetInterpolation(&sector[sprite[i].sectnum].floorz);
G_SetInterpolation(&sector[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;