]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Remove usage of "frame" event (improves performance, hopefully fixes PL)
authorMario <zacjardine@y7mail.com>
Wed, 7 Oct 2015 07:31:48 +0000 (17:31 +1000)
committerMario <zacjardine@y7mail.com>
Wed, 7 Oct 2015 07:31:48 +0000 (17:31 +1000)
qcsrc/common/minigames/minigame/snake.qc
qcsrc/common/minigames/sv_minigames.qc

index c7bf6ae59b8c1db0a1572d00c2ef96c6705df5bc..bef26caaa53cbc8ad2489b5604081470e47a384b 100644 (file)
@@ -74,6 +74,17 @@ void snake_new_mouse(entity minigame)
        minigame_server_sendflags(minigame,MINIG_SF_UPDATE);
 }
 
+void snake_move_head(entity minigame);
+void snake_head_think()
+{
+       entity minigame = self.owner;
+
+       if(minigame.minigame_flags & SNAKE_TURN_MOVE)
+               snake_move_head(minigame);
+
+       self.nextthink = time + minigame.snake_delay;
+}
+
 void snake_setup_pieces(entity minigame)
 {
        int targnum = bound(1, floor(random() * SNAKE_NUM_CNT), SNAKE_NUM_CNT - 1);
@@ -83,6 +94,8 @@ void snake_setup_pieces(entity minigame)
        piece.team = 1; // init default team?
        piece.netname = strzone(minigame_tile_buildname(targlet,targnum));
        piece.cnt = 1;
+       piece.think = snake_head_think;
+       piece.nextthink = time + 0.1;
        minigame_server_sendflags(piece,MINIG_SF_ALL);
 
        minigame.snake_head = piece;
@@ -275,16 +288,6 @@ int snake_server_event(entity minigame, string event, ...)
                        // Team 1 by default
                        return 1;
                }
-               case "frame":
-               {
-                       if(minigame.minigame_flags & SNAKE_TURN_MOVE)
-                       if(time >= minigame.snake_nextmove)
-                       {
-                               snake_move_head(minigame);
-                               minigame.snake_nextmove = time + minigame.snake_delay;
-                       }
-                       return false;
-               }
                case "cmd":
                {
                        switch(argv(0))
index c06e23c9c7961cd5c09e11797e3ee262504381e5..0f02e2b5819407d14f3b705df99a8aa2f86d8704 100644 (file)
@@ -163,14 +163,6 @@ int minigame_addplayer(entity minigame_session, entity player)
        return mgteam;
 }
 
-void minigame_frame()
-{
-       entity minig = self;
-
-       minig.minigame_event(minig,"frame");
-       minig.nextthink = time + 0.1;
-}
-
 entity start_minigame(entity player, string minigame )
 {
        if ( !autocvar_sv_minigames || !IS_REAL_CLIENT(player) )
@@ -183,8 +175,6 @@ entity start_minigame(entity player, string minigame )
                minig.classname = "minigame";
                minig.netname = strzone(strcat(e.netname,"_",ftos(num_for_edict(minig))));
                minig.descriptor = e;
-               minig.think = minigame_frame;
-               minig.nextthink = time;
                minig.minigame_event = e.minigame_event;
                minig.minigame_event(minig,"start");
                GameLogEcho(strcat(":minigame:start:",minig.netname));