1.06 Subproject: Adding Cargo Types

A private forum for those folks working on patches for RRT3.
milo
Engineer
Posts: 512
Joined: Sat Nov 11, 2006 5:36 pm
Location: End of the line

1.06 Subproject: Adding Cargo Types Unread post

Pure Al's doing some interesting work toward developing new cargo types. Biggest hurdle seems to be the reordering problem when we add new cargoes to the game, which I think is what scuttled Ned Fumpkin's nifty Atlantis project.

Currently, GMP files store event condition types using a four-byte integer. "YTD company <cargo> hauled" conditions, for example, occupy the codes from 000000FDh through 00000139h. This allocation scheme is what limits the game to 60 different cargoes, of which 41 are currently defined.

For locomotives, it looks as if RT3 is smart enough to assign user-created content indices that start after built-in content, so installing new engines doesn't break existing scenarios (though it could quite possibly cause problems for scenarios already using custom engines).

JSS discovered that the same rule does not apply to cargoes. Those seem to be assigned values based on their names - 'milk' comes after 'meat', for example. When one installs a new cargo, it causes all the other cargoes after it in the list to shift down a spot - so a 115h event that originally counted "YTD company milk hauled" might now count "YTD company meat hauled".

The name used to sort the list is an "internal" name, rather than one out of RT3.lng. Because the last resource is 'wool', I think someone suggested fixing the reordering problem simply by assigning custom cargoes names like 'xxyCrystals'. So here's the project for you avid modders:
  • Construct a tiny test map.
  • Test the naming idea by creating a new cargo with an 'xxyBlah' internal name. Does it work?
  • If so, is there a way to keep multiple new cargoes from colliding with each other? If I install xxyCrystals and then later decide to install xxxPigs, it disrupts scenario references to crystals, doesn't it?
  • Do we have to limit cargo releases to patches, in which we can control the installed cargo set? If so, which standard cargoes should we add?
  • Is anyone up for creating new railroad cars to go with our shiny new locos? :)
Discuss.
User avatar
pure al
Dispatcher
Posts: 306
Joined: Sat Dec 23, 2006 11:38 am
Location: British Rail Class 450

Unread post

Removed from Patch 1.06 sticky:
Bombardiere above you said this:
Quote:
Adding new cargo types have caused issues

What are these issues? I haven’t noticed anything but would like to know

Having made a very basic upgrade to the economic model I don’t see a reason why new cargos cannot be implemented. If new cargos are specific to new buildings (where none of the new cargos are supplied or demanded by old buildings) the buildings are not constructible in old scenarios (due to not being selected by default in the industry list) and so the new cargos are simply not available.

-------------------------------------------------------

Now on to your points Milo:
Construct a tiny test map. Test the naming idea by creating a new cargo with an 'xxyBlah' internal name. Does it work?
- I'll test this out.
If so, is there a way to keep multiple new cargoes from colliding with each other? If I install xxyCrystals and then later decide to install xxxPigs, it disrupts scenario references to crystals, doesn't it?
- I'll test this out also.
Do we have to limit cargo releases to patches, in which we can control the installed cargo set? If so, which standard cargoes should we add?
-Would like to know this asap!
Is anyone up for creating new railroad cars to go with our shiny new locos?!
-Already started a few, but need to know what buildings/cargos before I continue.
User avatar
canis39
Brakeman
Posts: 153
Joined: Sat Nov 11, 2006 5:02 pm
Location: Reston, VA

Unread post

Assuming the game orders cargoes alphabetically, it seems like we should come up with a plan for naming conventions. If we add "crystals" today, but then next week someone wants to add "bricks", that would cause a problem (xxyCrystals would be displaced by xxyBricks). It seems to me that each custom cargo type would need to be added in alphabetical order (so we're always adding to the bottom of the list). So we could do something like this:

xaCrystals
xbBricks
xcApples
xd...
xe...

If the game only accepts up to 60 cargoes and 41 are currently identified, then we can only add 19 custom cargo types, so "xa" through "xs" would be sufficient.

(Just for the record, I'm pretty excited about new cargo types).
User avatar
Wolverine@MSU
CEO
Posts: 1166
Joined: Fri Nov 10, 2006 2:14 pm
Location: East Lansing, MI

Unread post

canis39 wrote:(Just for the record, I'm pretty excited about new cargo types).
Me too. It openss up a whole new dimension for scenario authors.
User avatar
pure al
Dispatcher
Posts: 306
Joined: Sat Dec 23, 2006 11:38 am
Location: British Rail Class 450

Unread post

I guess the thing would be to agree on some cargos that should definitely be added. Gravel + Cement are good. Also Copper and Money maybe. Then new buildings would need to be made, some agreement on those wouldn't hurt.

At the moment I'm spending most of my time trying to figure out how to make the game read icons for new cargo. I can swap the old cargo's icon, but not the new. The new ones have the ‘All Cargo’ icon :(
User avatar
pure al
Dispatcher
Posts: 306
Joined: Sat Dec 23, 2006 11:38 am
Location: British Rail Class 450

Unread post

Ok Milo, just some feedback on the project you set.
I tested names like xaMoney and xbBrains, and those work. I first installed xaMoney, and set up an event that triggered when 6 cargo loads of xaMoney went to another territory. The event worked as planned, I got a message. I then installed xbBrains and tried the scenario, the event got triggered as normal. The xa-xz system works.

What do you guys truly think about having a cargo named xaMoney, instead of just Money? Could there be a work around Milo?
User avatar
canis39
Brakeman
Posts: 153
Joined: Sat Nov 11, 2006 5:02 pm
Location: Reston, VA

Unread post

If there's a way to get the "real names" into the cargo type list, I'm all for it. However, if we have to stick with the "xa - xz" system, I don't think that's the end of the world. To me, the improved gameplay options would more than make up for the weird names.

Here's a somewhat random idea. Since the bakery already demands and consumes sugar & grain, would it be possible to give it a supply cargo of "Bread"?

My 2 cents on cargo types & buildings mentioned here:

There would seem to be quite a few "mines" to choose from. Copper, Gold, Silver, Nickel, Diamond.

I don't really understand Money as a cargo type. What building would supply Money? A Bank? Would it demand anything? Would there be buildings that demand Money?
milo
Engineer
Posts: 512
Joined: Sat Nov 11, 2006 5:36 pm
Location: End of the line

Unread post

There should be. I'm a little surprised that the .cty file doesn't contain a direct reference to an entry in the RT3.lng file.

Hmm... Constant strings are stored in the .rdata segment of RT3.exe. "Milk" is at 5D1CC8h. There's a pointer to that location at 624850h in the .data segment, followed by 0CF8h, which happens to be the index of "Milk" in RT3.lng, so I think we've found the translation table. Judging from the surrounding contents, I think the table starts at 6243C8h and has eight-byte entries, so Milk is record 91h. Table seems to end at 624B1Fh, so there are 235 total entries in the table. Unfortunately it looks as if it's constant-size, and there isn't room to stuff new entries into it. It also looks as if RT3 uses the 'internal' name if it doesn't find an entry in the translation table.

Fix ideas:
  • Instead of the xa-xz stuff, use a leading whitespace character with a character index higher than that of 'w' (77h). 95h and A0h look like possible candidates. Downside is that the names can't be translated into other languages.
  • Modify the code to search a second translation table if it doesn't find an entry in the first.
  • Modify the .cty format to include an RT3.lng index directly, then alter the reader code to fall back to this if the translation table lookup fails.
Stick to the xa-xz names for now. I'll work on the translation problem.

What happens if you try the cargo additions the other way around? If you install xbBrains, set up the event for xbBrains deliveries, and then install xaMoney, does the event still work or does it switch to testing xaMoney?
User avatar
Wolverine@MSU
CEO
Posts: 1166
Joined: Fri Nov 10, 2006 2:14 pm
Location: East Lansing, MI

Unread post

milo wrote:What happens if you try the cargo additions the other way around? If you install xbBrains, set up the event for xbBrains deliveries, and then install xaMoney, does the event still work or does it switch to testing xaMoney?
I think it would switch to xaMoney based on your previous description of how the naming system works. We need to pool our collective wits and come up with a list of new cargoes that would be added all at once (after testing the concept) in a patch update. I don't think it would work if everyone had their own custom set of cargoes, which would mean umpteen different versions of the .exe game file. I haven't given much thought as to what would be useful cargoes, but the ones already mentioned, gravel/cement/bread/money etc seem like good ones. We have 19 spaces, and I would suggest that at least 4 or 5 cargoes be left as "mapmaker defined".
That is to say, have "pVcargo1", "qVcargo2",rVcargo3", and "sVcargo4" that could be used by the mapmaker as cargoes that are not already a defined cargo type. So if a particular scenario wanted to have "Pepto Bismol" as a cargo, they could tell the player that "pVcargo1" is Pepto Bismol etc.
User avatar
pure al
Dispatcher
Posts: 306
Joined: Sat Dec 23, 2006 11:38 am
Location: British Rail Class 450

Unread post

I think the white space idea is genius, I will try it out. How many people actually use non-English versions? Milo it looks like you’ve thought of a few possible options, so I’m more optimistic. It’s great having you around :D Oh and I’ll try the cargo additions the other way round, and get back to you.

I’ve begun work on the Gravel – Cement industry. The idea behind having Money as a cargo is to have scenarios where train robberies can be used. Money is created at a Mint Factory, and Banks are the buildings that demand money. That’s still not a definite, so I’ll leave that industry for the moment. Who knows, the 60 cargo limit could be increased somehow, but there’s a lot of work ahead to just fill in the 15 blank cargo spaces, especially if it’s just me doing the hexing, texturing and research for not only the cargos but also the buildings. Obviously I’m also more than happy to create new buildings that use the old cargos in different ways, so in theory there could be lots of new content :wink:
User avatar
canis39
Brakeman
Posts: 153
Joined: Sat Nov 11, 2006 5:02 pm
Location: Reston, VA

Unread post

I had thought about money leading to "train robberies" in scenarios...I like that idea. I just didn't get the supply/demand idea. I didn't even consider a Mint as the supply building...duh! So the Mint is the supply and the Bank is the demand. That's not bad!
User avatar
pure al
Dispatcher
Posts: 306
Joined: Sat Dec 23, 2006 11:38 am
Location: British Rail Class 450

Unread post

:? Ok, I’m a little confused, I created a scenario that required 8 cargos of xbBrains to be delivered to another territory, this would give me a message when completed. I tested and it worked. I then installed xaMoney, and a building that required it. I made sure the building was activated in the industries list of the same scenario. I ran the scenario again, delivered xbBrains to the other territory, and the message appeared! So despite xaMoney going before xbBrains in the cargo list, it still worked. I've tested over and over again. Is there another way to test?

If Atlantis created a problem then why doesn’t this? I need to try using names 'Money' and 'Brains' to see if it works. More testing is needed.

Is it possible that Ned simply altered existing cargos (changed name and icon)? At the moment the only way I can have new icons is by replacing existing cargos.
milo
Engineer
Posts: 512
Joined: Sat Nov 11, 2006 5:36 pm
Location: End of the line

Unread post

It's quite possible I was wrong about what was causing the bug. Pretty sure Ned created new cargos by altering existing ones... I wonder if he didn't change the cargo index value?

I've uploaded a copy of the Atlantis resources from before Ned pulled it, if you want to experiment and try to figure out what's going on. I think JSS' testcase involved installing Atlantis, then playing the Ireland scenario - all sorts of events changed the cargo they were counting.
User avatar
bombardiere
Dispatcher
Posts: 425
Joined: Tue Nov 14, 2006 9:07 am
Location: Turku, Finland

Unread post

Is it possible that Ned simply altered existing cargos (changed name and icon)? At the moment the only way I can have new icons is by replacing existing cargos.
There might be something here. Cargoes are numbered and there are gaps in Poptop's numbering. this may be the issue.. I haven't tested this numbering, but it may be worth to look at.

Also cargo has a number of file besides of cty. Icon etc. are related with car data files, such as .cgo ...

Edit1 Most likely Cargo ID (line 58 ) in . cty file sets the icon. Icons are stored independently, but also as one larger picture in same way as the original profile views. (P.S. cargo car's profile view can be changed in same way as the engine's)

P.P.S Al perhaps you could share your test program, and we could see if we reach into same conclusion.
User avatar
pure al
Dispatcher
Posts: 306
Joined: Sat Dec 23, 2006 11:38 am
Location: British Rail Class 450

Unread post

What does the cargo index number do? I have changed it on some occasions, but also left it on others.

Thanks for the info about icons bomber, again another thing to add to my ‘to do’ list :)

I’ll see what I can do, if nothing makes sense I’ll upload the scenario and relevant cargos. It'll let you know. My files are now a complete mess, I have no idea what works and what doesn’t! :?

Edit: I've just been testing 4 new cargos named normally like 'money' and 'gravel'. My scenario testing all went positively, with all messages triggered. I'll delve into Ned's files tomorrow to see how he did it.
User avatar
bombardiere
Dispatcher
Posts: 425
Joined: Tue Nov 14, 2006 9:07 am
Location: Turku, Finland

Unread post

What does the cargo index number do?
I wish I would know... This Cargo ID might be idicating icon, but it also may have other fuction. I have never tested cargo/industry succesfully...
User avatar
pure al
Dispatcher
Posts: 306
Joined: Sat Dec 23, 2006 11:38 am
Location: British Rail Class 450

Unread post

Ok so I've started to look at Atlantis and found that Ned used ID numbers of original cargos.

Edit- Great news, I’ve solved the icon problem, I had to edit the icon’s imb file to mention the name of the image file.

Ned’s Atlantis might have caused other scenarios not to function because by using IDs of previous cargos the order was being changed. I was making my cargos with IDs of 46+, and so there was no re-arrangement of the old ones, hence no previous scenarios would be affected, I hope.

I’m going to start some texturing work for my cargos, but I have no idea how the cargo pricing stuff works, so I’ll just use poptop’s industries as a base for now. I’ll post a few industries next week, finished or not, just to see what you guys think. Still haven’t installed your 1.06 beta Milo, been busy figuring things out, but I’ll try and review asap :wink:
milo
Engineer
Posts: 512
Joined: Sat Nov 11, 2006 5:36 pm
Location: End of the line

Unread post

Wow! Nice work - I bet you're right that that's what caused the reordering. If so, it still looks as if we should include cargoes as parts of patches until there's time to develop a load-resource-from-scenario event, because we'll likely have the same issue with the sequence numbers that we thought we had with the name ordering.

Here's how the GMP file appears to index the existing cargos:

01 alcohol
02 aluminum
03 ammunition
04 automobiles
05 bauxite
06 cheese
07 chemicals
08 clothing
09 coal
0a coffee
0b corn
0c cotton
0d diesel
0e fertilizer
0f furniture
10 goods
11 grain
12 iron
13 livestock
14 logs
15 lumber
16 mail
17 meat
18 milk
19 oil
1a paper
1b passengers
1c plastic
1d produce
1e pulpwood
1f rice
20 rubber
21 steel
22 sugar
23 tires
24 toys
25 troops
26 uranium
27 waste
28 weapons
29 wool

Do these appear to match your IDs?
User avatar
bombardiere
Dispatcher
Posts: 425
Joined: Tue Nov 14, 2006 9:07 am
Location: Turku, Finland

Unread post

Ned’s Atlantis might have caused other scenarios not to function because by using IDs of previous cargos the order was being changed. I was making my cargos with IDs of 46+, and so there was no re-arrangement of the old ones, hence no previous scenarios would be affected, I hope.
Great :D I had a hunch it had something witht he IDs :lol:
Do these appear to match your IDs?
No. If I remember correctly, they do not.

This cargo stuff is a good news. See Al, I knew that in short time you would be theaching more stuff to me than I do. :D

However, with new cargo we need to think what consumes those. For example what consumes cement. I guess cities and thus houses, but this need modifying existing files. Perhaps this could be doen as a group effort later...

P.S. I am interesting following cargo model. A quarry -> stone/sand -> Pottery/glass work -> Potts/China -> Houses/Retail/Department store. May be we can discuss about it later ... much later...
Edit- Great news, I’ve solved the icon problem, I had to edit the icon’s imb file to mention the name of the image file.
Do you use the same principle than with the engine profiles??? May be you can later explain this process to me.
User avatar
Wolverine@MSU
CEO
Posts: 1166
Joined: Fri Nov 10, 2006 2:14 pm
Location: East Lansing, MI

Unread post

Maybe instead of just coming up with cargoes to add, we need to think about whole cargo chains as bomber did above. So far we've heard about:

Gravel/Sand -> Cement -> Buildings
Gold/Siver -> Mint (Money) -> Banks
Copper -> Wire -> Buildings/Cable Companies/Phone Co./Electrified Track
Stone/Sand -> Pottery/China -> Retail etc.

These four cargo streams alone cover 10 new cargoes. With only 19 spaces there isn't room for much more, especially if a few spaces are left for "User Definable" cargos.
Post Reply