Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!iuvax!silver!creps From: creps@silver.bacs.indiana.edu (Steve Creps) Newsgroups: comp.sources.d Subject: Re: NetHack 2.2: objects[] bug Message-ID: <543@silver.bacs.indiana.edu> Date: 18 Dec 87 02:55:36 GMT References: <337@dlhpedg.co.uk> Reply-To: creps@silver.UUCP (Steve Creps) Organization: Indiana University Computer Science Department Lines: 45 In article <337@dlhpedg.co.uk> cl@datlog.co.uk (Charles Lambert) writes: >I have built NetHack 2.2 for HP-UX (Hewlett Packard UNIX-like). To keep >the game simple, I didn't switch on all the optional stuff: specifically, >I left SAC undefined so there are no soldiers. When I tried to run the game, >it printed the message > > init-prob error for * (80%) > >To cut a long story short: leaving soldiers out means that there are fewer >objects (to wit, no dead soldier) in objects[] (see objects.h). As a result, >the defined constant indeces for objects[] were wrong; the code that sets >initial probabilities for valuable gems was overwriting the probabilities >for "worthless piece[s] of coloured glass"; and the sum of probabilities >for all gems was coming out wrong. It's your own fault for #undef'ing my code! :-) Actually, I'm the person who wrote the stuff inside the "#ifdef SAC"'s, and I see that I made a slight mistake. Instead of just putting the dead soldier declaration in objects.h, I should have also put something into makedefs.c. That's my conclusion after a quick look at the source. >I still haven't worked out the most elegant fix. I think the whole design >of the objects database and access to it ought to be rehashed, to allow >for dynamic sizing, but that's a big job. I will come up with a fix this weekend, and will send it to mike for the 2.3 patch release. My suggestion is to define SAC; it's really pretty neat stuff (or will be when 2.3 is released) if I do say so myself. If you refuse to do that, you can always remove the #ifdef SAC and #endif around the declaration of dead soldiers. It won't actually add them as a type of object; it will just allocate the space in the array to satisfy the rest of the code. >As a quick-fix, I'll probably replace the defined indeces with variables >calculated early in the initialisation. I think commenting out the #ifdef #endif pair in objects.h (mentioned above) so that the array is properly aligned is a better quick fix. Unless you are going to define SAC (hint hint). - - - - - - - - - Steve Creps on the VAX 8650 running Ultrix 2.0-1 at Indiana University. creps@silver.bacs.indiana.edu "F-14 Tomcat! There IS no substitute."