Cargo Distribution
Moderator: OpenTTD Developers
Re: Cargo Distribution
Same slowdown here.
Winxp, MinGW-MSYS.
After some testing the problem seems to be with mailhandling.
If you leave mail unhandled -> no slowdowns.
Mind I only tested the slowdown and did not have a look at the source other than changing the patch to svn.
For testing i used a savegame.
hope this helps a bit.
Winxp, MinGW-MSYS.
After some testing the problem seems to be with mailhandling.
If you leave mail unhandled -> no slowdowns.
Mind I only tested the slowdown and did not have a look at the source other than changing the patch to svn.
For testing i used a savegame.
hope this helps a bit.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Re: Cargo Distribution
I tried it again, with mail unhandled (just like ChillCore). The same problem occurs again (even when I only let passengers have symetric handling).ChillCore wrote:Same slowdown here.
Winxp, MinGW-MSYS.
After some testing the problem seems to be with mailhandling.
If you leave mail unhandled -> no slowdowns.
Mind I only tested the slowdown and did not have a look at the source other than changing the patch to svn.
For testing i used a savegame.
hope this helps a bit.
I can also better pinpoint the moment the problem occurs. I let two buses drive from A->B and the other from A->C. No problems when they arrive at station A for the first time. When they arrive for the first time at B & C, then OpenTTD suddenly consumes 99% CPU. I have opened the stations GUI for stations A, B & C and clicked on the passengers (so I get more details).
Re: Cargo Distribution
I really tried only changing one value at a time...
*blushing smiley here*
I tried that again with a clean cfg.
I left everything like set by the patch and reduced the accuracy setting to 1.
That did the trick, not mail.
Even when set to 8 the slowdown is significant.
sorry again for that false bit of information.
*blushing smiley here*
I tried that again with a clean cfg.
I left everything like set by the patch and reduced the accuracy setting to 1.
That did the trick, not mail.
Even when set to 8 the slowdown is significant.
sorry again for that false bit of information.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Re: Cargo Distribution
Sorry, I'm a noob at this. But when I do 'apply patch' with Tortoise nothing appears. Can someone help please! 

Re: Cargo Distribution
What evidence do you have that nothing happened?
IOW, list exactly the steps you took, exactly the messages that the computer spat out at you, exactly the results you observed, and exactly the results you expected.
IOW, list exactly the steps you took, exactly the messages that the computer spat out at you, exactly the results you observed, and exactly the results you expected.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Re: Cargo Distribution
1. I downloaded the diff. file from the openings post.
2. I created a folder and downloaded the files from svn.openttd.org with tortoise
3. Then I right clicked on that folder and choosed 'apply patch' and I clicked on the Cargodist.diff
4. Tortoise opened but then nothing happened...
Thanks for the help already!
2. I created a folder and downloaded the files from svn.openttd.org with tortoise
3. Then I right clicked on that folder and choosed 'apply patch' and I clicked on the Cargodist.diff
4. Tortoise opened but then nothing happened...
Thanks for the help already!
Last edited by CrossSide on 12 Apr 2009 12:44, edited 2 times in total.
-
- Chief Executive
- Posts: 697
- Joined: 10 Jun 2003 00:19
- Location: Australia
Re: Cargo Distribution
Could you please use 'directory' or 'folder' instead of 'map'. In English, map means something else.
Re: Cargo Distribution
Changed it, sorry my English isn't perfect 

Re: Cargo Distribution
You need to change the file in various places like this.4. Tortoise opened but then nothing happened...
From:
diff --git a/source.list b/source.list
index 452a2c3..3431c2e 100644
--- a/source.list
+++ b/source.list
To:
Index: source.list
===================================================================
--- source.list (revision 16003)
+++ source.list (working copy)
For the new files you do this:
Index: src/linkgraph.cpp
===================================================================
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ src/linkgraph.cpp (working copy)
I tried pulling a diff for turtoise but the new files are not included in the created patch.
The patch i have for turtoise is the first 16003.
If you do not mind doing the upgrade to cargodist_r16003_2.diff yourself manually, i could post that one in the meantime.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Re: Cargo Distribution
I tried to change it but I cannot copy/paste? Sorry, I'm really not good at this 

Re: Cargo Distribution
Sure you can, a patch file is human readable. It is just a lot of work.
Lines starting with +++ or --- state which file is being handled.
Lines starting with @@ give line numbers
Lines starting with " " (a space) as first character are context, and you should find them exactly in your source file.
Lines starting with "-" as first character are to be deleted from the source file.
Lines starting with "+" as first character are to be copied at the appropiate place into the source file (without the leading "+").
Lines starting with +++ or --- state which file is being handled.
Lines starting with @@ give line numbers
Lines starting with " " (a space) as first character are context, and you should find them exactly in your source file.
Lines starting with "-" as first character are to be deleted from the source file.
Lines starting with "+" as first character are to be copied at the appropiate place into the source file (without the leading "+").
Re: Cargo Distribution
Thanks for the testing and the savegames. I think I can make some sense of it. So, to sum it up. Please correct me where I am wrong:
So, if you have a build and some time around, please try with accuracy == 1 and tell me if it still freezes.
Of course, if I can identify the problem to be related to my usage of floats, it will be obsolete as soon as the replacement for the MCF solver is ready.
- The freezing occurs with builds on Win XP with mingw, possibly only those made with BuildOTTD (which generally uses gcc 3.4).
- It is possible to reduce the accuracy to 1, which shouldn't be. 1 for accuracy should yield fairly random results, if any. 2 is a meaningful minimum.
- When reducing accuracy to very small numbers the freezing problem is less likely to occur.
So, if you have a build and some time around, please try with accuracy == 1 and tell me if it still freezes.
Of course, if I can identify the problem to be related to my usage of floats, it will be obsolete as soon as the replacement for the MCF solver is ready.
I have a git repository here, but no easy way to publish it. Any ideas?TrueBrain wrote:Ever considered using a Mercurial or Git repository for your code? Easier to track, and easier for us to follow
The guy on the picture is not me, it's Alonso.
Re: Cargo Distribution
Code: Select all
1/accuracy < epsilon
Code: Select all
1 < epsilon * accuracy
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Cargo Distribution
Using floats isn't a good idea
the devs avoid them because they are known to cause desyncs and other nasty things. Almost everything can be calculated with integers too AFAIK.

Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)

OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone

OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone







Re: Cargo Distribution
I know.Zuu wrote:can be changed toCode: Select all
1/accuracy < epsilon
In pure math, these are equivivalent, but when using integers such changes can be of significant importance.Code: Select all
1 < epsilon * accuracy
I know.XeryusTC wrote:Using floats isn't a good ideathe devs avoid them because they are known to cause desyncs and other nasty things. Almost everything can be calculated with integers too AFAIK.
Did you read what I wrote on Thursday? Whatever - in order to find out *why* it freezes after a month I leave the float calculations in for now and test with them. Otherwise I might create a situation where the problem is less obvious but still there. Thus it would be harder to debug than the current situation. I'm not completely sure that the float calculations are causing the problem, it's only a hypothesis for now. So, if you'd like to help me, please try with accuracy == 1. I will change the MCF solver to only use integer calculations as soon as the freezing problem is solved.
The guy on the picture is not me, it's Alonso.
Re: Cargo Distribution
Hi,
I've compiled your patch applied to r160003 with MSVC on WinXP and I think I've found a bug: the game asserts on with "invalid operator<"
You can reproduce it building two stations and a bus (I haven't tried any other type of transport) connecting them (A->B). The assertion will pop up some time after the bus reaches both bus stops for the first time (probably on first graph recalculation).
I had some time and started debugging your code and I think I've found the cause. The can't be used as predicate because it's not strict when x == y as in that case it returns true. I've changed it to
and the problem was gone. Also after confirming that I can build one route and keep playing I've created a second line B->C with one bus and tried to reproduce the "freeze" bug, but it hasn't occurred (let it run on fast forward for more then 2 game years).
I've attached a save, the assert (or freeze if it's the same problem) should appear on 7th March 1950.
I hope these informations will help you to finish this great patch
I've compiled your patch applied to r160003 with MSVC on WinXP and I think I've found a bug: the game asserts on
Code: Select all
template<class ANNOTATION>
void MultiCommodityFlow::Dijkstra(NodeID from, PathVector & paths) {
...
annos.erase(dest); //line 124 in mfc.cpp
...
}
You can reproduce it building two stations and a bus (I haven't tried any other type of transport) connecting them (A->B). The assertion will pop up some time after the bus reaches both bus stops for the first time (probably on first graph recalculation).
I had some time and started debugging your code and I think I've found the cause. The
Code: Select all
bool DistanceAnnotation::comp::operator()
Code: Select all
bool DistanceAnnotation::comp::operator()(const DistanceAnnotation * x, const DistanceAnnotation * y) const {
if(x == y)
return false;
return !greater(x->GetAnnotation(), y->GetAnnotation(), x, y);
}
I've attached a save, the assert (or freeze if it's the same problem) should appear on 7th March 1950.
I hope these informations will help you to finish this great patch

- Attachments
-
- debug 2, 28th Feb 1950.sav
- (105.33 KiB) Downloaded 272 times
Re: Cargo Distribution
Thanks isk. We have just duplicated efforts. Actually I spent half the afternoon installing stuff into the BuildOTTD-supplied mingw in order to reproduce the problem and then another hour to find out how to interrupt the program manually to examine the stack, but finally I have managed to ... and found out that the freeze is caused by exactly the same effect. But it's still nice to see people care about this patch.
I'll post a fixed all-in-one version in the first post.
I'll post a fixed all-in-one version in the first post.
The guy on the picture is not me, it's Alonso.
Re: Cargo Distribution
Probably lots of people do just like me, but they lurk most of the timefonso wrote:But it's still nice to see people care about this patch.

Re: Cargo Distribution
Don't worry that not enough people care - lots of us do, but for most (including me) the technical discussion is way over our head... And for some of us just a .patch is not enough; if anyone (not fonso, he has other things to do
) has a Windows .exe, that'd be handy...

Re: Cargo Distribution
The problem with posting buggy binaries is you can not change anything.MJS wrote: Don't worry that not enough people care - lots of us do, but for most (including me) the technical discussion is way over our head... And for some of us just a .patch is not enough; if anyone (not fonso, he has other things to do ) has a Windows .exe, that'd be handy...
If you compile yourself that is another story.
@fonso:
I am going to test your patch and i will post a patch for turtoise.
If you think the patch is stable enough I will post my binaries too,
if that is okay with you that is.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Who is online
Users browsing this forum: No registered users and 13 guests