]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/bot_waypoints
authorterencehill <piuntn@gmail.com>
Sat, 19 Aug 2017 15:26:44 +0000 (17:26 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 19 Aug 2017 15:26:44 +0000 (17:26 +0200)
15 files changed:
qcsrc/client/main.qc
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc
qcsrc/common/monsters/sv_spawn.qc
qcsrc/common/state.qc
qcsrc/lib/_all.inc
qcsrc/server/bot/default/aim.qc
qcsrc/server/client.qh
qcsrc/server/command/cmd.qc
qcsrc/server/compat/quake3.qc
qcsrc/server/impulse.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/miscfunctions.qh
qcsrc/server/mutators/mutator/gamemode_assault.qc
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/selection.qh

index 323ebb3516147bce98cc49f0d8286c2ec85324b1..64b340622a16a2ee2a3ea5f87d98efb97b1d3ea6 100644 (file)
@@ -108,6 +108,11 @@ void CSQC_Init()
                maxclients = i;
        }
 
+       // needs to be done so early because of the constants they create
+       static_init();
+       static_init_late();
+       static_init_precache();
+
        binddb = db_create();
        tempdb = db_create();
        ClientProgsDB = db_load("client.db");
index 223a81f7c4d4dfb6039a3ea6b2189b0df864dfd0..9992a37f4ce032faa7f25549728ff5d3303846a2 100644 (file)
@@ -1377,8 +1377,8 @@ void havocbot_goalrating_ons_controlpoints_attack(entity this, float ratingscale
                        best.cnt += 1;
 
                        this.havocbot_attack_time = 0;
-                       if(checkpvs(this.view_ofs,cp))
-                       if(checkpvs(this.view_ofs,best))
+                       if(checkpvs(this.origin + this.view_ofs, cp))
+                       if(checkpvs(this.origin + this.view_ofs, best))
                                this.havocbot_attack_time = time + 2;
                }
                else
@@ -1448,8 +1448,8 @@ bool havocbot_goalrating_ons_generator_attack(entity this, float ratingscale)
                        bestwp.cnt += 1;
 
                        this.havocbot_attack_time = 0;
-                       if(checkpvs(this.view_ofs,g))
-                       if(checkpvs(this.view_ofs,bestwp))
+                       if(checkpvs(this.origin + this.view_ofs, g))
+                       if(checkpvs(this.origin + this.view_ofs, bestwp))
                                this.havocbot_attack_time = time + 5;
 
                        return true;
index 4bbe2ce3d8f8a94fc336a0165e8009d0c16b0767..d6989ad31839d52229cc8f612879fd6c83ab8686 100644 (file)
@@ -16,11 +16,12 @@ entity spawnmonster (entity e, string monster, int monster_id, entity spawnedby,
        //if(invincible) { e.spawnflags |= MONSTERFLAG_INVINCIBLE; }
 
        setorigin(e, orig);
+       bool allow_any = boolean(monster == "anyrandom");
 
-       if(monster == "random")
+       if(monster == "random" || allow_any)
        {
                RandomSelection_Init();
-               FOREACH(Monsters, it != MON_Null && !(it.spawnflags & MONSTER_TYPE_PASSIVE) && !(it.spawnflags & MON_FLAG_HIDDEN),
+               FOREACH(Monsters, it != MON_Null && (allow_any || (!(it.spawnflags & MONSTER_TYPE_PASSIVE) && !(it.spawnflags & MON_FLAG_HIDDEN))),
                {
                        RandomSelection_AddEnt(it, 1, 1);
                });
index 3bd6c60ae0aec624d079ffa8557d3eded634fc28..ea936185b95ee2b1227a58be5664a7e2ecfda30c 100644 (file)
@@ -25,7 +25,7 @@ void PlayerState_detach(entity this)
     Inventory_delete(this);
 }
 
-void GetCvars(entity this, int);
+void GetCvars(entity this, entity store, int);
 void DecodeLevelParms(entity this);
 void PlayerScore_Attach(entity this);
 void ClientData_Attach(entity this);
@@ -40,7 +40,7 @@ void ClientState_attach(entity this)
 {
        this._cs = NEW(ClientState, this);
 
-    GetCvars(this, 0);  // get other cvars from player
+    GetCvars(this, CS(this), 0);  // get other cvars from player
 
        // TODO: fold all of these into ClientState
 
@@ -69,7 +69,7 @@ void PlayerScore_Detach(entity this);
 
 void ClientState_detach(entity this)
 {
-    GetCvars(this, -1);  // free cvars TODO: is this still needed now that it's stored on the clientstate entity?
+    GetCvars(this, CS(this), -1);  // free cvars TODO: is this still needed now that it's stored on the clientstate entity?
     accuracy_free(this); // TODO: needs to be before CS() is deleted!
     PlayerScore_Detach(this); // what ^they^ said
     W_HitPlotClose(this);
index d8f07455a28c7766065c6b6e0737020a4758a5e4..4da78f1444eb27b397d926442c7a153012adf01e 100644 (file)
@@ -250,13 +250,7 @@ void make_safe_for_remove(entity this);
 
 #ifdef CSQC
        void _CSQC_Init();
-       void CSQC_Init()
-       {
-               static_init();
-               static_init_late();
-               static_init_precache();
-               if (_CSQC_Init) _CSQC_Init();
-       }
+       void CSQC_Init() { if (_CSQC_Init) _CSQC_Init(); }
        #define CSQC_Init _CSQC_Init
 
        void _CSQC_Shutdown();
index feb19afe1f921b25fec4c0422555482c70ff1b43..8f2abb3f824b5745448a5fb4c16ab21545e5451b 100644 (file)
@@ -307,7 +307,7 @@ float bot_aimdir(entity this, vector v, float maxfiredeviation)
        //dprint("e ", vtos(diffang), " < ", ftos(maxfiredeviation), "\n");
 
        // decide whether to fire this time
-       if ((normalize(v) * shotdir) >= cos(maxfiredeviation * DEG2RAD))
+       if (v * shotdir >= cos(maxfiredeviation * DEG2RAD))
        if(vdist(trace_endpos-shotorg, <, 500 + 500 * bound(0, skill + this.bot_aggresskill, 10)) || random()*random()>bound(0,(skill+this.bot_aggresskill)*0.05,1))
                this.bot_firetimer = time + bound(0.1, 0.5-(skill+this.bot_aggresskill)*0.05, 0.5);
        //traceline(shotorg,shotorg+shotdir*1000,false,NULL);
index 614916019f60c4c385851febb2d25c8e102d38ad..9674872c0faa42bd6bc0c1a466204a0c166d9b08 100644 (file)
@@ -141,6 +141,8 @@ CLASS(Client, Object)
     ATTRIB(Client, cvar_cl_multijump, bool, this.cvar_cl_multijump);
     ATTRIB(Client, cvar_cl_accuracy_data_share, bool, this.cvar_cl_accuracy_data_share);
     ATTRIB(Client, cvar_cl_accuracy_data_receive, bool, this.cvar_cl_accuracy_data_receive);
+    ATTRIBARRAY(Client, cvar_cl_weaponpriorities, string, 10);
+    ATTRIB(Client, cvar_cl_weaponpriority, string, this.cvar_cl_weaponpriority);
 
     METHOD(Client, m_unwind, bool(Client this));
 
index 50250f9a5c2974bfb246dc3eff04dd0f2b18d346..a2c037c5d2d198573a8c5eb63eb7e388560df8bf 100644 (file)
@@ -454,7 +454,7 @@ void ClientCommand_sentcvar(entity caller, float request, float argc, string com
                                        tokenize_console(s);
                                }
 
-                               GetCvars(caller, 1);
+                               GetCvars(caller, CS(caller), 1);
 
                                return;
                        }
index 532428dd08893eb39a78c033b51850f43f3904dd..2e2301d0bdec150704ae2b6f297beddbda5870a2 100644 (file)
@@ -118,35 +118,23 @@ void target_give_init(entity this)
        {
                if (it.classname == "weapon_rocketlauncher" || it.classname == "weapon_devastator") {
                        this.ammo_rockets += it.count * WEP_CVAR(devastator, ammo);
-                       this.netname = "devastator";
+                       this.netname = cons(this.netname, "devastator");
                }
                else if (it.classname == "weapon_lightning") {
                        this.ammo_cells += it.count * WEP_CVAR_PRI(electro, ammo); // WEAPONTODO
-                       if(this.netname == "")
-                               this.netname = "electro";
-                       else
-                               this.netname = strcat(this.netname, " electro");
+                       this.netname = cons(this.netname, "electro");
                }
                else if (it.classname == "weapon_plasmagun") {
                        this.ammo_rockets += it.count * WEP_CVAR_PRI(hagar, ammo); // WEAPONTODO
-                       if(this.netname == "")
-                               this.netname = "hagar";
-                       else
-                               this.netname = strcat(this.netname, " hagar");
+                       this.netname = cons(this.netname, "hagar");
                }
                else if (it.classname == "weapon_bfg") {
                        this.ammo_cells += it.count * WEP_CVAR_PRI(crylink, ammo);
-                       if(this.netname == "")
-                               this.netname = "crylink";
-                       else
-                               this.netname = strcat(this.netname, " crylink");
+                       this.netname = cons(this.netname, "crylink");
                }
                else if (it.classname == "weapon_grenadelauncher" || it.classname == "weapon_mortar") {
                        this.ammo_rockets += it.count * WEP_CVAR_PRI(mortar, ammo); // WEAPONTODO
-                       if(this.netname == "")
-                               this.netname = "mortar";
-                       else
-                               this.netname = strcat(this.netname, " mortar");
+                       this.netname = cons(this.netname, "mortar");
                }
                else if (it.classname == "item_armor_body")
                        this.armorvalue = 100;
index f528f07b4eb32c9537c798ce6afc727cc6c955c4..588b794c812c35a22a45fc7ed88f0fcaf0010309 100644 (file)
@@ -97,7 +97,7 @@ X(0)
                for(int wepslot = 0; wepslot < MAX_WEAPONSLOTS; ++wepslot) \
                { \
                        .entity weaponentity = weaponentities[wepslot]; \
-                       W_CycleWeapon(this, this.cvar_cl_weaponpriorities[slot], dir, weaponentity); \
+                       W_CycleWeapon(this, CS(this).cvar_cl_weaponpriorities[slot], dir, weaponentity); \
                        if(wepslot == 0 && autocvar_g_weaponswitch_debug != 1) \
                                break; \
                } \
index 38d8926371282ba17882a2f623da0427673b29a9..78d290c81131bce368b9aa3711f32b9fc54b9516 100644 (file)
@@ -292,37 +292,37 @@ Called with:
   0:  sends the request
   >0: receives a cvar from name=argv(f) value=argv(f+1)
 */
-void GetCvars_handleString(entity this, string thisname, float f, .string field, string name)
+void GetCvars_handleString(entity this, entity store, string thisname, float f, .string field, string name)
 {
        if (f < 0)
        {
-               if (this.(field))
-                       strunzone(this.(field));
-               this.(field) = string_null;
+               if (store.(field))
+                       strunzone(store.(field));
+               store.(field) = string_null;
        }
        else if (f > 0)
        {
                if (thisname == name)
                {
-                       if (this.(field))
-                               strunzone(this.(field));
-                       this.(field) = strzone(argv(f + 1));
+                       if (store.(field))
+                               strunzone(store.(field));
+                       store.(field) = strzone(argv(f + 1));
                }
        }
        else
                stuffcmd(this, strcat("cl_cmd sendcvar ", name, "\n"));
 }
-void GetCvars_handleString_Fixup(entity this, string thisname, float f, .string field, string name, string(entity, string) func)
+void GetCvars_handleString_Fixup(entity this, entity store, string thisname, float f, .string field, string name, string(entity, string) func)
 {
-       GetCvars_handleString(this, thisname, f, field, name);
+       GetCvars_handleString(this, store, thisname, f, field, name);
        if (f >= 0) // also initialize to the fitting value for "" when sending cvars out
                if (thisname == name)
                {
-                       string s = func(this, strcat1(this.(field)));
-                       if (s != this.(field))
+                       string s = func(this, strcat1(store.(field)));
+                       if (s != store.(field))
                        {
-                               strunzone(this.(field));
-                               this.(field) = strzone(s);
+                               strunzone(store.(field));
+                               store.(field) = strzone(s);
                        }
                }
 }
@@ -339,7 +339,7 @@ void GetCvars_handleFloat(entity this, entity store, string thisname, float f, .
        else
                stuffcmd(this, strcat("cl_cmd sendcvar ", name, "\n"));
 }
-void GetCvars_handleFloatOnce(entity this, string thisname, float f, .float field, string name)
+void GetCvars_handleFloatOnce(entity this, entity store, string thisname, float f, .float field, string name)
 {
        if (f < 0)
        {
@@ -348,17 +348,17 @@ void GetCvars_handleFloatOnce(entity this, string thisname, float f, .float fiel
        {
                if (thisname == name)
                {
-                       if (!this.(field))
+                       if (!store.(field))
                        {
-                               this.(field) = stof(argv(f + 1));
-                               if (!this.(field))
-                                       this.(field) = -1;
+                               store.(field) = stof(argv(f + 1));
+                               if (!store.(field))
+                                       store.(field) = -1;
                        }
                }
        }
        else
        {
-               if (!this.(field))
+               if (!store.(field))
                        stuffcmd(this, strcat("cl_cmd sendcvar ", name, "\n"));
        }
 }
@@ -408,7 +408,7 @@ REPLICATE(cvar_g_xonoticversion, string, "g_xonoticversion");
 /**
  * @param f -1: cleanup, 0: request, 1: receive
  */
-void GetCvars(entity this, int f)
+void GetCvars(entity this, entity store, int f)
 {
        string s = string_null;
 
@@ -421,21 +421,21 @@ void GetCvars(entity this, int f)
 
        Notification_GetCvars(this);
 
-       ReplicateVars(this, CS(this), s, f);
-
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriority, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[0], "cl_weaponpriority0", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[1], "cl_weaponpriority1", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[2], "cl_weaponpriority2", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[3], "cl_weaponpriority3", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[4], "cl_weaponpriority4", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[5], "cl_weaponpriority5", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[6], "cl_weaponpriority6", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[7], "cl_weaponpriority7", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[8], "cl_weaponpriority8", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[9], "cl_weaponpriority9", W_FixWeaponOrder_AllowIncomplete);
-
-       GetCvars_handleFloat(this, CS(this), s, f, cvar_cl_allow_uidtracking, "cl_allow_uidtracking");
+       ReplicateVars(this, store, s, f);
+
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriority, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[0], "cl_weaponpriority0", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[1], "cl_weaponpriority1", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[2], "cl_weaponpriority2", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[3], "cl_weaponpriority3", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[4], "cl_weaponpriority4", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[5], "cl_weaponpriority5", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[6], "cl_weaponpriority6", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[7], "cl_weaponpriority7", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[8], "cl_weaponpriority8", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[9], "cl_weaponpriority9", W_FixWeaponOrder_AllowIncomplete);
+
+       GetCvars_handleFloat(this, store, s, f, cvar_cl_allow_uidtracking, "cl_allow_uidtracking");
 
        // fixup of switchweapon (needed for LMS or when spectating is disabled, as PutClientInServer comes too early)
        if (f > 0)
index abe8cd74a6c78c5aac70029d0acf971ce6e590a0..1c01a573797713c4fe39345da3f895e60717aad9 100644 (file)
@@ -44,7 +44,7 @@ void GetCvars_handleFloat(entity this, entity store, string thisname, float f, .
 
 float spamsound(entity e, float chan, Sound samp, float vol, float _atten);
 
-void GetCvars_handleString(entity this, string thisname, float f, .string field, string name);
+void GetCvars_handleString(entity this, entity store, string thisname, float f, .string field, string name);
 
 void precache_all_playermodels(string pattern);
 
@@ -75,7 +75,7 @@ void GameLogInit();
 
 void GameLogClose();
 
-void GetCvars(entity this, float f);
+void GetCvars(entity this, entity store, int f);
 
 string GetMapname();
 
index 85801af52a8fc900db8fcff339c2b6b153c5226d..bd88131d31b2ddfa6e6e2a81aac0e55c63a7ec37 100644 (file)
@@ -429,8 +429,8 @@ void havocbot_goalrating_ast_targets(entity this, float ratingscale)
 
                        this.havocbot_attack_time = 0;
 
-                       if(checkpvs(this.view_ofs,it))
-                       if(checkpvs(this.view_ofs,best))
+                       if(checkpvs(this.origin + this.view_ofs, it))
+                       if(checkpvs(this.origin + this.view_ofs, best))
                        {
                        //      dprint("increasing attack time for this target\n");
                                this.havocbot_attack_time = time + 2;
index 791d65915be989f9982b9d080024a860d13fab43..776d8d8d0f43800999a3b10829cb3c9c20cc2d93 100644 (file)
@@ -290,7 +290,7 @@ void W_CycleWeapon(entity this, string weaponorder, float dir, .entity weaponent
 void W_NextWeaponOnImpulse(entity this, float imp, .entity weaponentity)
 {
        float w;
-       w = W_GetCycleWeapon(this, this.cvar_cl_weaponpriority, +1, imp, 1, (CS(this).cvar_cl_weaponimpulsemode == 0), weaponentity);
+       w = W_GetCycleWeapon(this, CS(this).cvar_cl_weaponpriority, +1, imp, 1, (CS(this).cvar_cl_weaponimpulsemode == 0), weaponentity);
        if(w > 0)
                W_SwitchWeapon(this, Weapons_from(w), weaponentity);
 }
@@ -303,7 +303,7 @@ void W_NextWeapon(entity this, int list, .entity weaponentity)
        else if(list == 1)
                W_CycleWeapon(this, this.weaponorder_byimpulse, -1, weaponentity);
        else if(list == 2)
-               W_CycleWeapon(this, this.cvar_cl_weaponpriority, -1, weaponentity);
+               W_CycleWeapon(this, CS(this).cvar_cl_weaponpriority, -1, weaponentity);
 }
 
 // prev weapon
@@ -314,7 +314,7 @@ void W_PreviousWeapon(entity this, float list, .entity weaponentity)
        else if(list == 1)
                W_CycleWeapon(this, this.weaponorder_byimpulse, +1, weaponentity);
        else if(list == 2)
-               W_CycleWeapon(this, this.cvar_cl_weaponpriority, +1, weaponentity);
+               W_CycleWeapon(this, CS(this).cvar_cl_weaponpriority, +1, weaponentity);
 }
 
 // previously used if exists and has ammo, (second) best otherwise
index ea580e9118671e128bd03d45795e4dba6625e87c..eea33ddb7b98e71c762a7fc09f9d7f41856c7558 100644 (file)
@@ -12,7 +12,7 @@ bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andam
 .int weaponcomplainindex;
 float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, float complain, float skipmissing, .entity weaponentity);
 
-#define w_getbestweapon(ent,wepent) Weapons_from(W_GetCycleWeapon(ent, ent.cvar_cl_weaponpriority, 0, -1, false, true, wepent))
+#define w_getbestweapon(ent,wepent) Weapons_from(W_GetCycleWeapon(ent, CS(ent).cvar_cl_weaponpriority, 0, -1, false, true, wepent))
 
 void W_SwitchWeapon_Force(Player this, Weapon w, .entity weaponentity);