Wolf3d Haven Forum

Please log in or register. Smile

Join the forum, it's quick and easy

Wolf3d Haven Forum

Please log in or register. Smile

Wolf3d Haven Forum

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Wolf3d Haven Forum

A friendly Wolfenstein 3D community, about Wolfenstein 3D, the game that gave birth to first person shooters...


    [solved]Wolf4SDL - Add more than 8 doors

    avatar
    Josip_2P2
    Freshmen
    Freshmen


    Number of posts : 17
    Age : 28
    Location : Croatia
    Hobbie : Modding
    Registration date : 2019-02-04

    define - [solved]Wolf4SDL - Add more than 8 doors Empty [solved]Wolf4SDL - Add more than 8 doors

    Post by Josip_2P2 Mon Feb 11, 2019 9:51 am

    Hi!

    In WL_GAME.CPP I add some new doors to case number 105 (this is 4 new doors) and everything works fine...

    Where is the problem? Well, I found that cases from number 106 are reserved to floors, then I moved case number for more 2 new doors to 144 (this is the first tile after floor tiles).

    I used Chaos edit to add textures, tile configuration and put that new doors on map.(There is everything ok. I attached sprinfo)
    Everything is ok in WL_DEF.H too:


    WL_DEF.H related code:



    typedef enum {
        dr_normal,
        dr_lock1,
        dr_lock2,
        dr_lock3,
        dr_lock4,
        dr_elevator,
        dr_lock5,
        dr_lock6,
        dr_lock5keys,
        dr_wood
    } door_t;


    ----------------------------------------------

    I have problem with these last two doors.

    WL_DRAW.CPP code related to doors:


    #define DOORWALL        (PMSpriteStart-30)

    .............................

    .............................
    /*
    ====================
    = HitVertWall - Adjacent textures
    ====================
    */

                switch(doorobjlist[tilemap[xtile-xtilestep][ytile] & 0x80-1].lock)
                {
                   case dr_normal:
                      wallpic = DOORWALL+3;
                      break;

                   case dr_lock1:
                   case dr_lock2:
                   case dr_lock3:
                   case dr_lock4:
                   case dr_lock5:
                   case dr_lock6:
                   case dr_lock5keys:
                      wallpic = DOORWALL+11;
                      break;

                   case dr_elevator:
                      wallpic = DOORWALL+9;
                      break;

                   case dr_wood:
                      wallpic = DOORWALL+29;
                      break;
              }
            }
            else
                wallpic = vertwall[tilehit & ~0x40];


    /*
    ====================
    = HitHorizWall - Adjacent textures
    ====================
    */

    switch(doorobjlist[tilemap[xtile][ytile-ytilestep] & 0x80-1].lock)

                {
                   case dr_normal:
                      wallpic = DOORWALL+2;
                      break;

                   case dr_lock1:
                   case dr_lock2:
                   case dr_lock3:
                   case dr_lock4:
                   case dr_lock5:
                   case dr_lock6:
                   case dr_lock5keys:
                      wallpic = DOORWALL+10;
                      break;

                   case dr_elevator:
                      wallpic = DOORWALL+8;
                      break;

                   case dr_wood:
                      wallpic = DOORWALL+28;
                      break;
              }
            }
            else
                wallpic = horizwall[tilehit & ~0x40];

    /*
    ====================
    = HitHorizDoor
    ====================
    */

        switch(doorobjlist[doornum].lock)
        {
            case dr_normal:
                doorpage = DOORWALL;
                break;
            case dr_lock1:
                doorpage = DOORWALL+12;
                break;
            case dr_lock2:
                doorpage = DOORWALL+14;
                break;
            case dr_lock3:
                doorpage = DOORWALL+16;
                break;
            case dr_lock4:
                doorpage = DOORWALL+18;
                break;
            case dr_elevator:
                doorpage = DOORWALL+4;
                break;
            case dr_lock5:
                doorpage = DOORWALL+20;
                break;
            case dr_lock6:
                doorpage = DOORWALL+22;
                break;
            case dr_lock5keys:
                doorpage = DOORWALL+24;
                break;
            case dr_wood:
                doorpage = DOORWALL+26;
                break;
        }

    /*
    ====================
    = HitVertDoor
    ====================
    */


        switch(doorobjlist[doornum].lock)
        {
            case dr_normal:
                doorpage = DOORWALL+1;
                break;
            case dr_lock1:
                doorpage = DOORWALL+13;
                break;
            case dr_lock2:
                doorpage = DOORWALL+15;
                break;
            case dr_lock3:
                doorpage = DOORWALL+17;
                break;
            case dr_lock4:
                doorpage = DOORWALL+19;
                break;
            case dr_elevator:
                doorpage = DOORWALL+5;
                break;
            case dr_lock5:
                doorpage = DOORWALL+21;
                break;
            case dr_lock6:
                doorpage = DOORWALL+23;
                break;
            case dr_lock5keys:
                doorpage = DOORWALL+25;
                break;
            case dr_wood:
                doorpage = DOORWALL+27;
                break;
        }

    --------------------------------------------------------
    WL_GAME.CPP spawn doors code:


    if ((tile >= 90 && tile <= 105) || (tile >= 144 && tile <= 147))
                {
                    // door
                    switch (tile)
                    {
                        case 90:
                        case 92:
                        case 94:
                        case 96:
                        case 98:
                        case 100:
                        case 102:
                        case 104:
                            SpawnDoor (x,y,1,(tile-90)/2);
                            break;



                      case 144:
                      case 146:
                            SpawnDoor (x,y,1,(tile-144)/2);
                            break;


                        case 91:
                        case 93:
                        case 95:
                        case 97:
                        case 99:
                        case 101:
                        case 103:
                        case 105:
                            SpawnDoor (x,y,0,(tile-91)/2);
                            break;




                      case 145:
                      case 147:
                            SpawnDoor (x,y,0,(tile-145)/2);
                            break;

                    }
                }

    --------------------------------------------------------

    When I run game with this WL_GAME.CPP code, instead of wooden doors there are normal doors, instead of 5-lock doors there are gold key doors for horizontal and silver key doors for vertical.

    When I run game with changed values there are no object in game or there are some certain walls..

    Thank you.


    Last edited by Josip_2P2 on Tue Feb 12, 2019 1:47 am; edited 1 time in total
    avatar
    Guest
    Guest


    define - [solved]Wolf4SDL - Add more than 8 doors Empty Re: [solved]Wolf4SDL - Add more than 8 doors

    Post by Guest Mon Feb 11, 2019 1:49 pm

    Hi Josip_2P2,

    One thing you will probably have to do, is change byte lock to something bigger, like uint16_t lock, because a byte can only store 8 true and false bits, so doors 9 and 10 will wrap around back to the first two, as you found out. Smile

    The code for byte lock is here in WL_DEF.H:

    Code:
    typedef struct doorstruct
    {
        byte     tilex,tiley;
        boolean  vertical;
        byte     lock;
        doortype action;
        short    ticcount;
    } doorobj_t;

    https://github.com/AlumiuN/Wolf4SDL/blob/master/WL_DEF.H#L779

    I don't know if that change is enough to get it working or not though. Good luck Wink
    avatar
    Josip_2P2
    Freshmen
    Freshmen


    Number of posts : 17
    Age : 28
    Location : Croatia
    Hobbie : Modding
    Registration date : 2019-02-04

    define - [solved]Wolf4SDL - Add more than 8 doors Empty Re: [solved]Wolf4SDL - Add more than 8 doors

    Post by Josip_2P2 Mon Feb 11, 2019 3:09 pm

    Hi Princess Peach!

    "change byte lock to something bigger, like uint16_t lock"
    I was hoping that was the solution(it makes a lot of sense), but it's almost the same thing(it only changes dr_lock5keys vertical doors to gold key vertical doors, instead of silver key vertical doors...dr_wood is still showing as dr_normal). I'm sorry, idk what can be, is there something more related to doors in code...


    Thank you for advice, I appreciate it.
    avatar
    Guest
    Guest


    define - [solved]Wolf4SDL - Add more than 8 doors Empty Re: [solved]Wolf4SDL - Add more than 8 doors

    Post by Guest Mon Feb 11, 2019 5:10 pm

    Hi Josip_2P2,

    Thanks. I believe the spawndoor part of your code in wl_game.cpp should also look like this:

    Code:
                     case 144:
                      case 146:
                            SpawnDoor (x,y,1,((tile-144)/2)+8);
                            break;

    Code:
                     case 145:
                      case 147:
                            SpawnDoor (x,y,0,((tile-145)/2)+8);
                            break;

    The reason is because your new doors start as door 8 instead of 0 (which subtracting from what you previous had would give). Again I don't know if that change is enough to get it all working though. Round 2: Good luck Smile
    avatar
    Josip_2P2
    Freshmen
    Freshmen


    Number of posts : 17
    Age : 28
    Location : Croatia
    Hobbie : Modding
    Registration date : 2019-02-04

    define - [solved]Wolf4SDL - Add more than 8 doors Empty Re: [solved]Wolf4SDL - Add more than 8 doors

    Post by Josip_2P2 Tue Feb 12, 2019 1:44 am

    Huh, finally(round 2 hehe) it works !

    Thank you very much! Good luck ;D

    Sponsored content


    define - [solved]Wolf4SDL - Add more than 8 doors Empty Re: [solved]Wolf4SDL - Add more than 8 doors

    Post by Sponsored content


      Current date/time is Thu Apr 18, 2024 7:56 pm