Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rochester!cornell!svax!gil From: gil@svax.cs.cornell.edu (Gil Neiger) Newsgroups: rec.games.hack,net.sources.games,comp.sources.d Subject: Bug Fix for Hack (panicking in makemon) Message-ID: <1264@svax.cs.cornell.edu> Date: Tue, 21-Apr-87 19:46:36 EST Article-I.D.: svax.1264 Posted: Tue Apr 21 19:46:36 1987 Date-Received: Thu, 23-Apr-87 04:22:29 EST Reply-To: gil@svax.cs.cornell.edu (Gil Neiger) Organization: Cornell Univ. CS Dept, Ithaca NY Lines: 59 Xref: mnetor rec.games.hack:462 net.sources.games:1102 comp.sources.d:619 A few weeks ago a posted a problem I was having in hack here at Cornell. Many players were finding that when they reached level 27 or thereabouts they often lost a game due to "panic". They would get the message "Suddenly, the dungeon collapses" followed by "makemon?". I posted the appropriate section of makemon() that I had, but no one was able to help me. I noticed that some people have been having problems with another version (Amiga) of hack crashing - maybe my fix can help them also. I had installed a fix to makemon() to better balance monsters when using KOPS and ROCKMOLE. Here's what the code looked like: } else { ct = CMNUM - strlen(fut_geno); if(index(fut_geno, 'm')) ct++; /* make only 1 minotaur */ if(index(fut_geno, '@')) ct++; if(ct <= 0) return(0); /* no more monsters! */ tmp = 7; #ifdef KOPS tmp--; #endif KOPS #ifdef ROCKMOLE if(dlevel<4)tmp--; #endif ROCKMOLE tmp = rn2(ct*dlevel/24 + tmp); if(tmp < dlevel - 4) tmp = rn2(ct*dlevel/24 + 12); if(tmp >= ct) tmp = rn1(ct - ct/2, ct/2); ct = 0; #ifdef KOPS ct++; /****************************/ #endif KOPS for(; ct < CMNUM; ct++){ ptr = &mons[ct]; if(index(fut_geno, ptr->mlet)) continue; if(!tmp--) goto gotmon; } panic("makemon?"); } gotmon: The problem is when ct is decremented when KOPS is on (see ***); tmp needs to be correspondingly (if it is greater than 0). Specifically, that portion of the code should look like this tmp = rn2(ct*dlevel/24 + tmp); if(tmp < dlevel - 4) tmp = rn2(ct*dlevel/24 + 12); if(tmp >= ct) tmp = rn1(ct - ct/2, ct/2); ct = 0; #ifdef KOPS ct++; tmp = (tmp) ? tmp-- : tmp; #endif KOPS for(; ct < CMNUM; ct++){ ptr = &mons[ct]; Now you can be assured that the loop will terminate correctly and that there will be no panic. - Gil