Refactor C code related to gettimedate and sect*interpolation CON commands.

No functional changes.

git-svn-id: https://svn.eduke32.com/eduke32@3486 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-02-16 18:53:00 +00:00
parent 5e84185d6e
commit 6816afe07e
3 changed files with 60 additions and 42 deletions

View file

@ -36,16 +36,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern int32_t g_numEnvSoundsPlaying; extern int32_t g_numEnvSoundsPlaying;
extern int32_t g_noEnemies; extern int32_t g_noEnemies;
void G_SetInterpolation(int32_t *posptr) int32_t G_SetInterpolation(int32_t *posptr)
{ {
int32_t i=g_numInterpolations-1; int32_t i=g_numInterpolations-1;
if (g_numInterpolations >= MAXINTERPOLATIONS) return; if (g_numInterpolations >= MAXINTERPOLATIONS)
return 1;
for (; i>=0; i--) for (; i>=0; i--)
if (curipos[i] == posptr) return; if (curipos[i] == posptr)
return 0;
curipos[g_numInterpolations] = posptr; curipos[g_numInterpolations] = posptr;
oldipos[g_numInterpolations] = *posptr; oldipos[g_numInterpolations] = *posptr;
g_numInterpolations++; g_numInterpolations++;
return 0;
} }
void G_StopInterpolation(int32_t *posptr) void G_StopInterpolation(int32_t *posptr)
@ -594,44 +599,47 @@ void A_DoGutsDir(int32_t sp, int32_t gtype, int32_t n)
} }
} }
void Sect_SetInterpolation(int32_t sectnum) // NOTE: external linkage for Lunatic
int32_t G_ToggleWallInterpolation(int32_t w, int32_t doset)
{
if (doset)
{
return G_SetInterpolation(&wall[w].x)
|| G_SetInterpolation(&wall[w].y);
}
else
{
G_StopInterpolation(&wall[w].x);
G_StopInterpolation(&wall[w].y);
return 0;
}
}
static void Sect_ToggleInterpolation(int32_t sectnum, int32_t doset)
{ {
int32_t k, j = sector[sectnum].wallptr, endwall = j+sector[sectnum].wallnum; int32_t k, j = sector[sectnum].wallptr, endwall = j+sector[sectnum].wallnum;
for (; j<endwall; j++) for (; j<endwall; j++)
{ {
G_SetInterpolation(&wall[j].x); G_ToggleWallInterpolation(j, doset);
G_SetInterpolation(&wall[j].y);
k = wall[j].nextwall; k = wall[j].nextwall;
if (k >= 0) if (k >= 0)
{ {
G_SetInterpolation(&wall[k].x); G_ToggleWallInterpolation(k, doset);
G_SetInterpolation(&wall[k].y); G_ToggleWallInterpolation(wall[k].point2, doset);
k = wall[k].point2;
G_SetInterpolation(&wall[k].x);
G_SetInterpolation(&wall[k].y);
} }
} }
} }
void Sect_SetInterpolation(int32_t sectnum)
{
Sect_ToggleInterpolation(sectnum, 1);
}
void Sect_ClearInterpolation(int32_t sectnum) void Sect_ClearInterpolation(int32_t sectnum)
{ {
int32_t k, j = sector[sectnum].wallptr, endwall = j+sector[sectnum].wallnum; Sect_ToggleInterpolation(sectnum, 0);
for (; j<endwall; j++)
{
G_StopInterpolation(&wall[j].x);
G_StopInterpolation(&wall[j].y);
k = wall[j].nextwall;
if (k >= 0)
{
G_StopInterpolation(&wall[k].x);
G_StopInterpolation(&wall[k].y);
k = wall[k].point2;
G_StopInterpolation(&wall[k].x);
G_StopInterpolation(&wall[k].y);
}
}
} }
static int32_t move_rotfixed_sprite(int32_t j, int32_t pivotspr, int32_t daang) static int32_t move_rotfixed_sprite(int32_t j, int32_t pivotspr, int32_t daang)

View file

@ -275,7 +275,7 @@ void G_AddGameLight(int32_t radius,int32_t srcsprite,int32_t zoff
void G_ClearCameraView(DukePlayer_t *ps); void G_ClearCameraView(DukePlayer_t *ps);
void G_DoInterpolations(int32_t smoothratio); void G_DoInterpolations(int32_t smoothratio);
void G_MoveWorld(void); void G_MoveWorld(void);
void G_SetInterpolation(int32_t *posptr); int32_t G_SetInterpolation(int32_t *posptr);
void G_StopInterpolation(int32_t *posptr); void G_StopInterpolation(int32_t *posptr);
// PK 20110701: changed input argument: int32_t i (== sprite, whose sectnum...) --> sectnum directly // PK 20110701: changed input argument: int32_t i (== sprite, whose sectnum...) --> sectnum directly

View file

@ -968,6 +968,25 @@ static int32_t VM_ResetPlayer(int32_t g_p, int32_t g_flags)
return g_flags; return g_flags;
} }
void G_GetTimeDate(int32_t *vals)
{
time_t rawtime;
struct tm *ti;
time(&rawtime);
ti=localtime(&rawtime);
// initprintf("Time&date: %s\n",asctime (ti));
vals[0] = ti->tm_sec;
vals[1] = ti->tm_min;
vals[2] = ti->tm_hour;
vals[3] = ti->tm_mday;
vals[4] = ti->tm_mon;
vals[5] = ti->tm_year+1900;
vals[6] = ti->tm_wday;
vals[7] = ti->tm_yday;
}
#if !defined LUNATIC #if !defined LUNATIC
GAMEEXEC_STATIC void VM_Execute(int32_t loop) GAMEEXEC_STATIC void VM_Execute(int32_t loop)
{ {
@ -2891,22 +2910,13 @@ nullquote:
case CON_GETTIMEDATE: case CON_GETTIMEDATE:
insptr++; insptr++;
{ {
int32_t v1=*insptr++,v2=*insptr++,v3=*insptr++,v4=*insptr++,v5=*insptr++,v6=*insptr++,v7=*insptr++,v8=*insptr++; int32_t i, vals[8];
time_t rawtime;
struct tm *ti;
time(&rawtime); G_GetTimeDate(vals);
ti=localtime(&rawtime);
// initprintf("Time&date: %s\n",asctime (ti)); for (i=0; i<8; i++)
Gv_SetVarX(*insptr++, vals[i]);
Gv_SetVarX(v1, ti->tm_sec);
Gv_SetVarX(v2, ti->tm_min);
Gv_SetVarX(v3, ti->tm_hour);
Gv_SetVarX(v4, ti->tm_mday);
Gv_SetVarX(v5, ti->tm_mon);
Gv_SetVarX(v6, ti->tm_year+1900);
Gv_SetVarX(v7, ti->tm_wday);
Gv_SetVarX(v8, ti->tm_yday);
continue; continue;
} }