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       

[Code] Wall Patches
Page 2 of 2 Goto page Previous  1, 2
DieHard Wolfers Forum Index -> Code Tutorials 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
Sporb2000
DieHard SS
DieHard SS


Joined: 27 Dec 2004
Last Visit: 26 May 2009

Topics: 19
Posts: 383
Location: New Zealand - Invercargill
newzealand.gif

PostPosted: Thu Apr 28, 2005 9:22 pm
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

flamer46 wrote:
Where getting a bit off-topic here. Anyway. It`s strange. Probably a computer matter. On my Windows 98 comp it looks fine, even with 10 different ceiling textures and 10 different floor textures in view. The same code and map and the same view gives me screen garbage sometimes on my windows ME comp. It`s probably a computer matter.


Could you use these patchs to make shootable walls - IE when you shoot a patch it will dissapear and the wall underneath will be like a buggered version of the patch?

_________________
I Like (Brackets)
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 26 Apr 2017

Topics: 44
Posts: 2264
Location: USA
usa.gif

PostPosted: Fri Apr 29, 2005 5:17 am
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

@Sporb2000: Yes you could. Much like the way I demonstrated with the blood splat in the 2nd or 3rd post of this thread. I would have to be coded out a bit more though.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
Guest




Last Visit:





PostPosted: Sat Aug 27, 2005 9:59 pm
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Would it be possible to check to see what patch is applied to a wall and manipulate it in the same way as the elevator tile? (IE, advance the patch by one tile one 'used'). I know how to do this with normal walls but I was thinking it would be vary useful if it could be done with patches too. You could put like an ammo rack or switch or whatever on any wall you wanted instead of having it constrained to the full sized texture.
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 26 Apr 2017

Topics: 44
Posts: 2264
Location: USA
usa.gif

PostPosted: Sat Aug 27, 2005 10:51 pm
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

@kalnaren: Yes, you can and basically all you'd have to do is deal with the object plane value instead of the wall plane value. It shouldn't be hard to do at all.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
Guest




Last Visit:





PostPosted: Wed Aug 31, 2005 3:57 pm
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Well, I found out how to use the patches as switches, ammo racks, etc, etc. It was actually a lot simpler than I thought it was. But now I have a problem I can't seem to solve. My FPS takes a MASSIVE dive (I mean, unplayable) when looking at a patch on an E/W wall (Ie, a patch viewed from the N/S). I've gone over my code and didn't notice any problems. Patches viewed from the E/W don't lower framerate at all. Any thoughts?
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 26 Apr 2017

Topics: 44
Posts: 2264
Location: USA
usa.gif

PostPosted: Wed Aug 31, 2005 10:54 pm
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

It sounds like you forgot to do the change to either HitVertWall or HitHorizWall... you might want to check the end of the tutorial again.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
insurrectionman
DieHard Officer
DieHard Officer


Joined: 07 May 2005
Last Visit: 6:55 ago.

Topics: 83
Posts: 739
Location: Wisconsin
usa.gif

PostPosted: Wed Jun 21, 2006 8:32 am
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

It is possible to combine this with the Switch Activated Pushwalls? Because this would save a crapload of walls for switches. I put the wall patch placement in the 3rd plane instead of the 2nd. I think that may be a good start.

_________________
I'm back! I missed this community!
Youtube Channel: TreeSapThief

New Site: [url=http://www.treesapthief.com/[/url]
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 26 Apr 2017

Topics: 44
Posts: 2264
Location: USA
usa.gif

PostPosted: Wed Jun 21, 2006 8:53 am
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I think this would already work for the actual switch wall, but I think you mean to have patches on the pushwalls themselves, right? That's very possible and doesn't necessarily require a 3rd plane. I did this in Orb using only the object plane. I'll come up with a short tutorial addendum for this, just give me some time.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 26 Apr 2017

Topics: 44
Posts: 2264
Location: USA
usa.gif

PostPosted: Tue Jun 27, 2006 6:47 am
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

OK, I think this is all the code for making wall patches work on pushwalls. Basically what happens is that I define object codes for patched pushwalls, one for each patch, starting at 1000. ie: object 1000 is both a pushwall and has the first patch.

Hopefully I found all the code for this... the changes are pretty involved...

First, I move all the patch #defines to WL_DEF.H. Anywhere in the file should be good.
::: CODE :::
#define FIRSTPATCHOBJ    500
#define NUMPATCHES       2   // This is the number of patch pairs (light/dark) in use.
#define PATCHSTART       DOORWALL-NUMPATCHES*2

I then add this line:
::: CODE :::
#define SECRETPATCHOBJ   FIRSTPATCHOBJ+500

This sets the object code of the first patched pwall to 1000.

Find "extern int pwalldir;" in the same file and change it to:
::: CODE :::
extern int         pwalldir,pwallpatch;


Next I made the objects count as pwalls.
Open WL_GAME.C. Find ScanInfoPlane and scroll to the bottom of the huge switch list and add this:
::: CODE :::
         if (!loadedgame)
         {
            // convert patched secrets also.
            if (tile >= SECRETPATCHOBJ) && (tile < SECRETPATCHOBJ+NUMPATCHES)
            {
               gamestate.secrettotal++;
            }
         }


Open WL_ACT1.C and find
::: CODE :::
int         pwalldir;

change to
::: CODE :::
int         pwalldir,pwallpatch;

pwallpatch stores the patch number while the pushwall is in motion.

Now find "void PushWall" in the same file and insert this code right before "gamestate.secretcount++;"
::: CODE :::
   if ((MAPSPOT(checkx,checky,1) >= SECRETPATCHOBJ) && (MAPSPOT(checkx,checky,1) < SECRETPATCHOBJ+NUMPATCHES))
      pwallpatch=MAPSPOT(checkx,checky,1)-500;
   else
      pwallpatch=0;


Find "void StopPWall" (same file) and add this to it:
::: CODE :::
   if (pwallpatch)
   {
      //patched pwalls can't stop on a non-zero object code.
      if (MAPSPOT(pwallx,pwally,1))
      {
         Quit("Patched pwall stopped on an object");
      }
      MAPSPOT(pwallx,pwally,1)=pwallpatch;
   }


Now open WL_DRAW.C And replace your GetPatchNum routine with this one:
::: CODE :::
unsigned GetPatchNum(boolean ispwall)
{
   unsigned spot;

   if (!patchesenabled)
      return 0;
   if (ispwall)
      return pwallpatch;
   spot = MAPSPOT(xtile,ytile,1);
   // Restrict patch objects to the given range.
   if (spot >= SECRETPATCHOBJ && spot < SECRETPATCHOBJ+NUMPATCHES)
      return spot-1000;
   if (spot < FIRSTPATCHOBJ || spot >= FIRSTPATCHOBJ+NUMPATCHES)
      return 0;
   return spot;
}


Also change
::: CODE :::
boolean ApplyPatch(int wallpic)

to
::: CODE :::
boolean ApplyPatch(int wallpic, boolean ispwall)

and then inside that routine change
::: CODE :::
spot = GetPatchNum();

to
::: CODE :::
spot = GetPatchNum(ispwall);


The first few lines of "AssignWall" become:
::: CODE :::
void AssignWall(int wallpic, boolean ispwall)
{
   if (ApplyPatch (wallpic,ispwall))


Now change everywhere you currently have "AssignWall (wallpic);" to "AssignWall (wallpic,false);" and also everywhere you have "GetPatchNum()" to "GetPatchNum(false)".

Now change these lines in both "HitHorizPWall" and "HitVertPWall"...
::: CODE :::
if (lasttilehit == tilehit)
<snip>
*( ((unsigned *)&postsource)+1) = (unsigned)PM_GetPage(wallpic);

to
::: CODE :::
if (lasttilehit == tilehit && lastpatchnum == GetPatchNum(true))
<snip>
AssignWall (wallpic,true);


I think that gets everything but making sure things save properly. The thing that sucks is that you now have to save the object plane so it remembers that the pushed patched pwalls are still patched.

Now open WL_MAIN.C and find "SaveTheGame"
Right before the function add
::: CODE :::
#define objplanesize  MAPSIZE*MAPSIZE*2


Right after "sizeof(actorat) +" add
::: CODE :::
objplanesize  +

Then find "sizeof(pwalldir) +" and add
::: CODE :::
sizeof(pwallpatch) +


Now below "checksum = DoChecksum((byte far *)actorat,sizeof(actorat),checksum);" add:
::: CODE :::
   DiskFlopAnim(x,y);
   CA_FarWrite (file,(void far *)mapsegs[1],objplanesize);
   checksum = DoChecksum((byte far *)mapsegs[1],objplanesize,checksum);


Then find "checksum = DoChecksum((byte far *)&pwalldir,sizeof(pwalldir),checksum);" and add
::: CODE :::
   CA_FarWrite (file,(void far *)&pwallpatch,sizeof(pwallpatch));
   checksum = DoChecksum((byte far *)&pwallpatch,sizeof(pwallpatch),checksum);


Now go to LoadTheGame and find "checksum = DoChecksum((byte far *)actorat,sizeof(actorat),checksum);" and add:
::: CODE :::
   DiskFlopAnim(x,y);
   CA_FarRead (file,(void far *)mapsegs[1],objplanesize);
   checksum = DoChecksum((byte far *)mapsegs[1],objplanesize,checksum);

And after "checksum = DoChecksum((byte far *)&pwalldir,sizeof(pwalldir),checksum);" add
::: CODE :::
   CA_FarRead (file,(void far *)&pwallpatch,sizeof(pwallpatch));
   checksum = DoChecksum((byte far *)&pwallpatch,sizeof(pwallpatch),checksum);



I hope that's it.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
insurrectionman
DieHard Officer
DieHard Officer


Joined: 07 May 2005
Last Visit: 6:55 ago.

Topics: 83
Posts: 739
Location: Wisconsin
usa.gif

PostPosted: Tue Jun 27, 2006 9:25 am
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

This isn't exactly what i meant, i want the patch to be the switch and the patch is to change frames like a switch.

_________________
I'm back! I missed this community!
Youtube Channel: TreeSapThief

New Site: [url=http://www.treesapthief.com/[/url]
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 26 Apr 2017

Topics: 44
Posts: 2264
Location: USA
usa.gif

PostPosted: Tue Jun 27, 2006 4:23 pm
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Well, in that case, just set up a patch, say number 500, and when you flip the switch, it scans the object plane changing 500s to 501s.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
insurrectionman
DieHard Officer
DieHard Officer


Joined: 07 May 2005
Last Visit: 6:55 ago.

Topics: 83
Posts: 739
Location: Wisconsin
usa.gif

PostPosted: Tue Jun 27, 2006 8:29 pm
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Well, I'd have to set it in the Cmd_Use function, but i don't know what to replace the line:

::: CODE :::
else if (!buttonheld[bt_use] && doornum >= SWITCHTILE)
   {
      buttonheld[bt_use] = true;
      if (doornum >= SWITCHTILE && doornum <=SWITCHTILE+7)
      {
         switch (doornum)

_________________
I'm back! I missed this community!
Youtube Channel: TreeSapThief

New Site: [url=http://www.treesapthief.com/[/url]
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 26 Apr 2017

Topics: 44
Posts: 2264
Location: USA
usa.gif

PostPosted: Tue Jun 27, 2006 8:41 pm
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Here's what you'd have to do:
::: CODE :::
   if (!buttonheld[bt_use] && MAPSPOT(checkx,checky,1) >= SWITCHTILE)
   {
      buttonheld[bt_use] = true;

      MAPSPOT(checkx,checky,1)++;      // flip switch by incrementing the patch number
etc...

Unless this switch ends the level, you'll have to save the object plane to your save files. That code is at the end of the long tutorial post starting with 'Now open WL_MAIN.C and find "SaveTheGame"'.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
the_fish
Bring 'em On
Bring 'em On


Joined: 18 Nov 2006
Last Visit: 07 Nov 2008

Topics: 12
Posts: 133
Location: England
uk.gif

PostPosted: Sun Dec 10, 2006 1:42 pm
   Subject: Wall Patches for Ripper's Wolf4GW
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I'm working on a TC based on Ripper's 4GW engine, and found adapting this tutorial to be particularly thorny. I won't go into too many details (the ApplyPatch function has to be changed in the standard way to reference the new page system), but the MOST annoying thing which I spent days finding out is that the xtile and ytile variables now do different things to before. Evil or Very Mad

So for anyone who wants to have patches in 4GW, replace the GetPatchNum code with this:

::: CODE :::

unsigned GetPatchNum(boolean useXspot)
{
    // work off xspot/yspot, instead of xtile/ytile
    unsigned spot, x, y;
    (useXspot? spot=xspot : spot=yspot);

    x = (unsigned)((spot+1)/64);
    y = (unsigned)((spot+1)%64) -1;
   
    spot = MAPSPOT(x,y,1);
// Restrict patch objects to the given range.
   if (spot < FIRSTPATCHOBJ || spot >= FIRSTPATCHOBJ+NUMPATCHES )
      return 0;
   else
      return spot;

}


The 'useXspot' boolean is set to TRUE in the case of VertWalls and FALSE in the case of HorizWalls. 'ApplyPatch' will also have to have this extra argument as it calls GetPatchNum as well (or this boolean could be set as a global flag somewhere, but I don't code like that).

Sorry if this is confusing, I can write it out in full if requested, just thought I should summarise the trickiest bit. I really don't recommend mucking around with 4GW unless you are familiar with C/C++ or can somehow abduct and interrogate Ripper Razz .

the_fish
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 14 Jul 2007

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Wed Jan 10, 2007 12:15 pm
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I'm just making a small note: the fps is dropping (20/35) when a wall patch (or more), an enemy (or more) and a multi-texture ceiling/floor is drawn at the same time. The enemy is the badguy here, because without enemy being drawn, it works fine. I can't tell whether it's my code or in general. I'm just making sure this is taken into account, and just to note it.

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
the_fish
Bring 'em On
Bring 'em On


Joined: 18 Nov 2006
Last Visit: 07 Nov 2008

Topics: 12
Posts: 133
Location: England
uk.gif

PostPosted: Tue Jan 16, 2007 4:21 am
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

@lymxnedtodth: That's weird, as the code for patches/flats is completely independent of that for drawing sprites (ScaleShape). The biggest hit to framerate from patches is drawing the patch to the wall in the temporary byte array - this is the point of the
::: CODE :::

&& lastpatchnum == GetPatchNum()

bit in the Hit...Wall functions. Though as omitting this would cause EXTREME framerate drop, I don't think thats your problem.

Could be something to do with Page requests? I'm working with 4GW, so don't have this problem, but it could be that the increased loading/reloading of pages into memory is causing massive slowdown. It's all I can think of.

_________________
Mostly away: revising for finals (argh!)
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 14 Jul 2007

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Tue Jan 16, 2007 11:33 pm
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Definately. The drawing is not an issue. I encounter a great drop (1Cool when say 5 to 10 patches, with 1 or more enemies, a few sprites and a few directional sprites are drawn. That should be the page request. Somehow the drop is bigger or happens faster when the sprites are placed near each other in the vswap (say render chunk 1,2 and 3 at the same time.)

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
fraggeur
DieHard Guard
DieHard Guard


Joined: 31 Dec 2012
Last Visit: 13 Apr 2017

Topics: 11
Posts: 254

blank.gif

PostPosted: Sat Feb 27, 2016 2:34 pm
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

(Sorry for the 9 years up)

I am trying to implement wall patches and I get a "interesting" issue.

When I look at my patched wall and rotate my sight (player turning his head - especially to the right), the patched wall slides too (horizontal scrolling) to follow where my weapon aims.

Let's say that

WW = normal wall
XY = patched wall
[ and ] = screen borders

I have this in front of me. As long as I have the 3 walls in my field of view, it behaves correctly.
[WW XY WW]

if I rotate to the right and lose the left WW from my vision, the XY texture start sliding and I get something like this
WW ?[X WW]

If I rotate more, I get something like this
WW ??[ WW]


If I rotate back to the left, the XY reappears progressively.

Any clue?
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 7:47 ago.

Topics: 34
Posts: 2252
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Sun Feb 28, 2016 9:17 pm
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Can I see your HitHorizWall and HitVertWall functions? My guess is that something is messing with postsource's incrementing.
fraggeur
DieHard Guard
DieHard Guard


Joined: 31 Dec 2012
Last Visit: 13 Apr 2017

Topics: 11
Posts: 254

blank.gif

PostPosted: Mon Feb 29, 2016 2:57 pm
   Subject: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

That is very possible, I tried to adapt for Wolf4SDL, using for example GetTexture instead of GetPage, etc. Embarassed
Please see here my code:

::: CODE :::

void HitVertWall (void)
{
    int wallpic;
    int texture;

    texture = ((yintercept+texdelta)>>TEXTUREFROMFIXEDSHIFT)&TEXTUREMASK;
    if (xtilestep == -1)
    {
        texture = TEXTUREMASK-texture;
        xintercept += TILEGLOBAL;
    }

    if(lastside==1 && lastintercept==xtile && lasttilehit==tilehit && !(lasttilehit & /*0x40*/ BIT_WALL) && lastpatchnum == GetPatchNum())
    {
        if((pixx&3) && texture == lasttexture)
        {
            ScalePost();
            postx = pixx;
            wallheight[pixx] = wallheight[pixx-1];
            return;
        }
        ScalePost();
        wallheight[pixx] = CalcHeight();
        postsource+=texture-lasttexture;
        postwidth=1;
        postx=pixx;
        lasttexture=texture;
        return;
    }

    if(lastside!=-1) ScalePost();

    lastside=1;
    lastintercept=xtile;
    lasttilehit=tilehit;
    lasttexture=texture;
    wallheight[pixx] = CalcHeight();
    postx = pixx;
    postwidth = 1;

    if (tilehit & /*0x40*/ BIT_WALL)
    {                                                               // check for adjacent doors
        ytile = (short)(yintercept>>TILESHIFT);
        if ( tilemap[xtile-xtilestep][ytile]&/*0x80*/BIT_DOOR )
            wallpic = DOORWALL+3;
        else
            wallpic = vertwall[tilehit & ~/*0x40*/BIT_WALL];
    }
    else
        wallpic = vertwall[tilehit];

    //postsource = PM_GetTexture(wallpic) + texture;
    AssignWall (wallpic,texture);
}

void HitHorizWall (void)
{
    int wallpic;
    int texture;

    texture = ((xintercept+texdelta)>>TEXTUREFROMFIXEDSHIFT)&TEXTUREMASK;
    if (ytilestep == -1)
        yintercept += TILEGLOBAL;
    else
        texture = TEXTUREMASK-texture;

    if(lastside==0 && lastintercept==ytile && lasttilehit==tilehit && !(lasttilehit & /*0x40*/BIT_WALL) && lastpatchnum == GetPatchNum())
    {
        if((pixx&3) && texture == lasttexture)
        {
            ScalePost();
            postx=pixx;
            wallheight[pixx] = wallheight[pixx-1];
            return;
        }
        ScalePost();
        wallheight[pixx] = CalcHeight();
        postsource+=texture-lasttexture;
        postwidth=1;
        postx=pixx;
        lasttexture=texture;
        return;
    }

    if(lastside!=-1) ScalePost();

    lastside=0;
    lastintercept=ytile;
    lasttilehit=tilehit;
    lasttexture=texture;
    wallheight[pixx] = CalcHeight();
    postx = pixx;
    postwidth = 1;

    if (tilehit & /*0x40*/BIT_WALL)
    {                                                               // check for adjacent doors
        xtile = (short)(xintercept>>TILESHIFT);
        if ( tilemap[xtile][ytile-ytilestep]&/*0x80*/BIT_DOOR)
            wallpic = DOORWALL+2;
        else
            wallpic = horizwall[tilehit & ~/*0x40*/BIT_WALL];
    }
    else
        wallpic = horizwall[tilehit];

    //postsource = PM_GetTexture(wallpic) + texture;
    AssignWall (wallpic,texture);
}


void AssignWall(int wallpic,int texture)
{
   if (ApplyPatch (wallpic))
      //*( ((unsigned *)&postsource)+1) = (unsigned)(memptr)patchedwall;
      postsource = patchedwall;
   else
      //*( ((unsigned *)&postsource)+1) = (unsigned)PM_GetPage(wallpic);
      postsource = PM_GetTexture(wallpic) + texture;
}

boolean ApplyPatch(int wallpic)
{
      byte   *scan;
      int    pixel;
      unsigned spot;

   spot = GetPatchNum();
   if (spot > 0 && wallpic < DOORWALL) // Don't do door-related textures.
   {
      // Keep track of the patch in memory.
      //   The wall is already stored elsewhere.
      lastpatchnum = spot;
      spot -= FIRSTPATCHOBJ;
      // Adjust for light/dark patch sides
      spot = spot * 2 + (lastside?1:0);
      // Load the wall into the byte array first.
         scan = PM_GetTexture(wallpic);//PM_GetPage(wallpic);
         for (pixel=0; pixel<PMPageSize; pixel++,scan++)
          patchedwall[pixel] = *scan;
      // Now add the patch. This MUST be done separate from wallpic's page.
         scan = PM_GetTexture(PATCHSTART+spot);//PM_GetPage(PATCHSTART+spot);
         for (pixel=0; pixel<PMPageSize; pixel++,scan++)
          if (*scan < 255)
             patchedwall[pixel] = *scan;
      return true;
   }
   lastpatchnum = 0;
   return false;
}
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 7:47 ago.

Topics: 34
Posts: 2252
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Mon Feb 29, 2016 4:40 pm
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Ah, there's the problem - in AssignWall, the line:

::: CODE :::
postsource = patchedwall;


should be:

::: CODE :::
postsource = patchedwall + texture;


The reason this only happened when the wall was at the left edge of the screen is because texture is always 0 when this function is called unless the start of that wall is off the left of the screen, when it will be the offset of the column to start drawing on; as a result, the texture was always drawn as if it was drawing the texture from the very start, regardless of whether part of the texture should have been off-screen.
fraggeur
DieHard Guard
DieHard Guard


Joined: 31 Dec 2012
Last Visit: 13 Apr 2017

Topics: 11
Posts: 254

blank.gif

PostPosted: Thu Mar 03, 2016 11:29 am
   Subject: Re: [Code] Wall Patches
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Aaaaah my bad! That's why it works well for the non-patched walls though I modified the function... Thanks for having pointed it Smile
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> Code Tutorials View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 2 of 2 Goto page Previous  1, 2
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts [Code] Display Different Ammo Types on Statusbar-BrotherTank
Author: BrotherTank
1 2127 Fri Feb 11, 2005 9:18 pm
Zombie_Plan View latest post
No new posts [Code] Adding a Frames per Second Counter - Darkone
Author: BrotherTank
0 1506 Sat Mar 13, 2004 2:07 pm
BrotherTank View latest post
No new posts [Code] Changing an Enemies Attack Strength - BrotherTank
Author: BrotherTank
0 1755 Tue Jan 27, 2004 10:29 am
BrotherTank View latest post
No new posts [Code] Changing Weapons -CheckWeaponChange- BrotherTank
Author: BrotherTank
2 2426 Sun Oct 26, 2003 1:21 am
Guest View latest post
No new posts [Help] Different Enemy Dying Frames/Views
Author: Guest
7 605 Tue Jul 29, 2003 3:00 pm
Codetech84 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