It would be useful to be able to run the production change cb when an industry is constructed.
- set / randomise initial production
- convenient and sensible place to initialise local storage (can return 'no change' as the cb result)
Wondering if it would be acceptable to:
- define a bit on cb flags (prop 22),
- if bit set, call IndustryMonthlyLoop() from DoCreateNewIndustry()
[EDIT - that was a silly approach, sensible patch in next post.]
This is same way colour / cargo callbacks are called, and avoids duplicating IndustryMonthlyLoop, but I don't know if it's sane.
I favour this approach because it solves the problem, won't break existing newgrfs, involves very little new code, and won't require many (if any) changes in renum/nml.
industry_cmd.cpp, lines around 2681, 1656
Industry - production change cb on consruction (patch)
Moderator: Graphics Moderators
- andythenorth
- Tycoon
- Posts: 5705
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Industry - production change cb on consruction (patch)
Last edited by andythenorth on 22 Apr 2012 06:17, edited 1 time in total.
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
- andythenorth
- Tycoon
- Posts: 5705
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: Industry - production change cb on consruction
Patch adds callback 15F, called on industry construction.
(Patch updated to address various issues, also adding cb to newgrf debug, also fix comments)
Return 4-128 to set production level (prod_level).
Patch for nml to add cb 15F.
Version of FIRS where Arable Farm uses cb 15F.
-- Possible extension --
Authors using production cb for primary production (or other purposes) might want to set 'previous month production' accurately using their production algorithm. Values for last_month_production[0] and last_month_production[1] could be optionally set by cb 15F. Pass absolute values for these in registers 0x100 and 0x101?
EDIT - irc discussion suggested that authors using production cb for production can still set initial prod_level via cb 15F to adjust the value of 'previous month production' to one suiting the industry.
(Patch updated to address various issues, also adding cb to newgrf debug, also fix comments)
Return 4-128 to set production level (prod_level).
Patch for nml to add cb 15F.
Version of FIRS where Arable Farm uses cb 15F.
-- Possible extension --
Authors using production cb for primary production (or other purposes) might want to set 'previous month production' accurately using their production algorithm. Values for last_month_production[0] and last_month_production[1] could be optionally set by cb 15F. Pass absolute values for these in registers 0x100 and 0x101?
EDIT - irc discussion suggested that authors using production cb for production can still set initial prod_level via cb 15F to adjust the value of 'previous month production' to one suiting the industry.
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
- andythenorth
- Tycoon
- Posts: 5705
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: Industry - production change cb on consruction (patch)
Added to OpenTTD in r24186 (thanks frosch)
Also thanks to the others who helped
Also thanks to the others who helped

FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Who is online
Users browsing this forum: No registered users and 8 guests