|
|
/* $Id$ */
|
|
|
|
|
|
/*
|
|
|
* This file is part of OpenTTD.
|
|
|
* 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 newgrf_commons.h This file simplyfies and embeds a common mechanism of
|
|
|
* loading/saving and mapping of grf entities.
|
|
|
*/
|
|
|
|
|
|
#ifndef NEWGRF_COMMONS_H
|
|
|
#define NEWGRF_COMMONS_H
|
|
|
|
|
|
#include "tile_type.h"
|
|
|
#include "sprite.h"
|
|
|
#include "core/alloc_type.hpp"
|
|
|
#include "core/smallvec_type.hpp"
|
|
|
#include "command_type.h"
|
|
|
#include "direction_type.h"
|
|
|
#include "company_type.h"
|
|
|
|
|
|
/** Context for tile accesses */
|
|
|
enum TileContext {
|
|
|
TCX_NORMAL, ///< Nothing special.
|
|
|
TCX_UPPER_HALFTILE, ///< Querying information about the upper part of a tile with halftile foundation.
|
|
|
TCX_ON_BRIDGE, ///< Querying information about stuff on the bridge (via some bridgehead).
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Flags to enable register usage in sprite layouts.
|
|
|
*/
|
|
|
enum TileLayoutFlags {
|
|
|
TLF_NOTHING = 0x00,
|
|
|
|
|
|
TLF_DODRAW = 0x01, ///< Only draw sprite if value of register TileLayoutRegisters::dodraw is non-zero.
|
|
|
TLF_SPRITE = 0x02, ///< Add signed offset to sprite from register TileLayoutRegisters::sprite.
|
|
|
TLF_PALETTE = 0x04, ///< Add signed offset to palette from register TileLayoutRegisters::palette.
|
|
|
TLF_CUSTOM_PALETTE = 0x08, ///< Palette is from Action 1 (moved to SPRITE_MODIFIER_CUSTOM_SPRITE in palette during loading).
|
|
|
|
|
|
TLF_BB_XY_OFFSET = 0x10, ///< Add signed offset to bounding box X and Y positions from register TileLayoutRegisters::delta.parent[0..1].
|
|
|
TLF_BB_Z_OFFSET = 0x20, ///< Add signed offset to bounding box Z positions from register TileLayoutRegisters::delta.parent[2].
|
|
|
|
|
|
TLF_CHILD_X_OFFSET = 0x10, ///< Add signed offset to child sprite X positions from register TileLayoutRegisters::delta.child[0].
|
|
|
TLF_CHILD_Y_OFFSET = 0x20, ///< Add signed offset to child sprite Y positions from register TileLayoutRegisters::delta.child[1].
|
|
|
|
|
|
TLF_SPRITE_VAR10 = 0x40, ///< Resolve sprite with a specific value in variable 10.
|
|
|
TLF_PALETTE_VAR10 = 0x80, ///< Resolve palette with a specific value in variable 10.
|
|
|
|
|
|
TLF_KNOWN_FLAGS = 0x7F, ///< Known flags. Any unknown set flag will disable the GRF.
|
|
|
|
|
|
/** Flags which are still required after loading the GRF. */
|
|
|
TLF_DRAWING_FLAGS = ~TLF_CUSTOM_PALETTE,
|
|
|
|
|
|
/** Flags which do not work for the (first) ground sprite. */
|
|
|
TLF_NON_GROUND_FLAGS = TLF_BB_XY_OFFSET | TLF_BB_Z_OFFSET | TLF_CHILD_X_OFFSET | TLF_CHILD_Y_OFFSET,
|
|
|
|
|
|
/** Flags which refer to using multiple action-1-2-3 chains. */
|
|
|
TLF_VAR10_FLAGS = TLF_SPRITE_VAR10 | TLF_PALETTE_VAR10,
|
|
|
|
|
|
/** Flags which require resolving the action-1-2-3 chain for the sprite, even if it is no action-1 sprite. */
|
|
|
TLF_SPRITE_REG_FLAGS = TLF_DODRAW | TLF_SPRITE | TLF_BB_XY_OFFSET | TLF_BB_Z_OFFSET | TLF_CHILD_X_OFFSET | TLF_CHILD_Y_OFFSET,
|
|
|
|