From 99775330356c1f28da74ed52a4cc7e1248dab3be Mon Sep 17 00:00:00 2001 From: Adam Olsen Date: Fri, 20 Jul 2001 08:38:54 +0000 Subject: [PATCH] Initial commit of UserInfoCallback and setinfokey stuff. color, skin, and team are all set using setinfokey. You are no longer kicked for changing them. And the callback happily rejects every attempted change from the client (for skin and color atleast). --- defs.qc | 1 + tfort.qc | 86 ++++++++++++++++++++++----------------------- tforttm.qc | 101 +++++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 123 insertions(+), 65 deletions(-) diff --git a/defs.qc b/defs.qc index 7a47a3d..ad44c3c 100644 --- a/defs.qc +++ b/defs.qc @@ -841,6 +841,7 @@ float(string s) stof = #81; // convert string to float void(vector where, float set) multicast = #82; // sends the temp message to a set // of clients, possibly in PVS or PHS #endif +void (entity ent, string key, string value) setinfokey = #102; //============================================================================ diff --git a/tfort.qc b/tfort.qc index 6ec6e5b..fe30953 100644 --- a/tfort.qc +++ b/tfort.qc @@ -1735,11 +1735,11 @@ void(entity p) TeamFortress_SetSkin = else p.skin = p.playerclass; + st = "base"; // just in case + #ifdef QUAKE_WORLD if (p.skin != #PC_UNDEFINED) { - stuffcmd(p, "skin "); - //WK Figure out what Mr.Custom Should look like if (p.playerclass == #PC_CUSTOM && p.undercover_skin == 0) { @@ -1749,95 +1749,95 @@ void(entity p) TeamFortress_SetSkin = if ( p.team_no == 4) { if ( p.skin == #PC_SCOUT ) - stuffcmd(p, #TEAM4_SCOUT_SKIN); + st = #TEAM4_SCOUT_SKIN; else if ( p.skin == #PC_SNIPER ) - stuffcmd(p, #TEAM4_SNIPER_SKIN); + st = #TEAM4_SNIPER_SKIN; else if ( p.skin == #PC_SOLDIER ) - stuffcmd(p, #TEAM4_SOLDIER_SKIN); + st = #TEAM4_SOLDIER_SKIN; else if ( p.skin == #PC_DEMOMAN ) - stuffcmd(p, #TEAM4_DEMOMAN_SKIN); + st = #TEAM4_DEMOMAN_SKIN; else if ( p.skin == #PC_MEDIC ) - stuffcmd(p, #TEAM4_MEDIC_SKIN); + st = #TEAM4_MEDIC_SKIN; else if ( p.skin == #PC_HVYWEAP ) - stuffcmd(p, #TEAM4_HVYWEAP_SKIN); + st = #TEAM4_HVYWEAP_SKIN; else if ( p.skin == #PC_PYRO ) - stuffcmd(p, #TEAM4_PYRO_SKIN); + st = #TEAM4_PYRO_SKIN; else if ( p.skin == #PC_SPY ) - stuffcmd(p, #TEAM4_SPY_SKIN); + st = #TEAM4_SPY_SKIN; else if ( p.skin == #PC_ENGINEER ) - stuffcmd(p, #TEAM4_ENGINEER_SKIN); + st = #TEAM4_ENGINEER_SKIN; } else if ( p.team_no == 3) { if ( p.skin == #PC_SCOUT ) - stuffcmd(p, #TEAM3_SCOUT_SKIN); + st = #TEAM3_SCOUT_SKIN; else if ( p.skin == #PC_SNIPER ) - stuffcmd(p, #TEAM3_SNIPER_SKIN); + st = #TEAM3_SNIPER_SKIN; else if ( p.skin == #PC_SOLDIER ) - stuffcmd(p, #TEAM3_SOLDIER_SKIN); + st = #TEAM3_SOLDIER_SKIN; else if ( p.skin == #PC_DEMOMAN ) - stuffcmd(p, #TEAM3_DEMOMAN_SKIN); + st = #TEAM3_DEMOMAN_SKIN; else if ( p.skin == #PC_MEDIC ) - stuffcmd(p, #TEAM3_MEDIC_SKIN); + st = #TEAM3_MEDIC_SKIN; else if ( p.skin == #PC_HVYWEAP ) - stuffcmd(p, #TEAM3_HVYWEAP_SKIN); + st = #TEAM3_HVYWEAP_SKIN; else if ( p.skin == #PC_PYRO ) - stuffcmd(p, #TEAM3_PYRO_SKIN); + st = #TEAM3_PYRO_SKIN; else if ( p.skin == #PC_SPY ) - stuffcmd(p, #TEAM3_SPY_SKIN); + st = #TEAM3_SPY_SKIN; else if ( p.skin == #PC_ENGINEER ) - stuffcmd(p, #TEAM3_ENGINEER_SKIN); + st = #TEAM3_ENGINEER_SKIN; } else if ( p.team_no == 2) { if ( p.skin == #PC_SCOUT ) - stuffcmd(p, #TEAM2_SCOUT_SKIN); + st = #TEAM2_SCOUT_SKIN; else if ( p.skin == #PC_SNIPER ) - stuffcmd(p, #TEAM2_SNIPER_SKIN); + st = #TEAM2_SNIPER_SKIN; else if ( p.skin == #PC_SOLDIER ) - stuffcmd(p, #TEAM2_SOLDIER_SKIN); + st = #TEAM2_SOLDIER_SKIN; else if ( p.skin == #PC_DEMOMAN ) - stuffcmd(p, #TEAM2_DEMOMAN_SKIN); + st = #TEAM2_DEMOMAN_SKIN; else if ( p.skin == #PC_MEDIC ) - stuffcmd(p, #TEAM2_MEDIC_SKIN); + st = #TEAM2_MEDIC_SKIN; else if ( p.skin == #PC_HVYWEAP ) - stuffcmd(p, #TEAM2_HVYWEAP_SKIN); + st = #TEAM2_HVYWEAP_SKIN; else if ( p.skin == #PC_PYRO ) - stuffcmd(p, #TEAM2_PYRO_SKIN); + st = #TEAM2_PYRO_SKIN; else if ( p.skin == #PC_SPY ) - stuffcmd(p, #TEAM2_SPY_SKIN); + st = #TEAM2_SPY_SKIN; else if ( p.skin == #PC_ENGINEER ) - stuffcmd(p, #TEAM2_ENGINEER_SKIN); + st = #TEAM2_ENGINEER_SKIN; } else // if ( p.team_no == 1) { if ( p.skin == #PC_SCOUT ) - stuffcmd(p, #TEAM1_SCOUT_SKIN); + st = #TEAM1_SCOUT_SKIN; else if ( p.skin == #PC_SNIPER ) - stuffcmd(p, #TEAM1_SNIPER_SKIN); + st = #TEAM1_SNIPER_SKIN; else if ( p.skin == #PC_SOLDIER ) - stuffcmd(p, #TEAM1_SOLDIER_SKIN); + st = #TEAM1_SOLDIER_SKIN; else if ( p.skin == #PC_DEMOMAN ) - stuffcmd(p, #TEAM1_DEMOMAN_SKIN); + st = #TEAM1_DEMOMAN_SKIN; else if ( p.skin == #PC_MEDIC ) - stuffcmd(p, #TEAM1_MEDIC_SKIN); + st = #TEAM1_MEDIC_SKIN; else if ( p.skin == #PC_HVYWEAP ) - stuffcmd(p, #TEAM1_HVYWEAP_SKIN); + st = #TEAM1_HVYWEAP_SKIN; else if ( p.skin == #PC_PYRO ) - stuffcmd(p, #TEAM1_PYRO_SKIN); + st = #TEAM1_PYRO_SKIN; else if ( p.skin == #PC_SPY ) - stuffcmd(p, #TEAM1_SPY_SKIN); + st = #TEAM1_SPY_SKIN; else if ( p.skin == #PC_ENGINEER ) - stuffcmd(p, #TEAM1_ENGINEER_SKIN); + st = #TEAM1_ENGINEER_SKIN; } if ( p.skin == #PC_CIVILIAN ) - stuffcmd(p, "base\n"); // Need a civilian skin - } - else - { - stuffcmd(p, "skin base\n"); //WK Need a custom skin, or fake it + st = "base\n"; // Need a civilian skin } + stuffcmd(p, "skin "); + stuffcmd(p, st); + stuffcmd(p, "\n"); + setinfokey(p, "skin", st); #endif }; diff --git a/tforttm.qc b/tforttm.qc index b4cae62..70c12ca 100644 --- a/tforttm.qc +++ b/tforttm.qc @@ -207,10 +207,11 @@ void(entity p) SetTeamName = { local string st; - stuffcmd(p, "team "); st = GetTeamName(p.team_no); + stuffcmd(p, "team "); stuffcmd(p, st); stuffcmd(p, "\n"); + setinfokey(p, "team", st); }; #endif @@ -295,7 +296,11 @@ float(float tno) TeamFortress_TeamSet = // color command works. makeImmune(self,time+10); //self.immune_to_check = time + 10; - +// FOO + tc = TeamFortress_TeamGetColor(tno) - 1; + st = ftos(tc); + setinfokey(self, "color", st); +/* // Set the player's color stuffcmd(self, "color "); tc = TeamFortress_TeamGetColor(tno) - 1; @@ -306,7 +311,7 @@ float(float tno) TeamFortress_TeamSet = stuffcmd(self, st); stuffcmd(self, "\n"); - +*/ self.team_no = tno; self.lives = TeamFortress_TeamGetLives(tno); @@ -334,6 +339,12 @@ float(float tno) TeamFortress_TeamSet = bprint(#PRINT_HIGH, st); bprint(#PRINT_HIGH, ".\n"); +//FOO + tc = TeamFortress_TeamGetColor(tno) - 1; + st = ftos(tc); + setinfokey(self, "topcolor", st); + setinfokey(self, "bottomcolor", st); + // Set the player's color stuffcmd(self, "color "); tc = TeamFortress_TeamGetColor(tno) - 1; @@ -348,7 +359,7 @@ float(float tno) TeamFortress_TeamSet = self.team_no = tno; // Prevent the cheatchecking mechanism from nabbing them b4 the // color command works. - makeImmune(self,time+10); +// makeImmune(self,time+10); //self.immune_to_check = time + 10; self.lives = TeamFortress_TeamGetLives(tno); @@ -447,10 +458,12 @@ void() TeamFortress_CheckTeamCheats = stuffcmd(self, st); stuffcmd(self, "\n"); + setinfokey(self, "topcolor", st); + setinfokey(self, "bottomcolor", st); - bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n"); - sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n"); - stuffcmd(self, "disconnect\n"); +// bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n"); +// sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n"); +// stuffcmd(self, "disconnect\n"); return; } } @@ -466,10 +479,12 @@ void() TeamFortress_CheckTeamCheats = stuffcmd(self, st); stuffcmd(self, "\n"); + setinfokey(self, "topcolor", st); + setinfokey(self, "bottomcolor", st); - bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n"); - sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n"); - stuffcmd(self, "disconnect\n"); +// bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n"); +// sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n"); +// stuffcmd(self, "disconnect\n"); return; } #else @@ -496,10 +511,12 @@ void() TeamFortress_CheckTeamCheats = stuffcmd(self, st); stuffcmd(self, "\n"); + setinfokey(self, "topcolor", st); + setinfokey(self, "bottomcolor", st); - bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n"); - sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n"); - stuffcmd(self, "disconnect\n"); +// bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n"); +// sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n"); +// stuffcmd(self, "disconnect\n"); return; } } @@ -520,10 +537,12 @@ void() TeamFortress_CheckTeamCheats = stuffcmd(self, st); stuffcmd(self, "\n"); + setinfokey(self, "topcolor", st); + setinfokey(self, "bottomcolor", st); - bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n"); - sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n"); - stuffcmd(self, "disconnect\n"); +// bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n"); +// sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n"); +// stuffcmd(self, "disconnect\n"); return; } @@ -542,9 +561,9 @@ void() TeamFortress_CheckTeamCheats = { TeamFortress_SetSkin(self); - bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing skin.\n"); - sprint(self, #PRINT_HIGH, "You have been kicked for changing your skin. Don't do it.\n"); - stuffcmd(self, "disconnect\n"); +// bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing skin.\n"); +// sprint(self, #PRINT_HIGH, "You have been kicked for changing your skin. Don't do it.\n"); +// stuffcmd(self, "disconnect\n"); } if ((self.cutf_items & #CUTF_SPY_KIT) && self.undercover_skin != 0) @@ -597,9 +616,9 @@ void() TeamFortress_CheckTeamCheats = TeamFortress_SetSkin(self); - bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing skin.\n"); - sprint(self, #PRINT_HIGH, "You have been kicked for changing your skin. Don't do it.\n"); - stuffcmd(self, "disconnect\n"); +// bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing skin.\n"); +// sprint(self, #PRINT_HIGH, "You have been kicked for changing your skin. Don't do it.\n"); +// stuffcmd(self, "disconnect\n"); } } @@ -628,6 +647,44 @@ void() TeamFortress_CheckTeamCheats = } }; +void(string key, string value) UserInfoCallback = +{ + local string oldval; + local string st; + oldval = infokey(self, key); + + if(value == oldval) // generic reject + { + bprint(#PRINT_MEDIUM, "[oldval (" + key + ")(" + value + ")(" + oldval + ")]\n"); + return 1; // rejected! + } + + if (key == "topcolor" || key == "bottomcolor") + { + // no changing colors allowed + st = infokey(self, "bottomcolor"); // make sure top is same as bottom + setinfokey(self, "topcolor", st); + stuffcmd(self, "color "); + stuffcmd(self, st); + stuffcmd(self, "\n"); + bprint(#PRINT_MEDIUM, "[color (" + key + ")(" + value + ")(" + oldval + ")]\n"); + return 1; + } + else if (key == "skin") + { + stuffcmd(self, "skin "); + stuffcmd(self, oldval); + stuffcmd(self, "\n"); + bprint(#PRINT_MEDIUM, "[skin (" + key + ")(" + value + ")(" + oldval + ")]\n"); + return 1; + } + else + { + bprint(#PRINT_MEDIUM, "[default (" + key + ")(" + value + ")(" + oldval + ")]\n"); + return 0; // accept everything else + } +}; + //========================================================================= // Increase the score of a team void(float tno, float scoretoadd) TeamFortress_TeamIncreaseScore =