I am trying to load the map part of a saved game into memory (SGAME0.OP2). Saved game files contain some header data not present in map files. I don't really need the info in the saved game header, so it could just be ignored, or loaded into a variable.
Source Material Location: \Outpost2SVN\OllyDbg\InternalData\SavedGame and Map.txt
Outpost 2 .op2 File Format (Saved Games)
----------------------------------------
Offset Size Description
------ ---- -----------
0x0 0x19 "OUTPOST 2.00 SAVED GAME", 0x1A, 0 - String must match exactly or else load error
---------------------------
Note: The following is repeated as an array of 0x74 (116 decimal) elements
0x19+i*0x1E0 4 **TODO** Figure this out
0x1D+i*0x1E0 0x1DC **TODO** Figure this out
---------------------------
Note: From here, the format matches that of .map files
So, I'm using the following:
ifstream file(filename, ios::in | ios::binary);
if (saveFile)
}
file.ignore(0x19);
file.ignore(0x74);
}
file.read((char*)&mapHeader, sizeof(mapHeader));
When I load a map file, the code works fine. When trying to load a save file, it appears the map header data isn't being loaded properly. I'm assuming that my ignore commands are not placing the ifstream at the proper position to start reading the map data, but I'm not very familiar with doing this.
Any help would be appreciated!
I've updated the text file describing the saved game and map file formats. It was missing a section in the header of saved game files. I also filled out some details on the meaning of the previously unknown fields.
Offset Size Description
------ ---- -----------
0x0 0x19 "OUTPOST 2.00 SAVED GAME", 0x1A, 0 - String must match exactly or else load error
---------------------------
0x19 0x1086C fileDialogData
0x10885 0xD7A0 sheetData[0x73] (array of 0x73 (115) UnitTypeInfo objects, each loading 0x1E0 bytes of data)
Note: Technically each object loads data through a virtual function call, so each object could load a different amount of data. However, there are no overrides, so they all call the same base class function, and hence all load the same data.
4 int requiredTechNum
0x1DC struct[] unitTypeInfo.playerInfo[]
---------------------------
0x1E025 ... From here, the format matches that of .map files