summaryrefslogtreecommitdiff
path: root/src/engine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine.cpp')
-rw-r--r--src/engine.cpp142
1 files changed, 1 insertions, 141 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index ffc6c0176..60000ac5b 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -21,7 +21,6 @@
#include "functions.h"
#include "window_func.h"
#include "date_func.h"
-#include "autoreplace_base.h"
#include "autoreplace_gui.h"
#include "string_func.h"
#include "settings_type.h"
@@ -569,137 +568,6 @@ CargoID GetEngineCargoType(EngineID engine)
}
}
-/************************************************************************
- * Engine Replacement stuff
- ************************************************************************/
-
-DEFINE_OLD_POOL_GENERIC(EngineRenew, EngineRenew)
-
-/**
- * Retrieves the EngineRenew that specifies the replacement of the given
- * engine type from the given renewlist */
-static EngineRenew *GetEngineReplacement(EngineRenewList erl, EngineID engine, GroupID group)
-{
- EngineRenew *er = (EngineRenew *)erl;
-
- while (er) {
- if (er->from == engine && er->group_id == group) return er;
- er = er->next;
- }
- return NULL;
-}
-
-void RemoveAllEngineReplacement(EngineRenewList *erl)
-{
- EngineRenew *er = (EngineRenew *)(*erl);
- EngineRenew *next;
-
- while (er != NULL) {
- next = er->next;
- delete er;
- er = next;
- }
- *erl = NULL; // Empty list
-}
-
-EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group)
-{
- const EngineRenew *er = GetEngineReplacement(erl, engine, group);
- if (er == NULL && (group == DEFAULT_GROUP || (IsValidGroupID(group) && !GetGroup(group)->replace_protection))) {
- /* We didn't find anything useful in the vehicle's own group so we will try ALL_GROUP */
- er = GetEngineReplacement(erl, engine, ALL_GROUP);
- }
- return er == NULL ? INVALID_ENGINE : er->to;
-}
-
-CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags)
-{
- EngineRenew *er;
-
- /* Check if the old vehicle is already in the list */
- er = GetEngineReplacement(*erl, old_engine, group);
- if (er != NULL) {
- if (flags & DC_EXEC) er->to = new_engine;
- return CommandCost();
- }
-
- if (!EngineRenew::CanAllocateItem()) return CMD_ERROR;
-
- if (flags & DC_EXEC) {
- er = new EngineRenew(old_engine, new_engine);
- er->group_id = group;
-
- /* Insert before the first element */
- er->next = (EngineRenew *)(*erl);
- *erl = (EngineRenewList)er;
- }
-
- return CommandCost();
-}
-
-CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags)
-{
- EngineRenew *er = (EngineRenew *)(*erl);
- EngineRenew *prev = NULL;
-
- while (er)
- {
- if (er->from == engine && er->group_id == group) {
- if (flags & DC_EXEC) {
- if (prev == NULL) { // First element
- /* The second becomes the new first element */
- *erl = (EngineRenewList)er->next;
- } else {
- /* Cut this element out */
- prev->next = er->next;
- }
- delete er;
- }
- return CommandCost();
- }
- prev = er;
- er = er->next;
- }
-
- return CMD_ERROR;
-}
-
-static const SaveLoad _engine_renew_desc[] = {
- SLE_VAR(EngineRenew, from, SLE_UINT16),
- SLE_VAR(EngineRenew, to, SLE_UINT16),
-
- SLE_REF(EngineRenew, next, REF_ENGINE_RENEWS),
- SLE_CONDVAR(EngineRenew, group_id, SLE_UINT16, 60, SL_MAX_VERSION),
- SLE_END()
-};
-
-static void Save_ERNW()
-{
- EngineRenew *er;
-
- FOR_ALL_ENGINE_RENEWS(er) {
- SlSetArrayIndex(er->index);
- SlObject(er, _engine_renew_desc);
- }
-}
-
-static void Load_ERNW()
-{
- int index;
-
- while ((index = SlIterateArray()) != -1) {
- EngineRenew *er = new (index) EngineRenew();
- SlObject(er, _engine_renew_desc);
-
- /* Advanced vehicle lists, ungrouped vehicles got added */
- if (CheckSavegameVersion(60)) {
- er->group_id = ALL_GROUP;
- } else if (CheckSavegameVersion(71)) {
- if (er->group_id == DEFAULT_GROUP) er->group_id = ALL_GROUP;
- }
- }
-}
-
static const SaveLoad _engine_desc[] = {
SLE_CONDVAR(Engine, intro_date, SLE_FILE_U16 | SLE_VAR_I32, 0, 30),
SLE_CONDVAR(Engine, intro_date, SLE_INT32, 31, SL_MAX_VERSION),
@@ -805,13 +673,5 @@ static void Load_ENGS()
extern const ChunkHandler _engine_chunk_handlers[] = {
{ 'ENGN', Save_ENGN, Load_ENGN, CH_ARRAY },
- { 'ENGS', NULL, Load_ENGS, CH_RIFF },
- { 'ERNW', Save_ERNW, Load_ERNW, CH_ARRAY | CH_LAST},
+ { 'ENGS', NULL, Load_ENGS, CH_RIFF | CH_LAST },
};
-
-void InitializeEngines()
-{
- /* Clean the engine renew pool and create 1 block in it */
- _EngineRenew_pool.CleanPool();
- _EngineRenew_pool.AddBlockToPool();
-}