diasurgical / devilution

Diablo devolved - magic behind the 1996 computer game
Other
8.66k stars 921 forks source link

objects: add BUGFIX for holy shrine #2252

Closed mewmew closed 2 years ago

mewmew commented 2 years ago

If the random number generator ends up giving X-Y coordinate pairs that always are on bad tiles (e.g. solid, with object or with monster) then after a total of MAXDUNX * MAXDUNY tries, it will still cast phasing to teleport to the bad tile.

AJenbo commented 2 years ago

Yay I guessed correctly :)

Also this is an extremely inefficient way to search for a good spot to land :/

We have a save game for anyone that would like to see it in effect: https://github.com/diasurgical/devilutionX/issues/1566

galaxyhaxz commented 2 years ago

This is definitely a bug--however I think from their point of view they thought this would never actually be possible (there cannot be enough monsters/objects/players to take up all free tiles) thus didn't bother to add a fail safe.

Edit: this could potentially create a bug in mods where someone adds summoning and allows enough monsters to spawn indefinitely, to where the only free tile is the one already being stood upon.

Edit 2: Also as Anders said, it might be better if they had picked a tile, and if that tile isn't good, search around that tile first before starting the loop all over.

AJenbo commented 2 years ago

Since it uses random it could potentially pick the same wall tile 12544 times and then give up and teleport you in to it regardless :)

StephenCWills commented 2 years ago

Since it uses random it could potentially pick the same wall tile 12544 times and then give up and teleport you in to it regardless :)

To be fair, any psuedo-random number generator with anything remotely resembling uniform distribution should never do that.

mewmew commented 2 years ago

Yay I guessed correctly :)

Also this is an extremely inefficient way to search for a good spot to land :/

We have a save game for anyone that would like to see it in effect: diasurgical/devilutionX#1566

Wow, incredible that we have a reproducible save file that triggers this bug!

AJenbo commented 2 years ago

The psuedo-random number generator is known to only be 95% uniform so just have enough people play and it will eventually happen :)

galaxyhaxz commented 2 years ago

Also casting phasing directly only gives 500 attempts as opposed to 112x112 making a bad tile selection far more likely. just saying :P