X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fmiscfunctions.qh;h=634d3fb647185594e04001b18c1b1790ecf17942;hp=8b94ffe9345e3b32e4c97de767ae31389c94cc57;hb=252f4ca05841fb1d01caa95e266fd8fe1db68c58;hpb=267433aa7d5dd80399b808f692b8bc1ef75f0851 diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index 8b94ffe934..634d3fb647 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -1,14 +1,12 @@ -#ifndef MISCFUNCTIONS_H -#define MISCFUNCTIONS_H +#pragma once -#include "t_items.qh" +#include #include "mutators/events.qh" -#include "mutators/gamemode_race.qh" -#include "../common/constants.qh" -#include "../common/mapinfo.qh" -#include "../common/turrets/all.qh" +#include +#include +#include #ifdef RELEASE #define cvar_string_normal builtin_cvar_string @@ -34,19 +32,12 @@ float cvar_normal(string n) entity eliminatedPlayers; void EliminatedPlayers_Init(float(entity) isEliminated_func); -string admin_name(void); +string admin_name(); void write_recordmarker(entity pl, float tstart, float dt); void play2all(string samp); -void DistributeEvenly_Init(float amount, float totalweight); -float DistributeEvenly_Get(float weight); - -void modeleffect_spawn(string m, float s, float f, vector o, vector v, vector ang, vector angv, float s0, float s2, float a, float t1, float t2); - -void shockwave_spawn(string m, vector org, float sz, float t1, float t2); - void play2team(float t, string filename); void GetCvars_handleFloat(string thisname, float f, .float field, string name); @@ -63,15 +54,9 @@ void InitializeEntitiesRun(); void stopsoundto(float _dest, entity e, float chan); void soundtoat(float _dest, entity e, vector o, float chan, string samp, float vol, float _atten); -float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float d); -vector shotorg_adjust(vector vecs, float y_is_right, float visual); - -float DistributeEvenly_amount; -float DistributeEvenly_totalweight; void objerror(string s); void droptofloor(); -void() SUB_Remove; void attach_sameorigin(entity e, entity to, string tag); @@ -91,7 +76,7 @@ void GameLogInit(); void GameLogClose(); -void GetCvars(float f); +void GetCvars(entity this, float f); string GetMapname(); @@ -119,8 +104,6 @@ void remove_unsafely(entity e); void SetMovetypeFollow(entity ent, entity e); -vector shotorg_adjust_values(vector vecs, float y_is_right, float visual, float algn); - void soundto(float dest, entity e, float chan, string samp, float vol, float atten); void stopsound(entity e, float chan); @@ -133,38 +116,14 @@ void WarpZone_crosshair_trace(entity pl); void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag); +#define IS_DEAD(s) ((s).deadflag != DEAD_NO) + #define ITEM_TOUCH_NEEDKILL() (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)) -#define ITEM_DAMAGE_NEEDKILL(dt) (((dt) == DEATH_HURTTRIGGER) || ((dt) == DEATH_SLIME) || ((dt) == DEATH_LAVA) || ((dt) == DEATH_SWAMP)) +#define ITEM_DAMAGE_NEEDKILL(dt) (((dt) == DEATH_HURTTRIGGER.m_id) || ((dt) == DEATH_SLIME.m_id) || ((dt) == DEATH_LAVA.m_id) || ((dt) == DEATH_SWAMP.m_id)) #define PROJECTILE_TOUCH if(WarpZone_Projectile_Touch()) return -const string STR_PLAYER = "player"; -const string STR_SPECTATOR = "spectator"; -const string STR_OBSERVER = "observer"; - -#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 IS_MONSTER(v) (v.flags & FL_MONSTER) -#define IS_VEHICLE(v) (v.vehicle_flags & VHF_ISVEHICLE) -#define IS_TURRET(v) (v.turret_flags & TUR_FLAG_ISTURRET) - -#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(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 (!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 FOR_EACH_MONSTER(v) for(v = world; (v = findflags(v, flags, FL_MONSTER)) != world; ) - #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) @@ -173,13 +132,12 @@ string strcat1(string s) = #115; // FRIK_FILE float logfile_open; float logfile; -#define strstr strstrofs /* // NOTE: DO NOT USE THIS FUNCTION TOO OFTEN. // IT WILL MOST PROBABLY DESTROY _ALL_ OTHER TEMP // STRINGS AND TAKE QUITE LONG. haystack and needle MUST // BE CONSTANT OR strzoneD! -float strstr(string haystack, string needle, float offset) +float strstrofs(string haystack, string needle, float offset) { float len, endpos; string found; @@ -282,56 +240,19 @@ float g_weapon_stay; float want_weapon(entity weaponinfo, float allguns); // WEAPONTODO: what still needs done? void readplayerstartcvars(); -float g_bugrigs; -float g_bugrigs_planar_movement; -float g_bugrigs_planar_movement_car_jumping; -float g_bugrigs_reverse_spinning; -float g_bugrigs_reverse_speeding; -float g_bugrigs_reverse_stopping; -float g_bugrigs_air_steering; -float g_bugrigs_angle_smoothing; -float g_bugrigs_friction_floor; -float g_bugrigs_friction_brake; -float g_bugrigs_friction_air; -float g_bugrigs_accel; -float g_bugrigs_speed_ref; -float g_bugrigs_speed_pow; -float g_bugrigs_steer; - float sv_autotaunt; float sv_taunt; string GetGametype(); // g_world.qc -void mutators_add(); // mutators.qc -void readlevelcvars(void) +void readlevelcvars() { - // load mutators - mutators_add(); - if(cvar("sv_allow_fullbright")) serverflags |= SERVERFLAG_ALLOW_FULLBRIGHT; - g_bugrigs = cvar("g_bugrigs"); - g_bugrigs_planar_movement = cvar("g_bugrigs_planar_movement"); - g_bugrigs_planar_movement_car_jumping = cvar("g_bugrigs_planar_movement_car_jumping"); - g_bugrigs_reverse_spinning = cvar("g_bugrigs_reverse_spinning"); - g_bugrigs_reverse_speeding = cvar("g_bugrigs_reverse_speeding"); - g_bugrigs_reverse_stopping = cvar("g_bugrigs_reverse_stopping"); - g_bugrigs_air_steering = cvar("g_bugrigs_air_steering"); - g_bugrigs_angle_smoothing = cvar("g_bugrigs_angle_smoothing"); - g_bugrigs_friction_floor = cvar("g_bugrigs_friction_floor"); - g_bugrigs_friction_brake = cvar("g_bugrigs_friction_brake"); - g_bugrigs_friction_air = cvar("g_bugrigs_friction_air"); - g_bugrigs_accel = cvar("g_bugrigs_accel"); - 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_instagib = cvar("g_instagib"); sv_clones = cvar("sv_clones"); sv_foginterval = cvar("sv_foginterval"); - g_cloaked = cvar("g_cloaked"); g_footsteps = cvar("g_footsteps"); g_jetpack = cvar("g_jetpack"); sv_maxidle = cvar("sv_maxidle"); @@ -340,12 +261,12 @@ void readlevelcvars(void) sv_taunt = cvar("sv_taunt"); warmup_stage = cvar("g_warmup"); - g_warmup_limit = cvar("g_warmup_limit"); + warmup_limit = cvar("g_warmup_limit"); g_warmup_allguns = cvar("g_warmup_allguns"); g_warmup_allow_timeout = cvar("g_warmup_allow_timeout"); - if ((g_race && g_race_qualifying == 2) || g_assault || cvar("g_campaign")) - warmup_stage = 0; // these modes cannot work together, sorry + if(cvar("g_campaign")) + warmup_stage = 0; // no warmup during campaign g_pickup_respawntime_weapon = cvar("g_pickup_respawntime_weapon"); g_pickup_respawntime_superweapon = cvar("g_pickup_respawntime_superweapon"); @@ -413,30 +334,18 @@ void readlevelcvars(void) if(!g_weapon_stay) g_weapon_stay = cvar("g_weapon_stay"); + MUTATOR_CALLHOOK(ReadLevelCvars); + if (!warmup_stage) game_starttime = time + cvar("g_start_delay"); - for(int i = WEP_FIRST; i <= WEP_LAST; ++i) { - Weapon w = get_weaponinfo(i); - w.wr_init(w); - } + FOREACH(Weapons, it != WEP_Null, LAMBDA(it.wr_init(it))); readplayerstartcvars(); } //#NO AUTOCVARS END - -// Sound functions -//string precache_sound (string s) = #19; -// hack -float precache_sound_index (string s) = #19; - -const float SND_VOLUME = 1; -const float SND_ATTENUATION = 2; -const float SND_LARGEENTITY = 8; -const float SND_LARGESOUND = 16; - const float INITPRIO_FIRST = 0; const float INITPRIO_GAMETYPE = 0; const float INITPRIO_GAMETYPE_FALLBACK = 1; @@ -446,7 +355,7 @@ const float INITPRIO_SETLOCATION = 90; const float INITPRIO_LINKDOORS = 91; const float INITPRIO_LAST = 99; -.void(void) initialize_entity; +.void(entity this) initialize_entity; .float initialize_entity_order; .entity initialize_entity_next; entity initialize_entity_first; @@ -456,8 +365,5 @@ entity initialize_entity_first; float sound_allowed(float dest, entity e); -void InitializeEntity(entity e, void(void) func, float order); -void SetCustomizer(entity e, float(void) customizer, void(void) uncustomizer); -void Net_LinkEntity(entity e, bool docull, float dt, bool(entity, int) sendfunc); - -#endif +void InitializeEntity(entity e, void(entity this) func, float order); +void SetCustomizer(entity e, float() customizer, void() uncustomizer);