Changeset - r19262:b0c685c8a315
[Not reviewed]
master
0 2 0
frosch - 12 years ago 2012-04-22 16:28:09
frosch@openttd.org
(svn r24165) -Codechange: Split parts of static NewGRFClass::Assign() into non-static Insert().
2 files changed with 16 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/newgrf_class.h
Show inline comments
 
@@ -39,6 +39,8 @@ public:
 
	uint32 global_id; ///< Global ID for class, e.g. 'DFLT', 'WAYP', etc.
 
	StringID name;    ///< Name of this class.
 

	
 
	void Insert(Tspec *spec);
 

	
 
	static void Reset();
 
	static Tid Allocate(uint32 global_id);
 
	static void Assign(Tspec *spec);
src/newgrf_class_func.h
Show inline comments
 
@@ -71,6 +71,18 @@ DEFINE_NEWGRF_CLASS_METHOD(Tid)::Allocat
 
}
 

	
 
/**
 
 * Insert a spec into the class.
 
 * @param spec The spec to insert.
 
 */
 
DEFINE_NEWGRF_CLASS_METHOD(void)::Insert(Tspec *spec)
 
{
 
	uint i = this->count++;
 
	this->spec = ReallocT(this->spec, this->count);
 

	
 
	this->spec[i] = spec;
 
}
 

	
 
/**
 
 * Assign a spec to one of the classes.
 
 * @param spec The spec to assign.
 
 * @note The spec must have a valid class id set.
 
@@ -78,12 +90,7 @@ DEFINE_NEWGRF_CLASS_METHOD(Tid)::Allocat
 
DEFINE_NEWGRF_CLASS_METHOD(void)::Assign(Tspec *spec)
 
{
 
	assert(spec->cls_id < Tmax);
 
	NewGRFClass<Tspec, Tid, Tmax> *cls = &classes[spec->cls_id];
 

	
 
	uint i = cls->count++;
 
	cls->spec = ReallocT(cls->spec, cls->count);
 

	
 
	cls->spec[i] = spec;
 
	Get(spec->cls_id)->Insert(spec);
 
}
 

	
 
/**
 
@@ -169,6 +176,7 @@ DEFINE_NEWGRF_CLASS_METHOD(const Tspec *
 
	template void name::ResetClass(); \
 
	template void name::Reset(); \
 
	template Tid name::Allocate(uint32 global_id); \
 
	template void name::Insert(Tspec *spec); \
 
	template void name::Assign(Tspec *spec); \
 
	template NewGRFClass<Tspec, Tid, Tmax> *name::Get(Tid cls_id); \
 
	template uint name::GetCount(); \
0 comments (0 inline, 0 general)