diff options
author | yexo <yexo@openttd.org> | 2011-10-30 13:47:45 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2011-10-30 13:47:45 +0000 |
commit | 433f74edd9fd3d9f3fed5cf09c7d6c510600b0aa (patch) | |
tree | 41ce1db0b149196cbda1c78d8abf9d6e720042d2 /src/gamelog.cpp | |
parent | bd6d490987fe6767b8bb07ef9bf7753049c0c564 (diff) | |
download | openttd-433f74edd9fd3d9f3fed5cf09c7d6c510600b0aa.tar.xz |
(svn r23065) -Add: -q option to read a savegame, write some general info and exit
Diffstat (limited to 'src/gamelog.cpp')
-rw-r--r-- | src/gamelog.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/gamelog.cpp b/src/gamelog.cpp index 4cda9de14..f4f009166 100644 --- a/src/gamelog.cpp +++ b/src/gamelog.cpp @@ -774,3 +774,33 @@ void GamelogGRFUpdate(const GRFConfig *oldc, const GRFConfig *newc) free(ol); free(nl); } + +/** + * Get some basic information from the given gamelog. + * @param gamelog_action Pointer to the gamelog to extract information from. + * @param gamelog_actions Number of actions in the given gamelog. + * @param [out] last_ottd_rev OpenTTD NewGRF version from the binary that saved the savegame last. + * @param [out] ever_modified Max value of 'modified' from all binaries that ever saved this savegame. + * @param [out] removed_newgrfs Set to true if any NewGRFs have been removed. + */ +void GamelogInfo(LoggedAction *gamelog_action, uint gamelog_actions, uint32 *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs) +{ + const LoggedAction *laend = &gamelog_action[gamelog_actions]; + for (const LoggedAction *la = gamelog_action; la != laend; la++) { + const LoggedChange *lcend = &la->change[la->changes]; + for (const LoggedChange *lc = la->change; lc != lcend; lc++) { + switch (lc->ct) { + default: break; + + case GLCT_REVISION: + *last_ottd_rev = lc->revision.newgrf; + *ever_modified = max(*ever_modified, lc->revision.modified); + break; + + case GLCT_GRFREM: + *removed_newgrfs = true; + break; + } + } + } +} |