Page 22 of 47
Posted: 15 May 2003 18:38
by SHADOW-XIII
krtaylor wrote:It may not be possible to alter the AI. Would it be theoretically possible to disconnect the AI altogether and competely rewrite it, with the new code using the old pointers to lay track, operate, etc.?
there is no enough space/memory to do that
Posted: 15 May 2003 18:46
by eis_os
If you want rewrite the AI please do it we will try to pack it in memory. But you have to write the AI routines.
Posted: 15 May 2003 19:33
by krtaylor
Please, please, there are so many great Patch things under development, and more we are waiting for, that an enormous project like rewriting the AI is NOT a real request. I was asking if, theoretically, it is even possible. It sounds like we are not even sure if it is theoretically possible. Let's not worry about it. Maybe later (much, much, much later...) It seems like the understanding of the TTD code is growing by leaps and bounds, I keep reading about new ways to fiddle with it that nobody thought could be done, that now are understood. Who knows, maybe someday Josef will reverse-compile the whole thing and we'll be all set.

Posted: 16 May 2003 01:08
by Sokko
Good point; is it at all possible to decompile TTD? If you know what it's written in, there's a good chance that you can find some decompilers on the internet that will do the job nicely. Depending on the language, I think you can lose some of the information. Let's hope not.
Posted: 16 May 2003 01:54
by krtaylor
I am not an expert in this area, but my understanding is that TTD is written in some sort of unusual low-level code that makes it very challenging to reverse engineer. When it was written it was not uncommon to write a whole custom "game engine" as a platform to develope the actual game on, so in effect it would be two separate layers of different code, neither of which being straightforward. Am I correct in understanding that the way the patch works, is actually by going up into main memory and changing various pointers around after TTD is loaded into the computer's memory? In other words, it isn't changing any code at all, it is more of a "parasite" that rides on top of what is already there without really interacting with it.
Posted: 16 May 2003 04:29
by Patchman
TTD was written in assembly, and you can download the disassembly (which is what's closest to decompiling for assembly language) from Marcin's site at
http://kufel.immt.pwr.wroc.pl/~mgrzegor/ttdpatch/ida/ .
And you're incorrect. The patch actually mostly changes the code, there's only very little data it changes. For the most part, it finds a line of code where TTD does something important, and replaces it with a call to TTDPatch's improved version of that code.
For example, when a train enters or leaves a signal block, TTD finds out whether the signals can go green. This check is replaced by a call to TTDPatch, which additionally takes pre-signals into account.
Same for the selectgoods feature. TTD scans the area around an industry for stations. When it finds one, it distributes part of the cargo to it. TTDPatch replaces that with a check which first tests whether the cargo should be delivered at all, i.e. whether there was a carrier for it there before.
So the patch in general finds a "hook" into TTD's code, and replaces this hook with a call to an improved version that does more than TTD does. That's the patched code. Basically, it works on the old saying, "give me a big enough lever and the right hook and I can move the Earth."
Trivia time: Currently, there are about 280 code hooks, and 140 data hooks (to find locations of TTD variables etc.).
Posted: 16 May 2003 05:26
by spaceman-spiff
I thought it was like that, nice workaround if you haven't got the source code, that's probably the reason when you add/fix something, sometimes other things go broke

Posted: 16 May 2003 05:55
by Patchman
We do have the source code (i.e. the disassembly). It's just not what "normal" people would use as a programming language. I guess that means CS isn't "normal"...
Anyway, the patching really gets complicated if you need 50 hooks to add one feature. This would be the case for example for the two-runway-airport or other similarly complicated things. The first problem is that it takes hours to find each hook, and the second is that you can be sure that you forgot to change one important one, and won't find out until two days after the release version is out...
Bridges and Signals
Posted: 16 May 2003 13:30
by Flavius
Hi
Currently i am playing a game where my trains cross a short high speed bridge into a very big busy terminal. I cannot place signals on the bridge
so traffic builds up all the time
Would it be possible to have the watercourse pass under the rails via a concrete subway/pipe or tunnel

Thus i could place signals then

........
Posted: 16 May 2003 13:41
by krtaylor
Another way of putting this would be, can we put signals on a bridge? This has come up before but I don't remember where it went.
Posted: 16 May 2003 14:31
by eis_os
krtaylor wrote:Another way of putting this would be, can we put signals on a bridge? This has come up before but I don't remember where it went.
Not possible, really there isn't any bit free for place signals on or under bridges.
I have currently the same problem to add support for speedlimit signs.
ohh, now everyone knows what I am doing next

Posted: 16 May 2003 14:42
by krtaylor
What's the purpose of speedlimit signs? Why would you want to slow down the trains beyond what already slows them down (curves, hills, etc.)?
Posted: 16 May 2003 14:47
by SHADOW-XIII
if you could add speedlimit signs with red/green ligts (or semaphores) then we will get slow down ligts
Posted: 16 May 2003 15:05
by krtaylor
I'm still not sure I quite understand this. Is this anything like the "caution" signals I talked about some time back, where the signal behind a train would be red, then the one behind THAT would be yellow (slow down), then the one behind THAT would be green (full speed)?
Posted: 16 May 2003 15:10
by eis_os
Speedlimit signs before and behind a rail / road crossings makes sense or?
Maybe I will affect town ratings if your trains travel 200km/h in Towns
We will see what I can add to TTD
-add-
No I don't change anything in the Presignals,
it will break the complete routines for it. No No...
Posted: 16 May 2003 15:24
by krtaylor
Speaking of the presignals, ever since I installed the most recent alpha version and the new trainsets, I don't have presignals. They don't get created automatically, and CTRL doesn't do them either. I have the switches turned on in TPS. I do have the semaphore graphics installed but they don't seem to be working either. Any ideas?
Posted: 16 May 2003 16:35
by Dinges
Whatch for spaces after a line in your newgrfw.txt, DL the latest, place them in another order in your newgrfw.txt
And see if you can see what stands there by using the ? (query) tool
Re: Bridges and Signals
Posted: 16 May 2003 20:19
by Saiyan
Rollo wrote:Hi
Currently i am playing a game where my trains cross a short high speed bridge into a very big busy terminal. I cannot place signals on the bridge
so traffic builds up all the time

...
Why not split the bridge in two by raising a square of terrain someways in its path and planting your signals there?
Posted: 16 May 2003 20:26
by spaceman-spiff
That's too easy

Posted: 16 May 2003 21:38
by MagicBuzz
A little bugfix that should be easy to do :
-> Saving durrency, system measurment, town names mode and drive side screen.
I use to forget updaing these setting each time I start a new game, and I must restart a new game to change these settings.
It may be very cool if these parameters would be kept as the game diffucult settings
