]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/miscfunctions.qc
Merge branch 'master' into mirceakitsune/sandbox
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / miscfunctions.qc
index 3bb6e6b7ca0d65d9472b1d905e67e870735a6b03..2c089617277e583dbf44ab6914bcb6d9010b1431 100644 (file)
@@ -8,6 +8,21 @@ void crosshair_trace(entity pl)
 {
        traceline_antilag(pl, pl.cursor_trace_start, pl.cursor_trace_start + normalize(pl.cursor_trace_endpos - pl.cursor_trace_start) * MAX_SHOT_DISTANCE, MOVE_NORMAL, pl, ANTILAG_LATENCY(pl));
 }
+void crosshair_trace_plusvisibletriggers(entity pl)
+{
+       entity first;
+       entity e;
+       first = findchainfloat(solid, SOLID_TRIGGER);
+
+       for (e = first; e; e = e.chain)
+               if (e.model != "")
+                       e.solid = SOLID_BSP;
+
+       crosshair_trace(pl);
+
+       for (e = first; e; e = e.chain)
+               e.solid = SOLID_TRIGGER;
+}
 void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
 void WarpZone_crosshair_trace(entity pl)
 {
@@ -79,53 +94,6 @@ string strcat1(string s) = #115; // FRIK_FILE
 float logfile_open;
 float logfile;
 
-string GetAdvancedDeathReports(entity enPlayer) // Extra fragmessage information
-{
-       float nPlayerHealth = rint(enPlayer.health);
-       float nPlayerArmor = rint(enPlayer.armorvalue);
-       float nPlayerHandicap = enPlayer.cvar_cl_handicap;
-       float nPlayerPing = rint(enPlayer.ping);
-       string strPlayerPingColor;
-       string strMessage;
-       
-       if(nPlayerPing >= 150)
-               strPlayerPingColor = "^1";
-       else
-               strPlayerPingColor = "^2";
-
-       if((autocvar_sv_fragmessage_information_stats) && (enPlayer.health >= 1))
-               strMessage = strcat(strMessage, "^7(Health ^1", ftos(nPlayerHealth), "^7 / Armor ^2", ftos(nPlayerArmor), "^7)");
-
-       if(autocvar_sv_fragmessage_information_ping) {
-               if(clienttype(enPlayer) == CLIENTTYPE_BOT) // Bots have no ping
-                       strMessage = strcat(strMessage, " ^7(^2Bot");
-               else
-                       strMessage = strcat(strMessage, " ^7(Ping ", strPlayerPingColor, ftos(nPlayerPing), "ms");
-               if(autocvar_sv_fragmessage_information_handicap)
-                       if(autocvar_sv_fragmessage_information_handicap == 2)
-                               if(nPlayerHandicap <= 1)
-                                       strMessage = strcat(strMessage, "^7 / Handicap ^2Off^7)");
-                               else
-                                       strMessage = strcat(strMessage, "^7 / Handicap ^2", ftos(nPlayerHandicap), "^7)");
-                       else if not(nPlayerHandicap <= 1)
-                               strMessage = strcat(strMessage, "^7 / Handicap ^2", ftos(nPlayerHandicap), "^7)");
-               else
-                       strMessage = strcat(strMessage, "^7)");
-       } else if(autocvar_sv_fragmessage_information_handicap) {
-               if(autocvar_sv_fragmessage_information_handicap == 2)
-                       if(nPlayerHandicap <= 1)
-                               strMessage = strcat(strMessage, "^7(Handicap ^2Off^7)");
-                       else
-                               strMessage = strcat(strMessage, "^7(Handicap ^2", ftos(nPlayerHandicap), "^7)");
-               else if(nPlayerHandicap > 1)
-                       strMessage = strcat(strMessage, "^7(Handicap ^2", ftos(nPlayerHandicap), "^7)");
-       }
-       
-       if(strMessage) // add new line to the beginning if there is a message
-               strMessage = strcat("\n", strMessage);
-               
-       return strMessage;
-}
 void bcenterprint(string s)
 {
     // TODO replace by MSG_ALL (would show it to spectators too, though)?
@@ -367,13 +335,13 @@ void spawnfunc_target_location()
     self.classname = "target_location";
     // location name in netname
     // eventually support: count, teamgame selectors, line of sight?
-};
+}
 
 void spawnfunc_info_location()
 {
     self.classname = "target_location";
     self.message = self.netname;
-};
+}
 
 string NearestLocation(vector p)
 {
@@ -583,6 +551,7 @@ void GetCvars(float f)
        get_cvars_s = s;
        MUTATOR_CALLHOOK(GetCvars);
        GetCvars_handleFloat(s, f, autoswitch, "cl_autoswitch");
+       GetCvars_handleFloat(s, f, cvar_cl_autoscreenshot, "cl_autoscreenshot");
        GetCvars_handleFloat(s, f, cvar_cl_playerdetailreduction, "cl_playerdetailreduction");
        GetCvars_handleString(s, f, cvar_g_xonoticversion, "g_xonoticversion");
        GetCvars_handleFloat(s, f, cvar_cl_handicap, "cl_handicap");
@@ -616,6 +585,8 @@ void GetCvars(float f)
        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");
+       GetCvars_handleFloat(s, f, cvar_cl_movement_track_canjump, "cl_movement_track_canjump");
+       GetCvars_handleFloat(s, f, cvar_cl_newusekeysupported, "cl_newusekeysupported");
 
        // fixup of switchweapon (needed for LMS or when spectating is disabled, as PutClientInServer comes too early)
        if (f > 0)
@@ -738,13 +709,13 @@ string playername(entity p)
 
 vector randompos(vector m1, vector m2)
 {
-    local vector v;
+    vector v;
     m2 = m2 - m1;
     v_x = m2_x * random() + m1_x;
     v_y = m2_y * random() + m1_y;
     v_z = m2_z * random() + m1_z;
     return  v;
-};
+}
 
 //#NO AUTOCVARS START
 
@@ -1120,6 +1091,8 @@ string GetGametype(); // g_world.qc
 void readlevelcvars(void)
 {
        // first load all the mutators
+       if(cvar("g_invincible_projectiles"))
+               MUTATOR_ADD(mutator_invincibleprojectiles);
        if(cvar("g_nix"))
                MUTATOR_ADD(mutator_nix);
        if(cvar("g_dodging"))
@@ -1128,6 +1101,8 @@ void readlevelcvars(void)
                MUTATOR_ADD(mutator_rocketflying);
        if(cvar("g_vampire"))
                MUTATOR_ADD(mutator_vampire);
+       if(cvar("g_sandbox"))
+               MUTATOR_ADD(sandbox);
 
        if(cvar("sv_allow_fullbright"))
                serverflags |= SERVERFLAG_ALLOW_FULLBRIGHT;
@@ -1179,7 +1154,6 @@ void readlevelcvars(void)
        g_bloodloss = cvar("g_bloodloss");
        sv_maxidle = cvar("sv_maxidle");
        sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle");
-       sv_pogostick = cvar("sv_pogostick");
        g_ctf_reverse = cvar("g_ctf_reverse");
        sv_autotaunt = cvar("sv_autotaunt");
        sv_taunt = cvar("sv_taunt");
@@ -1256,9 +1230,6 @@ void readlevelcvars(void)
     if(!g_weapon_stay)
         g_weapon_stay = cvar("g_weapon_stay");
 
-       if (!g_weapon_stay && (cvar("deathmatch") == 2))
-               g_weapon_stay = 1;
-
        g_ghost_items = cvar("g_ghost_items");
 
        if(g_ghost_items >= 1)
@@ -1292,7 +1263,9 @@ float sound_allowed(float dest, entity e)
     {
         if (e.classname == "body")
             e = e.enemy;
-        if (e.owner && e.owner != e)
+       else if (e.realowner && e.realowner != e)
+            e = e.realowner;
+       else if (e.owner && e.owner != e)
             e = e.owner;
         else
             break;
@@ -1458,7 +1431,7 @@ float spamsound(entity e, float chan, string samp, float vol, float atten)
 
 void play2team(float t, string filename)
 {
-    local entity head;
+    entity head;
 
     if (autocvar_bot_sound_monopoly)
         return;
@@ -1632,7 +1605,7 @@ void precache()
     if(autocvar_sv_precacheweapons)
     {
         //precache weapon models/sounds
-        local float wep;
+        float wep;
         wep = WEP_FIRST;
         while (wep <= WEP_LAST)
         {
@@ -1673,8 +1646,7 @@ void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration,
                msg_entity = e;
                WRITESPECTATABLE_MSG_ONE({
                        WriteByte(MSG_ONE, SVC_TEMPENTITY);
-                       WriteByte(MSG_ONE, TE_CSQC_NOTIFY);
-                       WriteByte(MSG_ONE, CSQC_CENTERPRINT_GENERIC);
+                       WriteByte(MSG_ONE, TE_CSQC_CENTERPRINT_GENERIC);
                        WriteByte(MSG_ONE, id);
                        WriteString(MSG_ONE, s);
                        if (id != 0 && s != "")
@@ -2017,6 +1989,7 @@ float SUB_NoImpactCheck()
 #define SUB_OwnerCheck() (other && (other == self.owner))
 
 void RemoveGrapplingHook(entity pl);
+void W_Crylink_Dequeue(entity e);
 float WarpZone_Projectile_Touch_ImpactFilter_Callback()
 {
        if(SUB_OwnerCheck())
@@ -2025,6 +1998,11 @@ float WarpZone_Projectile_Touch_ImpactFilter_Callback()
        {
                if(self.classname == "grapplinghook")
                        RemoveGrapplingHook(self.realowner);
+               else if(self.classname == "spike")
+               {
+                       W_Crylink_Dequeue(self);
+                       remove(self);
+               }
                else
                        remove(self);
                return TRUE;
@@ -2040,7 +2018,6 @@ float MAX_IPBAN_URIS           = 16;
 float URI_GET_DISCARD          = 0;
 float URI_GET_IPBAN            = 1;
 float URI_GET_IPBAN_END        = 16;
-float URI_GET_PLAYERSTATS_SENT = 17;
 
 void URI_Get_Callback(float id, float status, string data)
 {
@@ -2061,10 +2038,6 @@ void URI_Get_Callback(float id, float status, string data)
         // online ban list
         OnlineBanList_URI_Get_Callback(id, status, data);
     }
-    else if (id == URI_GET_PLAYERSTATS_SENT)
-    {
-        PlayerStats_Sent_URI_Get_Callback(id, status, data);
-    }
     else
     {
         print("Received HTTP request data for an invalid id ", ftos(id), ".\n");
@@ -2081,7 +2054,19 @@ void print_to(entity e, string s)
 
 string uid2name(string myuid) {
        string s;
-       s = db_get(ServerProgsDB, strcat("uid2name", myuid));
+       s = db_get(ServerProgsDB, strcat("/uid2name/", myuid));
+
+       // FIXME remove this later after 0.6 release
+       // convert old style broken records to correct style
+       if(s == "")
+       {
+               s = db_get(ServerProgsDB, strcat("uid2name", myuid));
+               if(s != "")
+               {
+                       db_put(ServerProgsDB, strcat("/uid2name/", myuid), s);
+                       db_put(ServerProgsDB, strcat("uid2name", myuid), "");
+               }
+       }
        
        if(s == "")
                s = "^1Unregistered Player";
@@ -2470,6 +2455,7 @@ float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, f
 {
     float m, i;
     vector start, org, delta, end, enddown, mstart;
+    entity sp;
 
     m = e.dphitcontentsmask;
     e.dphitcontentsmask = goodcontents | badcontents;
@@ -2522,6 +2508,19 @@ float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, f
         if (trace_fraction >= 1)
             continue;
 
+       // rule 4: we must "see" some spawnpoint
+       for(sp = world; (sp = find(sp, classname, "info_player_deathmatch")); )
+               if(checkpvs(mstart, sp))
+                       break;
+       if(!sp)
+       {
+               for(sp = world; (sp = findflags(sp, flags, FL_ITEM)); )
+                       if(checkpvs(mstart, sp))
+                               break;
+               if(!sp)
+                       continue;
+       }
+
         // find a random vector to "look at"
         end_x = org_x + random() * delta_x;
         end_y = org_y + random() * delta_y;