shield not known?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agoodman
    Adept
    • Jan 2011
    • 114

    shield not known?

    The borg is using this shield that should be +4 but obj->known->to_a is 0. The result is he keeps trying to ID the shield (it is on the list of being able to be IDd) but there is nothing new (rune wise) to learn. He could drop the shield and it would show as +4 on the ground but I have no clue how it ended up in his inventory without the + to AC being known and if I need to teach the borg something new to do around this. Trying to sell it before dropping it causes an infinite loop.

    Attached save.

    Since this was a borg, if you tell me this is impossible for the base game to do, I will assume there is a memory overrun somewhere in the borg code (though I thought my debugger was set up to catch that) and search for that.
    Attached Files
  • backwardsEric
    Knight
    • Aug 2019
    • 531

    #2
    Since player->obj_k->to_a is one (as expected), I do not see any path in the base game's code that would cause obj->to_a to differ from obj->known->to_a. So I would not try to get the borg to work around that situation. Besides a memory overrun (either in the base game or the borg code), a use after free could also be the cause.

    We may want to modify store.c so the infinite loop does not happen and, instead, obj->known is made consistent with obj when object_learn_unknown_rune() did not find anything to learn.

    Comment

    • agoodman
      Adept
      • Jan 2011
      • 114

      #3
      and/or modify ID so that if it gets through and hasn't changed anything, it makes sure all the values match up that should. I think both places use the same underlying code so doing one might handle both.

      Comment

      • agoodman
        Adept
        • Jan 2011
        • 114

        #4
        I was thinking
        Code:
        /**
        * Learn a random unknown rune from an object
        *
        * \param p is the player
        * \param obj is the object
        */
        void object_learn_unknown_rune(struct player *p, struct object *obj)
        {
        /* Get a random unknown rune from the object */
        int i = object_find_unknown_rune(p, obj);
        
        /* No unknown runes */
        if (i < 0) {
            obj->known->notice |= OBJ_NOTICE_ASSESSED;
            player_know_object(player, obj);
            return;
        }
        
        /* Learn the rune */
        player_learn_rune(p, i, true);
        }
        as a way of saying "if you are learning a rune and you learned them all, you now have assessed that object" but I wasn't sure if that was what you guys would want.

        Comment

        Working...
        😀
        😂
        🥰
        😘
        🤢
        😎
        😞
        😡
        👍
        👎