User:AF

From sc2k-reverse
Jump to navigationJump to search

Landing page for information that isn't yet ready to go into the main sections on the site.

It will mostly account for a naming changes concerning marked down functions during the trawl with IDA.

Movie Function References

Oh the pain..

Although for now this is a suspicion, the next target is likely going to be the Smacker functions (specifically SmackOpen()).

Confirmed for now, when SmackOpen() is called, amongst other things it is passing the constructed filename.

Working on importing the "needed" functions at present.. and then we'll see what happens.

As it turns out although the initial failure check had been bypassed with the correct path, the one that SmackOpen() got was still the original.

So half-way there.

LPCSTR - const string.

1

Unsure where this is called from, though DATA XREF: .rdata:004DEE68
Thunk - 0x401C4E
Main - 0x48B2E0

Apparently it is a function within a class. __thiscall

Though this specific case may be a diversion.

2

Called from GameDoIdleUpkeep()
Thunk - 0x401104
Main - 0x48A980

Movie data directory address: 0x4EAA78

By default it references: '\DATA\'

No drive letter by default, so this is touched upon elsewhere.

3

Called from both GameDoIdleUpKeep and '1' just above
Thunk - 0x402360
Main - 0x48A810

It also references: '\DATA\'

Portability

Exploring portability currently, ie storing all relevant registry keys for the sc2kfix module, sc2k and scurk in a specific ini file.

The idea in this case is that the library will create an ini by default with 'portability' disabled, so the current behaviour is preserved, however when it is enabled then it will load/save all settings from there.

This will require a few tweaks concerning binary detection so it knows what to touch, load and save.

At the moment this is an experiment.

Thus far the following has been done:

  • A new 'sc2kfix.ini' is created
  • If the internal '[sc2kfix]' section isn't present it will migrate the previously stored registry entries, otherwise it will resort to the internal defaults.
  • All SimCity 2000 and SCURK entries are similarly migrated if they exist (or it goes through the usual installation process than then adds the necessary sections to the new ini file).
  • The imported used registry functions have been intercepted (this applies to SC2K 1996, 1995 and SCURK 1996)
  • A check has been added early on so if neither the simcity.exe or winscurk.exe binaries are used with this library, it won't create the sc2kfix.ini file.
  • RegOpenKeyExA rather than RegCreateKeyExA at this point (we no longer want to create the default keys if they're not present once the defaults have been loaded).
  • Aside from the RegSetValueExA cases, the rest appear to be handled.

Debug Menu

A test has been performed on the following Windows 95 versions:

Simcity 2000 Demo
Simcity 2000 CD Collection
Simcity 2000 Special Edition

They all exhibited the same issue with the attempted use of "Add all inventions".

It's.. most odd.

32908 - 0x808C

Show Version Info...
Thunk: 0x402694
Main: 0x4120E0

Based on a preliminary analysis, it's just reading the version.inf and then displaying it in the requester.

32909 - 0x808D

More Money
Thunk: 0x402B53
Main: 0x412280

32910 - 0x808E

Add All Gifts
Thunk: 0x401C0D
Main: 0x412290

From what I can see aside from granting all rewards, it also touches the invention years (very likely intentional to account for this function being used if the given gift hasn't yet been invented).

32911 - 0x808F

Add All Inventions (one would hope)
Thunk: 0x402388
Main: 0x412320

Center Tool

Thanks to @araxestroy's implementation of the middle-mouse button center control, there's a slight chance the case of the "constant scrolling" with the left-mouse button has jumped out.

The function isn't completely confirmed yet, however these are the address references:
Thunk: 0x401DFC
Main: 0x481780

WM_LBUTTONDOWN - 0x0201 - 513

Since there are multiple paths, this'll require a bit of experimentation.

During a drag not too far back the following was highlighted as well:
Thunk: 0x401406
Main: 0x47DD80

And another (yes this is a scattered approach):

Thunk: 0x402874
Main: 0x40CFB0

Which then goes -->

Thunk: 0x4019C4
Main: 0x40C2B0

Backtracing in-progress: 0x4251D0 -> 0x43F220 -> 0x4106C0

(The following are 'Main' not 'Thunk')
Parent: 0x4106C0
Map Editing: 0x442690
City Building and scenario: 0x43F220

With the two differing paths, in map editing mode at least if you click and your cursor leaves the valid map area and re-enters, it is far less likely to continue scrolling; while in normal mode if you click, leave the valid map area and re-enter it will pick up right where it left off.

Replicated the function externally by making use of the IDA-generated code, it works identically however it doesn't resolve the original problem. The next step will likely be the two tool menu functions.

Completed.

Reconcile Military Base spawning differences between DOS and Windows

Thus far the function has been reconstructed in the library, all but "Naval Base" handling is now present.

It has potentially opened the door to be able to hit the "bullseye" each time and spawn a specific base (assuming map conditions allow for it).

There are ways to dangerously get the Missile Silos to spawn, though any forced approach requires a more-general cleaner consideration.

The odd case with the Army Bases having at least one road-tile not quite being right appears to have also been nailed down (more testing still needed).

Reconcile differences in 'ItemPlacementCheck' - 0x4027F2

The specific purpose here is to understand and hopefully eliminate the portion that results in negative and/or anomalous military zone growth.

This 'if' block appears to be the culprit:

      if ( (*((_BYTE *)*(&dwMapXZON + v5) + v7) & 0xF) == 7 )
      {
        return 0;
      }

The check doesn't appear to exist in the equivalent-function in the DOS edition, though that's still being combed-over.

This has long since been accounted for.

Revisit the Naval Yard placement case

At the moment our implementation of the Naval Yard placement only has it occur from the ocean-facing map-edge inwards, it won't try to look for any possible valid placement cases on other water-bearing coasts that are connected to the main body of water. At this point it'll likely mean revisiting the DOS portion once again and combing over the code and certain function-level vars that "appear" to be related to the direction as far as I can tell.

Either way, this is a pending task.

Moving Thing Trip/Pathing Investigation

Pending task, intermediate calls need to be sought out.

Rebuild internal classes for better infrastructure flow tracking

This interesting task is in-progress.