60 bool print = _current_action != NULL;
62 _current_action = NULL;
73 for (uint i = 0; i < gamelog_actions; i++) {
75 for (uint j = 0; j < la->
changes; j++) {
93 _gamelog_action = NULL;
95 _current_action = NULL;
111 if (md5sum != NULL) {
113 buf +=
seprintf(buf, last,
"GRF ID %08X, checksum %s",
BSWAP32(grfid), txt);
119 buf +=
seprintf(buf, last,
", filename: %s (md5sum matches)", gc->
filename);
123 buf +=
seprintf(buf, last,
", filename: %s (matches GRFID only)", gc->
filename);
125 buf +=
seprintf(buf, last,
", unknown GRF");
136 "GRF config changed",
140 "emergency savegame",
167 GrfIDMapping grf_names;
169 proc(
"---- gamelog start ----");
173 for (
const LoggedAction *la = _gamelog_action; la != laend; la++) {
181 for (
const LoggedChange *lc = la->change; lc != lcend; lc++) {
185 default: NOT_REACHED();
187 buf +=
seprintf(buf,
lastof(buffer),
"New game mode: %u landscape: %u",
188 (uint)lc->mode.mode, (uint)lc->mode.landscape);
192 buf +=
seprintf(buf,
lastof(buffer),
"Revision text changed to %s, savegame version %u, ",
193 lc->revision.text, lc->revision.slver);
195 switch (lc->revision.modified) {
201 buf +=
seprintf(buf,
lastof(buffer),
"modified, _openttd_newgrf_version = 0x%08x", lc->revision.newgrf);
206 switch (lc->oldver.type) {
207 default: NOT_REACHED();
209 buf +=
seprintf(buf,
lastof(buffer),
"OTTD savegame without gamelog: version %u, %u",
210 GB(lc->oldver.version, 8, 16),
GB(lc->oldver.version, 0, 8));
224 lc->oldver.type ==
SGT_TTDP1 ?
"old" :
"new");
225 if (lc->oldver.version != 0) {
226 buf +=
seprintf(buf,
lastof(buffer),
", TTDP version %u.%u.%u.%u",
227 GB(lc->oldver.version, 24, 8),
GB(lc->oldver.version, 20, 4),
228 GB(lc->oldver.version, 16, 4),
GB(lc->oldver.version, 0, 16));
235 buf +=
seprintf(buf,
lastof(buffer),
"Setting changed: %s : %d -> %d", lc->setting.name, lc->setting.oldval, lc->setting.newval);
243 if (gm != grf_names.
End() && !gm->second.was_missing) buf +=
seprintf(buf,
lastof(buffer),
". Gamelog inconsistency: GrfID was already added!");
244 grf_names[lc->grfadd.grfid] = gc;
251 buf =
PrintGrfInfo(buf,
lastof(buffer), lc->grfrem.grfid, NULL, gm != grf_names.
End() ? gm->second.gc : NULL);
252 if (gm == grf_names.
End()) {
253 buf +=
seprintf(buf,
lastof(buffer),
". Gamelog inconsistency: GrfID was never added!");
257 gm->second.was_missing =
true;
267 buf +=
seprintf(buf,
lastof(buffer),
"Compatible NewGRF loaded: ");
268 buf =
PrintGrfInfo(buf,
lastof(buffer), lc->grfcompat.grfid, lc->grfcompat.md5sum, gc);
269 if (!grf_names.
Contains(lc->grfcompat.grfid)) buf +=
seprintf(buf,
lastof(buffer),
". Gamelog inconsistency: GrfID was never added!");
270 grf_names[lc->grfcompat.grfid] = gc;
277 buf =
PrintGrfInfo(buf,
lastof(buffer), lc->grfparam.grfid, NULL, gm != grf_names.
End() ? gm->second.gc : NULL);
278 if (gm == grf_names.
End()) buf +=
seprintf(buf,
lastof(buffer),
". Gamelog inconsistency: GrfID was never added!");
284 buf +=
seprintf(buf,
lastof(buffer),
"GRF order changed: %08X moved %d places %s",
285 BSWAP32(lc->grfmove.grfid),
abs(lc->grfmove.offset), lc->grfmove.offset >= 0 ?
"down" :
"up" );
286 buf =
PrintGrfInfo(buf,
lastof(buffer), lc->grfmove.grfid, NULL, gm != grf_names.
End() ? gm->second.gc : NULL);
287 if (gm == grf_names.
End()) buf +=
seprintf(buf,
lastof(buffer),
". Gamelog inconsistency: GrfID was never added!");
293 switch (lc->grfbug.bug) {
294 default: NOT_REACHED();
296 buf +=
seprintf(buf,
lastof(buffer),
"Rail vehicle changes length outside a depot: GRF ID %08X, internal ID 0x%X",
BSWAP32(lc->grfbug.grfid), (uint)lc->grfbug.data);
299 buf =
PrintGrfInfo(buf,
lastof(buffer), lc->grfbug.grfid, NULL, gm != grf_names.
End() ? gm->second.gc : NULL);
300 if (gm == grf_names.
End()) buf +=
seprintf(buf,
lastof(buffer),
". Gamelog inconsistency: GrfID was never added!");
312 proc(
"---- gamelog end ----");
316 static void GamelogPrintConsoleProc(
const char *s)
329 static void GamelogPrintDebugProc(
const char *s)
331 DEBUG(gamelog, _gamelog_print_level,
"%s", s);
343 _gamelog_print_level = level;
356 if (_current_action == NULL) {
364 _current_action->
change = NULL;
397 for (
const LoggedAction *la = _gamelog_action; la != laend; la++) {
399 for (
const LoggedChange *lc = la->change; lc != lcend; lc++) {
404 return (emergency != NULL);
415 if (lc == NULL)
return;
417 memset(lc->revision.text, 0,
sizeof(lc->revision.text));
418 strecpy(lc->revision.text, _openttd_revision,
lastof(lc->revision.text));
420 lc->revision.modified = _openttd_revision_modified;
421 lc->revision.newgrf = _openttd_newgrf_version;
432 if (lc == NULL)
return;
434 lc->
mode.mode = _game_mode;
446 if (lc == NULL)
return;
463 if (lc == NULL)
return;
465 lc->setting.name =
stredup(name);
466 lc->setting.oldval = oldval;
467 lc->setting.newval = newval;
480 for (
const LoggedAction *la = _gamelog_action; la != laend; la++) {
482 for (
const LoggedChange *lc = la->change; lc != lcend; lc++) {
487 if (rev == NULL || strcmp(rev->revision.text, _openttd_revision) != 0 ||
488 rev->revision.modified != _openttd_revision_modified ||
489 rev->revision.newgrf != _openttd_newgrf_version) {
503 for (
const LoggedAction *la = _gamelog_action; la != laend; la++) {
505 for (
const LoggedChange *lc = la->change; lc != lcend; lc++) {
525 if (lc == NULL)
return;
527 lc->grfbug.data = data;
528 lc->grfbug.grfid = grfid;
529 lc->grfbug.bug = bug;
544 for (
const LoggedAction *la = _gamelog_action; la != laend; la++) {
546 for (
const LoggedChange *lc = la->change; lc != lcend; lc++) {
547 if (lc->ct ==
GLCT_GRFBUG && lc->grfbug.grfid == grfid &&
581 if (lc == NULL)
return;
583 lc->grfrem.grfid = grfid;
597 if (lc == NULL)
return;
612 if (lc == NULL)
return;
627 if (lc == NULL)
return;
629 lc->grfmove.grfid = grfid;
630 lc->grfmove.offset = offset;
643 if (lc == NULL)
return;
645 lc->grfparam.grfid = grfid;
657 for (; newg != NULL; newg = newg->
next) {
701 while (o < ol->n && n < nl->n) {
707 for (oi = 0; oi < ol->n; oi++) {
720 for (ni = 0; ni < nl->n; ni++) {
736 assert(ni > n && ni < nl->n);
737 assert(oi > o && oi < ol->n);
778 void GamelogInfo(
LoggedAction *gamelog_action, uint gamelog_actions, uint32 *last_ottd_rev, byte *ever_modified,
bool *removed_newgrfs)
780 const LoggedAction *laend = &gamelog_action[gamelog_actions];
781 for (
const LoggedAction *la = gamelog_action; la != laend; la++) {
783 for (
const LoggedChange *lc = la->change; lc != lcend; lc++) {
788 *last_ottd_rev = lc->revision.newgrf;
789 *ever_modified =
max(*ever_modified, lc->revision.modified);
793 *removed_newgrfs =
true;