blob: a8a30c8cd74305441ef00ed120e6d1fbdf220ef7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "toBeSorted/counters/counter.h"
#include "d/flag/itemflag_manager.h"
/* 8016cc40 */ s32 Counter::checkedAdd(s32 num) {
s32 uncommitted = getUncommittedValue();
s32 max = getMax();
s32 result = uncommitted + num;
if (result < 0) {
setValue(0);
} else if (result < max) {
setValue(result);
} else {
setValue(max);
}
if (result < 0) {
return result;
}
return result <= max ? 0 : (result - max);
}
/* 8016cd30 */ u16 Counter::getCommittedValue() const {
return ItemflagManager::sInstance->getCounterOrFlag(counterId | 0x4000);
}
/* 8016cd50 */ u16 Counter::getUncommittedValue() const {
return ItemflagManager::sInstance->getUncommittedValue(counterId | 0x4000);
}
/* 8016cd70 */ void Counter::setValue(u16 num) {
ItemflagManager::sInstance->setFlagOrCounterToValue(counterId | 0x4000, num);
}
|