Page 1 of 3

NewGRF: Temperate Oil Wells don't only_decrease

Posted: 27 Jul 2008 01:00
by SirkoZ
Current version of the Grf:
oilsgoup.grf
(196 Bytes) Downloaded 2185 times
Current version of the Grf's Source:
oilsgoup_v2.nfo
(1.08 KiB) Downloaded 838 times
Changes since the last version:
SirkoZ wrote:I only changed so it says "Temperate Oil Wells only_decrease neutraliser" instead of just "Only_decrease neutraliser" in the NewGRF selection window
[Old Post]
Greets all!

EDIT: The files (v2) can be found here.

This is my first NFO/newGRF and I have some problems with it:

1st line - Action 8 (which NFO renum comments and replaces with a random action 0 and then complains '8' isn't the first :-X):

Code: Select all

0 * 43 08 06 53 5A 13 44 20 4F 6E 6C 79 5F 64 65 63 72 65 61 73 65 20 6E 65 75 74 72 61 6C 69 73 65 72 20 42 79 20 53 69 72 6B 6F 5A 00
2nd line - Action 0 (which should say that only_decrease flag (80) for (Temperate) Oil Wells is null and void):

Code: Select all

1 * 10 00 0A 01 01 0B 1A 07 00 00 00
3rd line - Action 7 which should disable this newGRF if Temperate terrain isn't used (yet grf coded says Sprite 2's transparency and redundancy is 100% - I suppose this is bad):

Code: Select all

2 * 06 07 83 01 03 00 00
Please help me make this one work for as it would sometimes be fun to have abundant Oil Wells in temperate games.

Thx

SirkoZ

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 27 Jul 2008 03:10
by DaleStan
Sprite 0 is not an action. NFORenum can't make sense of that sprite 0, so it comments it out and puts a valid one in. When it can make sense of the sprite 0, it removes it instead.

Generally, you want your action 7s to skip something. What is that one skipping?

As a general rule, the transparency/redundancy message is only interesting for real sprites. Pseudos always compress to exactly 100% of their original size. Also, that's a running total, not a per-sprite total.

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 27 Jul 2008 18:06
by SirkoZ
Action 7 here should skip this whole grf if terrain set to 00 = temperate. Although with even Action 0 not working (neither in oTTD nor in TTDPatch) I want to fix that one first...any help?

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 27 Jul 2008 21:20
by SirkoZ
None of you newGRF guru's (Purno et al) wrote any replies here - what gives?

Is this simple idea really so hard to implement - I mean one should be able to disable only_decrease flags with action 0, no?

I'm confused... :?

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 27 Jul 2008 22:54
by Lakie
What DaleStan tried to tell you is that the first sprite "0" must be the number of sprites in the file, the action / realsprites must begin from sprite "1" onwards.
Example for if you don't understand what you've been told:

Code: Select all

0 *  4        03 00 00 00
1 *  6        07 83 01 03 00 00
2 * 43        08 06 53 5A 13 44 20 4F 6E 6C 79 5F 64 65 63 72 65 61 73 65 20 6E 65 75 74 72 61 6C 69 73 65 72 20 42 79 20 53 69 72 6B 6F 5A 00
3 * 10        00 0A 01 01 0B 1A 07 00 00 00
Though I'm not sure if you are meant to skip the action8 to disable the grf these days.

Hope that helps,
~ Lakie

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 27 Jul 2008 23:06
by mart3p
Well, I haven't done any industry coding myself, but I'll try and give you what help I can.

Firstly, people are more likely to respond, if you layout and document your nfo so it can be immediately understood. ;) Something like this:

Code: Select all

1 * 10 00 0A // Action 0 - industries
       01 01 // 1 property, 1 industry
       0B    // Id - oil wells
       1A    // Property - special flags
       07 00 00 00 // Value
I can now see you are setting property 1A to a value of 7. This is setting bits 0, 1 and 2, according to the wiki these bits are:
  • 0 - Industry plants fields
    1 - Industry cuts trees
    2 - Industry is built on water
I don't think that's quite what you intended... ;)

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 27 Jul 2008 23:33
by Lakie
Indeed, I don't know anything about industries but based of the Wiki it looks although you mistook the bit for being the value you write into the nfo, you actually write the value of the bit (0x80 for bit 7).
Which would give you the desired effect (bit 7 - The industry cannot increase its production on the temperate climate (oil wells)).

~ Lakie

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 28 Jul 2008 10:27
by SirkoZ
Thanks, Lakie and mart3p - I should have posted the corrected NFO, sorry. :oops:
I mean I understand what DaleStan was saying about the action 8 and that 0 * 4 00 00 00 00 - that's simple. :-)

What baffles me is:
1.)Why action 0 doesn't work - I mean the bit 7 that has value 80 is for only_decrease, but I wanted to disable the only_decrease behaviour, that's why I set all the values for bit 7 to 00.
I just don't know how would I disable it otherwise...

2.) Action 7 - I'll deal with it when I have the 0 sorted. However - I don't know how exactly I'd prevent this grf from loading in other terrains (not temperate). I set the comparison that if it's 00 (temperate terrain that it skips the grf or so I think)... :-)

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 28 Jul 2008 10:39
by Purno
SirkoZ wrote:None of you newGRF guru's (Purno et al) wrote any replies here - what gives?
I don't code NFO, and since your question seems to be related to NFO, I cannot post anything useful to help you.

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 28 Jul 2008 10:40
by Lakie
As I said in my later post the value should be 0x80 not 0x07 (which is the bit number).

Code: Select all

    2 * 10	 00 0A 01 01 0B // Oil wells, one property
	 		      1A 80 00 00 00 // Can only decrease in production
As previously said by me, put the action7 above the action8.

~ Lakie

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 28 Jul 2008 12:10
by SirkoZ
Purno wrote:
SirkoZ wrote:None of you newGRF guru's (Purno et al) wrote any replies here - what gives?
I don't code NFO, and since your question seems to be related to NFO, I cannot post anything useful to help you.
Oh. :oops:

Thanks anyway. ;-)

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 28 Jul 2008 12:13
by Purno
You're welcome :)

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 28 Jul 2008 12:14
by SirkoZ
Lakie wrote:As I said in my later post the value should be 0x80 not 0x07 (which is the bit number).

Code: Select all

    2 * 10	 00 0A 01 01 0B // Oil wells, one property
	 		      1A 80 00 00 00 // Can only decrease in production
As previously said by me, put the action7 above the action8.

~ Lakie
Beautiful. Thank you - this newGRF is now disabled in all non-temperate terrains. :D

Now - the action 0 - how would I neutralise that only_decrease flag that is present in the game alone for temperate oil wells? I want them to increase production too - that's the thing that I don't know. :(

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 28 Jul 2008 12:27
by Lakie
I'd imagine just making the value for Action0 Property 1A 0x00000000 would work in that case?

~ Lakie

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 28 Jul 2008 12:34
by SirkoZ
Oh - thx - I'll try it out. :-)

EDIT: No...doesn't work. Oil wells still only_decrease (both OTTD and TTDP)...->nfo in the upper post - I edited it.

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 28 Jul 2008 14:45
by mart3p
I think you need a little more than setting property 1A. If I start a game in OpenTTD with your grf and debug grf enabled, I get the following message.

Code: Select all

dbg: [grf] [Test\oilsgoup.grf:2] IndustriesChangeInfo: newid 11
dbg: [grf] [Test\oilsgoup.grf:2] IndustriesChangeInfo: Attempt to modify undefined industry 11. Ignoring.
It seems a property 08 must be set to define the industry, or all other property settings for that ID are ignored. The trouble then, is that property 08 creates a new additional industry type, based on the old one. I think you also need to use property 09 to override the original oil wells.

Code: Select all

2 * 14	 00 0A // Action 0 - industries
       03 01 // 3 properties, 1 industry
       0B    // Id - oil wells
       08 0B // Property - substitute industry type
       09 0B // Property - industry type override
       1A    // Property - special flags
       00 00 00 00 // Value - clear all bits
I can't promise that this is entirely correct, as I say, I have never done any industry coding, but it seems to work. :)

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 28 Jul 2008 15:50
by SirkoZ
Wow - that's great, mart3p - I also asked belugas and he said that by nullifying the 1A prop in OTTD we also loose the behaviours:
INDUSTRYBEH_DONT_INCR_PROD and
INDUSTRYBEH_BEFORE_1950
although with Oil Wells recreated as a new type it shouldn't be a problem. I don't know.

Those 08 and 09 props' usages sure look easy now. :-)

Thank you. ;-)

P.S.: I PMed belugas with this development - we'll see - I have the feeling it will be fine.
Thanks again, mart3p I really appreciate it.
I'll make the newGRF right away and post it here and also in my signature (link to it).

Works in OpenTTD (default and smooth_economy) and in TTDPatch (default_economy).

EDIT: The files (v2) can be found here.

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 28 Jul 2008 17:36
by Lakie
Then add 0x100 to the value of bit 8 to 1A (remember that its little endian so the actual value would be "1A 00 01 00 00" in nfo).

~ Lakie

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 28 Jul 2008 17:39
by SirkoZ
Oh of course - it's that simple. I'm not used to all these bits so I was confused.

Thank you very much. ;-)

Version 2 - with disabled only_decrease and Oil Wells still being constructed before 1950:
Note: this newGRF is only intended to be used with the default TTD(Patch)/OpenTTD industries and not with any custom made (newGRF) industry sets.

Re: NewGRF: Temperate Oil Wells don't only_decrease

Posted: 28 Jul 2008 18:17
by michael blunck
Sorry to spoil the party, but I don´t see much sense in littering the world with lots and lots of tiny .grfs which make behaviour of "large" sets unpredictable. People will for sure collect every .grf encountered on the net and then complain about problems.

Be assured that this is a real problem. I.e., after succeeding in coding your first .grf why don´t you leave it for personal usage?

regards
Michael