From e447ef04ccb5cde55c49a8d0dd62c87619048251 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Fri, 19 Dec 2008 11:41:17 +0000 Subject: [PATCH] fixed so that events isn't processed when scrubbing a demo --- src/game/client/components/menus_demo.cpp | 2 ++ src/game/client/gameclient.cpp | 18 +++++++++++++++--- src/game/client/gameclient.hpp | 2 ++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index a8ed01772..08db31622 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -91,7 +91,9 @@ void MENUS::render_demoplayer(RECT main_view) if(amount > 0 && amount < 1.0f) { gameclient.on_reset(); + gameclient.suppress_events = true; client_demoplayer_setpos(amount); + gameclient.suppress_events = false; } } } diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 11b26053e..c21c4ff99 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -160,6 +160,9 @@ void GAMECLIENT::on_console_init() // let all the other components register their console commands for(int i = 0; i < all.num; i++) all.components[i]->on_console_init(); + + // + suppress_events = false; } void GAMECLIENT::on_init() @@ -443,6 +446,9 @@ void GAMECLIENT::on_statechange(int new_state, int old_state) void GAMECLIENT::process_events() { + if(suppress_events) + return; + int snaptype = SNAP_CURRENT; int num = snap_num_items(snaptype); for(int index = 0; index < num; index++) @@ -514,11 +520,17 @@ void GAMECLIENT::on_snapshot() if(config.dbg_stress) { - if((client_tick()%250) == 0) + if((client_tick()%100) == 0) { + char message[64]; + int msglen = rand()%(sizeof(message)-1); + for(int i = 0; i < msglen; i++) + message[i] = 'a'+(rand()%('z'-'a')); + message[msglen] = 0; + NETMSG_CL_SAY msg; - msg.team = -1; - msg.message = "galenskap!!!!"; + msg.team = rand()&1; + msg.message = message; msg.pack(MSGFLAG_VITAL); client_send_msg(); } diff --git a/src/game/client/gameclient.hpp b/src/game/client/gameclient.hpp index d4c8510aa..e470dc099 100644 --- a/src/game/client/gameclient.hpp +++ b/src/game/client/gameclient.hpp @@ -23,6 +23,7 @@ class GAMECLIENT STACK all; STACK input; + void dispatch_input(); void process_events(); void update_local_character_pos(); @@ -34,6 +35,7 @@ class GAMECLIENT static void con_kill(void *result, void *user_data); public: + bool suppress_events; // TODO: move this TUNING_PARAMS tuning;