Factor out setting baslayer timer from game into G_InitTimer().

git-svn-id: https://svn.eduke32.com/eduke32@3485 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-02-16 18:52:56 +00:00
parent 1bdc416e5f
commit 5e84185d6e
4 changed files with 16 additions and 32 deletions

View file

@ -7561,6 +7561,16 @@ void G_SetViewportShrink(int32_t dir)
G_UpdateScreenArea(); G_UpdateScreenArea();
} }
void G_InitTimer(int32_t ticspersec)
{
if (g_timerTicsPerSecond != ticspersec)
{
uninittimer();
inittimer(ticspersec);
g_timerTicsPerSecond = ticspersec;
}
}
void G_HandleLocalKeys(void) void G_HandleLocalKeys(void)
{ {
int32_t i,ch; int32_t i,ch;
@ -7707,27 +7717,15 @@ void G_HandleLocalKeys(void)
#if 0 #if 0
if (KB_KeyPressed(sc_kpad_Plus)) if (KB_KeyPressed(sc_kpad_Plus))
{ {
if (g_timerTicsPerSecond != 240) G_InitTimer(240);
{
uninittimer();
inittimer(240);
g_timerTicsPerSecond = 240;
}
} }
else if (KB_KeyPressed(sc_kpad_Minus)) else if (KB_KeyPressed(sc_kpad_Minus))
{ {
if (g_timerTicsPerSecond != 60) G_InitTimer(60);
{
uninittimer();
inittimer(60);
g_timerTicsPerSecond = 60;
}
} }
else if (g_timerTicsPerSecond != 120) else if (g_timerTicsPerSecond != 120)
{ {
uninittimer(); G_InitTimer(120);
inittimer(120);
g_timerTicsPerSecond = 120;
} }
#endif #endif

View file

@ -321,6 +321,7 @@ void P_SetGamePalette(DukePlayer_t *player,uint8_t palid,int32_t set);
int32_t app_main(int32_t argc,const char **argv); int32_t app_main(int32_t argc,const char **argv);
void fadepal(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step); void fadepal(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step);
//void fadepaltile(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step,int32_t tile); //void fadepaltile(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step,int32_t tile);
void G_InitTimer(int32_t ticpersec);
static inline int32_t G_GetTeamPalette(int32_t team) static inline int32_t G_GetTeamPalette(int32_t team)
{ {

View file

@ -2238,15 +2238,7 @@ nullquote:
case CON_INITTIMER: case CON_INITTIMER:
insptr++; insptr++;
{ G_InitTimer(Gv_GetVarX(*insptr++));
int32_t j = Gv_GetVarX(*insptr++);
if (g_timerTicsPerSecond == j)
continue;
uninittimer();
inittimer((g_timerTicsPerSecond = j));
}
continue; continue;
case CON_TIME: case CON_TIME:

View file

@ -1158,20 +1158,13 @@ static int32_t osdcmd_restorestate(const osdfuncparm_t *parm)
#ifdef DEBUGGINGAIDS #ifdef DEBUGGINGAIDS
static int32_t osdcmd_inittimer(const osdfuncparm_t *parm) static int32_t osdcmd_inittimer(const osdfuncparm_t *parm)
{ {
int32_t j;
if (parm->numparms != 1) if (parm->numparms != 1)
{ {
OSD_Printf("%dHz timer\n",g_timerTicsPerSecond); OSD_Printf("%dHz timer\n",g_timerTicsPerSecond);
return OSDCMD_SHOWHELP; return OSDCMD_SHOWHELP;
} }
j = Batol(parm->parms[0]); G_InitTimer(Batol(parm->parms[0]));
if (g_timerTicsPerSecond == j)
return OSDCMD_OK;
uninittimer();
inittimer(j);
g_timerTicsPerSecond = j;
OSD_Printf("%s\n",parm->raw); OSD_Printf("%s\n",parm->raw);
return OSDCMD_OK; return OSDCMD_OK;