I face an important bug.

Posted by Oblisgr on Sun 19 Jul 2020 08:07 PM — 4 posts, 16,947 views.

#0
Hi i just ask if someone have noticed a bug like this.
When i save my game the attributes and the ac of my player are rising. Each time i save they all go up.

I replaced my save.c with a fresh one and nothing changed so for sure it is not from there.

Anyone has face a bug like thing from his coding experience?

I m trying to find what causes the problem and fix it but i can figure ouy what other files are interract with this kind of stuff.

If anyone knows...
I will be grateful
Australia Forum Administrator #1
Do you mean, when you type "save" your HP etc. immediately go up in game? Without reloading? Or do you mean, they are higher next time when you load the game, compared to when you saved it?

What you could do is type "save" and then edit your player file and see if the correct numbers were saved, eg.


#PLAYER
Version      5
Name         Admin~
Sex          1
Class        5
Race         1
Age          0 23 9 605
Languages    -1 1
Level        65
Played       31580733
Room         21004
HpManaMove   24 24 145 145 110 110    <----- HERE


If the numbers in the save file are wrong, you have a problem in your saving.

However if they are correct, but higher when next loaded, you have a problem in your loading code.
#2
The numbers in pfile are changing too.
Everytime i do save the numbers there change too.

I replaced my save.c file with a clean one and did that just to check if i have the bug, and ideed i had so if i m right and save.c is the file that handles the saving, then it has no problem.

I dont thing it is a loading problem since the mud reads the wrong values that the pfile has.

The thing is that every time it stacks the new values to the old one. For example if Str is 10, after save it will be 11 (+1), then i save again and it gets 11 from pfile and adds +1 so 12 and goes on.

I also tried to grep for the AttrMod just to check if something else might be occured somewhere else but i havent touched anything there.
#3
I think i found why the ac is messed up.
I have 3 armor skills in my mud, light, medium and heavy.
I wanted to make them give extra ac by skill level so i replaced in handler.c under apply_ac function the following code with the next one but it causes problems.
Do you see how i cant be fixed maybe?

      case WEAR_BODY:
         return obj->value[0];


     case WEAR_BODY:

        if( obj->value[5] == 1 )
          {
          if(LEARNED(ch, gsn_lightarmor) > 0)
            {
          armortype = ((obj->value[0] * 10) + LEARNED(ch, gsn_lightarmor))/10;
            }
          }

        if( obj->value[5] == 2 )
          {
          if(LEARNED(ch, gsn_mediumarmor) > 0)
            {
          armortype = ((obj->value[0] * 10) + LEARNED(ch, gsn_mediumarmor))/10;
            }
          }

        if( obj->value[5] == 3 )
          {
          if(LEARNED(ch, gsn_heavyarmor) > 0)
            {
          armortype = ((obj->value[0] * 10) + LEARNED(ch, gsn_heavyarmor))/10;
            }
          }

      return armortype;