From e4b8bf807b76f6f446d9617d9a3957dc77dd6e90 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Mon, 21 Jul 2025 19:23:42 -0300 Subject: 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. --- src/crskill.cc | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/crskill.cc') 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; } } -- cgit v1.2.3