How to use extra_callback_info?

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
User avatar
Andrew350
Chairman
Chairman
Posts: 771
Joined: 19 Dec 2011 07:54
Location: Washington State, USA
Contact:

How to use extra_callback_info?

Post by Andrew350 »

So, I'm trying to use the cargo_subtype_display callback to add the word "(optional)" after one of the accepted cargoes for an industry. I have the following code:

Code: Select all

switch (FEAT_INDUSTRIES, SELF, switch_wastelanders_optional_text, extra_callback_info2 & 0x00000001) {
	1: string(STR_WASTELANDERS_OPTIONAL);
	CB_RESULT_NO_TEXT;
}
Honestly, I'm just taking a complete shot in the dark here, but it 'sort of' works. Unfortunately, while it adds the word to the correct cargo, it also adds it to one of the produced cargoes as well, which isn't what I want:
img1.png
img1.png (57.68 KiB) Viewed 2147 times
I'm pretty sure I'm using extra_callback_info2 wrong, and I really have no idea what to do. Any advice?

Thanks
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5631
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: How to use extra_callback_info?

Post by PikkaBird »

Why "& 0x00000001"? ;)
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: How to use extra_callback_info?

Post by Eddi »

obviously "&0x1" also returns 1 if extra_callback_info2 == 3. to mask the lowest byte, you need to use "&0xFF"
User avatar
Andrew350
Chairman
Chairman
Posts: 771
Joined: 19 Dec 2011 07:54
Location: Washington State, USA
Contact:

Re: How to use extra_callback_info?

Post by Andrew350 »

PikkaBird wrote:Why "& 0x00000001"? ;)
I don't know. :lol:
Eddi wrote:obviously "&0x1" also returns 1 if extra_callback_info2 == 3. to mask the lowest byte, you need to use "&0xFF"
Ok, so I was basically just backwards then, and the lowest byte is actually 0xFF and not 0x01?

(This bit/byte stuff isn't so obvious to some, btw ;))
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: How to use extra_callback_info?

Post by Eddi »

i use the word "obviously" very ironically, obviously :p
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 6 guests