OpenTPW

Theme Park Inc bank: the red-month mail#

This trace uses the identified English no-CD TPI Game.exe (SHA-256 77ea0c41410aad7c94a5eda658e31cb4ac05f7253aaf6746ad5e8a90afbd967a) and its shipped data. The game was not launched. It records what the bank does when a park stays in the red, which is the part of ECON-030 that docs/reverse/TPI-ADVISOR.md does not cover.

From the bank's month to the notification#

[BIN:TPI-EXE:0x5C0C49 red-month test] In its month message the bank takes the balance at +0x14. A negative balance with a nonnegative +0x124 gives a zero difference and no event; otherwise the bank dates the difference between the entered-red timestamp at +0x128 and the current date (0x4017EE, 0x871A30) and compares it with six. From six on it builds the event value 2 (0x5C0C9E) and broadcasts it on the lazily created event object at 0xA09728; it writes no state, opens no window and loads no artwork.

[BIN:TPI-EXE:0x5C091F bank event handling] The bank's own message handler receives that event as message type 19 whose payload field +8 is 2. Unless the world state at +0x1EAB78 is already 4 (the lost state that dismissing the letter sets, below) and unless 0x64A1D0 reports otherwise, it allocates a 36-byte record and posts it as message type 25 to the synchronous message centre (0x436DD0).

[BIN:TPI-EXE:0x5CEE50 notification record] The 36-byte record is {id 8, group 1, slot, 1, 0, tag 0x97, 1, tag 0x97}: the id at +4 is 8, the tag fields at +0x14 and +0x1C are 0x97 (151, the null tag the tag broadcast skips), and +8 is a 16-byte slot taken from the table at 0x9CD6D8. Its virtual 0x435DF0 returns 0x19 (25), so the message centre files it under type 25.

The only type-25 subscriber#

[BIN:TPI-EXE:0x635A72 tag system subscription] One object subscribes to type 25: the tag and mail system, whose handler table starts at 0x635D80 and whose own module logs TagSystem, MailMessage and numtags. Sixteen other types (the bank 0x5C08E0, the advisor 0x719470, the weather thing 0x641F60, …) are subscribed to other types, not this one.

[BIN:TPI-EXE:0x635E3F tag system dispatch] The handler dispatches on the message's type: 0x18 builds a record from a tag id, 0x19 (25) builds one from the notification's payload and 0x1B clears +0x12C. For type 25 it copies the payload's strings into the new 3,628-byte record, then picks a category and a text by the payload's id: id 6 → text 0x1A1, id 7 → text 0x1A3 with category 0x5F, id 8 → text 0x1A2 with category 0x5E (0x636288, 0x63625D, 0x636235). 0x5CD060 accepts ids 6 to 8 only; on acceptance the record is handed to the mail window's builder at 0x526CD0 (its flag object sits at 0xA59E50, set by 0x526940 and cleared at 0x526AC7; its window procedure is 0x526960, which gives the rows of category 0x5D/0x5E/0x5F their own actions) and the tag system's own +0xE0C is set.

The three advice messages the notification can carry#

The text ids the tag system uses are advice message ids, and each has a row in the same descriptor table the weather forecasts use (56-byte rows, +4 id, +8 message group, +0xC class, +0x10 score callback, +0x20 duplicate limit, +0x24 response). The oracle reads them after the native initializer runs:

Notification idMessageDescriptorGroupClassResponseSpeechTagTAG_SYSTEM.str entry
8 (the bank's six-month event)0x1A20x9E4878827498690x5E166
60x1A10x9E4840827488680x97none
7 (the challenge system's lost challenge)0x1A30x9E48B0827508700x5F167

The payload constructor 0x5CEE50 has three callers in the executable: the bank at 0x5C0969 (id 8), a window-module path at 0x53530C (id 8 again, after destroying a window) and the challenge system at 0x5C48DD (id 7), which logs Lost the challenge!!! on both of its call paths (0x5C7A2F, 0x5C8851) and clears a per-object word as it goes. So id 7 carries the challenge-lost advice, not a red-month variant, and nothing builds an id-6 record at all: message 0x1A1 has no sender in this trace.

Advisor.sam has no group 8 (its "Stuff to be said only once" comment heads group 9), so the group's intervals and limits keep their reset value 0. The advisor's queue never replaces a group-8 record and plays a pending one before any other (TPI-ADVISOR.md §3). The category the tag system writes is the advice's tag, so the three records carry 0x97 (id 6), 0x5F (id 7) and 0x5E (id 8) as their category; message 0x1A1 carries the null tag 0x97, which the tag broadcast skips, so it has no caption. The response rows are built by the same constructor as the forecast responses (0x715570); the null-tag row keeps the constructor's fallback words (-1, 0, 666, 0) because 0x636F70 refuses tags of 0x96 and above.

The caption the six-month mail carries is the bank's closure letter: TAG_SYSTEM.str entry 166 is a letter to the player saying the banks are forcing the park to close after six months in the red. The challenge mail's entry 167 is the same letter's second cause: the board is said to end the player's employment after too many failed challenges. Neither the bank nor the tag system changes the world state, but the letter is not only text: dismissing it ends the game (next section).

OpenTPW wires both mails into ThemeParkIncAdviceMail (ParkEconomy.TpiPendingMail): the advice goes into the advisor's queue, whose playback speaks it, and the client opens the letter window on the mail and loses the park when the letter is closed (ParkEconomy.LoseThemeParkIncPark). The bank's fires from the red-month rule; the challenge one fires on each lost challenge once the career firing line is used up (it starts at 5, 0x74BDD1, loses one per lost challenge at 0x5C4857 and posts whenever it is no longer positive at 0x5C48B6; see the challenge note). It still cannot appear in the shipped Theme Park Inc slice, because EconomyRules.ThemeParkIncMoney refuses the challenge system for that edition. The test drives it with the challenge system switched on and six lost challenges.

tools/ppc-analysis/oracle_x86/tpi_advisor_forecast_oracle.py checks the three descriptor rows, the three response rows and the tag-94 caption entry on the executable; it does not run the bank's month test, the message centre or the tag system's record builder.

The letter window and the end of the game#

[BIN:TPI-EXE:0x5CEF20 letter texts] The notification's own virtual functions (table 0x93DFA8) fill the tag system's record, all from TAG_SYSTEM.str (the string table at 0xA0D5F8): the subject is entry 165, "Game Over - You Lose!"; the sender is the first word of the sender row the constructor picked (row key 1 of the 16-byte table 0x9CD6D8: entries 173 and 174, a name and the title "President, Theme Park Inc."; 0x5CD0D0); the addressee, for the notification's +0xC value 1 that 0x5CEE50 writes, is the player's name (0x5CD14D, from the object at 0xAA0128); the body is entry 167 for id 7 and 166 for id 8, nothing for id 6 (0x5CEF60); a signature follows the body (0x5CD1C0: a newline, entry 173, a newline, entry 174). 0x5CD3A0 sets the record's first word to 0x8A and clears its go-to word +0xE10; the tag system then overwrites the first word with 0x5E for id 8 and 0x5F for id 7 (0x63623E, 0x636266) and opens the letter window on the record (0x636217, gated by 0x4029DC, unread).

[BIN:TPI-EXE:0x526CD0 letter window] The window is built over the layout table 0x9B4854 (root 0xA7F8, a !window at (46,44)-(2002,1492), 17 controls). The title 0xA806 and the Subject field 0xA7FA show the record's +0xC04; the From field 0xA7FC its +0x808; the To field 0xA800 its +0xA06; the Date field 0xA802 the record's +0xE24 through 0x518C30; their labels are UITEXT.str 857 "Subject:" (0xA7F9), 856 "From:" (0xA7FB), 855 "To:" (0xA7FF) and 858 "Date:" (0xA803). The mugshot 0xA7FE in the frame 0xA7FD shows frame +0xE02 minus 1, the body frame 0xA801 the record's +0x8, and the b_goto button 0xA808 is enabled only when +0xE10 is not 0 — never for these letters. The other buttons are b_close (0xA804), b_okay (0xA805) and b_help (0xA807).

[BIN:TPI-EXE:0x526960 letter window procedure] Message 5 and a click on any control but help (0xA807) destroy the window (message 4) and run the action of the record's category: 0x5E calls 0x649E60 with 0, 0x5F calls it with 1, and 0x5D calls 0x64A0B0 instead; a click on go-to also passes the record to 0x407D79. The window's close method 0x527420, which has no direct caller, runs the same actions. These are the only callers of 0x649E60 in the executable.

[BIN:TPI-EXE:0x649E92 game over] 0x649E60 writes the world state +0x1EAB78 = 4, the lost state the bank's handler tests (0x5C0931) and the only write of 4 in the executable, and passes the park's gate thing (the thing table 0xAA18B0 at the world's +0x1EAB66) and the reason to 0x4F8D80, which calls 0x50AFC0; it then walks the park's things and lists (not read further).

[BIN:TPI-EXE:0x50AFC0 loss window] The loss window is Theme Park World's (tp.exe 0x48AC40, see Hud/ParkHud.LossWindow.cs) with a text banner in place of the s_bkrupt model: it leaves the camera modes the flags at 0xA1465C name (0x4675A0, 0x4657F0), rides the gate's camera seat (0x5E5B20), disables the key tables (0x431230), closes the HUD's windows (message 5 to 0xA568BC, message 6 to 0xA60110 and 0xA60114), builds the full-screen window 0x7472 (2048 × 1536) with the procedure 0x50ACE0, and hands the caption object at 0xA5EA24 (0x53EE30: a window over the one-control table 0x9B96D8, sized to the text and centred on (1024, 768)) UITEXT.str 921 "BANKRUPT!" for reason 0 or 922 "Fired!" for reason 1.

[BIN:TPI-EXE:0x50ACE0 loss window procedure] As in Theme Park World, Escape (message 0x1000B, key 0x1B with no modifier bits) or a click of button 1 (message 0x10006) while the byte at 0xA1021D is set and more than 0x7D0 ms have passed since the creation message 21 leaves the window: it destroys it (message 4), leaves the seat camera (0x4657F0), hides the HUD behind its overlay (0x550BD0, the full-screen window 0xDDF22), enables the key tables again (0x4311E0) and clears 0xA568C4.

So the six-month letter is Theme Park Inc's bankruptcy and the challenge letter its dismissal: the park trades on only while the letter is open, and closing it loses the park. The earlier reading that the lost state belongs to a level teardown called from an "event-5 handler" took the letter window's message 5 for that handler.

The loss scene#

[BIN:TPI-EXE:0x53EE30 loss caption] The caption object at 0xA5EA24 (vtable 0x93CB38, whose message handler 0x53EDE0 does nothing) first destroys any caption it holds, then builds a window over the one-control table 0x9B96D8 through 0x4F4470 (the builder of Theme Park World's P window, tp.exe 0x47ED80). It measures the text in font slot 0 (0x500DE0(0), the MENUSMALL/MENUMED/MENUBIG family), sizes the window to it, and centres it on (1024, 768) (0x53EED7–0x53EF35), with the text centred both ways (0x84A4D2(1, 1, 3)). No colour call is made, so the text class's white stands (0x5123A3). The loss caption never moves, fades or expires; only the "GAME PAUSED" caption pulses. The same object shows the win window's "CONGRATULATIONS!" and "PLEASE WAIT".

[BIN:TPI-EXE:0x50ACE0 loss caption kept] Leaving the loss window does not touch the caption: the overlay 0xDDF22 is built over it as a later sibling. Theme Park World instead rebuilds its banner as a child of the overlay. The byte 0xA1021D the right-click exit tests is the setting RMBCancelOn (settings object 0xA101E0 +0x3D, serialized at 0x45A6E3). 0x550BD0 does nothing while [0xA1465C] & 0x16 is set, so the seat camera has to be left (0x4657F0) first.

[BIN:TPI-EXE:0x50B1C0 lost park reload] A reloaded lost park clears [0xA568C0], hides the HUD behind the overlay, builds the "BANKRUPT!" caption over it and gives the overlay the focus: no camera, no key-table change and no loss window.

[BIN:TPI-EXE:0x50D3F3 lost park menu] The lost park's menu has four lines, each a child window whose id is its command, made by 0x518FF0 (the steps of tp.exe 0x492F60) in font slot 0: Load Game (UITEXT 768, command 0x18, the load dialog 0x548570(1, 0)), Resume Game (771, 0x17), Select A New Player (774, 0x1A, 0x50B2B0 and "PLEASE WAIT" through 0x6A26B0(3, 1)) and Quit Game (772, 0x1B, 0x50BE60). A line's height is its text's plus 5, with 5 between lines, and the block is centred (y0 = half the window's height minus half the block's minus 10); Theme Park World starts its five lines (Load, Restart, Resume, Exit To Lobby, Quit) at 10. Opening the menu pauses nothing.

[BIN:TPI-EXE:0x42A17C lost pause lock] In the lost state the pause request 0x42A170 does nothing (its callers include the application's deactivation, the confirm-box builder, the pause menu, the Load dialog and the overlay's command 0xF), and the P toggle 0x42A270 refuses to pause but still resumes (0x42A27C); the resume 0x42A200 has no state check. tp.exe tests neither.

OpenTPW's Theme Park Inc HUD runs this scene (ThemeParkIncHud.Loss.cs): the gate's camera seat (Level.EnterLossView) under the centred caption, the Escape or late right-click exit into the hidden-HUD overlay that keeps the caption, the overlay's Escape into the four-line menu, the reload into the overlay with "BANKRUPT!" (reached through the economy snapshot; the Science continuation save refuses a lost park), and the pause lock. The letter window pauses nothing; a mail that arrives while a letter is open waits for it to close, because what the tag system does with a second notification then is not read. Not ported: the Theme Park Inc seat routine's extra writes (0x5E5B20: the gate's +0x5C byte and its script variable 0xC = 1), the panels 0x52FB80 and 0x5505C0(0) close and the window [0xA5E890], the lost Load Game's own branch of the load dialog (0x547A5F; OpenTPW continues the local Science slot), and the caption's drawn alpha. Whether the caption's full-canvas layer takes the pointer before the loss window (so a right click would never reach 0x50ACE0) is not read; OpenTPW follows the procedure.

What stays open#

The advisor's scoring keys InTheRedSixMonths, InTheRedThreeMonths, InTheRedMonthLeft and Bankrupted exist as strings at 0x982598, 0x98264C, 0x982700 and 0x9827B4, but neither those addresses nor any record around them is referenced by an immediate or a pointer in the file, unlike the descriptor rows the initializer writes by address. No consumer of them is traced in this executable. Whether a level script writes the world state itself is also unread, as are the gate 0x4029DC in front of the letter window, the category-0x5D action 0x64A0B0, the rest of 0x649E60 after the world state.

Source: docs/reverse/TPI-BANK-MAIL.md in the project repository.