Changeset - r17714:bdfed3434afd
[Not reviewed]
master
0 2 0
frosch - 13 years ago 2011-05-28 09:43:53
frosch@openttd.org
(svn r22504) -Codechange: Add EV_END and use it to check the lengths of _effect_init_procs and _effect_tick_procs.
2 files changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/effectvehicle.cpp
Show inline comments
 
@@ -523,62 +523,64 @@ static bool BubbleTick(EffectVehicle *v)
 
	v->cur_image = SPR_BUBBLE_0 + b->image;
 

	
 
	VehicleMove(v, true);
 

	
 
	return true;
 
}
 

	
 

	
 
typedef void EffectInitProc(EffectVehicle *v);
 
typedef bool EffectTickProc(EffectVehicle *v);
 

	
 
/** Functions to initialise an effect vehicle after construction. */
 
static EffectInitProc * const _effect_init_procs[] = {
 
	ChimneySmokeInit,   // EV_CHIMNEY_SMOKE
 
	SteamSmokeInit,     // EV_STEAM_SMOKE
 
	DieselSmokeInit,    // EV_DIESEL_SMOKE
 
	ElectricSparkInit,  // EV_ELECTRIC_SPARK
 
	SmokeInit,          // EV_SMOKE
 
	ExplosionLargeInit, // EV_EXPLOSION_LARGE
 
	BreakdownSmokeInit, // EV_BREAKDOWN_SMOKE
 
	ExplosionSmallInit, // EV_EXPLOSION_SMALL
 
	BulldozerInit,      // EV_BULLDOZER
 
	BubbleInit,         // EV_BUBBLE
 
};
 
assert_compile(lengthof(_effect_init_procs) == EV_END);
 

	
 
/** Functions for controling effect vehicles at each tick. */
 
static EffectTickProc * const _effect_tick_procs[] = {
 
	ChimneySmokeTick,   // EV_CHIMNEY_SMOKE
 
	SteamSmokeTick,     // EV_STEAM_SMOKE
 
	DieselSmokeTick,    // EV_DIESEL_SMOKE
 
	ElectricSparkTick,  // EV_ELECTRIC_SPARK
 
	SmokeTick,          // EV_SMOKE
 
	ExplosionLargeTick, // EV_EXPLOSION_LARGE
 
	BreakdownSmokeTick, // EV_BREAKDOWN_SMOKE
 
	ExplosionSmallTick, // EV_EXPLOSION_SMALL
 
	BulldozerTick,      // EV_BULLDOZER
 
	BubbleTick,         // EV_BUBBLE
 
};
 
assert_compile(lengthof(_effect_tick_procs) == EV_END);
 

	
 

	
 
/**
 
 * Create an effect vehicle at a particular location.
 
 * @param x The x location on the map.
 
 * @param y The y location on the map.
 
 * @param z The z location on the map.
 
 * @param type The type of effect vehicle.
 
 * @return The effect vehicle.
 
 */
 
EffectVehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type)
 
{
 
	if (!Vehicle::CanAllocateItem()) return NULL;
 

	
 
	EffectVehicle *v = new EffectVehicle();
 
	v->subtype = type;
 
	v->x_pos = x;
 
	v->y_pos = y;
 
	v->z_pos = z;
 
	v->tile = 0;
 
	v->UpdateDeltaXY(INVALID_DIR);
 
	v->vehstatus = VS_UNCLICKABLE;
 

	
 
	_effect_init_procs[type](v);
src/effectvehicle_func.h
Show inline comments
 
@@ -5,31 +5,32 @@
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file effectvehicle_func.h Functions related to effect vehicles. */
 

	
 
#ifndef EFFECTVEHICLE_FUNC_H
 
#define EFFECTVEHICLE_FUNC_H
 

	
 
#include "vehicle_type.h"
 

	
 
/** Effect vehicle types */
 
enum EffectVehicleType {
 
	EV_CHIMNEY_SMOKE            =  0, ///< Smoke of power plant (industry).
 
	EV_STEAM_SMOKE              =  1, ///< Smoke of steam engines.
 
	EV_DIESEL_SMOKE             =  2, ///< Smoke of diesel engines.
 
	EV_ELECTRIC_SPARK           =  3, ///< Sparcs of electric engines.
 
	EV_SMOKE                    =  4, ///< Smoke of broken aircraft, copper mine and disasters.
 
	EV_EXPLOSION_LARGE          =  5, ///< Various explosions.
 
	EV_BREAKDOWN_SMOKE          =  6, ///< Smoke of broken vehicles except aircraft.
 
	EV_EXPLOSION_SMALL          =  7, ///< Various explosions.
 
	EV_BULLDOZER                =  8, ///< Bulldozer at roadworks.
 
	EV_BUBBLE                   =  9, ///< Bubble of bubble generator (industry).
 
	EV_END
 
};
 

	
 
EffectVehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type);
 
EffectVehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicleType type);
 
EffectVehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicleType type);
 

	
 
#endif /* EFFECTVEHICLE_FUNC_H */
0 comments (0 inline, 0 general)