Skip to content

Commit

Permalink
review mehah: use std::vector
Browse files Browse the repository at this point in the history
  • Loading branch information
kokekanon committed Jan 9, 2025
1 parent f4ffffe commit 62f2531
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/creatures/appearance/attachedeffects/attachedeffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ bool Attachedeffects::loadFromXml() {
}

for (auto auraNode : doc.child("attachedeffects").children("aura")) {
auras.emplace(std::make_shared<Aura>(
auras.push_back(std::make_shared<Aura>(
pugi::cast<uint16_t>(auraNode.attribute("id").value()),
auraNode.attribute("name").as_string()
));
}

for (auto shaderNode : doc.child("attachedeffects").children("shader")) {
shaders.emplace(std::make_shared<Shader>(
shaders.push_back(std::make_shared<Shader>(
pugi::cast<uint16_t>(shaderNode.attribute("id").value()),
shaderNode.attribute("name").as_string()
));
}

for (auto effectNode : doc.child("attachedeffects").children("effect")) {
effects.emplace(std::make_shared<Effect>(
effects.push_back(std::make_shared<Effect>(
pugi::cast<uint16_t>(effectNode.attribute("id").value()),
effectNode.attribute("name").as_string()
));
}

for (auto wingNode : doc.child("attachedeffects").children("wing")) {
wings.emplace(std::make_shared<Wing>(
wings.push_back(std::make_shared<Wing>(
pugi::cast<uint16_t>(wingNode.attribute("id").value()),
wingNode.attribute("name").as_string()
));
Expand Down
22 changes: 11 additions & 11 deletions src/creatures/appearance/attachedeffects/attachedeffects.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
struct Aura {
Aura(uint16_t initId, const std::string &name) :
id(initId), name(name) { }
uint8_t id;
uint16_t id;
std::string name;
};

Expand All @@ -26,14 +26,14 @@ struct Shader {
struct Effect {
Effect(uint16_t initId, const std::string &name) :
id(initId), name(name) { }
uint8_t id;
uint16_t id;
std::string name;
};

struct Wing {
Wing(uint16_t initId, const std::string &name) :
id(initId), name(name) { }
uint8_t id;
uint16_t id;
std::string name;
};

Expand All @@ -52,22 +52,22 @@ class Attachedeffects {
std::shared_ptr<Effect> getEffectByName(const std::string &name);
std::shared_ptr<Wing> getWingByName(const std::string &name);

[[nodiscard]] const phmap::parallel_flat_hash_set<std::shared_ptr<Aura>> &getAuras() const {
[[nodiscard]] const std::vector<std::shared_ptr<Aura>> &getAuras() const {
return auras;
}
[[nodiscard]] const phmap::parallel_flat_hash_set<std::shared_ptr<Shader>> &getShaders() const {
[[nodiscard]] const std::vector<std::shared_ptr<Shader>> &getShaders() const {
return shaders;
}
[[nodiscard]] const phmap::parallel_flat_hash_set<std::shared_ptr<Effect>> &getEffects() const {
[[nodiscard]] const std::vector<std::shared_ptr<Effect>> &getEffects() const {
return effects;
}
[[nodiscard]] const phmap::parallel_flat_hash_set<std::shared_ptr<Wing>> &getWings() const {
[[nodiscard]] const std::vector<std::shared_ptr<Wing>> &getWings() const {
return wings;
}

private:
phmap::parallel_flat_hash_set<std::shared_ptr<Aura>> auras;
phmap::parallel_flat_hash_set<std::shared_ptr<Shader>> shaders;
phmap::parallel_flat_hash_set<std::shared_ptr<Effect>> effects;
phmap::parallel_flat_hash_set<std::shared_ptr<Wing>> wings;
std::vector<std::shared_ptr<Aura>> auras;
std::vector<std::shared_ptr<Shader>> shaders;
std::vector<std::shared_ptr<Effect>> effects;
std::vector<std::shared_ptr<Wing>> wings;
};

0 comments on commit 62f2531

Please sign in to comment.