DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Fan Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

Three bugs in Wolf3D that no one has ever fixed
Page 1 of 1
DieHard Wolfers Forum Index -> Wolfenstein 3d View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
Matthew
DieHard Officer
DieHard Officer


Joined: 02 Jul 2007
Last Visit: 30 Sep 2019

Topics: 102
Posts: 512

usa.gif

PostPosted: Tue Jan 01, 2019 8:17 pm
   Subject: Three bugs in Wolf3D that no one has ever fixed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

It seems that people in the Wolf3D community don't know how to inspect code. They just rely on the compiler or a debugger to find errors.

There are three bugs I know of in Wolf3D that no one has ever fixed. The original Wolf3D and SOD, Wolf4SDL, and every mod has them.

Except for my modified version of Wolf4SDL.

One of them is a glaring typographic error. "attackinfo" is defined as "attackinfo[4][14]", instead of "attackinfo[4][4]". In 16-bit Wolf3D, this wastes a significant amount of near memory.

Another is that the player can not close a door when it is opening. This is because "CloseDoor" does not take into account that doors that are not fully open are marked in "actorat".

The other is that line tracing through doors is not done correctly. The code is incorrect.

To fix these bugs, make the following changes:



WL_AGENT.C:

::: CODE :::
struct atkinf
{
   char   tics,attack,frame;      // attack is 1 for gun, 2 for knife
} attackinfo[4][4] =

{
{ {6,0,1},{6,2,2},{6,0,3},{6,-1,4} },
{ {6,0,1},{6,1,2},{6,0,3},{6,-1,4} },
{ {6,0,1},{6,1,2},{6,3,3},{6,-1,4} },
{ {6,0,1},{6,1,2},{6,4,3},{6,-1,4} },
};




WL_ACT1.C:

::: CODE :::
/*
=====================
=
= CloseDoor
=
=====================
*/

void CloseDoor (int door)
{
   int   tilex,tiley,area;
   objtype *check;

//
// don't close on anything solid
//
   tilex = doorobjlist[door].tilex;
   tiley = doorobjlist[door].tiley;

   if ((unsigned)actorat[tilex][tiley] != door | 0x80)
      return;

   if (player->tilex == tilex && player->tiley == tiley)
      return;




WL_ACT1.C:

::: CODE :::
/*
=====================
=
= CheckLine
=
= Returns true if a straight line between the player and ob is unobstructed
=
=====================
*/

boolean CheckLine (objtype *ob)
{
   int   x1,y1,xt1,yt1,x2,y2,xt2,yt2;
   int   x,y;
   int   xdist,ydist,xstep,ystep;
   int   temp;
   int   partial,delta;
   long   ltemp;
   int   xfrac,yfrac,deltafrac;
   unsigned   value;

   x1 = ob->x >> UNSIGNEDSHIFT;      // 1/256 tile precision
   y1 = ob->y >> UNSIGNEDSHIFT;
   xt1 = x1 >> 8;
   yt1 = y1 >> 8;

   x2 = plux;
   y2 = pluy;
   xt2 = player->tilex;
   yt2 = player->tiley;


   xdist = abs(xt2-xt1);

   if (xdist > 0)
   {
      if (xt2 > xt1)
      {
         partial = 256-(x1&0xff);
         xstep = 1;
      }
      else
      {
         partial = x1&0xff;
         xstep = -1;
      }

      deltafrac = abs(x2-x1);
      delta = y2-y1;
      ltemp = ((long)delta<<8)/deltafrac;
      if (ltemp > 0x7fffl)
         ystep = 0x7fff;
      else if (ltemp < -0x7fffl)
         ystep = -0x7fff;
      else
         ystep = ltemp;
      yfrac = y1 + (((long)ystep*partial) >>8);

      x = xt1+xstep;
      xt2 += xstep;
      do
      {
         y = yfrac>>8;
         yfrac += ystep;

         value = (unsigned)tilemap[x][y];
         x += xstep;

         if (!value)
            continue;

         if (value<128 || value>256)
            return false;

         //
         // see if the door is open enough
         //
         value &= ~0x80;
         temp = yfrac-ystep/2;

         if (temp>>8==y)
            if ((temp&0xff)>doorposition[value]>>8)
               return false;

      } while (x != xt2);
   }

   ydist = abs(yt2-yt1);

   if (ydist > 0)
   {
      if (yt2 > yt1)
      {
         partial = 256-(y1&0xff);
         ystep = 1;
      }
      else
      {
         partial = y1&0xff;
         ystep = -1;
      }

      deltafrac = abs(y2-y1);
      delta = x2-x1;
      ltemp = ((long)delta<<8)/deltafrac;
      if (ltemp > 0x7fffl)
         xstep = 0x7fff;
      else if (ltemp < -0x7fffl)
         xstep = -0x7fff;
      else
         xstep = ltemp;
      xfrac = x1 + (((long)xstep*partial) >>8);

      y = yt1 + ystep;
      yt2 += ystep;
      do
      {
         x = xfrac>>8;
         xfrac += xstep;

         value = (unsigned)tilemap[x][y];
         y += ystep;

         if (!value)
            continue;

         if (value<128 || value>256)
            return false;

         //
         // see if the door is open enough
         //
         value &= ~0x80;
         temp = xfrac-xstep/2;

         if (temp>>8==x)
            if ((temp&0xff)>doorposition[door]>>8)
               return false;

      } while (y != yt2);
   }

   return true;
}


Last edited by Matthew on Thu Jan 03, 2019 5:11 pm; edited 2 times in total
Blzut3
DieHard Guard
DieHard Guard


Joined: 08 Jun 2011
Last Visit: 24 Sep 2019

Topics: 3
Posts: 203

blank.gif

PostPosted: Tue Jan 01, 2019 8:46 pm
   Subject: Re: Three bugs in Wolf3D that no one has ever fixed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

You can't say everyone and forget about ECWolf!

The only one I'm not sure about is the CheckLine one although I'm pretty sure I checked that it was working as it should. The others went away when the data structures changed.
Matthew
DieHard Officer
DieHard Officer


Joined: 02 Jul 2007
Last Visit: 30 Sep 2019

Topics: 102
Posts: 512

usa.gif

PostPosted: Tue Jan 01, 2019 10:57 pm
   Subject: Three bugs in Wolf3D that no one has ever fixed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I've never played ECWolf, but I just looked at it's source code, and the problem with CheckLine is still there.

The value that is compared with the door position is the map coordinate, not the position relative to the door. It and the door position need to be normalized.

It also should check if the midpoint is on the same tile. If it is not, it should not check for the door intercept.

As I did in the above code, this should be done the following way:

::: CODE :::
if (p>>8==t)
   if ((p&0xff)>doorposition[value]>>8)
      return false;


Last edited by Matthew on Thu Jan 03, 2019 6:28 pm; edited 2 times in total
Tris
Bring 'em On
Bring 'em On


Joined: 02 May 2017
Last Visit: 13 Oct 2019

Topics: 6
Posts: 94

blank.gif

PostPosted: Tue Jan 01, 2019 11:49 pm
   Subject: Re: Three bugs in Wolf3D that no one has ever fixed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Nice work!
Aryan_Wolf3D
DieHard Guard
DieHard Guard


Joined: 21 Jul 2011
Last Visit: 16 Oct 2019

Topics: 6
Posts: 256

blank.gif

PostPosted: Wed Jan 02, 2019 4:37 am
   Subject: Re: Three bugs in Wolf3D that no one has ever fixed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Matthew wrote:
It seems that people in the Wolf3D community don't know how to inspect code. They just rely on the compiler or a debugger to find errors.

That's quite the assumption on your part, and while it may be true about some people, it's hardly fair to tar everyone with the same brush.

Quote:
There are three bugs I know of in Wolf3D that no one has ever fixed. The original Wolf3D and SOD, Wolf4SDL, and every mod has them.

Except for my modified version of Wolf4SDL.

One of them is a glaring typographic error. "attackinfo" is defined as "attackinfo[4][14]", instead of "attackinfo[4][4]". In 16-bit Wolf3D, this wastes a significant amount of near memory.

This can't really be called a bug, as it's up to the designer how many weapon frames he wants an animation to have. It's quite likely that the original Wolf was going to have a weapon with 14 frames, but they scrapped it and forgot to change it back to 4. The Wolf source is full of old stuff that never got removed, some of which wastes a ton more memory than this does.

Quote:
Another is that the player can not close a door when it is opening. This is because "CloseDoor" does not take into account that doors that are not fully open are marked in "actorat".

This is an interesting find, but who says it's a bug? It's quite possible that this behaviour was intentional. At least it stops you from instantly slamming an opening door on an enemy, thus making their ambush more effective (e.g. Hans Grosse on E1M9).

Quote:
The other is that line tracing through doors is not done correctly. The code is incorrect.

linuxwolf posted another fix for this yesterday. I'll try out your code later.

_________________
"Way too many #ifdefs in the code!" - John Carmack
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 23 Sep 2019

Topics: 57
Posts: 2239
Location: Canada
blank.gif

PostPosted: Wed Jan 02, 2019 9:36 am
   Subject: Re: Three bugs in Wolf3D that no one has ever fixed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Matthew wrote:
One of them is a glaring typographic error. "attackinfo" is defined as "attackinfo[4][14]", instead of "attackinfo[4][4]". In 16-bit Wolf3D, this wastes a significant amount of near memory.

I did add your [4][4] suggestion to wl6max12 to save a bit more space. As you can see from all the #ifdef KEEP_UNUSED defines in the diff.txt, there are quite a few things ID could have either removed or made smaller without consequence:
http://diehardwolfers.areyep.com/viewtopic.php?p=98535#98535

I'm guessing Wolf4SDL wasn't changed for the reasons Aryan said and because there's less need to save a few bytes in it. I imagine that altering the behavior of the doors would break the demos and change the gameplay to something different than what everyone is used to, so I probably wouldn't add them to wolf3d myself, but they might be interesting for a mod.
Matthew
DieHard Officer
DieHard Officer


Joined: 02 Jul 2007
Last Visit: 30 Sep 2019

Topics: 102
Posts: 512

usa.gif

PostPosted: Wed Jan 02, 2019 11:47 am
   Subject: Three bugs in Wolf3D that no one has ever fixed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Aryan_Wolf3D wrote:
It's quite likely that the original Wolf was going to have a weapon with 14 frames, but they scrapped it and forgot to change it back to 4.


I highly doubt it.



Aryan_Wolf3D wrote:
Quote:
Another is that the player can not close a door when it is opening. This is because "CloseDoor" does not take into account that doors that are not fully open are marked in "actorat".

This is an interesting find, but who says it's a bug? It's quite possible that this behaviour was intentional. At least it stops you from instantly slamming an opening door on an enemy, thus making their ambush more effective (e.g. Hans Grosse on E1M9).


This clearly was unintentional. The switch statement in "OperateDoor" includes "dr_opening". And "DoorClosing" checks "actorat" properly. Only "CloseDoor" has the problem.

There are much better ways to make enemy ambushes more effective.

It is fun to slam an opening door on an enemy. Smile
Aryan_Wolf3D
DieHard Guard
DieHard Guard


Joined: 21 Jul 2011
Last Visit: 16 Oct 2019

Topics: 6
Posts: 256

blank.gif

PostPosted: Wed Jan 02, 2019 12:50 pm
   Subject: Re: Three bugs in Wolf3D that no one has ever fixed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Matthew wrote:
Aryan_Wolf3D wrote:
It's quite likely that the original Wolf was going to have a weapon with 14 frames, but they scrapped it and forgot to change it back to 4.


I highly doubt it.

Why? It's pretty well known that Wolf was at first intended to be a very different game from the one we have, and there's evidence of at least 1 more weapon in some unused graphic sheets (which is also probably why the NUMWEAPONS macro is set to 5 in WL_DEF.H.)

Matthew wrote:
Aryan_Wolf3D wrote:
Quote:
Another is that the player can not close a door when it is opening. This is because "CloseDoor" does not take into account that doors that are not fully open are marked in "actorat".

This is an interesting find, but who says it's a bug? It's quite possible that this behaviour was intentional. At least it stops you from instantly slamming an opening door on an enemy, thus making their ambush more effective (e.g. Hans Grosse on E1M9).


This clearly was unintentional. The switch statement in "OperateDoor" includes "dr_opening". And "DoorClosing" checks "actorat" properly. Only "CloseDoor" has the problem.

There are much better ways to make enemy ambushes more effective.

It is fun to slam an opening door on an enemy. Smile

Ah, good catch there! I guess it's not the only thing in the code that is unintentional. Laughing I still prefer the original behaviour, but whatever works for you is cool too. Thumbs Up

_________________
"Way too many #ifdefs in the code!" - John Carmack
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 23 Sep 2019

Topics: 57
Posts: 2239
Location: Canada
blank.gif

PostPosted: Wed Jan 02, 2019 2:22 pm
   Subject: Re: Three bugs in Wolf3D that no one has ever fixed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Aryan_Wolf3D wrote:
Matthew wrote:
Aryan_Wolf3D wrote:
It's quite likely that the original Wolf was going to have a weapon with 14 frames, but they scrapped it and forgot to change it back to 4.


I highly doubt it.

Why? It's pretty well known that Wolf was at first intended to be a very different game from the one we have, and there's evidence of at least 1 more weapon in some unused graphic sheets (which is also probably why the NUMWEAPONS macro is set to 5 in WL_DEF.H.)

They could have also just not noticed, becase the 1 kinda looks like a [ and blends in and didn't give them a compile error. Maybe one of the coders was using the Numpad and just slapped 1 and 4 at the same time by accident. Very Happy
Matthew
DieHard Officer
DieHard Officer


Joined: 02 Jul 2007
Last Visit: 30 Sep 2019

Topics: 102
Posts: 512

usa.gif

PostPosted: Wed Jan 02, 2019 2:22 pm
   Subject: Three bugs in Wolf3D that no one has ever fixed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Aryan_Wolf3D wrote:
Matthew wrote:
Aryan_Wolf3D wrote:
It's quite likely that the original Wolf was going to have a weapon with 14 frames, but they scrapped it and forgot to change it back to 4.


I highly doubt it.

Why?


14 frames is a lot for a game of the time. Why would they make a weapon have that particular number of frames? And the second digit matches.



Aryan_Wolf3D wrote:
It's pretty well known that Wolf was at first intended to be a very different game from the one we have, and there's evidence of at least 1 more weapon in some unused graphic sheets (which is also probably why the NUMWEAPONS macro is set to 5 in WL_DEF.H.)


What type of weapon is that?



Chris wrote:
Maybe one of the coders was using the Numpad and just slapped 1 and 4 at the same time by accident. Very Happy


Good theory. I didn't think of that.
Aryan_Wolf3D
DieHard Guard
DieHard Guard


Joined: 21 Jul 2011
Last Visit: 16 Oct 2019

Topics: 6
Posts: 256

blank.gif

PostPosted: Wed Jan 02, 2019 3:40 pm
   Subject: Re: Three bugs in Wolf3D that no one has ever fixed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Matthew wrote:
What type of weapon is that?

Who knows. It could have been the mine/grenade thing in this pic, or something else entirely.

_________________
"Way too many #ifdefs in the code!" - John Carmack
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 23 Sep 2019

Topics: 57
Posts: 2239
Location: Canada
blank.gif

PostPosted: Thu Jan 03, 2019 12:18 pm
   Subject: Re: Three bugs in Wolf3D that no one has ever fixed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Aryan_Wolf3D wrote:
Matthew wrote:
What type of weapon is that?

Who knows. It could have been the mine/grenade thing in this pic, or something else entirely.

I couldn't see the image on my browser for some reason, so here's the original post too (bottom pic):
https://forums.3drealms.com/vb/showpost.php?p=936056&postcount=5

gerolf
DieHard Wolfer
DieHard Wolfer


Joined: 28 Jan 2010
Last Visit: 20 Jun 2019

Topics: 162
Posts: 1102
Location: Virginia
usa.gif

PostPosted: Thu Feb 14, 2019 6:34 pm
   Subject: Re: Three bugs in Wolf3D that no one has ever fixed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

I know I’m a little late to the party, but I’d like to add a bit to what Aryan and Chris said about the weapon. I know for sure that the unused weapon 5 was a S-Mine styled weapon. You were supposed to be able to drop it like a land mine, and in earlier versions they planned to have rugs in the game where you could hide the bombs under them. It was programmed into the game at one point according to Romero, but it was removed when they discarded other concepts and realized the weapon didn’t fit well with the rest of the weapons and action of the gameplay. It is unknown how many frames it would’ve took to animate the weapon. It could’ve been a typo, or it could’ve taken 14 frames of animation for a compete “attack” with the mine weapon.

_________________


Last edited by gerolf on Thu Feb 14, 2019 6:36 pm; edited 1 time in total
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> Wolfenstein 3d View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 1 of 1
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts Wolf3D Newsletter
Author: IanFranken
88 22268 Sun Mar 06, 2005 10:25 pm
Zombie_Plan View latest post
No new posts The Wolf3D Dome Archives
Author: Majik Monkee
15 5303 Thu Aug 12, 2004 5:12 pm
IanFranken View latest post
No new posts What I find off about Wolf3D
Author: Majik Monkee
11 4265 Fri Jun 11, 2004 9:21 am
Majik Monkee View latest post
No new posts Just wanted to say Great Job @ Btank & MCS...
Author: IanFranken
21 835 Mon May 31, 2004 8:27 am
Guest View latest post
No new posts Ideas for the "Wolfenstein" section
Author: Chris
12 6157 Wed Feb 04, 2004 5:17 pm
Zach View latest post
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
   You cannot delete your posts in this forum
You cannot vote in polls in this forum


Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group