User:AF/ClassExtrapolation

From sc2k-reverse
Revision as of 01:43, 18 June 2025 by AF (talk | contribs) (CGraphics)
Jump to navigationJump to search

The purposes of this page is to list the extrapolated classes during the reconstruction phase of the 1996 Special Edition.

For the most part this is a brute-force approach. As the classes are refined/trimmed they'll be adjusted over time.

The general methodology in this case is to generate a struct with N number of contained variables (this number can be rather high at times - it doesn't account for internal sub-structs and the like mind you, but there must be a starting place).

Structure Extrapolation

Whether the structural class format is entirely correct based on what was originally present is unclear.

However in order to ease the RE process some of these subclasses have created to reasonably allow for alignment.

NOTE: THIS LIST IS HEAVILY SUBJECT TO CHANGE

CWinApp -> CSimcityApp
CFrameWnd -> CMainFrame
CView -> CSimcityView
CWnd -> CSimcityWnd (m_hWndMDIClient from CMainFrame is passed to CSimcityWnd.SubclassWindow() via CMainFrame::CreateClient())
CEdit -> CSimcityEdit
CSimcityEdit -> CSimcityEditTwo
CSimcityEdit -> CSimcityEditThree
CDocument -> CSimcityDoc
CDocument -> CEngine
CDocument -> CSimGraphData
CMDIChildWnd -> CMyMDIChildWnd
CControlBar -> CMyToolBar
CMyToolBar -> CCityToolBar
CMyToolBar -> CMapToolBar
CDialog -> CAboutDialog
CDialog -> CMovieDialog
CDialog -> CGameDialog
CGameDialog -> CBridgeSelectDialog
CGameDialog -> CBudgetAdvisorDialog
CGameDialog -> CBudgetEducationDialog
CGameDialog -> CBudgetFireDialog
CGameDialog -> CBudgetFundDialog
CGameDialog -> CBudgetHealthDialog
CGameDialog -> CBudgetInformationDialog
CGameDialog -> CBudgetMainDialog
CGameDialog -> CBudgetOrdinanceDialog
CGameDialog -> CBudgetPoliceDialog
CGameDialog -> CBudgetTransportDialog
CGameDialog -> CBudgetZoneTaxSubDialog
CGameDialog -> CCityIndustryDialog
CGameDialog -> CCityMapDialog
CGameDialog -> CEventDialog
CGameDialog -> CGeneralInfoDialog
CGameDialog -> CInflightDialog
CGameDialog -> CInitialDialog
CGameDialog -> CNeighbourDialog
CGameDialog -> CNewGameDialog
CGameDialog -> CNewspaperDialog
CGameDialog -> COwnerInfoDialog
CGameDialog -> CPopulationDialog
CGameDialog -> CPowerPlantDialog
CGameDialog -> CQueryGeneralDialog
CGameDialog -> CQuerySpecificDialog
CGameDialog -> CScenarioDialog
CGameDialog -> CSelectArcologyDialog
CGameDialog -> CSimGraphDialog
CDockBar -> CStatusControlBar
CGraphics
CSound

CGraphics

struct CGraphics
{
  HBITMAP GRBitmap;
  HBITMAP GRBitmapLoColor;
  int GRlastPalUpdate;
  CPalette *GRpAppPalette; // TPalette in SCURK
  int GRwidth;
  int GRheight;
  int GRorient;
  int GRIsLockCnt;
  BYTE *GRpBits;
  BYTE *GRpBitsLoColor;
  BITMAPINFO *GRpBitmapInfo;
  WORD GRusage; // This only appears to crop up in SCURK, otherwise the var used in-place in CreateDIBSection is DIB_RGB_COLORS
};

CSound

This deals with both the Music and Sound.

struct __unaligned __declspec(align(2)) CSound
{
  HWND *dwSNDhWnd;
  BOOL bSNDPlaySound;
  int iSNDCurrSoundID;
  CString dwSNDSoundString;
  void *dwSNDBufferOne;
  int iSNDCurrentSound;
  void *dwSNDBufferTwo;
  BOOL bSNDWasPlaying;
  int iSNDSoundID;
  void *dwSNDBufferThree;
  void *dwSNDBufferFour;
  void *dwSNDBufferFive;
  int iSNDNextSoundID;
  DWORD dwSNDUnknownOne;
  WORD wSNDMCIDevID;
  DWORD dwSNDMCIError;
  DWORD dwSNDUnknownTwo;
  CString dwSNDMusicString;
};

CSimcityApp

Struct to address reference ('this' type is set to 'DWORD *' in this case - exceptions will be noted accordingly):

53 - 207 to allow for alignment.

this[53]  -> 0x4C70E4 - referenced in CSimcityApp::ExitInstance within the FreeLibrary() call.
this[54]  -> 0x4C70E8 - Game AutoSave
this[55]  -> 0x4C70EC - This appears to be to do with cursor hit testing (and adjustment made during OnSetCursor) (further tracing likely needed)
this[56]  -> 0x4C70F0 - Another CityMode var separate from wCityMode.
this[57]  -> 0x4C70F4 - results of GameDeviceCaps with the HORZRES attribute
this[58]  -> 0x4C70F8 - results of GameDeviceCaps with the VERTRES attribute
this[59]  -> 0x4C70FC - Boolean var for selecting the background or foreground palette (toggled via CMainFrame::OnActivateApp)
this[60]  -> 0x4C7100 - Variable set and unset via CGameDialog::DoModal
this[61]  -> 0x4C7104 - Priscilla Activated
this[62]  -> 0x4C7108 - Variable that's set during widget/dialog/window drag situations (further tracing needed)
this[63]  -> 0x4C710C - OnQuit var that could be about suspending the simulation (further tracing needed)
this[64]  -> 0x4C7110 - Variable set to 1 via CMainFrame::OnDestroy
this[65]  -> 0x4C7114 - Game Started (set in various places when a game starts or fails to start - loading failure for instance)
this[66]  -> 0x4C7118 - NoNewspapers setting
this[67]  -> 0x4C711C - Foreground palette
this[68]  -> 0x4C7120 - Background palette
this[69]  -> 0x4C7124 - CString One (marked as data but not with any name or reference)
this[72]  -> 0x4C7130 - CString Two
this[75]  -> 0x4C713C - CString Three
this[78]  -> 0x4C7148 - CString Four (the global has the type LPSTR during initial detection here)
this[81]  -> 0x4C7154 - SCURK setting
this[82]  -> 0x4C7158 - CSound class allocation
this[83]  -> 0x4C715C - Toggle next program step (boolean)
this[84]  -> 0x4C7160 - MultiDocSC2
this[85]  -> 0x4C7164 - MultiDocSCN
...
this[88]  -> 0x4C7170 - Array of 30 cursors.
this[119] -> 0x4C71EC - Active Cursor
this[120] -> 0x4C71F0 - GameMusic
this[121] -> 0x4C71F4 - GameSound
this[122] -> 0x4C71F8 - CString Array One (new alloc of 12)
this[158] -> 0x4C7288 - CString Array Two (new alloc of 12)
this[159] -> 0x4C728C - String Lengths passed to TextOutA
(WORD *)this[388] -> 0x4C7318 - Simulation Speed setting
(WORD *)this[389] -> 0x4C731A - Simulation Speed setting (this also appears in some areas as a HIGH word - hence the distinction)
this[195] -> 0x4C731C - Variable that's set and then unset within the SimulationTickingSpeed function
this[196] -> 0x4C7320 - (unmarked area - no name or reference)
this[197] -> 0x4C7324 - Animation "On Cycle" variable
this[198] -> 0x4C7328 - Animation "Off Cycle" variable
this[199] -> 0x4C732C - Toggle the palette animation of the title screen
this[200] -> 0x4C7330 - GetTickCount() result (unmarked area - no name or reference)
this[201] -> 0x4C7334 - Program Step
this[202] -> 0x4C7338 - DoProgramStepSkip (see CSimcityApp::PreTranslateMessage for what will trigger this attribute)
this[203] -> 0x4C733C - Menu Dialog Step
this[204] -> 0x4C7340 - MapModeVarCheck
this[205] -> 0x4C7344 - OnInitToggleToolBar
this[206] -> 0x4C7348 - Variable that's set via CMainFrame::OnSysCommand (likely if the 'Quit' command is triggered)
this[207] -> 0x4C734C - This variable stores the current program step prior to it changing to "Dialog Finish"
struct __cppobj CSimcityApp : CWinApp
{
  HMODULE dwSCAhModule;
  DWORD dwSCAGameAutoSave;
  DWORD dwSCACursorGameHit;
  DWORD dwSCACityMode;
  DWORD dwSCAGDCHorzRes;
  DWORD dwSCAGDCVertRes;
  DWORD dwSCAbForceBkgd;
  DWORD dwSCAGameDialogDoModalVar;
  DWORD bSCAPriscillaActivated;
  DWORD dwSCADragSuspendSim;
  DWORD dwSCAOnQuitSuspendSim;
  DWORD dwSCAMainFrameDestroyVar;
  DWORD dwSCAGameStarted;
  DWORD dwSCANoNewspapers;
  CPalette *dwSCAMainPaletteOne;
  CPalette *dwSCAMainPaletteTwo;
  CString dwSCACStringOne;
  CString dwSCACStringTwo;
  CString dwSCACStringThree;
  CString dwSCACStringFour;
  DWORD dwSCASCURK;
  CSound *dwSCACSoundOne;
  DWORD dwSCASetNextStep;
  CMultiDocTemplate *dwSCAMultiDocOne;
  CMultiDocTemplate *dwSCAMultiDocTwo;
  DWORD dwSCAThirtyFour;
  DWORD dwSCAThirtyFive;
  HCURSOR dwSCACursors[30];
  DWORD dwSCASixtySix;
  HCURSOR dwSCAActiveCursor;
  DWORD dwSCAGameMusic;
  DWORD dwSCAGameSound;
  CString *dwSCApCStringArrOne;
  DWORD dwSCASeventyOne;
  DWORD dwSCASeventyTwo;
  DWORD dwSCASeventyThree;
  DWORD dwSCASeventyFour;
  DWORD dwSCASeventyFive;
  DWORD dwSCASeventySix;
  DWORD dwSCASeventySeven;
  DWORD dwSCASeventyEight;
  DWORD dwSCASeventyNine;
  DWORD dwSCAEighty;
  DWORD dwSCAEightyOne;
  DWORD dwSCAEightyTwo;
  DWORD dwSCAEightyThree;
  DWORD dwSCAEightyFour;
  DWORD dwSCAEightyFive;
  DWORD dwSCAEightySix;
  DWORD dwSCAEightySeven;
  DWORD dwSCAEightyEight;
  DWORD dwSCAEightyNine;
  DWORD dwSCANinety;
  DWORD dwSCANinetyOne;
  DWORD dwSCANinetyTwo;
  DWORD dwSCANinetyThree;
  DWORD dwSCANinetyFour;
  DWORD dwSCANinetyFive;
  DWORD dwSCANinetySix;
  DWORD dwSCANinetySeven;
  DWORD dwSCANinetyEight;
  DWORD dwSCANinetyNine;
  DWORD dwSCAOneHundred;
  DWORD dwSCAOneHundredOne;
  DWORD dwSCAOneHundredTwo;
  DWORD dwSCAOneHundredThree;
  DWORD dwSCAOneHundredFour;
  DWORD dwSCAOneHundredFive;
  CString *dwSCApCStringArrTwo;
  DWORD dwSCAStoredStringLengths;
  DWORD dwSCAOneHundredEight;
  DWORD dwSCAOneHundredNine;
  DWORD dwSCAOneHundredTen;
  DWORD dwSCAOneHundredEleven;
  DWORD dwSCAOneHundredTwelve;
  DWORD dwSCAOneHundredThirteen;
  DWORD dwSCAOneHundredFourteen;
  DWORD dwSCAOneHundredFifteen;
  DWORD dwSCAOneHundredSixteen;
  DWORD dwSCAOneHundredSeventeen;
  DWORD dwSCAOneHundredEighteen;
  DWORD dwSCAOneHundredNineteen;
  DWORD dwSCAOneHundredTwenty;
  DWORD dwSCAOneHundredTwentyOne;
  DWORD dwSCAOneHundredTwentyTwo;
  DWORD dwSCAOneHundredTwentyThree;
  DWORD dwSCAOneHundredTwentyFour;
  DWORD dwSCAOneHundredTwentyFive;
  DWORD dwSCAOneHundredTwentySix;
  DWORD dwSCAOneHundredTwentySeven;
  DWORD dwSCAOneHundredTwentyEight;
  DWORD dwSCAOneHundredTwentyNine;
  DWORD dwSCAOneHundredThirty;
  DWORD dwSCAOneHundredThirtyOne;
  DWORD dwSCAOneHundredThirtyTwo;
  DWORD dwSCAOneHundredThirtyThree;
  DWORD dwSCAOneHundredThirtyFour;
  DWORD dwSCAOneHundredThirtyFive;
  DWORD dwSCAOneHundredThirtySix;
  DWORD dwSCAOneHundredThirtySeven;
  DWORD dwSCAOneHundredThirtyEight;
  DWORD dwSCAOneHundredThirtyNine;
  DWORD dwSCAOneHundredForty;
  DWORD dwSCAOneHundredFortyOne;
  WORD wSCAGameSpeedLOW;
  WORD wSCAGameSpeedHIGH;
  DWORD dwSCASimulationTickingSpeedVarOne;
  DWORD dwSCAOneHundredFortyFour;
  DWORD dwSCAAnimationOnCycle;
  DWORD dwSCAAnimationOffCycle;
  DWORD dwSCAToggleTitleScreenAnimation;
  DWORD dwSCALastTick;
  int iSCAProgramStep;
  DWORD dwSCADoStepSkip;
  DWORD dwSCAMenuDialogStep;
  DWORD dwSCAMapModeVarCheck;
  DWORD dwSCAOnInitToggleToolBar;
  DWORD dwSCASysCmdOnQuitVar;
  DWORD dwSCAInitDialogFinishLastProgramStep;
};

CMainFrame

struct __cppobj CMainFrame : CMDIFrameWnd
{
  CSimGraphDialog *dwMFSimGraphDialog;
  CPopulationDialog *dwMFPopulationDialog;
  CCityMapDialog *dwMFCityMapDialog;
  CNeighbourDialog *dwMFNeighbourDialog;
  CCityIndustryDialog *dwMFCityIndustryDialog;
  DWORD dwMFEight; // tracing required
  CGraphics *dwMFCGraphicsOne;
  DWORD dwMFnine; // tracing required
  DWORD dwMFTimerActive;
  UINT_PTR dwMFuIDEvent;
  UINT dwMFuDelay;
  UINT dwMFuPeriod;
  CStatusControlBar dwMFStatusControlBar;
  DWORD dwMFShowStatusBar;
  CCityToolBar dwMFCityToolBar;
  DWORD dwMFOneHundredEightyFour; // tracing required
  DWORD dwMFOneHundredEightyFive; // tracing required
  DWORD dwMFOneHundredEightySix; // tracing required
  CMapToolBar dwMFMapToolBar;
  DWORD dwMFTwoHundredFortyTwo; // tracing required
  DWORD dwMFTwoHundredFortyThree; // tracing required
  DWORD dwMFTwoHundredFortyFour; // tracing required
  CSimcityWnd dwMFCSimcityWnd;
  DWORD dwMFxOne;
  DWORD dwMFxTwo;
  CSize dwMFCSize;
  tagPOINT dwMFPointOne;
};

CStatusControlBar

struct __cppobj CStatusControlBar : CDialogBar
{
  CString dwSCBCStringOne;
  CString dwSCBCStringTwo;
  CString dwSCBCStringThree;
  COLORREF dwSCBColorOne;
  COLORREF dwSCBColorTwo;
  COLORREF dwSCBColorThree;
};

CMyToolBar

struct __cppobj CMyToolBar : CControlBar
{
  int iMyTBMenuButtonPos;
  int iMyTBLastButtonPos;
  CPoint dwMyTBPointFour;
  DWORD dwMyTBButtonMenu;
  CGraphics *dwMyTBCGraphicsOne;
  CGraphics *dwMyTBCGraphicsTwo;
  CGraphics *dwMyTBCGraphicsThree;
  DWORD dwMyTBButtonPressed;
  DWORD dwMyTBten;
  DWORD dwMyTBeleven;
  DWORD dwMyTBButtonFace;
  DWORD dwMyTBButtonShadow;
  DWORD dwMyTBButtonHighlighted;
  DWORD dwMyTBButtonText;
  DWORD dwMyTBWindowFrame;
  DWORD dwMyTBseventeen;
  DWORD dwMyTBeighteen;
  CPoint dwMyTBPointThree;
  DWORD dwMyTBControlsDisabled;
  DWORD dwMyTBtwentytwo;
  tagPOINT dwMyTBPointOne;
  tagPOINT dwMyTBPointTwo;
};

SIMC_TBBUTTON

Although this is still being experimented with, it "seems" that the custom toolbars that were built appeared to follow some principles as found with CToolBar (or COldToolBar as it once was if viewed from MFC 4.x >= - until an undefined point when it was removed).

The AFX_TBBUTTON struct specifically stands out, though in that instance the struct only contains the nID, nStyle and iImage, in our case the image handling appears to be from the CGraphics class, the dwSeparator and three CPoint class pointers account for coordinates of each button (BtnA - start, BtnB - end (?) on the main toolbar (M).

Much still needs to be confirmed, however this at least allows for general alignment in this area.

The following is cast to m_pData (or GetData() for MFC 4.x >=):

struct SIMC_TBBUTTON
{
  UINT nCmdID;
  UINT nStyle;
  int iIndex;
  CPoint *pPointBtnA;
  CPoint *pPointM;
  CPoint *pPointBtnB;
};

CCityToolBar

struct __cppobj CCityToolBar : CMyToolBar
{
  tagPOINT dwCTBPointThree;
  CMainFrame *dwCTBMainFrame;
  DWORD dwCTBcxRightBorder;
  DWORD dwCTBthirtyone;
  CMenu dwCTBMenuOne;
  CString dwCTBString[15];
  DWORD dwCTBseventysix;
  DWORD dwCTBseventyseven;
  DWORD dwCTBseventyeight;
  DWORD dwCTBseventynine;
  DWORD dwCTBeighty;
  DWORD dwCTBeightyone;
  DWORD dwCTBeightytwo;
  DWORD dwCTBeightythree;
  DWORD dwCTBeightyfour;
  DWORD dwCTToolSelection[15];
};

CMapToolBar

struct __cppobj CMapToolBar : CMyToolBar
{
  DWORD dwMTBTwentyNine;
  CMainFrame *dwMTBMainFrame;
  DWORD dwMTBcxRightBorder;
};

CSimcityWnd

struct __cppobj CSimcityWnd : CWnd
{
  CGraphics *dwSCWCGraphicsOne;
  CSize dwSCWSize;
};

CSimcityView

struct __cppobj __unaligned __declspec(align(2)) CSimcityView : CView
{
  CGraphics *dwSCVCGraphics;
  DWORD bSCVViewActive;
  DWORD dwSCVThree;
  void *dwSCVLockDIBRes;
  LONG dwSCVWidth;
  LONG dwSCVHeight;
  CScrollBar *dwSCVScrollBarVert;
  CScrollBar *dwSCVScrollBarHorz;
  CStatic *dwSCVStaticOne;
  CRect dwSCVScrollBarVertRectOne;
  CRect dwSCVScrollBarVertRectTwo;
  CRect dwSCVScrollBarVertRectThree;
  CRect dwSCVScrollPosVertRect;
  CRect dwSCVScrollBarHorzRectOne;
  CRect dwSCVScrollBarHorzRectTwo;
  CRect dwSCVScrollBarHorzRectThree;
  CRect dwSCVScrollPosHorzRect;
  CRect dwSCVScrollPosRect;
  CRect dwSCVStaticRect;
  DWORD dwSCVFiftyThree;
  DWORD dwSCVFiftyFour;
  DWORD dwSCVFiftyFive;
  CPoint dwSCVMousePoint;
  DWORD dwSCVFiftyEight;
  CPoint dwSCVRealPoint;
  DWORD dwSCVSixtyOne;
  DWORD dwSCVSixtyTwo;
  DWORD dwSCVSixtyThree;
  CRect dwSCVRECTOne;
  DWORD dwSCVSixtySix;
  CPoint dwSCVAdjustedPoint;
  WORD wSCVZoomLevel;
  DWORD dwSCVAdditionalZoomPerhaps;
};