mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3
525 words
3 minutes
CH1.27 Example: a bug in Angband
2026-04-24

1.27 Example: a bug in Angband


The author mentioned that there was a bug in an old rogue-like game from the nineties that had a fascinating bug carrying the spirit of "Roadside Picnic" by the Strugatsky brothers or the TV series "The Lost Room":

The frog-knows version was full of bugs. The funniest one allowed a devilish cheating technique in the game, which players called "mushroom farming". If there were more than a certain number (around five hundred) of objects in the dungeon, the game would corrupt, and many old things would turn into objects thrown on the floor. So the player would enter the dungeon, dig long corridors (with a special spell), and walk through those corridors creating mushrooms using another spell. When there were enough mushrooms, the player would drop and pick up, drop and pick up any useful item, and the mushrooms one by one would turn into that item. The player would then exit with hundreds of copies of the useful item.


How the bug works

In short, the game used fixed-size global arrays to store all the objects (weapons, armor, mushrooms, treasures...) present on the floor of the level. The game counted the number of items on the floor, and when that count exceeded a certain limit (around 256 items) the bug would trigger.

The game used a fixed-size array (such as t_list[MAX_TALLOC] or sorted_objects[MAX_DUNGEON_OBJ]).

The MAX_DUNGEON_OBJ was 423, but when the number of items on the floor exceeded 256 (not 423!), the index would wrap around or cause a memory overflow. The result was that every old thing (artifacts, weapons, etc.) would turn into "objects thrown to the floor". Players discovered they could exploit this by doing "mushroom farming" creating hundreds of mushrooms with a spell, then dropping and picking up a useful item, and the mushrooms would turn into that item one by one. They would exit with hundreds of copies.

Here is the code the author found in the source (version 2.4 fk):

#define MAX_DUNGEON_OBJ 423 // maximum number of objects allowed on dungeon floor
int16 sorted_objects[MAX_DUNGEON_OBJ]; // array of sorted object indices (fixed size = 423)
int8u object_ident[OBJECT_IDENT_SIZE]; // object identification flags
int16 t_level[MAX_OBJ_LEVEL+1]; // object level table
inven_type t_list[MAX_TALLOC]; // full inventory list of all dungeon objects
inven_type inventory[INVEN_ARRAY_SIZE]; // player's personal inventory

Since I don't like just reading, I decided to download this old game, find the version that contains the bug, and try to reproduce it myself. I found it, and to be honest I also modified several things in the game so that when the bug triggers it would give me something like an alert to confirm that it actually fired.

Anyway, let's try it.


Reproducing the bug

First thing after launching the game I set up the character:

angband character setup

Then I entered the game:

angband in-game

I set the level to the highest level as the book described, and started placing 300 elements to trigger the bug:

angband placing items

Then I used Ctrl+G to drop items:

angband dropping items

And indeed they were placed around me. I started moving and trying to pick up whatever was there and drop it until the alert appeared:

angband bug triggered alert

And that is exactly what we explained above.

Of course I tried to make this as hands-on as possible so the concept would be explained and understood more clearly and be visible nothing more. Besides, the game has newer versions released, but I did this just to apply it myself and share the experience that's all.

Share

If this article helped you, please share it with others!

CH1.27 Example: a bug in Angband
https://v3nn00m.github.io/posts/re4b/chapter1_27/
Author
0xV3n0m
Published at
2026-04-24

Some information may be outdated

Table of Contents