From: TimePath Date: Sat, 12 Dec 2015 07:05:14 +0000 (+1100) Subject: assert_once X-Git-Tag: xonotic-v0.8.2~1503 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d8ae277d6bc59894ee3db414307854a1c803d849;p=xonotic%2Fxonotic-data.pk3dir.git assert_once --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 576b2485c..79723cc3c 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -167,7 +167,7 @@ void Shutdown() .float has_team; float SetTeam(entity o, int Team) { - assert(Team); + assert_once(Team); entity tm; if(teamplay) { diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index d488dd63b..b7962d52d 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -79,7 +79,7 @@ void MoveToLast(entity e) float RegisterTeam(entity Team) { - assert(Team.team, eprint(Team)); + assert_once(Team.team, eprint(Team)); entity tm; AuditLists(); for(tm = teams.sort_next; tm; tm = tm.sort_next) diff --git a/qcsrc/lib/log.qh b/qcsrc/lib/log.qh index 60f8d103d..ab94e571b 100644 --- a/qcsrc/lib/log.qh +++ b/qcsrc/lib/log.qh @@ -12,6 +12,15 @@ } MACRO_END #define assert(expr, ...) _assert(LOG_SEVERE, expr, __VA_ARGS__) +#define assert_once(expr, ...) \ + MACRO_BEGIN { \ + static bool __once; \ + if (!__once) \ + { \ + assert(expr, __VA_ARGS__); \ + __once = true; \ + } \ + } MACRO_END #define demand(expr, ...) _assert(LOG_FATAL, expr, __VA_ARGS__) #define _assert(f, expr, then) \ MACRO_BEGIN \