Beyond 48 weapons, help is needed. (Code help) (ChaosEsqueAnthology) (Xonotic Mod)
In the Xonotic mod, ChaosEsque Anthology (https://sourceforge.net/p/chaosesqueanthology/discussion/general/thread/... ) help on the code is needed
The current code allows up to 48 weapons. With the addition of the morgenstern 48 weapons have been reached (no, weapons will not be removed to make way for others).
Divverent, of Xonotic, Nexuiz, and Darkplaces fame, created the macro code to support 48 weapons. This was an extension of the previous 24 weapon code. When I last talked to him he said that a further extension was trivial, simply follow the pattern of the existing macro code and extend it.
The problem comes from a simple fact that I, and perhaps others, have come to realize is unbreachable: I, your host, am simply not very smart. There are many things I cannot fathom. I get by by sticking to one thing and hammering away at it untill I understand it enough. It took me four years to learn quake C sufficiently to effortlessly move around the code without frustration. Four years.
That is a long time for learning a programming language.
The code that needs to be extended resides in the common directory of the quake C source, specifically the items header file:
qcsrc/common/items.qh
(accessable by web git if you wish here: http://chaosesqueanthology.git.sourceforge.net/git/gitweb.cgi?p=chaosesq... )
The code block in question starts at line 93, but note, the code that the anthology uses starts at line 127, note the maxcount 48 (we are using two weapon sets here, we need to extend it to three to add more weapons):
```
[code]
#define WEP_FIRST 1
float WEP_COUNT;
float WEP_LAST;
#if 0
# define WEP_MAXCOUNT 24
// default storage
.float _WS_weapons;
# define WEPSET_BIT(a) power2of((a) - WEP_FIRST)
# define WEPSET_DECLARE_A(a) float _WS_##a
# define WEPSET_CLEAR_E(e) ((e)._WS_weapons = 0)
# define WEPSET_CLEAR_A(a) (_WS_##a = 0)
# define WEPSET_EMPTY_E(e) ((e)._WS_weapons == 0)
# define WEPSET_EMPTY_A(a) (_WS_##a == 0)
# define WEPSET_COPY_AS(a) (_WS_##a = getstati(STAT_WEAPONS))
# define WEPSET_ADDSTAT() addstat(STAT_WEAPONS, AS_INT, _WS_weapons)
# define WEPSET_WRITE_E(dest,a) WriteInt24_t(dest, (a)._WS_weapons)
# define WEPSET_WRITE_A(dest,a) WriteInt24_t(dest, _WS_##a)
# define WEPSET_WRITE_W(dest,a) WriteInt24_t(dest, WEPSET_BIT(a))
# define WEPSET_READ_E(a) (a)._WS_weapons = ReadInt24_t()
# define WEPSET_READ_A(a) (_WS_##a) = ReadInt24_t()
# define WEPSET_OP1_EE(a,b,mergeop,x) ((a)._WS_weapons x (b)._WS_weapons)
# define WEPSET_OP2_EE(a,b,mergeop,x,y) ((a)._WS_weapons x (b)._WS_weapons y (a)._WS_weapons)
# define WEPSET_OP1_EA(a,b,mergeop,x) ((a)._WS_weapons x _WS_##b)
# define WEPSET_OP2_EA(a,b,mergeop,x,y) ((a)._WS_weapons x _WS_##b y (a)._WS_weapons)
# define WEPSET_OP1_EW(a,b,mergeop,x) ((a)._WS_weapons x WEPSET_BIT(b))
# define WEPSET_OP2_EW(a,b,mergeop,x,y) ((a)._WS_weapons x WEPSET_BIT(b) y (a)._WS_weapons)
# define WEPSET_OP1_AE(a,b,mergeop,x) (_WS_##a x (b)._WS_weapons)
# define WEPSET_OP2_AE(a,b,mergeop,x,y) (_WS_##a x (b)._WS_weapons y _WS_##a)
# define WEPSET_OP1_AA(a,b,mergeop,x) (_WS_##a x _WS_##b)
# define WEPSET_OP2_AA(a,b,mergeop,x,y) (_WS_##a x _WS_##b y _WS_##a)
# define WEPSET_OP1_AW(a,b,mergeop,x) (_WS_##a x WEPSET_BIT(b))
# define WEPSET_OP2_AW(a,b,mergeop,x,y) (_WS_##a x WEPSET_BIT(b) y _WS_##a)
#else
# define WEP_MAXCOUNT 48
# define WEP_FIRST2 25
.float _WS1_weapons;
.float _WS2_weapons;
# define WEPSET_BIT1(a) (((a) < WEP_FIRST2) ? power2of((a) - WEP_FIRST) : 0)
# define WEPSET_BIT2(a) (((a) >= WEP_FIRST2) ? power2of((a) - WEP_FIRST2) : 0)
# define WEPSET_DECLARE_A(a) float _WS1_##a, _WS2_##a
# define WEPSET_CLEAR_E(e) ((e)._WS1_weapons = (e)._WS2_weapons = 0)
# define WEPSET_CLEAR_A(a) ((_WS1_##a) = (_WS2_##a) = 0)
# define WEPSET_EMPTY_E(e) ((e)._WS1_weapons == 0 && (e)._WS2_weapons == 0)
# define WEPSET_EMPTY_A(a) ((_WS1_##a) == 0 && (_WS2_##a) == 0)
# define WEPSET_COPY_AS(a) ((_WS1_##a) = getstati(STAT_WEAPONS), (_WS2_##a) = getstati(STAT_WEAPONS2))
# define WEPSET_ADDSTAT() addstat(STAT_WEAPONS, AS_INT, _WS1_weapons); addstat(STAT_WEAPONS2, AS_INT, _WS2_weapons)
# define WEPSET_WRITE_E(dest,a) WriteInt24_t(dest, (a)._WS1_weapons); WriteInt24_t(dest, (a)._WS2_weapons)
# define WEPSET_WRITE_A(dest,a) WriteInt24_t(dest, _WS1_##a); WriteInt24_t(dest, _WS2_##a)
# define WEPSET_WRITE_W(dest,a) WriteInt24_t(dest, WEPSET_BIT1(a)); WriteInt24_t(dest, WEPSET_BIT2(a))
# define WEPSET_READ_E(a) (a)._WS1_weapons = ReadInt24_t(); (a)._WS2_weapons = ReadInt24_t()
# define WEPSET_READ_A(a) (_WS1_##a) = ReadInt24_t(); (_WS2_##a) = ReadInt24_t()
# define WEPSET_OP1_EE(a,b,mergeop,x) (((a)._WS1_weapons x (b)._WS1_weapons) mergeop ((a)._WS2_weapons x (b)._WS2_weapons))
# define WEPSET_OP2_EE(a,b,mergeop,x,y) (((a)._WS1_weapons x (b)._WS1_weapons y (a)._WS1_weapons) mergeop ((a)._WS2_weapons x (b)._WS2_weapons y (a)._WS2_weapons))
# define WEPSET_OP1_EA(a,b,mergeop,x) (((a)._WS1_weapons x _WS1_##b) mergeop ((a)._WS2_weapons x _WS2_##b))
# define WEPSET_OP2_EA(a,b,mergeop,x,y) (((a)._WS1_weapons x _WS1_##b y (a)._WS1_weapons) mergeop ((a)._WS2_weapons x _WS2_##b y (a)._WS2_weapons))
# define WEPSET_OP1_EW(a,b,mergeop,x) (((a)._WS1_weapons x WEPSET_BIT1(b)) mergeop ((a)._WS2_weapons x WEPSET_BIT2(b)))
# define WEPSET_OP2_EW(a,b,mergeop,x,y) (((a)._WS1_weapons x WEPSET_BIT1(b) y (a)._WS1_weapons) mergeop ((a)._WS2_weapons x WEPSET_BIT2(b) y (a)._WS2_weapons))
# define WEPSET_OP1_AE(a,b,mergeop,x) ((_WS1_##a x (b)._WS1_weapons) mergeop (_WS2_##a x (b)._WS2_weapons))
# define WEPSET_OP2_AE(a,b,mergeop,x,y) ((_WS1_##a x (b)._WS1_weapons y _WS1_##a) mergeop (_WS2_##a x (b)._WS2_weapons y _WS2_##a))
# define WEPSET_OP1_AA(a,b,mergeop,x) ((_WS1_##a x _WS1_##b) mergeop (_WS2_##a x _WS2_##b))
# define WEPSET_OP2_AA(a,b,mergeop,x,y) ((_WS1_##a x _WS1_##b y _WS1_##a) mergeop (_WS2_##a x _WS2_##b y _WS2_##a))
# define WEPSET_OP1_AW(a,b,mergeop,x) ((_WS1_##a x WEPSET_BIT1(b)) mergeop (_WS2_##a x WEPSET_BIT2(b)))
# define WEPSET_OP2_AW(a,b,mergeop,x,y) ((_WS1_##a x WEPSET_BIT1(b) y _WS1_##a) mergeop (_WS2_##a x WEPSET_BIT2(b) y _WS2_##a))
#endif
#define XX ,
#define WEPSET_COPY_EE(a,b) WEPSET_OP1_EE(a,b,XX,=)
#define WEPSET_EQ_EE(a,b) WEPSET_OP1_EE(a,b,&&,==)
#define WEPSET_OR_EE(a,b) WEPSET_OP1_EE(a,b,XX,|=)
#define WEPSET_AND_EE(a,b) WEPSET_OP2_EE(a,b,XX,=,&)
#define WEPSET_ANDNOT_EE(a,b) WEPSET_OP1_EE(a,b,XX,&~=)
#define WEPSET_CONTAINS_ANY_EE(a,b) !!(WEPSET_OP1_EE(a,b,||,&))
#define WEPSET_CONTAINS_ALL_EE(a,b) WEPSET_OP2_EE(b,a,&&,==,&)
#define WEPSET_COPY_EA(a,b) WEPSET_OP1_EA(a,b,XX,=)
#define WEPSET_EQ_EA(a,b) WEPSET_OP1_EA(a,b,&&,==)
#define WEPSET_OR_EA(a,b) WEPSET_OP1_EA(a,b,XX,|=)
#define WEPSET_AND_EA(a,b) WEPSET_OP2_EA(a,b,XX,=,&)
#define WEPSET_ANDNOT_EA(a,b) WEPSET_OP1_EA(a,b,XX,&~=)
#define WEPSET_CONTAINS_ANY_EA(a,b) !!(WEPSET_OP1_EA(a,b,||,&))
#define WEPSET_CONTAINS_ALL_EA(a,b) WEPSET_OP2_EA(b,a,&&,==,&)
#define WEPSET_COPY_EW(a,b) WEPSET_OP1_EW(a,b,XX,=)
#define WEPSET_EQ_EW(a,b) WEPSET_OP1_EW(a,b,&&,==)
#define WEPSET_OR_EW(a,b) WEPSET_OP1_EW(a,b,XX,|=)
#define WEPSET_AND_EW(a,b) WEPSET_OP2_EW(a,b,XX,=,&)
#define WEPSET_ANDNOT_EW(a,b) WEPSET_OP1_EW(a,b,XX,&~=)
#define WEPSET_CONTAINS_EW(a,b) !!(WEPSET_OP1_EW(a,b,||,&))
#define WEPSET_COPY_AE(a,b) WEPSET_OP1_AE(a,b,XX,=)
#define WEPSET_EQ_AE(a,b) WEPSET_OP1_AE(a,b,&&,==)
#define WEPSET_OR_AE(a,b) WEPSET_OP1_AE(a,b,XX,|=)
#define WEPSET_AND_AE(a,b) WEPSET_OP2_AE(a,b,XX,=,&)
#define WEPSET_ANDNOT_AE(a,b) WEPSET_OP1_AE(a,b,XX,&~=)
#define WEPSET_CONTAINS_ANY_AE(a,b) !!(WEPSET_OP1_AE(a,b,||,&))
#define WEPSET_CONTAINS_ALL_AE(a,b) WEPSET_OP2_AE(b,a,&&,==,&)
#define WEPSET_COPY_AA(a,b) WEPSET_OP1_AA(a,b,XX,=)
#define WEPSET_EQ_AA(a,b) WEPSET_OP1_AA(a,b,&&,==)
#define WEPSET_OR_AA(a,b) WEPSET_OP1_AA(a,b,XX,|=)
#define WEPSET_AND_AA(a,b) WEPSET_OP2_AA(a,b,XX,=,&)
#define WEPSET_ANDNOT_AA(a,b) WEPSET_OP1_AA(a,b,XX,&~=)
#define WEPSET_CONTAINS_ANY_AA(a,b) !!(WEPSET_OP1_AA(a,b,||,&))
#define WEPSET_CONTAINS_ALL_AA(a,b) WEPSET_OP2_AA(b,a,&&,==,&)
#define WEPSET_COPY_AW(a,b) WEPSET_OP1_AW(a,b,XX,=)
#define WEPSET_EQ_AW(a,b) WEPSET_OP1_AW(a,b,&&,==)
#define WEPSET_OR_AW(a,b) WEPSET_OP1_AW(a,b,XX,|=)
#define WEPSET_AND_AW(a,b) WEPSET_OP2_AW(a,b,XX,=,&)
#define WEPSET_ANDNOT_AW(a,b) WEPSET_OP1_AW(a,b,XX,&~=)
#define WEPSET_CONTAINS_AW(a,b) !!(WEPSET_OP1_AW(a,b,||,&))
WEPSET_DECLARE_A(WEPBIT_ALL);
WEPSET_DECLARE_A(WEPBIT_SUPERWEAPONS);
// note: the fabs call is just there to hide "if result is constant" warning
#define REGISTER_WEAPON_2(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
float id; \
float func(float); \
void RegisterWeapons_##id() \
{ \
WEP_LAST = (id = WEP_FIRST + WEP_COUNT); \
WEPSET_OR_AW(WEPBIT_ALL, id); \
if(fabs(weapontype & WEP_FLAG_SUPERWEAPON)) \
WEPSET_OR_AW(WEPBIT_SUPERWEAPONS, id); \
++WEP_COUNT; \
register_weapon(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname); \
} \
ACCUMULATE_FUNCTION(RegisterWeapons, RegisterWeapons_##id)
#ifdef MENUQC
#define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
REGISTER_WEAPON_2(WEP_##id,w_null,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
#else
#define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
REGISTER_WEAPON_2(WEP_##id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
#endif
#include "../server/w_all.qc"
#undef REGISTER_WEAPON
ACCUMULATE_FUNCTION(RegisterWeapons, register_weapons_done)
string W_FixWeaponOrder(string order, float complete);
string W_NumberWeaponOrder(string order);
string W_NameWeaponOrder(string order);
string W_FixWeaponOrder_BuildImpulseList(string o);
string W_FixWeaponOrder_AllowIncomplete(string order);
string W_FixWeaponOrder_ForceComplete(string order);
void W_RandomWeapons(entity e, float n);
[/code]
```
How? I don't know, but if you do, please tell!
it's unlikely that anyone knows something so specific. you might get lucky by *searching* on stackoverflow.com (i wouldn't submit this as an answer, it will probably get closed) or on gamedev.stackexchange for quakec help. sorry to say
I probably won't be able to help, but I am a little curious, I like the style of the code in the link you provided and would like to poke a around a little more.
Do you have a link to the actual repo? I tried the link below, but it appears empty?
https://sourceforge.net/p/chaosesqueanthology/xonotic-data.pk3dir/ref/ma...
Maybe a "#elseif 1" before the "# define WEP_MAXCOUNT 48", and then before the "#endif" define a new set of weapons, begining with a "#else"? Well presuming the "if 0" is representing an integer and not a bool, else you might have to increment the WEP_MAXCOUNT define.... would help if there was more code....
It is the item.h code in:
chaosesqueanthology/xonotic-data.pk3dir/qcsrc/common/
Some links to folder
http//chaosesqueanthology.git.sourceforge.net/git/gitweb.cgi?p=chaosesqueanthology/xonotic-data.pk3dir;a=tree;f=qcsrc/common;h=6fb57e17ec6836b59bd7960fd13a11227140418a;hb=HEAD
Link to file:
http//chaosesqueanthology.git.sourceforge.net/git/gitweb.cgi?p=chaosesqueanthology/xonotic-data.pk3dir;a=blob;f=qcsrc/common/items.qh;h=7108f50b51165c656aad9f1e9b7f1c0a6a1dc757;hb=HEAD
The code needs to be extended in the pattern it was.
The =0 code is the old 24 weapon code,
the next (larger) code is the 48 weapon code (has 2 weaponsets)
We must make code like that but supporting 3 weaponsets rather than 2 or 1.
The items.qh file has also been posted here at the end:
http//dev.xonotic.org/issues/1970
At some point Xonotic added support for 72 weapons (though they use only about 15, so this is for mods).
We need to look at their code and add what is needed to the code we are using.
(ex: another addstat for a 3rd weaponset, probably changes to the statistics code too)
http//git.xonotic.org/?p=xonotic/xonotic-data.pk3dir.git;a=blob;f=qcsrc/common/items.qh;h=264c9ca73bd56070b6a41d69e0a359ea0f1503db;hb=HEAD;js=1
http//git.xonotic.org/?p=xonotic/xonotic-data.pk3dir.git;a=blob;f=qcsrc/common/items.qc;h=19173079fa0f1b1b198323c3d6a1b1f7c61e8b7f;hb=HEAD;js=1
VS code we are using:
chaosesqueanthology.git.sourceforge.net/git/gitweb.cgi?http//chaosesqueanthology.git.sourceforge.net/git/gitweb.cgi?p=chaosesqueanthology/xonotic-data.pk3dir;a=blob;f=qcsrc/common/items.qh;h=7108f50b51165c656aad9f1e9b7f1c0a6a1dc757;hb=HEADp=chaosesqueanthology/xonotic-data.pk3dir;a=blob;f=qcsrc/common/items.qh;h=7108f50b51165c656aad9f1e9b7f1c0a6a1dc757;hb=HEAD
We can't just drop in replacement, as the code has diverged. We must study the two and apply what we learn.
(The engine has diverged too, ex: more recent darkplaces engines do not support iqm as fully as older ones, complex iqm models exported by the official exporter show up invisible in modern darkplaces engine and water reflections don't seem to work right on bleeding edge DarkPlaces on intel gfx chips,so we stick with the slightly older branch of darkplaces and backport things for the source and linux compiles)
The response I got on the support request was from Samuel (the person who dominates and controls regular xonotic now) "figure it out yourself you stupid twat". Samuel codes a lot but for all his programming he rarely makes anything new. He rewrites already written code and for that thinks he's the savior of xonotic when he's strangling it. He was the reason chaosesque forked off from xonotic proper. His changes cause too many bugs and general instability. (Not to mention the difficulty in keeping up with that pace of churn)
now back to divverent's code... these merge ops in the code can we add a third piece to it like one could do with multiplication or no
weapon code is in cl weapons qc. And cl weapon system qc
help is needed as Samuel is correct: I'm a stupid twat so please help figure out this code so more weapons can be added
@chaosesqueteam: Wow. I thought maybe you were paraphrasing Samual's reply, but that was his actual verbatim response on the Xonotic bug tracker.
What a dick.
Keep at it, and don't let one egomaniacal douchebag get to you - you've got most of the pieces here, and just need to figure out how to put them together. Nobody starts out as a prodigy, and I'd take a hard-working mid-level programmer with a good attitude over a 'genius' who drives away enthusiastic contributors any day of the week.
My project: Bits & Bots
One note, in the commit comment for the current xonotic weapons code divverent notes that since gmqcc supports various bit level ops he has removed the weaponset macro code and switched to using said ops.
fteqcc does not support said bit level ops so we have to keep with the macro code and figure out how to extend it to 72 weaps. IE a third weaponset in addition to the current weapset and weapset2. It's a policy of the chaosesque project to keep compatability with fteqcc and gmqcc as one doesn't know what compiler someone might be knowledgable of if they pick up the code many years from now in som dusty ruin or in a duengon twenty levels down (May darkhold have that many levels one day) or in an abandoned spacecraft of magenta. The ISO ships with both but best to err on the safe side.
http//git.xonotic.org/?p=xonotic/xonotic-data.pk3dir.git;a=commitdiff;h=39380aa9e45dbc545f5fe241c0002ce65a6f635e;js=1
I would like to add a katana, shriukens, and a desert eagle to the game, however more weapons slots are needed. Last time I talked to the German main developer of Nexuiz and Xonotic he said to extend the system, when needed was not difficult. However it is beyond me because I am not terribly smart. I can work within a system, but cannot surpass even the simplest of limits. That is in everything.
The programmer that originated the bitshifting weapon code is Divverent of Nexuiz and Xonotic. He is often busy with his job and family so it is difficult to contact him (I've only been able to maybe once a year these days). (The bitshifting code is needed for compatability with fteqcc quake C compiler)
Other people who might be able to figure it out and how to extend the code reside on the anynet.org irc server in #qc and #darkplaces. And on the quakenet.org irc server on various #xonotic channels (maybe #nexuiz too). Also any channel associated with fte quake engine might also be useful.
Could some of you, here, perhaps ask them. My scheduel is such that I and they are rarely on at the same time so I can't communicate with them effectivly. I very much wish to add more weapons.
Tzork might be able to help, maybe gray or blub aswell. (note: avoid asking samual)
Divverent provided some insight into the bitshifting code in furtherance of adding a third weaponset:
03:43 <divVerent> it is possible to extend the bitshift code, but I won't
03:43 <divVerent> it's a lot of work
03:43 <divVerent> trivial work, but any typo will break it horribly
03:43 <divVerent> just change any part that handles _x and _y to also handle _z
03:44 <divVerent> but beware, this is typo hell. Any typo you make, and it'll
explode.
http//chaosesqueanthology.git.sourceforge.net/git/gitweb.cgi?p=chaosesqueanthology/xonotic-data.pk3dir;a=blob;f=qcsrc/common/items.qh;h=7108f50b51165c656aad9f1e9b7f1c0a6a1dc757;hb=HEAD
qcsrc/common/items.qh
I think an example of where it is handling x and y would be:
146 # define WEPSET_OP2_EE(a,b,mergeop,x,y) (((a)._WS1_weapons x (b)._WS1_weapons y (a)._WS1_weapons) mergeop ((a)._WS2_weapons x (b)._WS2_weapons y (a)._WS2_weapons))
148 # define WEPSET_OP2_EA(a,b,mergeop,x,y) (((a)._WS1_weapons x _WS1_##b y (a)._WS1_weapons) mergeop ((a)._WS2_weapons x _WS2_##b y (a)._WS2_weapons))
150 # define WEPSET_OP2_EW(a,b,mergeop,x,y) (((a)._WS1_weapons x WEPSET_BIT1(b) y (a)._WS1_weapons) mergeop ((a)._WS2_weapons x WEPSET_BIT2(b) y (a)._WS2_weapons))
152 # define WEPSET_OP2_AE(a,b,mergeop,x,y) ((_WS1_##a x (b)._WS1_weapons y _WS1_##a) mergeop (_WS2_##a x (b)._WS2_weapons y _WS2_##a))
154 # define WEPSET_OP2_AA(a,b,mergeop,x,y) ((_WS1_##a x _WS1_##b y _WS1_##a) mergeop (_WS2_##a x _WS2_##b y _WS2_##a))
156 # define WEPSET_OP2_AW(a,b,mergeop,x,y) ((_WS1_##a x WEPSET_BIT1(b) y _WS1_##a) mergeop (_WS2_##a x WEPSET_BIT2(b) y _WS2_##a))
I'm not sure what mergeop does or how macro code really works, but if anyone can figure it out, we have some more hints as to how this all goes together now.
08:46 <divVerent> no, you only change the right side
08:46 <divVerent> one example
08:46 <divVerent> \# define WEPSET_OP1_EE(a,b,mergeop,x) (((a)._WS1_weapons x (b)._WS1_weapons)
mergeop ((a)._WS2_weapons x (b)._WS2_weapons))
08:46 <divVerent> becomes
08:47 <divVerent> # define WEPSET_OP1_EE(a,b,mergeop,x) (((a)._WS1_weapons x (b)._WS1_weapons)
mergeop ((a)._WS2_weapons x (b)._WS2_weapons) mergeop ((a)._WS3_weapons x
(b)._WS3_weapons))
08:47 <divVerent> and yes, this way 72 isn't even the final limit - you can add as many _WS*_weapons as
you want that way
08:47 <divVerent> but it's horrible to do this for all those macros
08:47 <divVerent> at least you only need to work on the "abstract group" of the macros, i.e. the top
<divVerent> except if you really want to stick with this because it can be made to go even beyond 72
08:51 <divVerent> wepset has an absolute limit of 72, but is way nicer code
08:51 <divVerent> as it uses the vector type
<divVerent> then keep your macros :P
08:52 <divVerent> but you maintain them, I won't
08:52 <divVerent> at least I gave you an example... apply that to all the others and it should work
08:52 <divVerent> do a single typo, and it'll fail horribly
08:52 <irrilichdemon> is it ok if I post this macro info to a public file?
08:52 <divVerent> sure, but I won't verify it all
08:52 <irrilichdemon> ok, thanks :)
08:52 <divVerent> it's hard to even check them
08:52 <divVerent> that's the main reason it got killed
08:52 <irrilichdemon> one more question about them
08:52 <divVerent> it's REALLY bad code
08:53 <irrilichdemon> at least you only need to work on the "abstract group" of the macros, i.e. the top
08:53 <irrilichdemon> do I just change
08:53 <divVerent> I don't have the code in front of me
08:54 <divVerent> ah, see it
08:54 <divVerent> I meant from:
08:54 <divVerent> # define WEP_MAXCOUNT 48
08:54 <divVerent> to
08:54 <divVerent> # define WEPSET_OP2_AW(a,b,mergeop,x,y) ((_WS1_##a x WEPSET_BIT1(b) y _WS1_##a) mergeop (_WS2_##a x WEPSET_BIT2(b) y _WS2_##a))
08:55 <irrilichdemon> lines: 146, 148, 150, 152, 154, and 156?
<divVerent> while this COPY, EQ, OR .. doesn't need touching
08:55 <divVerent> sorry, I have no line numbers here
08:55 <divVerent> but I'd assume almost all lines from the first to the last I quoted need changing
08:55 <irrilichdemon> 145 is:
08:55 <irrilichdemon> 145 # define WEPSET_OP1_EE(a,b,mergeop,x) (((a)._WS1_weapons x (b)._WS1_weapons) mergeop ((a)._WS2_weapons x (b)._WS2_weapons))
08:55 <divVerent> sure needs changfing the way I told you
08:55 <irrilichdemon> 146 is
08:55 <irrilichdemon> 146 # define WEPSET_OP2_EE(a,b,mergeop,x,y) (((a)._WS1_weapons x (b)._WS1_weapons y (a)._WS1_weapons) mergeop ((a)._WS2_weapons x
(b)._WS2_weapons y (a)._WS2_weapons))
08:55 <divVerent> same change needed
08:56 <divVerent> the mergeop ...WS2... stuff needs to be copied to the end and become a mergeop ...WS3...
08:56 <divVerent> that'll be a very long line
08:56 <divVerent> # define WEPSET_DECLARE_A(a) float _WS1_##a, _WS2_##a
08:56 <divVerent> even this needs changing
08:57 <irrilichdemon> ok let me try a triad... brb a few min trying
08:57 <divVerent> to add a _WS3_##a
08:57 <divVerent> # define WEPSET_ADDSTAT() addstat(STAT_WEAPONS, AS_INT, _WS1_weapons); addstat(STAT_WEAPONS2, AS_INT, _WS2_weapons)
08:57 <divVerent> and this will need a new STAT_WEAPONS3
08:59 <divVerent> oh, the lines with the power2of stuff needs to be handled a bit different
09:00 <divVerent> copy it to make a third one of these :P
09:00 <divVerent> but that should be obvious
09:01 <irrilichdemon> 145 # define WEPSET_OP1_EE(a,b,mergeop,x) ((((a)._WS1_weapons x (b)._WS1_weapons) mergeop ((a)._WS2_weapons x (b)._WS2_weapons)) mergeop
((a)._WS3_weapons x (b)._WS3_weapons)))
09:01 <irrilichdemon> 146 # define WEPSET_OP2_EE(a,b,mergeop,x,y) ((((a)._WS1_weapons x (b)._WS1_weapons y (a)._WS1_weapons) mergeop ((a)._WS2_weapons x
(b)._WS2_weapons y (a)._WS2_weapons)) mergeop ((a)._WS3_weapons x (b)._WS3_weapons y (a)._WS3_weapons)))
09:01 <irrilichdemon>
09:01 <irrilichdemon> 132 # define WEPSET_BIT3(a) (((a) >= WEP_FIRST3) ? power2of((a) - WEP_FIRST3) : 0)
09:02 <irrilichdemon> is that how it's should go?
09:09 <irrilichdemon>
09:09 <irrilichdemon> also in cl_weapons.qc there seems to be this for weapon reloading
09:09 <irrilichdemon> http//chaosesqueanthology.git.sourceforge.net/git/gitweb.cgi?p=chaosesqueanthology/xonotic-data.pk3dir;a=blob;f=qcsrc/server/cl_weapons.qc;h=ece50bac7bd5ecf69db11722585f1ba4c752e4fb;hb=HEAD
09:10 -!- Irssi: Pasting 8 lines to divVerent. Press Ctrl-K if you wish to do this or Ctrl-C to cancel.
09:10 <irrilichdemon> if(doreduce && g_weapon_stay == 2)
09:10 <irrilichdemon> 260 {
09:10 <irrilichdemon> 261 for(i = 0, j = 1; i < 24; ++i, j *= 2)
09:10 <irrilichdemon> 262 {
09:10 <irrilichdemon> 263 if(wa & j)
09:10 <irrilichdemon> 264 {
09:10 <irrilichdemon> 265 ammofield = Item_CounterField(j);
09:10 <irrilichdemon> 266
09:10 <irrilichdemon> 267 // if our weapon is loaded, give its load back to the player
09:10 <irrilichdemon>
09:10 <irrilichdemon> and similar
09:10 <irrilichdemon> should it be
09:11 <irrilichdemon> for(i = 0, j = 1; i < 24; ++i, j *= 2; i < 48; ++i, j *= 3)
09:11 <irrilichdemon> for working with a 3rd weapset
Ok here's my attempt at following the given rules:
http://pastebin.com/bpC7xYSc
#else# define WEP_MAXCOUNT 72# define WEP_FIRST2 25# define WEP_FIRST3 49.float _WS1_weapons;.float _WS2_weapons;.float _WS3_weapons;# define WEPSET_BIT1(a) (((a) < WEP_FIRST2) ? power2of((a) - WEP_FIRST) : 0)# define WEPSET_BIT2(a) (((a) >= WEP_FIRST2) ? power2of((a) - WEP_FIRST2) : 0)# define WEPSET_BIT3(a) (((a) >= WEP_FIRST3) ? power2of((a) - WEP_FIRST3) : 0)# define WEPSET_DECLARE_A(a) float _WS1_##a, _WS2_##a, _WS3_##a# define WEPSET_CLEAR_E(e) ((e)._WS1_weapons = (e)._WS2_weapons = (e)._WS3_weapons = 0)# define WEPSET_CLEAR_A(a) ((_WS1_##a) = (_WS2_##a) = (_WS3_##a) = 0)# define WEPSET_EMPTY_E(e) ((e)._WS1_weapons == 0 && (e)._WS2_weapons == 0 && (e)._WS3_weapons == 0)# define WEPSET_EMPTY_A(a) ((_WS1_##a) == 0 && (_WS2_##a) == 0 && (_WS3_##a) == 0)# define WEPSET_COPY_AS(a) ((_WS1_##a) = getstati(STAT_WEAPONS), (_WS2_##a) = getstati(STAT_WEAPONS2), (_WS3_##a) = getstati(STAT_WEAPONS3))# define WEPSET_ADDSTAT() addstat(STAT_WEAPONS, AS_INT, _WS1_weapons); addstat(STAT_WEAPONS2, AS_INT, _WS2_weapons); addstat(STAT_WEAPONS3, AS_INT, _WS3_weapons)# define WEPSET_WRITE_E(dest,a) WriteInt24_t(dest, (a)._WS1_weapons); WriteInt24_t(dest, (a)._WS2_weapons); WriteInt24_t(dest, (a)._WS3_weapons)# define WEPSET_WRITE_A(dest,a) WriteInt24_t(dest, _WS1_##a); WriteInt24_t(dest, _WS2_##a); WriteInt24_t(dest, _WS3_##a)# define WEPSET_WRITE_W(dest,a) WriteInt24_t(dest, WEPSET_BIT1(a)); WriteInt24_t(dest, WEPSET_BIT2(a)); WriteInt24_t(dest, WEPSET_BIT3(a))# define WEPSET_READ_E(a) (a)._WS1_weapons = ReadInt24_t(); (a)._WS2_weapons = ReadInt24_t(); (a)._WS3_weapons = ReadInt24_t()# define WEPSET_READ_A(a) (_WS1_##a) = ReadInt24_t(); (_WS2_##a) = ReadInt24_t(); (_WS3_##a) = ReadInt24_t() # define WEPSET_OP1_EE(a,b,mergeop,x) (((a)._WS1_weapons x (b)._WS1_weapons) mergeop ((a)._WS2_weapons x (b)._WS2_weapons) mergeop ((a)._WS3_weapons x (b)._WS3_weapons))# define WEPSET_OP2_EE(a,b,mergeop,x,y) (((a)._WS1_weapons x (b)._WS1_weapons y (a)._WS1_weapons) mergeop ((a)._WS2_weapons x (b)._WS2_weapons y (a)._WS2_weapons) mergeop ((a)._WS3_weapons x (b)._WS3_weapons y (a)._WS3_weapons)) # define WEPSET_OP1_EA(a,b,mergeop,x) (((a)._WS1_weapons x _WS1_##b) mergeop ((a)._WS2_weapons x _WS2_##b) mergeop ((a)._WS3_weapons x _WS3_##b))# define WEPSET_OP2_EA(a,b,mergeop,x,y) (((a)._WS1_weapons x _WS1_##b y (a)._WS1_weapons) mergeop ((a)._WS2_weapons x _WS2_##b y (a)._WS2_weapons) mergeop ((a)._WS3_weapons x _WS3_##b y (a)._WS3_weapons)) # define WEPSET_OP1_EW(a,b,mergeop,x) (((a)._WS1_weapons x WEPSET_BIT1(b)) mergeop ((a)._WS2_weapons x WEPSET_BIT2(b)) mergeop ((a)._WS3_weapons x WEPSET_BIT3(b)))# define WEPSET_OP2_EW(a,b,mergeop,x,y) (((a)._WS1_weapons x WEPSET_BIT1(b) y (a)._WS1_weapons) mergeop ((a)._WS2_weapons x WEPSET_BIT2(b) y (a)._WS2_weapons) mergeop ((a)._WS3_weapons x WEPSET_BIT3(b) y (a)._WS3_weapons)) # define WEPSET_OP1_AE(a,b,mergeop,x) ((_WS1_##a x (b)._WS1_weapons) mergeop (_WS2_##a x (b)._WS2_weapons) mergeop (_WS3_##a x (b)._WS3_weapons))# define WEPSET_OP2_AE(a,b,mergeop,x,y) ((_WS1_##a x (b)._WS1_weapons y _WS1_##a) mergeop (_WS2_##a x (b)._WS2_weapons y _WS2_##a) mergeop (_WS3_##a x (b)._WS3_weapons y _WS3_##a)) # define WEPSET_OP1_AA(a,b,mergeop,x) ((_WS1_##a x _WS1_##b) mergeop (_WS2_##a x _WS2_##b) mergeop (_WS3_##a x _WS3_##b))# define WEPSET_OP2_AA(a,b,mergeop,x,y) ((_WS1_##a x _WS1_##b y _WS1_##a) mergeop (_WS2_##a x _WS2_##b y _WS2_##a) mergeop (_WS3_##a x _WS3_##b y _WS3_##a)) # define WEPSET_OP1_AW(a,b,mergeop,x) ((_WS1_##a x WEPSET_BIT1(b)) mergeop (_WS2_##a x WEPSET_BIT2(b)) mergeop (_WS3_##a x WEPSET_BIT3(b)))# define WEPSET_OP2_AW(a,b,mergeop,x,y) ((_WS1_##a x WEPSET_BIT1(b) y _WS1_##a) mergeop (_WS2_##a x WEPSET_BIT2(b) y _WS2_##a) mergeop (_WS3_##a x WEPSET_BIT3(b) y _WS3_##a))#endif
Divverent came through. We now have a third weaponset, and the knowlege to extend it when we need to.
The third weaponset gives us a max weapons of 72.
Just added a katana as the 49th weapon.
We-pon. We have it all!