Lathain Valtiel Posted November 18, 2007 Share Posted November 18, 2007 I know how it is calculated, it's a power of two for each weapon... but how does the game check the result? Keep diving by 2 until there's no more weapons to disable, starting with the highest weapon on the list? Link to comment Share on other sites More sharing options...
Cohsty243 Posted November 18, 2007 Share Posted November 18, 2007 if im right lol.. Each weapon has its own bitflag. i think it checks that if the g_weapondisable integer contains a bitflag assigned to a weapon then disable it/cannot be spawned. ensi or razor can probably explain it better lol. Link to comment Share on other sites More sharing options...
XycaleTh Posted November 18, 2007 Share Posted November 18, 2007 As Cohsty said, the g_weapondisable cvar contains a number which tells the game which weapons to disable. I haven't got JKA code in front of me so the numbers might not be right. If say, g_weapondisable = 24, in binary this is 11000. If the game wanted to check if the saber was enabled (for this example, the bitflag for saber can be 8, or 01000 in binary), you would do: if ( g_weapondisable.integer & WP_SABER )...... The & is a bitwise AND operator like this: 110000 010000 & 010000 When there are two 1s in the same column, the answer is 1, otherwise its 0. The if statement checks the result in between the brackets if it's true/false. False = 0, true = anything else. Hope that helps, and that you understood it Link to comment Share on other sites More sharing options...
ensiform Posted November 18, 2007 Share Posted November 18, 2007 Power of 2 is the correct way, not binary . WP_NONE = 0 WP_STUN_BATON = 1 WP_MELEE = 2 WP_SABER = 3 WP_BRYAR_PISTOL = 4 WP_BLASTER = 5 WP_DISRUPTOR = 6 WP_BOWCASTER = 7 WP_REPEATER = 8 WP_DEMP2 = 9 WP_FLECHETTE = 10 WP_ROCKET_LAUNCHER = 11 WP_THERMAL = 12 WP_TRIP_MINE = 13 WP_DET_PACK = 14 WP_CONCUSSION = 15 WP_BRYAR_OLD = 16 WP_EMPLACED_GUN = 17 WP_TURRET = 18 WP_NUM_WEAPONS = 19 2^0 = 1 2^1 = 2 2^2 = 4 2^3 = 8 2^4 = 16 2^5 = 32 2^6 = 64 2^7 = 128 2^8 = 256 2^9 = 512 2^10 = 1024 2^11 = 2048 2^12 = 4096 2^13 = 8192 2^14 = 16384 2^15 = 32768 2^16 = 65536 2^17 = 131072 2^18 = 262144 2^19 = 524288 Also, checking is done by & (1 << WP_) not just & WP_ Link to comment Share on other sites More sharing options...
XycaleTh Posted November 18, 2007 Share Posted November 18, 2007 It's pretty much the same thing Link to comment Share on other sites More sharing options...
ensiform Posted November 19, 2007 Share Posted November 19, 2007 It's pretty much the same thing No its not when the r-value of the & isn't already a 1 <<. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.