diff options
-rw-r--r-- | src/lang/english.txt | 3 | ||||
-rw-r--r-- | src/newgrf.cpp | 1 | ||||
-rw-r--r-- | src/newgrf_object.cpp | 21 | ||||
-rw-r--r-- | src/newgrf_object.h | 14 | ||||
-rw-r--r-- | src/table/object_land.h | 2 |
5 files changed, 40 insertions, 1 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt index 63307eed8..e709825a8 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2059,6 +2059,9 @@ STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_OF_LAND :{BLACK}Raise a STR_LANDSCAPING_LEVEL_LAND_TOOLTIP :{BLACK}Level land STR_LANDSCAPING_TOOLTIP_PURCHASE_LAND :{BLACK}Purchase land for future use +STR_OBJECT_CLASS_LTHS :Lighthouses +STR_OBJECT_CLASS_TRNS :Transmitters + # Tree planting window (last two for SE only) STR_PLANT_TREE_CAPTION :{WHITE}Trees STR_PLANT_TREE_TOOLTIP :{BLACK}Select tree type to plant diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 3e0a8ff91..293bc33a7 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -6796,6 +6796,7 @@ static void ResetNewGRFData() ResetIndustries(); /* Reset the objects. */ + ObjectClass::Reset(); ResetObjects(); /* Reset station classes */ diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp index edb991fa8..30dd23df5 100644 --- a/src/newgrf_object.cpp +++ b/src/newgrf_object.cpp @@ -11,8 +11,11 @@ #include "stdafx.h" #include "core/mem_func.hpp" +#include "newgrf.h" +#include "newgrf_class_func.h" #include "newgrf_object.h" #include "object_map.h" +#include "openttd.h" /** The override manager for our objects. */ ObjectOverrideManager _object_mngr(NEW_OBJECT_OFFSET, NUM_OBJECTS, INVALID_OBJECT_TYPE); @@ -42,3 +45,21 @@ void ResetObjects() MemCpyT(_object_specs, _original_objects, lengthof(_original_objects)); } +template <typename Tspec, typename Tid, Tid Tmax> +/* static */ void NewGRFClass<Tspec, Tid, Tmax>::InsertDefaults() +{ + /* We only add the transmitters in the scenario editor. */ + if (_game_mode != GM_EDITOR) return; + + ObjectClassID cls = ObjectClass::Allocate('LTHS'); + ObjectClass::SetName(cls, STR_OBJECT_CLASS_LTHS); + _object_specs[OBJECT_LIGHTHOUSE].cls_id = cls; + ObjectClass::Assign(&_object_specs[OBJECT_LIGHTHOUSE]); + + cls = ObjectClass::Allocate('TRNS'); + ObjectClass::SetName(cls, STR_OBJECT_CLASS_TRNS); + _object_specs[OBJECT_TRANSMITTER].cls_id = cls; + ObjectClass::Assign(&_object_specs[OBJECT_TRANSMITTER]); +} + +INSTANTIATE_NEWGRF_CLASS_METHODS(ObjectClass, ObjectSpec, ObjectClassID, OBJECT_CLASS_MAX) diff --git a/src/newgrf_object.h b/src/newgrf_object.h index 2fea6668b..5946ae397 100644 --- a/src/newgrf_object.h +++ b/src/newgrf_object.h @@ -15,6 +15,7 @@ #include "economy_func.h" #include "strings_type.h" #include "object_type.h" +#include "newgrf_class.h" #include "newgrf_commons.h" /** Various object behaviours. */ @@ -38,10 +39,20 @@ DECLARE_ENUM_AS_BIT_SET(ObjectFlags) void ResetObjects(); +/** Class IDs for objects. */ +enum ObjectClassID { + OBJECT_CLASS_BEGIN = 0, ///< The lowest valid value + OBJECT_CLASS_MAX = 32, ///< Maximum number of classes. + INVALID_OBJECT_CLASS = 0xFF, ///< Class for the less fortunate. +}; +/** Allow incrementing of ObjectClassID variables */ +DECLARE_POSTFIX_INCREMENT(ObjectClassID) + /** An object that isn't use for transport, industries or houses. */ struct ObjectSpec { /* 2 because of the "normal" and "buy" sprite stacks. */ GRFFilePropsBase<2> grf_prop; ///< Properties related the the grf file + ObjectClassID cls_id; ///< The class to which this spec belongs. StringID name; ///< The name for this object. uint8 size; ///< The size of this objects; low nibble for X, high nibble for Y. @@ -77,4 +88,7 @@ struct ObjectSpec { static const ObjectSpec *GetByTile(TileIndex tile); }; +/** Struct containing information relating to station classes. */ +typedef NewGRFClass<ObjectSpec, ObjectClassID, OBJECT_CLASS_MAX> ObjectClass; + #endif /* NEWGRF_OBJECT_H */ diff --git a/src/table/object_land.h b/src/table/object_land.h index 69e0768f3..a5b2a985f 100644 --- a/src/table/object_land.h +++ b/src/table/object_land.h @@ -123,7 +123,7 @@ static const DrawTileSprites _object_hq[] = { #undef TILE_SPRITE_LINE -#define M(name, size, build_cost_multiplier, clear_cost_multiplier, flags) { GRFFilePropsBase<2>(), name, size, build_cost_multiplier, clear_cost_multiplier, flags, true } +#define M(name, size, build_cost_multiplier, clear_cost_multiplier, flags) { GRFFilePropsBase<2>(), INVALID_OBJECT_CLASS, name, size, build_cost_multiplier, clear_cost_multiplier, flags, true } /** Specification of the original object structures. */ extern const ObjectSpec _original_objects[] = { |