X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmiscfunctions.qc;h=e2d6bd0af76c5d5500c3838dec8b00f5a098bcec;hb=773883ab5d3e9d165fe2ee5784c96720e0cd392c;hp=48208fdeae4ad01a93d3286b2a5e7813ba86ee19;hpb=d8e541e5cabb4e7981c0ab2e86f859440f0138f1;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 48208fdea..e2d6bd0af 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) { @@ -67,6 +66,16 @@ float DistributeEvenly_Get(float weight) DistributeEvenly_amount -= f; return f; } +float DistributeEvenly_GetRandomized(float weight) +{ + float f; + if (weight <= 0) + return 0; + f = floor(random() + DistributeEvenly_amount * weight / DistributeEvenly_totalweight); + DistributeEvenly_totalweight -= weight; + DistributeEvenly_amount -= f; + return f; +} #define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e) @@ -85,9 +94,12 @@ string STR_OBSERVER = "observer"; #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 CENTER_OR_VIEWOFS(ent) (ent.origin + ((ent.classname == STR_PLAYER) ? 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 @@ -598,85 +610,6 @@ void backtrace(string msg) 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) { @@ -772,7 +705,6 @@ float warmup_start_ammo_fuel; float warmup_start_health; float warmup_start_armorvalue; float g_weapon_stay; -float g_ghost_items; entity get_weaponinfo(float w); @@ -1120,7 +1052,9 @@ void readlevelcvars(void) if(cvar("g_rocket_flying")) MUTATOR_ADD(mutator_rocketflying); if(cvar("g_vampire")) - MUTATOR_ADD(mutator_vampire); + MUTATOR_ADD(mutator_vampire); + if(cvar("g_superspectate")) + MUTATOR_ADD(mutator_superspec); } // is this a mutator? is this a mode? @@ -1157,7 +1091,6 @@ void readlevelcvars(void) #endif sv_clones = cvar("sv_clones"); - sv_gentle = cvar("sv_gentle"); sv_foginterval = cvar("sv_foginterval"); g_cloaked = cvar("g_cloaked"); if(g_cts) @@ -1248,11 +1181,6 @@ void readlevelcvars(void) if(!g_weapon_stay) g_weapon_stay = cvar("g_weapon_stay"); - g_ghost_items = cvar("g_ghost_items"); - - if(g_ghost_items >= 1) - g_ghost_items = 0.25; // default alpha value - if not(inWarmupStage && !g_ca) game_starttime = cvar("g_start_delay"); @@ -1648,34 +1576,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() @@ -2401,8 +2301,8 @@ vector shotorg_adjust_values(vector vecs, float y_is_right, float visual, float { if (visual) { - vecs_y = 0; - vecs_z -= 2; + if (autocvar_g_shootfromclient) { vecs = shotorg_adjustfromclient(vecs, y_is_right, (autocvar_g_shootfromclient >= 2), algn); } + else { vecs_y = 0; vecs_z -= 2; } } else { @@ -2807,3 +2707,8 @@ 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); } +}