Changeset - r15951:b2083610fae0
[Not reviewed]
master
0 5 0
rubidium - 14 years ago 2010-08-28 17:32:30
rubidium@openttd.org
(svn r20649) -Codechange: implement classes for objects
5 files changed with 40 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -2059,6 +2059,9 @@ STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_O
 
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
src/newgrf.cpp
Show inline comments
 
@@ -6796,6 +6796,7 @@ static void ResetNewGRFData()
 
	ResetIndustries();
 

	
 
	/* Reset the objects. */
 
	ObjectClass::Reset();
 
	ResetObjects();
 

	
 
	/* Reset station classes */
src/newgrf_object.cpp
Show inline comments
 
@@ -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)
src/newgrf_object.h
Show inline comments
 
@@ -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 */
src/table/object_land.h
Show inline comments
 
@@ -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[] = {
0 comments (0 inline, 0 general)