From: drjaska Date: Tue, 7 Feb 2023 14:28:21 +0000 (+0200) Subject: Merge branch 'master' into drjaska/weapontodo X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fmerge-requests%2F1118%2Fhead;p=xonotic%2Fxonotic-data.pk3dir.git Merge branch 'master' into drjaska/weapontodo --- c0e7f2b2a54fdcfe90c00b40b65024f1b4d46994 diff --cc qcsrc/common/notifications/all.qh index 2df383ce2,9d39c2199..42d1867be --- a/qcsrc/common/notifications/all.qh +++ b/qcsrc/common/notifications/all.qh @@@ -632,9 -645,18 +645,9 @@@ string notif_arg_item_wepammo(float f1 { string ammoitems = ""; Weapon wep = REGISTRY_GET(Weapons, f1); - // TODO: registry handles - switch (wep.ammo_type) - { - case RES_SHELLS: ammoitems = ITEM_Shells.m_name; break; - case RES_BULLETS: ammoitems = ITEM_Bullets.m_name; break; - case RES_ROCKETS: ammoitems = ITEM_Rockets.m_name; break; - case RES_CELLS: ammoitems = ITEM_Cells.m_name; break; - case RES_PLASMA: ammoitems = ITEM_Plasma.m_name; break; - case RES_FUEL: ammoitems = ITEM_JetpackFuel.m_name; break; - default: return ""; // doesn't use ammo - } + if (GETAMMONAME(wep.ammo_type)) + ammoitems = GETAMMONAME(wep.ammo_type); - return sprintf(_(" with %d %s"), f2, ammoitems); + return sprintf(_(" with %d %s"), f2, strtolower(ammoitems)); } diff --cc qcsrc/common/weapons/all.qc index 819d44f08,effa087e6..29e21a762 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@@ -103,29 -107,20 +103,13 @@@ string W_NameWeaponOrder_MapFunc(strin return s; } - string W_UndeprecateName(string s) -string W_NameWeaponOrder(string order) --{ - switch (s) - { - case "nex": return "vortex"; - case "rocketlauncher": return "devastator"; - case "laser": return "blaster"; - case "minstanex": return "vaporizer"; - case "grenadelauncher": return "mortar"; - case "uzi": return "machinegun"; - case "hmg": return "okhmg"; - case "rpc": return "okrpc"; - default: return s; - } - return mapPriorityList(order, W_NameWeaponOrder_MapFunc); --} + string W_NumberWeaponOrder_MapFunc(string s) { if (s == "0" || stof(s)) return s; - s = W_UndeprecateName(s); - FOREACH(Weapons, it != WEP_Null && it.netname == s, return ftos(i)); + FOREACH(Weapons, it != WEP_Null && (it.netname == s || it.m_deprecated_netname == s), return ftos(i)); return s; } -string W_NumberWeaponOrder(string order) -{ - return mapPriorityList(order, W_NumberWeaponOrder_MapFunc); -} float W_FixWeaponOrder_BuildImpulseList_buf[REGISTRY_MAX(Weapons)]; string W_FixWeaponOrder_BuildImpulseList_order; diff --cc qcsrc/common/weapons/weapon.qh index a771bc9a0,cf0f637f0..06c23d9fb --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@@ -214,34 -216,22 +216,33 @@@ const int WEP_FLAG_SPECIALATTACK = BI string weaponorder_byid; // functions: - string W_UndeprecateName(string s); -string W_FixWeaponOrder(string order, float complete); -string W_NameWeaponOrder(string order); -string W_NumberWeaponOrder(string order); +#define W_FIXWEAPONORDER(order, complete) fixPriorityList(order, WEP_FIRST, WEP_LAST, WEP_IMPULSE_BEGIN - WEP_FIRST, complete) +string W_NameWeaponOrder_MapFunc(string s); +string W_NumberWeaponOrder_MapFunc(string s); +#define W_NAMEWEAPONORDER(order) mapPriorityList(order, W_NameWeaponOrder_MapFunc) +#define W_NUMBERWEAPONORDER(order) mapPriorityList(order, W_NumberWeaponOrder_MapFunc) string W_FixWeaponOrder_BuildImpulseList(string o); string W_FixWeaponOrder_AllowIncomplete(entity this, string order); -string W_FixWeaponOrder_ForceComplete(string order); WepSet W_RandomWeapons(entity e, WepSet remaining, int n); - -string GetAmmoPicture(Resource ammotype); - -string GetAmmoName(Resource ammotype); - -entity GetAmmoItem(Resource ammotype); +#define W_FIXWEAPONORDER_FORCECOMPLETE(order) \ + W_FIXWEAPONORDER(((order == "") ? W_NUMBERWEAPONORDER(cvar_defstring("cl_weaponpriority")) : order), 1) #ifdef CSQC -int GetAmmoStat(Resource ammotype); +#define GETAMMOTYPEFROMNUM(i) \ + i == 0 ? RES_SHELLS : \ + i == 1 ? RES_BULLETS : \ + i == 2 ? RES_ROCKETS : \ + i == 3 ? RES_CELLS : \ + i == 4 ? RES_PLASMA : \ + i == 5 ? RES_FUEL : RES_NONE + +#define GETAMMOSTAT(res) \ + res == RES_SHELLS ? STAT_SHELLS : \ + res == RES_BULLETS ? STAT_NAILS : \ + res == RES_ROCKETS ? STAT_ROCKETS : \ + res == RES_CELLS ? STAT_CELLS : \ + res == RES_PLASMA ? STAT_PLASMA.m_id : \ + res == RES_FUEL ? STAT_FUEL.m_id : -1 #endif string W_Sound(string w_snd); diff --cc qcsrc/server/items/items.qc index adb11faa3,6b653d9c3..877e831da --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@@ -826,19 -852,16 +852,16 @@@ float ammo_pickupevalfunc(entity player float c = 0; float rating = 0; - // Detect needed ammo + // detect needed ammo if(item.itemdef.instanceOfWeaponPickup) { - entity ammo = NULL; - if(GetResource(item, RES_SHELLS)) { need_shells = true; ammo = ITEM_Shells; } - else if(GetResource(item, RES_BULLETS)) { need_nails = true; ammo = ITEM_Bullets; } - else if(GetResource(item, RES_ROCKETS)) { need_rockets = true; ammo = ITEM_Rockets; } - else if(GetResource(item, RES_CELLS)) { need_cells = true; ammo = ITEM_Cells; } - else if(GetResource(item, RES_PLASMA)) { need_plasma = true; ammo = ITEM_Plasma; } - else if(GetResource(item, RES_FUEL)) { need_fuel = true; ammo = ITEM_JetpackFuel; } - + entity res = item.itemdef.m_weapon.ammo_type; - entity ammo = (res != RES_NONE) ? GetAmmoItem(res) : NULL; ++ entity ammo = (res != RES_NONE) ? GETAMMOITEM(res) : NULL; if(!ammo) return 0; + if(res != RES_NONE && GetResource(item, res)) + item_resource = res; + wpn = item; rating = ammo.m_botvalue; } @@@ -1289,7 -1294,7 +1295,7 @@@ spawnfunc(target_items { FOREACH(StatusEffect, it.instanceOfBuff, { - s = Buff_UndeprecateName(s); - string s = Buff_CompatName(argv(j)); ++ s = Buff_CompatName(s); if(s == it.netname) { this.buffdef = it; @@@ -1299,8 -1304,8 +1305,8 @@@ } }); FOREACH(Weapons, it != WEP_Null, { - s = W_UndeprecateName(s); - if(s == it.netname) - string s = argv(j); ++ s = argv(j); + if(s == it.netname || s == it.m_deprecated_netname) { STAT(WEAPONS, this) |= (it.m_wepset); if(this.spawnflags == 0 || this.spawnflags == 2) @@@ -1365,8 -1370,8 +1371,8 @@@ n = tokenize_console(this.netname); for(int j = 0; j < n; ++j) { - string cmd = argv(j); - FOREACH(Weapons, it != WEP_Null && (cmd == it.netname || cmd == it.m_deprecated_netname), { + string s = argv(j); - FOREACH(Weapons, it != WEP_Null && W_UndeprecateName(s) == it.netname, { ++ FOREACH(Weapons, it != WEP_Null && (s == it.netname || s == it.m_deprecated_netname), { it.wr_init(it); break; }); @@@ -1670,9 -1675,9 +1676,9 @@@ float GiveItems(entity e, float beginar got += GiveBuff(e, it, op, val); break; }); - FOREACH(Weapons, it != WEP_Null && W_UndeprecateName(cmd) == it.netname, { + FOREACH(Weapons, it != WEP_Null && (cmd == it.netname || cmd == it.m_deprecated_netname), { - got += GiveWeapon(e, it.m_id, op, val); - break; + got += GiveWeapon(e, it.m_id, op, val); + break; }); break; }