From 9726a1c7677b023f1150255b1b341b595d8a378d Mon Sep 17 00:00:00 2001 From: div0 Date: Fri, 26 Sep 2008 18:36:47 +0000 Subject: [PATCH] new vote/ready nagger display (untested, can't test this alone) fix MOTD display for spectators for now git-svn-id: svn://svn.icculus.org/nexuiz/trunk@4507 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/client/Main.qc | 22 ++++++ data/qcsrc/client/main.qh | 6 ++ data/qcsrc/client/sbar.qc | 108 +++++++++++++++------------- data/qcsrc/common/constants.qh | 4 +- data/qcsrc/server/cl_client.qc | 13 ++-- data/qcsrc/server/clientcommands.qc | 104 +++++++++++++-------------- data/qcsrc/server/defs.qh | 3 - data/qcsrc/server/g_world.qc | 2 + data/qcsrc/server/miscfunctions.qc | 10 ++- data/qcsrc/server/scores.qc | 7 -- data/qcsrc/server/teamplay.qc | 7 +- data/qcsrc/server/vote.qc | 9 +-- data/qcsrc/server/vote.qh | 1 - 13 files changed, 162 insertions(+), 134 deletions(-) diff --git a/data/qcsrc/client/Main.qc b/data/qcsrc/client/Main.qc index 2ff0371f7..8f3217413 100644 --- a/data/qcsrc/client/Main.qc +++ b/data/qcsrc/client/Main.qc @@ -444,6 +444,26 @@ void Ent_ReadTeamScore() Sbar_UpdateTeamPos(o); } +void Ent_Nagger() +{ + float nags; + string s; + + nags = ReadByte(); + + if(nags & 128) + { + if(vote_called_vote) + strunzone(vote_called_vote); + vote_called_vote = strzone(ReadString()); + } + + ready_waiting = (nags & 1); + ready_waiting_for_me = (nags & 2); + vote_waiting = (nags & 4); + vote_waiting_for_me = (nags & 8); +} + // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured. // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS. void(float bIsNewEntity) CSQC_Ent_Update = @@ -484,6 +504,8 @@ void(float bIsNewEntity) CSQC_Ent_Update = Ent_RainOrSnow(); else if(self.enttype == ENT_CLIENT_LASER) Ent_Laser(); + else if(self.enttype == ENT_CLIENT_NAGGER) + Ent_Nagger(); else error("unknown entity type in CSQC_Ent_Update\n"); diff --git a/data/qcsrc/client/main.qh b/data/qcsrc/client/main.qh index 9d06539e9..ed9291f1c 100644 --- a/data/qcsrc/client/main.qh +++ b/data/qcsrc/client/main.qh @@ -129,3 +129,9 @@ float angles_held_status[24]; string getcommandkey(string text, string command); float sbar_showbinds; float sbar_showbinds_limit; + +string vote_called_vote; +float ready_waiting; +float ready_waiting_for_me; +float vote_waiting; +float vote_waiting_for_me; diff --git a/data/qcsrc/client/sbar.qc b/data/qcsrc/client/sbar.qc index 0962697a2..aab243576 100644 --- a/data/qcsrc/client/sbar.qc +++ b/data/qcsrc/client/sbar.qc @@ -1323,6 +1323,19 @@ float Sbar_WouldDrawScoreboard () return 0; } +vector Sbar_DrawNoteLine(vector offset, string s) +{ + dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0) + drawcolorcodedstring( + offset - sbar_fontsize_x * '1 0 0' * stringwidth(s, TRUE), + s, + sbar_fontsize, + sbar_alpha_fg, + 0 + ); + return offset + sbar_fontsize_y * '0 1 0'; +} + void Sbar_Draw (void) { float i; @@ -1333,63 +1346,25 @@ void Sbar_Draw (void) sbar_fontsize = Sbar_GetFontsize(); - if(warmup_stage) - { - s = strcat("^1Press ^3", getcommandkey("ready", "ready"), "^1 to end warmup"); - dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0) - drawcolorcodedstring( - o - sbar_fontsize_x * '2 0 0' * stringwidth(s, TRUE), - s, - sbar_fontsize * 2, - sbar_alpha_fg, - 0 - ); - o += sbar_fontsize_y * '0 2 0'; - } - if(spectatee_status) { if(spectatee_status == -1) s = "^1Observing"; else s = strcat("^1Spectating ^7", getplayerkey(spectatee_status - 1, "name")); - dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0) - drawcolorcodedstring( - o - sbar_fontsize_x * '1 0 0' * stringwidth(s, TRUE), - s, - sbar_fontsize, - sbar_alpha_fg, - 0 - ); - o += sbar_fontsize_y * '0 1 0'; + o = Sbar_DrawNoteLine(o, s); if(spectatee_status == -1) s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate"); else s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player"); - dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0) - drawcolorcodedstring( - o - sbar_fontsize_x * '1 0 0' * stringwidth(s, TRUE), - s, - sbar_fontsize, - sbar_alpha_fg, - 0 - ); - o += sbar_fontsize_y * '0 1 0'; + o = Sbar_DrawNoteLine(o, s); if(spectatee_status == -1) s = strcat("^1Use ^3", getcommandkey("next-weapon", "weapnext"), "^1 or ^3", getcommandkey("previous-weapon", "weapprev"), "^1 to change the speed"); else s = strcat("^1Press ^3", getcommandkey("secondary fire", "+altattack"), getcommandkey("", "weapprev"), "^1 to observe"); - dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0) - drawcolorcodedstring( - o - sbar_fontsize_x * '1 0 0' * stringwidth(s, TRUE), - s, - sbar_fontsize, - sbar_alpha_fg, - 0 - ); - o += sbar_fontsize_y * '0 1 0'; + o = Sbar_DrawNoteLine(o, s); if(gametype == GAME_ARENA) s = "^1Wait for your turn to join"; @@ -1406,17 +1381,50 @@ void Sbar_Draw (void) } else s = strcat("^1Press ^7", getcommandkey("jump", "+jump"), "^1 to join"); - dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0) - drawcolorcodedstring( - o - sbar_fontsize_x * '1 0 0' * stringwidth(s, TRUE), - s, - sbar_fontsize, - sbar_alpha_fg, - 0 - ); - o += sbar_fontsize_y * '0 1 0'; + o = Sbar_DrawNoteLine(o, s); } + if(ready_waiting) + { + if(ready_waiting_for_me) + { + if(warmup_stage) + s = strcat("^1Press ^3", getcommandkey("ready", "ready"), "^1 to end warmup"); + else + s = strcat("^1Press ^3", getcommandkey("ready", "ready"), "^1 once you are ready"); + } + else + { + if(warmup_stage) + s = strcat("^1Waiting for others to ready up to end warmup..."); + else + s = strcat("^1Waiting for others to ready up..."); + } + o = Sbar_DrawNoteLine(o, s); + } + if(vote_waiting) + { + s = strcat("^1A vote has been called for ", vote_called_vote); + o = Sbar_DrawNoteLine(o, s); + + if(vote_waiting_for_me) + { + s = strcat("^1Press ^3", getcommandkey("vyes", "vyes"), "^1 to accept"); + o = Sbar_DrawNoteLine(o, s); + + s = strcat("^1Press ^3", getcommandkey("vno", "vno"), "^1 to reject"); + o = Sbar_DrawNoteLine(o, s); + + s = strcat("^1Press ^3", getcommandkey("vabstain", "vabstain"), "^1 to abstain"); + o = Sbar_DrawNoteLine(o, s); + } + else + { + s = strcat("^1Waiting for others to vote..."); + o = Sbar_DrawNoteLine(o, s); + } + } + //Sbar_SortFrags(); Sbar_UpdatePlayerTeams(); diff --git a/data/qcsrc/common/constants.qh b/data/qcsrc/common/constants.qh index e3f9b4b8c..46e780592 100644 --- a/data/qcsrc/common/constants.qh +++ b/data/qcsrc/common/constants.qh @@ -18,7 +18,8 @@ // Revision 17: multi-weaponimpulses // Revision 18: warmup // Revision 19: fog -#define CSQC_REVISION 19 +// Revision 20: naggers +#define CSQC_REVISION 20 // probably put these in common/ // so server/ and client/ can be synced better @@ -48,6 +49,7 @@ const float ENT_CLIENT_TEAMSCORES = 5; const float ENT_CLIENT_POINTPARTICLES = 6; const float ENT_CLIENT_RAINSNOW = 7; const float ENT_CLIENT_LASER = 8; +const float ENT_CLIENT_NAGGER = 9; // [flags] [votecalledvote] /////////////////////////// // key constants diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index d63fc673a..fb6ae7b59 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -1937,8 +1937,10 @@ void ObserverThink() self.flags = self.flags | FL_JUMPRELEASED; } } + /* if(self.BUTTON_ZOOM) self.wantswelcomemessage = 0; + */ if(self.wantswelcomemessage) PrintWelcomeMessage(self); } @@ -1974,8 +1976,10 @@ void SpectatorThink() self.flags = self.flags | FL_JUMPRELEASED; } } + /* if(self.BUTTON_ZOOM) self.wantswelcomemessage = 0; + */ if(self.wantswelcomemessage) PrintWelcomeMessage(self); self.flags = self.flags | FL_CLIENT | FL_NOTARGET; @@ -1989,7 +1993,6 @@ Called every frame for each client before the physics are run ============= */ void() ctf_setstatus; -.float vote_nagtime; .float spectatee_status; void PlayerPreThink (void) { @@ -2039,14 +2042,6 @@ void PlayerPreThink (void) self.version_nagtime = 0; } - // vote nagging - if(self.cvar_scr_centertime) - if(time > self.vote_nagtime) - { - VoteNag(); - self.vote_nagtime = time + self.cvar_scr_centertime * 0.6; - } - // GOD MODE info if(!(self.flags & FL_GODMODE)) if(self.max_armorvalue) { diff --git a/data/qcsrc/server/clientcommands.qc b/data/qcsrc/server/clientcommands.qc index 2fc6f724c..255f1f257 100644 --- a/data/qcsrc/server/clientcommands.qc +++ b/data/qcsrc/server/clientcommands.qc @@ -1,3 +1,48 @@ +entity nagger; +float readycount; +void Nagger_SendEntity(entity to, float sendflags) +{ + float nags; + WriteByte(MSG_ENTITY, ENT_CLIENT_NAGGER); + + nags = 0; + if(readycount) + { + nags |= 1; + if(to.ready == 0) + nags |= 2; + } + if(votecalled) + { + nags |= 4; + if(to.vote_vote == 0) + nags |= 8; + } + + if(sendflags & 128) + { + WriteByte(MSG_ENTITY, nags | 128); + WriteString(MSG_ENTITY, votecalledvote); + } + else + WriteByte(MSG_ENTITY, nags); +} +void Nagger_Init() +{ + nagger = spawn(); + Net_LinkEntity(nagger); + nagger.SendFlags = 128; + nagger.SendEntity = Nagger_SendEntity; +} +void Nagger_VoteChanged() +{ + nagger.SendFlags = 128; +} +void Nagger_ReadyCounted() +{ + nagger.SendFlags = 1; +} + void ReadyCount(); string MapVote_Suggest(string m); @@ -395,11 +440,6 @@ void ReadyRestart() if(checkrules_overtimeend) checkrules_overtimeend = 0; - if(readyNagActive) { //if every player is ready, remove the ready-nagger again - readyNagActive = 0; - remove(readyNagger); - } - restart_countdown = time + RESTART_COUNTDOWN; restart_mapalreadyrestarted = 0; //reset this var, needed when cvar sv_ready_restart_repeatable is in use if(0 < cvar("timelimit") || inWarmupStage) @@ -480,57 +520,13 @@ void ReadyCount() r += 1; } - if(!r) - return; // NOTE: this also excludes !p, as r <= p - - if(cvar("sv_ready_restart_nag")) { - if(!readyNagActive) { - readyNagger = spawn(); - readyNagger.think = readyNagger_Think; - readyNagger.cnt = cvar("sv_ready_restart_nag_duration"); - readyNagger.nextthink = time; - readyNagActive = 1; - } - } - - if(r < p) - return; - - ReadyRestart(); -} + readycount = r; -/** - * Centerprints the information to all players who didn't ready up yet to do so. - */ -void readyNagger_Think() { - local entity plr; - if(self.cnt <= 0) { //have a break showing the ready nag - //make sure that the old ready-nag-centerprint isn't shown too long: - FOR_EACH_REALCLIENT(plr) { - if(plr.classname == "player") { - if (!plr.ready) - centerprint_atprio(plr, CENTERPRIO_SPAM, ""); - } - } - self.cnt = cvar("sv_ready_restart_nag_duration"); - self.nextthink = time + cvar("sv_ready_restart_nag_interval"); - } - else { - //show the ready nagging to all players who aren't ready yet - FOR_EACH_REALCLIENT(plr) { - if(plr.classname == "player") { - if (!plr.ready) { - centerprint_atprio(plr, CENTERPRIO_SPAM, "^2Please ready up (F4 by default)!"); - //play reminder sound once the centerprint appears for the first time after the pause: - if (self.cnt == cvar("sv_ready_restart_nag_duration")) - play2(plr, "misc/talk2.wav"); - } - } - } + if(r) // at least one is ready + if(r == p) // and, everyone is ready + ReadyRestart(); - self.nextthink = time + 1; - self.cnt -= 1; - } + Nagger_ReadyCounted(); } /** diff --git a/data/qcsrc/server/defs.qh b/data/qcsrc/server/defs.qh index ff607eeff..9dd7c73fb 100644 --- a/data/qcsrc/server/defs.qh +++ b/data/qcsrc/server/defs.qh @@ -281,9 +281,6 @@ float restart_countdown; //point in time when the countdown is over float restart_mapalreadyrestarted; //bool, indicates whether reset_map() was already executed entity restartAnnouncer; //a temporary entity which will play the countdown sounds 3, 2, 1 for all clients, will also reset the map after the countdown void restartAnnouncer_Think(); -entity readyNagger; //manages printing the ready-nag to active players who are not ready yet -void readyNagger_Think(); -float readyNagActive; //if set to 1, the readyNagger entity was already spawned (boolean) float blockSpectators; //if set, new or existing spectators or observers will be removed unless they become a player within g_maxplayers_spectator_blocktime seconds .float spectatortime; //point in time since the client is spectating or observing void checkSpectatorBlock(); diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index 8a76fe084..873cb1392 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -156,6 +156,7 @@ float GotoFirstMap() float world_already_spawned; void RegisterWeapons(); +void Nagger_Init(); void spawnfunc_worldspawn (void) { float fd, l; @@ -357,6 +358,7 @@ void spawnfunc_worldspawn (void) addstat(STAT_SYS_TICRATE, AS_FLOAT, stat_sys_ticrate); addstat(STAT_WEAPONS, AS_INT, weapons); addstat(STAT_SWITCHWEAPON, AS_INT, switchweapon); + Nagger_Init(); next_pingtime = time + 5; world_initialized = 1; diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index 4d2768876..dcd75e828 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -657,8 +657,6 @@ void centerprint(entity e, string s) centerprint_atprio(e, CENTERPRIO_NORMAL, s); } -void VoteNag(); - // decolorizes and team colors the player name when needed string playername(entity p) { @@ -1454,3 +1452,11 @@ void spawnfunc_func_breakable() { self.use = assault_destructible_use; // shared use function, b/c they woudl do the same thing anyways self.event_damage = func_breakable_damage; } + +void Net_LinkEntity(entity e) +{ + e.model = "net_entity"; + e.modelindex = 1; + e.effects = EF_NODEPTHTEST | EF_LOWPRECISION; +} + diff --git a/data/qcsrc/server/scores.qc b/data/qcsrc/server/scores.qc index 72152cc8d..cca5bfd09 100644 --- a/data/qcsrc/server/scores.qc +++ b/data/qcsrc/server/scores.qc @@ -10,13 +10,6 @@ var .float teamscores_primary; float scores_flags_primary; float teamscores_flags_primary; -void Net_LinkEntity(entity e) -{ - e.model = "net_entity"; - e.modelindex = 1; - e.effects = EF_NODEPTHTEST | EF_LOWPRECISION; -} - vector ScoreField_Compare(entity t1, entity t2, .float field, float fieldflags, vector previous) // returns: cmp value, best prio { if(!(fieldflags & SFL_SORT_PRIO_MASK)) // column does not sort diff --git a/data/qcsrc/server/teamplay.qc b/data/qcsrc/server/teamplay.qc index 9510b19bc..2926861c5 100644 --- a/data/qcsrc/server/teamplay.qc +++ b/data/qcsrc/server/teamplay.qc @@ -387,10 +387,15 @@ void PrintWelcomeMessage(entity pl) else if (timeoutStatus != 0) specString = strcat(specString, "\n\n", getTimeoutText(1)); else - return; + { + if(!self.BUTTON_INFO && self.classname == "player") + return; + goto normal; + } return centerprint_atprio(self, CENTERPRIO_SPAM, specString); } +:normal if(g_minstagib) mutator = "^2Minstagib ^1"; else if(g_rocketarena) diff --git a/data/qcsrc/server/vote.qc b/data/qcsrc/server/vote.qc index a3f939b58..cf843a555 100644 --- a/data/qcsrc/server/vote.qc +++ b/data/qcsrc/server/vote.qc @@ -137,6 +137,7 @@ float GameCommand_Vote(string s, entity e) { if(cvar("sv_eventlog")) GameLogEcho(strcat(":vote:vcall:", ftos(votecaller.playerid), ":", votecalledvote_display)); VoteCount(); // needed if you are the only one + Nagger_VoteChanged(); } else { print_to(e, "^1This vote is not ok. See help for more info."); } @@ -175,6 +176,7 @@ float GameCommand_Vote(string s, entity e) { if(cvar("sv_eventlog")) GameLogEcho(strcat(":vote:vcall:", ftos(votecaller.playerid), ":", votecalledvote_display)); VoteCount(); // needed if you are the only one + Nagger_VoteChanged(); } } else { print_to(e, "^1Vote to become master is NOT allowed."); @@ -420,6 +422,7 @@ void VoteReset() { votecalled = FALSE; votecalledmaster = FALSE; votefinished = 0; + Nagger_VoteChanged(); } void VoteAccept() { @@ -462,12 +465,6 @@ void VoteStop(entity stopper) { VoteReset(); } -void VoteNag() { - if(votecalled) - if(self.vote_vote == 0) - centerprint_atprio(self, CENTERPRIO_VOTE, strcat("^7^3", VoteNetname(votecaller), "^2 called a vote for ", votecalledvote_display, "\n\n^2You have not voted yet!\n^2HINT: By default, F1 is yes and F2 is no.")); -} - void VoteSpam(float yescount, float nocount, float abstaincount, float notvoters, float mincount, string result) { string s; diff --git a/data/qcsrc/server/vote.qh b/data/qcsrc/server/vote.qh index ebd1d187d..1a71afc29 100644 --- a/data/qcsrc/server/vote.qh +++ b/data/qcsrc/server/vote.qh @@ -15,6 +15,5 @@ void VoteAccept(); void VoteReject(); void VoteTimeout(); void VoteStop(entity stopper); -void VoteNag(); void VoteSpam(float yescount, float nocount, float abstaincount, float notvoters, float mincount, string result); void VoteCount(); -- 2.39.2