Text Corruption on build

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
traskjd
Engineer
Engineer
Posts: 40
Joined: 17 Nov 2004 04:18
Location: Wellington, New Zealand
Contact:

Text Corruption on build

Post by traskjd »

Hi,

Before I get blasted for asking a question about code not working when it comes right from SVN, this is just to ensure I'm not doing anything wrong.

I'm a software developer, although pretty much all .net these days I remember C / C++ etc and am interested in poking around the code and possibly working on changes in the future (work and life willing :-) )

However, I'm having a problem and I'm not sure if it's me or the code - I'm willing to bet it's me.

When I compile the network branch of OpenTTD I can get it built fine in both Debug and Release mode however when I run it I get a pile of corrupted multi-coloured text at the bottom of the screen. Also an error about a string character in the console window behind it (if running the debug build). I've grabbed the latest a few times from the networking branch and all the times I've done it I've had this problem - before and after you guys trialled playing the multiplayer - so I'm thinking it's probably just me.

Is this a common newbie setup problem? Just looking for an answer, then the thread can be locked or deleted :-) It's just for future reference as well.

BTW, to whoever is coding the new network layer, it's looking good, certainly a lot of code has been written from what I've seen :-)

- JD

P.S. Running on Win2k3, VS.Net 2003 [No problems with 2k3 and the normal download, just when I compile :)]
traskjd
Engineer
Engineer
Posts: 40
Joined: 17 Nov 2004 04:18
Location: Wellington, New Zealand
Contact:

Post by traskjd »

Since I'm not getting too much of a response I can only guess I haven't given enough detail :-)

Here is a screen dump from the game as soon as it loads.
Attachments
Screen corruption example
Screen corruption example
example.PNG (186.08 KiB) Viewed 3159 times
User avatar
Celestar
Director
Director
Posts: 574
Joined: 02 Jul 2004 10:56
Contact:

Post by Celestar »

I cannot reconstruct the problem, most likely to the fact that there is no Windows installation whatsoever on any computer in this house. I'll relay it to our windows devs.

Celestar
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

Hi traskjd,

It is actually a very easy bug to fix if you know where to look. In fact, I was just shown this today and with nowhere to look fixed it in ten minutes. Here's the lowdown. You should've started ottd with debugging on (-d 1) or higher (-d 4...etc.). In the console window you could then see that all it spams is "Unknown string command character". Now find that line of code in the source (gfx.c line 562), start going back from the stacktrace (called functions) to see where it might go wrong. It is in fact called by "DrawTextMessage" (texteff.c line 168). At that moment you can see that the culprit variable i is 10. But the maximum size of _text_message_list is MAX_CHAT_MESSAGES (which is also 10). Of course accessing the 10"th" element is an invalid out of bounds access and you get garbage. The fix is straightforward now :) (for (i=MAX_CHAT_MESSAGES-1...).

Well that was it ;). The debugger is your best friend ^^ (check out the latest rev to see this bug fixed).

Cheers.

(of course this only happened on windows, where for some (weird) reason the --i didn't get applied when the loop was entered, but afterwards. GCC did it fine. Which one is right/wrong I don't know).
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
traskjd
Engineer
Engineer
Posts: 40
Joined: 17 Nov 2004 04:18
Location: Wellington, New Zealand
Contact:

Post by traskjd »

Thank you very much!! :-D

I did have a poke around, got as far as seeing where it was happening but didn't think of the size! My mistake :-)

Alright, now I can keep on with tinkering and hopefully in the future I can come up with some contributions :-)

Thanks again,

traskjd
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 48 guests