mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
4 Commits
c5e3f3a417
...
359694b462
Author | SHA1 | Date |
---|---|---|
|
359694b462 | |
|
7546c1acab | |
|
a6143eea21 | |
|
4672bdb266 |
|
@ -1125,6 +1125,15 @@ static bool AircraftController(Aircraft *v)
|
|||
}
|
||||
|
||||
if (amd.flags.Test(AirportMovingDataFlag::Land)) {
|
||||
if (st->airport.blocks.Test(AirportBlock::Zeppeliner)) {
|
||||
/* Zeppeliner blocked the runway, abort landing */
|
||||
v->state = FLYING;
|
||||
UpdateAircraftCache(v);
|
||||
SetAircraftPosition(v, gp.x, gp.y, GetAircraftFlightLevel(v));
|
||||
v->pos = v->previous_pos;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (st->airport.tile == INVALID_TILE) {
|
||||
/* Airport has been removed, abort the landing procedure */
|
||||
v->state = FLYING;
|
||||
|
@ -1782,6 +1791,11 @@ static void AirportClearBlock(const Aircraft *v, const AirportFTAClass *apc)
|
|||
if (apc->layout[v->previous_pos].blocks != apc->layout[v->pos].blocks) {
|
||||
Station *st = Station::Get(v->targetairport);
|
||||
|
||||
if (st->airport.blocks.Test(AirportBlock::Zeppeliner) &&
|
||||
apc->layout[v->previous_pos].blocks == AirportBlock::RunwayIn) {
|
||||
return;
|
||||
}
|
||||
|
||||
st->airport.blocks.Reset(apc->layout[v->previous_pos].blocks);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,6 +127,7 @@ enum class AirportBlock : uint8_t {
|
|||
/* end of new blocks */
|
||||
|
||||
Nothing = 30,
|
||||
Zeppeliner = 62, ///< Block for the zeppeliner disaster vehicle.
|
||||
AirportClosed = 63, ///< Dummy block for indicating a closed airport.
|
||||
};
|
||||
using AirportBlocks = EnumBitSet<AirportBlock, uint64_t>;
|
||||
|
|
|
@ -215,7 +215,7 @@ void DisasterVehicle::UpdatePosition(int x, int y, int z)
|
|||
|
||||
/**
|
||||
* Zeppeliner handling, v->state states:
|
||||
* 0: Zeppeliner initialization has found a small airport, go there and crash
|
||||
* 0: Zeppeliner initialization has found an airport, go there and crash
|
||||
* 1: Create crash and animate falling down for extra dramatic effect
|
||||
* 2: Create more smoke and leave debris on ground
|
||||
* 2: Clear the runway after some time and remove crashed zeppeliner
|
||||
|
@ -263,7 +263,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
|
|||
|
||||
if (IsValidTile(v->tile) && IsAirportTile(v->tile)) {
|
||||
Station *st = Station::GetByTile(v->tile);
|
||||
st->airport.blocks.Reset(AirportBlock::RunwayIn);
|
||||
st->airport.blocks.Reset({AirportBlock::Zeppeliner, AirportBlock::RunwayIn});
|
||||
AI::NewEvent(GetTileOwner(v->tile), new ScriptEventDisasterZeppelinerCleared(st->index));
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
|
|||
}
|
||||
|
||||
if (IsValidTile(v->tile) && IsAirportTile(v->tile)) {
|
||||
Station::GetByTile(v->tile)->airport.blocks.Set(AirportBlock::RunwayIn);
|
||||
Station::GetByTile(v->tile)->airport.blocks.Reset({AirportBlock::Zeppeliner, AirportBlock::RunwayIn});
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -722,14 +722,14 @@ typedef void DisasterInitProc();
|
|||
|
||||
|
||||
/**
|
||||
* Zeppeliner which crashes on a small airport if one found,
|
||||
* Zeppeliner which crashes on an airport if one found,
|
||||
* otherwise crashes on a random tile
|
||||
*/
|
||||
static void Disaster_Zeppeliner_Init()
|
||||
{
|
||||
if (!Vehicle::CanAllocateItem(2)) return;
|
||||
|
||||
/* Pick a random place, unless we find a small airport */
|
||||
/* Pick a random place, unless we find an airport */
|
||||
int x = TileX(RandomTile()) * TILE_SIZE + TILE_SIZE / 2;
|
||||
|
||||
for (const Station *st : Station::Iterate()) {
|
||||
|
|
|
@ -43,26 +43,26 @@ SpriteFontCache::SpriteFontCache(FontSize fs) : FontCache(fs)
|
|||
}
|
||||
|
||||
/**
|
||||
* Get SpriteID associated with a GlyphID.
|
||||
* @param key Glyph to find.
|
||||
* @return SpriteID of glyph, or 0 if not present.
|
||||
* Get SpriteID associated with a character.
|
||||
* @param key Character to find.
|
||||
* @return SpriteID for character, or 0 if not present.
|
||||
*/
|
||||
SpriteID SpriteFontCache::GetUnicodeGlyph(GlyphID key)
|
||||
SpriteID SpriteFontCache::GetUnicodeGlyph(char32_t key)
|
||||
{
|
||||
const auto found = this->glyph_to_spriteid_map.find(key & ~SPRITE_GLYPH);
|
||||
if (found == std::end(this->glyph_to_spriteid_map)) return 0;
|
||||
const auto found = this->char_map.find(key);
|
||||
if (found == std::end(this->char_map)) return 0;
|
||||
return found->second;
|
||||
}
|
||||
|
||||
void SpriteFontCache::SetUnicodeGlyph(char32_t key, SpriteID sprite)
|
||||
{
|
||||
this->glyph_to_spriteid_map[key] = sprite;
|
||||
this->char_map[key] = sprite;
|
||||
}
|
||||
|
||||
void SpriteFontCache::InitializeUnicodeGlyphMap()
|
||||
{
|
||||
/* Clear out existing glyph map if it exists */
|
||||
this->glyph_to_spriteid_map.clear();
|
||||
this->char_map.clear();
|
||||
|
||||
SpriteID base;
|
||||
switch (this->fs) {
|
||||
|
|
|
@ -28,8 +28,8 @@ public:
|
|||
bool IsBuiltInFont() override { return true; }
|
||||
|
||||
private:
|
||||
std::unordered_map<GlyphID, SpriteID> glyph_to_spriteid_map{}; ///< Mapping of glyphs to sprite IDs.
|
||||
SpriteID GetUnicodeGlyph(GlyphID key);
|
||||
std::unordered_map<char32_t, SpriteID> char_map{}; ///< Mapping of characters to sprite IDs.
|
||||
SpriteID GetUnicodeGlyph(char32_t key);
|
||||
};
|
||||
|
||||
#endif /* SPRITEFONTCACHE_H */
|
||||
|
|
|
@ -24,10 +24,12 @@
|
|||
#include "api/script_event.hpp"
|
||||
#include "api/script_log.hpp"
|
||||
|
||||
#include "../company_base.h"
|
||||
#include "../company_func.h"
|
||||
#include "../company_type.h"
|
||||
#include "../fileio_func.h"
|
||||
#include "../goal_type.h"
|
||||
#include "../league_type.h"
|
||||
#include "../signs_type.h"
|
||||
#include "../story_type.h"
|
||||
#include "../misc/endian_buffer.hpp"
|
||||
|
||||
#include "../safeguards.h"
|
||||
|
|
|
@ -12,12 +12,10 @@
|
|||
|
||||
#include <queue>
|
||||
|
||||
#include "../signs_func.h"
|
||||
#include "../vehicle_func.h"
|
||||
#include "../command_type.h"
|
||||
#include "../company_type.h"
|
||||
#include "../rail_type.h"
|
||||
#include "../road_type.h"
|
||||
#include "../group.h"
|
||||
#include "../goal_type.h"
|
||||
#include "../story_type.h"
|
||||
|
||||
#include "script_types.hpp"
|
||||
#include "script_log_types.hpp"
|
||||
|
|
Loading…
Reference in New Issue