From 8bd529bdaff3a9aadc4cc76de682d5082d58495a Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 7 Oct 2015 17:31:48 +1000 Subject: [PATCH] Remove usage of "frame" event (improves performance, hopefully fixes PL) --- qcsrc/common/minigames/minigame/snake.qc | 23 +++++++++++++---------- qcsrc/common/minigames/sv_minigames.qc | 10 ---------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/qcsrc/common/minigames/minigame/snake.qc b/qcsrc/common/minigames/minigame/snake.qc index c7bf6ae59..bef26caaa 100644 --- a/qcsrc/common/minigames/minigame/snake.qc +++ b/qcsrc/common/minigames/minigame/snake.qc @@ -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)) diff --git a/qcsrc/common/minigames/sv_minigames.qc b/qcsrc/common/minigames/sv_minigames.qc index c06e23c9c..0f02e2b58 100644 --- a/qcsrc/common/minigames/sv_minigames.qc +++ b/qcsrc/common/minigames/sv_minigames.qc @@ -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)); -- 2.39.2