X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fmiscfunctions.qc;h=d57b28624aaf84a31ca1d5f5e542aca9f8b7397c;hp=63ed488c0d837907444c67ba30aa4879ff6fa168;hb=fc0e4c6f26156858a71e0ec62eb974fa11eec2f9;hpb=dca461716d4204384f9bbf8826c05045d59832c7 diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 63ed488c0..d57b28624 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -32,7 +32,6 @@ void WarpZone_crosshair_trace(entity pl) void() spawnfunc_info_player_deathmatch; // needed for the other spawnpoints void() spawnpoint_use; string GetMapname(); -string ColoredTeamName(float t); string admin_name(void) { @@ -80,26 +79,27 @@ float DistributeEvenly_GetRandomized(float weight) #define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e) - string STR_PLAYER = "player"; string STR_SPECTATOR = "spectator"; string STR_OBSERVER = "observer"; -#if 0 -#define FOR_EACH_CLIENT(v) for(v = world; (v = findflags(v, flags, FL_CLIENT)) != world; ) -#define FOR_EACH_REALCLIENT(v) FOR_EACH_CLIENT(v) if(clienttype(v) == CLIENTTYPE_REAL) -#define FOR_EACH_PLAYER(v) for(v = world; (v = find(v, classname, STR_PLAYER)) != world; ) -#define FOR_EACH_REALPLAYER(v) FOR_EACH_PLAYER(v) if(clienttype(v) == CLIENTTYPE_REAL) -#else +#define IS_PLAYER(v) (v.classname == STR_PLAYER) +#define IS_SPEC(v) (v.classname == STR_SPECTATOR) +#define IS_OBSERVER(v) (v.classname == STR_OBSERVER) +#define IS_CLIENT(v) (v.flags & FL_CLIENT) +#define IS_BOT_CLIENT(v) (clienttype(v) == CLIENTTYPE_BOT) +#define IS_REAL_CLIENT(v) (clienttype(v) == CLIENTTYPE_REAL) +#define IS_NOT_A_CLIENT(v) (clienttype(v) == CLIENTTYPE_NOTACLIENT) + #define FOR_EACH_CLIENTSLOT(v) for(v = world; (v = nextent(v)) && (num_for_edict(v) <= maxclients); ) -#define FOR_EACH_CLIENT(v) FOR_EACH_CLIENTSLOT(v) if(v.flags & FL_CLIENT) -#define FOR_EACH_REALCLIENT(v) FOR_EACH_CLIENT(v) if(clienttype(v) == CLIENTTYPE_REAL) -#define FOR_EACH_PLAYER(v) FOR_EACH_CLIENT(v) if(v.classname == STR_PLAYER) -#define FOR_EACH_SPEC(v) FOR_EACH_CLIENT(v) if(v.classname != STR_PLAYER) -#define FOR_EACH_REALPLAYER(v) FOR_EACH_REALCLIENT(v) if(v.classname == STR_PLAYER) -#endif +#define FOR_EACH_CLIENT(v) FOR_EACH_CLIENTSLOT(v) if(IS_CLIENT(v)) +#define FOR_EACH_REALCLIENT(v) FOR_EACH_CLIENT(v) if(IS_REAL_CLIENT(v)) -#define CENTER_OR_VIEWOFS(ent) (ent.origin + ((ent.classname == STR_PLAYER) ? ent.view_ofs : ((ent.mins + ent.maxs) * 0.5))) +#define FOR_EACH_PLAYER(v) FOR_EACH_CLIENT(v) if(IS_PLAYER(v)) +#define FOR_EACH_SPEC(v) FOR_EACH_CLIENT(v) if not(IS_PLAYER(v)) // Samual: shouldn't this be IS_SPEC(v)? and rather create a separate macro to include observers too +#define FOR_EACH_REALPLAYER(v) FOR_EACH_REALCLIENT(v) if(IS_PLAYER(v)) + +#define CENTER_OR_VIEWOFS(ent) (ent.origin + (IS_PLAYER(ent) ? ent.view_ofs : ((ent.mins + ent.maxs) * 0.5))) // copies a string to a tempstring (so one can strunzone it) string strcat1(string s) = #115; // FRIK_FILE @@ -107,15 +107,6 @@ string strcat1(string s) = #115; // FRIK_FILE float logfile_open; float logfile; -void bcenterprint(string s) -{ - // TODO replace by MSG_ALL (would show it to spectators too, though)? - entity head; - FOR_EACH_PLAYER(head) - if (clienttype(head) == CLIENTTYPE_REAL) - centerprint(head, s); -} - void GameLogEcho(string s) { string fn; @@ -164,63 +155,6 @@ void GameLogClose() } } -float spawnpoint_nag; -void relocate_spawnpoint() -{ - // nudge off the floor - setorigin(self, self.origin + '0 0 1'); - - tracebox(self.origin, PL_MIN, PL_MAX, self.origin, TRUE, self); - if (trace_startsolid) - { - vector o; - o = self.origin; - self.mins = PL_MIN; - self.maxs = PL_MAX; - if (!move_out_of_solid(self)) - objerror("could not get out of solid at all!"); - print("^1NOTE: this map needs FIXING. Spawnpoint at ", vtos(o - '0 0 1')); - print(" needs to be moved out of solid, e.g. by '", ftos(self.origin_x - o_x)); - print(" ", ftos(self.origin_y - o_y)); - print(" ", ftos(self.origin_z - o_z), "'\n"); - if (autocvar_g_spawnpoints_auto_move_out_of_solid) - { - if (!spawnpoint_nag) - print("\{1}^1NOTE: this map needs FIXING (it contains spawnpoints in solid, see server log)\n"); - spawnpoint_nag = 1; - } - else - { - setorigin(self, o); - self.mins = self.maxs = '0 0 0'; - objerror("player spawn point in solid, mapper sucks!\n"); - return; - } - } - - self.use = spawnpoint_use; - self.team_saved = self.team; - if (!self.cnt) - self.cnt = 1; - - if (have_team_spawns != 0) - if (self.team) - have_team_spawns = 1; - have_team_spawns_forteam[self.team] = 1; - - if (autocvar_r_showbboxes) - { - // show where spawnpoints point at too - makevectors(self.angles); - entity e; - e = spawn(); - e.classname = "info_player_foo"; - setorigin(e, self.origin + v_forward * 24); - setsize(e, '-8 -8 -8', '8 8 8'); - e.solid = SOLID_TRIGGER; - } -} - #define strstr strstrofs /* // NOTE: DO NOT USE THIS FUNCTION TOO OFTEN. @@ -546,7 +480,11 @@ void GetCvars(float f) get_cvars_f = f; get_cvars_s = s; + MUTATOR_CALLHOOK(GetCvars); + + Notification_GetCvars(); + GetCvars_handleFloat(s, f, autoswitch, "cl_autoswitch"); GetCvars_handleFloat(s, f, cvar_cl_autoscreenshot, "cl_autoscreenshot"); GetCvars_handleString(s, f, cvar_g_xonoticversion, "g_xonoticversion"); @@ -590,102 +528,6 @@ void GetCvars(float f) } } -void backtrace(string msg) -{ - float dev, war; - dev = autocvar_developer; - war = autocvar_prvm_backtraceforwarnings; - cvar_set("developer", "1"); - cvar_set("prvm_backtraceforwarnings", "1"); - print("\n"); - print("--- CUT HERE ---\nWARNING: "); - print(msg); - print("\n"); - remove(world); // isn't there any better way to cause a backtrace? - print("\n--- CUT UNTIL HERE ---\n"); - cvar_set("developer", ftos(dev)); - cvar_set("prvm_backtraceforwarnings", ftos(war)); -} - -string Team_ColorCode(float teamid) -{ - if (teamid == COLOR_TEAM1) - return "^1"; - else if (teamid == COLOR_TEAM2) - return "^4"; - else if (teamid == COLOR_TEAM3) - return "^3"; - else if (teamid == COLOR_TEAM4) - return "^6"; - else - return "^7"; -} - -string Team_ColorName(float t) -{ - // fixme: Search for team entities and get their .netname's! - if (t == COLOR_TEAM1) - return "Red"; - if (t == COLOR_TEAM2) - return "Blue"; - if (t == COLOR_TEAM3) - return "Yellow"; - if (t == COLOR_TEAM4) - return "Pink"; - return "Neutral"; -} - -string Team_ColorNameLowerCase(float t) -{ - // fixme: Search for team entities and get their .netname's! - if (t == COLOR_TEAM1) - return "red"; - if (t == COLOR_TEAM2) - return "blue"; - if (t == COLOR_TEAM3) - return "yellow"; - if (t == COLOR_TEAM4) - return "pink"; - return "neutral"; -} - -float ColourToNumber(string team_colour) -{ - if (team_colour == "red") - return COLOR_TEAM1; - - if (team_colour == "blue") - return COLOR_TEAM2; - - if (team_colour == "yellow") - return COLOR_TEAM3; - - if (team_colour == "pink") - return COLOR_TEAM4; - - if (team_colour == "auto") - return 0; - - return -1; -} - -float NumberToTeamNumber(float number) -{ - if (number == 1) - return COLOR_TEAM1; - - if (number == 2) - return COLOR_TEAM2; - - if (number == 3) - return COLOR_TEAM3; - - if (number == 4) - return COLOR_TEAM4; - - return -1; -} - // decolorizes and team colors the player name when needed string playername(entity p) { @@ -1094,12 +936,6 @@ float g_bugrigs_speed_ref; float g_bugrigs_speed_pow; float g_bugrigs_steer; -float g_touchexplode; -float g_touchexplode_radius; -float g_touchexplode_damage; -float g_touchexplode_edgedamage; -float g_touchexplode_force; - float sv_autotaunt; float sv_taunt; @@ -1115,6 +951,8 @@ void readlevelcvars(void) MUTATOR_ADD(mutator_spawn_near_teammate); if(cvar("g_physical_items")) MUTATOR_ADD(mutator_physical_items); + if(cvar("g_touchexplode")) + MUTATOR_ADD(mutator_touchexplode); if(!g_minstagib) { if(cvar("g_invincible_projectiles")) @@ -1154,14 +992,7 @@ void readlevelcvars(void) g_bugrigs_speed_pow = cvar("g_bugrigs_speed_pow"); g_bugrigs_steer = cvar("g_bugrigs_steer"); - g_touchexplode = cvar("g_touchexplode"); - g_touchexplode_radius = cvar("g_touchexplode_radius"); - g_touchexplode_damage = cvar("g_touchexplode_damage"); - g_touchexplode_edgedamage = cvar("g_touchexplode_edgedamage"); - g_touchexplode_force = cvar("g_touchexplode_force"); - sv_clones = cvar("sv_clones"); - sv_gentle = cvar("sv_gentle"); sv_foginterval = cvar("sv_foginterval"); g_cloaked = cvar("g_cloaked"); if(g_cts) @@ -1635,34 +1466,6 @@ void precache() #endif } -// sorry, but using \ in macros breaks line numbers -#define WRITESPECTATABLE_MSG_ONE_VARNAME(varname,statement) entity varname; varname = msg_entity; FOR_EACH_REALCLIENT(msg_entity) if(msg_entity == varname || (msg_entity.classname == STR_SPECTATOR && msg_entity.enemy == varname)) statement msg_entity = varname -#define WRITESPECTATABLE_MSG_ONE(statement) WRITESPECTATABLE_MSG_ONE_VARNAME(oldmsg_entity, statement) -#define WRITESPECTATABLE(msg,statement) if(msg == MSG_ONE) { WRITESPECTATABLE_MSG_ONE(statement); } else statement float WRITESPECTATABLE_workaround = 0 - - -void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration, float countdown_num) -{ - if ((clienttype(e) == CLIENTTYPE_REAL) && (e.flags & FL_CLIENT)) - { - msg_entity = e; - WRITESPECTATABLE_MSG_ONE({ - WriteByte(MSG_ONE, SVC_TEMPENTITY); - WriteByte(MSG_ONE, TE_CSQC_CENTERPRINT_GENERIC); - WriteByte(MSG_ONE, id); - WriteString(MSG_ONE, s); - if (id != 0 && s != "") - { - WriteByte(MSG_ONE, duration); - WriteByte(MSG_ONE, countdown_num); - } - }); - } -} -void Send_CSQC_Centerprint_Generic_Expire(entity e, float id) -{ - Send_CSQC_Centerprint_Generic(e, id, "", 1, 0); -} // WARNING: this kills the trace globals #define EXACTTRIGGER_TOUCH if(WarpZoneLib_ExactTrigger_Touch()) return #define EXACTTRIGGER_INIT WarpZoneLib_ExactTrigger_Init() @@ -2141,22 +1944,6 @@ string race_readName(string map, float pos) return uid2name(db_get(ServerProgsDB, strcat(map, rr, "crypto_idfp", ftos(pos)))); } -string race_placeName(float pos) { - if(floor((mod(pos, 100))/10) * 10 != 10) // examples: 12th, 111th, 213th will not execute this block - { - if(mod(pos, 10) == 1) - return strcat(ftos(pos), "st"); - else if(mod(pos, 10) == 2) - return strcat(ftos(pos), "nd"); - else if(mod(pos, 10) == 3) - return strcat(ftos(pos), "rd"); - else - return strcat(ftos(pos), "th"); - } - else - return strcat(ftos(pos), "th"); -} - float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance) { float m, i;