mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r20647) -Codechange: update some of the object spec information
This commit is contained in:
parent
f1f1c71a41
commit
34da98f2b1
|
@ -35,6 +35,7 @@
|
|||
#include "newgrf_industries.h"
|
||||
#include "newgrf_airporttiles.h"
|
||||
#include "newgrf_airport.h"
|
||||
#include "newgrf_object.h"
|
||||
#include "rev.h"
|
||||
#include "fios.h"
|
||||
#include "strings_func.h"
|
||||
|
@ -6794,6 +6795,9 @@ static void ResetNewGRFData()
|
|||
ResetCustomIndustries();
|
||||
ResetIndustries();
|
||||
|
||||
/* Reset the objects. */
|
||||
ResetObjects();
|
||||
|
||||
/* Reset station classes */
|
||||
StationClass::Reset();
|
||||
ResetCustomStations();
|
||||
|
|
|
@ -53,4 +53,11 @@ enum AirpAnimationTrigger {
|
|||
AAT_STATION_250_TICKS, ///< Triggered every 250 ticks (for all tiles at the same time).
|
||||
};
|
||||
|
||||
/** Animation triggers for objects. */
|
||||
enum ObjectAnimationTrigger {
|
||||
OAT_BUILT, ///< Triggered when the object is built (for all tiles at the same time).
|
||||
OAT_TILELOOP, ///< Triggered in the periodic tile loop.
|
||||
OAT_250_TICKS, ///< Triggered every 250 ticks (for all tiles at the same time).
|
||||
};
|
||||
|
||||
#endif /* NEWGRF_ANIMATION_TYPE_H */
|
||||
|
|
|
@ -251,6 +251,27 @@ enum CallbackID {
|
|||
|
||||
/** Called to determine text to show as airport layout name. */
|
||||
CBID_AIRPORT_LAYOUT_NAME = 0x156, // 15 bit callback
|
||||
|
||||
/** Callback done for each tile of an object to check the slope. */
|
||||
CBID_OBJECT_LAND_SLOPE_CHECK = 0x157, // 15 bit callback, not implemented
|
||||
|
||||
/** Determine the next animation frame for a house. */
|
||||
CBID_OBJECT_ANIMATION_NEXT_FRAME = 0x158, // 15 bit callback, not implemented
|
||||
|
||||
/** Called for periodically starting or stopping the animation. */
|
||||
CBID_OBJECT_ANIMATION_START_STOP = 0x159, // 15 bit callback, not implemented
|
||||
|
||||
/** Called to indicate how long the current animation frame should last. */
|
||||
CBID_OBJECT_ANIMATION_SPEED = 0x15A, // 8 bit callback, not implemented
|
||||
|
||||
/** Called to determine the colour of a town building. */
|
||||
CBID_OBJECT_COLOUR = 0x15B, // 15 bit callback, not implemented
|
||||
|
||||
/** Called to determine more text in the fund object window */
|
||||
CBID_OBJECT_FUND_MORE_TEXT = 0x15C, // 15 bit callback, not implemented
|
||||
|
||||
/** Called to determine if one can alter the ground below an object tile */
|
||||
CBID_OBJECT_AUTOSLOPE = 0x15D, // 15 bit callback, not implemented
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -346,6 +367,18 @@ enum IndustryTileCallbackMask {
|
|||
CBM_INDT_AUTOSLOPE = 6, ///< decides allowance of autosloping
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback masks for objects
|
||||
*/
|
||||
enum ObjectCallbackMask {
|
||||
CBM_OBJ_SLOPE_CHECK = 0, ///< decides slope suitability
|
||||
CBM_OBJ_ANIMATION_NEXT_FRAME = 1, ///< decides next animation frame
|
||||
CBM_OBJ_ANIMATION_SPEED = 2, ///< decides animation speed
|
||||
CBM_OBJ_COLOUR = 3, ///< decide the color of the building
|
||||
CBM_OBJ_FUND_MORE_TEXT = 4, ///< additional text in fund window
|
||||
CBM_OBJ_AUTOSLOPE = 5, ///< decides allowance of autosloping
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback masks for airport tiles
|
||||
*/
|
||||
|
|
|
@ -10,15 +10,18 @@
|
|||
/** @file newgrf_object.cpp Handling of object NewGRFs. */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "core/mem_func.hpp"
|
||||
#include "newgrf_object.h"
|
||||
#include "object_map.h"
|
||||
|
||||
extern const ObjectSpec _original_objects[];
|
||||
extern const ObjectSpec _original_objects[NEW_OBJECT_OFFSET];
|
||||
/** All the object specifications. */
|
||||
static ObjectSpec _object_specs[NUM_OBJECTS];
|
||||
|
||||
/* static */ const ObjectSpec *ObjectSpec::Get(ObjectType index)
|
||||
{
|
||||
assert(index < OBJECT_MAX);
|
||||
return &_original_objects[index];
|
||||
assert(index < NUM_OBJECTS);
|
||||
return &_object_specs[index];
|
||||
}
|
||||
|
||||
/* static */ const ObjectSpec *ObjectSpec::GetByTile(TileIndex tile)
|
||||
|
@ -26,3 +29,13 @@ extern const ObjectSpec _original_objects[];
|
|||
return ObjectSpec::Get(GetObjectType(tile));
|
||||
}
|
||||
|
||||
/** This function initialize the spec arrays of objects. */
|
||||
void ResetObjects()
|
||||
{
|
||||
/* Clean the pool. */
|
||||
MemSetT(_object_specs, 0, lengthof(_object_specs));
|
||||
|
||||
/* And add our originals. */
|
||||
MemCpyT(_object_specs, _original_objects, lengthof(_original_objects));
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,11 @@ enum ObjectFlags {
|
|||
OBJECT_FLAG_NOT_ON_LAND = 1 << 9, ///< Object can not be on land, implicitly sets #OBJECT_FLAG_BUILT_ON_WATER.
|
||||
OBJECT_FLAG_DRAW_WATER = 1 << 10, ///< Object wants to be drawn on water.
|
||||
OBJECT_FLAG_ALLOW_UNDER_BRIDGE = 1 << 11, ///< Object can built under a bridge.
|
||||
OBJECT_FLAG_ANIM_RANDOM_BITS = 1 << 12, ///< Object wants random bits in "next animation frame" callback
|
||||
};
|
||||
DECLARE_ENUM_AS_BIT_SET(ObjectFlags)
|
||||
|
||||
void ResetObjects();
|
||||
|
||||
/** An object that isn't use for transport, industries or houses. */
|
||||
struct ObjectSpec {
|
||||
|
@ -42,6 +44,7 @@ struct ObjectSpec {
|
|||
uint8 build_cost_multiplier; ///< Build cost multiplier per tile.
|
||||
uint8 clear_cost_multiplier; ///< Clear cost multiplier per tile.
|
||||
ObjectFlags flags; ///< Flags/settings related to the object.
|
||||
bool enabled; ///< Is this spec enabled?
|
||||
|
||||
/**
|
||||
* Get the cost for building a structure of this type.
|
||||
|
|
|
@ -121,9 +121,9 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||
CommandCost cost(EXPENSES_PROPERTY);
|
||||
|
||||
ObjectType type = (ObjectType)GB(p1, 0, 8);
|
||||
if (type >= OBJECT_MAX) return CMD_ERROR;
|
||||
|
||||
const ObjectSpec *spec = ObjectSpec::Get(type);
|
||||
if (!spec->enabled) return CMD_ERROR;
|
||||
|
||||
if (spec->flags & OBJECT_FLAG_ONLY_IN_SCENEDIT && (_game_mode != GM_EDITOR || _current_company != OWNER_NONE)) return CMD_ERROR;
|
||||
if (spec->flags & OBJECT_FLAG_ONLY_IN_GAME && (_game_mode != GM_NORMAL || _current_company > MAX_COMPANIES)) return CMD_ERROR;
|
||||
|
||||
|
@ -195,6 +195,10 @@ static void DrawTile_Object(TileInfo *ti)
|
|||
{
|
||||
ObjectType type = GetObjectType(ti->tile);
|
||||
const ObjectSpec *spec = ObjectSpec::Get(type);
|
||||
|
||||
/* Fall back for when the object doesn't exist anymore. */
|
||||
if (!spec->enabled) type = OBJECT_TRANSMITTER;
|
||||
|
||||
if ((spec->flags & OBJECT_FLAG_HAS_NO_FOUNDATION) == 0) DrawFoundation(ti, GetFoundation_Object(ti->tile, ti->tileh));
|
||||
|
||||
const DrawTileSprites *dts = NULL;
|
||||
|
|
|
@ -13,14 +13,17 @@
|
|||
#define OBJECT_TYPE_H
|
||||
|
||||
/** Types of objects. */
|
||||
enum ObjectType {
|
||||
OBJECT_TRANSMITTER = 0, ///< The large antenna
|
||||
OBJECT_LIGHTHOUSE = 1, ///< The nice lighthouse
|
||||
OBJECT_STATUE = 2, ///< Statue in towns
|
||||
OBJECT_OWNED_LAND = 3, ///< Owned land 'flag'
|
||||
OBJECT_HQ = 4, ///< HeadQuarter of a player
|
||||
OBJECT_MAX,
|
||||
};
|
||||
typedef uint16 ObjectType;
|
||||
|
||||
static const ObjectType OBJECT_TRANSMITTER = 0; ///< The large antenna
|
||||
static const ObjectType OBJECT_LIGHTHOUSE = 1; ///< The nice lighthouse
|
||||
static const ObjectType OBJECT_STATUE = 2; ///< Statue in towns
|
||||
static const ObjectType OBJECT_OWNED_LAND = 3; ///< Owned land 'flag'
|
||||
static const ObjectType OBJECT_HQ = 4; ///< HeadQuarter of a player
|
||||
|
||||
static const ObjectType NEW_OBJECT_OFFSET = 5; ///< Offset for new objects
|
||||
static const ObjectType NUM_OBJECTS = 256; ///< Number of supported objects
|
||||
static const ObjectType INVALID_OBJECT_TYPE = 0xFFFF; ///< An invalid object
|
||||
|
||||
/** Unique identifier for an object. */
|
||||
typedef uint16 ObjectID;
|
||||
|
|
|
@ -123,7 +123,7 @@ static const DrawTileSprites _object_hq[] = {
|
|||
|
||||
#undef TILE_SPRITE_LINE
|
||||
|
||||
#define M(name, size, build_cost_multiplier, clear_cost_multiplier, flags) { name, size, build_cost_multiplier, clear_cost_multiplier, flags }
|
||||
#define M(name, size, build_cost_multiplier, clear_cost_multiplier, flags) { name, size, build_cost_multiplier, clear_cost_multiplier, flags, true }
|
||||
|
||||
/** Specification of the original object structures. */
|
||||
extern const ObjectSpec _original_objects[] = {
|
||||
|
|
Loading…
Reference in New Issue