X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmiscfunctions.qc;h=2b73841808bed3223c1eef10bef5c06dd384138c;hb=a00d7aad132a38ac48dc4a1cd0c49aa829a0b850;hp=9965d5232e1c0c36de49006239656ccb13e4572a;hpb=8f0f47ad72cb8977d36e9690cd958f37825097d2;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 9965d5232..7c4c33938 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -79,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 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 + ((ent.classname == STR_PLAYER) ? ent.view_ofs : ((ent.mins + ent.maxs) * 0.5))) +#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 @@ -106,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; @@ -163,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. @@ -545,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"); @@ -573,10 +512,6 @@ void GetCvars(float f) self.cvar_cl_accuracy_data_share = boolean(self.cvar_cl_accuracy_data_share); self.cvar_cl_accuracy_data_receive = boolean(self.cvar_cl_accuracy_data_receive); -#ifdef ALLOW_FORCEMODELS - GetCvars_handleFloat(s, f, cvar_cl_forceplayermodels, "cl_forceplayermodels"); - GetCvars_handleFloat(s, f, cvar_cl_forceplayermodelsfromxonotic, "cl_forceplayermodelsfromxonotic"); -#endif GetCvars_handleFloatOnce(s, f, cvar_cl_gunalign, "cl_gunalign"); GetCvars_handleFloat(s, f, cvar_cl_allow_uid2name, "cl_allow_uid2name"); GetCvars_handleFloat(s, f, cvar_cl_allow_uidtracking, "cl_allow_uidtracking"); @@ -597,7 +532,7 @@ void GetCvars(float f) string playername(entity p) { string t; - if (teamplay && !intermission_running && p.classname == "player") + if (teamplay && !intermission_running && IS_PLAYER(p)) { t = Team_ColorCode(p.team); return strcat(t, strdecolorize(p.netname)); @@ -758,7 +693,7 @@ void readplayerstartcvars() s = cvar_string("g_weaponarena"); if (s == "0" || s == "") { - if(g_lms || g_ca) + if(g_ca) s = "most"; } @@ -832,26 +767,9 @@ void readplayerstartcvars() if (g_weaponarena) { - g_minstagib = 0; // incompatible - g_pinata = 0; // incompatible g_weapon_stay = 0; // incompatible WEPSET_COPY_AA(start_weapons, g_weaponarena_weapons); - if(!(g_lms || g_ca)) - start_items |= IT_UNLIMITED_AMMO; - } - else if (g_minstagib) - { - g_pinata = 0; // incompatible - g_weapon_stay = 0; // incompatible - g_bloodloss = 0; // incompatible - start_health = 100; - start_armorvalue = 0; - WEPSET_COPY_AW(start_weapons, WEP_MINSTANEX); - g_minstagib_invis_alpha = cvar("g_minstagib_invis_alpha"); - start_items |= IT_UNLIMITED_SUPERWEAPONS; - - if (g_minstagib_invis_alpha <= 0) - g_minstagib_invis_alpha = -1; + start_items |= IT_UNLIMITED_AMMO; } else { @@ -870,16 +788,8 @@ void readplayerstartcvars() if(!cvar("g_use_ammunition")) start_items |= IT_UNLIMITED_AMMO; - - if(cvar("g_nexball")) - start_items |= IT_UNLIMITED_SUPERWEAPONS; // FIXME BAD BAD BAD BAD HACK, NEXBALL SHOULDN'T ABUSE PORTO'S WEAPON SLOT - - if(g_minstagib) - { - start_ammo_cells = cvar("g_minstagib_ammo_start"); - start_ammo_fuel = cvar("g_start_ammo_fuel"); - } - else if(start_items & IT_UNLIMITED_WEAPON_AMMO) + + if(start_items & IT_UNLIMITED_WEAPON_AMMO) { start_ammo_rockets = 999; start_ammo_shells = 999; @@ -889,28 +799,11 @@ void readplayerstartcvars() } else { - if(g_lms || g_ca) - { - start_ammo_shells = cvar("g_lms_start_ammo_shells"); - start_ammo_nails = cvar("g_lms_start_ammo_nails"); - start_ammo_rockets = cvar("g_lms_start_ammo_rockets"); - start_ammo_cells = cvar("g_lms_start_ammo_cells"); - start_ammo_fuel = cvar("g_lms_start_ammo_fuel"); - } - else - { - start_ammo_shells = cvar("g_start_ammo_shells"); - start_ammo_nails = cvar("g_start_ammo_nails"); - start_ammo_rockets = cvar("g_start_ammo_rockets"); - start_ammo_cells = cvar("g_start_ammo_cells"); - start_ammo_fuel = cvar("g_start_ammo_fuel"); - } - } - - if (g_lms || g_ca) - { - start_health = cvar("g_lms_start_health"); - start_armorvalue = cvar("g_lms_start_armor"); + start_ammo_shells = cvar("g_start_ammo_shells"); + start_ammo_nails = cvar("g_start_ammo_nails"); + start_ammo_rockets = cvar("g_start_ammo_rockets"); + start_ammo_cells = cvar("g_start_ammo_cells"); + start_ammo_fuel = cvar("g_start_ammo_fuel"); } if (inWarmupStage) @@ -926,7 +819,7 @@ void readplayerstartcvars() WEPSET_COPY_AA(warmup_start_weapons_default, start_weapons_default); WEPSET_COPY_AA(warmup_start_weapons_defaultmask, start_weapons_defaultmask); - if (!g_weaponarena && !g_minstagib && !g_ca) + if (!g_weaponarena && !g_ca) { warmup_start_ammo_shells = cvar("g_warmup_start_ammo_shells"); warmup_start_ammo_cells = cvar("g_warmup_start_ammo_cells"); @@ -1001,51 +894,42 @@ 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; -float sv_pitch_min; -float sv_pitch_max; -float sv_pitch_fixyaw; - string GetGametype(); // g_world.qc void readlevelcvars(void) { - g_minstagib = cvar("g_minstagib"); - - // load ALL the mutators - if(cvar("g_dodging")) - MUTATOR_ADD(mutator_dodging); - if(cvar("g_spawn_near_teammate")) - MUTATOR_ADD(mutator_spawn_near_teammate); - if(cvar("g_physical_items")) - MUTATOR_ADD(mutator_physical_items); - if(!g_minstagib) - { - if(cvar("g_invincible_projectiles")) - MUTATOR_ADD(mutator_invincibleprojectiles); - if(cvar("g_new_toys")) - MUTATOR_ADD(mutator_new_toys); - if(cvar("g_nix")) - MUTATOR_ADD(mutator_nix); - if(cvar("g_rocket_flying")) - MUTATOR_ADD(mutator_rocketflying); - if(cvar("g_vampire")) - MUTATOR_ADD(mutator_vampire); - if(cvar("g_superspectate")) - MUTATOR_ADD(mutator_superspec); - } - - // is this a mutator? is this a mode? - if(cvar("g_sandbox")) - MUTATOR_ADD(sandbox); - + // load mutators + #define CHECK_MUTATOR_ADD(mut_cvar,mut_name,dependence) \ + { if(cvar(mut_cvar) && dependence) { MUTATOR_ADD(mut_name); } } + + CHECK_MUTATOR_ADD("g_dodging", mutator_dodging, 1); + CHECK_MUTATOR_ADD("g_spawn_near_teammate", mutator_spawn_near_teammate, 1); + CHECK_MUTATOR_ADD("g_physical_items", mutator_physical_items, 1); + CHECK_MUTATOR_ADD("g_touchexplode", mutator_touchexplode, 1); + CHECK_MUTATOR_ADD("g_minstagib", mutator_minstagib, 1); + CHECK_MUTATOR_ADD("g_invincible_projectiles", mutator_invincibleprojectiles, !cvar("g_minstagib")); + CHECK_MUTATOR_ADD("g_new_toys", mutator_new_toys, !cvar("g_minstagib")); + CHECK_MUTATOR_ADD("g_nix", mutator_nix, !cvar("g_minstagib")); + CHECK_MUTATOR_ADD("g_rocket_flying", mutator_rocketflying, !cvar("g_minstagib")); + CHECK_MUTATOR_ADD("g_vampire", mutator_vampire, !cvar("g_minstagib")); + CHECK_MUTATOR_ADD("g_superspectate", mutator_superspec, 1); + CHECK_MUTATOR_ADD("g_pinata", mutator_pinata, !cvar("g_minstagib")); + CHECK_MUTATOR_ADD("g_midair", mutator_midair, 1); + CHECK_MUTATOR_ADD("g_bloodloss", mutator_bloodloss, !cvar("g_minstagib")); + CHECK_MUTATOR_ADD("g_random_gravity", mutator_random_gravity, 1); + CHECK_MUTATOR_ADD("g_norecoil", mutator_norecoil, 1); + CHECK_MUTATOR_ADD("g_multijump", mutator_multijump, 1); + CHECK_MUTATOR_ADD("g_footsteps", mutator_footsteps, 1); + CHECK_MUTATOR_ADD("g_melee_only", mutator_melee_only, !cvar("g_minstagib")); + CHECK_MUTATOR_ADD("g_nades", mutator_nades, 1); + CHECK_MUTATOR_ADD("g_sandbox", sandbox, 1); + CHECK_MUTATOR_ADD("g_riflearena", mutator_riflearena, !cvar("g_minstagib")); + CHECK_MUTATOR_ADD("g_campcheck", mutator_campcheck, 1); + + #undef CHECK_MUTATOR_ADD + if(cvar("sv_allow_fullbright")) serverflags |= SERVERFLAG_ALLOW_FULLBRIGHT; @@ -1064,29 +948,16 @@ void readlevelcvars(void) g_bugrigs_speed_ref = cvar("g_bugrigs_speed_ref"); 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"); - -#ifdef ALLOW_FORCEMODELS - sv_clforceplayermodels = cvar("sv_clforceplayermodels"); -#endif + + g_minstagib = cvar("g_minstagib"); sv_clones = cvar("sv_clones"); sv_foginterval = cvar("sv_foginterval"); g_cloaked = cvar("g_cloaked"); if(g_cts) g_cloaked = 1; // always enable cloak in CTS - g_jump_grunt = cvar("g_jump_grunt"); - g_footsteps = cvar("g_footsteps"); g_grappling_hook = cvar("g_grappling_hook"); g_jetpack = cvar("g_jetpack"); - g_midair = cvar("g_midair"); - g_norecoil = cvar("g_norecoil"); - g_bloodloss = cvar("g_bloodloss"); sv_maxidle = cvar("sv_maxidle"); sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle"); sv_autotaunt = cvar("sv_autotaunt"); @@ -1097,7 +968,7 @@ void readlevelcvars(void) g_warmup_allguns = cvar("g_warmup_allguns"); g_warmup_allow_timeout = cvar("g_warmup_allow_timeout"); - if ((g_race && g_race_qualifying == 2) || g_runematch || g_arena || g_assault || cvar("g_campaign")) + if ((g_race && g_race_qualifying == 2) || g_arena || g_assault || cvar("g_campaign")) inWarmupStage = 0; // these modes cannot work together, sorry g_pickup_respawntime_weapon = cvar("g_pickup_respawntime_weapon"); @@ -1160,18 +1031,12 @@ void readlevelcvars(void) g_pickup_ammo_anyway = cvar("g_pickup_ammo_anyway"); g_pickup_weapons_anyway = cvar("g_pickup_weapons_anyway"); - g_pinata = cvar("g_pinata"); - g_weapon_stay = cvar(strcat("g_", GetGametype(), "_weapon_stay")); if(!g_weapon_stay) g_weapon_stay = cvar("g_weapon_stay"); - if not(inWarmupStage && !g_ca) - game_starttime = cvar("g_start_delay"); - - sv_pitch_min = cvar("sv_pitch_min"); - sv_pitch_max = cvar("sv_pitch_max"); - sv_pitch_fixyaw = cvar("sv_pitch_fixyaw"); + if not(inWarmupStage) + game_starttime = time + cvar("g_start_delay"); readplayerstartcvars(); } @@ -1207,7 +1072,7 @@ float sound_allowed(float dest, entity e) return TRUE; // sounds by players can be removed if (autocvar_bot_sound_monopoly) - if (clienttype(e) == CLIENTTYPE_REAL) + if (IS_REAL_CLIENT(e)) return FALSE; // anything else may pass return TRUE; @@ -1434,11 +1299,6 @@ void precache() { // gamemode related things precache_model ("models/misc/chatbubble.spr"); - if (g_runematch) - { - precache_model ("models/runematch/curse.mdl"); - precache_model ("models/runematch/rune.mdl"); - } #ifdef TTURRETS_ENABLED if (autocvar_g_turrets) @@ -1476,12 +1336,6 @@ void precache() precache_playermodel(s); } - if (g_footsteps) - { - PrecacheGlobalSound((globalsound_step = "misc/footstep0 6")); - PrecacheGlobalSound((globalsound_metalstep = "misc/metalfootstep0 6")); - } - // gore and miscellaneous sounds //precache_sound ("misc/h2ohit.wav"); precache_model ("models/hook.md3"); @@ -1556,6 +1410,8 @@ void precache() ambientsound ('0 0 0', self.noise, VOL_BASE, ATTN_NONE); } #endif + +#include "precache-for-csqc.inc" } // WARNING: this kills the trace globals @@ -2036,22 +1892,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; @@ -2651,8 +2491,3 @@ float isPushable(entity e) return TRUE; return FALSE; } - -void dedicated_print(string input) // print(), but only print if the server is not local -{ - if not(server_is_local) { print(input); } -}