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...


+3
Imed
Dark_wizzie
AlumiuN
7 posters

    Chaos edit or WDC source code??? or a new editor?

    mmed
    mmed
    Don't Hurt Me!
    Don't Hurt Me!


    Male
    Number of posts : 52
    Age : 30
    Registration date : 2012-07-25

    Chaos edit or WDC source code??? or a new editor? Empty Chaos edit or WDC source code??? or a new editor?

    Post by mmed Fri Apr 18, 2014 6:17 am

    There is the source code of these editors?
    or a new editor?


    these editors are too limited:




    chaos edit:


    maps limited to 64x64  No 
    sprites and walls limited to 128x128  Rolling Eyes 
    64 walls limit in 3d editor  Neutral 
    supports only 3 planes   No 
    files are damaged    Evil or Very Mad 

    and more...



    WDC:


    sprites and walls limited to 128x128   Rolling Eyes 
    bugs    Evil or Very Mad 
    files are damaged  Evil or Very Mad 
    and more...


    HWE:

    256x256 maps  High on Drugs 
    zoom  Smile 
    files are damaged  Evil or Very Mad 
    bug  Evil or Very Mad  Evil or Very Mad  Evil or Very Mad 

    bug  Evil or Very Mad  Evil or Very Mad  Evil or Very Mad
    bug  Evil or Very Mad  Evil or Very Mad  Evil or Very Mad
    bug  Evil or Very Mad  Evil or Very Mad  Evil or Very Mad
    bug  Evil or Very Mad  Evil or Very Mad  Evil or Very Mad
    bug  Evil or Very Mad  Evil or Very Mad  Evil or Very Mad


    I would like to improve these editors  Very Happy
    linuxwolf
    linuxwolf
    Bring em' On!
    Bring em' On!


    Male
    Number of posts : 160
    Age : 42
    Location : Australia
    Hobbie : Games
    Registration date : 2011-12-25

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by linuxwolf Fri Apr 18, 2014 8:53 am

    Why not write your own? If not, I might be able to release a new one with my next mod but it isn't going to be very user friendly.
    AlumiuN
    AlumiuN
    Don't Hurt Me!
    Don't Hurt Me!


    Number of posts : 52
    Age : 32
    Location : Christchurch, New Zealand
    Registration date : 2013-08-31

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by AlumiuN Fri Apr 18, 2014 9:41 pm

    I've been considering writing an SDL 'clone' of Mapedit for some time. Unfortunately I haven't had the motivation to do so, but when I do I'll be making it open source so that people can maintain it if I'm not around.
    Dark_wizzie
    Dark_wizzie
    I am Death Incarnate!
    I am Death Incarnate!


    Female
    Number of posts : 5120
    Age : 30
    Location : California, USA
    Job : Investor
    Hobbie : Computers, chess, computer chess, fashion, and philosophy
    Message : I made this forum when I was 13 High on Drugs
    Registration date : 2007-03-24

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by Dark_wizzie Fri Apr 18, 2014 11:13 pm

    Chaosedit, I think when I open up a wolf3d map and them open up a Sod game, it crashes. And the inability to make the window larger on my large screen is a huge pain in the ass.

    Nothing is perfect I'm afraid.



    Wolf3d Haven
    Minute Logic Blog
    mmed
    mmed
    Don't Hurt Me!
    Don't Hurt Me!


    Male
    Number of posts : 52
    Age : 30
    Registration date : 2012-07-25

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by mmed Sat Apr 19, 2014 10:06 am

    linuxwolf wrote:Why not write your own? If not, I might be able to release a new one with my next mod but it isn't going to be very user friendly.


    not know where to start. so I want to use one already made
    mmed
    mmed
    Don't Hurt Me!
    Don't Hurt Me!


    Male
    Number of posts : 52
    Age : 30
    Registration date : 2012-07-25

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by mmed Sat Apr 19, 2014 10:15 am

    AlumiuN wrote:I've been considering writing an SDL 'clone' of Mapedit for some time. Unfortunately I haven't had the motivation to do so, but when I do I'll be making it open source so that people can maintain it if I'm not around.


    I'm making a mod with awesome stuff (never seen before...) (really) but have maps in 64x64 or 128x128 makes you want to throw all the crap  Dead

    to you can also serve the editor  Very Happy
    mmed
    mmed
    Don't Hurt Me!
    Don't Hurt Me!


    Male
    Number of posts : 52
    Age : 30
    Registration date : 2012-07-25

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by mmed Sat Apr 19, 2014 10:21 am

    Dark_wizzie wrote:Chaosedit, I think when I open up a wolf3d map and them open up a Sod game, it crashes. And the inability to make the window larger on my large screen is a huge pain in the ass.

    Nothing is perfect I'm afraid.


    yes, you're right
    avatar
    Imed
    Can I Play, Daddy?
    Can I Play, Daddy?


    Number of posts : 32
    Age : 33
    Registration date : 2013-10-26

    Chaos edit or WDC source code??? or a new editor? Empty Some Thoughs

    Post by Imed Sat Apr 19, 2014 7:21 pm

    The most difficult thing to understand for us is the wl6 map format. ¿How this work? ¿How to decompile/compile it?...That is the kind of info we need at least to start.

    We arent experts, but we try to use the wolf3d source code as a basis for a possible map editor, but obviously, without help is hard to do.

    An open source map editor, that is all we need, it doesnt need to be Like chaos edit with a lot of stuff...a mapedit clone...we can start from there.

    Thanks for understanding.
    linuxwolf
    linuxwolf
    Bring em' On!
    Bring em' On!


    Male
    Number of posts : 160
    Age : 42
    Location : Australia
    Hobbie : Games
    Registration date : 2011-12-25

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by linuxwolf Sat Apr 19, 2014 11:04 pm

    I can give you code for decompiling/compiling the map formats. I got it to work by studying the TED tools by John Romero. He did the work on wolf3d map formats in the first place. John Carmack just did the engine.
    avatar
    Imed
    Can I Play, Daddy?
    Can I Play, Daddy?


    Number of posts : 32
    Age : 33
    Registration date : 2013-10-26

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by Imed Sun Apr 20, 2014 5:48 am

    linuxwolf wrote:I can give you code for decompiling/compiling the map formats. I got it to work by studying the TED tools by John Romero. He did the work on wolf3d map formats in the first place. John Carmack just did the engine.

    Well linuxwolf, maybe you can save us.  rabbit . That would be lovely, thanks in advance.

    TED tools. Arent those Rise of the Triad related?

    Waiting for your help.


    ****************************************************************************
    I need to say this:

    All the people in this forum has been always very cooperative; DemedgruppeStudios is integrated only by me and my brother, we has been working in this mod for Wolf4sdl since 2 years (more or less), my brother start maybe 1 year before.

    I personally always been focus in Half Life modding. Since we start this wolf3d project -i love wolf3d-
    we have like 10 ideas for maps, coding, spriting, etc....almost every day.  Shocked  (MADNESS!!!  What a Face  )

    With some lacks in coding knowledge, many of our ideas are maybe to big for us -We always try to solve by ourself first, then, if we didnt success...ask here.-. But you know how this is, when you have something new....you wanna be like "the first man who did it". Our mod will doesnt look like wolf3d anymore, is a total TC. All, absolutely ALL is changed, gameplay, weapons, enemies, allies, props, lightning, sounds, music, menu, and more. I play many wolf3d mods and there are only a few that i consider like worth the effort to play, and those mods are our "objetive", we wanna create something "better" than those mods -please dont take it in a bad sense- even when i really enjoy mods like spear resurrection,  Federal Cases: Tara Carmichael, the epic  Operation Eisenfaust : Origins, and some others. Always has the feeling of "why they did this in this way, and not in another",  study then an idea comes out like a "whooshh"  scratch  scratch  "i could do that better"....and that is how we live  Cool since we start wolf3d modding.


    So we have a really big project -thanks to many of you people, with the help, tutorials and the coolness- but that has his negative point -we are fighting against that negative point since last year almost-; the wolf3d engine and editors limits.

    With more than 20 years old, i firstly believe that this engine will be absolute revamped, like happens in Half life, Doom or even Duke Nukem. But sadly, is not. Yes, we have wolf4sdl -is awesome-, that give us more freedom in comparison with the original- without mention those opengl based version of wolf3d, those also are good but i personally dont like too much.

    But people, listen to me, nobody has even tried to create a different system for those crappy IDs, something more easy to work and read? Anyone try to overcome the texture limit (without "unstable" tricks)? Those are basic things to do in every old-engine that anyone modding, if we dont do that, we will have more "map packs" than really mods.

    And what about the Editors tools?
    Why are the editors "limited" to X number of Ids?confused Because if you solve some things like i mention above -and we did- you cannot use it, due the editors limit.

    Why are those editors "close source"??
    It would be more practical making then "open source", so the community will help with the development, adding features and ideas.

    For us, the editors are like a bottle neck ( and i think, many of you will agree with me); the editors are the main limit for every big project in wolf3d modding.

    I sincerely believe that wolf3d modding is stagnant.
    If that "limit" is overcome, a full new generation of wolf3d mods will come, more people will be insterested in modding for this old engine because is more easier to do, more powerfull. Right now, you need to think in many limits, and problems due the lack of proper and generic tools.

    The solutions for this things are in your hands community, we hardly try to help solving them but this requires coding skills besides goodwill, Cool  honor and courage... Cool .  This is NOT one man`s work, is a community need, the basis of future evolution in wolf3d modding.

    Ideas for making good editors?
    Well, my dream (a man can dream, right?) it would be a mix between Multimedia Fusion (the drag and drop thing) and Valve Hammer Editor (all what you need in some buttons). but that is just me.


    Remember this words in the future, remember. I hope you join us in this "crusade".






    Thats all folks, i dont speak english so sorry if i am not clear enough.....(U CAN ASK ME  cheers  )

    Thanks in advance.
    avatar
    Guest
    Guest


    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by Guest Wed Apr 23, 2014 7:20 pm

    Imed wrote:Ideas for making good editors?

    Mapedit Razz
    avatar
    Imed
    Can I Play, Daddy?
    Can I Play, Daddy?


    Number of posts : 32
    Age : 33
    Registration date : 2013-10-26

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by Imed Thu Apr 24, 2014 1:02 pm

    Therefore wrote:
    Imed wrote:Ideas for making good editors?

    Mapedit Razz

    Mapedit Source Code you may want to say.

    LinuxWolf wrote:I can give you code for decompiling/compiling the map formats. I got it to work by studying the TED tools by John Romero. He did the work on wolf3d map formats in the first place. John Carmack just did the engine.

    When?
    linuxwolf
    linuxwolf
    Bring em' On!
    Bring em' On!


    Male
    Number of posts : 160
    Age : 42
    Location : Australia
    Hobbie : Games
    Registration date : 2011-12-25

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by linuxwolf Thu Apr 24, 2014 6:38 pm

    Imed wrote:LinuxWolfI can give you code for decompiling/compiling the map formats. I got it to work by studying the TED tools by John Romero. He did the work on wolf3d map formats in the first place. John Carmack just did the engine.

    When?

    Right now. I compile map formats that are compatible with Chaos Edit.

    Code:
    #define LWLIB_MAPTOOL_EDITORID "CE1.27:3P:FF:Mapfile was edited with ChaosEdit (www.chaos-software.de.vu)"

    typedef struct
    {
        word RLEWtag;
        int32_t headeroffsets[100];
    } mapfiletype;

    namespace MapTool_Const
    {
     enum e
     {
     // these must match wl_def.h
     MaxTitleChars = 16, // MAXTITLECHARS
     MapPlanes = 3, // MAPPLANES
     MapArea = 64 * 64, // maparea
     NumMaps = 60, // NUMMAPS
     };
    }

    typedef uint16_t MapTool_Word_t;
    typedef MapTool_Word_t MapTool_Planes_t[MapTool_Const::MapPlanes]
     [MapTool_Const::MapArea];

    typedef struct MapTool_Map_s
    {
     MapTool_Word_t width;
     MapTool_Word_t height;
     char name[MapTool_Const::MaxTitleChars];
     MapTool_Planes_t planes;
    } MapTool_Map_t;

    class MapTool
    {
     struct
     {
     MapTool_Map_t maps[MapTool_Const::NumMaps];
     } priv;

     int saveMapHead();

     lwlib_Byte_t *mapPlaneOnDisk(int mapNum, int planeNum,
     int *onDiskSize);

     int mapPlaneSizeOnDisk(int mapNum, int planeNum);

     void saveMapHeaders(int handle, int off);

     void saveMapPlanes(int handle);

     void saveMaps_FileFormatGame();

    public:
     MapTool();
    };

    int MapTool::saveMapHead()
    {
     int i;
     int off;
     int handle;
     char fname[32];
     int32_t length;
     mapfiletype tinf;
     MapTool_Map_t *map;

     CA_FilePath(fname, sizeof(fname), mheadname);

     handle = open(fname, O_RDWR | O_BINARY);
     if (handle == -1)
     CA_CannotOpen(fname);

     lwlib_Zero(tinf);
     tinf.RLEWtag = RLEWtag;

     off = strlen(LWLIB_MAPTOOL_EDITORID);

     for (i = 0; i < NUMMAPS; i++)
     {
     map = &priv.maps[i];
     if (!(map->width == 64 && map->height == 64))
     {
     tinf.headeroffsets[i] = -1;
     continue;
     }

     tinf.headeroffsets[i] = off;
     off += sizeof(maptype);
     }

     length = NUMMAPS * 4 + 2;
     write(handle, &tinf, length);
     
    close(handle);

     return off;
    }

    lwlib_Byte_t *MapTool::mapPlaneOnDisk(int mapNum, int planeNum,
     int *onDiskSize)
    {
     int expanded, rlew_size, compressed;
     byte *planeseg, *rlew_planeseg;
     MapTool_Map_t *map;

     map = &priv.maps[mapNum];

     expanded = maparea * 2;
     rlew_planeseg = lwlib_CallocMany(byte, expanded + 2);
     rlew_size = CA_RLEWCompress(map->planes[planeNum], expanded,
     ((word *)rlew_planeseg) + 1, RLEWtag);
     *((word *)rlew_planeseg) = (word)expanded;

     expanded = rlew_size + 2;
    planeseg = lwlib_CallocMany(byte, (expanded * 3 / 2) + 2);
     compressed = CAL_CarmackCompress((word *)rlew_planeseg, expanded,
     ((word *)planeseg) + 1);
     *((word *)planeseg) = (word)expanded;

     free(rlew_planeseg);

     if (onDiskSize != NULL)
     {
     *onDiskSize = compressed + 2;
     }
     return planeseg;
    }

    int MapTool::mapPlaneSizeOnDisk(int mapNum, int planeNum)
    {
     int onDiskSize;
     byte *planeseg;

     planeseg = mapPlaneOnDisk(mapNum, planeNum, &onDiskSize);
     free(planeseg);

     return onDiskSize;
    }

    void MapTool::saveMapHeaders(int handle, int off)
    {
     int i, j;
     int size;
     MapTool_Map_t *map;
     maptype mapheader;

     for (i = 0; i < NUMMAPS; i++)
     {
     map = &priv.maps[i];
     if (!(map->width == 64 && map->height == 64))
     {
     continue;
     }

     lwlib_Zero(mapheader);
     for (j = 0; j < 3; j++)
     {
     size = mapPlaneSizeOnDisk(i, j);
     mapheader.planestart[j] = off;
     mapheader.planelength[j] = size;
     off += size;
     }
     mapheader.width = mapheader.height = 64;
     lwlib_Copy(mapheader.name, map->name);

     write(handle, &mapheader, sizeof(mapheader));
     }
    }

    void MapTool::saveMapPlanes(int handle)
    {
     int i, j;
     int onDiskSize;
     byte *planeseg;
     MapTool_Map_t *map;

     for (i = 0; i < NUMMAPS; i++)
     {
     map = &priv.maps[i];
     if (!(map->width == 64 && map->height == 64))
     {
     continue;
     }

     for (j = 0; j < 3; j++)
     {
     planeseg = mapPlaneOnDisk(i, j, &onDiskSize);
     write(handle, planeseg, onDiskSize);
     free(planeseg);
     }
     }
    }

    void MapTool::saveMaps_FileFormatGame()
    {
     int off;
     int handle;
     char fname[32];

     off = saveMapHead();

            CA_FilePath(fname, sizeof(fname), "gamemaps");

     handle = open(fname, O_RDWR | O_BINARY);
     if (handle == -1)
     {
     CA_CannotOpen(fname);
     }

     write(handle, LWLIB_MAPTOOL_EDITORID, strlen(LWLIB_MAPTOOL_EDITORID));

     saveMapHeaders(handle, off);
     saveMapPlanes(handle);

     close(handle);
    }

    // =================================================================== //

    #define NEARTAG 0xa7
    #define FARTAG  0xa8

    char *CA_FilePath(char *buf, int sz, const char *filename)
    {
     snprintf(buf, sz, "%s%s.%s", gamedir, filename, extension);
     return buf;
    }

    int32_t CA_RLEWCompress (word *source, int32_t length, word *dest, word rlewtag)
    {
        word value,count;
        unsigned i;
        word *start,*end;

        start = dest;

        end = source + (length+1)/2;

        //
        // compress it
        //
        do
        {
            count = 1;
            value = *source++;
            while (*source == value && source<end)
            {
                count++;
                source++;
            }
            if (count>3 || value == rlewtag)
            {
                //
                // send a tag / count / value string
                //
                *dest++ = rlewtag;
                *dest++ = count;
                *dest++ = value;
            }
            else
            {
                //
                // send word without compressing
                //
                for (i=1;i<=count;i++)
                    *dest++ = value;
            }

        } while (source<end);

        return (int32_t)(2*(dest-start));
    }

    int CAL_CarmackCompress (word *source, int length, word *dest)
    {
        word ch,chhigh;
        word *inptr, *outptr;
        int outlength;

        assert(length % 2 == 0);

        inptr = source;
        outptr = dest;

        outlength = 0;
        length /= 2;

        do
        {
            ch = *inptr;

            chhigh = ch>>8;
            if (chhigh == NEARTAG || chhigh == FARTAG)
            {
                *outptr++ = ch & 0xff00;
                *((byte *)outptr) = ch&0xff;
                outptr = (word *)((byte *)outptr + 1);
                outlength += 3;
            }
            else
            {
                *outptr++ = ch;
                outlength += 2;
            }
            inptr++;
            length--;

            if (length<0)
                Quit ("Length < 0!");
        } while (length);

        return outlength;
    }

    I hope it helps. This code may or may not compile as is and I provide no assurances over its correctness. I will say this code is working fine for my purposes.

    If you do decide to start a new map tool project, please make it open source so the rest of us can take advantage of it. My custom map tool is GL based and not ... suitable ... for open sourcing. Nobody uses it but me. And I only use it when I want to test a coding feature, not for making real maps or anything.
    avatar
    Imed
    Can I Play, Daddy?
    Can I Play, Daddy?


    Number of posts : 32
    Age : 33
    Registration date : 2013-10-26

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by Imed Fri Apr 25, 2014 12:21 pm

    linuxwolf wrote:
    Imed wrote:LinuxWolfI can give you code for decompiling/compiling the map formats. I got it to work by studying the TED tools by John Romero. He did the work on wolf3d map formats in the first place. John Carmack just did the engine.

    When?

    Right now. I compile map formats that are compatible with Chaos Edit.

    Code:
    #define LWLIB_MAPTOOL_EDITORID "CE1.27:3P:FF:Mapfile was edited with ChaosEdit (www.chaos-software.de.vu)"

    typedef struct
    {
        word RLEWtag;
        int32_t headeroffsets[100];
    } mapfiletype;

    namespace MapTool_Const
    {
     enum e
     {
     // these must match wl_def.h
     MaxTitleChars = 16, // MAXTITLECHARS
     MapPlanes = 3, // MAPPLANES
     MapArea = 64 * 64, // maparea
     NumMaps = 60, // NUMMAPS
     };
    }

    typedef uint16_t MapTool_Word_t;
    typedef MapTool_Word_t MapTool_Planes_t[MapTool_Const::MapPlanes]
     [MapTool_Const::MapArea];

    typedef struct MapTool_Map_s
    {
     MapTool_Word_t width;
     MapTool_Word_t height;
     char name[MapTool_Const::MaxTitleChars];
     MapTool_Planes_t planes;
    } MapTool_Map_t;

    class MapTool
    {
     struct
     {
     MapTool_Map_t maps[MapTool_Const::NumMaps];
     } priv;

     int saveMapHead();

     lwlib_Byte_t *mapPlaneOnDisk(int mapNum, int planeNum,
     int *onDiskSize);

     int mapPlaneSizeOnDisk(int mapNum, int planeNum);

     void saveMapHeaders(int handle, int off);

     void saveMapPlanes(int handle);

     void saveMaps_FileFormatGame();

    public:
     MapTool();
    };

    int MapTool::saveMapHead()
    {
     int i;
     int off;
     int handle;
     char fname[32];
     int32_t length;
     mapfiletype tinf;
     MapTool_Map_t *map;

     CA_FilePath(fname, sizeof(fname), mheadname);

     handle = open(fname, O_RDWR | O_BINARY);
     if (handle == -1)
     CA_CannotOpen(fname);

     lwlib_Zero(tinf);
     tinf.RLEWtag = RLEWtag;

     off = strlen(LWLIB_MAPTOOL_EDITORID);

     for (i = 0; i < NUMMAPS; i++)
     {
     map = &priv.maps[i];
     if (!(map->width == 64 && map->height == 64))
     {
     tinf.headeroffsets[i] = -1;
     continue;
     }

     tinf.headeroffsets[i] = off;
     off += sizeof(maptype);
     }

     length = NUMMAPS * 4 + 2;
     write(handle, &tinf, length);
     
    close(handle);

     return off;
    }

    lwlib_Byte_t *MapTool::mapPlaneOnDisk(int mapNum, int planeNum,
     int *onDiskSize)
    {
     int expanded, rlew_size, compressed;
     byte *planeseg, *rlew_planeseg;
     MapTool_Map_t *map;

     map = &priv.maps[mapNum];

     expanded = maparea * 2;
     rlew_planeseg = lwlib_CallocMany(byte, expanded + 2);
     rlew_size = CA_RLEWCompress(map->planes[planeNum], expanded,
     ((word *)rlew_planeseg) + 1, RLEWtag);
     *((word *)rlew_planeseg) = (word)expanded;

     expanded = rlew_size + 2;
    planeseg = lwlib_CallocMany(byte, (expanded * 3 / 2) + 2);
     compressed = CAL_CarmackCompress((word *)rlew_planeseg, expanded,
     ((word *)planeseg) + 1);
     *((word *)planeseg) = (word)expanded;

     free(rlew_planeseg);

     if (onDiskSize != NULL)
     {
     *onDiskSize = compressed + 2;
     }
     return planeseg;
    }

    int MapTool::mapPlaneSizeOnDisk(int mapNum, int planeNum)
    {
     int onDiskSize;
     byte *planeseg;

     planeseg = mapPlaneOnDisk(mapNum, planeNum, &onDiskSize);
     free(planeseg);

     return onDiskSize;
    }

    void MapTool::saveMapHeaders(int handle, int off)
    {
     int i, j;
     int size;
     MapTool_Map_t *map;
     maptype mapheader;

     for (i = 0; i < NUMMAPS; i++)
     {
     map = &priv.maps[i];
     if (!(map->width == 64 && map->height == 64))
     {
     continue;
     }

     lwlib_Zero(mapheader);
     for (j = 0; j < 3; j++)
     {
     size = mapPlaneSizeOnDisk(i, j);
     mapheader.planestart[j] = off;
     mapheader.planelength[j] = size;
     off += size;
     }
     mapheader.width = mapheader.height = 64;
     lwlib_Copy(mapheader.name, map->name);

     write(handle, &mapheader, sizeof(mapheader));
     }
    }

    void MapTool::saveMapPlanes(int handle)
    {
     int i, j;
     int onDiskSize;
     byte *planeseg;
     MapTool_Map_t *map;

     for (i = 0; i < NUMMAPS; i++)
     {
     map = &priv.maps[i];
     if (!(map->width == 64 && map->height == 64))
     {
     continue;
     }

     for (j = 0; j < 3; j++)
     {
     planeseg = mapPlaneOnDisk(i, j, &onDiskSize);
     write(handle, planeseg, onDiskSize);
     free(planeseg);
     }
     }
    }

    void MapTool::saveMaps_FileFormatGame()
    {
     int off;
     int handle;
     char fname[32];

     off = saveMapHead();

            CA_FilePath(fname, sizeof(fname), "gamemaps");

     handle = open(fname, O_RDWR | O_BINARY);
     if (handle == -1)
     {
     CA_CannotOpen(fname);
     }

     write(handle, LWLIB_MAPTOOL_EDITORID, strlen(LWLIB_MAPTOOL_EDITORID));

     saveMapHeaders(handle, off);
     saveMapPlanes(handle);

     close(handle);
    }

    // =================================================================== //

    #define NEARTAG 0xa7
    #define FARTAG  0xa8

    char *CA_FilePath(char *buf, int sz, const char *filename)
    {
     snprintf(buf, sz, "%s%s.%s", gamedir, filename, extension);
     return buf;
    }

    int32_t CA_RLEWCompress (word *source, int32_t length, word *dest, word rlewtag)
    {
        word value,count;
        unsigned i;
        word *start,*end;

        start = dest;

        end = source + (length+1)/2;

        //
        // compress it
        //
        do
        {
            count = 1;
            value = *source++;
            while (*source == value && source<end)
            {
                count++;
                source++;
            }
            if (count>3 || value == rlewtag)
            {
                //
                // send a tag / count / value string
                //
                *dest++ = rlewtag;
                *dest++ = count;
                *dest++ = value;
            }
            else
            {
                //
                // send word without compressing
                //
                for (i=1;i<=count;i++)
                    *dest++ = value;
            }

        } while (source<end);

        return (int32_t)(2*(dest-start));
    }

    int CAL_CarmackCompress (word *source, int length, word *dest)
    {
        word ch,chhigh;
        word *inptr, *outptr;
        int outlength;

        assert(length % 2 == 0);

        inptr = source;
        outptr = dest;

        outlength = 0;
        length /= 2;

        do
        {
            ch = *inptr;

            chhigh = ch>>8;
            if (chhigh == NEARTAG || chhigh == FARTAG)
            {
                *outptr++ = ch & 0xff00;
                *((byte *)outptr) = ch&0xff;
                outptr = (word *)((byte *)outptr + 1);
                outlength += 3;
            }
            else
            {
                *outptr++ = ch;
                outlength += 2;
            }
            inptr++;
            length--;

            if (length<0)
                Quit ("Length < 0!");
        } while (length);

        return outlength;
    }

    I hope it helps. This code may or may not compile as is and I provide no assurances over its correctness. I will say this code is working fine for my purposes.

    If you do decide to start a new map tool project, please make it open source so the rest of us can take advantage of it. My custom map tool is GL based and not ... suitable ... for open sourcing. Nobody uses it but me. And I only use it when I want to test a coding feature, not for making real maps or anything.


    Thanks Linuxwolf, at least this is something to start. I also found some info about wolf3d map formats.
    If this become an acceptable/stable tool , i will post it here, as an Open Source Community Project ASAP.

    Thanks again Linuxwolf ! From Demedgruppestudios.
    linuxwolf
    linuxwolf
    Bring em' On!
    Bring em' On!


    Male
    Number of posts : 160
    Age : 42
    Location : Australia
    Hobbie : Games
    Registration date : 2011-12-25

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by linuxwolf Fri Apr 25, 2014 7:46 pm

    My pleasure. Wink
    avatar
    easytoon
    Lucky
    Lucky


    Male
    Number of posts : 7
    Age : 39
    Job : Programer
    Message : Eva, auf Wiedersehen!
    Registration date : 2014-08-24

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by easytoon Mon Aug 25, 2014 6:41 pm

    Good luck Smile
    mmed
    mmed
    Don't Hurt Me!
    Don't Hurt Me!


    Male
    Number of posts : 52
    Age : 30
    Registration date : 2012-07-25

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by mmed Tue Aug 26, 2014 12:58 pm

    easytoon wrote:Good luck Smile
    was difficult to make it work.. Shocked
    here's a screenshot of the mod. it was difficult to follow without the correct editor.

    https://wolf3d.darkbb.com/t3092-news-of-our-project


    maybe will revive the mod  Zombys    Shocked Shocked Shocked I do not know yet.
    Officer-Michael John
    Officer-Michael John
    Seasoned Wolfer
    Seasoned Wolfer


    Male
    Number of posts : 332
    Age : 26
    Hobbie : Video and Wolf 3D mode making
    Registration date : 2014-08-04

    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by Officer-Michael John Mon Apr 04, 2016 3:09 am

    I like it with ChaosEdit 64X64 or 128X128 maps making. I changed a source code, but I don't found a ChaosEdit source code.

    Sponsored content


    Chaos edit or WDC source code??? or a new editor? Empty Re: Chaos edit or WDC source code??? or a new editor?

    Post by Sponsored content


      Current date/time is Fri Apr 26, 2024 3:49 pm