mirror of
https://github.com/EnergyMech/energymech.git
synced 2025-12-17 23:47:14 +00:00
reduce calls to trivia_tick
This commit is contained in:
parent
0b713ea5e4
commit
f7c9703d2d
@ -254,6 +254,7 @@ BEG int triv_qdelay MDEF(30); /* proc var */
|
|||||||
BEG char *triv_qfile MDEF(NULL); /* proc var */
|
BEG char *triv_qfile MDEF(NULL); /* proc var */
|
||||||
BEG char triv_qchar MDEF('*'); /* proc var */
|
BEG char triv_qchar MDEF('*'); /* proc var */
|
||||||
BEG TrivScore *scorelist MDEF(NULL);
|
BEG TrivScore *scorelist MDEF(NULL);
|
||||||
|
BEG time_t triv_next_time MDEF(0);
|
||||||
|
|
||||||
#endif /* TRIVIA */
|
#endif /* TRIVIA */
|
||||||
|
|
||||||
|
|||||||
4
src/h.h
4
src/h.h
@ -407,11 +407,11 @@ LS void do_sigusr1(void) __page(CMD1_SEG);
|
|||||||
LS void sig_usr1(int) __page(CMD1_SEG);
|
LS void sig_usr1(int) __page(CMD1_SEG);
|
||||||
LS void sig_usr2(int) __page(DBUG_SEG); /* DEBUG */
|
LS void sig_usr2(int) __page(DBUG_SEG); /* DEBUG */
|
||||||
LS void sig_suicide() __attr(RARE_SEG, __noreturn__); /* rare */
|
LS void sig_suicide() __attr(RARE_SEG, __noreturn__); /* rare */
|
||||||
LS void do_sigint(void) __page(RARE_SEG); /* rare */
|
LS void do_sigint(void) __attr(RARE_SEG, __noreturn__); /* rare */
|
||||||
LS void sig_int(int) __page(RARE_SEG); /* rare */
|
LS void sig_int(int) __page(RARE_SEG); /* rare */
|
||||||
LS void sig_ill(int) __page(RARE_SEG);
|
LS void sig_ill(int) __page(RARE_SEG);
|
||||||
LS void sig_abrt(int) __page(RARE_SEG);
|
LS void sig_abrt(int) __page(RARE_SEG);
|
||||||
LS void sig_bus(int) __page(CMD1_SEG);
|
LS void sig_bus(int) __attr(RARE_SEG, __noreturn__);
|
||||||
#if defined(__linux__) && defined(__x86_64__) && defined(DEBUG) && !defined(__STRICT_ANSI__)
|
#if defined(__linux__) && defined(__x86_64__) && defined(DEBUG) && !defined(__STRICT_ANSI__)
|
||||||
LS void sig_segv(int, siginfo_t *, void *) __attr(RARE_SEG, __noreturn__);
|
LS void sig_segv(int, siginfo_t *, void *) __attr(RARE_SEG, __noreturn__);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -402,20 +402,20 @@ void sig_int(int signum)
|
|||||||
* SIGILL, Illegal instruction
|
* SIGILL, Illegal instruction
|
||||||
*/
|
*/
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
void sig_ill(int crap)
|
void sig_ill(int crap)
|
||||||
{
|
{
|
||||||
debug("(sigill)\n");
|
debug("(sigill)\n");
|
||||||
}
|
}
|
||||||
#endif /* DEBUG */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SIGABRT, abort(3)
|
* SIGABRT, abort(3)
|
||||||
*/
|
*/
|
||||||
#ifdef DEBUG
|
|
||||||
void sig_abrt(int crap)
|
void sig_abrt(int crap)
|
||||||
{
|
{
|
||||||
debug("(sigabrt)\n");
|
debug("(sigabrt)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -881,7 +881,8 @@ restart_die:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TRIVIA
|
#ifdef TRIVIA
|
||||||
trivia_tick();
|
if (triv_next_time && (now >= triv_next_time))
|
||||||
|
trivia_tick();
|
||||||
#endif /* TRIVIA */
|
#endif /* TRIVIA */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
50
src/toybox.c
50
src/toybox.c
@ -50,7 +50,6 @@ LS TrivScore *lastwinner;
|
|||||||
LS Chan *triv_chan = NULL;
|
LS Chan *triv_chan = NULL;
|
||||||
LS Strp *triv_answers = NULL;
|
LS Strp *triv_answers = NULL;
|
||||||
LS time_t triv_ask_time;
|
LS time_t triv_ask_time;
|
||||||
LS time_t triv_next_time = 0;
|
|
||||||
LS time_t triv_weektop10;
|
LS time_t triv_weektop10;
|
||||||
LS int triv_mode;
|
LS int triv_mode;
|
||||||
LS int triv_score;
|
LS int triv_score;
|
||||||
@ -575,37 +574,34 @@ void trivia_tick(void)
|
|||||||
Chan *chan;
|
Chan *chan;
|
||||||
Mech *bot;
|
Mech *bot;
|
||||||
|
|
||||||
if (triv_next_time && (now >= triv_next_time))
|
for(bot=botlist;bot;bot=bot->next)
|
||||||
{
|
{
|
||||||
for(bot=botlist;bot;bot=bot->next)
|
for(chan=bot->chanlist;chan;chan=chan->next)
|
||||||
{
|
{
|
||||||
for(chan=bot->chanlist;chan;chan=chan->next)
|
if (triv_chan == chan)
|
||||||
{
|
{
|
||||||
if (triv_chan == chan)
|
current = bot;
|
||||||
|
triv_next_time = now + TRIV_HINT_DELAY;
|
||||||
|
switch(triv_mode)
|
||||||
{
|
{
|
||||||
current = bot;
|
case TRIV_WAIT_QUESTION:
|
||||||
triv_next_time = now + TRIV_HINT_DELAY;
|
trivia_question();
|
||||||
switch(triv_mode)
|
break;
|
||||||
{
|
case TRIV_HINT_TWO:
|
||||||
case TRIV_WAIT_QUESTION:
|
hint_two();
|
||||||
trivia_question();
|
break;
|
||||||
break;
|
case TRIV_HINT_THREE:
|
||||||
case TRIV_HINT_TWO:
|
hint_three();
|
||||||
hint_two();
|
break;
|
||||||
break;
|
case TRIV_NO_ANSWER:
|
||||||
case TRIV_HINT_THREE:
|
trivia_no_answer();
|
||||||
hint_three();
|
return; /* dont increment with triv_mode */
|
||||||
break;
|
|
||||||
case TRIV_NO_ANSWER:
|
|
||||||
trivia_no_answer();
|
|
||||||
return; /* dont increment with triv_mode */
|
|
||||||
}
|
|
||||||
triv_mode++;
|
|
||||||
#ifdef DEBUG
|
|
||||||
current = NULL;
|
|
||||||
#endif /* DEBUG */
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
triv_mode++;
|
||||||
|
#ifdef DEBUG
|
||||||
|
current = NULL;
|
||||||
|
#endif /* DEBUG */
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user