Ring of Perma Accuracy?

Think you've found a bug? Please report it here.
Thorbear
Two-Headed Troll
Posts: 131
Joined: Wed 12.01.2005, 15:00
Contact:

Ring of Perma Accuracy?

Post by Thorbear » Sun 31.05.2009, 23:13

Image

My priest came across this funny thing today.
When I used "Detection" I noticed a white '&' in the top left corner, so I dug there, and it turned into a brown '=' which was a Ring of Accuracy.
I cannot walk there, neither can I dig there, and the ring seems indestructable.
I am Thorbear...

User avatar
Warrior
Evil Iggy
Posts: 667
Joined: Sat 26.10.2002, 15:00
Location: Norway
Contact:

Re: Ring of Perma Accuracy?

Post by Warrior » Mon 01.06.2009, 12:14

This is not the first time this has happened but we're looking into it. Thanks for reporting it :)
-- Mangband Project Team Member

Ashi
Giant Mottled Ant Lion
Posts: 218
Joined: Sun 10.11.2002, 19:58

Re: Ring of Perma Accuracy?

Post by Ashi » Mon 01.06.2009, 20:28

I saw something similar once when I recalled down to rescue someone who died. I used enlightenment and discovered a mysterious ? in the corner.

Image

PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Re: Ring of Perma Accuracy?

Post by PowerWyrm » Tue 02.06.2009, 12:09

I had something similar in the bug list for my variant (the look command when used manually was acting as if something was at position 0,0), but I couldn't find the cause of it. Now I know it's in the regular MAng code source :)

PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Re: Ring of Perma Accuracy?

Post by PowerWyrm » Tue 02.06.2009, 14:16

Sounds like a bug in the "in_bounds" macros. In particular, the "in_bounds2" macro makes no sense to me... why exclude the left and top walls in the town and not in the dungeon? why not the right and bottom ones? The macro in the vanilla code makes more sense.

PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Re: Ring of Perma Accuracy?

Post by PowerWyrm » Sat 06.06.2009, 17:57

Forget about my last post. There's a *CRITICAL* bug in the current source code related to monster inventories. That code was taken from vanilla Angband, IN WHICH THE BUG STILL EXISTS!!! Expect not only objects created at (0,0)... but also server crashes and endless loops.
In the code, the delete_monster_idx() method sets o_ptr->held_m_idx = 0 (this part is commented with /* Hack -- efficiency */) before calling delete_object_idx(). However, the delete_object_idx() will also check o_ptr->held_m_idx to see if the object is part of a monster inventory, or a dungeon object. In this case, all objects in the monster inventory will be treated as dungeon objects... and since those objects don't have a dungeon location anymore, a lot of stuff will happen at (0,0).

Ashi
Giant Mottled Ant Lion
Posts: 218
Joined: Sun 10.11.2002, 19:58

Re: Ring of Perma Accuracy?

Post by Ashi » Sat 06.06.2009, 18:57

Whoa, nice find! But what about players?

Image

PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Re: Ring of Perma Accuracy?

Post by PowerWyrm » Sat 06.06.2009, 20:51

Whenever a monster that picked up an object drops it, some copy is created at (0,0) and then erased. Leftovers in cave_ptr may remain at (0,0)...

User avatar
Flambard
King Vampire
Posts: 258
Joined: Wed 20.06.2007, 10:49

Re: Ring of Perma Accuracy?

Post by Flambard » Sat 06.06.2009, 20:52

*Superb* find PW !

Ashi, your screenshot is scary :)

PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Re: Ring of Perma Accuracy?

Post by PowerWyrm » Sun 07.06.2009, 21:14

From monster.txt:

##### Non-race (contains the "player" picture) #####

N:0:<player>
G:@:w

That's what happens in the screenshot...
So to be sure where the problem is, simply search for "monster_type *m_ptr = &m_list[m_idx];" in the source code where m_idx = 0. Shouldn't be hard to find...

PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Re: Ring of Perma Accuracy?

Post by PowerWyrm » Mon 08.06.2009, 15:28

Ok I found the reason of all that bullshit... Everywhere in the code, when browsing the list of objects/monsters (o_list/m_list), bounds used are 1 to o_max/m_max... except in 2 places (loading and saving objects/monsters in the server savefile) where the bounds used are 0 to o_max/m_max. Basically, the game saves and loads a "fake" monster and a "fake" object at position 0 in the list... and then use them in many places.

Fix:
1) change lower bound from 0 to 1 in rd_server_savefile() and wr_server_savefile
2) edit server savefile: find section <monsters>, remove first entry (a <player>); find section <objects>, remove first entry (<nothing>)

User avatar
Flambard
King Vampire
Posts: 258
Joined: Wed 20.06.2007, 10:49

Re: Ring of Perma Accuracy?

Post by Flambard » Mon 08.06.2009, 15:32

Sounds good !

I'm curious tho, how would the game use them if everywhere else the loop goes from 1 ?

PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Re: Ring of Perma Accuracy?

Post by PowerWyrm » Mon 08.06.2009, 17:50

Well I checked the whole code and I found other occurences of the loop starting at 0. Need to check every occurence of m_list, o_list, m_max and o_max to be sure all loops start at 1. Object/monster #0 should never be used.

PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Re: Ring of Perma Accuracy?

Post by PowerWyrm » Tue 09.06.2009, 07:33

The main cause of the problem comes from the loops in setup_objects() and setup_monsters() which attach objects/monsters to the cave array. setup_objects() does a check on o_ptr->k_idx and should in theory reject "fake" objects. setup_monsters() does NOT make the check on m_ptr->r_idx... so a "fake" monster 0 is automatically placed at (0,0) in the town. To avoid placing "dead" monsters, setup_monsters() should be rewritten in the same way as setup_objects().

Ardor
Giant Gnat
Posts: 38
Joined: Sat 15.08.2009, 18:13

Re: Ring of Perma Accuracy?

Post by Ardor » Sun 07.11.2010, 10:31

I remember digging to a sword of some kind in that spot, only to find to my disappointment that it was surrounded by perma-rock. So sad.

Post Reply