View Single Post
  #7  
Old 09-23-2015, 09:37 PM
Cilraaz
Sarnak
 
Join Date: Mar 2010
Posts: 77
Default

So I took a look at this again today and I think I was right above, but for the wrong reason.

I looked into bit shifting a bit more and realized I was calculating it wrong above (though still coming up with kinda the right answer). I think my logic needs to look at what possibilities should evaluate true. I'm going to do a bit of rambling just to get thoughts down into the thread. Feel free to pick any of it apart.

Earlier, AdrianD posted the expansion value chart:
Code:
Expansion Value	All Expansions	
0	Original0	Original
1	Kunark	1	Kunark
2	Velious	3	Velious
4	Luclin	7	Luclin
8	PoP	15	PoP
16	Ykesha	31	Ykesha
32	LDoN	63	LDoN
64	GoD	127	GoD
128	OoW	255	OoW
256	DoN	511	DoN
512	DoD	1023	DoD
1024	PoR	2047	PoR
2048	TSS	4095	TSS
4096	TBS	8191	TBS
8192	SoF	16383	SoF
16384	SoD	32767	SoD
32768	UF	65535	UF
65536	HoT	131071	HoT
131072	VoA	262143	VoA
262144	RoF	524287	RoF
524288	CoF	1048575	CoF
1048576	tDS	2097151	tDS
If we convert that to the bitmask values, we get (inclusively, it would be all bits after the initial 1 also being 1 instead of 0, but that wouldn't really change anything):
Code:
SoL  - 00000100
PoP  - 00001000
LoY  - 00010000
LDoN - 00100000
GoD  - 01000000
etc
Now, if we look at bitshifted values of expansions from the AA table (results after the "1 << rank->expansion" calculation), we have:
Code:
SoL  - 00001000
PoP  - 00010000
LoY  - 00100000
LDoN - 01000000
GoD  - 10000000
etc
So in the code now, isn't it comparing SoL (0100, or inclusively 0111) to the bitshifted AA expansion variable for SoL (1000)? If so, then wouldn't this always evaluate false, making the code correction posted earlier correct?
Code:
if(!(CastToClient()->GetPP().expansions & (1 << (rank->expansion - 1)))) {
Again, I'd kind of like a dev (or anyone who knows this code, C++, bitmasks, bitshifting, etc better than I do) to take a peek and let me know if I'm insane or not.
Reply With Quote