diff --git a/src/canvas.cpp b/src/canvas.cpp index 8384c50..7d5d84a 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -253,21 +253,21 @@ namespace game glBindRenderbuffer(GL_RENDERBUFFER, rbo); } - void Canvas::size_set(ivec2 size) + void Canvas::size_set(ivec2 newSize) { - if ((flags & DEFAULT) == 0 && (size.x != this->size.x || size.y != this->size.y)) + if ((flags & DEFAULT) == 0 && (newSize.x != this->size.x || newSize.y != this->size.y)) { glBindTexture(GL_TEXTURE_2D, texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.x, size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, newSize.x, newSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); glBindTexture(GL_TEXTURE_2D, 0); glBindRenderbuffer(GL_RENDERBUFFER, rbo); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, size.x, size.y); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, newSize.x, newSize.y); glBindRenderbuffer(GL_RENDERBUFFER, 0); } - this->size = size; - glViewport(0, 0, size.x, size.y); + this->size = newSize; + glViewport(0, 0, newSize.x, newSize.y); } void Canvas::clear(vec4 color) diff --git a/src/entity/actor.cpp b/src/entity/actor.cpp index b7b00e6..4938842 100644 --- a/src/entity/actor.cpp +++ b/src/entity/actor.cpp @@ -31,14 +31,15 @@ namespace game::entity Actor& Actor::operator=(const Actor&) = default; Actor& Actor::operator=(Actor&&) noexcept = default; - Actor::Actor(Anm2 _anm2, vec2 _position, Mode mode, float time, int animationIndex) : Anm2(_anm2), position(_position) + Actor::Actor(Anm2 _anm2, vec2 _position, Mode playMode, float startAtTime, int startAnimationIndex) + : Anm2(_anm2), position(_position) { - this->mode = mode; - this->startTime = time; - if (animationIndex != -1) - play(animationIndex, mode, time); + this->mode = playMode; + this->startTime = startAtTime; + if (startAnimationIndex != -1) + play(startAnimationIndex, playMode, startAtTime); else - play_default_animation(mode, time); + play_default_animation(playMode, startAtTime); } Anm2::Animation* Actor::animation_get(int index) @@ -68,10 +69,10 @@ namespace game::entity return -1; } - Anm2::Item* Actor::item_get(Anm2::Type type, int id, int animationIndex) + Anm2::Item* Actor::item_get(Anm2::Type type, int id, int checkAnimationIndex) { - if (animationIndex == -1) animationIndex = this->animationIndex; - if (auto animation = animation_get(animationIndex)) + if (checkAnimationIndex == -1) checkAnimationIndex = this->animationIndex; + if (auto animation = animation_get(checkAnimationIndex)) { switch (type) { @@ -103,14 +104,14 @@ namespace game::entity return duration; } - Anm2::Frame Actor::frame_generate(Anm2::Item& item, float time, Anm2::Type type, int id) + Anm2::Frame Actor::frame_generate(Anm2::Item& item, float frameTime, Anm2::Type type, int id) { Anm2::Frame frame{}; frame.isVisible = false; if (item.frames.empty()) return frame; - time = time < 0.0f ? 0.0f : time; + frameTime = frameTime < 0.0f ? 0.0f : frameTime; Anm2::Frame* frameNext = nullptr; Anm2::Frame frameNextCopy{}; @@ -125,7 +126,7 @@ namespace game::entity durationNext += frame.duration; - if (time >= durationCurrent && time < durationNext) + if (frameTime >= durationCurrent && frameTime < durationNext) { if (i + 1 < (int)item.frames.size()) { @@ -177,7 +178,7 @@ namespace game::entity if (frame.isInterpolated && frameNext && frame.duration > 1) { - auto interpolation = (time - durationCurrent) / (durationNext - durationCurrent); + auto interpolation = (frameTime - durationCurrent) / (durationNext - durationCurrent); frame.rotation = glm::mix(frame.rotation, frameNextCopy.rotation, interpolation); frame.position = glm::mix(frame.position, frameNextCopy.position, interpolation); @@ -189,34 +190,34 @@ namespace game::entity return frame; } - void Actor::play(int index, Mode mode, float time, float speedMultiplier) + void Actor::play(int index, Mode playMode, float startAtTime, float speedMultiplierValue) { if (!vector::in_bounds(animations, index)) return; - if (mode != PLAY_FORCE && index == animationIndex) return; + if (playMode != PLAY_FORCE && index == animationIndex) return; this->playedEventID = -1; this->playedTriggers.clear(); - this->speedMultiplier = speedMultiplier; + this->speedMultiplier = speedMultiplierValue; this->animationIndex = index; - this->time = time; - if (mode == PLAY) state = PLAYING; + this->time = startAtTime; + if (playMode == PLAY) state = PLAYING; } void Actor::queue_play(QueuedPlay newQueuedPlay) { queuedPlay = newQueuedPlay; } void Actor::queue_default_animation() { queue_play({defaultAnimation}); } - void Actor::play(const std::string& name, Mode mode, float time, float speedMultiplier) + void Actor::play(const std::string& name, Mode playMode, float startAtTime, float speedMultiplierValue) { if (animationMap.contains(name)) - play(animationMap.at(name), mode, time, speedMultiplier); + play(animationMap.at(name), playMode, startAtTime, speedMultiplierValue); else logger.error(std::string("Animation \"" + name + "\" does not exist! Unable to play!")); } - void Actor::play_default_animation(Mode mode, float time, float speedMultiplier) + void Actor::play_default_animation(Mode playMode, float startAtTime, float speedMultiplierValue) { - play(defaultAnimationID, mode, time, speedMultiplier); + play(defaultAnimationID, playMode, startAtTime, speedMultiplierValue); } void Actor::tick() @@ -256,7 +257,7 @@ namespace game::entity { if (!playedTriggers.contains(trigger.atFrame) && time >= trigger.atFrame) { - auto id = trigger.soundIDs[(int)math::random_max(trigger.soundIDs.size())]; + auto id = trigger.soundIDs[(int)math::random_max((float)trigger.soundIDs.size())]; if (auto sound = map::find(sounds, id)) sound->audio.play(); playedTriggers.insert((int)trigger.atFrame); playedEventID = trigger.eventID; @@ -276,7 +277,7 @@ namespace game::entity playedTriggers.clear(); } - for (int i = 0; i < (int)overrides.size(); i++) + for (int i = 0; i < (int)overrides.size();) { auto& override_ = overrides[i]; @@ -285,8 +286,13 @@ namespace game::entity if (override_.time.has_value()) { *override_.time -= 1.0f; - if (*override_.time <= 0.0f) overrides.erase(overrides.begin() + i++); + if (*override_.time <= 0.0f) + { + overrides.erase(overrides.begin() + i); + continue; + } } + i++; } } diff --git a/src/entity/character.cpp b/src/entity/character.cpp index ee419eb..5bc7af6 100644 --- a/src/entity/character.cpp +++ b/src/entity/character.cpp @@ -77,7 +77,7 @@ namespace game::entity float Character::weight_get(measurement::System system) { - return system == measurement::IMPERIAL ? weight * measurement::KG_TO_LB : weight; + return system == measurement::IMPERIAL ? weight * (float)measurement::KG_TO_LB : weight; } int Character::stage_from_weight_get(float checkWeight) const @@ -93,25 +93,25 @@ namespace game::entity int Character::stage_get() const { return stage_from_weight_get(weight); } - int Character::stage_max_get() const { return data.stages.size(); } + int Character::stage_max_get() const { return (int)data.stages.size(); } - float Character::stage_threshold_get(int stage, measurement::System system) const + float Character::stage_threshold_get(int stageIndex, measurement::System system) const { - if (stage == -1) stage = this->stage; + if (stageIndex == -1) stageIndex = this->stage; float threshold = data.weight; if (!data.stages.empty()) { - if (stage <= 0) + if (stageIndex <= 0) threshold = data.weight; - else if (stage >= stage_max_get()) + else if (stageIndex >= stage_max_get()) threshold = data.stages.back().threshold; else - threshold = data.stages[stage - 1].threshold; + threshold = data.stages[stageIndex - 1].threshold; } - return system == measurement::IMPERIAL ? threshold * measurement::KG_TO_LB : threshold; + return system == measurement::IMPERIAL ? threshold * (float)measurement::KG_TO_LB : threshold; } float Character::stage_threshold_next_get(measurement::System system) const @@ -139,9 +139,9 @@ namespace game::entity float Character::capacity_percent_get() const { return calories / max_capacity(); } std::string Character::animation_name_convert(const std::string& name) { return std::format("{}{}", name, stage); } - void Character::play_convert(const std::string& animation, Mode mode, float time, float speedMultiplier) + void Character::play_convert(const std::string& animation, Mode playMode, float startAtTime, float speedMultiplierValue) { - play(animation_name_convert(animation), mode, time, speedMultiplier); + play(animation_name_convert(animation), playMode, startAtTime, speedMultiplierValue); } void Character::expand_areas_apply() diff --git a/src/resource/xml/character.hpp b/src/resource/xml/character.hpp index 3d10558..1714aef 100644 --- a/src/resource/xml/character.hpp +++ b/src/resource/xml/character.hpp @@ -88,7 +88,7 @@ namespace game::resource::xml Texture texture{}; Audio sound{}; int id{-1}; - float chanceOnNewGame{0.001}; + float chanceOnNewGame{0.001f}; }; Anm2 anm2{}; diff --git a/src/resource/xml/play.hpp b/src/resource/xml/play.hpp index a8e3923..537e229 100644 --- a/src/resource/xml/play.hpp +++ b/src/resource/xml/play.hpp @@ -34,14 +34,14 @@ namespace game::resource::xml Sounds sounds{}; std::vector grades{}; - float rewardScoreBonus{0.01}; - float rewardGradeBonus{0.05}; - float speedMin{0.005}; - float speedMax{0.075}; + float rewardScoreBonus{0.01f}; + float rewardGradeBonus{0.05f}; + float speedMin{0.005f}; + float speedMax{0.075f}; float speedScoreBonus{0.000025f}; - float rangeBase{0.75}; - float rangeMin{0.10}; - float rangeScoreBonus{0.0005}; + float rangeBase{0.75f}; + float rangeMin{0.10f}; + float rangeScoreBonus{0.0005f}; int endTimerMax{20}; int endTimerFailureMax{60}; int rewardScore{999}; diff --git a/src/util/imgui.hpp b/src/util/imgui.hpp index 62aa90d..3eacfbb 100644 --- a/src/util/imgui.hpp +++ b/src/util/imgui.hpp @@ -16,7 +16,7 @@ namespace game::util::imgui ImVec2 size_without_footer_get(int = 1); inline ImVec2 to_imvec2(vec2 value) { return ImVec2(value.x, value.y); } - inline ImVec2 to_imvec2(ivec2 value) { return ImVec2(value.x, value.y); } + inline ImVec2 to_imvec2(ivec2 value) { return ImVec2((float)value.x, (float)value.y); } inline vec2 to_vec2(ImVec2 value) { return vec2(value.x, value.y); } inline ivec2 to_ivec2(ImVec2 value) { return ivec2(value.x, value.y); } diff --git a/src/util/math.hpp b/src/util/math.hpp index 8711e0f..c6a057b 100644 --- a/src/util/math.hpp +++ b/src/util/math.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "glm/ext/matrix_float4x4.hpp" #include "glm/ext/vector_float2.hpp"