From: Mario Date: Sat, 15 Jul 2017 21:26:46 +0000 (+1000) Subject: Port allowed_timeouts and active_minigame to ClientStatus, also fix a CS() call after... X-Git-Tag: xonotic-v0.8.5~2611 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c7595546506cb5d2af62a2c2db7b8681e01e4d01;p=xonotic%2Fxonotic-data.pk3dir.git Port allowed_timeouts and active_minigame to ClientStatus, also fix a CS() call after the ClientStatus entity has been removed (cleaner fix pending) --- diff --git a/qcsrc/common/minigames/sv_minigames.qc b/qcsrc/common/minigames/sv_minigames.qc index 033a524fb..4f1cd5dc2 100644 --- a/qcsrc/common/minigames/sv_minigames.qc +++ b/qcsrc/common/minigames/sv_minigames.qc @@ -3,7 +3,7 @@ void player_clear_minigame(entity player) { - player.active_minigame = NULL; + CS(player).active_minigame = NULL; player.minigame_players = NULL; if ( IS_PLAYER(player) ) set_movetype(player, MOVETYPE_WALK); @@ -124,11 +124,11 @@ bool minigame_CheckSend(entity this, entity client) int minigame_addplayer(entity minigame_session, entity player) { - if ( player.active_minigame ) + if ( CS(player).active_minigame ) { - if ( player.active_minigame == minigame_session ) + if ( CS(player).active_minigame == minigame_session ) return 0; - minigame_rmplayer(player.active_minigame,player); + minigame_rmplayer(CS(player).active_minigame,player); } entity player_pointer = new(minigame_player); int mgteam = minigame_session.minigame_event(minigame_session,"join",player,player_pointer); @@ -140,7 +140,7 @@ int minigame_addplayer(entity minigame_session, entity player) player_pointer.team = mgteam; player_pointer.list_next = minigame_session.minigame_players; minigame_session.minigame_players = player_pointer; - player.active_minigame = minigame_session; + CS(player).active_minigame = minigame_session; player.minigame_players = player_pointer; setcefc(player_pointer, minigame_CheckSend); Net_LinkEntity(player_pointer, false, 0, minigame_SendEntity); @@ -215,7 +215,7 @@ entity join_minigame(entity player, string game_id ) void part_minigame(entity player ) { - entity minig = player.active_minigame; + entity minig = CS(player).active_minigame; if ( minig && minig.classname == "minigame" ) minigame_rmplayer(minig,player); @@ -262,19 +262,19 @@ void end_minigames() string invite_minigame(entity inviter, entity player) { - if ( !inviter || !inviter.active_minigame ) + if ( !inviter || !CS(inviter).active_minigame ) return "Invalid minigame"; if ( VerifyClientEntity(player, true, false) <= 0 ) return "Invalid player"; if ( inviter == player ) return "You can't invite yourself"; - if ( player.active_minigame == inviter.active_minigame ) + if ( CS(player).active_minigame == CS(inviter).active_minigame ) return strcat(player.netname," is already playing"); Send_Notification(NOTIF_ONE, player, MSG_INFO, INFO_MINIGAME_INVITE, - inviter.active_minigame.netname, inviter.netname ); + CS(inviter).active_minigame.netname, inviter.netname ); - GameLogEcho(strcat(":minigame:invite:",inviter.active_minigame.netname,":", + GameLogEcho(strcat(":minigame:invite:",CS(inviter).active_minigame.netname,":", ftos(etof(player)),":",player.netname)); return ""; @@ -282,10 +282,10 @@ string invite_minigame(entity inviter, entity player) entity minigame_find_player(entity client) { - if ( ! client.active_minigame ) + if ( ! CS(client).active_minigame ) return NULL; entity e; - for ( e = client.active_minigame.minigame_players; e; e = e.list_next ) + for ( e = CS(client).active_minigame.minigame_players; e; e = e.list_next ) if ( e.minigame_players == client ) return e; return NULL; @@ -293,11 +293,11 @@ entity minigame_find_player(entity client) bool MinigameImpulse(entity this, int imp) { - if (!this.active_minigame) return false; + if (!CS(this).active_minigame) return false; entity e = minigame_find_player(this); - if ( imp && this.active_minigame && e ) + if ( imp && CS(this).active_minigame && e ) { - return this.active_minigame.minigame_event(this.active_minigame,"impulse",e,imp); + return CS(this).active_minigame.minigame_event(CS(this).active_minigame,"impulse",e,imp); } return false; } @@ -350,7 +350,7 @@ void ClientCommand_minigame(entity caller, int request, int argc, string command } else if ( minig_cmd == "end" || minig_cmd == "part" ) { - if ( caller.active_minigame ) + if ( CS(caller).active_minigame ) { part_minigame(caller); sprint(caller,"Left minigame session\n"); @@ -361,14 +361,14 @@ void ClientCommand_minigame(entity caller, int request, int argc, string command } else if ( minig_cmd == "invite" && argc > 2 ) { - if ( caller.active_minigame ) + if ( CS(caller).active_minigame ) { entity client = GetIndexedEntity(argc, 2); string error = invite_minigame(caller,client); if ( error == "" ) { sprint(caller,"You have invited ",client.netname, - " to join your game of ", caller.active_minigame.descriptor.message, "\n"); + " to join your game of ", CS(caller).active_minigame.descriptor.message, "\n"); } else sprint(caller,"Could not invite: ", error, ".\n"); @@ -377,12 +377,12 @@ void ClientCommand_minigame(entity caller, int request, int argc, string command sprint(caller,"You aren't playing any minigame...\n"); return; } - else if ( caller.active_minigame ) + else if ( CS(caller).active_minigame ) { entity e = minigame_find_player(caller); string subcommand = substring(command,argv_end_index(0),-1); int arg_c = tokenize_console(subcommand); - if ( caller.active_minigame.minigame_event(caller.active_minigame,"cmd",e,arg_c,subcommand) ) + if ( CS(caller).active_minigame.minigame_event(CS(caller).active_minigame,"cmd",e,arg_c,subcommand) ) return; } diff --git a/qcsrc/common/models/all.inc b/qcsrc/common/models/all.inc index f47d8e7c5..eb95d7c28 100644 --- a/qcsrc/common/models/all.inc +++ b/qcsrc/common/models/all.inc @@ -335,6 +335,7 @@ MODEL(VEH_SPIDERBOT_TOP, "models/vehicles/spiderbot_top.dpm"); MODEL(VEH_SPIDERBOT_VIEW, "models/vehicles/spiderbot_cockpit.dpm"); MODEL(CHAT, "models/misc/chatbubble.spr"); +MODEL(CHAT_MINIGAME, "models/sprites/minigame_busy.iqm"); MODEL(0, "models/sprites/0.spr32"); MODEL(1, "models/sprites/1.spr32"); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index b1059ca49..296e8c03f 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1229,7 +1229,7 @@ void ClientConnect(entity this) } CS(this).jointime = time; - this.allowed_timeouts = autocvar_sv_timeout_number; + CS(this).allowed_timeouts = autocvar_sv_timeout_number; if (IS_REAL_CLIENT(this)) { @@ -1286,7 +1286,7 @@ void ClientDisconnect(entity this) PlayerStats_GameReport_FinalizePlayer(this); if (this.vehicle) vehicles_exit(this.vehicle, VHEF_RELEASE); - if (this.active_minigame) part_minigame(this); + if (CS(this).active_minigame) part_minigame(this); if (IS_PLAYER(this)) Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1); if (autocvar_sv_eventlog) @@ -1299,6 +1299,7 @@ void ClientDisconnect(entity this) MUTATOR_CALLHOOK(ClientDisconnect, this); + if (CS(this).netname_previous) strunzone(CS(this).netname_previous); // needs to be before the CS entity is removed! ClientState_detach(this); Portal_ClearAll(this); @@ -1318,7 +1319,6 @@ void ClientDisconnect(entity this) bot_relinkplayerlist(); - if (CS(this).netname_previous) strunzone(CS(this).netname_previous); if (this.clientstatus) strunzone(this.clientstatus); if (this.weaponorder_byimpulse) strunzone(this.weaponorder_byimpulse); if (this.personal) delete(this.personal); @@ -1345,7 +1345,7 @@ void ChatBubbleThink(entity this) if ( !IS_DEAD(this.owner) && IS_PLAYER(this.owner) ) { - if ( this.owner.active_minigame ) + if ( CS(this.owner).active_minigame ) this.mdl = "models/sprites/minigame_busy.iqm"; else if (PHYS_INPUT_BUTTON_CHAT(this.owner)) this.mdl = "models/misc/chatbubble.spr"; diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 660cb7c1e..b6f3abd69 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -85,6 +85,8 @@ CLASS(Client, Object) ATTRIB(Client, spectatortime, float, this.spectatortime); ATTRIB(Client, version_nagtime, float, this.version_nagtime); ATTRIB(Client, netname_previous, string, this.netname_previous); + ATTRIB(Client, allowed_timeouts, int, this.allowed_timeouts); + ATTRIB(Client, active_minigame, entity, this.active_minigame); METHOD(Client, m_unwind, bool(Client this)); diff --git a/qcsrc/server/command/common.qc b/qcsrc/server/command/common.qc index 936858ce4..84366ea6b 100644 --- a/qcsrc/server/command/common.qc +++ b/qcsrc/server/command/common.qc @@ -721,7 +721,7 @@ void CommonCommand_timeout(float request, entity caller) // DEAR GOD THIS COMMA { print_to(caller, "^7Error: You can not call a timeout while the map is being restarted."); } - else if (caller && (caller.allowed_timeouts < 1)) + else if (caller && (CS(caller).allowed_timeouts < 1)) { print_to(caller, "^7Error: You already used all your timeout calls for this map."); } @@ -736,9 +736,9 @@ void CommonCommand_timeout(float request, entity caller) // DEAR GOD THIS COMMA else // everything should be okay, proceed with starting the timeout { - if (caller) caller.allowed_timeouts -= 1; + if (caller) CS(caller).allowed_timeouts -= 1; // write a bprint who started the timeout (and how many they have left) - bprint(GetCallerName(caller), " ^7called a timeout", (caller ? strcat(" (", ftos(caller.allowed_timeouts), " timeout(s) left)") : ""), "!\n"); + bprint(GetCallerName(caller), " ^7called a timeout", (caller ? strcat(" (", ftos(CS(caller).allowed_timeouts), " timeout(s) left)") : ""), "!\n"); timeout_status = TIMEOUT_LEADTIME; timeout_caller = caller; diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index f8ab3a440..fda3adc40 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -456,7 +456,7 @@ void ReadyRestart_force() // after a restart every players number of allowed timeouts gets reset, too if (autocvar_sv_timeout) { - FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(it.allowed_timeouts = autocvar_sv_timeout_number)); + FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(CS(it).allowed_timeouts = autocvar_sv_timeout_number)); } // reset map immediately if this cvar is not set if (!autocvar_sv_ready_restart_after_countdown) reset_map(true); diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index 2ee496065..e3201c4e5 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -994,11 +994,11 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc centerprint(privatesay, cmsgstr); } } - else if ( teamsay && source.active_minigame ) + else if ( teamsay && CS(source).active_minigame ) { sprint(source, sourcemsgstr); dedicated_print(msgstr); // send to server console too - FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source && it.active_minigame == source.active_minigame && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), sprint(it, msgstr)); + FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source && CS(it).active_minigame == CS(source).active_minigame && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), sprint(it, msgstr)); } else if(teamsay > 0) // team message, only sent to team mates {