[Tutorial] Vanishing Dogs Bug Fix
Select messages from
# through # FAQ
[/[Print]\]

DieHard Wolfers -> Code Crackers

#1: [Tutorial] Vanishing Dogs Bug Fix Author: WSJ PostPosted: Mon Jun 13, 2005 9:27 pm
    —
There is a bug in the original Wolfenstein code which will sometimes cause Dogs and Fake Hitlers to "disappear" when they go through an open door. This fix will solve it...

Open WL_ACT2.C, and go down to the "T_DogChase" function. Add the lines marked in red:

::: CODE :::

void T_DogChase (objtype *ob)
{
   long    move;
   int      dist,chance;
   long   dx,dy;


   if (ob->dir == nodir)
   {
      SelectDodgeDir (ob);
      if (ob->dir == nodir)
         return;                     // object is blocked in
   }

   move = ob->speed*tics;

   while (move)
   {
   //
   // check for byte range
   //
      dx = player->x - ob->x;
      if (dx<0)
         dx = -dx;
      dx -= move;
      if (dx <= MINACTORDIST)
      {
         dy = player->y - ob->y;
         if (dy<0)
            dy = -dy;
         dy -= move;
         if (dy <= MINACTORDIST)
         {
            NewState (ob,&s_dogjump1);
            return;
         }
      }

      if (ob->distance < 0)
      {
      //
      // waiting for a door to open
      //
         if (doorobjlist[-ob->distance-1].action != dr_open)
            return;
         ob->distance = TILEGLOBAL;   // go ahead, the door is now opoen
      }

      if (move < ob->distance)
      {
         MoveObj (ob,move);
         break;
      }
   
   ( ... )


That should make the Dogs not disappear when they run through a door.

For Fake Hitlers, go to the "T_Fake" function and again add the lines in red:

::: CODE :::

void T_Fake (objtype *ob)
{
   long move;
   int   dx,dy,dist;
   boolean   dodge;

   if (CheckLine(ob))         // got a shot at player?
   {
      if ( US_RndT() < (tics<<1) )
      {
      //
      // go into attack frame
      //
         NewState (ob,&s_fakeshoot1);
         return;
      }
   }

   if (ob->dir == nodir)
   {
      SelectDodgeDir (ob);
      if (ob->dir == nodir)
         return;                     // object is blocked in
   }

   move = ob->speed*tics;

   while (move)
   {

      if (ob->distance < 0)
      {
      //
      // waiting for a door to open
      //
         if (doorobjlist[-ob->distance-1].action != dr_open)
            return;
         ob->distance = TILEGLOBAL;   // go ahead, the door is now opoen
      }

      if (move < ob->distance)
      {
         MoveObj (ob,move);
         break;
      }

   ( ... )


As you can see, I used the same block of code in both chase routines. This block was used in "T_Chase" and some of the boss chase routines, but it was left out for Dogs and Fake Hitlers. Its main purpose, I believe, was to prevent guards from walking through a door that hadn't fully opened.

I hope this tutorial was helpful.

-WSJ

EDIT: removed an unnecessary line... "OpenDoor (-ob->distance-1);" (no quotes). However, if you decide to give your Dogs the ability to open doors, I think you'll have to add this line right above the "if (doorobjlist[-ob->distance-1].action != dr_open)"


Last edited by WSJ on Tue Jun 14, 2005 7:06 pm; edited 1 time in total

#2: Re: [Tutorial] Vanishing Dogs Bug Fix Author: Zombie_PlanLocation: A hole in the wall PostPosted: Tue Jun 14, 2005 2:39 am
    —
Good one WSJ, hopefully people will use this. I'm glad to see you're still contributing to the community code-wise.

#3: Re: [Tutorial] Vanishing Dogs Bug Fix Author: WSJ PostPosted: Tue Jun 14, 2005 5:08 am
    —
Yeah, Tricob reminded me about this bug because I had mentioned it in the "ReadThis" manual in Castle Totenkopf. Now that I've figured out how to fix it, I thought it would be good to post this tutorial.

#4: Re: [Tutorial] Vanishing Dogs Bug Fix Author: Adam BiserLocation: USA PostPosted: Tue Jun 14, 2005 10:16 am
    —
Why are the "OpenDoor (-ob->distance-1);" lines there since dogs and fake hitlers can't open doors? I assume that line can be left out, right?

#5: Re: [Tutorial] Vanishing Dogs Bug Fix Author: Zombie_PlanLocation: A hole in the wall PostPosted: Tue Jun 14, 2005 5:25 pm
    —
You have to remember that WSJ doesn't use dogs that often, and his ghosts are usually flamers or minigunners, so they all need to be able to open doors for him. At least, i think that's wat waz planned...

#6: Re: [Tutorial] Vanishing Dogs Bug Fix Author: TricobLocation: Neo-traditions, Inc. PostPosted: Tue Jun 14, 2005 7:10 pm
    —
A major thanks for the bug fix tutorial, WSJ. I remember having major problems with the Dog-related bug in my own Level 6 of Episode 4, and had to remove the dogs in that room all together. Now I can put 'em back in! Cheesy Grin

#7: Re: [Tutorial] Vanishing Dogs Bug Fix Author: WSJ PostPosted: Tue Jun 14, 2005 7:14 pm
    —
@Adam: I believe you're right... Embarassed Thanks for pointing that out. You see, I copied and pasted that segment of code from "T_Chase" when I tried to fix the bug. Leaving that line there didn't cause any problems for me, so I guess I overlooked it.

@Deathshead: Yes, that has often been the case in my mods, though I don't think I came up with the bug fix until COTS, which had dogs in it.

@Tricob: You're welcome. Smile

The code has been updated.

#8: Re: [Tutorial] Vanishing Dogs Bug Fix Author: ChrisLocation: Canada PostPosted: Tue Jun 14, 2005 7:52 pm
    —
Interesting WSJ. I was going to impliment this, but apparently I already fixed this bug (without even knowing it). Surprised
After doing some testing, looks like this is the reason: http://diehardwolfers.areyep.com/viewtopic.php?p=34280&#34280

::: CODE :::
//
// follow the walls from there to the right, drawwing as we go
//
         spotvis[player->tilex][player->tiley] = 1;

So, I guess if you want to get rid of a bunch of "detect sprites over player" bugs at once; adding that one line to WL_DRAW.C might be easier. Wink

#9: Re: [Tutorial] Vanishing Dogs Bug Fix Author: TricobLocation: Neo-traditions, Inc. PostPosted: Tue Jun 14, 2005 8:50 pm
    —
It doesn't allow you to kill the dog or move forward, though. That's the whole problem with the "vanishing" in the first place.

#10: Re: [Tutorial] Vanishing Dogs Bug Fix Author: Adam BiserLocation: USA PostPosted: Tue Jun 14, 2005 9:26 pm
    —
What surprises me is that "if (ob->distance < 0)" should never be true for the dog or fake hitler.
In TryWalk, ob->distance is set to the negative door number (-1 more). The doornum is set in CHECKSIDE, but dogobj and fakeobj never use CHECKSIDE. Strange. Maybe I'm missing something though...

#11: Re: [Tutorial] Vanishing Dogs Bug Fix Author: Dugtrio17Location: Seattle PostPosted: Tue Jun 14, 2005 9:49 pm
    —
Chris LIIIIIIIIIIIIVVVEESS... I can die a happy man Smile
Oh, and fine job fixing this annoying bug, WSJ.

#12: Re: [Tutorial] Vanishing Dogs Bug Fix Author: WSJ PostPosted: Wed Jun 15, 2005 5:14 am
    —
Chris is AL-I-I-I-VE! HE'S AL-I-I-I-VE!! AL-I-I-I-VE!!!

Sorry, I love doing that Frankenstein voice. I remember years back when I was new to coding, I figured out how to create a new enemy for the first time, and I was yelling "It's AL-I-I-I-VE! IT'S AL-I-I-I-VE!!"

Cheesy Grin

#13: Re: [Tutorial] Vanishing Dogs Bug Fix Author: TricobLocation: Neo-traditions, Inc. PostPosted: Wed Jun 15, 2005 6:14 pm
    —
Adam Biser wrote:
What surprises me is that "if (ob->distance < 0)" should never be true for the dog or fake hitler.
In TryWalk, ob->distance is set to the negative door number (-1 more). The doornum is set in CHECKSIDE, but dogobj and fakeobj never use CHECKSIDE. Strange. Maybe I'm missing something though...

The door-related code still has some bugs in it that Id never fixed. If you look through the code, you'll see that the code has a "safeguard" to prevent guards from walking through doors if they're not completely open. And yet anyone can walk through a door the instant anyone but the player signals it to open. I'd really like to fix that bug, as it causes the Officers in my Level One of Episode 4 to disappear if you're moving against a door when an Officer signals it to open.

Another "safeguard" that doesn't work: The code checks to see if the maximum length of a recorded demo has been reached, and the demo should end automatically when the maximum length *is* reached. Yet the maximum length can always be exceeded regardless of this so-called "safeguard".

#14: Re: [Tutorial] Vanishing Dogs Bug Fix Author: Adam BiserLocation: USA PostPosted: Thu Jun 16, 2005 6:49 am
    —
Tricob wrote:
If you look through the code, you'll see that the code has a "safeguard" to prevent guards from walking through doors if they're not completely open. And yet anyone can walk through a door the instant anyone but the player signals it to open.
That's a bug I've not seen. The only door-related bug I've seen, which is the one I think this is supposed to fix, is the dog (I think) appearing to jump through a door.
Maybe ob->distance is becoming 0 a different way. Maybe in MoveObj where we have "ob->distance -=move;" but it doesn't check to make sure that "ob->distance" stays 0 or greater.... just rambling.

EDIT: MoveObj isn't it because we check that move < ob->distance before calling it.

#15: Re: [Tutorial] Vanishing Dogs Bug Fix Author: TricobLocation: Neo-traditions, Inc. PostPosted: Thu Jun 16, 2005 6:18 pm
    —
Adam Biser wrote:
Maybe ob->distance is becoming 0 a different way. Maybe in MoveObj where we have "ob->distance -=move;" but it doesn't check to make sure that "ob->distance" stays 0 or greater.... just rambling.

EDIT: MoveObj isn't it because we check that move < ob->distance before calling it.

I think this is connected with the fact that (BLOCK) objects and solid walls can be walked through with the "help" of a Moving Guard. It's possible that the "moving" routine - being it in or out of Attack mode - is restarted (perhaps just for a single cycle) from the beginning, compensating for the positional change. If that's the case, the problem could be fixed by adding a simple "IF" statement in the right part of the code. Just a hypothesis.

#16: Re: [Tutorial] Vanishing Dogs Bug Fix Author: ChrisLocation: Canada PostPosted: Fri Jun 17, 2005 11:40 am
    —
Tricob wrote:
It doesn't allow you to kill the dog or move forward, though. That's the whole problem with the "vanishing" in the first place.

How are you testing this Tricob? The first case I could find was in SOD level 3.

SPEAR1.EXE - Fresh spear code, no changes.
SPEAR2.EXE - Fresh spear code, WSJ's dog chase addition.
SPEAR3.EXE - Fresh spear code, with the spotvis = 1 line.
SAVEGAM0.* - A 1x1 floorcode by a door that makes the dog vanish

http://www.canadianphilatelics.com/choksta/dogtest.zip

Only the exe with the change I posted makes the dog appear (and behave correctly). I can assure you that these exes are 100% real. Feel free to test things out and see what you get though. Whatever the outcome, you're still great in my book WSJ. Pizza

Tricob wrote:
Another "safeguard" that doesn't work: The code checks to see if the maximum length of a recorded demo has been reached, and the demo should end automatically when the maximum length *is* reached. Yet the maximum length can always be exceeded regardless of this so-called "safeguard".

Yeah, I never really liked seeing that "Demo Buffer Overflowed" message either. I just made it so that the level would fade out, then return you to the menu when the limit has been reached. If you want to try that, here's what the end of my PollControls() funtion in WL_PLAY.C looks like:

::: CODE :::
      *demoptr++ = buttonbits;
      *demoptr++ = controlx;
      *demoptr++ = controly;

      if (demoptr >= lastdemoptr-8)
         playstate = ex_completed;
      else
      {

         controlx *= (int)tics;
         controly *= (int)tics;
      }

If you use it in combination with this idea, the game will prompt you with a display of the demo number screen once it's reached the limit too. Still not as fun as seeing the "neverending demo files" that you can achieve with that beta exe on the Demo Recording thread though. What?

Dugtrio17 wrote:
Chris LIIIIIIIIIIIIVVVEESS... I can die a happy man Smile

DATZ AW3ZOME!

#17: Re: [Tutorial] Vanishing Dogs Bug Fix Author: TricobLocation: Neo-traditions, Inc. PostPosted: Fri Jun 17, 2005 7:14 pm
    —
Re: Dogtest.ZIP. Deal. I'll check it out.

I'm sceptical about the savegames part, though. They tend to behave irradically when you run them on anything but the EXE you saved them with. The SAVEGAMx's results would probably be misleading.

Edit: Testing all three EXEs, I warped to Floor 4, which let me get to dogs sooner than Floor 3 would have. I wasn't able to replicate the disappearing dogs bug in any three of the SPEARx.EXE files. *However*, the problem *did* recur when I loaded the saved game in SPEAR1 and SPEAR2. SPEAR3 did something really wacky ... It said the saved game was "Corrupted", than brought me to Floor 17, and hung on a black screen.

I don't really know why your code change works though, since the change is in WL_DRAW, not WL_ACT1 or WL_ACT2. It seems as though the dog bug doesn't exist in SOD at all. The code change mentioned below might say why.

Up until version 1.2 of Wolfenstein 3-D, Id had some maps they didn't release because it had Deaf Guards turn into "Statues", despite the fact that all Floor Codes were correct. This bug often occurs if you place a Deaf Guard in a tight hall, especially in a dead end.

Well, it turns out that the bug does *not* occur if you place a Difficulty 1 Moving Actor in the same room as the Deaf Guard! I imagine Id figured out the same thing, so they figured out what part of the code fixed the problem, placed Spear-exclusive code into the game, and got the maps working (There's still one map-related bug left; Floor 4 has a hidden hall with lots of twists and turns, then a pack of Deaf Guards; one SS in this room is a "living statue" still; a misplaced Floor Code in a single square between four Deaf Guards is the cause of this, and is easily fixable).

Anyway, maybe Id fixed the dog bug when they fixed the "Deaf Guard statue" bug using the same line(s) of code.

Whatever the case, thanks for the Dog fix and Demo fix. Smile

#18: Re: [Tutorial] Vanishing Dogs Bug Fix Author: ChrisLocation: Canada PostPosted: Thu Sep 28, 2017 5:49 am
    —
It seems another way to fix the Dogs Disappearing in Doors is to get rid of the "tilespot" checks in DrawScaleds in WL_DRAW.C:

::: CODE :::
//
// place active objects
//
   for (obj = player->next;obj;obj=obj->next)
   {
      if (!(visptr->shapenum = obj->state->shapenum))
         continue;                  // no shape

      spotloc = (obj->tilex<<6)+obj->tiley;   // optimize: keep in struct?
      visspot = &spotvis[0][0]+spotloc;

      //
      // could be in any of the nine surrounding tiles
      //
      if (*visspot
      || *(visspot-1)
      || *(visspot+1)
      || *(visspot-65)
      || *(visspot-64)
      || *(visspot-63)
      || *(visspot+65)
      || *(visspot+64)
      || *(visspot+63) )

{
         obj->active = true;

Thanks to AryanWolf3D and AlumiuN for talking about "removing tilespot" so that I could notice this added bonus. Laughing

#19: Re: [Tutorial] Vanishing Dogs Bug Fix Author: Aryan_Wolf3D PostPosted: Thu Sep 28, 2017 6:33 am
    —
Haha, so you did test it! Glad to hear it worked! Thumbs Up



DieHard Wolfers -> Code Crackers


output generated using printer-friendly topic mod. All times are GMT

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group