diff options
author | rubidium <rubidium@openttd.org> | 2010-08-28 17:30:55 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-08-28 17:30:55 +0000 |
commit | 1ec1f1ef374b70b0e057d806f1310b7aeadce50c (patch) | |
tree | d6f6372fa139e30557ab074379f979c7776e27ae /src/newgrf_commons.cpp | |
parent | 34da98f2b14e63c7042f44271d0b452fcd970737 (diff) | |
download | openttd-1ec1f1ef374b70b0e057d806f1310b7aeadce50c.tar.xz |
(svn r20648) -Codechange: implement the NewGRF override manager for objects
Diffstat (limited to 'src/newgrf_commons.cpp')
-rw-r--r-- | src/newgrf_commons.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index 952224f3d..91a449987 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -21,6 +21,7 @@ #include "station_map.h" #include "tree_map.h" #include "tunnelbridge_map.h" +#include "newgrf_object.h" #include "genworld.h" #include "core/mem_func.hpp" @@ -289,6 +290,36 @@ void IndustryTileOverrideManager::SetEntitySpec(const IndustryTileSpec *its) } /** + * Method to install the new object data in its proper slot + * The slot assigment is internal of this method, since it requires + * checking what is available + * @param spec ObjectSpec that comes from the grf decoding process + */ +void ObjectOverrideManager::SetEntitySpec(ObjectSpec *spec) +{ + /* First step : We need to find if this object is already specified in the savegame data. */ + ObjectType type = this->GetID(spec->grf_prop.local_id, spec->grf_prop.grffile->grfid); + + if (type == invalid_ID) { + /* Not found. + * Or it has already been overriden, so you've lost your place old boy. + * Or it is a simple substitute. + * We need to find a free available slot */ + type = this->AddEntityID(spec->grf_prop.local_id, spec->grf_prop.grffile->grfid, OBJECT_TRANSMITTER); + } + + if (type == invalid_ID) { + grfmsg(1, "Object.SetEntitySpec: Too many objects allocated. Ignoring."); + return; + } + + extern ObjectSpec _object_specs[NUM_OBJECTS]; + + /* Now that we know we can use the given id, copy the spec to its final destination. */ + memcpy(&_object_specs[type], spec, sizeof(*spec)); +} + +/** * Function used by houses (and soon industries) to get information * on type of "terrain" the tile it is queries sits on. * @param tile TileIndex of the tile been queried |