More aggressive sanitization. Loads of integer definition fixes
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "CreatePokemon.hpp"
|
||||
namespace PkmnLib::Battling {
|
||||
CreatePokemon& CreatePokemon::WithRandomIndividualValues(ArbUt::Random rand) {
|
||||
CreatePokemon& CreatePokemon::WithRandomIndividualValues(ArbUt::Random& rand) {
|
||||
_ivHp = rand.Get(0, 32);
|
||||
_ivAttack = rand.Get(0, 32);
|
||||
_ivDefense = rand.Get(0, 32);
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib::Battling {
|
||||
return *this;
|
||||
}
|
||||
|
||||
CreatePokemon& CreatePokemon::WithIndividualValue(CreatureLib::Library::Statistic stat, uint8_t value) {
|
||||
CreatePokemon& CreatePokemon::WithIndividualValue(CreatureLib::Library::Statistic stat, u8 value) {
|
||||
switch (stat) {
|
||||
case PkmnLib::Library::Statistic::HealthPoints: _ivHp = value; break;
|
||||
case PkmnLib::Library::Statistic::PhysicalAttack: _ivAttack = value; break;
|
||||
@@ -22,7 +22,7 @@ namespace PkmnLib::Battling {
|
||||
return *this;
|
||||
}
|
||||
|
||||
CreatePokemon& CreatePokemon::WithEffortValue(CreatureLib::Library::Statistic stat, uint8_t value) {
|
||||
CreatePokemon& CreatePokemon::WithEffortValue(CreatureLib::Library::Statistic stat, u8 value) {
|
||||
switch (stat) {
|
||||
case PkmnLib::Library::Statistic::HealthPoints: _evHp = value; break;
|
||||
case PkmnLib::Library::Statistic::PhysicalAttack: _evAttack = value; break;
|
||||
@@ -55,7 +55,7 @@ namespace PkmnLib::Battling {
|
||||
}
|
||||
auto identifier = this->_identifier;
|
||||
if (identifier == 0) {
|
||||
identifier = rand.Get();
|
||||
identifier = rand.GetUnsigned();
|
||||
}
|
||||
auto gender = this->_gender;
|
||||
if (gender == static_cast<CreatureLib::Library::Gender>(-1)) {
|
||||
@@ -80,10 +80,10 @@ namespace PkmnLib::Battling {
|
||||
attacks[i] = new LearnedMove(move.GetValue(), kv.LearnMethod);
|
||||
}
|
||||
}
|
||||
auto ivs = CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 31>(_ivHp, _ivAttack, _ivDefense, _ivSpAtt,
|
||||
_ivSpDef, _ivSpeed);
|
||||
auto evs = CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 252>(_evHp, _evAttack, _evDefense, _evSpAtt,
|
||||
_evSpDef, _evSpeed);
|
||||
auto ivs = CreatureLib::Library::ClampedStatisticSet<u8, 0, 31>(_ivHp, _ivAttack, _ivDefense, _ivSpAtt,
|
||||
_ivSpDef, _ivSpeed);
|
||||
auto evs = CreatureLib::Library::ClampedStatisticSet<u8, 0, 252>(_evHp, _evAttack, _evDefense, _evSpAtt,
|
||||
_evSpDef, _evSpeed);
|
||||
|
||||
if (_nature.IsEmpty()) {
|
||||
_nature = _library->GetNatureLibrary()->GetRandomNatureName(rand);
|
||||
@@ -106,8 +106,7 @@ namespace PkmnLib::Battling {
|
||||
_nature = nature;
|
||||
return *this;
|
||||
}
|
||||
CreatePokemon& CreatePokemon::WithIndividualValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt,
|
||||
uint8_t spDef, uint8_t speed) {
|
||||
CreatePokemon& CreatePokemon::WithIndividualValues(u8 hp, u8 att, u8 def, u8 spAtt, u8 spDef, u8 speed) {
|
||||
_ivHp = hp;
|
||||
_ivAttack = att;
|
||||
_ivDefense = def;
|
||||
@@ -116,8 +115,7 @@ namespace PkmnLib::Battling {
|
||||
_ivSpeed = speed;
|
||||
return *this;
|
||||
}
|
||||
CreatePokemon& CreatePokemon::WithEffortValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt, uint8_t spDef,
|
||||
uint8_t speed) {
|
||||
CreatePokemon& CreatePokemon::WithEffortValues(u8 hp, u8 att, u8 def, u8 spAtt, u8 spDef, u8 speed) {
|
||||
_evHp = hp;
|
||||
_evAttack = att;
|
||||
_evDefense = def;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace PkmnLib::Battling {
|
||||
ArbUt::StringView _nature;
|
||||
CreatureLib::Library::Gender _gender = static_cast<CreatureLib::Library::Gender>(-1);
|
||||
ArbUt::StringView _heldItem = ""_cnc;
|
||||
uint32_t _identifier = 0;
|
||||
u32 _identifier = 0;
|
||||
|
||||
struct ToLearnMethod {
|
||||
ArbUt::OptionalBorrowedPtr<const Library::MoveData> Move;
|
||||
@@ -25,28 +25,28 @@ namespace PkmnLib::Battling {
|
||||
: Move(move), LearnMethod(method){};
|
||||
};
|
||||
ArbUt::List<ToLearnMethod> _attacks;
|
||||
uint8_t _currentMove = 0;
|
||||
u8 _currentMove = 0;
|
||||
|
||||
uint8_t _ivHp = 0;
|
||||
uint8_t _ivAttack = 0;
|
||||
uint8_t _ivDefense = 0;
|
||||
uint8_t _ivSpAtt = 0;
|
||||
uint8_t _ivSpDef = 0;
|
||||
uint8_t _ivSpeed = 0;
|
||||
u8 _ivHp = 0;
|
||||
u8 _ivAttack = 0;
|
||||
u8 _ivDefense = 0;
|
||||
u8 _ivSpAtt = 0;
|
||||
u8 _ivSpDef = 0;
|
||||
u8 _ivSpeed = 0;
|
||||
|
||||
uint8_t _evHp = 0;
|
||||
uint8_t _evAttack = 0;
|
||||
uint8_t _evDefense = 0;
|
||||
uint8_t _evSpAtt = 0;
|
||||
uint8_t _evSpDef = 0;
|
||||
uint8_t _evSpeed = 0;
|
||||
u8 _evHp = 0;
|
||||
u8 _evAttack = 0;
|
||||
u8 _evDefense = 0;
|
||||
u8 _evSpAtt = 0;
|
||||
u8 _evSpDef = 0;
|
||||
u8 _evSpeed = 0;
|
||||
|
||||
bool _shininessSet = false;
|
||||
bool _isShiny = false;
|
||||
bool _allowedExperienceGain = true;
|
||||
|
||||
public:
|
||||
CreatePokemon(const BattleLibrary* library, const ArbUt::StringView& species, uint8_t level)
|
||||
CreatePokemon(const BattleLibrary* library, const ArbUt::StringView& species, u8 level)
|
||||
: _library(library), _species(species), _level(level),
|
||||
_attacks(library->GetSettings()->GetMaximalAttacks()) {}
|
||||
|
||||
@@ -56,13 +56,11 @@ namespace PkmnLib::Battling {
|
||||
CreatePokemon& WithHeldItem(const ArbUt::StringView& item);
|
||||
CreatePokemon& LearnMove(const ArbUt::StringView& move, CreatureLib::Battling::AttackLearnMethod method);
|
||||
|
||||
CreatePokemon& WithRandomIndividualValues(ArbUt::Random rand = ArbUt::Random());
|
||||
CreatePokemon& WithIndividualValue(CreatureLib::Library::Statistic stat, uint8_t value);
|
||||
CreatePokemon& WithIndividualValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt, uint8_t spDef,
|
||||
uint8_t speed);
|
||||
CreatePokemon& WithEffortValue(CreatureLib::Library::Statistic stat, uint8_t value);
|
||||
CreatePokemon& WithEffortValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt, uint8_t spDef,
|
||||
uint8_t speed);
|
||||
CreatePokemon& WithRandomIndividualValues(ArbUt::Random& rand);
|
||||
CreatePokemon& WithIndividualValue(CreatureLib::Library::Statistic stat, u8 value);
|
||||
CreatePokemon& WithIndividualValues(u8 hp, u8 att, u8 def, u8 spAtt, u8 spDef, u8 speed);
|
||||
CreatePokemon& WithEffortValue(CreatureLib::Library::Statistic stat, u8 value);
|
||||
CreatePokemon& WithEffortValues(u8 hp, u8 att, u8 def, u8 spAtt, u8 spDef, u8 speed);
|
||||
|
||||
CreatePokemon& WithNature(const ArbUt::StringView& nature);
|
||||
CreatePokemon& IsAllowedExperienceGain(bool value);
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
#include "LearnedMove.hpp"
|
||||
@@ -14,7 +14,7 @@ namespace PkmnLib::Battling {
|
||||
return GetAttack().ForceAs<const Library::MoveData>();
|
||||
}
|
||||
|
||||
LearnedAttack* Clone() const override {
|
||||
LearnedAttack* non_null Clone() const override {
|
||||
auto move = new LearnedMove(GetAttack().ForceAs<const Library::MoveData>(), GetLearnMethod());
|
||||
move->DecreaseUses(GetMaxUses() - GetRemainingUses());
|
||||
return move;
|
||||
|
||||
@@ -10,23 +10,23 @@
|
||||
namespace PkmnLib::Battling {
|
||||
class Pokemon : public CreatureLib::Battling::Creature {
|
||||
private:
|
||||
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 31> _individualValues;
|
||||
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 252> _effortValues;
|
||||
CreatureLib::Library::ClampedStatisticSet<u8, 0, 31> _individualValues;
|
||||
CreatureLib::Library::ClampedStatisticSet<u8, 0, 252> _effortValues;
|
||||
|
||||
ArbUt::BorrowedPtr<const PkmnLib::Library::Nature> _nature;
|
||||
uint8_t _friendship = 0;
|
||||
u8 _friendship = 0;
|
||||
bool _isEgg;
|
||||
|
||||
public:
|
||||
Pokemon(ArbUt::BorrowedPtr<const BattleLibrary> library,
|
||||
const ArbUt::BorrowedPtr<const Library::PokemonSpecies>& species,
|
||||
const ArbUt::BorrowedPtr<const Library::PokemonForme>& forme, level_int_t level, uint32_t experience,
|
||||
uint32_t uid, CreatureLib::Library::Gender gender, uint8_t coloring,
|
||||
const ArbUt::BorrowedPtr<const Library::PokemonForme>& forme, level_int_t level, u32 experience,
|
||||
u32 uid, CreatureLib::Library::Gender gender, u8 coloring,
|
||||
ArbUt::OptionalBorrowedPtr<const Library::Item> heldItem, const std::optional<std::string>& nickname,
|
||||
const CreatureLib::Library::TalentIndex& talent,
|
||||
const std::vector<CreatureLib::Battling::LearnedAttack*>& moves,
|
||||
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 31> individualValues,
|
||||
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 252> effortValues,
|
||||
CreatureLib::Library::ClampedStatisticSet<u8, 0, 31> individualValues,
|
||||
CreatureLib::Library::ClampedStatisticSet<u8, 0, 252> effortValues,
|
||||
ArbUt::BorrowedPtr<const PkmnLib::Library::Nature> nature, bool allowedExperienceGain = true,
|
||||
bool isEgg = false)
|
||||
: CreatureLib::Battling::Creature(
|
||||
@@ -48,16 +48,14 @@ namespace PkmnLib::Battling {
|
||||
}
|
||||
|
||||
inline const ArbUt::BorrowedPtr<const PkmnLib::Library::Nature>& GetNature() const noexcept { return _nature; }
|
||||
inline uint8_t GetIndividualValue(CreatureLib::Library::Statistic stat) const {
|
||||
inline u8 GetIndividualValue(CreatureLib::Library::Statistic stat) const {
|
||||
return _individualValues.GetStat(stat);
|
||||
}
|
||||
inline void SetIndividualValue(CreatureLib::Library::Statistic stat, uint8_t value) {
|
||||
inline void SetIndividualValue(CreatureLib::Library::Statistic stat, u8 value) {
|
||||
return _individualValues.SetStat(stat, value);
|
||||
}
|
||||
inline uint8_t GetEffortValue(CreatureLib::Library::Statistic stat) const {
|
||||
return _effortValues.GetStat(stat);
|
||||
}
|
||||
inline void SetEffortValue(CreatureLib::Library::Statistic stat, uint8_t value) {
|
||||
inline u8 GetEffortValue(CreatureLib::Library::Statistic stat) const { return _effortValues.GetStat(stat); }
|
||||
inline void SetEffortValue(CreatureLib::Library::Statistic stat, u8 value) {
|
||||
return _effortValues.SetStat(stat, value);
|
||||
}
|
||||
inline bool IsEgg() const noexcept { return _isEgg; }
|
||||
@@ -70,10 +68,10 @@ namespace PkmnLib::Battling {
|
||||
void Evolve(ArbUt::BorrowedPtr<const Library::PokemonSpecies> mon,
|
||||
ArbUt::BorrowedPtr<const Library::PokemonForme> forme);
|
||||
|
||||
uint8_t GetFriendship() const noexcept { return _friendship; }
|
||||
void SetFriendship(uint8_t value) noexcept { _friendship = value; }
|
||||
void ChangeFriendship(int8_t amount) noexcept {
|
||||
uint8_t newValue;
|
||||
u8 GetFriendship() const noexcept { return _friendship; }
|
||||
void SetFriendship(u8 value) noexcept { _friendship = value; }
|
||||
void ChangeFriendship(i8 amount) noexcept {
|
||||
u8 newValue;
|
||||
if (__builtin_add_overflow(_friendship, amount, &newValue)) {
|
||||
if (amount < 0)
|
||||
newValue = 0;
|
||||
@@ -85,7 +83,7 @@ namespace PkmnLib::Battling {
|
||||
|
||||
bool IsUsable() const noexcept override;
|
||||
|
||||
Creature* Clone() const override;
|
||||
Creature* non_null Clone() const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
namespace PkmnLib::Battling {
|
||||
class PokemonParty : public CreatureLib::Battling::CreatureParty {
|
||||
public:
|
||||
PokemonParty(ArbUt::List<CreatureLib::Battling::Creature*> party)
|
||||
PokemonParty(ArbUt::List<CreatureLib::Battling::Creature * nullable> party)
|
||||
: CreatureLib::Battling::CreatureParty(std::move(party)) {}
|
||||
PokemonParty(std::initializer_list<CreatureLib::Battling::Creature*> party)
|
||||
PokemonParty(std::initializer_list<CreatureLib::Battling::Creature* nullable> party)
|
||||
: CreatureLib::Battling::CreatureParty(party) {}
|
||||
PokemonParty(size_t size) : CreatureLib::Battling::CreatureParty(size) {}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace PkmnLib::Battling {
|
||||
return CreatureLib::Battling::CreatureParty::GetAtIndex(index).As<Pokemon>();
|
||||
}
|
||||
|
||||
CreatureParty* Clone() const override {
|
||||
CreatureParty* non_null Clone() const override {
|
||||
auto party = new PokemonParty(GetParty().Count());
|
||||
auto i = 0;
|
||||
for (auto c : GetParty()) {
|
||||
|
||||
Reference in New Issue
Block a user