src/autoreplace.cpp
author terom@frrb.lan
Fri, 19 Dec 2008 01:38:09 +0200
changeset 10439 50f056aa3024
parent 10127 4f53c1cfcfe9
permissions -rw-r--r--
industries, unmoveables... everything but the landscape
10127
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
     1
/* $Id$ */
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
     2
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
     3
/** @file autoreplace.cpp Management of replacement lists. */
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
     4
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
     5
#include "stdafx.h"
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
     6
#include "openttd.h"
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
     7
#include "debug.h"
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
     8
#include "command_func.h"
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
     9
#include "saveload.h"
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    10
#include "group.h"
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    11
#include "autoreplace_base.h"
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    12
#include "oldpool_func.h"
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    13
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    14
DEFINE_OLD_POOL_GENERIC(EngineRenew, EngineRenew)
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    15
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    16
/**
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    17
 * Retrieves the EngineRenew that specifies the replacement of the given
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    18
 * engine type from the given renewlist */
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    19
static EngineRenew *GetEngineReplacement(EngineRenewList erl, EngineID engine, GroupID group)
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    20
{
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    21
	EngineRenew *er = (EngineRenew *)erl;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    22
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    23
	while (er) {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    24
		if (er->from == engine && er->group_id == group) return er;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    25
		er = er->next;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    26
	}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    27
	return NULL;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    28
}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    29
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    30
void RemoveAllEngineReplacement(EngineRenewList *erl)
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    31
{
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    32
	EngineRenew *er = (EngineRenew *)(*erl);
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    33
	EngineRenew *next;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    34
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    35
	while (er != NULL) {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    36
		next = er->next;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    37
		delete er;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    38
		er = next;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    39
	}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    40
	*erl = NULL; // Empty list
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    41
}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    42
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    43
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group)
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    44
{
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    45
	const EngineRenew *er = GetEngineReplacement(erl, engine, group);
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    46
	if (er == NULL && (group == DEFAULT_GROUP || (IsValidGroupID(group) && !GetGroup(group)->replace_protection))) {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    47
		/* We didn't find anything useful in the vehicle's own group so we will try ALL_GROUP */
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    48
		er = GetEngineReplacement(erl, engine, ALL_GROUP);
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    49
	}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    50
	return er == NULL ? INVALID_ENGINE : er->to;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    51
}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    52
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    53
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags)
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    54
{
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    55
	EngineRenew *er;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    56
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    57
	/* Check if the old vehicle is already in the list */
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    58
	er = GetEngineReplacement(*erl, old_engine, group);
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    59
	if (er != NULL) {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    60
		if (flags & DC_EXEC) er->to = new_engine;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    61
		return CommandCost();
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    62
	}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    63
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    64
	if (!EngineRenew::CanAllocateItem()) return CMD_ERROR;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    65
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    66
	if (flags & DC_EXEC) {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    67
		er = new EngineRenew(old_engine, new_engine);
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    68
		er->group_id = group;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    69
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    70
		/* Insert before the first element */
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    71
		er->next = (EngineRenew *)(*erl);
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    72
		*erl = (EngineRenewList)er;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    73
	}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    74
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    75
	return CommandCost();
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    76
}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    77
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    78
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags)
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    79
{
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    80
	EngineRenew *er = (EngineRenew *)(*erl);
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    81
	EngineRenew *prev = NULL;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    82
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    83
	while (er)
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    84
	{
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    85
		if (er->from == engine && er->group_id == group) {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    86
			if (flags & DC_EXEC) {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    87
				if (prev == NULL) { // First element
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    88
					/* The second becomes the new first element */
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    89
					*erl = (EngineRenewList)er->next;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    90
				} else {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    91
					/* Cut this element out */
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    92
					prev->next = er->next;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    93
				}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    94
				delete er;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    95
			}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    96
			return CommandCost();
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    97
		}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    98
		prev = er;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
    99
		er = er->next;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   100
	}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   101
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   102
	return CMD_ERROR;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   103
}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   104
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   105
static const SaveLoad _engine_renew_desc[] = {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   106
	    SLE_VAR(EngineRenew, from,     SLE_UINT16),
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   107
	    SLE_VAR(EngineRenew, to,       SLE_UINT16),
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   108
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   109
	    SLE_REF(EngineRenew, next,     REF_ENGINE_RENEWS),
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   110
	SLE_CONDVAR(EngineRenew, group_id, SLE_UINT16, 60, SL_MAX_VERSION),
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   111
	SLE_END()
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   112
};
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   113
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   114
static void Save_ERNW()
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   115
{
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   116
	EngineRenew *er;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   117
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   118
	FOR_ALL_ENGINE_RENEWS(er) {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   119
		SlSetArrayIndex(er->index);
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   120
		SlObject(er, _engine_renew_desc);
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   121
	}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   122
}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   123
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   124
static void Load_ERNW()
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   125
{
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   126
	int index;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   127
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   128
	while ((index = SlIterateArray()) != -1) {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   129
		EngineRenew *er = new (index) EngineRenew();
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   130
		SlObject(er, _engine_renew_desc);
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   131
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   132
		/* Advanced vehicle lists, ungrouped vehicles got added */
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   133
		if (CheckSavegameVersion(60)) {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   134
			er->group_id = ALL_GROUP;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   135
		} else if (CheckSavegameVersion(71)) {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   136
			if (er->group_id == DEFAULT_GROUP) er->group_id = ALL_GROUP;
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   137
		}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   138
	}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   139
}
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   140
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   141
extern const ChunkHandler _autoreplace_chunk_handlers[] = {
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   142
	{ 'ERNW', Save_ERNW,     Load_ERNW,     CH_ARRAY | CH_LAST},
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   143
};
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   144
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   145
void InitializeEngineRenews()
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   146
{
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   147
	/* Clean the engine renew pool and create 1 block in it */
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   148
	_EngineRenew_pool.CleanPool();
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   149
	_EngineRenew_pool.AddBlockToPool();
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents:
diff changeset
   150
}