Xonotic Forums
How do I use the newer 48 slot weapon system? - Printable Version

+- Xonotic Forums (https://forums.xonotic.org)
+-- Forum: Creating & Contributing (https://forums.xonotic.org/forumdisplay.php?fid=10)
+--- Forum: Xonotic - Development (https://forums.xonotic.org/forumdisplay.php?fid=12)
+--- Thread: How do I use the newer 48 slot weapon system? (/showthread.php?tid=2930)



How do I use the newer 48 slot weapon system? - May Epper - 04-19-2012

qcsrc / common / items.qh

http://git.xonotic.org/?p=xonotic/xonotic-data.pk3dir.git;a=blob;f=qcsrc/common/items.qh;h=5a39d2148c045b1d155250cf8ae71432adbab85a;hb=HEAD

I enabled the idef'd code here:
Code:
121 #else

122 # define WEP_MAXCOUNT 48

123 # define WEP_FIRST2 25

124 .float _WS1_weapons;

125 .float _WS2_weapons;

126 # define WEPSET_BIT1(a)                 (((a) < WEP_FIRST2) ? power2of((a) - WEP_FIRST) : 0)

127 # define WEPSET_BIT2(a)                 (((a) >= WEP_FIRST2) ? power2of((a) - WEP_FIRST2) : 0)

128 # define WEPSET_DECLARE_A(a)            float _WS1_##a, _WS2_##a

129 # define WEPSET_CLEAR_E(e)              ((e)._WS1_weapons = (e)._WS2_weapons = 0)

130 # define WEPSET_CLEAR_A(a)              ((_WS1_##a) = (_WS2_##a) = 0)

131 # define WEPSET_EMPTY_E(e)              ((e)._WS1_weapons == 0 && (e)._WS2_weapons == 0)

132 # define WEPSET_EMPTY_A(a)              ((_WS1_##a) == 0 && (_WS2_##a) == 0)

133 # define WEPSET_COPY_AS(a)              ((_WS1_##a) = getstati(STAT_WEAPONS), (_WS2_##a) = getstati(STAT_WEAPONS2))

134 # define WEPSET_ADDSTAT()               addstat(STAT_WEAPONS, AS_INT, _WS1_weapons); addstat(STAT_WEAPONS2, AS_INT, _WS2_weapons)

135 # define WEPSET_OP1_EE(a,b,mergeop,x)   (((a)._WS1_weapons x (b)._WS1_weapons) mergeop ((a)._WS2_weapons x (b)._WS2_weapons))

136 # 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))

137 # define WEPSET_OP1_EA(a,b,mergeop,x)   (((a)._WS1_weapons x _WS1_##b) mergeop ((a)._WS2_weapons x _WS2_##b))

138 # 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))

139 # define WEPSET_OP1_EW(a,b,mergeop,x)   (((a)._WS1_weapons x WEPSET_BIT1(b)) mergeop ((a)._WS2_weapons x WEPSET_BIT2(b)))

140 # 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))

141 # define WEPSET_OP1_AE(a,b,mergeop,x)   ((_WS1_##a x (b)._WS1_weapons) mergeop (_WS2_##a x (b)._WS2_weapons))

142 # 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))

143 # define WEPSET_OP1_AA(a,b,mergeop,x)   ((_WS1_##a x _WS1_##b) mergeop (_WS2_##a x _WS2_##b))

144 # 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))

145 # define WEPSET_OP1_AW(a,b,mergeop,x)   ((_WS1_##a x WEPSET_BIT1(b)) mergeop (_WS2_##a x WEPSET_BIT2(b)))

146 # 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))

147 #endif

And defined STAT_WEAPONS2 as some number (is this correct?) in qcsrc / common / constants.qh
http://git.xonotic.org/?p=xonotic/xonotic-data.pk3dir.git;a=blob;f=qcsrc/common/constants.qh;h=e70a83c391d7b992ce0091e91efc89504fa31c4d;hb=HEAD

Compiled fine. Runs fine, untill I add the 25th weapon to compile in, or so.
Then I get a crash in the quakeC. So it seems, I guess, I have to add a macro to the 25th and above weapons I guess. What would that be?

Please don't ask why. Trying to test this if you need an answer to "why would you want to add more weapons".


RE: How do I use the newer 48 slot weapon system? - Mr. Bougo - 04-20-2012

"a crash", that's not very specific. Care to give more details about the crash? In case of a segfault, do you know how to do a gdb backtrace?