mirror of https://github.com/OpenTTD/OpenTTD
Codechange: use std::array.fill over memset
parent
228f9ca941
commit
96873dee63
|
@ -424,7 +424,6 @@ Sprite *Blitter_32bppOptimized::EncodeInternal(SpriteType sprite_type, const Spr
|
||||||
dest_sprite->y_offs = root_sprite.y_offs;
|
dest_sprite->y_offs = root_sprite.y_offs;
|
||||||
|
|
||||||
SpriteData *dst = (SpriteData *)dest_sprite->data;
|
SpriteData *dst = (SpriteData *)dest_sprite->data;
|
||||||
memset(dst, 0, sizeof(*dst));
|
|
||||||
|
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
for (ZoomLevel z = zoom_min; z <= zoom_max; z++) {
|
for (ZoomLevel z = zoom_min; z <= zoom_max; z++) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ struct Object : ObjectPool::PoolItem<&_object_pool> {
|
||||||
static inline void IncTypeCount(ObjectType type)
|
static inline void IncTypeCount(ObjectType type)
|
||||||
{
|
{
|
||||||
assert(type < NUM_OBJECTS);
|
assert(type < NUM_OBJECTS);
|
||||||
counts[type]++;
|
Object::counts[type]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +56,7 @@ struct Object : ObjectPool::PoolItem<&_object_pool> {
|
||||||
static inline void DecTypeCount(ObjectType type)
|
static inline void DecTypeCount(ObjectType type)
|
||||||
{
|
{
|
||||||
assert(type < NUM_OBJECTS);
|
assert(type < NUM_OBJECTS);
|
||||||
counts[type]--;
|
Object::counts[type]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,17 +67,17 @@ struct Object : ObjectPool::PoolItem<&_object_pool> {
|
||||||
static inline uint16_t GetTypeCount(ObjectType type)
|
static inline uint16_t GetTypeCount(ObjectType type)
|
||||||
{
|
{
|
||||||
assert(type < NUM_OBJECTS);
|
assert(type < NUM_OBJECTS);
|
||||||
return counts[type];
|
return Object::counts[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resets object counts. */
|
/** Resets object counts. */
|
||||||
static inline void ResetTypeCounts()
|
static inline void ResetTypeCounts()
|
||||||
{
|
{
|
||||||
memset(&counts, 0, sizeof(counts));
|
Object::counts.fill(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static uint16_t counts[NUM_OBJECTS]; ///< Number of objects per type ingame
|
static std::array<uint16_t, NUM_OBJECTS> counts; ///< Number of objects per type ingame
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
ObjectPool _object_pool("Object");
|
ObjectPool _object_pool("Object");
|
||||||
INSTANTIATE_POOL_METHODS(Object)
|
INSTANTIATE_POOL_METHODS(Object)
|
||||||
uint16_t Object::counts[NUM_OBJECTS];
|
/* static */ std::array<uint16_t, NUM_OBJECTS> Object::counts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the object associated with a tile.
|
* Get the object associated with a tile.
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
*/
|
*/
|
||||||
void PrepareOldDiffCustom()
|
void PrepareOldDiffCustom()
|
||||||
{
|
{
|
||||||
memset(_old_diff_custom, 0, sizeof(_old_diff_custom));
|
_old_diff_custom.fill(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,6 +39,6 @@ extern SettingTable _win32_settings;
|
||||||
|
|
||||||
static const uint GAME_DIFFICULTY_NUM = 18;
|
static const uint GAME_DIFFICULTY_NUM = 18;
|
||||||
extern const std::array<std::string, GAME_DIFFICULTY_NUM> _old_diff_settings;
|
extern const std::array<std::string, GAME_DIFFICULTY_NUM> _old_diff_settings;
|
||||||
extern uint16_t _old_diff_custom[GAME_DIFFICULTY_NUM];
|
extern std::array<uint16_t, GAME_DIFFICULTY_NUM> _old_diff_custom;
|
||||||
|
|
||||||
#endif /* SETTINGS_TABLE_H */
|
#endif /* SETTINGS_TABLE_H */
|
||||||
|
|
|
@ -31,7 +31,7 @@ using SpriteComponents = EnumBitSet<SpriteComponent, uint8_t, SpriteComponent::E
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T>
|
||||||
class SpriteCollMap {
|
class SpriteCollMap {
|
||||||
std::array<T, to_underlying(ZoomLevel::End)> data;
|
std::array<T, to_underlying(ZoomLevel::End)> data{};
|
||||||
public:
|
public:
|
||||||
inline constexpr T &operator[](const ZoomLevel &zoom) { return this->data[to_underlying(zoom)]; }
|
inline constexpr T &operator[](const ZoomLevel &zoom) { return this->data[to_underlying(zoom)]; }
|
||||||
inline constexpr const T &operator[](const ZoomLevel &zoom) const { return this->data[to_underlying(zoom)]; }
|
inline constexpr const T &operator[](const ZoomLevel &zoom) const { return this->data[to_underlying(zoom)]; }
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
[pre-amble]
|
[pre-amble]
|
||||||
const std::array<std::string, GAME_DIFFICULTY_NUM> _old_diff_settings{"max_no_competitors", "competitor_start_time", "number_towns", "industry_density", "max_loan", "initial_interest", "vehicle_costs", "competitor_speed", "competitor_intelligence", "vehicle_breakdowns", "subsidy_multiplier", "construction_cost", "terrain_type", "quantity_sea_lakes", "economy", "line_reverse_mode", "disasters", "town_council_tolerance"};
|
const std::array<std::string, GAME_DIFFICULTY_NUM> _old_diff_settings{"max_no_competitors", "competitor_start_time", "number_towns", "industry_density", "max_loan", "initial_interest", "vehicle_costs", "competitor_speed", "competitor_intelligence", "vehicle_breakdowns", "subsidy_multiplier", "construction_cost", "terrain_type", "quantity_sea_lakes", "economy", "line_reverse_mode", "disasters", "town_council_tolerance"};
|
||||||
|
|
||||||
uint16_t _old_diff_custom[GAME_DIFFICULTY_NUM];
|
std::array<uint16_t, GAME_DIFFICULTY_NUM> _old_diff_custom;
|
||||||
uint8_t _old_diff_level; ///< Old difficulty level from old savegames
|
uint8_t _old_diff_level; ///< Old difficulty level from old savegames
|
||||||
|
|
||||||
static void DifficultyNoiseChange(int32_t new_value);
|
static void DifficultyNoiseChange(int32_t new_value);
|
||||||
|
|
Loading…
Reference in New Issue