Page 1 of 1
2cc locomotive (and rail type) selection
Posted: 03 Jul 2010 16:33
by Michiel
Am I doing something obviously wrong, or is 2cc lying to me?
Code: Select all
local engineList = AIEngineList(AIVehicle.VT_RAIL);
engineList.Valuate(AIEngine.IsWagon);
engineList.KeepValue(0);
engineList.Valuate(AIEngine.CanPullCargo, cargo);
engineList.KeepValue(1);
Debug("Engines for " + AICargo.GetCargoLabel(cargo));
for (local engine = engineList.Begin(); engineList.HasNext(); engine = engineList.Next()) {
Debug(AIEngine.GetName(engine));
}
In a normal game, this lists the normal locomotives. With 2cc loaded, I get an empty list. According to the docs for CanPullCargo:
AIEngine.CanPullCargo wrote:This function is not exhaustive; a true here does not mean that the vehicle can pull the wagons, a false does mean it can't.
However, I can manually build a steam or diesel loco and attach an appropriate wagon without problems.
Meta-issue: I'm not even trying to select a locomotive yet - I'm trying to find a rail type on which a locomotive can run, which can pull the desired cargo (i.e., not monorail). There's no way to find out which AIRail.RailType is which, is there? Except hardcoding the numeric IDs, but that's a little fragile...
Re: 2cc locomotive (and rail type) selection
Posted: 03 Jul 2010 16:38
by Michiel
Bonus question: how to figure this out with NuTracks?
Re: 2cc locomotive (and rail type) selection
Posted: 03 Jul 2010 17:19
by Yexo
Michiel wrote:In a normal game, this lists the normal locomotives. With 2cc loaded, I get an empty list.
That is because the 2cc trainset sets the "special AI flag 'optimized for passengers'" to true for all engines. As such I'd say it's a bug in the 2cc set.
Re: 2cc locomotive (and rail type) selection
Posted: 03 Jul 2010 17:40
by Michiel
Bugger. Is there a way (for an AI) to detect which newgrfs are loaded? Then I can at least hardcode a workaround for 2cc, since that is one of the most popular ones, it seems.
Re: 2cc locomotive (and rail type) selection
Posted: 03 Jul 2010 17:41
by frosch
Michiel wrote:Meta-issue: I'm not even trying to select a locomotive yet - I'm trying to find a rail type on which a locomotive can run, which can pull the desired cargo (i.e., not monorail). There's no way to find out which AIRail.RailType is which, is there? Except hardcoding the numeric IDs, but that's a little fragile...
Isn't
Code: Select all
engineList.Valuate(AIEngine.GetRailType);
what you are looking for? Then you can select an engine and a railtype from the list.
Bugger. Is there a way (for an AI) to detect which newgrfs are loaded? Then I can at least hardcode a workaround for 2cc, since that is one of the most popular ones, it seems.
Unlike other sets 2CC is maintained. So just wait a little for the fix.
Re: 2cc locomotive (and rail type) selection
Posted: 03 Jul 2010 17:45
by Yexo
Michiel wrote:Bugger. Is there a way (for an AI) to detect which newgrfs are loaded? Then I can at least hardcode a workaround for 2cc, since that is one of the most popular ones, it seems.
There isn't, and IMO there shouldn't be one either. Just bug the 2ccset devs hard enough so they get a fixed NewGRF out asap. (
bug report).
frosch: That code should come after the code Michiel already has (and which doesn't work due to a bug in 2ccset). First select all engines that can pull the given cargo, when you have a selection of engines you can create a list of railtypes by iterating over the engines and marking AIEngine.GetRailType() for each engine as usable.
Re: 2cc locomotive (and rail type) selection
Posted: 03 Jul 2010 17:46
by Michiel
frosch wrote:Michiel wrote:Meta-issue: I'm not even trying to select a locomotive yet - I'm trying to find a rail type on which a locomotive can run, which can pull the desired cargo (i.e., not monorail). There's no way to find out which AIRail.RailType is which, is there? Except hardcoding the numeric IDs, but that's a little fragile...
Isn't
Code: Select all
engineList.Valuate(AIEngine.GetRailType);
what you are looking for? Then you can select an engine and a railtype from the list.
Almost. That'll let me select an engine that'll run on that track, but then I still don't know if I can use it to pull wood/coal/... wagons. The problem is that I end up with third rail or monorail tracks which don't have cargo trains.
frosch wrote:Bugger. Is there a way (for an AI) to detect which newgrfs are loaded? Then I can at least hardcode a workaround for 2cc, since that is one of the most popular ones, it seems.
Unlike other sets 2CC is maintained. So just wait a little for the fix.
Would it help if I post a bug report, or is this a known issue?
Re: 2cc locomotive (and rail type) selection
Posted: 03 Jul 2010 17:48
by Yexo
The bug is known for about 20 minutes now, but it's already in both the 2ccset development forum topic and in their bug tracker.
Re: 2cc locomotive (and rail type) selection
Posted: 03 Jul 2010 17:48
by Michiel
Wow, you guys are fast

Re: 2cc locomotive (and rail type) selection
Posted: 04 Jul 2010 04:13
by Lord Aro
Of course, NoCab can use 2cc set trains, why not just copy thaat?

Re: 2cc locomotive (and rail type) selection
Posted: 04 Jul 2010 09:36
by Michiel
I don't think it does, actually. It uses the same CanPullCargo function I'm trying to use. It selects a locomotive for passengers/mail/valuables, but not for freight, and it doesn't actually build anything if I limit it to trains.
Re: 2cc locomotive (and rail type) selection
Posted: 06 Jul 2010 21:14
by DJ Nekkid
can you guys check if things works as intended now? now all _engines_ should not have the pax-bit set. r563 should have this. Pull/make or wait until 18:18 tomorrow

(or were that changed to 17:17?)
Re: 2cc locomotive (and rail type) selection
Posted: 06 Jul 2010 21:21
by planetmaker
It's still 18:18h local time on the clocks in Oslo, Amsterdam, Berling and Zurich.
What about setting the bit for a few MU. There's probably not much point to allow an ICE or TGV engine to tow a coal wagon... and it will be able to attach passenger and mail wagons only anyway (maybe valuables, don't know).
Re: 2cc locomotive (and rail type) selection
Posted: 07 Jul 2010 07:34
by Michiel
I think I'll have time to have a look at it tonight

Re: 2cc locomotive (and rail type) selection
Posted: 07 Jul 2010 09:40
by DJ Nekkid
planetmaker wrote:It's still 18:18h local time on the clocks in Oslo, Amsterdam, Berling and Zurich.
What about setting the bit for a few MU. There's probably not much point to allow an ICE or TGV engine to tow a coal wagon... and it will be able to attach passenger and mail wagons only anyway (maybe valuables, don't know).
AFAIK does all MUs (and metros) have this one set.
mu.tnfo wrote:
#ifndef THIS_ENG_AI_PAXOPTIMIZED
#define THIS_ENG_AI_PAXOPTIMIZED 01
#endif
the change on the engines were merely that 01 -> 00
and as far as i know dont any vehicle have that set in its .pfno file
