src/gamelog.cpp
author smatz
Sun, 15 Jun 2008 13:52:51 +0000
changeset 10966 3de9939c8a91
parent 10845 4cc81b7cf711
child 11169 60cbac6bc442
permissions -rw-r--r--
(svn r13520) -Fix (r13375): pointer has to be valid before it can be loaded to (SLE_STR)
10824
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
     1
/* $Id$ */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
     2
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
     3
/** @file gamelog.cpp Definition of functions used for logging of important changes in the game */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
     4
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
     5
#include "stdafx.h"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
     6
#include "openttd.h"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
     7
#include "saveload.h"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
     8
#include "core/alloc_func.hpp"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
     9
#include "core/bitmath_func.hpp"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    10
#include "core/math_func.hpp"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    11
#include "network/core/config.h"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    12
#include "variables.h"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    13
#include "string_func.h"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    14
#include "settings_type.h"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    15
#include "newgrf_config.h"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    16
#include <string.h>
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    17
#include <stdarg.h>
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    18
#include "gamelog.h"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    19
#include "console_func.h"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    20
#include "debug.h"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    21
#include "rev.h"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    22
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    23
extern const uint16 SAVEGAME_VERSION;  ///< current savegame version
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    24
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    25
extern SavegameType _savegame_type; ///< type of savegame we are loading
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    26
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    27
extern uint32 _ttdp_version;     ///< version of TTDP savegame (if applicable)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    28
extern uint16 _sl_version;       ///< the major savegame version identifier
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    29
extern byte   _sl_minor_version; ///< the minor savegame version, DO NOT USE!
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    30
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    31
/** Type of logged change */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    32
enum GamelogChangeType {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    33
	GLCT_MODE,        ///< Scenario editor x Game, different landscape
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    34
	GLCT_REVISION,    ///< Changed game revision string
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    35
	GLCT_OLDVER,      ///< Loaded from savegame without logged data
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    36
	GLCT_PATCH,       ///< Non-networksafe patch value changed
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    37
	GLCT_GRFADD,      ///< Removed GRF
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    38
	GLCT_GRFREM,      ///< Added GRF
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    39
	GLCT_GRFCOMPAT,   ///< Loading compatible GRF
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    40
	GLCT_GRFPARAM,    ///< GRF parameter changed
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    41
	GLCT_GRFMOVE,     ///< GRF order changed
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    42
	GLCT_END,         ///< So we know how many GLCTs are there
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    43
	GLCT_NONE = 0xFF, ///< In savegames, end of list
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    44
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    45
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    46
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    47
/** Contains information about one logged change */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    48
struct LoggedChange {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    49
	GamelogChangeType ct; ///< Type of change logged in this struct
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    50
	union {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    51
		struct {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    52
			byte mode;       ///< new game mode - Editor x Game
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    53
			byte landscape;  ///< landscape (temperate, arctic, ...)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    54
		} mode;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    55
		struct {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    56
			char text[NETWORK_REVISION_LENGTH]; ///< revision string, _openttd_revision
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    57
			uint32 newgrf;   ///< _openttd_newgrf_version
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    58
			uint16 slver;    ///< _sl_version
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    59
			byte modified;   ///< _openttd_revision_modified
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    60
		} revision;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    61
		struct {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    62
			uint32 type;     ///< type of savegame, @see SavegameType
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    63
			uint32 version;  ///< major and minor version OR ttdp version
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    64
		} oldver;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    65
		GRFIdentifier grfadd;    ///< ID and md5sum of added GRF
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    66
		struct {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    67
			uint32 grfid;    ///< ID of removed GRF
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    68
		} grfrem;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    69
		GRFIdentifier grfcompat; ///< ID and new md5sum of changed GRF
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    70
		struct {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    71
			uint32 grfid;    ///< ID of GRF with changed parameters
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    72
		} grfparam;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    73
		struct {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    74
			uint32 grfid;    ///< ID of moved GRF
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    75
			int32 offset;    ///< offset, positive = move down
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    76
		} grfmove;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    77
		struct {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    78
			char *name;      ///< name of the patch
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    79
			int32 oldval;    ///< old value
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    80
			int32 newval;    ///< new value
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    81
		} patch;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    82
	};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    83
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    84
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    85
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    86
/** Contains information about one logged action that caused at least one logged change */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    87
struct LoggedAction {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    88
	LoggedChange *change; ///< First logged change in this action
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    89
	uint32 changes;       ///< Number of changes in this action
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    90
	GamelogActionType at; ///< Type of action
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    91
	uint16 tick;          ///< Tick when it happened
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    92
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    93
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    94
static GamelogActionType _gamelog_action_type = GLAT_NONE; ///< action to record if anything changes
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    95
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    96
static LoggedAction *_gamelog_action = NULL; ///< first logged action
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    97
static uint _gamelog_actions         = 0;    ///< number of actions
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    98
static LoggedAction *_current_action = NULL; ///< current action we are logging, NULL when there is no action active
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
    99
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   100
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   101
/** Stores information about new action, but doesn't allocate it
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   102
 * Action is allocated only when there is at least one change
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   103
 * @param at type of action
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   104
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   105
void GamelogStartAction(GamelogActionType at)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   106
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   107
	assert(_gamelog_action_type == GLAT_NONE); // do not allow starting new action without stopping the previous first
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   108
	_gamelog_action_type = at;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   109
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   110
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   111
/** Stops logging of any changes
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   112
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   113
void GamelogStopAction()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   114
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   115
	assert(_gamelog_action_type != GLAT_NONE); // nobody should try to stop if there is no action in progress
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   116
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   117
	_current_action = NULL;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   118
	_gamelog_action_type = GLAT_NONE;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   119
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   120
	if (_debug_gamelog_level > 4) GamelogPrintDebug();
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   121
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   122
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   123
/** Resets and frees all memory allocated - used before loading or starting a new game
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   124
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   125
void GamelogReset()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   126
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   127
	assert(_gamelog_action_type == GLAT_NONE);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   128
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   129
	for (uint i = 0; i < _gamelog_actions; i++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   130
		const LoggedAction *la = &_gamelog_action[i];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   131
		for (uint j = 0; j < la->changes; j++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   132
			const LoggedChange *lc = &la->change[j];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   133
			if (lc->ct == GLCT_PATCH) free(lc->patch.name);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   134
		}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   135
		free(la->change);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   136
	}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   137
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   138
	free(_gamelog_action);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   139
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   140
	_gamelog_action  = NULL;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   141
	_gamelog_actions = 0;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   142
	_current_action  = NULL;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   143
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   144
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   145
enum {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   146
	GAMELOG_BUF_LEN = 1024 ///< length of buffer for one line of text
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   147
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   148
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   149
static int _dbgofs = 0; ///< offset in current output buffer
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   150
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   151
static void AddDebugText(char *buf, const char *s, ...)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   152
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   153
	if (GAMELOG_BUF_LEN <= _dbgofs) return;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   154
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   155
	va_list va;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   156
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   157
	va_start(va, s);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   158
	_dbgofs += vsnprintf(buf + _dbgofs, GAMELOG_BUF_LEN - _dbgofs, s, va);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   159
	va_end(va);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   160
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   161
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   162
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   163
/** Prints GRF filename if found
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   164
 * @param grfid GRF which filename to print
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   165
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   166
static void PrintGrfFilename(char *buf, uint grfid)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   167
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   168
	const GRFConfig *gc = FindGRFConfig(grfid);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   169
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   170
	if (gc == NULL) return;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   171
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   172
	AddDebugText(buf, ", filename: %s", gc->filename);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   173
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   174
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   175
/** Prints GRF ID, checksum and filename if found
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   176
 * @param grfid GRF ID
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   177
 * @param md5sum array of md5sum to print
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   178
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   179
static void PrintGrfInfo(char *buf, uint grfid, const uint8 *md5sum)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   180
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   181
	char txt[40];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   182
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   183
	md5sumToString(txt, lastof(txt), md5sum);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   184
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   185
	AddDebugText(buf, "GRF ID %08X, checksum %s", BSWAP32(grfid), txt);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   186
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   187
	PrintGrfFilename(buf, grfid);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   188
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   189
	return;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   190
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   191
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   192
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   193
/** Text messages for various logged actions */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   194
static const char *la_text[] = {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   195
	"new game started",
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   196
	"game loaded",
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   197
	"GRF config changed",
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   198
	"cheat was used",
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   199
	"patch settings changed"
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   200
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   201
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   202
assert_compile(lengthof(la_text) == GLAT_END);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   203
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   204
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   205
/** Prints active gamelog */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   206
void GamelogPrint(GamelogPrintProc *proc)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   207
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   208
	char buf[GAMELOG_BUF_LEN];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   209
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   210
	proc("---- gamelog start ----");
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   211
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   212
	const LoggedAction *laend = &_gamelog_action[_gamelog_actions];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   213
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   214
	for (const LoggedAction *la = _gamelog_action; la != laend; la++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   215
		assert((uint)la->at < GLAT_END);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   216
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   217
		snprintf(buf, GAMELOG_BUF_LEN, "Tick %u: %s", (uint)la->tick, la_text[(uint)la->at]);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   218
		proc(buf);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   219
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   220
		const LoggedChange *lcend = &la->change[la->changes];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   221
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   222
		for (const LoggedChange *lc = la->change; lc != lcend; lc++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   223
			_dbgofs = 0;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   224
			AddDebugText(buf, "     ");
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   225
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   226
			switch (lc->ct) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   227
				default: NOT_REACHED();
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   228
				case GLCT_MODE:
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   229
					AddDebugText(buf, "New game mode: %u landscape: %u",
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   230
						(uint)lc->mode.mode, (uint)lc->mode.landscape);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   231
					break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   232
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   233
				case GLCT_REVISION:
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   234
					AddDebugText(buf, "Revision text changed to %s, savegame version %u, ",
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   235
						lc->revision.text, lc->revision.slver);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   236
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   237
					switch (lc->revision.modified) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   238
						case 0: AddDebugText(buf, "not "); break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   239
						case 1: AddDebugText(buf, "maybe "); break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   240
						default: break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   241
					}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   242
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   243
					AddDebugText(buf, "modified, _openttd_newgrf_version = 0x%08x", lc->revision.newgrf);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   244
					break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   245
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   246
				case GLCT_OLDVER:
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   247
					AddDebugText(buf, "Conversion from ");
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   248
					switch (lc->oldver.type) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   249
						default: NOT_REACHED();
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   250
						case SGT_OTTD:
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   251
							AddDebugText(buf, "OTTD savegame without gamelog: version %u, %u",
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   252
								GB(lc->oldver.version, 8, 16), GB(lc->oldver.version, 0, 8));
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   253
							break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   254
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   255
						case SGT_TTD:
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   256
							AddDebugText(buf, "TTD savegame");
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   257
							break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   258
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   259
						case SGT_TTDP1:
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   260
						case SGT_TTDP2:
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   261
							AddDebugText(buf, "TTDP savegame, %s format",
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   262
								lc->oldver.type == SGT_TTDP1 ? "old" : "new");
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   263
							if (lc->oldver.version != 0) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   264
								AddDebugText(buf, ", TTDP version %u.%u.%u.%u",
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   265
									GB(lc->oldver.version, 24, 8), GB(lc->oldver.version, 20, 4),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   266
									GB(lc->oldver.version, 16, 4), GB(lc->oldver.version, 0, 16));
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   267
							}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   268
							break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   269
					}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   270
					break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   271
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   272
				case GLCT_PATCH:
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   273
					AddDebugText(buf, "Patch setting changed: %s : %d -> %d", lc->patch.name, lc->patch.oldval, lc->patch.newval);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   274
					break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   275
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   276
				case GLCT_GRFADD:
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   277
					AddDebugText(buf, "Added NewGRF: ");
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   278
					PrintGrfInfo(buf, lc->grfadd.grfid, lc->grfadd.md5sum);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   279
					break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   280
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   281
				case GLCT_GRFREM:
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   282
					AddDebugText(buf, "Removed NewGRF: %08X", BSWAP32(lc->grfrem.grfid));
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   283
					PrintGrfFilename(buf, lc->grfrem.grfid);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   284
					break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   285
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   286
				case GLCT_GRFCOMPAT:
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   287
					AddDebugText(buf, "Compatible NewGRF loaded: ");
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   288
					PrintGrfInfo(buf, lc->grfcompat.grfid, lc->grfcompat.md5sum);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   289
					break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   290
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   291
				case GLCT_GRFPARAM:
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   292
					AddDebugText(buf, "GRF parameter changed: %08X", BSWAP32(lc->grfparam.grfid));
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   293
					PrintGrfFilename(buf, lc->grfparam.grfid);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   294
					break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   295
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   296
				case GLCT_GRFMOVE:
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   297
					AddDebugText(buf, "GRF order changed: %08X moved %d places %s",
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   298
						BSWAP32(lc->grfmove.grfid), abs(lc->grfmove.offset), lc->grfmove.offset >= 0 ? "down" : "up" );
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   299
					PrintGrfFilename(buf, lc->grfmove.grfid);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   300
					break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   301
			}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   302
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   303
			proc(buf);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   304
		}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   305
	}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   306
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   307
	proc("---- gamelog end ----");
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   308
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   309
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   310
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   311
static void GamelogPrintConsoleProc(const char *s)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   312
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   313
	IConsolePrint(CC_WARNING, s);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   314
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   315
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   316
void GamelogPrintConsole()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   317
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   318
	GamelogPrint(&GamelogPrintConsoleProc);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   319
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   320
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   321
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   322
static void GamelogPrintDebugProc(const char *s)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   323
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   324
	debug_print("gamelog", s);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   325
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   326
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   327
void GamelogPrintDebug()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   328
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   329
	GamelogPrint(&GamelogPrintDebugProc);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   330
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   331
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   332
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   333
/** Allocates new LoggedChange and new LoggedAction if needed.
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   334
 * If there is no action active, NULL is returned.
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   335
 * @param ct type of change
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   336
 * @return new LoggedChange, or NULL if there is no action active
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   337
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   338
static LoggedChange *GamelogChange(GamelogChangeType ct)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   339
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   340
	if (_current_action == NULL) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   341
		if (_gamelog_action_type == GLAT_NONE) return NULL;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   342
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   343
		_gamelog_action  = ReallocT(_gamelog_action, _gamelog_actions + 1);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   344
		_current_action  = &_gamelog_action[_gamelog_actions++];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   345
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   346
		_current_action->at      = _gamelog_action_type;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   347
		_current_action->tick    = _tick_counter;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   348
		_current_action->change  = NULL;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   349
		_current_action->changes = 0;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   350
	}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   351
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   352
	_current_action->change = ReallocT(_current_action->change, _current_action->changes + 1);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   353
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   354
	LoggedChange *lc = &_current_action->change[_current_action->changes++];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   355
	lc->ct = ct;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   356
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   357
	return lc;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   358
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   359
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   360
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   361
/** Logs a change in game revision
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   362
 * @param revision new revision string
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   363
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   364
void GamelogRevision()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   365
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   366
	assert(_gamelog_action_type == GLAT_START || _gamelog_action_type == GLAT_LOAD);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   367
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   368
	LoggedChange *lc = GamelogChange(GLCT_REVISION);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   369
	if (lc == NULL) return;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   370
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   371
	strncpy(lc->revision.text, _openttd_revision, lengthof(lc->revision.text));
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   372
	lc->revision.slver = SAVEGAME_VERSION;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   373
	lc->revision.modified = _openttd_revision_modified;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   374
	lc->revision.newgrf = _openttd_newgrf_version;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   375
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   376
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   377
/** Logs a change in game mode (scenario editor or game)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   378
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   379
void GamelogMode()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   380
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   381
	assert(_gamelog_action_type == GLAT_START || _gamelog_action_type == GLAT_LOAD || _gamelog_action_type == GLAT_CHEAT);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   382
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   383
	LoggedChange *lc = GamelogChange(GLCT_MODE);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   384
	if (lc == NULL) return;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   385
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   386
	lc->mode.mode      = _game_mode;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   387
	lc->mode.landscape = _settings_game.game_creation.landscape;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   388
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   389
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   390
/** Logs loading from savegame without gamelog
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   391
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   392
void GamelogOldver()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   393
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   394
	assert(_gamelog_action_type == GLAT_LOAD);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   395
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   396
	LoggedChange *lc = GamelogChange(GLCT_OLDVER);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   397
	if (lc == NULL) return;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   398
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   399
	lc->oldver.type = _savegame_type;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   400
	lc->oldver.version = (_savegame_type == SGT_OTTD ? ((uint32)_sl_version << 8 | _sl_minor_version) : _ttdp_version);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   401
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   402
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   403
/** Logs change in game patches. Only non-networksafe patches are logged
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   404
 * @param name patch name
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   405
 * @param oldval old patch value
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   406
 * @param newval new patch value
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   407
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   408
void GamelogPatch(const char *name, int32 oldval, int32 newval)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   409
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   410
	assert(_gamelog_action_type == GLAT_PATCH);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   411
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   412
	LoggedChange *lc = GamelogChange(GLCT_PATCH);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   413
	if (lc == NULL) return;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   414
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   415
	lc->patch.name = strdup(name);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   416
	lc->patch.oldval = oldval;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   417
	lc->patch.newval = newval;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   418
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   419
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   420
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   421
/** Finds out if current revision is different than last revision stored in the savegame.
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   422
 * Appends GLCT_REVISION when the revision string changed
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   423
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   424
void GamelogTestRevision()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   425
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   426
	const LoggedChange *rev = NULL;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   427
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   428
	const LoggedAction *laend = &_gamelog_action[_gamelog_actions];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   429
	for (const LoggedAction *la = _gamelog_action; la != laend; la++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   430
		const LoggedChange *lcend = &la->change[la->changes];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   431
		for (const LoggedChange *lc = la->change; lc != lcend; lc++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   432
			if (lc->ct == GLCT_REVISION) rev = lc;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   433
		}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   434
	}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   435
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   436
	if (rev == NULL || strcmp(rev->revision.text, _openttd_revision) != 0 ||
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   437
			rev->revision.modified != _openttd_revision_modified ||
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   438
			rev->revision.newgrf != _openttd_newgrf_version) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   439
		GamelogRevision();
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   440
	}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   441
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   442
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   443
/** Finds last stored game mode or landscape.
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   444
 * Any change is logged
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   445
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   446
void GamelogTestMode()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   447
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   448
	const LoggedChange *mode = NULL;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   449
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   450
	const LoggedAction *laend = &_gamelog_action[_gamelog_actions];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   451
	for (const LoggedAction *la = _gamelog_action; la != laend; la++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   452
		const LoggedChange *lcend = &la->change[la->changes];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   453
		for (const LoggedChange *lc = la->change; lc != lcend; lc++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   454
			if (lc->ct == GLCT_MODE) mode = lc;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   455
		}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   456
	}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   457
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   458
	if (mode == NULL || mode->mode.mode != _game_mode || mode->mode.landscape != _settings_game.game_creation.landscape) GamelogMode();
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   459
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   460
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   461
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   462
/** Decides if GRF should be logged
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   463
 * @param g grf to determine
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   464
 * @return true iff GRF is not static and is loaded
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   465
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   466
static inline bool IsLoggableGrfConfig(const GRFConfig *g)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   467
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   468
	return !HasBit(g->flags, GCF_STATIC) && g->status != GCS_NOT_FOUND;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   469
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   470
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   471
/** Logs removal of a GRF
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   472
 * @param grfid ID of removed GRF
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   473
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   474
void GamelogGRFRemove(uint32 grfid)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   475
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   476
	assert(_gamelog_action_type == GLAT_LOAD || _gamelog_action_type == GLAT_GRF);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   477
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   478
	LoggedChange *lc = GamelogChange(GLCT_GRFREM);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   479
	if (lc == NULL) return;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   480
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   481
	lc->grfrem.grfid = grfid;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   482
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   483
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   484
/** Logs adding of a GRF
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   485
 * @param newg added GRF
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   486
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   487
void GamelogGRFAdd(const GRFConfig *newg)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   488
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   489
	assert(_gamelog_action_type == GLAT_LOAD || _gamelog_action_type == GLAT_START || _gamelog_action_type == GLAT_GRF);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   490
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   491
	if (!IsLoggableGrfConfig(newg)) return;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   492
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   493
	LoggedChange *lc = GamelogChange(GLCT_GRFADD);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   494
	if (lc == NULL) return;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   495
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   496
	memcpy(&lc->grfadd, newg, sizeof(GRFIdentifier));
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   497
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   498
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   499
/** Logs loading compatible GRF
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   500
 * (the same ID, but different MD5 hash)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   501
 * @param newg new (updated) GRF
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   502
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   503
void GamelogGRFCompatible(const GRFIdentifier *newg)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   504
{
10845
4cc81b7cf711 (svn r13396) -Fix (r13375): assertion failing when changing grfs in game (compatible grfs)
glx
parents: 10824
diff changeset
   505
	assert(_gamelog_action_type == GLAT_LOAD || _gamelog_action_type == GLAT_GRF);
10824
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   506
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   507
	LoggedChange *lc = GamelogChange(GLCT_GRFCOMPAT);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   508
	if (lc == NULL) return;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   509
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   510
	memcpy(&lc->grfcompat, newg, sizeof(GRFIdentifier));
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   511
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   512
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   513
/** Logs changing GRF order
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   514
 * @param grfid GRF that is moved
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   515
 * @param offset how far it is moved, positive = moved down
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   516
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   517
static void GamelogGRFMove(uint32 grfid, int32 offset)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   518
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   519
	assert(_gamelog_action_type == GLAT_GRF);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   520
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   521
	LoggedChange *lc = GamelogChange(GLCT_GRFMOVE);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   522
	if (lc == NULL) return;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   523
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   524
	lc->grfmove.grfid  = grfid;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   525
	lc->grfmove.offset = offset;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   526
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   527
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   528
/** Logs change in GRF parameters.
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   529
 * Details about parameters changed are not stored
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   530
 * @param grfid ID of GRF to store
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   531
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   532
static void GamelogGRFParameters(uint32 grfid)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   533
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   534
	assert(_gamelog_action_type == GLAT_GRF);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   535
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   536
	LoggedChange *lc = GamelogChange(GLCT_GRFPARAM);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   537
	if (lc == NULL) return;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   538
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   539
	lc->grfparam.grfid = grfid;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   540
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   541
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   542
/** Logs adding of list of GRFs.
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   543
 * Useful when old savegame is loaded or when new game is started
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   544
 * @param newg head of GRF linked list
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   545
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   546
void GamelogGRFAddList(const GRFConfig *newg)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   547
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   548
	assert(_gamelog_action_type == GLAT_START || _gamelog_action_type == GLAT_LOAD);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   549
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   550
	for (; newg != NULL; newg = newg->next) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   551
		GamelogGRFAdd(newg);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   552
	}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   553
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   554
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   555
/** List of GRFs using array of pointers instead of linked list */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   556
struct GRFList {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   557
	uint n;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   558
	const GRFConfig *grf[VARARRAY_SIZE];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   559
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   560
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   561
/** Generates GRFList
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   562
 * @param grfc head of GRF linked list
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   563
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   564
static GRFList *GenerateGRFList(const GRFConfig *grfc)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   565
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   566
	uint n = 0;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   567
	for (const GRFConfig *g = grfc; g != NULL; g = g->next) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   568
		if (IsLoggableGrfConfig(g)) n++;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   569
	}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   570
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   571
	GRFList *list = (GRFList*)MallocT<byte>(sizeof(GRFList) + n * sizeof(GRFConfig*));
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   572
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   573
	list->n = 0;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   574
	for (const GRFConfig *g = grfc; g != NULL; g = g->next) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   575
		if (IsLoggableGrfConfig(g)) list->grf[list->n++] = g;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   576
	}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   577
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   578
	return list;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   579
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   580
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   581
/** Compares two NewGRF lists and logs any change
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   582
 * @param oldc original GRF list
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   583
 * @param newc new GRF list
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   584
 */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   585
void GamelogGRFUpdate(const GRFConfig *oldc, const GRFConfig *newc)
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   586
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   587
	GRFList *ol = GenerateGRFList(oldc);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   588
	GRFList *nl = GenerateGRFList(newc);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   589
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   590
	uint o = 0, n = 0;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   591
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   592
	while (o < ol->n && n < nl->n) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   593
		const GRFConfig *og = ol->grf[o];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   594
		const GRFConfig *ng = nl->grf[n];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   595
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   596
		if (og->grfid != ng->grfid) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   597
			uint oi, ni;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   598
			for (oi = 0; oi < ol->n; oi++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   599
				if (ol->grf[oi]->grfid == nl->grf[n]->grfid) break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   600
			}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   601
			if (oi < o) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   602
				/* GRF was moved, this change has been logged already */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   603
				n++;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   604
				continue;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   605
			}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   606
			if (oi == ol->n) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   607
				/* GRF couldn't be found in the OLD list, GRF was ADDED */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   608
				GamelogGRFAdd(nl->grf[n++]);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   609
				continue;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   610
			}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   611
			for (ni = 0; ni < nl->n; ni++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   612
				if (nl->grf[ni]->grfid == ol->grf[o]->grfid) break;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   613
			}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   614
			if (ni < n) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   615
				/* GRF was moved, this change has been logged already */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   616
				o++;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   617
				continue;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   618
			}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   619
			if (ni == nl->n) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   620
				/* GRF couldn't be found in the NEW list, GRF was REMOVED */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   621
				GamelogGRFRemove(ol->grf[o++]->grfid);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   622
				continue;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   623
			}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   624
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   625
			/* o < oi < ol->n
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   626
			 * n < ni < nl->n */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   627
			assert(ni > n && ni < nl->n);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   628
			assert(oi > o && oi < ol->n);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   629
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   630
			ni -= n; // number of GRFs it was moved downwards
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   631
			oi -= o; // number of GRFs it was moved upwards
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   632
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   633
			if (ni >= oi) { // prefer the one that is moved further
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   634
				/* GRF was moved down */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   635
				GamelogGRFMove(ol->grf[o++]->grfid, ni);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   636
			} else {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   637
				GamelogGRFMove(nl->grf[n++]->grfid, -(int)oi);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   638
			}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   639
		} else {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   640
			if (memcmp(og->md5sum, ng->md5sum, sizeof(og->md5sum)) != 0) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   641
				/* md5sum changed, probably loading 'compatible' GRF */
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   642
				GamelogGRFCompatible(nl->grf[n]);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   643
			}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   644
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   645
			if (og->num_params != ng->num_params || memcmp(og->param, ng->param, og->num_params * sizeof(og->param[0])) != 0) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   646
				GamelogGRFParameters(ol->grf[o]->grfid);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   647
			}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   648
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   649
			o++;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   650
			n++;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   651
		}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   652
	}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   653
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   654
	while (o < ol->n) GamelogGRFRemove(ol->grf[o++]->grfid); // remaining GRFs were removed ...
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   655
	while (n < nl->n) GamelogGRFAdd   (nl->grf[n++]);    // ... or added
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   656
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   657
	free(ol);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   658
	free(nl);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   659
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   660
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   661
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   662
static const SaveLoad _glog_action_desc[] = {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   663
	SLE_VAR(LoggedAction, tick,              SLE_UINT16),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   664
	SLE_END()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   665
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   666
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   667
static const SaveLoad _glog_mode_desc[] = {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   668
	SLE_VAR(LoggedChange, mode.mode,         SLE_UINT8),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   669
	SLE_VAR(LoggedChange, mode.landscape,    SLE_UINT8),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   670
	SLE_END()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   671
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   672
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   673
static const SaveLoad _glog_revision_desc[] = {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   674
	SLE_ARR(LoggedChange, revision.text,     SLE_UINT8,  NETWORK_REVISION_LENGTH),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   675
	SLE_VAR(LoggedChange, revision.newgrf,   SLE_UINT32),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   676
	SLE_VAR(LoggedChange, revision.slver,    SLE_UINT16),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   677
	SLE_VAR(LoggedChange, revision.modified, SLE_UINT8),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   678
	SLE_END()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   679
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   680
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   681
static const SaveLoad _glog_oldver_desc[] = {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   682
	SLE_VAR(LoggedChange, oldver.type,       SLE_UINT32),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   683
	SLE_VAR(LoggedChange, oldver.version,    SLE_UINT32),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   684
	SLE_END()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   685
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   686
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   687
static const SaveLoad _glog_patch_desc[] = {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   688
	SLE_STR(LoggedChange, patch.name,        SLE_STR,    128),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   689
	SLE_VAR(LoggedChange, patch.oldval,      SLE_INT32),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   690
	SLE_VAR(LoggedChange, patch.newval,      SLE_INT32),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   691
	SLE_END()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   692
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   693
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   694
static const SaveLoad _glog_grfadd_desc[] = {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   695
	SLE_VAR(LoggedChange, grfadd.grfid,      SLE_UINT32    ),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   696
	SLE_ARR(LoggedChange, grfadd.md5sum,     SLE_UINT8,  16),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   697
	SLE_END()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   698
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   699
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   700
static const SaveLoad _glog_grfrem_desc[] = {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   701
	SLE_VAR(LoggedChange, grfrem.grfid,      SLE_UINT32),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   702
	SLE_END()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   703
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   704
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   705
static const SaveLoad _glog_grfcompat_desc[] = {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   706
	SLE_VAR(LoggedChange, grfcompat.grfid,   SLE_UINT32    ),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   707
	SLE_ARR(LoggedChange, grfcompat.md5sum,  SLE_UINT8,  16),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   708
	SLE_END()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   709
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   710
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   711
static const SaveLoad _glog_grfparam_desc[] = {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   712
	SLE_VAR(LoggedChange, grfparam.grfid,    SLE_UINT32),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   713
	SLE_END()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   714
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   715
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   716
static const SaveLoad _glog_grfmove_desc[] = {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   717
	SLE_VAR(LoggedChange, grfmove.grfid,    SLE_UINT32),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   718
	SLE_VAR(LoggedChange, grfmove.offset,   SLE_INT32),
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   719
	SLE_END()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   720
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   721
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   722
static const SaveLoad *_glog_desc[] = {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   723
	_glog_mode_desc,
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   724
	_glog_revision_desc,
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   725
	_glog_oldver_desc,
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   726
	_glog_patch_desc,
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   727
	_glog_grfadd_desc,
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   728
	_glog_grfrem_desc,
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   729
	_glog_grfcompat_desc,
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   730
	_glog_grfparam_desc,
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   731
	_glog_grfmove_desc
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   732
};
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   733
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   734
assert_compile(lengthof(_glog_desc) == GLCT_END);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   735
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   736
static void Load_GLOG()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   737
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   738
	assert(_gamelog_action == NULL);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   739
	assert(_gamelog_actions == 0);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   740
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   741
	GamelogActionType at;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   742
	while ((at = (GamelogActionType)SlReadByte()) != GLAT_NONE) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   743
		_gamelog_action = ReallocT(_gamelog_action, _gamelog_actions + 1);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   744
		LoggedAction *la = &_gamelog_action[_gamelog_actions++];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   745
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   746
		la->at = at;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   747
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   748
		SlObject(la, _glog_action_desc); // has to be saved after 'DATE'!
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   749
		la->change = NULL;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   750
		la->changes = 0;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   751
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   752
		GamelogChangeType ct;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   753
		while ((ct = (GamelogChangeType)SlReadByte()) != GLCT_NONE) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   754
			la->change = ReallocT(la->change, la->changes + 1);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   755
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   756
			LoggedChange *lc = &la->change[la->changes++];
10966
3de9939c8a91 (svn r13520) -Fix (r13375): pointer has to be valid before it can be loaded to (SLE_STR)
smatz
parents: 10845
diff changeset
   757
			/* for SLE_STR, pointer has to be valid! so make it NULL */
3de9939c8a91 (svn r13520) -Fix (r13375): pointer has to be valid before it can be loaded to (SLE_STR)
smatz
parents: 10845
diff changeset
   758
			memset(lc, 0, sizeof(*lc));
10824
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   759
			lc->ct = ct;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   760
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   761
			assert((uint)ct < GLCT_END);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   762
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   763
			SlObject(lc, _glog_desc[ct]);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   764
		}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   765
	}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   766
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   767
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   768
static void Save_GLOG()
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   769
{
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   770
	const LoggedAction *laend = &_gamelog_action[_gamelog_actions];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   771
	size_t length = 0;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   772
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   773
	for (const LoggedAction *la = _gamelog_action; la != laend; la++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   774
		const LoggedChange *lcend = &la->change[la->changes];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   775
		for (LoggedChange *lc = la->change; lc != lcend; lc++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   776
			assert((uint)lc->ct < lengthof(_glog_desc));
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   777
			length += SlCalcObjLength(lc, _glog_desc[lc->ct]) + 1;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   778
		}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   779
		length += 4;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   780
	}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   781
	length++;
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   782
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   783
	SlSetLength(length);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   784
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   785
	for (LoggedAction *la = _gamelog_action; la != laend; la++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   786
		SlWriteByte(la->at);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   787
		SlObject(la, _glog_action_desc);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   788
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   789
		const LoggedChange *lcend = &la->change[la->changes];
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   790
		for (LoggedChange *lc = la->change; lc != lcend; lc++) {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   791
			SlWriteByte(lc->ct);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   792
			assert((uint)lc->ct < GLCT_END);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   793
			SlObject(lc, _glog_desc[lc->ct]);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   794
		}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   795
		SlWriteByte(GLCT_NONE);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   796
	}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   797
	SlWriteByte(GLAT_NONE);
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   798
}
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   799
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   800
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   801
extern const ChunkHandler _gamelog_chunk_handlers[] = {
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   802
	{ 'GLOG', Save_GLOG, Load_GLOG, CH_RIFF | CH_LAST }
1a34ba6f338a (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents:
diff changeset
   803
};