// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman // Ken Silverman's official web site: "http://www.advsys.net/ken" // See the included license file "BUILDLIC.TXT" for license info. #include #include #include #ifdef PLATFORM_DOS #include #include #include #include #include "dos_compat.h" #else #include #include #include #include "unix_compat.h" #endif #define NEWMAPVERSION 7 #define MAXMENUFILES 1024 #define MAXSECTORS 1024 #define MAXWALLS 8192 #define MAXSPRITES 4096 #define MAXSTATUS 1024 #define MAXTILES 4096 static char menuname[MAXMENUFILES][32]; static long menunamecnt; #ifdef PLATFORM_DOS #pragma pack(push,1); #endif typedef struct { unsigned short wallptr, wallnum; short ceilingpicnum, floorpicnum; short ceilingheinum, floorheinum; long ceilingz, floorz; signed char ceilingshade, floorshade; char ceilingxpanning, floorxpanning; char ceilingypanning, floorypanning; char ceilingstat, floorstat; char ceilingpal, floorpal; char visibility; short lotag, hitag, extra; } sectortype; typedef struct { long x, y; short point2, nextsector, nextwall; short picnum, overpicnum; signed char shade; char pal; short cstat; unsigned char xrepeat, yrepeat, xpanning, ypanning; short lotag, hitag, extra; } walltype; typedef struct { long x, y, z; short cstat; signed char shade; char pal, clipdist; unsigned char xrepeat, yrepeat; signed char xoffset, yoffset; short picnum, ang, xvel, yvel, zvel, owner; short sectnum, statnum; short lotag, hitag, extra; } spritetype; //40 bytes typedef struct { short wallptr, wallnum; long ceilingz, floorz; short ceilingstat, floorstat; short ceilingpicnum, ceilingheinum; signed char ceilingshade; char ceilingpal, ceilingxpanning, ceilingypanning; short floorpicnum, floorheinum; signed char floorshade; char floorpal, floorxpanning, floorypanning; char visibility, filler; short lotag, hitag, extra; } newsectortype; //32 bytes typedef struct { long x, y; short point2, nextwall, nextsector, cstat; short picnum, overpicnum; signed char shade; char pal, xrepeat, yrepeat, xpanning, ypanning; short lotag, hitag, extra; } newwalltype; //44 bytes typedef struct { long x, y, z; short cstat, picnum; signed char shade; char pal, clipdist, filler; unsigned char xrepeat, yrepeat; signed char xoffset, yoffset; short sectnum, statnum; short ang, owner, xvel, yvel, zvel; short lotag, hitag, extra; } newspritetype; #ifdef PLATFORM_DOS #pragma pack(pop); #endif //************************************************************************** static sectortype sector[MAXSECTORS]; static walltype wall[MAXWALLS]; static spritetype sprite[MAXSPRITES]; static newsectortype newsector[MAXSECTORS]; static newwalltype newwall[MAXWALLS]; static newspritetype newsprite[MAXSPRITES]; static long posx, posy, posz, mapversion; static short ang, cursectnum, numsectors, numwalls, numsprites; // Function definitions void convmap(char *filename); int loadoldboard(char *filename); int savenewboard(char *filename); int getfilenames(char *kind); void sortfilenames(void); int main(int argc, char **argv) { long i; if (argc != 2) { printf("CONVMAP%d [filespec] by Ken Silverman\n",NEWMAPVERSION); printf("This CONVMAP%d.EXE converts map version %d to map version %d\n",NEWMAPVERSION,NEWMAPVERSION-1,NEWMAPVERSION); exit(0); } menunamecnt = 0; getfilenames(argv[1]); sortfilenames(); if (menunamecnt == 0) { printf("CONVMAP%d [filespec] by Ken Silverman\n",NEWMAPVERSION); printf("This CONVMAP%d.EXE converts map version %d to map version %d\n",NEWMAPVERSION,NEWMAPVERSION-1,NEWMAPVERSION); printf("File not found\n"); exit(0); } printf("Converting map version %d to map version %d\n",NEWMAPVERSION-1,NEWMAPVERSION); for(i=0;i 0)) if ((fileinfo.name[0] != '.') || (fileinfo.name[1] != 0)) { if (menunamecnt < MAXMENUFILES) { strcpy(menuname[menunamecnt],fileinfo.name); menuname[menunamecnt][16] = type; menunamecnt++; } //else // printmessage("Too many files! (max=MAXMENUFILES)"); } } while (_dos_findnext(&fileinfo) == 0); return(0); } void sortfilenames(void) { char sortbuffer[32]; long i, j, k; for(i=1;i