Path: utzoo!attcan!uunet!mcvax!hp4nl!ctisbv!pim
From: pim@ctisbv.UUCP (Pim Zandbergen)
Newsgroups: comp.sources.games.bugs
Subject: Re: Omega bug (includes minor spoiler)
Summary: it *is* a bug
Keywords: omega bug
Message-ID: <432@ctisbv.UUCP>
Date: 16 Aug 88 19:52:32 GMT
References: <418@ctisbv.UUCP> <316@mrsvr.UUCP>
Reply-To: pim@ctisbv.UUCP (Pim Zandbergen)
Organization: CTI Software BV, The Hague, The Netherlands
Lines: 69

In article <316@mrsvr.UUCP> ralston@mrsvr.UUCP (Richard Ralston) writes:
>From article <418@ctisbv.UUCP>, by pim@ctisbv.UUCP (Pim Zandbergen):
>> I'm confronted with a very annoying bug in Omega version 0.71.
>> Whenever I try to disarm a trap I just found, I just walk in it,
>> without any warning. This can be quite lethal :-(
>
>	I believe this is a "feature."  Whenever you try to disarm
>	a trap, you take the risk of accidently setting of said trap.
>	If you goof, Omega sets off the trap by putting you into the
>	trap.
>Richard B. Ralston                      | DISCLAIMER:
>                                        | I take full responsibility
>G.E. Medical Systems                    |  for what I said!
>PO Box 414                              |
>Milwaukee, WI 53201-414                 | (What *did* I say anyway?)

Yes, it is a feature. One *can* set off a trap by accident, trying
to disarm it. But it *is* a bug, because the chances of doing so
are wrong.
Take a look at disarm() in ocom2.c or hit 'n' if you don't want to.


/* try to deactivate a trap */
void disarm()
{
	if (disarm succeeds for some reason)
	{
		lots of nice things happen ...
	}
	else if (random_range(10+Level->depth) > Player.dex)
	{
		print1("You accidentally set off the trap!");
		various disasters happen ...
	}
	else print1("You failed to disarm the trap.");
}

This means that when you're on level 0 (city level) and your dexterity
is higher than 10, you cannot accidently set off a trap. Yet this is
what happened to me all the time. 

Digging into the sources and setting breakpoints with sdb, I found
out that Level->depth contained some random (huge) number instead of 0.
The citylevel structure is malloc'd in ocity.c but the depth
structure member is not initialised to zero anywhere.

Maybe on a Sun malloc(3) clears everything to zeroes automatically,
but on an AT&T 3B2 it doesn't. (BTW, I compiled Omega with malloc(3X) ).

Here's my patch to how I *think* it should be done:
--------------------------------------------------------------------------
*** orig/ogen1.c	Wed Aug 10 17:45:25 1988
--- ogen1.c	Wed Aug 10 01:55:31 1988
***************
*** 48,53 ****
--- 48,54 ----
  {
    int i,j;
    if (dungeon_level != NULL) {
+     dungeon_level->depth = 0;
      dungeon_level->generated = FALSE;
      dungeon_level->numrooms = 0;
      dungeon_level->tunnelled = 0;
-------------------------------------------------------------------------------
-- 
--------------------+------------------------------------+---------------------
Pim Zandbergen      | CTI Software BV                    | Phone: +31 70 542302 
pim@ctisbv.UUCP     | Laan Copes van Cattenburch 70      | Fax:   +31 70 512837
..!mcvax!ctisbv!pim | 2585 GD The Hague, The Netherlands | Telex: 32133 CTI NL