More examples of bad pointer coding

Chat about "The Legend of Skullkeep", the true sequel to the original Dungeon Master.
This forum may contain spoilers.
Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Suule
On Master
Posts: 656
Joined: Tue Aug 09, 2005 11:42 pm
Location: Warsaw, Poland

More examples of bad pointer coding

Post by Suule »

I began experimenting with the item replication bug again and I had the strangest thing happen to me. Here it goes:

I 'fixed' the dungeon.dat to 'No Torham' copying all of his items to his 'freezer'. I've unfrozen Equus and started to grab random stuff from the mirrors (in order to sell it or put it in a money box). Well after the first round of item selling I went back and tried to rob the champions out of more items for cash.

I've started from Uggo the Mad (1 Scale Hauberk stolen and sold) and to my suprise his equipment turned into that of Equus. Except instead of a torso plate he had the scale armour he had. I've checked Torham (from which I got cash) and I saw all his money (1 crystal, 3 golden coins and one silver one) turned into planks and small planks or just disappeared. This also happened to few other champions I borrowed the money from. Cordian from which I've got a rapier and scale hauberk (both were sold) was stripped out of his equipment, and now had two scale hauberk: one in the hand, the other one worn. Anders from which I had stolen a Scale mail had now a scale armor in hand.

Right now I'll try reproducing this bug.
User avatar
purple1
Adept
Posts: 237
Joined: Wed Jul 14, 2004 5:04 pm
Location: California, USA

Post by purple1 »

If you would read my topic about hacking DM2, you could do whatever you wanted in the game. The pointer coding is fine; you have simply screwed up parts of the item database by using the replication bug. If you download a memory editor, I can give you some steps to changing some common items into something more valuable, if you would like. I can change any weapon into any other weapon quite easily.
User avatar
Adamo
Italodance spammer
Posts: 1534
Joined: Fri Apr 22, 2005 11:59 am
Location: Poland
Contact:

Post by Adamo »

Suule wrote:
Location: Warsaw, Poland
witamy na forum!
Spoiler
(\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/)
Spoiler
(@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@)
Spoiler
(>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<)
User avatar
Suule
On Master
Posts: 656
Joined: Tue Aug 09, 2005 11:42 pm
Location: Warsaw, Poland

Post by Suule »

purple1 wrote:If you would read my topic about hacking DM2, you could do whatever you wanted in the game. The pointer coding is fine; you have simply screwed up parts of the item database by using the replication bug. If you download a memory editor, I can give you some steps to changing some common items into something more valuable, if you would like. I can change any weapon into any other weapon quite easily.
Well I still think it's the pointer coding that went wrong. I've tried reproducing the bug but this time the game hanged up while trying to descent to the hall of champions to check the character inventories. Well the database in the last game was fine (The items had their correct commands, weights and stats) I think that this bug kicks in when a duplicated item is destroyed (selling the item destorys it).

Thanks for the offering but I'm afraid that in WinXP the trainers and memory editors have a hard time running. As I said: what I did was pure experimenting, trying to see what bugs should I avoid while doing a DM2 clone.
witamy na forum!
Dzieki!
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post by Gambit37 »

You're complaining about a possible bug that's only viewable if you use another bug to hack the game? Weird!
User avatar
purple1
Adept
Posts: 237
Joined: Wed Jul 14, 2004 5:04 pm
Location: California, USA

Post by purple1 »

Selling an item does not destroy it... all non-infinite sellables become an inventory item of the shop keeper or are inventory of some unknown object right behind the table.

The problem with the duplicating is that the bug creates a duplicate reference in the same object. If the two objects meet, the game crashes. It's very easy to crash the game with duped stuff. The reason that you say the game has "bad pointer coding" is because you expected the duplicated object to be added to the item database, which it isn't. The duplication bug isn't supposed to happen, and so the game isn't programmed to deal with it. Just like the game isn't programmed to deal with references to objects that don't exist.
User avatar
Suule
On Master
Posts: 656
Joined: Tue Aug 09, 2005 11:42 pm
Location: Warsaw, Poland

Post by Suule »

Selling an item does not destroy it... all non-infinite sellables become an inventory item of the shop keeper or are inventory of some unknown object right behind the table.
Very intresting... I assumed the item was destroyed and then recreated since it was 'magically' recharged when I bought it back. I'm intrested to hear more of your findings about DM2 mechanisms since it will surely help me in writting my DM2 clone.
The problem with the duplicating is that the bug creates a duplicate reference in the same object. If the two objects meet, the game crashes. It's very easy to crash the game with duped stuff. The reason that you say the game has "bad pointer coding" is because you expected the duplicated object to be added to the item database, which it isn't. The duplication bug isn't supposed to happen, and so the game isn't programmed to deal with it. Just like the game isn't programmed to deal with references to objects that don't exist.
Funny that this item duplication bug was unfixed, because when I played the beta few years ago (I had the same beta version of DM2 like the on DM Encyclopedia, released by a cracking group ), the same bug was there and worked the almost same way (The main diffrence was that you could exit the mirror with the item in hand - that was fixed). It lead to similar freezes or inventory corructions that happen in DM2. Strange they didn't write a code to fix it. Either to protect the 'freezer screen' more or just a detector of duped objects (like in Diablo). I say it's bad coding because the bug could be fixed... but wasn't. Then again I sometimes feel that not everything the developers wanted was put into the game. I think once again release dates made the developers partially fix the issue instead of digging in further and fixing it totally. [/quote]
User avatar
purple1
Adept
Posts: 237
Joined: Wed Jul 14, 2004 5:04 pm
Location: California, USA

Post by purple1 »

Hey, the Macintosh version of the game doesn't have the bug. And the Mac version will run on pretty much ANY Mac that was made within the last 10 years. Maybe you're right about that release date thing. If you want information, check the dungeon format page on the Encyclopaedia. Because PCs use little endian, you'll need to switch the order of the bytes in the words to properly decode the dungeon format.
Tom Hatfield
Ee Master
Posts: 688
Joined: Mon May 07, 2001 7:00 pm
Location: Indiana, USA
Contact:

Post by Tom Hatfield »

That is one very nice things about Macs: backward compatibility.

Gambit: I was about to say the same thing. You can't expect a game to function normally when you hack it. It functions quite well when you're not throwing wrenches in the gears, so I'd say it's a pretty solid design.
User avatar
purple1
Adept
Posts: 237
Joined: Wed Jul 14, 2004 5:04 pm
Location: California, USA

Post by purple1 »

Wait! I know WHY it is happening! If I were to steal ONLY the first item in any character's inventory and then sell it to a shop, it would change locations. And because the pointer for the first item links to the next item which links to the next, all the rest of the items on that character would also be transferred. But the original item is cloned because there was still a reference on the person.

Example (I must be rambling):

1. Cordain has a Scale Hauberk. There is a reference in the item list which points to it and links the rest of Cordain's inventory.

2. You "steal" the Scale Hauberk, which creates a second reference to it in your hand.

3. By selling it, the second reference is changed to the shop's location. All the linked items join it in the store as inventory. (They couldn't be inventory for the HAND because the hand can't actually hold them... it ignores them as linked references). The linking has now been moved, essentially.

4. You go back to Cordain and notice that the Scale Haubrek is still there. The first reference didn't go away, so it still counts as being there. It now links to objects that have moved, which is a problem. Picking it up and selling it causes both Scale Haubreks to meet each other and exist in the same place, which the game can't handle and then freezes.

Am I right? I'm trying to understand this.
User avatar
Suule
On Master
Posts: 656
Joined: Tue Aug 09, 2005 11:42 pm
Location: Warsaw, Poland

Post by Suule »

Hmmrrr.. your theory may be right, the inventories seem to be two or one way quques so changing the pointers would make the whole list move.

I'll try it out tomorrow, it's too late to do it now.
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

Yes, this sounds about right, ands is the same sort of thing that would happen in long games of DM when the same ID number got re-used to create two of the same items - usually one would be in an inventory and the other in the dungeon floor - fine until you drop the first or your champion dies, then #boom# the references collide
User avatar
Suule
On Master
Posts: 656
Joined: Tue Aug 09, 2005 11:42 pm
Location: Warsaw, Poland

Post by Suule »

Okay... I'v tried the theory today. I've duped a silver coin from Frozen Torham's inventory that was the LAST item on the field. I've payed with it for a torch, went to HoC and the game froze. While duping the first item from the list (Last in the stack) lead to no consequences

The item list seems to be a quque... the first item show is the first link of the chain of items. Items that are last in the item lists (using the editors) are the ones creating the item quque. So selling the item causes the WHOLE quque to be distrupted (That's why I could see shopkeepr's inventory in the freezers), causing either a crash or wierd effects. While selling the last item on the quque seems to be a-ok.

So solution is simple: before duping any stuff. Check the item's position in the queque. If it's last or in the middle. Don't attempt to dupe it. If it's the first one. You can dupe it without any consequences.
User avatar
purple1
Adept
Posts: 237
Joined: Wed Jul 14, 2004 5:04 pm
Location: California, USA

Post by purple1 »

I accidentally changed a pointer of Torham's knife on the ground into the first itme in the normal weapon shop and I got some weird stuff. Along with a pile of items, I found an odd green face that weighed nothing, had no effects, and a screwed-up name. I'm guessing the pic was used for errors, such as an item without a pic. Odd.
User avatar
Suule
On Master
Posts: 656
Joined: Tue Aug 09, 2005 11:42 pm
Location: Warsaw, Poland

Post by Suule »

Ah! The Yuk Face. It's used to mark the end of an array of records in the data file.

Originally it was one of the playtesting heroes in the Beta, that had Archmaster in everything and cosmic stats. I guess they left the face in as an "End of Record" marker.
Post Reply

Return to “Dungeon Master II: The Legend of Skullkeep (DM2)”