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       

MAXWALLTILES/MAXDOORS - Removing the hard coded limits
Page 1 of 1
DieHard Wolfers Forum Index -> SDL Code Crackers 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
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

Topics: 55
Posts: 2115
Location: Canada
blank.gif

PostPosted: Mon Sep 21, 2009 5:46 pm
   Subject: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

I noticed that with the factory settings of SDL, most things are very easy to adjust (like MAXACTORS, MAXSTATS, MAPSHIFT, NUMFLOORS, NUMVISABLE, etc.) just by changing the number in the define, which is pretty cool. Party

One area that is still not so easy to change though, is MAXWALLTILES and MAXDOORS.

Currently, the walls and wall sides use up to bit6 (1<<6), and the doors use up to bit7 (1<<7.). The most practical way around this restriction, in my opinion, would be to change tilemap from a byte to an int and get rid of the "magic numbers" (0x40, 0x80, 0x7f, etc.) for the 'tilemap bit separation' by using an adjustable #define to control the bits used instead.

Here's some new MAXDOORS/MAXWALLS options that this method would open up:

::: CODE :::
WALLBIT  MAXDOORS/MAXWALLS       BINARY                      HEX

6             doors 128, walls 64       0000 0000 dw00 0000       Dx0080, Wx0040
7             doors 256, walls 128      0000 000d w000 0000       Dx0100, Wx0080
8             doors 512, walls 256      0000 00dw 0000 0000       Dx0200, Wx0100
9             doors 1024, walls 512    0000 0dw0 0000 0000       Dx0400, Wx0200
10           doors 2048, walls 1024   0000 dw00 0000 0000       Dx0800, Wx0400
11           doors 4096, walls 2048   000d w000 0000 0000       Dx1000, Wx0800
12           doors 8192, walls 4096   00dw 0000 0000 0000       Dx2000, Wx1000
13           doors 16384, wall 8192   0dw0 0000 0000 0000       Dx4000, Wx2000

I threw together a patch for WolfSDL_v1.6 that uses this idea, if anyone wants to try it:

http://chokfiles.webs.com/bitshift.rar

The default is #define WALLSHIFT 10, which lets you use up to 1024 walls and 2048 doors.
To restore it back to the default amount of walls/doors, just change it to use #define WALLSHIFT 6.

p.s. How is everyone currently getting extra walls into their addons (and how many textures do you use)? Just curious.



Here's the actual code adjustments I did in the SDL source for this idea to work...

* The code in blue denotes stuff for changing TILEMAP to an int.
* The code in red denotes stuff for replacing the "magic numbers" with defines.
* The code in purple denotes an example of how to load the newtiles from the gamemaps file.
(all the walls can be loaded into the level using mapdefs 1001+ (0x3E9), as shown in the included map/list for WDC.)


In WL_DEF.H:

::: CODE :::
#define MAXTICS 10
#define DEMOTICS        4

#define WALLSHIFT       10

#define BIT_WALL        (1<<WALLSHIFT)
#define BIT_DOOR        (1<<(WALLSHIFT+1))
#define BIT_ALLTILES    (1<<(WALLSHIFT+2))
#define LAST_WALLNUM    BIT_WALL-1
#define LAST_DOORNUM    BIT_DOOR-1


#define MAXACTORS       150         // max number of nazis, etc / map
#define MAXSTATS        400         // max number of lamps, bonus, etc
#define MAXDOORS        BIT_DOOR   // max number of sliding doors
#define MAXWALLTILES    BIT_WALL   // max number of wall tiles

::: CODE :::
extern  uint16_t        tilemap[MAPSIZE][MAPSIZE];      // wall values only

::: CODE :::
extern word      pwalldir,pwalltile;


In WL_ACT1.CPP:

1. SpawnStatic()
::: CODE :::
            case block:
            actorat[tilex][tiley] = (objtype *) BIT_WALL;          // consider it a blocking tile

2. SpawnDoor()
::: CODE :::
    actorat[tilex][tiley] = (objtype *)(uintptr_t)(doornum | BIT_DOOR);   // consider it a solid wall

    //
    // make the door tile a special tile, and mark the adjacent tiles
    // for door sides
    //
    tilemap[tilex][tiley] = doornum | BIT_DOOR;
    map = mapsegs[0] + (tiley<<mapshift) +tilex;
    if (vertical)
    {
        *map = *(map-1);                        // set area number
        tilemap[tilex][tiley-1] |= BIT_WALL;
        tilemap[tilex][tiley+1] |= BIT_WALL;
    }
    else
    {
        *map = *(map-mapwidth);                                 // set area number
        tilemap[tilex-1][tiley] |= BIT_WALL;
        tilemap[tilex+1][tiley] |= BIT_WALL;
    }

3. CloseDoor()
::: CODE :::
    //
    // make the door space solid
    //
    actorat[tilex][tiley] = (objtype *)(uintptr_t)(door | BIT_DOOR);

4. DoorClosing()
::: CODE :::
    if ( ((int)(uintptr_t)actorat[tilex][tiley] != (door | BIT_DOOR))
        || (player->tilex == tilex && player->tiley == tiley) )

5. Above PushWall()
::: CODE :::
word pwalldir,pwalltile;

6. PushWall()
::: CODE :::
    pwalltile = tilemap[pwallx][pwally];
    tilemap[pwallx][pwally] = BIT_WALL;
    tilemap[pwallx+dx][pwally+dy] = BIT_WALL;

7. MovePWalls()
::: CODE :::
            actorat[pwallx+dx][pwally+dy] = (objtype *)(uintptr_t) (tilemap[pwallx+dx][pwally+dy] = oldtile);
            tilemap[pwallx+dx][pwally+dy] = BIT_WALL;


In WL_AGENT.CPP:

1. Cmd_Use()
::: CODE :::
    else if (!buttonheld[bt_use] && doornum & BIT_DOOR)
    {
        buttonheld[bt_use] = true;
        OperateDoor (doornum & ~BIT_DOOR);
    }


In WL_DEBUG.CPP:

1. BasicOverhead()
::: CODE :::
            else if (MAPSPOT(x,y,1) == PUSHABLETILE) color = 171;  // pushwall
            else if (tile == BIT_WALL) color = 158; // solid obj
            else if (tile < BIT_DOOR) color = 154;  // walls
            else if (tile < BIT_ALLTILES) color = 146;  // doors

2. DebugKeys (Keyboard[sc_F])
::: CODE :::
        US_Print (" 3:");
        if ((unsigned)(uintptr_t)actorat[player->tilex][player->tiley] < BIT_ALLTILES)


In WL_DRAW.CPP:

1. HitVertWall()
::: CODE :::
    if(lastside==1 && lastintercept==xtile && lasttilehit==tilehit && !(lasttilehit & BIT_WALL))

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

2. HitHorizWall()
::: CODE :::
    if(lastside==0 && lastintercept==ytile && lasttilehit==tilehit && !(lasttilehit & BIT_WALL))

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

3. HitHorizDoor()
::: CODE :::
    doornum = tilehit&LAST_DOORNUM;
    texture = ((xintercept-doorposition[doornum])>>TEXTUREFROMFIXEDSHIFT)&TEXTUREMASK;

4. HitVertDoor()
::: CODE :::
    doornum = tilehit&LAST_DOORNUM;
    texture = ((yintercept-doorposition[doornum])>>TEXTUREFROMFIXEDSHIFT)&TEXTUREMASK;

5. HitHorizPWall()
::: CODE :::
    wallpic = horizwall[pwalltile&BIT_WALL];

6. HitVertPWall()
::: CODE :::
    wallpic = vertwall[pwalltile&BIT_WALL];

7. DrawScaleds()
::: CODE :::
void DrawScaleds (void)
{
    int      i,least,numvisable,height;
    byte     *visspot;
    uint16_t *tilespot;

    unsigned spotloc;

8. AsmRefresh()
::: CODE :::
    int32_t xstep,ystep;
    longword xpartial,ypartial;
    boolean playerInPushwallBackTile = tilemap[focaltx][focalty] == BIT_WALL;

::: CODE :::
            tilehit=((uint16_t *)tilemap)[xspot];
            if(tilehit)
            {
                if(tilehit&BIT_DOOR)
                {
                    int32_t yintbuf=yintercept+(ystep>>1);
                    if((yintbuf>>16)!=(yintercept>>16))
                        goto passvert;
                    if((word)yintbuf<doorposition[tilehit&LAST_DOORNUM])
                        goto passvert;

::: CODE :::
                    if(tilehit==BIT_WALL)
                    {
                        if(pwalldir==di_west || pwalldir==di_east)

::: CODE :::
            tilehit=((uint16_t *)tilemap)[yspot];
            if(tilehit)
            {
                if(tilehit&BIT_DOOR)
                {
                    int32_t xintbuf=xintercept+(xstep>>1);
                    if((xintbuf>>16)!=(xintercept>>16))
                        goto passhoriz;
                    if((word)xintbuf<doorposition[tilehit&LAST_DOORNUM])
                        goto passhoriz;

::: CODE :::
                    if(tilehit==BIT_WALL)
                    {
                        if(pwalldir==di_north || pwalldir==di_south)


In WL_GAME.CPP:

1. SetupGameLevel()
::: CODE :::
//
// copy the wall data to a data segment array
//
    #define NEWTILE_OFFSET  1000

    memset (tilemap,0,sizeof(tilemap));
    memset (actorat,0,sizeof(actorat));
    map = mapsegs[0];
    for (y=0;y<mapheight;y++)
    {
        for (x=0;x<mapwidth;x++)
        {
            tile = *map++;
            if (tile<AREATILE)
            {
                // solid wall
                tilemap[x][y] = (byte) tile;
                actorat[x][y] = (objtype *)(uintptr_t) tile;
            }
            else if (tile>=NEWTILE_OFFSET && tile < (NEWTILE_OFFSET+MAXWALLTILES))
            {
                tilemap[x][y] = tile - NEWTILE_OFFSET;
                actorat[x][y] = (objtype *)(uintptr_t) (tile - NEWTILE_OFFSET);
            }

            else
            {
                // area floor
                tilemap[x][y] = 0;
                actorat[x][y] = 0;
            }
        }
    }


In WL_PLAY.CPP:

::: CODE :::
uint16_t tilemap[MAPSIZE][MAPSIZE]; // wall values only


In WL_STATE.CPP:

1. Above TryWalk()
::: CODE :::
#define CHECKDIAG(x,y)                              \
{                                                   \
    temp=(uintptr_t)actorat[x][y];                  \
    if (temp)                                       \
    {                                               \
        if (temp<BIT_ALLTILES)                               \
            return false;                           \
        if (((objtype *)temp)->flags&FL_SHOOTABLE)  \
            return false;                           \
    }                                               \
}

#ifdef PLAYDEMOLIKEORIGINAL
    #define DOORCHECK                                   \
            if(DEMOCOND_ORIG)                           \
                doornum = temp&63;                      \
            else                                        \
            {                                           \
                doornum = (int) temp & LAST_DOORNUM;    \
                OpenDoor(doornum);                      \
                ob->distance = -doornum - 1;            \
                return true;                            \
            }
#else
    #define DOORCHECK                                   \
            doornum = (int) temp & LAST_DOORNUM;        \
            OpenDoor(doornum);                          \
            ob->distance = -doornum - 1;                \
            return true;
#endif

#define CHECKSIDE(x,y)                                  \
{                                                       \
    temp=(uintptr_t)actorat[x][y];                      \
    if (temp)                                           \
    {                                                   \
        if (temp<BIT_DOOR)                              \
            return false;                               \
        if (temp<BIT_ALLTILES)                          \
        {                                               \
            DOORCHECK                                   \
        }                                               \
        else if (((objtype *)temp)->flags&FL_SHOOTABLE) \
            return false;                               \
    }                                                   \
}

2. CheckLine()
::: CODE :::
            if (value<BIT_DOOR || value>BIT_ALLTILES)
                return false;

            //
            // see if the door is open enough
            //
            value &= ~BIT_DOOR;
            intercept = yfrac-ystep/2;

::: CODE :::
            if (value<BIT_DOOR || value>BIT_ALLTILES)
                return false;

            //
            // see if the door is open enough
            //
            value &= ~BIT_DOOR;
            intercept = xfrac-xstep/2;



Looks like a lot of editing... but that's only because there was many hard coded numbers in there! Laughing
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 1:23 ago.

Topics: 160
Posts: 8008
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Mon Sep 21, 2009 8:09 pm
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Awesome work, Chris! This will change mapping limits of Wolf4SDL forever. Too Cool

Chris wrote:
p.s. How is everyone currently getting extra walls into their addons (and how many textures do you use)? Just curious.
BT posted his source code called "Bunker4SDL", which has 90 Walls code and many other features. They include:

* Wall Patches
* Blake Stone-style opening/closing doors
* Different door sides
* DarkOne's AI routines
* Animated Walls
* Floating keys
* Animated sprites
* Warp Player code

... and more. WolfDX uses the Bunker4SDL code as a base (using 90 walls currently, but will use at least 20 Wall Patches), but it still has many features I'm doing from scratch (and some features already in that I'm re-doing myself, such as the Teleport code).
Dean
Moderator
<B>Moderator</B>


Joined: 10 Jan 2006
Last Visit: 23 Oct 2016

Topics: 52
Posts: 2187
Location: Australia
australia.gif

PostPosted: Tue Sep 22, 2009 6:00 am
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Outstanding work as usual Chris! Thanks for taking the time to look at the SDL code and share this with everyone. Smile

_________________
The Wolfenstein 3d Blog
The Wolfenstein 3d Blog is now on Facebook!

"Strong minds discuss ideas, average minds discuss events, weak minds discuss people" - Socrates
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

Topics: 55
Posts: 2115
Location: Canada
blank.gif

PostPosted: Tue Sep 22, 2009 11:36 am
   Subject: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Cool. It's nice that Brothertank ported a lot of his features and structural ideas from Wolf Advanced over! Thumbs Up

I thought the original demos would act differently from this (and that more adjustments would have to be made to get them to play correctly again), but it looks like changing the tilemap size doesn't affect the behavior of the random tables at all!

Another interesting thing, is that, using RLEW and Carmack compression on a 16-bit tilemap when saving your game (like they did for the gamemaps data) would technically work much better now. Although maybe that's being a little overzealous. Laughing
Airslide
Don't Hurt Me
Don't Hurt Me


Joined: 08 Aug 2005
Last Visit: 02 Jan 2011

Topics: 8
Posts: 60

blank.gif

PostPosted: Wed Sep 23, 2009 8:51 pm
   Subject: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I thought of this just a few days ago, didn't think it'd take that many changes though Laughing

Good job Thumbs Up
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 1:23 ago.

Topics: 160
Posts: 8008
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Thu Sep 24, 2009 8:27 pm
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

How will this code react if the 90 Walls code from BT's Bunker source is already enabled? Confused
RichterBelmont12
DieHard Wolfer
DieHard Wolfer


Joined: 14 Aug 2004
Last Visit: 13 Nov 2017

Topics: 97
Posts: 1505
Location: New Jersey
usa.gif

PostPosted: Tue May 10, 2011 8:35 pm
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I'm sorry for bumping this but I have a Problem

I have Milti Door slides to identify Locked doors soo i added this as normal

::: CODE :::
 if (tilehit & BIT_WALL)
      {                        // check for adjacent doors
         ytile = yintercept>>TILESHIFT;
         tile = tilemap[xtile-xtilestep][ytile];
         if (tile & BIT_DOOR)
         {
            switch(doorobjlist[tile & BIT_WALL].lock)
            { 
               case dr_lock1:
                  wallpic = DOORWALL+5;
                  break;
               case dr_lock2:
                  wallpic = DOORWALL+7;
                  break;
               case dr_lock3:
                  wallpic = DOORWALL+9;
                  break;
               case dr_lock4:
                  wallpic = DOORWALL+11;
                  break;
               case dr_lock5:
                  wallpic = DOORWALL+13;
                  break;
               case dr_lock6:
                  wallpic = DOORWALL+15;
                  break;
               default:
                  wallpic = DOORWALL+3;
                  break;
            }
         }
         else
            wallpic = vertwall[tilehit & ~BIT_WALL];
      }
      else
         wallpic = vertwall[tilehit];


and

::: CODE :::
  if (tilehit & BIT_WALL)
      {                        // check for adjacent doors
         xtile = xintercept>>TILESHIFT;
         tile = tilemap[xtile][ytile-ytilestep];
         if(tile & BIT_DOOR)
         {
            switch(doorobjlist[tile & BIT_WALL].lock)
            {
               case dr_lock1:
                  wallpic = DOORWALL+4;
                  break;
               case dr_lock2:
                  wallpic = DOORWALL+6;
                  break;
               case dr_lock3:
                  wallpic = DOORWALL+8;
                  break;
               case dr_lock4:
                  wallpic = DOORWALL+10;
                  break;
               case dr_lock5:
                  wallpic = DOORWALL+12;
                  break; 
               case dr_lock6:
                  wallpic = DOORWALL+14;
                  break;   
               default:
                  wallpic = DOORWALL+2;
                  break; 
            }
         }
         else
            wallpic = horizwall[tilehit & ~BIT_WALL];
      }
      else
         wallpic = horizwall[tilehit];


And i get this



Any idea to fix this?

_________________
http://www.youtube.com/RichterBelmont12

https://www.facebook.com/RichterBelmont123

https://twitter.com/Richterbelmont6
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

Topics: 55
Posts: 2115
Location: Canada
blank.gif

PostPosted: Tue May 10, 2011 10:05 pm
   Subject: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hey Richter,

To get the door number from a tile, you should use tile&LAST_DOORNUM (tile%BIT_DOOR works too).

I modified your code a bit, let me know how it works now...

::: CODE :::
    if (tilehit & BIT_WALL)
    {                                                               // check for adjacent doors
        ytile = (short)(yintercept>>TILESHIFT);
        if ( tilemap[xtile-xtilestep][ytile] & BIT_DOOR )
        {
            switch(doorobjlist[tilemap[xtile-xtilestep][ytile]
& LAST_DOORNUM].lock)
            {
               case dr_lock1:
                  wallpic = DOORWALL+5;
                  break;
               case dr_lock2:
                  wallpic = DOORWALL+7;
                  break;
               case dr_lock3:
                  wallpic = DOORWALL+9;
                  break;
               case dr_lock4:
                  wallpic = DOORWALL+11;
                  break;
               case dr_lock5:
                  wallpic = DOORWALL+13;
                  break;
               case dr_lock6:
                  wallpic = DOORWALL+15;
                  break;
               default:
                  wallpic = DOORWALL+3;
                  break;
            }
        }
        else
            wallpic = vertwall[tilehit & ~BIT_WALL];
    }
    else
        wallpic = vertwall[tilehit];

::: CODE :::
    if (tilehit & BIT_WALL)
    {                                                               // check for adjacent doors
        xtile = (short)(xintercept>>TILESHIFT);
        if ( tilemap[xtile][ytile-ytilestep] & BIT_DOOR)
        {
            switch(doorobjlist[tilemap[xtile][ytile-ytilestep]
& LAST_DOORNUM].lock)
            {
               case dr_lock1:
                  wallpic = DOORWALL+5;
                  break;
               case dr_lock2:
                  wallpic = DOORWALL+7;
                  break;
               case dr_lock3:
                  wallpic = DOORWALL+9;
                  break;
               case dr_lock4:
                  wallpic = DOORWALL+11;
                  break;
               case dr_lock5:
                  wallpic = DOORWALL+13;
                  break;
               case dr_lock6:
                  wallpic = DOORWALL+15;
                  break;
               default:
                  wallpic = DOORWALL+3;
                  break;
            }
        }
        else
            wallpic = horizwall[tilehit & ~BIT_WALL];
    }
    else
        wallpic = horizwall[tilehit];
RichterBelmont12
DieHard Wolfer
DieHard Wolfer


Joined: 14 Aug 2004
Last Visit: 13 Nov 2017

Topics: 97
Posts: 1505
Location: New Jersey
usa.gif

PostPosted: Wed May 11, 2011 5:46 am
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Works like a Charm Thanks Chris!

_________________
http://www.youtube.com/RichterBelmont12

https://www.facebook.com/RichterBelmont123

https://twitter.com/Richterbelmont6
ThunderEnema
I am Death Incarnate
I am Death Incarnate


Joined: 05 Jul 2012
Last Visit: 10 Dec 2017

Topics: 4
Posts: 186
Location: Washington
usa.gif

PostPosted: Mon Dec 05, 2016 12:59 am
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I am sorry to bump an old thread, but I ran into a really strange problem related to this code recently.

I am using wall values 1,000 and up for my walls; I noticed that when I place a deaf guard next to one of these walls, the guard turns into a statue and does not move until it is attacked. This never used to happen before I implemented this code and was just using the normal 1-64 wall values (it didn't even happen when I used values 1-90). I have tried changing the newtile_offset to use a different wall value (144,200,400), I still get the same result where the wall turns a nearby deaf guard into a statue.

Is there something about this code that conflicts with the ambush tile?

_________________
"When I see someone wearing crocs in public, I have all the information I need to know that I will never get along with that person." -Me
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 0:34 ago.

Topics: 37
Posts: 2401
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Mon Dec 05, 2016 1:54 am
   Subject: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Ah, yep, there's a problem with it in SpawnStand where it only checks if a floor code is high enough to be a floor code, never if it's low enough to be not one of the new walls. Find this section:

::: CODE :::
    map = mapsegs[0]+(tiley<<mapshift)+tilex;
    tile = *map;
    if (tile == AMBUSHTILE)
    {
        tilemap[tilex][tiley] = 0;

        if (*(map+1) >= AREATILE)
            tile = *(map+1);
        if (*(map-mapwidth) >= AREATILE)
            tile = *(map-mapwidth);
        if (*(map+mapwidth) >= AREATILE)
            tile = *(map+mapwidth);
        if ( *(map-1) >= AREATILE)
            tile = *(map-1);

        *map = tile;
        newobj->areanumber = tile-AREATILE;

        newobj->flags |= FL_AMBUSH;
    }


And change it to this:

::: CODE :::
    map = mapsegs[0]+(tiley<<mapshift)+tilex;
    tile = *map;
    if (tile == AMBUSHTILE)
    {
        tilemap[tilex][tiley] = 0;

        if (*(map+1) >= AREATILE && *(map+1) < AREATILE + NUMAREAS)
            tile = *(map+1);
        if (*(map-mapwidth) >= AREATILE && *(map-mapwidth) < AREATILE + NUMAREAS)
            tile = *(map-mapwidth);
        if (*(map+mapwidth) >= AREATILE && *(map+mapwidth) < AREATILE + NUMAREAS)
            tile = *(map+mapwidth);
        if ( *(map-1) >= AREATILE && *(map-1) < AREATILE + NUMAREAS)
            tile = *(map-1);

        *map = tile;
        newobj->areanumber = tile-AREATILE;

        newobj->flags |= FL_AMBUSH;
    }


That should hopefully fix it.
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

Topics: 55
Posts: 2115
Location: Canada
blank.gif

PostPosted: Mon Dec 05, 2016 8:22 am
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Thanks AlumiuN. I posted about it here too (purple code near the bottom) but have been pro-Dos lately and never got around to trying it out. Thanks ThunderEnema for confirming that the problem does indeed exist. Smile
ThunderEnema
I am Death Incarnate
I am Death Incarnate


Joined: 05 Jul 2012
Last Visit: 10 Dec 2017

Topics: 4
Posts: 186
Location: Washington
usa.gif

PostPosted: Mon Dec 05, 2016 4:53 pm
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Thanks AlumiuN. I will test out the code tonight and report the results. I appreciate your help!

_________________
"When I see someone wearing crocs in public, I have all the information I need to know that I will never get along with that person." -Me
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 1:23 ago.

Topics: 160
Posts: 8008
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Mon Dec 05, 2016 5:18 pm
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
Ah, yep, there's a problem with it in SpawnStand where it only checks if a floor code is high enough to be a floor code, never if it's low enough to be not one of the new walls.
Oh, boy ... that means my Base Of Operations code has this bug too, and it's been sitting around unfixed for years now. Razz

Thanks for posting the bugfix, AlumiuN. Smile
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

Topics: 55
Posts: 2115
Location: Canada
blank.gif

PostPosted: Tue Dec 06, 2016 9:54 am
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

In the link I posted, there's also a fix for the deaf guard code in WL_GAME (first purple code). This situation is less obvious: if you have a Death Incarnate or Bring Em On enemy on a deaf guard floor beside a 144+ wall in certain direction(s) and play the game on a lower skill level than what skill the enemy is, SpawnStand will not be called and this code will instead when it sees the deaf floorcode, and without the fix it can make the floorcode for that square and possibly subsequent ones beside it invalid.

Though if anyone wants to do it the "move floorcodes up past all the walls" way instead (red code idea) I'll still take offers to convert the floorcodes in the maps to higher values, because I like that idea better and then no purple code is needed. Very Happy
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Tue Dec 06, 2016 10:08 am
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Chris wrote:
In the link I posted, there's also a fix for the deaf guard code in WL_GAME (first purple code). This situation is less obvious: if you have a Death Incarnate or Bring Em On enemy on a deaf guard floor beside a 144+ wall in certain direction(s) and play the game on a lower skill level than what skill the enemy is, SpawnStand will not be called and this code will instead when it sees the deaf floorcode, and without the fix it can make the floorcode for that square and possibly subsequent ones beside it invalid.

Though if anyone wants to do it the "move floorcodes up past all the walls" way instead (red code idea), I'll still take offers to convert the floorcodes in the maps to higher values because I like that idea better and then no purple code is needed. Very Happy


Good and necessary information, Thanks! As somebody who rarely plays on anything lower than Death Incarnate, there is a good chance this would have slipped by my testing unnoticed.

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 0:34 ago.

Topics: 37
Posts: 2401
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Tue Dec 06, 2016 1:38 pm
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I avoided this issue by just shoving the doors and floorcodes further down the list :3
ThunderEnema
I am Death Incarnate
I am Death Incarnate


Joined: 05 Jul 2012
Last Visit: 10 Dec 2017

Topics: 4
Posts: 186
Location: Washington
usa.gif

PostPosted: Tue Dec 06, 2016 1:42 pm
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN: The code worked like a charm! Thanks.

Chris: Thanks for updating the info in your tutorial for the WL_Game ambush tile code. I would have missed that.

I think both the red and the purple versions of the code are useful. I, personally, would not want to use the red version of the code in this instance because I've mapped about 20 levels for my mod using the old floor values.

Anyway, thanks for the help guys!

_________________
"When I see someone wearing crocs in public, I have all the information I need to know that I will never get along with that person." -Me
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Tue Dec 06, 2016 1:56 pm
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
I avoided this issue by just shoving the doors and floorcodes further down the list :3


If I was starting a new mod I would probably do this because it is the cleanest way, but being so far into it I don't want to go through the hassle.

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 0:34 ago.

Topics: 37
Posts: 2401
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Tue Dec 06, 2016 3:44 pm
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Barry wrote:
AlumiuN wrote:
I avoided this issue by just shoving the doors and floorcodes further down the list :3


If I was starting a new mod I would probably do this because it is the cleanest way, but being so far into it I don't want to go through the hassle.


Yeah, of course; no point doing all that work when there's a simple fix available Smile
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

Topics: 55
Posts: 2115
Location: Canada
blank.gif

PostPosted: Tue Feb 21, 2017 8:10 pm
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

The red and blue code is now included in AlumiuN's repository: https://github.com/AlumiuN/Wolf4SDL

If you download that base, all you have to do is adjust WALLSHIFT, MAXWALLTILES and MAXDOORS in wl_def.h to your liking and add the purple code (or another idea like this). It even knows to compile tilemap as a byte or word automagically (cool! Too Cool ).
Aryan_Wolf3D
I am Death Incarnate
I am Death Incarnate


Joined: 21 Jul 2011
Last Visit: 14 Dec 2017

Topics: 6
Posts: 172

blank.gif

PostPosted: Wed Feb 22, 2017 1:04 am
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

There's another "magic number" in wl_agent.cpp, in the TryMove function:

::: CODE :::
if(tilemap[x][y]==64 && x==pwallx && y==pwally)   // back of moving pushwall?

The 64 should be "BIT_WALL", otherwise the player can't move along with the pushwall anymore.

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


Joined: 29 Nov 2007
Last Visit: 0:34 ago.

Topics: 37
Posts: 2401
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Wed Feb 22, 2017 1:09 am
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Fixed, thanks Smile
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

Topics: 55
Posts: 2115
Location: Canada
blank.gif

PostPosted: Thu Feb 23, 2017 8:20 am
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Nice catch Aryan_Wolf3D!
fraggeur
DieHard Guard
DieHard Guard


Joined: 31 Dec 2012
Last Visit: 09 Dec 2017

Topics: 11
Posts: 259

blank.gif

PostPosted: Thu Feb 23, 2017 1:04 pm
   Subject: Re: MAXWALLTILES/MAXDOORS - Removing the hard coded limits
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Wow I had carried this bug in my mod and didn't really notice. I just tried now before/after, I prefer with the fix Smile
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> SDL Code Crackers 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 Announcement: Wolf3d & Spear of Destiny Shareware SDL Downloads
Author: BrotherTank
10 13130 Tue Aug 24, 2010 10:18 am
dcbasic View latest post
No new posts Sticky: [Tutorial] Compiling Wolf4SDL with Code::Blocks
Author: dcbasic
90 17488 Wed May 24, 2017 7:53 pm
Falcon*93 View latest post
No new posts [WOLF4SDL Help] Blake Stone Style doors
Author: Haasboy
3 2192 Sun Jul 20, 2008 7:56 am
Haasboy View latest post
No new posts [SDL-Help] Wall patches fix
Author: insurrectionman
0 915 Tue Jul 15, 2008 11:12 am
insurrectionman View latest post
No new posts [SDL] Apply 2nd ScaleFactor to selected (hi-res) vga gfx
Author: Andy_Nonymous
9 3266 Sun Apr 27, 2008 2:30 am
AlumiuN 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