Save/load in AI
Posted: 19 Jul 2007, 11:02
To save/load works correct in games with AI, it must support save/load.
Since 0.75b1 in C++ AI interface was added 2 methods:Save and Load.
When game saves Save method is called(for all AI's). It's parameter is savegame file stream.
When game loads engine calls IsLoadSupported. If it returns false engine creates AI, calls Init and adds all units. If returns true it creates AI but calls Load instead Init. Load's parameters is savegame file stream and ai callback.
In IsLoadSupported in GlobalAI:
DLL_EXPORT bool IsLoadSupported();
In IsLoadSupported in GroupAI:
DLL_EXPORT bool IsLoadSupported(unsigned aiNumber);
Since 0.75b1 in C++ AI interface was added 2 methods:Save and Load.
When game saves Save method is called(for all AI's). It's parameter is savegame file stream.
When game loads engine calls IsLoadSupported. If it returns false engine creates AI, calls Init and adds all units. If returns true it creates AI but calls Load instead Init. Load's parameters is savegame file stream and ai callback.
In IsLoadSupported in GlobalAI:
DLL_EXPORT bool IsLoadSupported();
In IsLoadSupported in GroupAI:
DLL_EXPORT bool IsLoadSupported(unsigned aiNumber);