The uiFlag is a value that is written into the saved game that allows future DLLs to detect saved games written by older DLLs and change how they read the file.
Say version 1 of the DLL writes the treasury of every player as a signed 2-byte value. This allows a maximum of 32767
per player.
Well, clearly this will not suffice. So after some play-testing the designers decide to make a new DLL version 2 that writes a 4-byte value allowing for 2.147 billion
per player.
To allow the version 2 DLL to read version 1 DLL saved games, they change the uiFlag to 2 when writing new saves and put this into the code that reads the treasury:
Code:
int m_iTreatury; // 4 bytes
...
if (uiFlag < 2) {
// old saved game detected
short iTreasury; // 2 bytes
read(pStream, &iTreasury); // read 2 bytes
m_iTreasury = iTreasury;
}
else {
read(pStream, &m_iTreasury); // read 4 bytes
}
Okay, so that takes care of version 2 DLLs reading a version 1 saved game. No problem.
Now, here's the version 1 DLLs read code for this same part:
Code:
short m_iTreatury; // 2 bytes
...
read(pStream, &m_iTreasury); // read 2 bytes
D'oh! As you can see, the coders of version 1 did not anticipate that the future game would allow four bytes for the treasury. Now, they could
rewrite the version 1 DLL to handle this easily enough, but that of course requires
rewriting the version 1 DLL.
Code:
short m_iTreatury; // 2 bytes
...
if (uiFlag < 2) {
read(pStream, &iTreasury); // read 2 bytes
}
else {
// new saved game detected
int iTreasury; // 4 bytes
read(pStream, &iTreasury); // read 4 bytes
m_iTreasury = (short) iTreasury; // truncation, too bad!
}
If we could force everyone to use a new DLL that we wrote that didn't have the UP changes but
did have code to handle reading in the new GPP values, that would be grand. But that's just not feasible, and so we are left with no way for older DLLs to read in UP saved games.