From: terencehill Date: Sat, 19 Aug 2017 15:26:44 +0000 (+0200) Subject: Merge branch 'master' into terencehill/bot_waypoints X-Git-Tag: xonotic-v0.8.5~2378^2~79 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=5a7362e456f39815970f1d71cfc8822446e3cb60;hp=ce60d9f94ee138e703382c08383c5d837e6ab1cc;p=xonotic%2Fxonotic-data.pk3dir.git Merge branch 'master' into terencehill/bot_waypoints --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 323ebb351..64b340622 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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"); diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index 223a81f7c..9992a37f4 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -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; diff --git a/qcsrc/common/monsters/sv_spawn.qc b/qcsrc/common/monsters/sv_spawn.qc index 4bbe2ce3d..d6989ad31 100644 --- a/qcsrc/common/monsters/sv_spawn.qc +++ b/qcsrc/common/monsters/sv_spawn.qc @@ -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); }); diff --git a/qcsrc/common/state.qc b/qcsrc/common/state.qc index 3bd6c60ae..ea936185b 100644 --- a/qcsrc/common/state.qc +++ b/qcsrc/common/state.qc @@ -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); diff --git a/qcsrc/lib/_all.inc b/qcsrc/lib/_all.inc index d8f07455a..4da78f144 100644 --- a/qcsrc/lib/_all.inc +++ b/qcsrc/lib/_all.inc @@ -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(); diff --git a/qcsrc/server/bot/default/aim.qc b/qcsrc/server/bot/default/aim.qc index feb19afe1..8f2abb3f8 100644 --- a/qcsrc/server/bot/default/aim.qc +++ b/qcsrc/server/bot/default/aim.qc @@ -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); diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 614916019..9674872c0 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -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)); diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 50250f9a5..a2c037c5d 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -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; } diff --git a/qcsrc/server/compat/quake3.qc b/qcsrc/server/compat/quake3.qc index 532428dd0..2e2301d0b 100644 --- a/qcsrc/server/compat/quake3.qc +++ b/qcsrc/server/compat/quake3.qc @@ -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; diff --git a/qcsrc/server/impulse.qc b/qcsrc/server/impulse.qc index f528f07b4..588b794c8 100644 --- a/qcsrc/server/impulse.qc +++ b/qcsrc/server/impulse.qc @@ -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; \ } \ diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 38d892637..78d290c81 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -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) diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index abe8cd74a..1c01a5737 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -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(); diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qc b/qcsrc/server/mutators/mutator/gamemode_assault.qc index 85801af52..bd88131d3 100644 --- a/qcsrc/server/mutators/mutator/gamemode_assault.qc +++ b/qcsrc/server/mutators/mutator/gamemode_assault.qc @@ -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; diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index 791d65915..776d8d8d0 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -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 diff --git a/qcsrc/server/weapons/selection.qh b/qcsrc/server/weapons/selection.qh index ea580e911..eea33ddb7 100644 --- a/qcsrc/server/weapons/selection.qh +++ b/qcsrc/server/weapons/selection.qh @@ -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);