+ 2

Need help understanding this.

I'm reading the source code for a game that I play: void gorgeous_set(void) { for (int i = 0; i < 11; i++) { writeSlot(i, 0x2adc + i); //put item ID of first furniture in series } writeSlot(11, 0x2401); //put flooring/wallpaper here. writeSlot(12, 0x2362); } void GoldTools(void) { for (int i = 0; i < 6; i++) { writeSlot(i, 0x3353 + (i * 4)); //put item ID of first furniture in series } } My question is what is the difference between, what does it mean, and what is happening in these lines: "(i, 0x2adc + i);" and "(i, 0x3353 + (i * 4));" Thanks for any help!

14th May 2017, 1:28 AM
Sami
4 ответов
+ 4
These hex values are address of some object. when we add i*4 the address changes. 0x2adc has different address than 0x3353
14th May 2017, 1:36 AM
MR Programmer
MR Programmer - avatar
+ 3
0x3353 +i*4 is not equal to 0x3353+i it is like 5+4 is not equal to 5+1
14th May 2017, 1:46 AM
MR Programmer
MR Programmer - avatar
+ 2
Hmm. Okay, thank you! Kinnnd of get it now.
14th May 2017, 1:50 AM
Sami
+ 1
Why can you not write (i, 0x3353 + (i * 4)); like this (i, 0x3353 +i);? Or vice versa. (i, 0x2adc +i); like (i, 0x2adc + (i * 4));?
14th May 2017, 1:40 AM
Sami