OpenTTD

Tasklist

FS#4758 - Allow referencing DCxx texts via textstack

Attached to Project: OpenTTD
Opened by George (George) - Friday, 02 September 2011, 23:28 GMT
Last edited by frosch (frosch) - Saturday, 03 September 2011, 16:12 GMT
Type Feature Request
Category NewGRF
Status Assigned
Assigned To frosch (frosch)
Operating System All
Severity High
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

R22804

when a GRF returns a DCxx string in reference stack for error message for CB 28/2F, OTTD crashes

Steps to reproduce:
Start a new game, give yourself some money and try to build vehicles factory on the sloped land. Game crashes.

The change I did to the factory is changing the String to return
D0xx string, returned as D4xx works fine
48xx string works well without a change
00e7 string does not work both as 00E7 and 04E7 (the name is not displayed)

P.S. In some old version of OTTD (before 10000 AFAIR) DCxx strings were working. I just did not use them because of TTDP
This task depends upon

Comment by Michael Lutz (michi_cc) - Saturday, 03 September 2011, 00:30 GMT
Quoting the NewGRF specs (which apply to OpenTTD as well): "[...] but DCxx textIDs won't work correctly. When you need to choose from your own texts dynamically, you must use D0xx IDs, and add 400h to them [...]"

OpenTTD still shouldn't crash though but handle the error gracefully.
Comment by Ingo von Borstel (planetmaker) - Saturday, 03 September 2011, 05:13 GMT
backtrace:

Reason: KERN_INVALID_ADDRESS at address: 0x61616368
Utf8Decode (c=0xbfffae90, s=0x61616368 <Address 0x61616368 out of bounds>) at /Users/ingo/ottd/trunk/src/string.cpp:459
459 if (!HasBit(s[0], 7)) {
(gdb) bt
#0 Utf8Decode (c=0xbfffae90, s=0x61616368 <Address 0x61616368 out of bounds>) at /Users/ingo/ottd/trunk/src/string.cpp:459
#1 0x00335cde in Utf8Consume [inlined] () at /Users/ingo/ottd/trunk/src/string_func.h:696
#2 0x00335cde in FormatString (buff=0xbfffb2cf "Can't construct this industry type here...", str_arg=0x19e57b39 " requires flat land", args=0x531420, casei=0, last=0xbfffbacb "", dry_run=true) at /Users/ingo/ottd/trunk/src/strings.cpp:696
#3 0x00336048 in FormatString (buff=0xbfffb2cc "Can't construct this industry type here...", str_arg=0x19e57b39 " requires flat land", args=0x531420, casei=0, last=0xbfffbacb "", dry_run=false) at /Users/ingo/ottd/trunk/src/strings.cpp:681
#4 0x0033c7c5 in GetStringWithArgs (buffr=0xbfffb2cc "Can't construct this industry type here...", string=57356, args=0x531420, last=0xbfffbacb "") at /Users/ingo/ottd/trunk/src/strings.cpp:188
#5 0x0033ce7b in OTTD_GetString (buffr=0xbfffae90 "M?", string=57356, last=0xbfffae90 "M?") at /Users/ingo/ottd/trunk/src/strings.cpp:195
#6 0x0019c52f in GetStringHeight (str=57356, maxw=-1073762672) at /Users/ingo/ottd/trunk/src/gfx.cpp:806
#7 0x001d9272 in ErrmsgWindow::UpdateWidgetSize (this=0x19b9fcb0, widget=2, size=0xbfffbb70, padding=@0x4183e8, fill=0xbfffbb68, resize=0xbfffbb60) at /Users/ingo/ottd/trunk/src/misc_gui.cpp:610
#8 0x003a76c5 in NWidgetLeaf::SetupSmallestSize (this=0x19ba0050, w=0x19b9fcb0, init_array=true) at /Users/ingo/ottd/trunk/src/widget.cpp:2198
#9 0x003a8283 in NWidgetVertical::SetupSmallestSize (this=0x19ba00b0, w=0x19b9fcb0, init_array=true) at /Users/ingo/ottd/trunk/src/widget.cpp:1208
#10 0x003aaaa4 in NWidgetBackground::SetupSmallestSize (this=0x19b9ff80, w=0x19b9fcb0, init_array=true) at /Users/ingo/ottd/trunk/src/widget.cpp:1647
#11 0x003a8283 in NWidgetVertical::SetupSmallestSize (this=0x19b9ff30, w=0x19b9fcb0, init_array=true) at /Users/ingo/ottd/trunk/src/widget.cpp:1208
#12 0x003b3283 in Window::InitializeData (this=0x19b9fcb0, desc=0x549860, window_number=-1073762672) at /Users/ingo/ottd/trunk/src/window.cpp:939
#13 0x003b3334 in Window::FinishInitNested (this=0x19b9fcb0, desc=0x549860, window_number=0) at /Users/ingo/ottd/trunk/src/window.cpp:1320
#14 0x001d8021 in ShowErrorMessage (summary_msg=2839, detailed_msg=57356, wl=WL_INFO, x=1312, y=3744, textref_stack_size=4, textref_stack=0x51b500) at /Users/ingo/ottd/trunk/src/misc_gui.cpp:598
#15 0x0015b457 in DoCommandP (tile=59986, p1=10, p2=2724134600, cmd=186056746, callback=0, text=0x0, my_cmd=true) at /Users/ingo/ottd/trunk/src/command.cpp:533
#16 0x001becdd in BuildIndustryWindow::OnPlaceObject (this=0x1a2f7e30, pt={x = 1312, y = 3746}, tile=59986) at /Users/ingo/ottd/trunk/src/industry_gui.cpp:559
#17 0x00397735 in HandleViewportClicked (vp=0x19b1b5e0, x=639, y=346) at /Users/ingo/ottd/trunk/src/viewport.cpp:1898
#18 0x003b46fa in HandleMouseEvents () at /Users/ingo/ottd/trunk/src/window.cpp:2226
#19 0x003b8bdc in QZ_GameLoop () at /Users/ingo/ottd/trunk/src/video/cocoa/event.mm:423
#20 0x003b6562 in -[OTTDMain applicationDidFinishLaunching:] (self=0x2a00ea0, _cmd=0x927dd8ab, note=0x1da9aa0) at /Users/ingo/ottd/trunk/src/video/cocoa/cocoa_v.mm:71
#21 0x94feaefc in _nsnote_callback ()
#22 0x967c2793 in __CFXNotificationPost ()
#23 0x967c219a in _CFXNotificationPostNotification ()
#24 0x94fdfcf0 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#25 0x94fed0fd in -[NSNotificationCenter postNotificationName:object:] ()
#26 0x90493216 in -[NSApplication _postDidFinishNotification] ()
#27 0x90493126 in -[NSApplication _sendFinishLaunchingNotification] ()
#28 0x905ea339 in -[NSApplication(NSAppleEventHandling) _handleAEOpen:] ()
#29 0x905e9f59 in -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] ()
#30 0x95020298 in -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()
#31 0x9502005c in _NSAppleEventManagerGenericHandler ()
#32 0x94782f5c in aeDispatchAppleEvent ()
#33 0x94782e5b in dispatchEventAndSendReply ()
#34 0x94782d65 in aeProcessAppleEvent ()
#35 0x916ec197 in AEProcessAppleEvent ()
#36 0x904637d2 in _DPSNextEvent ()
#37 0x90462dd6 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#38 0x904251f3 in -[NSApplication run] ()
#39 0x003b6767 in VideoDriver_Cocoa::MainLoop (this=0x1e41180) at /Users/ingo/ottd/trunk/src/video/cocoa/cocoa_v.mm:373
#40 0x0025a806 in ttd_main (argc=1, argv=0xbffff8a4) at /Users/ingo/ottd/trunk/src/openttd.cpp:721
#41 0x00269f34 in main (argc=1, argv=0xbffff8a4) at /Users/ingo/ottd/trunk/src/os/unix/unix.cpp:266
Comment by George (George) - Saturday, 03 September 2011, 08:30 GMT
http://newgrf-specs.tt-wiki.net/wiki/Action0/Industries#Industry_name_.281F.29:
Industry name (1F)
This is the text ID that will be attached to the town name when TTD texts refer to the industry.

Why the name should be DCxx, but CB 2F\28 requires D0xx string? How to use the same string in industry name and industry error?
Comment by George (George) - Saturday, 03 September 2011, 09:17 GMT
looks like industry name works when it is d0xx string
Comment by frosch (frosch) - Saturday, 03 September 2011, 16:12 GMT
  • Field changed: Type (Bug → Feature Request)
  • Field changed: Summary (OTTD crashes on DCxx string → Allow referencing DCxx texts via textstack)
  • Field changed: Status (New → Assigned)
  • Field changed: Category (NewIndustries → NewGRF)
  • Task assigned to frosch (frosch)
The crash has been fixed in r22882.

Support for using such strings might actually be added in OTTD.

Loading...