mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
4 Commits
29135d7ed7
...
9dd6692adf
Author | SHA1 | Date |
---|---|---|
|
9dd6692adf | |
|
7546c1acab | |
|
a6143eea21 | |
|
797f2e15ba |
|
@ -456,6 +456,9 @@ void Aircraft::OnNewCalendarDay()
|
||||||
void Aircraft::OnNewEconomyDay()
|
void Aircraft::OnNewEconomyDay()
|
||||||
{
|
{
|
||||||
if (!this->IsNormalAircraft()) return;
|
if (!this->IsNormalAircraft()) return;
|
||||||
|
|
||||||
|
PerformanceAccumulator framerate(PFE_GL_AIRCRAFT);
|
||||||
|
|
||||||
EconomyAgeVehicle(this);
|
EconomyAgeVehicle(this);
|
||||||
|
|
||||||
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
||||||
|
|
|
@ -43,26 +43,26 @@ SpriteFontCache::SpriteFontCache(FontSize fs) : FontCache(fs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get SpriteID associated with a GlyphID.
|
* Get SpriteID associated with a character.
|
||||||
* @param key Glyph to find.
|
* @param key Character to find.
|
||||||
* @return SpriteID of glyph, or 0 if not present.
|
* @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);
|
const auto found = this->char_map.find(key);
|
||||||
if (found == std::end(this->glyph_to_spriteid_map)) return 0;
|
if (found == std::end(this->char_map)) return 0;
|
||||||
return found->second;
|
return found->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteFontCache::SetUnicodeGlyph(char32_t key, SpriteID sprite)
|
void SpriteFontCache::SetUnicodeGlyph(char32_t key, SpriteID sprite)
|
||||||
{
|
{
|
||||||
this->glyph_to_spriteid_map[key] = sprite;
|
this->char_map[key] = sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteFontCache::InitializeUnicodeGlyphMap()
|
void SpriteFontCache::InitializeUnicodeGlyphMap()
|
||||||
{
|
{
|
||||||
/* Clear out existing glyph map if it exists */
|
/* Clear out existing glyph map if it exists */
|
||||||
this->glyph_to_spriteid_map.clear();
|
this->char_map.clear();
|
||||||
|
|
||||||
SpriteID base;
|
SpriteID base;
|
||||||
switch (this->fs) {
|
switch (this->fs) {
|
||||||
|
|
|
@ -28,8 +28,8 @@ public:
|
||||||
bool IsBuiltInFont() override { return true; }
|
bool IsBuiltInFont() override { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<GlyphID, SpriteID> glyph_to_spriteid_map{}; ///< Mapping of glyphs to sprite IDs.
|
std::unordered_map<char32_t, SpriteID> char_map{}; ///< Mapping of characters to sprite IDs.
|
||||||
SpriteID GetUnicodeGlyph(GlyphID key);
|
SpriteID GetUnicodeGlyph(char32_t key);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SPRITEFONTCACHE_H */
|
#endif /* SPRITEFONTCACHE_H */
|
||||||
|
|
|
@ -1696,6 +1696,9 @@ void RoadVehicle::OnNewCalendarDay()
|
||||||
void RoadVehicle::OnNewEconomyDay()
|
void RoadVehicle::OnNewEconomyDay()
|
||||||
{
|
{
|
||||||
if (!this->IsFrontEngine()) return;
|
if (!this->IsFrontEngine()) return;
|
||||||
|
|
||||||
|
PerformanceAccumulator framerate(PFE_GL_ROADVEHS);
|
||||||
|
|
||||||
EconomyAgeVehicle(this);
|
EconomyAgeVehicle(this);
|
||||||
|
|
||||||
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
||||||
|
|
|
@ -24,10 +24,12 @@
|
||||||
#include "api/script_event.hpp"
|
#include "api/script_event.hpp"
|
||||||
#include "api/script_log.hpp"
|
#include "api/script_log.hpp"
|
||||||
|
|
||||||
#include "../company_base.h"
|
#include "../company_type.h"
|
||||||
#include "../company_func.h"
|
|
||||||
#include "../fileio_func.h"
|
#include "../fileio_func.h"
|
||||||
|
#include "../goal_type.h"
|
||||||
#include "../league_type.h"
|
#include "../league_type.h"
|
||||||
|
#include "../signs_type.h"
|
||||||
|
#include "../story_type.h"
|
||||||
#include "../misc/endian_buffer.hpp"
|
#include "../misc/endian_buffer.hpp"
|
||||||
|
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
|
|
@ -12,12 +12,10 @@
|
||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
#include "../signs_func.h"
|
#include "../command_type.h"
|
||||||
#include "../vehicle_func.h"
|
#include "../company_type.h"
|
||||||
|
#include "../rail_type.h"
|
||||||
#include "../road_type.h"
|
#include "../road_type.h"
|
||||||
#include "../group.h"
|
|
||||||
#include "../goal_type.h"
|
|
||||||
#include "../story_type.h"
|
|
||||||
|
|
||||||
#include "script_types.hpp"
|
#include "script_types.hpp"
|
||||||
#include "script_log_types.hpp"
|
#include "script_log_types.hpp"
|
||||||
|
|
|
@ -260,6 +260,8 @@ void Ship::OnNewCalendarDay()
|
||||||
/** Economy day handler. */
|
/** Economy day handler. */
|
||||||
void Ship::OnNewEconomyDay()
|
void Ship::OnNewEconomyDay()
|
||||||
{
|
{
|
||||||
|
PerformanceAccumulator framerate(PFE_GL_SHIPS);
|
||||||
|
|
||||||
EconomyAgeVehicle(this);
|
EconomyAgeVehicle(this);
|
||||||
|
|
||||||
if ((++this->day_counter & 7) == 0) {
|
if ((++this->day_counter & 7) == 0) {
|
||||||
|
|
|
@ -4176,6 +4176,8 @@ void Train::OnNewCalendarDay()
|
||||||
/** Economy day handler. */
|
/** Economy day handler. */
|
||||||
void Train::OnNewEconomyDay()
|
void Train::OnNewEconomyDay()
|
||||||
{
|
{
|
||||||
|
PerformanceAccumulator framerate(PFE_GL_TRAINS);
|
||||||
|
|
||||||
EconomyAgeVehicle(this);
|
EconomyAgeVehicle(this);
|
||||||
|
|
||||||
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
||||||
|
|
|
@ -955,16 +955,17 @@ void CallVehicleTicks()
|
||||||
{
|
{
|
||||||
_vehicles_to_autoreplace.clear();
|
_vehicles_to_autoreplace.clear();
|
||||||
|
|
||||||
|
PerformanceAccumulator::Reset(PFE_GL_TRAINS);
|
||||||
|
PerformanceAccumulator::Reset(PFE_GL_ROADVEHS);
|
||||||
|
PerformanceAccumulator::Reset(PFE_GL_SHIPS);
|
||||||
|
PerformanceAccumulator::Reset(PFE_GL_AIRCRAFT);
|
||||||
|
|
||||||
RunEconomyVehicleDayProc();
|
RunEconomyVehicleDayProc();
|
||||||
|
|
||||||
{
|
{
|
||||||
PerformanceMeasurer framerate(PFE_GL_ECONOMY);
|
PerformanceMeasurer framerate(PFE_GL_ECONOMY);
|
||||||
for (Station *st : Station::Iterate()) LoadUnloadStation(st);
|
for (Station *st : Station::Iterate()) LoadUnloadStation(st);
|
||||||
}
|
}
|
||||||
PerformanceAccumulator::Reset(PFE_GL_TRAINS);
|
|
||||||
PerformanceAccumulator::Reset(PFE_GL_ROADVEHS);
|
|
||||||
PerformanceAccumulator::Reset(PFE_GL_SHIPS);
|
|
||||||
PerformanceAccumulator::Reset(PFE_GL_AIRCRAFT);
|
|
||||||
|
|
||||||
for (Vehicle *v : Vehicle::Iterate()) {
|
for (Vehicle *v : Vehicle::Iterate()) {
|
||||||
[[maybe_unused]] VehicleID vehicle_index = v->index;
|
[[maybe_unused]] VehicleID vehicle_index = v->index;
|
||||||
|
|
Loading…
Reference in New Issue