]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
assert_once
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 12 Dec 2015 07:05:14 +0000 (18:05 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 12 Dec 2015 07:06:19 +0000 (18:06 +1100)
qcsrc/client/main.qc
qcsrc/client/miscfunctions.qc
qcsrc/lib/log.qh

index 576b2485c5e1ced62fea02d1cf5777f6fa9c3644..79723cc3c2e3dd4b300c7ec14e734b3155a4ce79 100644 (file)
@@ -167,7 +167,7 @@ void Shutdown()
 .float has_team;
 float SetTeam(entity o, int Team)
 {
-       assert(Team);
+       assert_once(Team);
        entity tm;
        if(teamplay)
        {
index d488dd63b537a9170bbcea295e46ff19033472f7..b7962d52d5fb73e42cc2f8e802b9d016f6027565 100644 (file)
@@ -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)
index 60f8d103dc381ff3a69ad652ccd8630b081ffd32..ab94e571bc004fc1c79c054efe2cff1caf94ef6b 100644 (file)
        } 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 \