summaryrefslogtreecommitdiff
path: root/src/SSystem/SComponent/c_lib.cpp
diff options
context:
space:
mode:
authorTakaRikka <38417346+TakaRikka@users.noreply.github.com>2025-03-01 04:48:49 -0800
committerGitHub <noreply@github.com>2025-03-01 14:48:49 +0200
commit19e18654c9866a5aa5c181c0432157995596cbcb (patch)
tree0ebbd4697e3189bad69383cfe536db7fab93c775 /src/SSystem/SComponent/c_lib.cpp
parent9c3c07575a47d64fa70561d6a2cfd166aee94ccd (diff)
tag_allmato almost, swhit0 treesh swball done, misc cleanup (#2312)
* d_a_tag_allmato almost done * d_a_swhit0 done * some SSystem cleanup * treesh done * swball done, some other rel cleanup
Diffstat (limited to 'src/SSystem/SComponent/c_lib.cpp')
-rw-r--r--src/SSystem/SComponent/c_lib.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/SSystem/SComponent/c_lib.cpp b/src/SSystem/SComponent/c_lib.cpp
index 62c86b920b..16fd52e15d 100644
--- a/src/SSystem/SComponent/c_lib.cpp
+++ b/src/SSystem/SComponent/c_lib.cpp
@@ -41,8 +41,9 @@ void cLib_memSet(void* ptr, int value, unsigned long num) {
* @return The absolute value of remaining distance to target
*/
f32 cLib_addCalc(f32* pvalue, f32 target, f32 scale, f32 maxStep, f32 minStep) {
+ f32 step = 0.0f;
if (*pvalue != target) {
- f32 step = scale * (target - *pvalue);
+ step = scale * (target - *pvalue);
if (step >= minStep || step <= -minStep) {
if (step > maxStep) {
step = maxStep;
@@ -54,15 +55,16 @@ f32 cLib_addCalc(f32* pvalue, f32 target, f32 scale, f32 maxStep, f32 minStep) {
} else {
if (step > 0) {
if (step < minStep) {
- *pvalue += minStep;
+ step = minStep;
+ *pvalue += step;
if (*pvalue > target) {
*pvalue = target;
}
}
} else {
- minStep = -minStep;
- if (step > minStep) {
- *pvalue += minStep;
+ if (step > -minStep) {
+ step = -minStep;
+ *pvalue += step;
if (*pvalue < target) {
*pvalue = target;
}