aboutsummaryrefslogtreecommitdiff
path: root/src/crskill.cc
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-07-21 19:23:42 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-07-21 22:49:41 -0300
commite4b8bf807b76f6f446d9617d9a3957dc77dd6e90 (patch)
treef974c51ca7ea111c7e96990e39453ae5dba9a6c5 /src/crskill.cc
parent7b9e7dbbcf1d779419be8f22df812ff523a25450 (diff)
downloadgame-e4b8bf807b76f6f446d9617d9a3957dc77dd6e90.tar.gz
game-e4b8bf807b76f6f446d9617d9a3957dc77dd6e90.zip
multiple bug-fixes and improvements
- Make uint32 -> Object conversion explicit. This can be more verbose but will get a lot of small mistakes, especially with function overloads. - Fix problem with the path finder not including the last step when `MustReach` was false. - Fix problem with NPC conditions. - Fix problem with monster homes continuously spawning monsters. - Fix problem with creating the standard inventory. - Fix problem with creature timers (IMPORTANT). - Fix problem with `ThrowPossible` (IMPORTANT). - Fix problem with rune casting. - Fix problem with executing moveuse events. - Fix problem with `MoveRel` and `WriteName` moveuse actions. - Fix problem with eating food deleting the whole stack. - Many other bug-fixes and improvements.
Diffstat (limited to 'src/crskill.cc')
-rw-r--r--src/crskill.cc28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/crskill.cc b/src/crskill.cc
index e12e9c6..092e701 100644
--- a/src/crskill.cc
+++ b/src/crskill.cc
@@ -1201,20 +1201,18 @@ bool TSkillBase::SetSkills(int Race){
void TSkillBase::ProcessSkills(void){
int Index = 0;
- int End = this->FirstFreeTimer;
- while(Index < End){
+ while(Index < this->FirstFreeTimer){
// TODO(fusion): Probably remove if `Skill == NULL`?
TSkill *Skill = this->TimerList[Index];
- if(Skill && !Skill->Process()){
+ if(Skill != NULL && Skill->Process()){
// NOTE(fusion): A little swap and pop action.
- End -= 1;
- this->TimerList[Index] = this->TimerList[End];
- this->TimerList[End] = NULL;
+ this->FirstFreeTimer -= 1;
+ this->TimerList[Index] = this->TimerList[this->FirstFreeTimer];
+ this->TimerList[this->FirstFreeTimer] = NULL;
}else{
Index += 1;
}
}
- this->FirstFreeTimer = (uint16)End;
}
bool TSkillBase::SetTimer(uint16 SkNr, int Cycle, int Count, int MaxCount, int AdditionalValue){
@@ -1229,9 +1227,10 @@ bool TSkillBase::SetTimer(uint16 SkNr, int Cycle, int Count, int MaxCount, int A
TSkill *Skill = this->Skills[SkNr];
bool Result = Skill->SetTimer(Cycle, Count, MaxCount, AdditionalValue);
if(Result){
- // NOTE(fusion): A little push back action.
- // BUG(fusion): We don't check if there is room in `TimerList`. I'd assume
- // it is naturally bound by the maximum number of skills?
+ // NOTE(fusion): A little push back action. We don't check if there is
+ // room in `TimerList` because it should be naturally bound by the max
+ // number of skills.
+ ASSERT(this->FirstFreeTimer < NARRAY(this->TimerList));
this->TimerList[this->FirstFreeTimer] = Skill;
this->FirstFreeTimer += 1;
}
@@ -1249,13 +1248,12 @@ void TSkillBase::DelTimer(uint16 SkNr){
if(Skill != NULL){
Skill->DelTimer();
- int End = this->FirstFreeTimer;
- for(int Index = 0; Index < End; Index += 1){
+ for(int Index = 0; Index < this->FirstFreeTimer; Index += 1){
if(Skill == this->TimerList[Index]){
// NOTE(fusion): A little swap and pop action.
- End -= 1;
- this->TimerList[Index] = this->TimerList[End];
- this->TimerList[End] = NULL;
+ this->FirstFreeTimer -= 1;
+ this->TimerList[Index] = this->TimerList[this->FirstFreeTimer];
+ this->TimerList[this->FirstFreeTimer] = NULL;
break;
}
}