int* tickPtr = (int*)0x56EB1C; // Data pointer cast
int (*funcPtr)(int value1, int value2) = (int (*)(int, int))0x400120; // Function pointer cast
void SomeFunction()
{
int value = *tickPtr; // Access data through pointer
(*funcPtr)(3,4); // Call through function pointer
funcPtr(3, 4); // Call through function pointer (short form)
}
class SomeClass
{
public:
void ClassMethod();
};
void (SomeClass::*methodPtr)() = &SomeClass::ClassMethod; // Setting up a function pointer
void SomeFunction2()
{
SomeClass someClassInstance;
SomeClass* someClassPtr = &someClassInstance; // Initialize a pointer to the class
(someClassInstance.*methodPtr)(); // Call class method through method function pointer
(someClassPtr->*methodPtr)(); // Call class method through method function pointer, using class pointer
}
int (SomeClass::*methodPtr2)() = (int (SomeClass::*)())0x400140;// Attempted function pointer cast
Main.cpp(35) : error C2440: 'type cast' : cannot convert from 'const int' to 'int (__thiscall SomeClass::*)(void)'
There are no conversions from integral values to pointer-to-member values
class SomeClass2;
int (*SomeClass2::methodPtr3)() = (int (*)())0x400140;
Main.cpp(41) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1794)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
class A
{
public:
void F1();
};
void G(A* a)
{
a->F1();
}
Compiling...
Main.cpp
Linking...
Main.obj : error LNK2001: unresolved external symbol "public: void __thiscall A::F1(void)" (?F1@A@@QAEXXZ)
symbolName EQU numericValue
global ?F1@A@@QAEXXZ
?F1@A@@QAEXXZ EQU 0x400140
if (tethysGame.tick == 3)
{
int i;
ofstream techList("TechList.txt");
for (i = 0; i < research.numTechs; i++)
{
techList << i << ") " << research.techInfo[i]->techName << endl;
}
}
if (*(int*)(0x56EB1C) == 3)
{
int i;
ofstream techList("TechList.txt");
for (i = 0; i < *(int*)0x56C230; i++)
{
techList << i << ") " << *(char**)((*(int**)0x56C234)[i] + 0x28) << endl;
}
}
MultiplayerPreGameSetupWnd preGameSetupWnd;
preGameSetupWnd.ShowHostGame(hostGameParameters);
class CheatView : public CommandPaneView
{
public:
// Member variables
// ----------------
// vtbl
// ----------------
UICommandButton disasterButton[4];
CreateUnitCommand spawnDisasterCommand[4];
public:
// Virtual member functions (inherited)
virtual void UpdateView() {};
virtual void OnAddView()
{
// Setup action parameters
spawnDisasterCommand[0].unitType = mapMeteor;
spawnDisasterCommand[0].cargo = (map_id)1;
spawnDisasterCommand[1].unitType = mapLightning;
spawnDisasterCommand[1].cargo = (map_id)1;
spawnDisasterCommand[2].unitType = mapVortex;
spawnDisasterCommand[2].cargo = (map_id)1;
spawnDisasterCommand[3].unitType = mapEarthquake;
spawnDisasterCommand[3].cargo = (map_id)1;
// Set the button actions
disasterButton[0].command = &spawnDisasterCommand[0];
disasterButton[1].command = &spawnDisasterCommand[1];
disasterButton[2].command = &spawnDisasterCommand[2];
disasterButton[3].command = &spawnDisasterCommand[3];
// Add the buttons to the display
AddButtons(this, 4,
&disasterButton[0], "&Meteor", "Create &Meteor",
&disasterButton[1], "&Storm", "Create &Storm",
&disasterButton[2], "&Vortex", "Create &Vortex",
&disasterButton[3], "&Earthquake", "Create &Earthquake");
};
virtual void OnRemoveView() {};
virtual bool IsNewView() { return 1; };
virtual void Draw(Rect* drawRect, GFXClippedSurface* surface) {};
virtual void SetReportPageIndex() {};
virtual bool DoesUnitSelectionChangeCauseUpdate() { return 0; };
virtual void OnAction() {};
virtual int GetSelectedReportButtonIndex() { return 0; };
};
#ifndef Font_H
#define Font_H
#include <windef.h>
#include <wingdi.h>
namespace OP2ForcedExport
{
class GFXSurface;
struct RenderDataBase;
struct Point;
struct Size;
struct Rect;
// Min Size: 0x4
class FontBase
{
public:
// Virtual member functions
virtual ~FontBase(); // 0x416BE0 (scalar-deleting: 0,1)
public:
// Member variables
// ----
// vtbl // 0x4CFBD0
// ----
};
// Min Size: 0x1C60
class Font : public FontBase
{
public:
// Virtual member functions
virtual ~Font(); // 0x415CB0 (scalar-deleting: 0,1)
virtual Size* GetTextSize(Size* size, char* string, int stringLength); // 0x415F60
// Constructor/Destructor
Font(); // 0x415C80
// ~Font(); // 0x415CF0 (non-virtual destructor)
// Member functions
void CreateFont(LOGFONT* logFont); // 0x415D10
void DrawString(char* string, int stringLength, GFXSurface* surface, Point* drawPos, Rect* drawRect, COLORREF color); // 0x4162B0
void DrawString(char* string, RenderDataBase* renderData, GFXSurface* surface, Point* drawPos, Rect* drawRect, COLORREF color, int vSpacing); // 0x4161F0
void DrawString(char* string, RenderDataBase* renderData, GFXSurface* surface, Rect* textRect, Rect* drawRect, int vSpacing); // 0x416B20
void ParseString(char* string, int stringLength, int boundingWidth, RenderDataBase* renderData, Size* size); // 0x416770
void ParseString(char* string, int stringLength, int boundingWidth, RenderDataBase* renderData, Size* size, int a1); // 0x415FE0 **
public:
// Member variables
// ----
// vtbl // 0x4CFBC8
// ----
LOGFONT logFont; // 0x4
int b1; // 0x40 ** Find out what this field is for
int tmHeight; // 0x44
int tmAscent; // 0x48
int tmDescent; // 0x4C
int tmInternalLeading; // 0x50
int tmExternalLeading; // 0x54
int tmMaxCharWidth; // 0x58 MaxCharWidth+1
GLYPHMETRICS glyphMetrics[256]; // 0x5C
char* characterImageBuffer; // 0x1C5C
// ----
};
struct RenderChunk
{
int xOffset; // 0x0 Pixel offset of this chunk of text
int stringStart; // 0x4 Index of first strin char in this chunk
int stringLen; // 0x8 Length of this chunk in characters
int bIsEOL; // 0xC Is-End-Of-Line, used for text wrapping
COLORREF color; // 0x10 Color used to render this chunk of text
};
struct RenderDataBase
{
int numChunks; // 0x0 Total allocated RenderChunk space
int numLines; // 0x4
int numChunksUsed; // 0x8 Used RenderChunk space
//RenderChunk renderChunk[1]; // 0xC Describes a section of unbroken text in a single color
RenderDataBase() { numChunks = 0; };// Convenient initalizer for the struct array size
};
// For convenience to make a varible of a specific size
template <int N>
struct RenderData : public RenderDataBase
{
RenderChunk renderChunk[N]; // 0xC Describes a section of unbroken text in a single color
RenderData<N>() { numChunks = N; }; // Convenient initalizer for the struct array size
};
// Globals
extern Font buttonFont; // 0x577EE8
extern Font aFont; // 0x579B48 ** Find out what this font is for
} // End Namespace
#endif
// Include Guard
#ifndef TethysGame_H
#define TethysGame_H
#include "GameOpt.h"
#include "GameStartInfo.h"
#include "Player.h"
namespace OP2ForcedExport
{
class GameNetLayer;
enum GameTermReasons;
class TFileDialog;
class TethysGame
{
public:
// Static Constructor/Destructor
// [Static]Constructor() // 0x4890C0
// [Static]Destructor() // 0x489100
// Constructor/Destructor
TethysGame(); // 0x489130
// Member functions
bool LoadDebugMap(); // 0x489170
bool StartGame(GameStartInfo* gameStartInfo); // 0x4893B0 bSuccess
void LoadPlayerGameStartInfo(GameStartInfo* gameStartInfo); // 0x4899C0
int F1(MissionResults* missionResults); // 0x489AB0 **
MissionResults* GetMissionResults(); // 0x489B00
void InitPlayers(int numPlayers); // 0x489E50
void ProcessGameCycle(); // 0x489EA0
void Deinitialize(); // 0x48A080
bool Save(StreamIO* savedGame); // 0x48A150 ** [Dead code?]
bool Load(StreamIO* savedGame); // 0x48A170 ** [Dead code?]
bool VerifySavedGameTileTag(StreamIO* savedGame); // 0x48A190 bSuccess
bool SaveGame(StreamIO* savedGame, TFileDialog* savedGameDialog); // 0x48A1F0 bSuccess
bool LoadGame(StreamIO* savedGame); // 0x48A3E0 bSuccess
void LocalPlayerQuit(char a1, char a2); // 0x48A6A0 **
void PostQuitMessage(int quitMessageIndex, int quitDelay); // 0x48A720
// ----
// Static member functions
static void __fastcall AddMessage(int pixelX, int pixelY, const char* message, int toPlayerNum, int soundIndex); // 0x478710
public:
// Member variables
GameOpt gameOpt; // 0x0
int numPlayers; // 0x68 Initialized from level DescBlock
int numHumanPlayers; // 0x6C
int cpProcessingInterval; // 0x70 Note: Must be a power of 2
int lgCpProcessingInterval; // 0x74 Cached base 2 log, so a bit shift can be used to multiply
int networkCpArraySpace; // 0x78 Space available for Command Packet data in network packets
int b1; // 0x7C **
int b2; // 0x80 **
int tick; // 0x84 Note: 100 ticks per mark, most input processing done every 4 ticks
int tickOfLastSetGameOptCp; // 0x88 Not set by FreeMoraleLevel, SetGameSpeed, SetDaylightEverywhere
int b3; // 0x8C **
int localPlayerNum; // 0x90
int b4; // 0x94 **
int startFadeOutTick; // 0x98
GameTermReasons termReason; // 0x9C
int b5; // 0xA0 **
GameStartInfo gameStartInfo; // 0xA4 Game starting parameters, used to restart a level, and return MissionResults
char padding[3]; // 0x481 Padding, due to unaligned size of GameStartInfo
Player player[7]; // 0x484
GameNetLayer* gameNetLayer; // 0x5980
};
// Globals
extern TethysGame tethysGame; // 0x56EA98
} // End namespace
#endif // End Include Guard
#include "TethysGame.h"
using namespace OP2ForcedExport;
...
TethysGame* tGame = (TethysGame*)0x56EA98 // Pointer casting trick (use address specified for the extern variable)
tGame->gameOpt.forceMoraleExcellentPlayerBitMask = -1; // Fix morale (without "Cheated Game!" message)
#ifndef GameOpt_H
#define GameOpt_H
namespace OP2ForcedExport
{
const int numOptions = 26;
enum GameOptIndex
{
// Main Debug flags
GameOptBoolPowerBoost = 0, // 0x0 Adds 0x100000 = 1048576 power, buildings work without CC, and 100000 common ore storage (rare storage?)
GameOptBoolAllTechsAvailable = 1, // 0x1 Research.HasTech always returns true, and all beacons surveyed. Lab research list not updated: prevents research (fails to start as expected)
GameOptBoolLogMoraleOutput = 2, // 0x2 Log Morale status to "MORALE.LOG"
GameOptBoolDoDamage4X = 3, // 0x3
GameOptBoolFastUnits = 4, // 0x4
GameOptBoolInstantKitBuild = 5, // 0x5 Instant research
GameOptBoolShowUnitPaths = 6, // 0x6
GameOptBoolShowMiniMapUnits = 7, // 0x7 Does not hide vehicles in the dark when headlights are off
// Placeholder Cheats [switched through to specified Player]
GameOptSetCommonOre = 8, // 0x8
GameOptSetRarePre = 9, // 0x9
GameOptSetScientists = 10, // 0xA
GameOptSetWorkers = 11, // 0xB
GameOptSetFoodStored = 12, // 0xC
GameOptSetKids = 13, // 0xD
// RCC Effect Debug flags
GameOptBoolDisableRccEffect = 14, // 0xE
GameOptBoolEnableRccEffect = 15, // 0xF
// Unknown, possibly removed [Set by hidden or removed UI]
// = 16, // 0x10 **
// = 17, // 0x11 **
// Daylight flags
GameOptBoolDaylightMoves = 18, // 0x12
GameOptBoolDaylightEverywhere = 19, // 0x13 (Not Cheat)
// Game Speed
GameOptGameSpeed4X = 20, // 0x14 (Not Cheat)
// Fixed morale
GameOptForceMoraleExcellentMask = 21, // 0x15
GameOptForceMoraleGoodMask = 22, // 0x16
GameOptForceMoraleFairMask = 23, // 0x17
GameOptForceMoralePoorMask = 24, // 0x18
GameOptForceMoraleTerribleMask = 25, // 0x19
// -- End Global options --
// Player resource cheats
GameOptPlayerAddResources = 26, // 0x1A Workers + 50, Scientists + 25, Kids + 10, Common Ore + 1000, Rare Ore + 1000, Food Stored + 25000
GameOptAllPlayerAddResources = 27, // 0x1B Workers + 50, Scientists + 25, Kids + 10, Common Ore + 1000, Rare Ore + 1000, Food Stored + 25000
// Disaster creation debug options
GameOptCreateVortex = 28, // 0x1C Vortex (0, 700):8, RoboDozer (0, 21)
GameOptCreateLightning = 29, // 0x1D Storm (0, 500):12, RoboDozer (0, 15)
GameOptCreateEarthquake = 30, // 0x1E Quake (512, 2048):4
GameOptCreateMeteor = 31, // 0x1F Meteor (100, 700):4, RoboDozer (3, 15)
// Free morale level
GameOptFreeMoraleLevel = 32, // 0x20 (Not Cheat)
};
union GameOpt
{
struct
{
// Main Debug flags
int bPowerBoost; // 0x0 Adds 0x100000 = 1048576 power, buildings work without CC, and 100000 common ore storage (rare storage?)
int bAllTechsAvailable; // 0x4 All bulding options available. Prevents research (fails to start as expected)
int bLogMoraleOutput; // 0x8
int bDoDamage4X; // 0xC
int bFastUnits; // 0x10
int bInstantKitBuild; // 0x14 Instant research
int bShowUnitPaths; // 0x18
int bAllMiniMapUnitsVisible; // 0x1C
// [No global references, special cased to map to specified player]
int setCommonOrePlaceholder; // 0x20
int setRareOrePlaceholder; // 0x24
int setScientistsPlaceholder; // 0x28
int setWorkersPlaceholder; // 0x2C
int setFoodStoredPlaceholder; // 0x30
int setKidsPlaceholder; // 0x34
// RCC Effect Debug flags
int bForceDisableRCCEffect; // 0x38 For all Human Players
int bForceEnableRCCEffect; // 0x3C For all Human Players
// Unknown, possibly removed
int b1; // 0x40 ** [Possibly set through hidden or removed UI]
int b2; // 0x44 ** [Possibly set through hidden or removed UI]
// Daylight flags
int bDaylightMoves; // 0x48
int bDaylightEverywhere; // 0x4C (Not Cheat)
// Game Speed
int gameSpeed4X; // 0x50 (Not Cheat)
// Fixed morale
union
{
struct
{
int forceMoraleExcellentPlayerBitMask; // 0x54
int forceMoraleGoodPlayerBitMask; // 0x58
int forceMoraleFairPlayerBitMask; // 0x5C
int forceMoralePoorPlayerBitMask; // 0x60
int forceMoraleTerriblePlayerBitMask; // 0x64
};
int forceMoralePlayerBitMask[5];
};
};
int option[numOptions]; // 26 Options
};
} // End namespace
#endif
#ifndef PointTypes_H
#define PointTypes_H
namespace OP2ForcedExport
{
// Common Types
struct Point
{
int x;
int y;
};
struct Rect
{
union
{
struct
{
int x1;
int y1;
int x2;
int y2;
};
struct
{
Point topLeft;
Point bottomRight;
};
};
};
} // End namespace
#endif
// Win32 data types, compatable with windows.h, but doesn't require windows.h
#ifndef BasicTypes_H
#define BasicTypes_H
typedef long LONG;
typedef unsigned int UINT;
typedef unsigned long ULONG;
typedef __int64 LONGLONG;
typedef UINT WPARAM;
typedef LONG LPARAM;
typedef unsigned long DWORD;
typedef DWORD COLORREF;
#define MakeHandleType(name) typedef struct name##__* name
MakeHandleType(HINSTANCE);
MakeHandleType(HHOOK);
MakeHandleType(HACCEL);
MakeHandleType(HMENU);
MakeHandleType(HWND);
MakeHandleType(HDC);
MakeHandleType(HFONT);
MakeHandleType(HICON);
MakeHandleType(HBITMAP);
MakeHandleType(HPALETTE);
typedef HICON HCURSOR;
#endif
struct VolIndexEntry
{
DWORD fileNameOffset; // 0x0 Offset in string table
DWORD dataOffset; // 0x4 Offset to the data in the VOL file
DWORD dataLength; // 0x8 Length of the internal file data
BYTE compressionCode; // 0xC Compression used on file data
BYTE bUsed; // 0xD Indicates index entry is valid (not quite bool: tested against 1) [Unused entries must only occur at the end of the table (binary searched)]
};
LoadAddons = "NetFix"
LoadAddons = "NetFix, ForcedExports"
[ForcedExports]
Dll = "op2exp.dll"
B) Manually add entries to the export table within Outpost2.exe.May wanna turn off smilies Arklon.
An automatic update system is not required. Just finish the thing and THEN include it in the game download. Its not like its absolutely needed now.Easier said than done. Even ForcedExports wasn't nearly complete. Plus, there are still many, many functions (for example, much of the pathfinder) we haven't yet looked at a whole lot that we'll need to to properly name them. If we waited until we were totally done categorizing every internal function, at that point, we'd be very close to having reverse engineered enough of the game to start rewriting it anyway.