2006-04-13 20:47:06 +00:00
|
|
|
// "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.
|
|
|
|
//
|
|
|
|
// This file has been modified from Ken Silverman's original release
|
|
|
|
// by Jonathon Fowler (jonof@edgenetwk.com)
|
|
|
|
|
|
|
|
#include "build.h"
|
|
|
|
#include "compat.h"
|
|
|
|
#include "pragmas.h"
|
|
|
|
#include "osd.h"
|
|
|
|
#include "cache1d.h"
|
|
|
|
#include "editor.h"
|
|
|
|
|
|
|
|
#include "baselayer.h"
|
|
|
|
#ifdef RENDERTYPEWIN
|
|
|
|
#include "winlayer.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#define TIMERINTSPERSECOND 120
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
#define updatecrc16(crc,dat) (crc = (((crc<<8)&65535)^crctable[((((uint16_t)crc)>>8)&65535)^dat]))
|
|
|
|
static int32_t crctable[256];
|
2008-10-18 12:37:26 +00:00
|
|
|
static char kensig[64];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t ExtInit(void);
|
|
|
|
extern int32_t ExtPreInit(int32_t argc,const char **argv);
|
2006-04-13 20:47:06 +00:00
|
|
|
extern void ExtUnInit(void);
|
|
|
|
extern void ExtPreCheckKeys(void);
|
|
|
|
#ifdef SUPERBUILD
|
|
|
|
extern void ExtAnalyzeSprites(void);
|
|
|
|
#endif
|
|
|
|
extern void ExtCheckKeys(void);
|
|
|
|
extern void ExtLoadMap(const char *mapname);
|
|
|
|
extern void ExtSaveMap(const char *mapname);
|
2009-01-09 09:29:17 +00:00
|
|
|
extern const char *ExtGetSectorCaption(int16_t sectnum);
|
|
|
|
extern const char *ExtGetWallCaption(int16_t wallnum);
|
|
|
|
extern const char *ExtGetSpriteCaption(int16_t spritenum);
|
|
|
|
extern void ExtShowSectorData(int16_t sectnum);
|
|
|
|
extern void ExtShowWallData(int16_t wallnum);
|
|
|
|
extern void ExtShowSpriteData(int16_t spritenum);
|
|
|
|
extern void ExtEditSectorData(int16_t sectnum);
|
|
|
|
extern void ExtEditWallData(int16_t wallnum);
|
|
|
|
extern void ExtEditSpriteData(int16_t spritenum);
|
|
|
|
extern const char *ExtGetSectorType(int32_t lotag);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
extern char spritecol2d[MAXTILES][2];
|
|
|
|
|
|
|
|
char noclip=0;
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t vel, svel, angvel;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-15 03:16:38 +00:00
|
|
|
// 0 1 2 3 4 5 6 7
|
|
|
|
// up, down, left, right, lshift, rctrl, lctrl, space
|
|
|
|
// 8 9 10 11 12 13
|
|
|
|
// a, z, pgdn, pgup, [,], [.]
|
|
|
|
// 14 15 16 17 18 19
|
|
|
|
// kpenter, enter, =, -, tab, `
|
2009-01-09 09:29:17 +00:00
|
|
|
uint8_t buildkeys[NUMBUILDKEYS] =
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39,
|
|
|
|
0x1e,0x2c,0xd1,0xc9,0x33,0x34,
|
|
|
|
0x9c,0x1c,0xd,0xc,0xf,0x29
|
|
|
|
};
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
vec3_t pos;
|
|
|
|
int32_t horiz = 100;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t mousexsurp = 0, mouseysurp = 0;
|
|
|
|
int16_t ang, cursectnum;
|
|
|
|
int32_t hvel;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t grponlymode = 0;
|
|
|
|
extern int32_t editorgridextent; // in engine.c
|
2006-04-13 20:47:06 +00:00
|
|
|
extern double msens;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t graphicsmode = 0;
|
|
|
|
extern int32_t xyaspect;
|
|
|
|
extern int32_t totalclocklock;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t synctics = 0, lockclock = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
extern char vgacompatible;
|
|
|
|
|
|
|
|
extern char picsiz[MAXTILES];
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t startposx, startposy, startposz;
|
|
|
|
extern int16_t startang, startsectnum;
|
|
|
|
extern int32_t ydim16, halfxdim16, midydim16;
|
2008-02-16 22:27:08 +00:00
|
|
|
extern intptr_t frameplace;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t xdim2d = 640, ydim2d = 480, xdimgame = 640, ydimgame = 480, bppgame = 8;
|
|
|
|
int32_t forcesetup = 1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t cachesize, artsize;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static int16_t oldmousebstatus = 0;
|
|
|
|
int16_t brightness = 0;
|
2008-10-14 08:40:59 +00:00
|
|
|
char game_executable[BMAX_PATH] = DEFAULT_GAME_LOCAL_EXEC;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t zlock = 0x7fffffff, zmode = 0, whitecol, kensplayerheight = 32;
|
|
|
|
int16_t defaultspritecstat = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t localartfreq[MAXTILES];
|
|
|
|
int16_t localartlookup[MAXTILES], localartlookupnum;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
char tempbuf[4096];
|
|
|
|
|
|
|
|
char names[MAXTILES][25];
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t asksave = 0;
|
|
|
|
extern int16_t editstatus, searchit;
|
|
|
|
extern int32_t searchx, searchy; //search input
|
|
|
|
extern int16_t searchsector, searchwall, searchstat; //search output
|
|
|
|
int32_t osearchx, osearchy; //old search input
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int16_t pointhighlight, linehighlight, highlightcnt;
|
|
|
|
int16_t grid = 3, gridlock = 1, showtags = 1;
|
|
|
|
int32_t zoom = 768, gettilezoom = 1;
|
2009-05-01 06:35:27 +00:00
|
|
|
int32_t lastpm16time = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t numsprites;
|
|
|
|
extern int32_t mapversion;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t highlight[MAXWALLS];
|
|
|
|
int16_t highlightsector[MAXSECTORS], highlightsectorcnt = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
extern char textfont[128][8];
|
|
|
|
|
2008-05-16 19:51:38 +00:00
|
|
|
char pskysearch[MAXSECTORS];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t temppicnum, tempcstat, templotag, temphitag, tempextra;
|
|
|
|
uint32_t temppal, tempvis, tempxrepeat, tempyrepeat;
|
|
|
|
int32_t tempshade, tempxvel, tempyvel, tempzvel;
|
|
|
|
char somethingintab = 255;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t mlook = 0,mskip=0;
|
|
|
|
int32_t revertCTRL=0,scrollamount=3;
|
|
|
|
int32_t unrealedlook=1, quickmapcycling=1; //PK
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
static char boardfilename[BMAX_PATH], selectedboardfilename[BMAX_PATH];
|
|
|
|
|
|
|
|
static CACHE1D_FIND_REC *finddirs=NULL, *findfiles=NULL, *finddirshigh=NULL, *findfileshigh=NULL;
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t numdirs=0, numfiles=0;
|
|
|
|
static int32_t currentlist=0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
//static int32_t repeatcountx, repeatcounty;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t fillist[640];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t mousx, mousy;
|
|
|
|
int16_t prefixtiles[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
2008-03-23 00:06:42 +00:00
|
|
|
/*
|
2006-04-13 20:47:06 +00:00
|
|
|
static char scantoasc[128] =
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
0,0,'1','2','3','4','5','6','7','8','9','0','-','=',0,0,
|
|
|
|
'q','w','e','r','t','y','u','i','o','p','[',']',0,0,'a','s',
|
|
|
|
'd','f','g','h','j','k','l',';',39,'`',0,92,'z','x','c','v',
|
|
|
|
'b','n','m',',','.','/',0,'*',0,32,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1',
|
|
|
|
'2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
};
|
2006-04-13 20:47:06 +00:00
|
|
|
static char scantoascwithshift[128] =
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
0,0,'!','@','#','$','%','^','&','*','(',')','_','+',0,0,
|
|
|
|
'Q','W','E','R','T','Y','U','I','O','P','{','}',0,0,'A','S',
|
|
|
|
'D','F','G','H','J','K','L',':',34,'~',0,'|','Z','X','C','V',
|
|
|
|
'B','N','M','<','>','?',0,'*',0,32,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1',
|
|
|
|
'2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
};
|
2008-03-23 00:06:42 +00:00
|
|
|
*/
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t pk_turnaccel=16;
|
|
|
|
int32_t pk_turndecel=12;
|
|
|
|
int32_t pk_uedaccel=3;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
char lastpm16buf[60];
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
char changechar(char dachar, int32_t dadir, char smooshyalign, char boundcheck);
|
|
|
|
int32_t adjustmark(int32_t *xplc, int32_t *yplc, int16_t danumwalls);
|
|
|
|
int32_t checkautoinsert(int32_t dax, int32_t day, int16_t danumwalls);
|
2006-04-13 20:47:06 +00:00
|
|
|
void keytimerstuff(void);
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t clockdir(int16_t wallstart);
|
|
|
|
void flipwalls(int16_t numwalls, int16_t newnumwalls);
|
|
|
|
void insertpoint(int16_t linehighlight, int32_t dax, int32_t day);
|
|
|
|
void deletepoint(int16_t point);
|
|
|
|
int32_t deletesector(int16_t sucksect);
|
|
|
|
int32_t checksectorpointer(int16_t i, int16_t sectnum);
|
|
|
|
void fixrepeats(int16_t i);
|
|
|
|
int16_t loopinside(int32_t x, int32_t y, int16_t startwall);
|
|
|
|
int32_t fillsector(int16_t sectnum, char fillcolor);
|
|
|
|
int16_t whitelinescan(int16_t dalinehighlight);
|
|
|
|
void printcoords16(int32_t posxe, int32_t posye, int16_t ange);
|
|
|
|
void copysector(int16_t soursector, int16_t destsector, int16_t deststartwall, char copystat);
|
|
|
|
void showsectordata(int16_t sectnum);
|
|
|
|
void showwalldata(int16_t wallnum);
|
|
|
|
void showspritedata(int16_t spritenum);
|
|
|
|
int32_t drawtilescreen(int32_t pictopleft, int32_t picbox);
|
2006-04-13 20:47:06 +00:00
|
|
|
void overheadeditor(void);
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line);
|
2006-04-13 20:47:06 +00:00
|
|
|
void fixspritesectors(void);
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t movewalls(int32_t start, int32_t offs);
|
|
|
|
int32_t loadnames(void);
|
2006-04-13 20:47:06 +00:00
|
|
|
void updatenumsprites(void);
|
2009-01-09 09:29:17 +00:00
|
|
|
void getclosestpointonwall(int32_t x, int32_t y, int32_t dawall, int32_t *nx, int32_t *ny);
|
2006-04-13 20:47:06 +00:00
|
|
|
void initcrc(void);
|
2009-01-09 09:29:17 +00:00
|
|
|
void AutoAlignWalls(int32_t nWall0, int32_t ply);
|
|
|
|
int32_t gettile(int32_t tilenum);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t menuselect(void);
|
2008-05-15 03:16:38 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t menuselect_pk(int32_t); //PK
|
2008-05-15 03:16:38 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t getfilenames(char *path, char *kind);
|
2006-04-13 20:47:06 +00:00
|
|
|
void clearfilenames(void);
|
2008-02-02 16:38:30 +00:00
|
|
|
void loadmhk();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
void clearkeys(void) { memset(keystatus,0,sizeof(keystatus)); }
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t osdcmd_restartvid(const osdfuncparm_t *parm)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t qsetmode;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-03-23 00:06:42 +00:00
|
|
|
UNREFERENCED_PARAMETER(parm);
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (qsetmode != 200) return OSDCMD_OK;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
resetvideomode();
|
|
|
|
if (setgamemode(fullscreen,xdim,ydim,bpp))
|
|
|
|
OSD_Printf("restartvid: Reset failed...\n");
|
|
|
|
|
|
|
|
return OSDCMD_OK;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t osdcmd_vidmode(const osdfuncparm_t *parm)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t newx = xdim, newy = ydim, newbpp = bpp, newfullscreen = fullscreen;
|
|
|
|
extern int32_t qsetmode;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
switch (parm->numparms)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
case 1: // bpp switch
|
|
|
|
newbpp = Batol(parm->parms[0]);
|
|
|
|
break;
|
|
|
|
case 4: // fs, res, bpp switch
|
|
|
|
newfullscreen = (Batol(parm->parms[3]) != 0);
|
|
|
|
case 3: // res & bpp switch
|
|
|
|
newbpp = Batol(parm->parms[2]);
|
|
|
|
case 2: // res switch
|
|
|
|
newx = Batol(parm->parms[0]);
|
|
|
|
newy = Batol(parm->parms[1]);
|
|
|
|
break;
|
2006-11-13 23:12:47 +00:00
|
|
|
default:
|
|
|
|
return OSDCMD_SHOWHELP;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-10 01:29:37 +00:00
|
|
|
if (qsetmode != 200)
|
2008-02-21 05:11:41 +00:00
|
|
|
{
|
|
|
|
qsetmodeany(newx,newy);
|
|
|
|
xdim2d = xdim;
|
|
|
|
ydim2d = ydim;
|
|
|
|
|
|
|
|
begindrawing(); //{{{
|
2009-05-01 06:35:27 +00:00
|
|
|
clearbuf((char *)(frameplace + (ydim16*bytesperline)), (bytesperline*STATUS2DSIZ2) >> 2, 0x00000000l);
|
2008-02-21 05:11:41 +00:00
|
|
|
clearbuf((char *)frameplace, (ydim16*bytesperline) >> 2, 0L);
|
|
|
|
|
|
|
|
ydim16 = ydim;
|
2009-05-01 06:35:27 +00:00
|
|
|
// drawline16(0,ydim-STATUS2DSIZ,xdim-1,ydim-STATUS2DSIZ,editorcolors[1]);
|
2008-09-03 14:02:42 +00:00
|
|
|
/* drawline16(0,ydim-1,xdim-1,ydim-1,1);
|
|
|
|
drawline16(0,ydim-STATUS2DSIZ,0,ydim-1,1);
|
|
|
|
drawline16(xdim-1,ydim-STATUS2DSIZ,xdim-1,ydim-1,1);
|
|
|
|
drawline16(0,ydim-STATUS2DSIZ+24,xdim-1,ydim-STATUS2DSIZ+24,1);
|
|
|
|
drawline16(192-24,ydim-STATUS2DSIZ,192-24,ydim-STATUS2DSIZ+24,1);
|
|
|
|
drawline16(0,ydim-1-20,xdim-1,ydim-1-20,1);
|
|
|
|
drawline16(256,ydim-1-20,256,ydim-1,1); */
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2008-02-21 05:11:41 +00:00
|
|
|
enddrawing(); //}}}
|
|
|
|
return OSDCMD_OK;
|
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (setgamemode(newfullscreen,newx,newy,newbpp))
|
|
|
|
OSD_Printf("vidmode: Mode change failed!\n");
|
|
|
|
xdimgame = newx; ydimgame = newy; bppgame = newbpp; fullscreen = newfullscreen;
|
|
|
|
return OSDCMD_OK;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t startwin_run(void);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
extern char *defsfilename; // set in bstub.c
|
2007-01-22 05:00:57 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t app_main(int32_t argc, const char **argv)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-03-23 00:06:42 +00:00
|
|
|
char quitflag, cmdsetup = 0;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j, k;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
pathsearchmode = 1; // unrestrict findfrompath so that full access to the filesystem can be had
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
#ifdef USE_OPENGL
|
2008-02-24 00:46:57 +00:00
|
|
|
OSD_RegisterFunction("restartvid","restartvid: reinitialize the video mode",osdcmd_restartvid);
|
2008-10-23 20:19:30 +00:00
|
|
|
OSD_RegisterFunction("vidmode","vidmode <xdim> <ydim> <bpp> <fullscreen>: immediately change the video mode",osdcmd_vidmode);
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
wm_setapptitle("Mapster32");
|
|
|
|
|
2007-01-21 23:49:07 +00:00
|
|
|
if ((i = ExtPreInit(argc,argv)) < 0) return -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
#ifdef RENDERTYPEWIN
|
2006-04-24 19:04:22 +00:00
|
|
|
backgroundidle = 1;
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
editstatus = 1;
|
|
|
|
boardfilename[0] = 0;
|
2007-12-12 17:42:14 +00:00
|
|
|
for (i=1; i<argc; i++)
|
|
|
|
{
|
|
|
|
if (argv[i][0] == '-')
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
if (!strcmp(argv[i], "-setup")) cmdsetup = 1;
|
2007-12-12 17:42:14 +00:00
|
|
|
else if (!strcmp(argv[i], "-help") || !strcmp(argv[i], "--help") || !strcmp(argv[i], "-?"))
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
char *s =
|
|
|
|
"Mapster32\n"
|
|
|
|
"Syntax: mapster32 [options] mapname\n"
|
|
|
|
"Options:\n"
|
|
|
|
"\t-grp\tUse an extra GRP or ZIP file.\n"
|
|
|
|
"\t-g\tSame as above.\n"
|
2006-07-01 01:40:18 +00:00
|
|
|
#if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2)
|
2006-04-24 19:04:22 +00:00
|
|
|
"\t-setup\tDisplays the configuration dialogue box before entering the editor.\n"
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
;
|
2006-07-01 01:40:18 +00:00
|
|
|
#if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2)
|
2006-04-24 19:04:22 +00:00
|
|
|
wm_msgbox("Mapster32",s);
|
2006-04-13 20:47:06 +00:00
|
|
|
#else
|
2006-04-24 19:04:22 +00:00
|
|
|
puts(s);
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
if (!boardfilename[0])
|
|
|
|
{
|
2009-02-02 01:49:14 +00:00
|
|
|
Bstrncpy(boardfilename, argv[i], BMAX_PATH-4-1);
|
2006-04-24 19:04:22 +00:00
|
|
|
boardfilename[i-BMAX_PATH] = 0;
|
|
|
|
}
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
if (boardfilename[0] == 0)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
Bstrcpy(boardfilename,"newboard.map");
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if (Bstrchr(boardfilename,'.') == 0)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
Bstrcat(boardfilename, ".map");
|
|
|
|
}
|
|
|
|
//Bcanonicalisefilename(boardfilename,0);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((i = ExtInit()) < 0) return -1;
|
2006-07-01 01:40:18 +00:00
|
|
|
#if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2)
|
2007-12-12 17:42:14 +00:00
|
|
|
if (i || forcesetup || cmdsetup)
|
|
|
|
{
|
2006-07-24 02:47:47 +00:00
|
|
|
if (quitevent || !startwin_run()) return -1;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
|
|
|
|
2006-11-17 05:05:16 +00:00
|
|
|
if (initinput()) return -1;
|
|
|
|
// if (option[3] != 0) moustat =
|
|
|
|
initmouse();
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
inittimer(TIMERINTSPERSECOND);
|
|
|
|
installusertimercallback(keytimerstuff);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-19 07:09:43 +00:00
|
|
|
loadpics("tiles000.art",1048576*16);
|
2006-04-24 19:04:22 +00:00
|
|
|
loadnames();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-10-05 09:23:55 +00:00
|
|
|
Bstrcpy(kensig,"Uses BUILD technology by Ken Silverman");
|
2006-04-24 19:04:22 +00:00
|
|
|
initcrc();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (!loaddefinitionsfile(defsfilename)) initprintf("Definitions file loaded.\n");
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
k = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<256; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
j = ((int32_t)palette[i*3])+((int32_t)palette[i*3+1])+((int32_t)palette[i*3+2]);
|
2006-04-24 19:04:22 +00:00
|
|
|
if (j > k) { k = j; whitecol = i; }
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXSECTORS; i++) sector[i].extra = -1;
|
|
|
|
for (i=0; i<MAXWALLS; i++) wall[i].extra = -1;
|
|
|
|
for (i=0; i<MAXSPRITES; i++) sprite[i].extra = -1;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
ExtPreLoadMap();
|
2009-01-13 12:23:18 +00:00
|
|
|
i = loadboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
2008-02-02 16:38:30 +00:00
|
|
|
loadmhk();
|
2009-01-13 12:23:18 +00:00
|
|
|
if (i == -2) i = loadoldboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
2006-04-24 19:04:22 +00:00
|
|
|
if (i < 0)
|
|
|
|
{
|
|
|
|
initspritelists();
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.x = 32768;
|
|
|
|
pos.y = 32768;
|
|
|
|
pos.z = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
ang = 1536;
|
|
|
|
numsectors = 0;
|
|
|
|
numwalls = 0;
|
|
|
|
cursectnum = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ExtLoadMap(boardfilename);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
updatenumsprites();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
startposx = pos.x;
|
|
|
|
startposy = pos.y;
|
|
|
|
startposz = pos.z;
|
2006-04-24 19:04:22 +00:00
|
|
|
startang = ang;
|
2006-04-13 20:47:06 +00:00
|
|
|
startsectnum = cursectnum; // TX 20050225: moved to loadboard
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
totalclock = 0;
|
2007-12-12 17:42:14 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
updatesector(pos.x,pos.y,&cursectnum);
|
2007-12-12 17:42:14 +00:00
|
|
|
|
2007-01-15 00:38:21 +00:00
|
|
|
if (cursectnum == -1)
|
|
|
|
{
|
2008-08-12 22:38:50 +00:00
|
|
|
double gamma = vid_gamma;
|
|
|
|
vid_gamma = 1.0;
|
2007-01-15 00:38:21 +00:00
|
|
|
setbrightness(0,palette,0);
|
|
|
|
overheadeditor();
|
2008-05-16 00:23:33 +00:00
|
|
|
keystatus[buildkeys[BK_MODE2D_3D]] = 0;
|
2008-08-12 22:38:50 +00:00
|
|
|
vid_gamma = gamma;
|
|
|
|
setbrightness(brightness,palette,0);
|
2007-01-15 00:38:21 +00:00
|
|
|
}
|
2009-05-01 19:28:57 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (setgamemode(fullscreen,xdimgame,ydimgame,bppgame) < 0)
|
|
|
|
{
|
|
|
|
ExtUnInit();
|
|
|
|
uninitengine();
|
|
|
|
Bprintf("%d * %d not supported in this graphics mode\n",xdim,ydim);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
setbrightness(brightness,palette,0);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
CANCEL:
|
2006-04-24 19:04:22 +00:00
|
|
|
quitflag = 0;
|
|
|
|
while (quitflag == 0)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
|
|
|
{
|
|
|
|
if (quitevent)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
keystatus[1] = 1;
|
|
|
|
quitevent = 0;
|
|
|
|
}
|
2006-12-11 22:23:56 +00:00
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
OSD_DispatchQueued();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
ExtPreCheckKeys();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum);
|
2006-04-13 20:47:06 +00:00
|
|
|
#ifdef SUPERBUILD
|
2006-04-24 19:04:22 +00:00
|
|
|
ExtAnalyzeSprites();
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
drawmasks();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
ExtCheckKeys();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
nextpage();
|
|
|
|
synctics = totalclock-lockclock;
|
|
|
|
lockclock += synctics;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[1])
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[1] = 0;
|
|
|
|
begindrawing(); //{{{
|
2006-04-13 20:47:06 +00:00
|
|
|
printext256(0,0,whitecol,0,"Are you sure you want to quit?",0);
|
2006-04-24 19:04:22 +00:00
|
|
|
enddrawing(); //}}}
|
|
|
|
|
|
|
|
showframe(1);
|
|
|
|
synctics = totalclock-lockclock;
|
|
|
|
lockclock += synctics;
|
|
|
|
|
|
|
|
while ((keystatus[1]|keystatus[0x1c]|keystatus[0x39]|keystatus[0x31]) == 0)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
|
|
|
{
|
|
|
|
if (quitevent)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
quitflag = 1;
|
|
|
|
break;
|
|
|
|
}
|
2007-01-12 05:49:09 +00:00
|
|
|
}
|
|
|
|
idle();
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-05-18 21:09:30 +00:00
|
|
|
if (keystatus[0x15]||keystatus[0x1c]) // Y or ENTER
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
keystatus[0x15] = 0;
|
2008-05-18 21:09:30 +00:00
|
|
|
keystatus[0x1c] = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
quitflag = 1; break;
|
|
|
|
}
|
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
while (keystatus[1])
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
keystatus[1] = 0;
|
|
|
|
quitevent = 0;
|
|
|
|
goto CANCEL;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (asksave)
|
|
|
|
{
|
|
|
|
begindrawing(); //{{{
|
|
|
|
printext256(0,8,whitecol,0,"Save changes?",0);
|
|
|
|
showframe(1); //}}}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
while ((keystatus[1]|keystatus[0x1c]|keystatus[0x39]|keystatus[0x31]|keystatus[0x2e]) == 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2006-12-11 21:56:00 +00:00
|
|
|
if (handleevents()) { if (quitevent) break; } // like saying no
|
2007-01-12 05:49:09 +00:00
|
|
|
idle();
|
2007-12-12 17:42:14 +00:00
|
|
|
|
2008-05-18 21:09:30 +00:00
|
|
|
if (keystatus[0x15] || keystatus[0x1c]) // Y or ENTER
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2008-03-15 21:04:35 +00:00
|
|
|
char *f;
|
2006-04-24 19:04:22 +00:00
|
|
|
keystatus[0x15] = 0;
|
2008-05-18 21:09:30 +00:00
|
|
|
keystatus[0x1c] = 0;
|
2007-01-30 02:04:14 +00:00
|
|
|
fixspritesectors();
|
2006-04-24 19:04:22 +00:00
|
|
|
updatesector(startposx,startposy,&startsectnum);
|
|
|
|
ExtPreSaveMap();
|
2008-03-15 21:04:35 +00:00
|
|
|
if (pathsearchmode) f = boardfilename;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// virtual filesystem mode can't save to directories so drop the file into
|
|
|
|
// the current directory
|
|
|
|
f = strrchr(boardfilename, '/');
|
|
|
|
if (!f) f = boardfilename; else f++;
|
|
|
|
}
|
|
|
|
saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
|
|
|
|
ExtSaveMap(f);
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
while (keystatus[1]||keystatus[0x2e])
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
keystatus[1] = 0;
|
|
|
|
keystatus[0x2e] = 0;
|
|
|
|
quitevent = 0;
|
|
|
|
goto CANCEL;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
clearfilenames();
|
|
|
|
ExtUnInit();
|
|
|
|
uninitengine();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bprintf("Memory status: %d(%d) bytes\n",cachesize,artsize);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bprintf("%s\n",kensig);
|
|
|
|
return(0);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2008-05-16 19:51:38 +00:00
|
|
|
/*
|
2006-04-13 20:47:06 +00:00
|
|
|
void showmouse(void)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
for (i=1;i<=4;i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
plotpixel(searchx+i,searchy,whitecol);
|
|
|
|
plotpixel(searchx-i,searchy,whitecol);
|
|
|
|
plotpixel(searchx,searchy-i,whitecol);
|
|
|
|
plotpixel(searchx,searchy+i,whitecol);
|
|
|
|
}
|
2008-05-16 19:51:38 +00:00
|
|
|
}*/
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t mhk=0;
|
2008-02-02 16:38:30 +00:00
|
|
|
void loadmhk()
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
char *p; char levname[BMAX_PATH];
|
2008-02-02 16:38:30 +00:00
|
|
|
|
2008-02-07 04:38:28 +00:00
|
|
|
if (!mhk)return;
|
2008-02-02 16:38:30 +00:00
|
|
|
strcpy(levname, boardfilename);
|
|
|
|
p = Bstrrchr(levname,'.');
|
|
|
|
if (!p) strcat(levname,".mhk");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p[1]='m';
|
|
|
|
p[2]='h';
|
|
|
|
p[3]='k';
|
|
|
|
p[4]=0;
|
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
if (!loadmaphack(levname))initprintf("Loaded map hack file '%s'\n",levname); else mhk=2;
|
2008-02-02 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
void editinput(void)
|
|
|
|
{
|
2008-05-16 19:51:38 +00:00
|
|
|
// char smooshyalign, repeatpanalign, buffer[80];
|
|
|
|
// short sectnum, nextsectnum, startwall, endwall, dasector, daang;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t mousz, bstatus;
|
|
|
|
int32_t i, j, k, /*cnt,*/ tempint=0, doubvel/*, changedir, wallfind[2], daz[2]*/;
|
|
|
|
int32_t /*dashade[2],*/ goalz, xvect, yvect,/*PK*/ zvect, hiz, loz;
|
2009-01-13 12:23:18 +00:00
|
|
|
hitdata_t hitinfo;
|
|
|
|
int32_t dax, day, hihit, lohit;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-15 03:16:38 +00:00
|
|
|
// 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46
|
|
|
|
// F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL
|
|
|
|
|
2008-05-16 19:51:38 +00:00
|
|
|
/* if (keystatus[0x57] > 0) //F11 - brightness
|
|
|
|
{
|
|
|
|
keystatus[0x57] = 0;
|
|
|
|
brightness++;
|
|
|
|
if (brightness >= 16) brightness = 0;
|
|
|
|
setbrightness(brightness,palette,0);
|
|
|
|
}
|
|
|
|
if (keystatus[88] > 0) //F12
|
|
|
|
{
|
|
|
|
screencapture("captxxxx.tga",keystatus[0x2a]|keystatus[0x36]);
|
|
|
|
keystatus[88] = 0;
|
|
|
|
}*/
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
mousz = 0;
|
|
|
|
getmousevalues(&mousx,&mousy,&bstatus);
|
|
|
|
mousx = (mousx<<16)+mousexsurp;
|
|
|
|
mousy = (mousy<<16)+mouseysurp;
|
2008-09-04 23:11:48 +00:00
|
|
|
|
|
|
|
if ((unrealedlook && !mskip) &&
|
2008-10-20 04:00:00 +00:00
|
|
|
(((!mlook && (bstatus&2) && !(bstatus&(1|4)))) || ((bstatus&1) && !(bstatus&(2|4)))))
|
2008-09-04 23:11:48 +00:00
|
|
|
mlook = 3;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
ldiv_t ld;
|
2008-09-04 23:11:48 +00:00
|
|
|
if (mlook)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
ld = ldiv((int32_t)(mousx), (int32_t)((1<<16)/(msens*0.5f))); mousx = ld.quot; mousexsurp = ld.rem;
|
|
|
|
ld = ldiv((int32_t)(mousy), (int32_t)((1<<16)/(msens*0.25f))); mousy = ld.quot; mouseysurp = ld.rem;
|
2008-09-04 23:11:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
ld = ldiv((int32_t)(mousx), (int32_t)((1<<16)/msens)); mousx = ld.quot; mousexsurp = ld.rem;
|
|
|
|
ld = ldiv((int32_t)(mousy), (int32_t)((1<<16)/msens)); mousy = ld.quot; mouseysurp = ld.rem;
|
2008-09-04 23:11:48 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-09-04 23:11:48 +00:00
|
|
|
if (mlook == 3)
|
|
|
|
mlook = 0;
|
|
|
|
|
2008-05-15 03:16:38 +00:00
|
|
|
// UnrealEd:
|
|
|
|
// rmb: mouselook
|
|
|
|
// lbm: x:turn y:fwd/back local x
|
|
|
|
// lmb&rmb: x:strafe y:up/dn (move in local yz plane)
|
|
|
|
// mmb: fwd/back in viewing vector
|
|
|
|
|
2008-05-16 19:51:38 +00:00
|
|
|
if (unrealedlook && !mskip) //PK
|
2008-05-15 03:16:38 +00:00
|
|
|
{
|
|
|
|
if ((bstatus&1) && !(bstatus&(2|4)))
|
|
|
|
{
|
2008-09-04 23:11:48 +00:00
|
|
|
ang += mousx;
|
2009-01-09 09:29:17 +00:00
|
|
|
xvect = -((mousy*(int32_t)sintable[(ang+2560)&2047])<<(3+pk_uedaccel));
|
|
|
|
yvect = -((mousy*(int32_t)sintable[(ang+2048)&2047])<<(3+pk_uedaccel));
|
2008-05-15 03:16:38 +00:00
|
|
|
|
|
|
|
if (noclip)
|
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.x += xvect>>14;
|
|
|
|
pos.y += yvect>>14;
|
|
|
|
updatesector(pos.x,pos.y,&cursectnum);
|
2008-05-15 03:16:38 +00:00
|
|
|
}
|
2009-01-13 12:23:18 +00:00
|
|
|
else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0);
|
2008-05-15 03:16:38 +00:00
|
|
|
}
|
|
|
|
else if (!mlook && (bstatus&2) && !(bstatus&(1|4)))
|
|
|
|
{
|
|
|
|
mlook=2;
|
|
|
|
}
|
|
|
|
else if ((bstatus&1) && (bstatus&2) && !(bstatus&4))
|
|
|
|
{
|
|
|
|
zmode = 2;
|
2009-01-09 09:29:17 +00:00
|
|
|
xvect = -((mousx*(int32_t)sintable[(ang+2048)&2047])<<pk_uedaccel);
|
|
|
|
yvect = -((mousx*(int32_t)sintable[(ang+1536)&2047])<<pk_uedaccel);
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.z += mousy<<(4+pk_uedaccel);
|
2008-05-15 03:16:38 +00:00
|
|
|
if (noclip)
|
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.x += xvect>>14;
|
|
|
|
pos.y += yvect>>14;
|
|
|
|
updatesectorz(pos.x,pos.y,pos.z,&cursectnum);
|
2008-05-15 03:16:38 +00:00
|
|
|
}
|
2009-01-13 12:23:18 +00:00
|
|
|
else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0);
|
2008-05-15 03:16:38 +00:00
|
|
|
}
|
|
|
|
else if (bstatus&4)
|
|
|
|
{
|
|
|
|
zmode = 2;
|
|
|
|
|
|
|
|
// horiz-100 of 200 is viewing at 326.4 build angle units (=atan(200/128)) upward
|
|
|
|
tempint = getangle(128, horiz-100);
|
|
|
|
|
|
|
|
xvect = -((mousy*
|
2009-01-09 09:29:17 +00:00
|
|
|
((int32_t)sintable[(ang+2560)&2047]>>6)*
|
|
|
|
((int32_t)sintable[(tempint+512)&2047])>>6)
|
2008-05-15 03:16:38 +00:00
|
|
|
<<pk_uedaccel);
|
|
|
|
yvect = -((mousy*
|
2009-01-09 09:29:17 +00:00
|
|
|
((int32_t)sintable[(ang+2048)&2047]>>6)*
|
|
|
|
((int32_t)sintable[(tempint+512)&2047])>>6)
|
2008-05-15 03:16:38 +00:00
|
|
|
<<pk_uedaccel);
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
zvect = mousy*(((int32_t)sintable[(tempint+2048)&2047])>>(10-pk_uedaccel));
|
2008-05-15 03:16:38 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.z += zvect;
|
2008-05-15 03:16:38 +00:00
|
|
|
if (noclip)
|
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.x += xvect>>16;
|
|
|
|
pos.y += yvect>>16;
|
|
|
|
updatesectorz(pos.x,pos.y,pos.z,&cursectnum);
|
2008-05-15 03:16:38 +00:00
|
|
|
}
|
2009-01-13 12:23:18 +00:00
|
|
|
else clipmove(&pos,&cursectnum,xvect>>2,yvect>>2,128L,4L<<8,4L<<8,CLIPMASK0);
|
2008-05-15 03:16:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-03 14:02:42 +00:00
|
|
|
if (mskip)
|
|
|
|
mskip=0;
|
|
|
|
else
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-05-16 19:51:38 +00:00
|
|
|
if (mlook && !(unrealedlook && bstatus&(1|4)))
|
2008-09-03 14:02:42 +00:00
|
|
|
{
|
2008-09-04 23:11:48 +00:00
|
|
|
ang += mousx;
|
|
|
|
horiz -= mousy;
|
2008-09-03 14:02:42 +00:00
|
|
|
|
2008-09-04 23:11:48 +00:00
|
|
|
// if (mousy && !(mousy/4))
|
2008-10-20 04:00:00 +00:00
|
|
|
// horiz--;
|
|
|
|
// if (mousx && !(mousx/2))
|
|
|
|
// ang++;
|
2008-09-03 14:02:42 +00:00
|
|
|
if (horiz > 299)
|
|
|
|
horiz = 299;
|
|
|
|
if (horiz < -99)
|
|
|
|
horiz = -99;
|
|
|
|
if (mlook == 1)
|
|
|
|
{
|
|
|
|
searchx = xdim>>1;
|
|
|
|
searchy = ydim>>1;
|
|
|
|
}
|
|
|
|
osearchx = searchx-mousx;
|
|
|
|
osearchy = searchy-mousy;
|
|
|
|
}
|
|
|
|
else if (!(unrealedlook && (bstatus&(1|2|4))))
|
|
|
|
{
|
|
|
|
osearchx = searchx;
|
|
|
|
osearchy = searchy;
|
|
|
|
searchx += mousx;
|
|
|
|
searchy += mousy;
|
|
|
|
if (searchx < 12) searchx = 12;
|
|
|
|
if (searchy < 12) searchy = 12;
|
|
|
|
if (searchx > xdim-13) searchx = xdim-13;
|
|
|
|
if (searchy > ydim-13) searchy = ydim-13;
|
|
|
|
}
|
2008-05-16 19:51:38 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-16 19:51:38 +00:00
|
|
|
// showmouse();
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
// if (keystatus[0x3b] > 0) pos.x--;
|
|
|
|
// if (keystatus[0x3c] > 0) pos.x++;
|
|
|
|
// if (keystatus[0x3d] > 0) pos.y--;
|
|
|
|
// if (keystatus[0x3e] > 0) pos.y++;
|
2008-02-02 16:38:30 +00:00
|
|
|
// if (keystatus[0x43] > 0) ang--;
|
|
|
|
// if (keystatus[0x44] > 0) ang++;
|
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x43])
|
2008-02-02 16:38:30 +00:00
|
|
|
{
|
|
|
|
mhk=1;
|
|
|
|
loadmhk();
|
|
|
|
keystatus[0x43] = 0;
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x44])
|
2008-02-02 16:38:30 +00:00
|
|
|
{
|
2009-01-10 07:38:50 +00:00
|
|
|
memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
|
2009-05-01 06:35:27 +00:00
|
|
|
memset(spritesmooth, 0, sizeof(spritesmooth_t) *(MAXSPRITES+MAXUNIQHUDID));
|
2009-04-29 19:43:51 +00:00
|
|
|
#ifdef POLYMER
|
2009-04-24 02:53:50 +00:00
|
|
|
staticlightcount = 0;
|
2009-04-29 19:43:51 +00:00
|
|
|
#endif
|
2008-02-02 16:38:30 +00:00
|
|
|
mhk=0;
|
2008-02-07 04:38:28 +00:00
|
|
|
initprintf("Maphacks disabled\n");
|
2008-02-02 16:38:30 +00:00
|
|
|
keystatus[0x44] = 0;
|
|
|
|
}
|
|
|
|
begindrawing(); //{{{
|
2008-02-07 04:38:28 +00:00
|
|
|
if (mhk)printext256(0,16,whitecol,0,(mhk==1)?"Maphacks ON":"Maphacks ON (not found)",0);
|
2008-02-02 16:38:30 +00:00
|
|
|
enddrawing(); //}}}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if (angvel != 0) //ang += angvel * constant
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
//ENGINE calculates angvel for you
|
2006-04-24 19:04:22 +00:00
|
|
|
doubvel = synctics;
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_RUN]]) //Lt. shift makes turn velocity 50% faster
|
2006-04-24 19:04:22 +00:00
|
|
|
doubvel += (synctics>>1);
|
|
|
|
ang += ((angvel*doubvel)>>4);
|
|
|
|
ang = (ang+2048)&2047;
|
|
|
|
}
|
|
|
|
if ((vel|svel) != 0)
|
|
|
|
{
|
|
|
|
doubvel = synctics;
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_RUN]]) //Lt. shift doubles forward velocity
|
2006-04-24 19:04:22 +00:00
|
|
|
doubvel += synctics;
|
|
|
|
xvect = 0, yvect = 0;
|
|
|
|
if (vel != 0)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
xvect += ((vel*doubvel*(int32_t)sintable[(ang+2560)&2047])>>3);
|
|
|
|
yvect += ((vel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
if (svel != 0)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
xvect += ((svel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3);
|
|
|
|
yvect += ((svel*doubvel*(int32_t)sintable[(ang+1536)&2047])>>3);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
if (noclip)
|
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.x += xvect>>14;
|
|
|
|
pos.y += yvect>>14;
|
|
|
|
updatesector(pos.x,pos.y,&cursectnum);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2009-01-13 12:23:18 +00:00
|
|
|
else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2009-01-13 12:23:18 +00:00
|
|
|
getzrange(&pos,cursectnum,&hiz,&hihit,&loz,&lohit,128L,CLIPMASK0);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-16 19:51:38 +00:00
|
|
|
/* if (keystatus[0x3a] > 0)
|
|
|
|
{
|
|
|
|
zmode++;
|
|
|
|
if (zmode == 3) zmode = 0;
|
2009-01-13 12:23:18 +00:00
|
|
|
if (zmode == 1) zlock = (loz-pos.z)&0xfffffc00;
|
2008-05-16 19:51:38 +00:00
|
|
|
keystatus[0x3a] = 0;
|
|
|
|
}*/
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (zmode == 0)
|
|
|
|
{
|
|
|
|
goalz = loz-(kensplayerheight<<8); //playerheight pixels above floor
|
|
|
|
if (goalz < hiz+(16<<8)) //ceiling&floor too close
|
|
|
|
goalz = ((loz+hiz)>>1);
|
|
|
|
goalz += mousz;
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_MOVEUP]]) //A (stand high)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
/*
|
|
|
|
if (keystatus[0x1d]|keystatus[0x9d])
|
|
|
|
horiz = max(-100,horiz-((keystatus[buildkeys[BK_RUN]]+1)*synctics*2));
|
|
|
|
else
|
|
|
|
*/
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
goalz -= (16<<8);
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_RUN]]) //Either shift key
|
2006-04-24 19:04:22 +00:00
|
|
|
goalz -= (24<<8);
|
|
|
|
}
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_MOVEDOWN]]) //Z (stand low)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
/*
|
|
|
|
if (keystatus[0x1d]|keystatus[0x9d])
|
|
|
|
horiz = min(300,horiz+((keystatus[buildkeys[BK_RUN]]+1)*synctics*2));
|
|
|
|
else
|
|
|
|
*/
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
goalz += (12<<8);
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_RUN]]) //Either shift key
|
2006-04-24 19:04:22 +00:00
|
|
|
goalz += (12<<8);
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
if (goalz != pos.z)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
if (pos.z < goalz) hvel += 64;
|
|
|
|
if (pos.z > goalz) hvel = ((goalz-pos.z)>>3);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.z += hvel;
|
|
|
|
if (pos.z > loz-(4<<8)) pos.z = loz-(4<<8), hvel = 0;
|
|
|
|
if (pos.z < hiz+(4<<8)) pos.z = hiz+(4<<8), hvel = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
goalz = pos.z;
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_MOVEUP]]) //A
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x1d]|keystatus[0x9d])
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2008-05-16 00:23:33 +00:00
|
|
|
horiz = max(-100,horiz-((keystatus[buildkeys[BK_RUN]]+1)*synctics*2));
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (zmode != 1)
|
|
|
|
goalz -= (8<<8);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
zlock += (4<<8);
|
2008-05-16 00:23:33 +00:00
|
|
|
keystatus[buildkeys[BK_MOVEUP]] = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_MOVEDOWN]]) //Z (stand low)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x1d]|keystatus[0x9d])
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2008-05-16 00:23:33 +00:00
|
|
|
horiz = min(300,horiz+((keystatus[buildkeys[BK_RUN]]+1)*synctics*2));
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (zmode != 1)
|
|
|
|
goalz += (8<<8);
|
|
|
|
else if (zlock > 0)
|
|
|
|
{
|
|
|
|
zlock -= (4<<8);
|
2008-05-16 00:23:33 +00:00
|
|
|
keystatus[buildkeys[BK_MOVEDOWN]] = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-04-27 22:47:47 +00:00
|
|
|
if (!noclip)
|
|
|
|
{
|
|
|
|
if (goalz < hiz+(4<<8)) goalz = hiz+(4<<8);
|
|
|
|
if (goalz > loz-(4<<8)) goalz = loz-(4<<8);
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
if (zmode == 1) goalz = loz-zlock;
|
2008-04-27 22:47:47 +00:00
|
|
|
if (!noclip && (goalz < hiz+(4<<8))) goalz = ((loz+hiz)>>1); //ceiling&floor too close
|
2009-01-13 12:23:18 +00:00
|
|
|
if (zmode == 1) pos.z = goalz;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
if (goalz != pos.z)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
//if (pos.z < goalz) hvel += (32<<keystatus[buildkeys[BK_RUN]]);
|
|
|
|
//if (pos.z > goalz) hvel -= (32<<keystatus[buildkeys[BK_RUN]]);
|
|
|
|
if (pos.z < goalz) hvel = ((synctics* 192)<<keystatus[buildkeys[BK_RUN]]);
|
|
|
|
if (pos.z > goalz) hvel = ((synctics*-192)<<keystatus[buildkeys[BK_RUN]]);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.z += hvel;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-04-27 22:47:47 +00:00
|
|
|
if (!noclip)
|
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
if (pos.z > loz-(4<<8)) pos.z = loz-(4<<8), hvel = 0;
|
|
|
|
if (pos.z < hiz+(4<<8)) pos.z = hiz+(4<<8), hvel = 0;
|
2008-04-27 22:47:47 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
hvel = 0;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
searchit = 2;
|
|
|
|
if (searchstat >= 0)
|
|
|
|
{
|
2006-04-13 20:47:06 +00:00
|
|
|
if ((bstatus&(1|2|4)) > 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
searchit = 0;
|
2008-05-16 19:51:38 +00:00
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x1f]) //S (insert sprite) (3D)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
dax = 16384;
|
|
|
|
day = divscale14(searchx-(xdim>>1),xdim>>1);
|
|
|
|
rotatepoint(0,0,dax,day,ang,&dax,&day);
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
hitscan((const vec3_t *)&pos,cursectnum, //Start position
|
2006-04-24 19:04:22 +00:00
|
|
|
dax,day,(scale(searchy,200,ydim)-horiz)*2000, //vector of 3D ang
|
2009-01-13 12:23:18 +00:00
|
|
|
&hitinfo,CLIPMASK1);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
if (hitinfo.hitsect >= 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
dax = hitinfo.pos.x;
|
2009-01-19 06:41:28 +00:00
|
|
|
day = hitinfo.pos.y;
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((gridlock > 0) && (grid > 0))
|
|
|
|
{
|
|
|
|
if ((searchstat == 0) || (searchstat == 4))
|
|
|
|
{
|
2009-01-19 06:41:28 +00:00
|
|
|
hitinfo.pos.z = (hitinfo.pos.z&0xfffffc00);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
day = ((day+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
i = insertsprite(hitinfo.hitsect,0);
|
2006-04-24 19:04:22 +00:00
|
|
|
sprite[i].x = dax, sprite[i].y = day;
|
|
|
|
sprite[i].cstat = defaultspritecstat;
|
|
|
|
sprite[i].shade = 0;
|
|
|
|
sprite[i].pal = 0;
|
|
|
|
sprite[i].xrepeat = 64, sprite[i].yrepeat = 64;
|
|
|
|
sprite[i].xoffset = 0, sprite[i].yoffset = 0;
|
|
|
|
sprite[i].ang = 1536;
|
|
|
|
sprite[i].xvel = 0; sprite[i].yvel = 0; sprite[i].zvel = 0;
|
|
|
|
sprite[i].owner = -1;
|
|
|
|
sprite[i].clipdist = 32;
|
|
|
|
sprite[i].lotag = 0;
|
|
|
|
sprite[i].hitag = 0;
|
|
|
|
sprite[i].extra = -1;
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=0; k<MAXTILES; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
localartfreq[k] = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=0; k<MAXSPRITES; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (sprite[k].statnum < MAXSTATUS)
|
|
|
|
localartfreq[sprite[k].picnum]++;
|
|
|
|
j = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=0; k<MAXTILES; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (localartfreq[k] > localartfreq[j])
|
|
|
|
j = k;
|
|
|
|
if (localartfreq[j] > 0)
|
|
|
|
sprite[i].picnum = j;
|
|
|
|
else
|
|
|
|
sprite[i].picnum = 0;
|
|
|
|
|
|
|
|
if (somethingintab == 3)
|
|
|
|
{
|
|
|
|
sprite[i].picnum = temppicnum;
|
|
|
|
if ((tilesizx[temppicnum] <= 0) || (tilesizy[temppicnum] <= 0))
|
|
|
|
{
|
|
|
|
j = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=0; k<MAXTILES; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((tilesizx[k] > 0) && (tilesizy[k] > 0))
|
|
|
|
{
|
|
|
|
j = k;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sprite[i].picnum = j;
|
|
|
|
}
|
|
|
|
sprite[i].shade = tempshade;
|
|
|
|
sprite[i].pal = temppal;
|
|
|
|
sprite[i].xrepeat = tempxrepeat;
|
|
|
|
sprite[i].yrepeat = tempyrepeat;
|
|
|
|
if (sprite[i].xrepeat < 1) sprite[i].xrepeat = 1;
|
|
|
|
if (sprite[i].yrepeat < 1) sprite[i].yrepeat = 1;
|
|
|
|
sprite[i].cstat = tempcstat;
|
|
|
|
}
|
|
|
|
|
|
|
|
j = ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1);
|
|
|
|
if ((sprite[i].cstat&128) == 0)
|
2009-01-19 06:41:28 +00:00
|
|
|
sprite[i].z = min(max(hitinfo.pos.z,
|
2009-02-19 16:47:54 +00:00
|
|
|
getceilzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)+(j<<1)),
|
|
|
|
getflorzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y));
|
2006-04-24 19:04:22 +00:00
|
|
|
else
|
2009-01-19 06:41:28 +00:00
|
|
|
sprite[i].z = min(max(hitinfo.pos.z,
|
2009-02-19 16:47:54 +00:00
|
|
|
getceilzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)+j),
|
|
|
|
getflorzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)-j);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if ((searchstat == 0) || (searchstat == 4))
|
|
|
|
{
|
|
|
|
sprite[i].cstat = (sprite[i].cstat&~48)|(16+64);
|
2009-01-13 12:23:18 +00:00
|
|
|
if (hitinfo.hitwall >= 0)
|
|
|
|
sprite[i].ang = ((getangle(wall[wall[hitinfo.hitwall].point2].x-wall[hitinfo.hitwall].x,
|
2009-02-19 16:47:54 +00:00
|
|
|
wall[wall[hitinfo.hitwall].point2].y-wall[hitinfo.hitwall].y)+512)&2047);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
//Make sure sprite's in right sector
|
|
|
|
if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0)
|
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
j = wall[hitinfo.hitwall].point2;
|
|
|
|
sprite[i].x -= ksgn(wall[j].y-wall[hitinfo.hitwall].y);
|
|
|
|
sprite[i].y += ksgn(wall[j].x-wall[hitinfo.hitwall].x);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (tilesizy[sprite[i].picnum] >= 32) sprite[i].cstat |= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
updatenumsprites();
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
keystatus[0x1f] = 0;
|
|
|
|
}
|
2008-05-16 19:51:38 +00:00
|
|
|
/* if (keystatus[0xd3] > 0)
|
|
|
|
{
|
|
|
|
if (searchstat == 3)
|
|
|
|
{
|
|
|
|
deletesprite(searchwall);
|
|
|
|
updatenumsprites();
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
keystatus[0xd3] = 0;
|
|
|
|
}*/
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x3f]||keystatus[0x40]) //F5,F6
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
switch (searchstat)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
ExtShowSectorData(searchsector); break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
ExtShowWallData(searchwall); break;
|
|
|
|
case 3:
|
|
|
|
ExtShowSpriteData(searchwall); break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
keystatus[0x3f] = 0, keystatus[0x40] = 0;
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x41]||keystatus[0x42]) //F7,F8
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
switch (searchstat)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
ExtEditSectorData(searchsector); break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
ExtEditWallData(searchwall); break;
|
|
|
|
case 3:
|
|
|
|
ExtEditSpriteData(searchwall); break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
keystatus[0x41] = 0, keystatus[0x42] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_MODE2D_3D]]) // Enter
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-08-12 22:38:50 +00:00
|
|
|
double gamma = vid_gamma;
|
|
|
|
vid_gamma = 1.0;
|
2006-11-19 07:31:03 +00:00
|
|
|
setbrightness(0,palette,0);
|
2006-04-24 19:04:22 +00:00
|
|
|
overheadeditor();
|
2008-05-16 00:23:33 +00:00
|
|
|
keystatus[buildkeys[BK_MODE2D_3D]] = 0;
|
2008-08-12 22:38:50 +00:00
|
|
|
vid_gamma = gamma;
|
|
|
|
setbrightness(brightness,palette,0);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
char changechar(char dachar, int32_t dadir, char smooshyalign, char boundcheck)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (dadir < 0)
|
|
|
|
{
|
|
|
|
if ((dachar > 0) || (boundcheck == 0))
|
|
|
|
{
|
|
|
|
dachar--;
|
|
|
|
if (smooshyalign > 0)
|
|
|
|
dachar = (dachar&0xf8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dadir > 0)
|
|
|
|
{
|
|
|
|
if ((dachar < 255) || (boundcheck == 0))
|
|
|
|
{
|
|
|
|
dachar++;
|
|
|
|
if (smooshyalign > 0)
|
|
|
|
{
|
|
|
|
if (dachar >= 256-8) dachar = 255;
|
|
|
|
else dachar = ((dachar+7)&0xf8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(dachar);
|
|
|
|
}
|
|
|
|
|
|
|
|
void overheadeditor(void)
|
|
|
|
{
|
|
|
|
char buffer[80], *dabuffer, ch;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j, k, m=0, mousxplc, mousyplc, firstx=0, firsty=0, oposz, col;
|
|
|
|
int32_t tempint, tempint1, tempint2, doubvel;
|
|
|
|
int32_t startwall=0, endwall, dax, day, daz, x1, y1, x2, y2, x3, y3, x4, y4;
|
|
|
|
int32_t highlightx1, highlighty1, highlightx2, highlighty2, xvect, yvect;
|
|
|
|
int16_t pag, suckwall=0, sucksect, newnumwalls, newnumsectors, split=0, bad;
|
|
|
|
int16_t splitsect=0, danumwalls, secondstartwall, joinsector[2], joinsectnum;
|
|
|
|
int16_t splitstartwall=0, splitendwall, loopnum;
|
|
|
|
int32_t mousx, mousy, bstatus;
|
|
|
|
int32_t centerx, centery, circlerad;
|
|
|
|
int16_t circlepoints, circleang1, circleang2, circleangdir;
|
|
|
|
int32_t sectorhighlightx=0, sectorhighlighty=0;
|
|
|
|
int16_t cursectorhighlight, sectorhighlightstat;
|
2006-04-24 19:04:22 +00:00
|
|
|
walltype *wal;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t prefixarg = 0;
|
2009-01-13 12:23:18 +00:00
|
|
|
hitdata_t hitinfo;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
//qsetmode640480();
|
|
|
|
qsetmodeany(xdim2d,ydim2d);
|
|
|
|
xdim2d = xdim;
|
|
|
|
ydim2d = ydim;
|
|
|
|
|
|
|
|
osearchx = searchx;
|
|
|
|
osearchy = searchy;
|
|
|
|
|
|
|
|
searchx = scale(searchx,xdim2d,xdimgame);
|
2009-05-01 06:35:27 +00:00
|
|
|
searchy = scale(searchy,ydim2d-STATUS2DSIZ2,ydimgame);
|
2009-01-13 12:23:18 +00:00
|
|
|
oposz = pos.z;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
begindrawing(); //{{{
|
2009-05-01 06:35:27 +00:00
|
|
|
clearbuf((char *)(frameplace + (ydim16*bytesperline)), (bytesperline*STATUS2DSIZ2) >> 2, 0x00000000l);
|
2006-04-24 19:04:22 +00:00
|
|
|
clearbuf((char *)frameplace, (ydim16*bytesperline) >> 2, 0L);
|
|
|
|
|
|
|
|
ydim16 = ydim;
|
2009-05-01 06:35:27 +00:00
|
|
|
// drawline16(0,ydim-STATUS2DSIZ2,xdim-1,ydim-STATUS2DSIZ2,editorcolors[1]);
|
2008-09-03 14:02:42 +00:00
|
|
|
/* drawline16(0,ydim-1,xdim-1,ydim-1,1);
|
|
|
|
drawline16(0,ydim-STATUS2DSIZ,0,ydim-1,1);
|
|
|
|
drawline16(xdim-1,ydim-STATUS2DSIZ,xdim-1,ydim-1,1);
|
|
|
|
drawline16(0,ydim-STATUS2DSIZ+24,xdim-1,ydim-STATUS2DSIZ+24,1);
|
|
|
|
drawline16(192-24,ydim-STATUS2DSIZ,192-24,ydim-STATUS2DSIZ+24,1); */
|
2008-02-21 05:11:41 +00:00
|
|
|
if (totalclock < 120*5)
|
2008-09-03 04:20:46 +00:00
|
|
|
{
|
2008-09-03 14:02:42 +00:00
|
|
|
printmessage16("Press F1 for help");
|
2008-12-23 23:27:53 +00:00
|
|
|
printext16(8L,ydim-STATUS2DSIZ+32L,editorcolors[9],-1,kensig,0);
|
2008-09-03 04:20:46 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
// printmessage16("Version: "VERSION);
|
2008-09-01 07:15:16 +00:00
|
|
|
// drawline16(0,ydim-1-20,xdim-1,ydim-1-20,1);
|
2008-09-04 23:11:48 +00:00
|
|
|
// drawline16(256,ydim-1-20,256,ydim-1,1);
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2006-04-24 19:04:22 +00:00
|
|
|
enddrawing(); //}}}
|
|
|
|
|
|
|
|
pag = 0;
|
|
|
|
highlightcnt = -1;
|
|
|
|
cursectorhighlight = -1;
|
|
|
|
lastpm16time = -1;
|
|
|
|
|
|
|
|
//White out all bordering lines of grab that are
|
|
|
|
//not highlighted on both sides
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=highlightsectorcnt-1; i>=0; i--)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall + sector[highlightsector[i]].wallnum;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=highlightsectorcnt-1; k>=0; k--)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (highlightsector[k] == wall[j].nextsector)
|
|
|
|
break;
|
|
|
|
if (k < 0)
|
|
|
|
{
|
|
|
|
wall[wall[j].nextwall].nextwall = -1;
|
|
|
|
wall[wall[j].nextwall].nextsector = -1;
|
|
|
|
wall[j].nextwall = -1;
|
|
|
|
wall[j].nextsector = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<(MAXWALLS>>3); i++) //Clear all highlights
|
2006-04-24 19:04:22 +00:00
|
|
|
show2dwall[i] = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<(MAXSPRITES>>3); i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
show2dsprite[i] = 0;
|
|
|
|
|
|
|
|
sectorhighlightstat = -1;
|
|
|
|
newnumwalls = -1;
|
|
|
|
joinsector[0] = -1;
|
|
|
|
circlewall = -1;
|
|
|
|
circlepoints = 7;
|
|
|
|
bstatus = 0;
|
2008-05-16 00:23:33 +00:00
|
|
|
keystatus[buildkeys[BK_MODE2D_3D]] = 0;
|
|
|
|
while ((keystatus[buildkeys[BK_MODE2D_3D]]>>1) == 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
|
|
|
{
|
|
|
|
if (quitevent)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
keystatus[1] = 1;
|
|
|
|
quitevent = 0;
|
|
|
|
}
|
2007-01-12 05:49:09 +00:00
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
|
2008-12-25 09:43:00 +00:00
|
|
|
if (!graphicsmode)
|
|
|
|
idle();
|
2006-04-24 19:04:22 +00:00
|
|
|
OSD_DispatchQueued();
|
|
|
|
|
|
|
|
oldmousebstatus = bstatus;
|
|
|
|
getmousevalues(&mousx,&mousy,&bstatus);
|
|
|
|
mousx = (mousx<<16)+mousexsurp;
|
|
|
|
mousy = (mousy<<16)+mouseysurp;
|
|
|
|
{
|
|
|
|
ldiv_t ld;
|
2009-01-09 09:29:17 +00:00
|
|
|
ld = ldiv((int32_t)(mousx), (1<<16)); mousx = ld.quot; mousexsurp = ld.rem;
|
|
|
|
ld = ldiv((int32_t)(mousy), (1<<16)); mousy = ld.quot; mouseysurp = ld.rem;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2008-09-04 23:11:48 +00:00
|
|
|
searchx += mousx;
|
|
|
|
searchy += mousy;
|
2006-04-24 19:04:22 +00:00
|
|
|
if (searchx < 8) searchx = 8;
|
|
|
|
if (searchx > xdim-8-1) searchx = xdim-8-1;
|
|
|
|
if (searchy < 8) searchy = 8;
|
|
|
|
if (searchy > ydim-8-1) searchy = ydim-8-1;
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
/* if (keystatus[0x3b] > 0) pos.x--, keystatus[0x3b] = 0;
|
|
|
|
if (keystatus[0x3c] > 0) pos.x++, keystatus[0x3c] = 0;
|
|
|
|
if (keystatus[0x3d] > 0) pos.y--, keystatus[0x3d] = 0;
|
|
|
|
if (keystatus[0x3e] > 0) pos.y++, keystatus[0x3e] = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
if (keystatus[0x43] > 0) ang--, keystatus[0x43] = 0;
|
|
|
|
if (keystatus[0x44] > 0) ang++, keystatus[0x44] = 0; */
|
|
|
|
if (angvel != 0) //ang += angvel * constant
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
//ENGINE calculates angvel for you
|
2006-04-24 19:04:22 +00:00
|
|
|
doubvel = synctics;
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_RUN]]) //Lt. shift makes turn velocity 50% faster
|
2006-04-24 19:04:22 +00:00
|
|
|
doubvel += (synctics>>1);
|
|
|
|
ang += ((angvel*doubvel)>>4);
|
|
|
|
ang = (ang+2048)&2047;
|
|
|
|
}
|
|
|
|
if ((vel|svel) != 0)
|
|
|
|
{
|
|
|
|
doubvel = synctics;
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_RUN]]) //Lt. shift doubles forward velocity
|
2006-04-24 19:04:22 +00:00
|
|
|
doubvel += synctics;
|
|
|
|
xvect = 0, yvect = 0;
|
|
|
|
if (vel != 0)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
xvect += ((vel*doubvel*(int32_t)sintable[(ang+2560)&2047])>>3);
|
|
|
|
yvect += ((vel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
if (svel != 0)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
xvect += ((svel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3);
|
|
|
|
yvect += ((svel*doubvel*(int32_t)sintable[(ang+1536)&2047])>>3);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
if (noclip)
|
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.x += xvect>>14;
|
|
|
|
pos.y += yvect>>14;
|
|
|
|
updatesector(pos.x,pos.y,&cursectnum);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2009-01-13 12:23:18 +00:00
|
|
|
else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getpoint(searchx,searchy,&mousxplc,&mousyplc);
|
2008-09-02 02:45:06 +00:00
|
|
|
linehighlight = getlinehighlight(mousxplc, mousyplc, linehighlight);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if (newnumwalls >= numwalls)
|
|
|
|
{
|
|
|
|
dax = mousxplc;
|
|
|
|
day = mousyplc;
|
|
|
|
adjustmark(&dax,&day,newnumwalls);
|
|
|
|
wall[newnumwalls].x = dax;
|
|
|
|
wall[newnumwalls].y = day;
|
|
|
|
}
|
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim - STATUS2DSIZ2;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint = numwalls;
|
2006-04-24 19:04:22 +00:00
|
|
|
numwalls = newnumwalls;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (numwalls < 0) numwalls = tempint;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
clear2dscreen();
|
2008-12-19 00:53:54 +00:00
|
|
|
|
2008-12-25 09:43:00 +00:00
|
|
|
if (graphicsmode)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t ii = xyaspect;
|
2008-12-25 12:56:25 +00:00
|
|
|
|
|
|
|
i = yxaspect;
|
2008-12-25 09:43:00 +00:00
|
|
|
Bmemset(show2dsector, 255, sizeof(show2dsector));
|
2008-12-25 12:56:25 +00:00
|
|
|
setview(0, 0, xdim-1, ydim16-1);
|
|
|
|
yxaspect = xyaspect = 65536;
|
|
|
|
|
2008-12-28 23:27:24 +00:00
|
|
|
if (graphicsmode == 2)
|
|
|
|
totalclocklock = totalclock;
|
2008-12-25 12:56:25 +00:00
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
drawmapview(pos.x, pos.y + scale((57344/zoom), ydim, 200), zoom, 1536);
|
2008-12-25 09:43:00 +00:00
|
|
|
yxaspect = i;
|
|
|
|
xyaspect = ii;
|
|
|
|
}
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
draw2dgrid(pos.x,pos.y,ang,zoom,grid);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-12-19 00:53:54 +00:00
|
|
|
ExtPreCheckKeys();
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
x2 = mulscale14(startposx-pos.x,zoom); //Draw brown arrow (start)
|
|
|
|
y2 = mulscale14(startposy-pos.y,zoom);
|
2006-04-24 19:04:22 +00:00
|
|
|
if (((halfxdim16+x2) >= 2) && ((halfxdim16+x2) <= xdim-3))
|
|
|
|
if (((midydim16+y2) >= 2) && ((midydim16+y2) <= ydim16-3))
|
|
|
|
{
|
|
|
|
x1 = mulscale11(sintable[(startang+2560)&2047],zoom) / 768;
|
|
|
|
y1 = mulscale11(sintable[(startang+2048)&2047],zoom) / 768;
|
|
|
|
begindrawing(); //{{{
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16((halfxdim16+x2)+x1,(midydim16+y2)+y1,(halfxdim16+x2)-x1,(midydim16+y2)-y1,editorcolors[2]);
|
|
|
|
drawline16((halfxdim16+x2)+x1,(midydim16+y2)+y1,(halfxdim16+x2)+y1,(midydim16+y2)-x1,editorcolors[2]);
|
|
|
|
drawline16((halfxdim16+x2)+x1,(midydim16+y2)+y1,(halfxdim16+x2)-y1,(midydim16+y2)+x1,editorcolors[2]);
|
2006-04-24 19:04:22 +00:00
|
|
|
enddrawing(); //}}}
|
|
|
|
}
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
draw2dscreen(pos.x,pos.y,ang,zoom,grid);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
begindrawing(); //{{{
|
2008-09-03 04:20:46 +00:00
|
|
|
if (showtags == 1)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-09-03 04:20:46 +00:00
|
|
|
if (zoom >= 768)
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-09-03 14:02:42 +00:00
|
|
|
dabuffer = (char *)ExtGetSectorCaption(i);
|
|
|
|
if (dabuffer[0] != 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-09-03 14:02:42 +00:00
|
|
|
dax = 0; //Get average point of sector
|
|
|
|
day = 0;
|
|
|
|
startwall = sector[i].wallptr;
|
|
|
|
endwall = startwall + sector[i].wallnum - 1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2008-09-03 14:02:42 +00:00
|
|
|
{
|
|
|
|
dax += wall[j].x;
|
|
|
|
day += wall[j].y;
|
|
|
|
}
|
|
|
|
if (endwall > startwall)
|
|
|
|
{
|
|
|
|
dax /= (endwall-startwall+1);
|
|
|
|
day /= (endwall-startwall+1);
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
dax = mulscale14(dax-pos.x,zoom);
|
|
|
|
day = mulscale14(day-pos.y,zoom);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-09-03 14:02:42 +00:00
|
|
|
x1 = halfxdim16+dax-(Bstrlen(dabuffer)<<1);
|
|
|
|
y1 = midydim16+day-4;
|
|
|
|
x2 = x1 + (Bstrlen(dabuffer)<<2)+2;
|
|
|
|
y2 = y1 + 7;
|
|
|
|
if ((x1 > 3) && (x2 < xdim) && (y1 > 1) && (y2 < ydim16))
|
|
|
|
{
|
2008-12-23 23:27:53 +00:00
|
|
|
printext16(x1,y1,editorcolors[0],editorcolors[7],dabuffer,1);
|
|
|
|
drawline16(x1-1,y1-1,x2-3,y1-1,editorcolors[7]);
|
|
|
|
drawline16(x1-1,y2+1,x2-3,y2+1,editorcolors[7]);
|
2008-09-01 07:15:16 +00:00
|
|
|
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(x1-2,y1,x1-2,y2,editorcolors[7]);
|
|
|
|
drawline16(x2-2,y1,x2-2,y2,editorcolors[7]);
|
|
|
|
drawline16(x2-3,y1,x2-3,y2,editorcolors[7]);
|
2008-09-03 14:02:42 +00:00
|
|
|
}
|
2008-09-01 07:15:16 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
x3 = divscale14(-halfxdim16,zoom)+pos.x;
|
|
|
|
y3 = divscale14(-(midydim16-4),zoom)+pos.y;
|
|
|
|
x4 = divscale14(halfxdim16,zoom)+pos.x;
|
|
|
|
y4 = divscale14(ydim16-(midydim16-4),zoom)+pos.y;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-09-02 02:45:06 +00:00
|
|
|
if (newnumwalls >= 0)
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=newnumwalls; i>=tempint; i--)
|
2008-09-02 02:45:06 +00:00
|
|
|
wall[i].cstat |= (1<<14);
|
|
|
|
}
|
|
|
|
|
|
|
|
i = numwalls-1;
|
|
|
|
if (newnumwalls >= 0) i = newnumwalls-1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (wal=&wall[i]; i>=0; i--,wal--)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-09-03 04:20:46 +00:00
|
|
|
if (zoom < 768 && !(wal->cstat & (1<<14))) continue;
|
2006-04-24 19:04:22 +00:00
|
|
|
//Get average point of wall
|
|
|
|
dax = ((wal->x+wall[wal->point2].x)>>1);
|
|
|
|
day = ((wal->y+wall[wal->point2].y)>>1);
|
|
|
|
if ((dax > x3) && (dax < x4) && (day > y3) && (day < y4))
|
|
|
|
{
|
|
|
|
dabuffer = (char *)ExtGetWallCaption(i);
|
|
|
|
if (dabuffer[0] != 0)
|
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
dax = mulscale14(dax-pos.x,zoom);
|
|
|
|
day = mulscale14(day-pos.y,zoom);
|
2006-04-24 19:04:22 +00:00
|
|
|
x1 = halfxdim16+dax-(Bstrlen(dabuffer)<<1);
|
|
|
|
y1 = midydim16+day-4;
|
|
|
|
x2 = x1 + (Bstrlen(dabuffer)<<2)+2;
|
|
|
|
y2 = y1 + 7;
|
2008-09-01 07:15:16 +00:00
|
|
|
if ((x1 > 3) && (x2 < xdim) && (y1 > 1) && (y2 < ydim16))
|
|
|
|
{
|
2008-12-23 23:27:53 +00:00
|
|
|
printext16(x1,y1,editorcolors[0],editorcolors[31],dabuffer,1);
|
|
|
|
drawline16(x1-1,y1-1,x2-3,y1-1,editorcolors[31]);
|
|
|
|
drawline16(x1-1,y2+1,x2-3,y2+1,editorcolors[31]);
|
2008-09-01 07:15:16 +00:00
|
|
|
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(x1-2,y1,x1-2,y2,editorcolors[31]);
|
|
|
|
drawline16(x2-2,y1,x2-2,y2,editorcolors[31]);
|
|
|
|
drawline16(x2-3,y1,x2-3,y2,editorcolors[31]);
|
2008-09-01 07:15:16 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0; j = numsprites;
|
2008-09-03 04:20:46 +00:00
|
|
|
if (zoom >= 768)
|
2008-09-03 14:02:42 +00:00
|
|
|
while ((j > 0) && (i < MAXSPRITES))
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-09-03 14:02:42 +00:00
|
|
|
if (sprite[i].statnum < MAXSTATUS)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-09-03 14:02:42 +00:00
|
|
|
dabuffer = (char *)ExtGetSpriteCaption(i);
|
|
|
|
if (dabuffer[0] != 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-09-03 14:02:42 +00:00
|
|
|
//Get average point of sprite
|
|
|
|
dax = sprite[i].x;
|
|
|
|
day = sprite[i].y;
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
dax = mulscale14(dax-pos.x,zoom);
|
|
|
|
day = mulscale14(day-pos.y,zoom);
|
2008-09-03 14:02:42 +00:00
|
|
|
x1 = halfxdim16+dax-(Bstrlen(dabuffer)<<1);
|
|
|
|
y1 = midydim16+day-4;
|
|
|
|
x2 = x1 + (Bstrlen(dabuffer)<<2)+2;
|
|
|
|
y2 = y1 + 7;
|
|
|
|
if ((x1 > 3) && (x2 < xdim) && (y1 > 1) && (y2 < ydim16))
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-09-03 14:02:42 +00:00
|
|
|
col = 3;
|
|
|
|
if (spritecol2d[sprite[i].picnum][0])
|
|
|
|
col = spritecol2d[sprite[i].picnum][0];
|
|
|
|
if ((sprite[i].cstat&1) > 0)
|
|
|
|
{
|
|
|
|
col = 5;
|
|
|
|
if (spritecol2d[sprite[i].picnum][1])
|
|
|
|
col = spritecol2d[sprite[i].picnum][1];
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-09-03 14:02:42 +00:00
|
|
|
if ((i == pointhighlight-16384) && (totalclock & 32)) col += (2<<2);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-12-23 23:27:53 +00:00
|
|
|
printext16(x1,y1,editorcolors[0],editorcolors[col],dabuffer,1);
|
2008-09-01 07:15:16 +00:00
|
|
|
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(x1-1,y1-1,x2-3,y1-1,editorcolors[col]);
|
|
|
|
drawline16(x1-1,y2+1,x2-3,y2+1,editorcolors[col]);
|
2008-09-01 07:15:16 +00:00
|
|
|
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(x1-2,y1,x1-2,y2,editorcolors[col]);
|
|
|
|
drawline16(x2-2,y1,x2-2,y2,editorcolors[col]);
|
|
|
|
drawline16(x2-3,y1,x2-3,y2,editorcolors[col]);
|
2008-09-03 14:02:42 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2008-09-03 14:02:42 +00:00
|
|
|
j--;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2008-09-03 14:02:42 +00:00
|
|
|
i++;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
printcoords16(pos.x,pos.y,ang);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
numwalls = tempint;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if (highlightsectorcnt > 0)
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
fillsector(highlightsector[i],2);
|
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
if (keystatus[0x2a]) // FIXME
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
drawlinepat = 0x00ff00ff;
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(searchx,0,searchx,ydim2d-1,editorcolors[15]);
|
|
|
|
drawline16(0,searchy,xdim2d-1,searchy,editorcolors[15]);
|
2006-04-24 19:04:22 +00:00
|
|
|
drawlinepat = 0xffffffff;
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(tempbuf,"(%d,%d)",mousxplc,mousyplc);
|
2006-04-24 19:04:22 +00:00
|
|
|
i = (Bstrlen(tempbuf)<<3)+6;
|
2006-11-13 23:12:47 +00:00
|
|
|
if ((searchx+i) < (xdim2d-1))
|
2006-04-24 19:04:22 +00:00
|
|
|
i = 0;
|
|
|
|
else i = (searchx+i)-(xdim2d-1);
|
2009-05-01 06:35:27 +00:00
|
|
|
if ((searchy+16) < (ydim2d-STATUS2DSIZ2-1))
|
2006-04-24 19:04:22 +00:00
|
|
|
j = 0;
|
2009-05-01 06:35:27 +00:00
|
|
|
else j = (searchy+16)-(ydim2d-STATUS2DSIZ2-1);
|
2008-12-23 23:27:53 +00:00
|
|
|
printext16(searchx+6-i,searchy+6-j,editorcolors[11],-1,tempbuf,0);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(searchx,0,searchx,8,editorcolors[15]);
|
|
|
|
drawline16(0,searchy,8,searchy,editorcolors[15]);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
col = 15-((gridlock<<1)+gridlock);
|
2008-05-10 01:29:37 +00:00
|
|
|
if (joinsector[0] >= 0)col = 11;
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(searchx,searchy-8,searchx,searchy-1,editorcolors[col]);
|
|
|
|
drawline16(searchx+1,searchy-8,searchx+1,searchy-1,editorcolors[col]);
|
|
|
|
drawline16(searchx,searchy+2,searchx,searchy+9,editorcolors[col]);
|
|
|
|
drawline16(searchx+1,searchy+2,searchx+1,searchy+9,editorcolors[col]);
|
|
|
|
drawline16(searchx-8,searchy,searchx-1,searchy,editorcolors[col]);
|
|
|
|
drawline16(searchx-8,searchy+1,searchx-1,searchy+1,editorcolors[col]);
|
|
|
|
drawline16(searchx+2,searchy,searchx+9,searchy,editorcolors[col]);
|
|
|
|
drawline16(searchx+2,searchy+1,searchx+9,searchy+1,editorcolors[col]);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
//Draw the white pixel closest to mouse cursor on linehighlight
|
2008-05-16 19:51:38 +00:00
|
|
|
if (linehighlight>=0)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
getclosestpointonwall(mousxplc,mousyplc,(int32_t)linehighlight,&dax,&day);
|
2009-01-13 12:23:18 +00:00
|
|
|
x2 = mulscale14(dax-pos.x,zoom);
|
|
|
|
y2 = mulscale14(day-pos.y,zoom);
|
2008-05-16 19:51:38 +00:00
|
|
|
if (wall[linehighlight].nextsector >= 0)
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(halfxdim16+x2,midydim16+y2,halfxdim16+x2,midydim16+y2,editorcolors[15]);
|
2008-05-16 19:51:38 +00:00
|
|
|
else
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(halfxdim16+x2,midydim16+y2,halfxdim16+x2,midydim16+y2,editorcolors[5]);
|
2008-05-16 19:51:38 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
enddrawing(); //}}}
|
|
|
|
|
|
|
|
OSD_Draw();
|
|
|
|
|
|
|
|
ExtCheckKeys(); // TX 20050101, it makes more sense to have this here so keys can be overwritten with new functions in bstub.c
|
|
|
|
|
|
|
|
// Flip/mirror sector Ed Coolidge
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x2d]) // X (2D)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (highlightsectorcnt > 0)
|
|
|
|
{
|
|
|
|
k = 0;
|
|
|
|
dax = 0;
|
|
|
|
day = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
dax += wall[j].x;
|
|
|
|
day += wall[j].y;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (k > 0)
|
|
|
|
{
|
|
|
|
dax /= k;
|
|
|
|
day /= k;
|
|
|
|
}
|
|
|
|
|
|
|
|
k = (keystatus[0x38]|keystatus[0xb8]); //ALT-X mirror sector in x
|
|
|
|
|
|
|
|
if ((gridlock > 0) && (grid > 0))
|
|
|
|
{
|
|
|
|
dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
day = ((day+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
// dax = ((dax+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1));
|
|
|
|
// day = ((day+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1));
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startofloop;
|
|
|
|
int32_t endofloop;
|
|
|
|
int32_t numtoswap = -1;
|
|
|
|
int32_t w=0;
|
2006-04-24 19:04:22 +00:00
|
|
|
walltype tempwall;
|
2006-10-17 01:12:31 +00:00
|
|
|
|
|
|
|
startofloop = startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endofloop = endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
/*
|
|
|
|
if (k != 0)
|
|
|
|
{
|
|
|
|
//mirror sector textures
|
|
|
|
sector[highlightsector[i]].ceilingstat ^= 0x10;
|
|
|
|
sector[highlightsector[i]].floorstat ^= 0x10;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
//save position of wall at start of loop
|
|
|
|
x3 = wall[startofloop].x;
|
|
|
|
y3 = wall[startofloop].y;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
//fix position of walls
|
|
|
|
wall[j].x = dax-wall[wall[j].point2].x+dax; //flip wall.x about dax
|
|
|
|
wall[j].y = wall[wall[j].point2].y;
|
|
|
|
|
|
|
|
if (k != 0)
|
|
|
|
{
|
|
|
|
//mirror walls about dax
|
|
|
|
wall[j].cstat ^= 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wall[j].point2==startofloop) //check if j is end of loop
|
|
|
|
{
|
|
|
|
endofloop = j;
|
|
|
|
wall[endofloop].x = dax-x3+dax; //flip wall.x about dax
|
|
|
|
wall[endofloop].y = y3;
|
|
|
|
//correct order of walls in loop to maintain player space (right-hand rule)
|
|
|
|
numtoswap = (endofloop-startofloop)>>1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (w=1; w<=numtoswap; w++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
Bmemcpy(&tempwall,&wall[startofloop+w],sizeof(walltype));
|
|
|
|
Bmemcpy(&wall[startofloop+w],&wall[endofloop-w+1],sizeof(walltype));
|
|
|
|
Bmemcpy(&wall[endofloop-w+1],&tempwall,sizeof(walltype));
|
|
|
|
}
|
|
|
|
|
|
|
|
//make point2 point to next wall in loop
|
2009-02-19 16:47:54 +00:00
|
|
|
for (w=startofloop; w<endofloop; w++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
wall[w].point2 = w+1;
|
|
|
|
}
|
|
|
|
wall[endofloop].point2 = startofloop;
|
|
|
|
|
|
|
|
startofloop = endofloop+1; //set first wall of next loop
|
|
|
|
//save position of wall at start of loop
|
|
|
|
x3 = wall[startofloop].x;
|
|
|
|
y3 = wall[startofloop].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
j = headspritesect[highlightsector[i]];
|
|
|
|
while (j != -1)
|
|
|
|
{
|
|
|
|
x3 = sprite[j].x;
|
|
|
|
sprite[j].x = dax-x3+dax; //flip sprite.x about dax
|
|
|
|
sprite[j].ang = ((1024+2048-sprite[j].ang)&2047); //flip ang about 512
|
|
|
|
if (k != 0)
|
|
|
|
{
|
|
|
|
//don't mirror monsters
|
2006-11-13 23:12:47 +00:00
|
|
|
if ((sprite[j].cstat & 0x30) != 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
//mirror sprites about day
|
|
|
|
sprite[j].cstat ^= 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
j = nextspritesect[j];
|
|
|
|
}
|
|
|
|
}
|
2008-09-03 14:02:42 +00:00
|
|
|
/*if (k == 0)*/
|
|
|
|
keystatus[0x2d] = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
printmessage16("Selected sector(s) flipped");
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x15]) // Y (2D)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (highlightsectorcnt > 0)
|
|
|
|
{
|
|
|
|
k = 0;
|
|
|
|
dax = 0;
|
|
|
|
day = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
dax += wall[j].x;
|
|
|
|
day += wall[j].y;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (k > 0)
|
|
|
|
{
|
|
|
|
dax /= k;
|
|
|
|
day /= k;
|
|
|
|
}
|
|
|
|
|
|
|
|
k = (keystatus[0x38]|keystatus[0xb8]); //ALT-Y mirror sectors in y
|
|
|
|
|
|
|
|
if ((gridlock > 0) && (grid > 0))
|
|
|
|
{
|
|
|
|
dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
day = ((day+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
// dax = ((dax+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1));
|
|
|
|
// day = ((day+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1));
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startofloop;
|
|
|
|
int32_t endofloop;
|
|
|
|
int32_t numtoswap = -1;
|
|
|
|
int32_t w=0;
|
2006-04-24 19:04:22 +00:00
|
|
|
walltype tempwall;
|
2006-10-17 01:12:31 +00:00
|
|
|
|
|
|
|
startofloop = startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endofloop = endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2006-04-24 19:04:22 +00:00
|
|
|
/*
|
|
|
|
if (k != 0)
|
|
|
|
{
|
|
|
|
//mirror sector textures
|
|
|
|
sector[highlightsector[i]].ceilingstat ^= 0x10;
|
|
|
|
sector[highlightsector[i]].floorstat ^= 0x10;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
//save position of wall at start of loop
|
|
|
|
x3 = wall[startofloop].x;
|
|
|
|
y3 = wall[startofloop].y;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
//fix position of walls
|
|
|
|
wall[j].x = wall[wall[j].point2].x;
|
|
|
|
wall[j].y = day-wall[wall[j].point2].y+day; //flip wall.y about day
|
|
|
|
if (k != 0)
|
|
|
|
{
|
|
|
|
//mirror walls about day
|
|
|
|
wall[j].cstat ^= 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wall[j].point2==startofloop) //check if j is end of loop
|
|
|
|
{
|
|
|
|
endofloop = j;
|
|
|
|
wall[endofloop].x = x3;
|
|
|
|
wall[endofloop].y = day-y3+day; //flip wall.y about dax
|
|
|
|
//correct order of walls in loop to maintain player space (right-hand rule)
|
|
|
|
numtoswap = (endofloop-startofloop)>>1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (w=1; w<=numtoswap; w++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
Bmemcpy(&tempwall,&wall[startofloop+w],sizeof(walltype));
|
|
|
|
Bmemcpy(&wall[startofloop+w],&wall[endofloop-w+1],sizeof(walltype));
|
|
|
|
Bmemcpy(&wall[endofloop-w+1],&tempwall,sizeof(walltype));
|
|
|
|
}
|
|
|
|
|
|
|
|
//make point2 point to next wall in loop
|
2009-02-19 16:47:54 +00:00
|
|
|
for (w=startofloop; w<endofloop; w++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
wall[w].point2 = w+1;
|
|
|
|
}
|
|
|
|
wall[endofloop].point2 = startofloop;
|
|
|
|
|
|
|
|
startofloop = endofloop+1; //set first wall of next loop
|
|
|
|
//save position of wall at start of loop
|
|
|
|
x3 = wall[startofloop].x;
|
|
|
|
y3 = wall[startofloop].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
j = headspritesect[highlightsector[i]];
|
|
|
|
while (j != -1)
|
|
|
|
{
|
|
|
|
y3 = sprite[j].y;
|
|
|
|
sprite[j].y = day-y3+day; //flip sprite.y about day
|
|
|
|
sprite[j].ang = ((2048-sprite[j].ang)&2047); //flip ang about 512
|
|
|
|
if (k != 0)
|
|
|
|
{
|
|
|
|
//don't mirror monsters
|
2006-11-13 23:12:47 +00:00
|
|
|
if ((sprite[j].cstat & 0x30) != 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
//mirror sprites about day
|
|
|
|
sprite[j].cstat ^= 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
j = nextspritesect[j];
|
|
|
|
}
|
|
|
|
}
|
2008-09-03 14:02:42 +00:00
|
|
|
/*if (k == 0)*/
|
|
|
|
keystatus[0x15] = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
printmessage16("Selected sector(s) flipped");
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// end edit for sector flip
|
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[88]) //F12
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[88] = 0;
|
|
|
|
/*
|
|
|
|
j = ydim16; ydim16 = ydim;
|
|
|
|
clear2dscreen();
|
2009-01-13 12:23:18 +00:00
|
|
|
draw2dgrid(pos.x,pos.y,ang,zoom,grid);
|
|
|
|
draw2dscreen(pos.x,pos.y,ang,zoom,grid);
|
2006-04-24 19:04:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
screencapture("captxxxx.tga",keystatus[0x2a]|keystatus[0x36]);
|
|
|
|
|
|
|
|
/*
|
|
|
|
ydim16 = j;
|
|
|
|
clear2dscreen();
|
2009-01-13 12:23:18 +00:00
|
|
|
draw2dgrid(pos.x,pos.y,ang,zoom,grid);
|
|
|
|
draw2dscreen(pos.x,pos.y,ang,zoom,grid);
|
2006-04-24 19:04:22 +00:00
|
|
|
*/
|
|
|
|
showframe(1);
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x30]) // B (clip Blocking xor) (2D)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-09-02 02:45:06 +00:00
|
|
|
pointhighlight = getpointhighlight(mousxplc, mousyplc, pointhighlight);
|
|
|
|
linehighlight = getlinehighlight(mousxplc, mousyplc, linehighlight);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if ((pointhighlight&0xc000) == 16384)
|
|
|
|
{
|
|
|
|
sprite[pointhighlight&16383].cstat ^= 1;
|
|
|
|
sprite[pointhighlight&16383].cstat &= ~256;
|
|
|
|
sprite[pointhighlight&16383].cstat |= ((sprite[pointhighlight&16383].cstat&1)<<8);
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
else if (linehighlight >= 0)
|
|
|
|
{
|
|
|
|
wall[linehighlight].cstat ^= 1;
|
|
|
|
wall[linehighlight].cstat &= ~64;
|
|
|
|
if ((wall[linehighlight].nextwall >= 0) && ((keystatus[0x2a]|keystatus[0x36]) == 0))
|
|
|
|
{
|
|
|
|
wall[wall[linehighlight].nextwall].cstat &= ~(1+64);
|
|
|
|
wall[wall[linehighlight].nextwall].cstat |= (wall[linehighlight].cstat&1);
|
|
|
|
}
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
keystatus[0x30] = 0;
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x21]) //F (F alone does nothing in 2D right now)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[0x21] = 0;
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x38]|keystatus[0xb8]) //ALT-F (relative alignmment flip)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-09-02 02:45:06 +00:00
|
|
|
linehighlight = getlinehighlight(mousxplc, mousyplc, linehighlight);
|
2006-04-24 19:04:22 +00:00
|
|
|
if (linehighlight >= 0)
|
|
|
|
{
|
|
|
|
setfirstwall(sectorofwall(linehighlight),linehighlight);
|
|
|
|
asksave = 1;
|
|
|
|
printmessage16("This wall now sector's first wall (sector[].wallptr)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x18]) // O (ornament onto wall) (2D)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[0x18] = 0;
|
|
|
|
if ((pointhighlight&0xc000) == 16384)
|
|
|
|
{
|
|
|
|
asksave = 1;
|
|
|
|
i = (pointhighlight&16383);
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
hitscan((const vec3_t *)&sprite[i],sprite[i].sectnum,
|
2006-04-24 19:04:22 +00:00
|
|
|
sintable[(sprite[i].ang+2560+1024)&2047],
|
|
|
|
sintable[(sprite[i].ang+2048+1024)&2047],
|
2009-01-13 12:23:18 +00:00
|
|
|
0,&hitinfo,CLIPMASK1);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
sprite[i].x = hitinfo.pos.x;
|
|
|
|
sprite[i].y = hitinfo.pos.y;
|
|
|
|
sprite[i].z = hitinfo.pos.z;
|
|
|
|
changespritesect(i,hitinfo.hitsect);
|
|
|
|
if (hitinfo.hitwall >= 0)
|
|
|
|
sprite[i].ang = ((getangle(wall[wall[hitinfo.hitwall].point2].x-wall[hitinfo.hitwall].x,wall[wall[hitinfo.hitwall].point2].y-wall[hitinfo.hitwall].y)+512)&2047);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
//Make sure sprite's in right sector
|
|
|
|
if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0)
|
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
j = wall[hitinfo.hitwall].point2;
|
|
|
|
sprite[i].x -= ksgn(wall[j].y-wall[hitinfo.hitwall].y);
|
|
|
|
sprite[i].y += ksgn(wall[j].x-wall[hitinfo.hitwall].x);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-03 04:20:46 +00:00
|
|
|
if (keystatus[0x33] || (bstatus&1 && bstatus&32)) // , (2D)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (highlightsectorcnt > 0)
|
|
|
|
{
|
|
|
|
k = 0;
|
|
|
|
dax = 0;
|
|
|
|
day = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
dax += wall[j].x;
|
|
|
|
day += wall[j].y;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (k > 0)
|
|
|
|
{
|
|
|
|
dax /= k;
|
|
|
|
day /= k;
|
|
|
|
}
|
|
|
|
|
|
|
|
k = (keystatus[0x2a]|keystatus[0x36]);
|
|
|
|
|
|
|
|
if (k == 0)
|
|
|
|
{
|
|
|
|
if ((gridlock > 0) && (grid > 0))
|
|
|
|
{
|
|
|
|
dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
day = ((day+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (k == 0)
|
|
|
|
{
|
|
|
|
x3 = wall[j].x;
|
|
|
|
y3 = wall[j].y;
|
|
|
|
wall[j].x = dax+day-y3;
|
|
|
|
wall[j].y = day+x3-dax;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rotatepoint(dax,day,wall[j].x,wall[j].y,1,&wall[j].x,&wall[j].y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
j = headspritesect[highlightsector[i]];
|
|
|
|
while (j != -1)
|
|
|
|
{
|
|
|
|
if (k == 0)
|
|
|
|
{
|
|
|
|
x3 = sprite[j].x;
|
|
|
|
y3 = sprite[j].y;
|
|
|
|
sprite[j].x = dax+day-y3;
|
|
|
|
sprite[j].y = day+x3-dax;
|
|
|
|
sprite[j].ang = ((sprite[j].ang+512)&2047);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rotatepoint(dax,day,sprite[j].x,sprite[j].y,1,&sprite[j].x,&sprite[j].y);
|
|
|
|
sprite[j].ang = ((sprite[j].ang+1)&2047);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
j = nextspritesect[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (k == 0) keystatus[0x33] = 0;
|
2008-09-03 04:20:46 +00:00
|
|
|
mouseb &= ~32;
|
|
|
|
bstatus &= ~32;
|
2006-04-24 19:04:22 +00:00
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pointhighlight >= 16384)
|
|
|
|
{
|
|
|
|
i = pointhighlight-16384;
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x2a]|keystatus[0x36])
|
2006-04-24 19:04:22 +00:00
|
|
|
sprite[i].ang = ((sprite[i].ang+2048-1)&2047);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprite[i].ang = ((sprite[i].ang+2048-128)&2047);
|
|
|
|
keystatus[0x33] = 0;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-09-03 04:20:46 +00:00
|
|
|
mouseb &= ~32;
|
|
|
|
bstatus &= ~32;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
clearmidstatbar16();
|
2009-01-09 09:29:17 +00:00
|
|
|
showspritedata((int16_t)pointhighlight-16384);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-09-03 04:20:46 +00:00
|
|
|
if (keystatus[0x34] || (bstatus&1 && bstatus&16)) // . (2D)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (highlightsectorcnt > 0)
|
|
|
|
{
|
|
|
|
k = 0;
|
|
|
|
dax = 0;
|
|
|
|
day = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
dax += wall[j].x;
|
|
|
|
day += wall[j].y;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (k > 0)
|
|
|
|
{
|
|
|
|
dax /= k;
|
|
|
|
day /= k;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
k = (keystatus[0x2a]|keystatus[0x36]);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (k == 0)
|
|
|
|
{
|
|
|
|
if ((gridlock > 0) && (grid > 0))
|
|
|
|
{
|
|
|
|
dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
day = ((day+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (k == 0)
|
|
|
|
{
|
|
|
|
x3 = wall[j].x;
|
|
|
|
y3 = wall[j].y;
|
|
|
|
wall[j].x = dax+y3-day;
|
|
|
|
wall[j].y = day+dax-x3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rotatepoint(dax,day,wall[j].x,wall[j].y,2047,&wall[j].x,&wall[j].y);
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
j = headspritesect[highlightsector[i]];
|
|
|
|
while (j != -1)
|
|
|
|
{
|
|
|
|
if (k == 0)
|
|
|
|
{
|
|
|
|
x3 = sprite[j].x;
|
|
|
|
y3 = sprite[j].y;
|
|
|
|
sprite[j].x = dax+y3-day;
|
|
|
|
sprite[j].y = day+dax-x3;
|
|
|
|
sprite[j].ang = ((sprite[j].ang+1536)&2047);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rotatepoint(dax,day,sprite[j].x,sprite[j].y,2047,&sprite[j].x,&sprite[j].y);
|
|
|
|
sprite[j].ang = ((sprite[j].ang+2047)&2047);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
j = nextspritesect[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (k == 0) keystatus[0x34] = 0;
|
2008-09-03 04:20:46 +00:00
|
|
|
mouseb &= ~16;
|
|
|
|
bstatus &= ~16;
|
2006-04-24 19:04:22 +00:00
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pointhighlight >= 16384)
|
|
|
|
{
|
|
|
|
i = pointhighlight-16384;
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x2a]|keystatus[0x36])
|
2006-04-24 19:04:22 +00:00
|
|
|
sprite[i].ang = ((sprite[i].ang+2048+1)&2047);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprite[i].ang = ((sprite[i].ang+2048+128)&2047);
|
|
|
|
keystatus[0x34] = 0;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-09-03 04:20:46 +00:00
|
|
|
mouseb &= ~16;
|
|
|
|
bstatus &= ~16;
|
2006-04-24 19:04:22 +00:00
|
|
|
clearmidstatbar16();
|
2009-01-09 09:29:17 +00:00
|
|
|
showspritedata((int16_t)pointhighlight-16384);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x46]) //Scroll lock (set starting position)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
startposx = pos.x;
|
|
|
|
startposy = pos.y;
|
|
|
|
startposz = pos.z;
|
2006-04-24 19:04:22 +00:00
|
|
|
startang = ang;
|
|
|
|
startsectnum = cursectnum;
|
|
|
|
keystatus[0x46] = 0;
|
|
|
|
asksave = 1;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x3f]) //F5
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[0x3f] = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (inside(mousxplc,mousyplc,i) == 1)
|
|
|
|
{
|
|
|
|
ydim16 = STATUS2DSIZ;
|
2009-01-09 09:29:17 +00:00
|
|
|
ExtShowSectorData((int16_t)i);
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x40]) //F6
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[0x40] = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (pointhighlight >= 16384)
|
|
|
|
{
|
|
|
|
i = pointhighlight-16384;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
ydim16 = STATUS2DSIZ;
|
2009-01-09 09:29:17 +00:00
|
|
|
ExtShowSpriteData((int16_t)i);
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else if (linehighlight >= 0)
|
|
|
|
{
|
|
|
|
i = linehighlight;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
ydim16 = STATUS2DSIZ;
|
2009-01-09 09:29:17 +00:00
|
|
|
ExtShowWallData((int16_t)i);
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x41]) //F7
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[0x41] = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (inside(mousxplc,mousyplc,i) == 1)
|
|
|
|
{
|
|
|
|
ydim16 = STATUS2DSIZ;
|
2009-01-09 09:29:17 +00:00
|
|
|
ExtEditSectorData((int16_t)i);
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x42]) //F8
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[0x42] = 0;
|
|
|
|
|
|
|
|
if (pointhighlight >= 16384)
|
|
|
|
{
|
|
|
|
i = pointhighlight-16384;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
ydim16 = STATUS2DSIZ;
|
2009-01-09 09:29:17 +00:00
|
|
|
ExtEditSpriteData((int16_t)i);
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else if (linehighlight >= 0)
|
|
|
|
{
|
|
|
|
i = linehighlight;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
ydim16 = STATUS2DSIZ;
|
2009-01-09 09:29:17 +00:00
|
|
|
ExtEditWallData((int16_t)i);
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x23]) //H (Hi 16 bits of tag)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[0x23] = 0;
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x1d]|keystatus[0x9d]) //Ctrl-H
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-09-02 02:45:06 +00:00
|
|
|
pointhighlight = getpointhighlight(mousxplc, mousyplc, pointhighlight);
|
|
|
|
linehighlight = getlinehighlight(mousxplc, mousyplc, linehighlight);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((pointhighlight&0xc000) == 16384)
|
|
|
|
{
|
|
|
|
sprite[pointhighlight&16383].cstat ^= 256;
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
else if (linehighlight >= 0)
|
|
|
|
{
|
|
|
|
wall[linehighlight].cstat ^= 64;
|
|
|
|
if ((wall[linehighlight].nextwall >= 0) && ((keystatus[0x2a]|keystatus[0x36]) == 0))
|
|
|
|
{
|
|
|
|
wall[wall[linehighlight].nextwall].cstat &= ~64;
|
|
|
|
wall[wall[linehighlight].nextwall].cstat |= (wall[linehighlight].cstat&64);
|
|
|
|
}
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
else if (keystatus[0x38]|keystatus[0xb8]) //ALT
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (pointhighlight >= 16384)
|
|
|
|
{
|
|
|
|
i = pointhighlight-16384;
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(buffer,"Sprite (%d) Hi-tag: ",i);
|
2006-04-24 19:04:22 +00:00
|
|
|
sprite[i].hitag = getnumber16(buffer,sprite[i].hitag,65536L,0);
|
|
|
|
clearmidstatbar16();
|
2009-01-09 09:29:17 +00:00
|
|
|
showspritedata((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else if (linehighlight >= 0)
|
|
|
|
{
|
|
|
|
i = linehighlight;
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(buffer,"Wall (%d) Hi-tag: ",i);
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[i].hitag = getnumber16(buffer,wall[i].hitag,65536L,0);
|
|
|
|
clearmidstatbar16();
|
2009-01-09 09:29:17 +00:00
|
|
|
showwalldata((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (inside(mousxplc,mousyplc,i) == 1)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(buffer,"Sector (%d) Hi-tag: ",i);
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[i].hitag = getnumber16(buffer,sector[i].hitag,65536L,0);
|
|
|
|
clearmidstatbar16();
|
2009-01-09 09:29:17 +00:00
|
|
|
showsectordata((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-05-01 06:35:27 +00:00
|
|
|
// printmessage16("");
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x19]) // P (palookup #)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[0x19] = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (inside(mousxplc,mousyplc,i) == 1)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(buffer,"Sector (%d) Ceilingpal: ",i);
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[i].ceilingpal = getnumber16(buffer,sector[i].ceilingpal,256L,0);
|
|
|
|
clearmidstatbar16();
|
2009-01-09 09:29:17 +00:00
|
|
|
showsectordata((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(buffer,"Sector (%d) Floorpal: ",i);
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[i].floorpal = getnumber16(buffer,sector[i].floorpal,256L,0);
|
|
|
|
clearmidstatbar16();
|
2009-01-09 09:29:17 +00:00
|
|
|
showsectordata((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
// printmessage16("");
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x12]) // E (status list)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (pointhighlight >= 16384)
|
|
|
|
{
|
|
|
|
i = pointhighlight-16384;
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(buffer,"Sprite (%d) Status list: ",i);
|
2006-04-24 19:04:22 +00:00
|
|
|
changespritestat(i,getnumber16(buffer,sprite[i].statnum,65536L,0));
|
|
|
|
clearmidstatbar16();
|
2009-01-09 09:29:17 +00:00
|
|
|
showspritedata((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
// printmessage16("");
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
keystatus[0x12] = 0;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (highlightsectorcnt < 0)
|
|
|
|
{
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x36]) //Right shift (point highlighting)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (highlightcnt == 0)
|
|
|
|
{
|
|
|
|
highlightx2 = searchx, highlighty2 = searchy;
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(highlightx2,highlighty1,highlightx1,highlighty1,editorcolors[5]);
|
|
|
|
drawline16(highlightx2,highlighty2,highlightx1,highlighty2,editorcolors[5]);
|
|
|
|
drawline16(highlightx1,highlighty2,highlightx1,highlighty1,editorcolors[5]);
|
|
|
|
drawline16(highlightx2,highlighty2,highlightx2,highlighty1,editorcolors[5]);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
if (highlightcnt != 0)
|
|
|
|
{
|
|
|
|
highlightx1 = searchx;
|
|
|
|
highlighty1 = searchy;
|
|
|
|
highlightx2 = searchx;
|
|
|
|
highlighty2 = searchx;
|
|
|
|
highlightcnt = 0;
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<(MAXWALLS>>3); i++) //Clear all highlights
|
2006-04-24 19:04:22 +00:00
|
|
|
show2dwall[i] = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<(MAXSPRITES>>3); i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
show2dsprite[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (highlightcnt == 0)
|
|
|
|
{
|
|
|
|
getpoint(highlightx1,highlighty1,&highlightx1,&highlighty1);
|
|
|
|
getpoint(highlightx2,highlighty2,&highlightx2,&highlighty2);
|
|
|
|
if (highlightx1 > highlightx2)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint = highlightx1; highlightx1 = highlightx2; highlightx2 = tempint;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
if (highlighty1 > highlighty2)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint = highlighty1; highlighty1 = highlighty2; highlighty2 = tempint;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x1d]|keystatus[0x9d])
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if ((linehighlight >= 0) && (linehighlight < MAXWALLS))
|
|
|
|
{
|
|
|
|
i = linehighlight;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
highlight[highlightcnt++] = i;
|
|
|
|
show2dwall[i>>3] |= (1<<(i&7));
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<numwalls; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[j].x == wall[i].x)
|
|
|
|
if (wall[j].y == wall[i].y)
|
|
|
|
if (i != j)
|
|
|
|
{
|
|
|
|
highlight[highlightcnt++] = j;
|
|
|
|
show2dwall[j>>3] |= (1<<(j&7));
|
|
|
|
}
|
|
|
|
|
|
|
|
i = wall[i].point2;
|
|
|
|
}
|
|
|
|
while (i != linehighlight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((wall[i].x >= highlightx1) && (wall[i].x <= highlightx2))
|
|
|
|
if ((wall[i].y >= highlighty1) && (wall[i].y <= highlighty2))
|
|
|
|
{
|
|
|
|
highlight[highlightcnt++] = i;
|
|
|
|
show2dwall[i>>3] |= (1<<(i&7));
|
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXSPRITES; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (sprite[i].statnum < MAXSTATUS)
|
|
|
|
if ((sprite[i].x >= highlightx1) && (sprite[i].x <= highlightx2))
|
|
|
|
if ((sprite[i].y >= highlighty1) && (sprite[i].y <= highlighty2))
|
|
|
|
{
|
|
|
|
highlight[highlightcnt++] = i+16384;
|
|
|
|
show2dsprite[i>>3] |= (1<<(i&7));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (highlightcnt <= 0)
|
|
|
|
highlightcnt = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (highlightcnt < 0)
|
|
|
|
{
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0xb8]) //Right alt (sector highlighting)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (highlightsectorcnt == 0)
|
|
|
|
{
|
|
|
|
highlightx2 = searchx, highlighty2 = searchy;
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2006-04-24 19:04:22 +00:00
|
|
|
begindrawing(); //{{{
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(highlightx2,highlighty1,highlightx1,highlighty1,editorcolors[10]);
|
|
|
|
drawline16(highlightx2,highlighty2,highlightx1,highlighty2,editorcolors[10]);
|
|
|
|
drawline16(highlightx1,highlighty2,highlightx1,highlighty1,editorcolors[10]);
|
|
|
|
drawline16(highlightx2,highlighty2,highlightx2,highlighty1,editorcolors[10]);
|
2006-04-24 19:04:22 +00:00
|
|
|
enddrawing(); //}}}
|
|
|
|
}
|
|
|
|
if (highlightsectorcnt != 0)
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
checksectorpointer(wall[j].nextwall,wall[j].nextsector);
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)j,highlightsector[i]);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
highlightx1 = searchx;
|
|
|
|
highlighty1 = searchy;
|
|
|
|
highlightx2 = searchx;
|
|
|
|
highlighty2 = searchx;
|
|
|
|
highlightsectorcnt = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (highlightsectorcnt == 0)
|
|
|
|
{
|
|
|
|
getpoint(highlightx1,highlighty1,&highlightx1,&highlighty1);
|
|
|
|
getpoint(highlightx2,highlighty2,&highlightx2,&highlighty2);
|
|
|
|
if (highlightx1 > highlightx2)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint = highlightx1; highlightx1 = highlightx2; highlightx2 = tempint;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
if (highlighty1 > highlighty2)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint = highlighty1; highlighty1 = highlighty2; highlighty2 = tempint;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[i].wallptr;
|
|
|
|
endwall = startwall + sector[i].wallnum;
|
|
|
|
bad = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[j].x < highlightx1) bad = 1;
|
|
|
|
if (wall[j].x > highlightx2) bad = 1;
|
|
|
|
if (wall[j].y < highlighty1) bad = 1;
|
|
|
|
if (wall[j].y > highlighty2) bad = 1;
|
|
|
|
if (bad == 1) break;
|
|
|
|
}
|
|
|
|
if (bad == 0)
|
|
|
|
highlightsector[highlightsectorcnt++] = i;
|
|
|
|
}
|
|
|
|
if (highlightsectorcnt <= 0)
|
|
|
|
highlightsectorcnt = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//White out all bordering lines of grab that are
|
|
|
|
//not highlighted on both sides
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=highlightsectorcnt-1; i>=0; i--)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall + sector[highlightsector[i]].wallnum;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=highlightsectorcnt-1; k>=0; k--)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (highlightsector[k] == wall[j].nextsector)
|
|
|
|
break;
|
|
|
|
if (k < 0)
|
|
|
|
{
|
|
|
|
wall[wall[j].nextwall].nextwall = -1;
|
|
|
|
wall[wall[j].nextwall].nextsector = -1;
|
|
|
|
wall[j].nextwall = -1;
|
|
|
|
wall[j].nextsector = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (((bstatus&1) < (oldmousebstatus&1)) && (highlightsectorcnt < 0)) //after dragging
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t wallsdrawn = newnumwalls-numwalls;
|
2008-10-31 10:08:51 +00:00
|
|
|
|
|
|
|
if (newnumwalls != -1)
|
|
|
|
{
|
|
|
|
newnumwalls = -1;
|
|
|
|
Bmemcpy(&wall[MAXWALLS-wallsdrawn],&wall[numwalls],sizeof(walltype) * wallsdrawn);
|
|
|
|
}
|
|
|
|
else wallsdrawn = -1;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
j = 1;
|
|
|
|
if (highlightcnt > 0)
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (pointhighlight == highlight[i])
|
|
|
|
{
|
|
|
|
j = 0;
|
|
|
|
break;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (j == 0)
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if ((highlight[i]&0xc000) == 16384)
|
|
|
|
{
|
|
|
|
j = (highlight[i]&16383);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
setsprite(j,(vec3_t *)&sprite[j]);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint = ((tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<2);
|
|
|
|
sprite[j].z = max(sprite[j].z,getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint);
|
2006-04-24 19:04:22 +00:00
|
|
|
sprite[j].z = min(sprite[j].z,getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((pointhighlight&0xc000) == 16384)
|
|
|
|
{
|
|
|
|
j = (pointhighlight&16383);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
setsprite(j,(vec3_t *)&sprite[j]);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint = ((tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<2);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
sprite[j].z = max(sprite[j].z,getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint);
|
2006-04-24 19:04:22 +00:00
|
|
|
sprite[j].z = min(sprite[j].z,getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((pointhighlight&0xc000) == 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
dax = wall[pointhighlight].x;
|
|
|
|
day = wall[pointhighlight].y;
|
|
|
|
}
|
|
|
|
else if ((pointhighlight&0xc000) == 16384)
|
|
|
|
{
|
|
|
|
dax = sprite[pointhighlight&16383].x;
|
|
|
|
day = sprite[pointhighlight&16383].y;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls-1; i>=0; i--) //delete points
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[i].x == wall[wall[i].point2].x)
|
|
|
|
if (wall[i].y == wall[wall[i].point2].y)
|
2009-01-09 09:29:17 +00:00
|
|
|
if (sector[sectorofwall((int16_t)i)].wallnum > 3)
|
2008-10-31 10:08:51 +00:00
|
|
|
if (sector[sectorofwall(wall[i].point2)].wallnum > 3)
|
|
|
|
if (!(wall[i].nextwall == -1 ||
|
|
|
|
(sector[sectorofwall(wall[i].nextwall)].wallnum > 3 &&
|
|
|
|
sector[sectorofwall(wall[wall[i].nextwall].point2)].wallnum > 3)))
|
|
|
|
{
|
|
|
|
printmessage16("Invalid operation, delete or join sector instead.");
|
|
|
|
goto SKIP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls-1; i>=0; i--) //delete points
|
2008-10-31 10:08:51 +00:00
|
|
|
{
|
|
|
|
if (wall[i].x == wall[wall[i].point2].x)
|
|
|
|
if (wall[i].y == wall[wall[i].point2].y)
|
2009-01-09 09:29:17 +00:00
|
|
|
if (sector[sectorofwall((int16_t)i)].wallnum > 3)
|
2008-10-31 10:08:51 +00:00
|
|
|
if (sector[sectorofwall(wall[i].point2)].wallnum > 3)
|
|
|
|
if (wall[i].nextwall == -1 ||
|
|
|
|
(sector[sectorofwall(wall[i].nextwall)].wallnum > 3 &&
|
|
|
|
sector[sectorofwall(wall[wall[i].nextwall].point2)].wallnum > 3))
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
deletepoint((int16_t)i);
|
2008-10-31 10:08:51 +00:00
|
|
|
printmessage16("Point deleted.");
|
|
|
|
asksave = 1;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2008-10-31 10:08:51 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++) //make new red lines?
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if ((wall[i].x == dax) && (wall[i].y == day))
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)i,sectorofwall((int16_t)i));
|
|
|
|
fixrepeats((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
else if ((wall[wall[i].point2].x == dax) && (wall[wall[i].point2].y == day))
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)i,sectorofwall((int16_t)i));
|
|
|
|
fixrepeats((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-10-31 10:08:51 +00:00
|
|
|
if (wallsdrawn != -1)
|
|
|
|
{
|
|
|
|
Bmemcpy(&wall[numwalls],&wall[MAXWALLS-wallsdrawn],sizeof(walltype) * wallsdrawn);
|
|
|
|
newnumwalls = numwalls + wallsdrawn;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
2008-10-31 10:08:51 +00:00
|
|
|
wall[i].point2 = i+1;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-10-31 10:08:51 +00:00
|
|
|
SKIP:
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((bstatus&1) > 0) //drag points
|
|
|
|
{
|
|
|
|
if (highlightsectorcnt > 0)
|
|
|
|
{
|
|
|
|
if ((bstatus&1) > (oldmousebstatus&1))
|
|
|
|
{
|
|
|
|
newnumwalls = -1;
|
|
|
|
sectorhighlightstat = -1;
|
|
|
|
updatesector(mousxplc,mousyplc,&cursectorhighlight);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((cursectorhighlight >= 0) && (cursectorhighlight < numsectors))
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (cursectorhighlight == highlightsector[i])
|
|
|
|
{
|
|
|
|
//You clicked inside one of the flashing sectors!
|
|
|
|
sectorhighlightstat = 1;
|
|
|
|
|
|
|
|
dax = mousxplc;
|
|
|
|
day = mousyplc;
|
|
|
|
if ((gridlock > 0) && (grid > 0))
|
|
|
|
{
|
|
|
|
dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
day = ((day+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
}
|
|
|
|
sectorhighlightx = dax;
|
|
|
|
sectorhighlighty = day;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sectorhighlightstat == 1)
|
|
|
|
{
|
|
|
|
dax = mousxplc;
|
|
|
|
day = mousyplc;
|
|
|
|
if ((gridlock > 0) && (grid > 0))
|
|
|
|
{
|
|
|
|
dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
day = ((day+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
dax -= sectorhighlightx;
|
|
|
|
day -= sectorhighlighty;
|
|
|
|
sectorhighlightx += dax;
|
|
|
|
sectorhighlighty += day;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2007-12-12 17:42:14 +00:00
|
|
|
{ wall[j].x += dax; wall[j].y += day; }
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=headspritesect[highlightsector[i]]; j>=0; j=nextspritesect[j])
|
2007-12-12 17:42:14 +00:00
|
|
|
{ sprite[j].x += dax; sprite[j].y += day; }
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//for(i=0;i<highlightsectorcnt;i++)
|
|
|
|
//{
|
|
|
|
// startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
// endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
|
|
|
// for(j=startwall;j<=endwall;j++)
|
|
|
|
// {
|
|
|
|
// if (wall[j].nextwall >= 0)
|
|
|
|
// checksectorpointer(wall[j].nextwall,wall[j].nextsector);
|
|
|
|
// checksectorpointer((short)j,highlightsector[i]);
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
asksave = 1;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((bstatus&1) > (oldmousebstatus&1))
|
2008-09-02 02:45:06 +00:00
|
|
|
pointhighlight = getpointhighlight(mousxplc, mousyplc, pointhighlight);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (pointhighlight >= 0)
|
|
|
|
{
|
|
|
|
dax = mousxplc;
|
|
|
|
day = mousyplc;
|
|
|
|
if ((gridlock > 0) && (grid > 0))
|
|
|
|
{
|
|
|
|
dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
day = ((day+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
j = 1;
|
|
|
|
if (highlightcnt > 0)
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (pointhighlight == highlight[i])
|
2007-12-12 17:42:14 +00:00
|
|
|
{ j = 0; break; }
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (j == 0)
|
|
|
|
{
|
|
|
|
if ((pointhighlight&0xc000) == 0)
|
|
|
|
{
|
|
|
|
dax -= wall[pointhighlight].x;
|
|
|
|
day -= wall[pointhighlight].y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dax -= sprite[pointhighlight&16383].x;
|
|
|
|
day -= sprite[pointhighlight&16383].y;
|
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if ((highlight[i]&0xc000) == 0)
|
|
|
|
{
|
|
|
|
wall[highlight[i]].x += dax;
|
|
|
|
wall[highlight[i]].y += day;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprite[highlight[i]&16383].x += dax;
|
|
|
|
sprite[highlight[i]&16383].y += day;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((pointhighlight&0xc000) == 0)
|
|
|
|
dragpoint(pointhighlight,dax,day);
|
|
|
|
else if ((pointhighlight&0xc000) == 16384)
|
|
|
|
{
|
|
|
|
daz = ((tilesizy[sprite[pointhighlight&16383].picnum]*sprite[pointhighlight&16383].yrepeat)<<2);
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (inside(dax,day,i) == 1)
|
|
|
|
if (sprite[pointhighlight&16383].z >= getceilzofslope(i,dax,day))
|
|
|
|
if (sprite[pointhighlight&16383].z-daz <= getflorzofslope(i,dax,day))
|
|
|
|
{
|
|
|
|
sprite[pointhighlight&16383].x = dax;
|
|
|
|
sprite[pointhighlight&16383].y = day;
|
|
|
|
if (sprite[pointhighlight&16383].sectnum != i)
|
2009-01-09 09:29:17 +00:00
|
|
|
changespritesect(pointhighlight&16383,(int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-09-02 02:45:06 +00:00
|
|
|
pointhighlight = getpointhighlight(mousxplc, mousyplc, pointhighlight);
|
2006-04-24 19:04:22 +00:00
|
|
|
sectorhighlightstat = -1;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((bstatus&6) > 0)
|
|
|
|
{
|
2009-05-01 06:35:27 +00:00
|
|
|
if (keystatus[0x1d]|keystatus[0x9d])
|
|
|
|
{
|
|
|
|
int16_t cursectornum;
|
|
|
|
|
|
|
|
for (cursectornum=0; cursectornum<numsectors; cursectornum++)
|
|
|
|
if (inside(mousxplc,mousyplc,cursectornum) == 1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (cursectornum < numsectors)
|
|
|
|
{
|
|
|
|
if (pointhighlight >= 16384)
|
|
|
|
{
|
|
|
|
i = pointhighlight-16384;
|
|
|
|
ExtEditSpriteData((int16_t)i);
|
|
|
|
}
|
|
|
|
else if ((linehighlight >= 0) && (bstatus&1 || sectorofwall(linehighlight) == cursectornum))
|
|
|
|
{
|
|
|
|
ExtEditWallData((int16_t)linehighlight);
|
|
|
|
}
|
|
|
|
else if (cursectornum >= 0)
|
|
|
|
{
|
|
|
|
ExtEditSectorData((int16_t)cursectornum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bstatus &= ~6;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
searchx = halfxdim16;
|
|
|
|
searchy = midydim16;
|
|
|
|
pos.x = mousxplc;
|
|
|
|
pos.y = mousyplc;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-06-03 07:54:20 +00:00
|
|
|
if (circlewall != -1 && (keystatus[0x4a] || (bstatus&32 && !(keystatus[0x1d]|keystatus[0x9d])))) // -
|
|
|
|
{
|
|
|
|
if (circlepoints > 1)
|
|
|
|
circlepoints--;
|
|
|
|
keystatus[0x4a] = 0;
|
|
|
|
mouseb &= ~32;
|
|
|
|
bstatus &= ~32;
|
|
|
|
}
|
|
|
|
if (circlewall != -1 && (keystatus[0x4e] || (bstatus&16 && !(keystatus[0x1d]|keystatus[0x9d])))) // +
|
|
|
|
{
|
|
|
|
if (circlepoints < 63)
|
|
|
|
circlepoints++;
|
|
|
|
keystatus[0x4e] = 0;
|
|
|
|
mouseb &= ~16;
|
|
|
|
bstatus &= ~16;
|
|
|
|
}
|
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if ((keystatus[buildkeys[BK_MOVEUP]] || (bstatus&16)) && (zoom < 16384))
|
2007-02-15 01:45:38 +00:00
|
|
|
{
|
|
|
|
zoom += synctics*(zoom>>4);
|
2007-03-01 00:50:59 +00:00
|
|
|
if (zoom < 24) zoom += 2;
|
2007-02-15 01:45:38 +00:00
|
|
|
if (bstatus&16 && (keystatus[0x38] || keystatus[0xb8]))
|
|
|
|
{
|
|
|
|
searchx = halfxdim16;
|
|
|
|
searchy = midydim16;
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.x = mousxplc;
|
|
|
|
pos.y = mousyplc;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
2008-12-31 09:07:49 +00:00
|
|
|
if (zoom > 16384) zoom = 16384;
|
2009-05-01 06:35:27 +00:00
|
|
|
_printmessage16("Zoom: %d",zoom);
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if ((keystatus[buildkeys[BK_MOVEDOWN]] || (bstatus&32)) && (zoom > 8))
|
2007-02-15 01:45:38 +00:00
|
|
|
{
|
|
|
|
zoom -= synctics*(zoom>>4);
|
|
|
|
if (bstatus&32 && (keystatus[0x38] || keystatus[0xb8]))
|
|
|
|
{
|
|
|
|
searchx = halfxdim16;
|
|
|
|
searchy = midydim16;
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.x = mousxplc;
|
|
|
|
pos.y = mousyplc;
|
2007-02-15 01:45:38 +00:00
|
|
|
}
|
2008-12-31 09:07:49 +00:00
|
|
|
if (zoom < 8) zoom = 8;
|
2009-05-01 06:35:27 +00:00
|
|
|
_printmessage16("Zoom: %d",zoom);
|
2007-02-15 01:45:38 +00:00
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x22]) // G (grid on/off)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
grid++;
|
|
|
|
if (grid == 7) grid = 0;
|
|
|
|
keystatus[0x22] = 0;
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x26]) // L (grid lock)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
gridlock = 1-gridlock, keystatus[0x26] = 0;
|
|
|
|
if (gridlock == 0)
|
2008-10-31 10:08:51 +00:00
|
|
|
printmessage16("Grid locking off");
|
2006-04-24 19:04:22 +00:00
|
|
|
else
|
2008-10-31 10:08:51 +00:00
|
|
|
printmessage16("Grid locking on");
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x24]) // J (join sectors)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (joinsector[0] >= 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
joinsector[1] = -1;
|
2008-10-31 10:08:51 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2008-10-31 10:08:51 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (inside(mousxplc,mousyplc,i) == 1)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-10-31 10:08:51 +00:00
|
|
|
startwall = sector[i].wallptr;
|
2009-05-01 06:35:27 +00:00
|
|
|
endwall = startwall + sector[i].wallnum;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2008-10-31 10:08:51 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextsector == joinsector[0])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-11-09 13:47:27 +00:00
|
|
|
if (j >= endwall && i != joinsector[0])
|
2008-10-31 10:08:51 +00:00
|
|
|
{
|
2009-05-01 06:35:27 +00:00
|
|
|
_printmessage16("Join non-adjacent sectors? (Y/N)");
|
2008-10-31 10:08:51 +00:00
|
|
|
showframe(1);
|
|
|
|
bflushchars(); ch = 0;
|
|
|
|
while (keystatus[1] == 0)
|
|
|
|
{
|
|
|
|
if (handleevents())
|
|
|
|
{
|
|
|
|
if (quitevent)
|
|
|
|
{
|
|
|
|
quitevent = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
idle();
|
|
|
|
|
|
|
|
ch = bgetchar();
|
|
|
|
|
|
|
|
if (ch == 'Y' || ch == 'y')
|
|
|
|
{
|
|
|
|
joinsector[1] = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (ch == 'N' || ch == 'n' || ch == 13 || ch == ' ')
|
|
|
|
{
|
|
|
|
joinsector[1] = joinsector[0];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
joinsector[1] = i;
|
|
|
|
break;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2008-10-31 10:08:51 +00:00
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((joinsector[1] >= 0) && (joinsector[0] != joinsector[1]))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
newnumwalls = numwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=0; k<2; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[joinsector[k]].wallptr;
|
|
|
|
endwall = startwall + sector[joinsector[k]].wallnum - 1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[j].cstat == 255)
|
|
|
|
continue;
|
|
|
|
joinsectnum = k;
|
|
|
|
if (wall[j].nextsector == joinsector[1-joinsectnum])
|
|
|
|
{
|
|
|
|
wall[j].cstat = 255;
|
|
|
|
continue;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
i = j;
|
|
|
|
m = newnumwalls;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
Bmemcpy(&wall[newnumwalls],&wall[i],sizeof(walltype));
|
|
|
|
wall[newnumwalls].point2 = newnumwalls+1;
|
|
|
|
newnumwalls++;
|
|
|
|
wall[i].cstat = 255;
|
|
|
|
|
|
|
|
i = wall[i].point2;
|
|
|
|
if (wall[i].nextsector == joinsector[1-joinsectnum])
|
|
|
|
{
|
|
|
|
i = wall[wall[i].nextwall].point2;
|
|
|
|
joinsectnum = 1 - joinsectnum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while ((wall[i].cstat != 255) && (wall[i].nextsector != joinsector[1-joinsectnum]));
|
|
|
|
wall[newnumwalls-1].point2 = m;
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (newnumwalls > numwalls)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
Bmemcpy(§or[numsectors],§or[joinsector[0]],sizeof(sectortype));
|
|
|
|
sector[numsectors].wallptr = numwalls;
|
|
|
|
sector[numsectors].wallnum = newnumwalls-numwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//fix sprites
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<2; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
j = headspritesect[joinsector[i]];
|
|
|
|
while (j != -1)
|
|
|
|
{
|
|
|
|
k = nextspritesect[j];
|
|
|
|
changespritesect(j,numsectors);
|
|
|
|
j = k;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
numsectors++;
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[i].nextwall >= 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[wall[i].nextwall].nextwall = i;
|
|
|
|
wall[wall[i].nextwall].nextsector = numsectors-1;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
numwalls = newnumwalls;
|
|
|
|
newnumwalls = -1;
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=0; k<2; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[joinsector[k]].wallptr;
|
|
|
|
endwall = startwall + sector[joinsector[k]].wallnum - 1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[j].nextwall = -1;
|
|
|
|
wall[j].nextsector = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
deletesector((int16_t)joinsector[0]);
|
2006-04-24 19:04:22 +00:00
|
|
|
if (joinsector[0] < joinsector[1])
|
|
|
|
joinsector[1]--;
|
2009-01-09 09:29:17 +00:00
|
|
|
deletesector((int16_t)joinsector[1]);
|
2006-04-24 19:04:22 +00:00
|
|
|
printmessage16("Sectors joined.");
|
|
|
|
}
|
|
|
|
}
|
2008-09-03 14:02:42 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
printmessage16("No sectors joined.");
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
joinsector[0] = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
joinsector[0] = -1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (inside(mousxplc,mousyplc,i) == 1)
|
|
|
|
{
|
|
|
|
joinsector[0] = i;
|
|
|
|
printmessage16("Join sector - press J again on sector to join with.");
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
keystatus[0x24] = 0;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-16 20:15:43 +00:00
|
|
|
// PK
|
|
|
|
for (i=0x02; i<=0x0b; i++) // keys '1' to '0' on the upper row
|
|
|
|
if (keystatus[i])
|
|
|
|
{
|
2008-08-28 15:04:16 +00:00
|
|
|
prefixarg = prefixtiles[i-2];
|
2008-05-16 20:15:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if ((keystatus[0x38]||keystatus[0xb8])&&keystatus[0x1f]) //ALT-S
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if ((linehighlight >= 0) && (wall[linehighlight].nextwall == -1))
|
|
|
|
{
|
|
|
|
if ((newnumwalls = whitelinescan(linehighlight)) < numwalls)
|
|
|
|
{
|
|
|
|
printmessage16("Can't make a sector out there.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
wall[wall[i].nextwall].nextwall = i;
|
|
|
|
wall[wall[i].nextwall].nextsector = numsectors;
|
|
|
|
}
|
|
|
|
numwalls = newnumwalls;
|
|
|
|
newnumwalls = -1;
|
|
|
|
numsectors++;
|
|
|
|
printmessage16("Inner loop made into new sector.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
keystatus[0x1f] = 0;
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
else if (keystatus[0x1f]) //S
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
sucksect = -1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (inside(mousxplc,mousyplc,i) == 1)
|
|
|
|
{
|
|
|
|
sucksect = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sucksect >= 0)
|
|
|
|
{
|
|
|
|
dax = mousxplc;
|
|
|
|
day = mousyplc;
|
|
|
|
if ((gridlock > 0) && (grid > 0))
|
|
|
|
{
|
|
|
|
dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
day = ((day+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
}
|
|
|
|
|
|
|
|
i = insertsprite(sucksect,0);
|
|
|
|
sprite[i].x = dax, sprite[i].y = day;
|
|
|
|
sprite[i].cstat = defaultspritecstat;
|
|
|
|
sprite[i].shade = 0;
|
|
|
|
sprite[i].pal = 0;
|
|
|
|
sprite[i].xrepeat = 64, sprite[i].yrepeat = 64;
|
|
|
|
sprite[i].xoffset = 0, sprite[i].yoffset = 0;
|
|
|
|
sprite[i].ang = 1536;
|
|
|
|
sprite[i].xvel = 0; sprite[i].yvel = 0; sprite[i].zvel = 0;
|
|
|
|
sprite[i].owner = -1;
|
|
|
|
sprite[i].clipdist = 32;
|
|
|
|
sprite[i].lotag = 0;
|
|
|
|
sprite[i].hitag = 0;
|
|
|
|
sprite[i].extra = -1;
|
|
|
|
|
|
|
|
sprite[i].z = getflorzofslope(sucksect,dax,day);
|
|
|
|
if ((sprite[i].cstat&128) != 0)
|
|
|
|
sprite[i].z -= ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1);
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=0; k<MAXTILES; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
localartfreq[k] = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=0; k<MAXSPRITES; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (sprite[k].statnum < MAXSTATUS)
|
|
|
|
localartfreq[sprite[k].picnum]++;
|
|
|
|
j = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=0; k<MAXTILES; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (localartfreq[k] > localartfreq[j])
|
|
|
|
j = k;
|
|
|
|
if (localartfreq[j] > 0)
|
|
|
|
sprite[i].picnum = j;
|
|
|
|
else
|
|
|
|
sprite[i].picnum = 0;
|
|
|
|
|
2008-05-16 20:15:43 +00:00
|
|
|
// PK
|
|
|
|
if (prefixarg)
|
|
|
|
{
|
|
|
|
sprite[i].picnum = prefixarg;
|
|
|
|
sprite[i].xrepeat = sprite[i].yrepeat = 48;
|
2008-05-16 20:27:52 +00:00
|
|
|
prefixarg = 0;
|
2008-05-16 20:15:43 +00:00
|
|
|
}
|
|
|
|
else if (somethingintab == 3)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
sprite[i].picnum = temppicnum;
|
|
|
|
if ((tilesizx[temppicnum] <= 0) || (tilesizy[temppicnum] <= 0))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
j = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=0; k<MAXTILES; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((tilesizx[k] > 0) && (tilesizy[k] > 0))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
j = k;
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
sprite[i].picnum = j;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
sprite[i].shade = tempshade;
|
|
|
|
sprite[i].pal = temppal;
|
|
|
|
sprite[i].xrepeat = tempxrepeat;
|
|
|
|
sprite[i].yrepeat = tempyrepeat;
|
|
|
|
if (sprite[i].xrepeat < 1) sprite[i].xrepeat = 1;
|
|
|
|
if (sprite[i].yrepeat < 1) sprite[i].yrepeat = 1;
|
|
|
|
sprite[i].cstat = tempcstat;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if (tilesizy[sprite[i].picnum] >= 32)
|
|
|
|
sprite[i].cstat |= 1;
|
|
|
|
|
|
|
|
printmessage16("Sprite inserted.");
|
|
|
|
updatenumsprites();
|
2006-04-13 20:47:06 +00:00
|
|
|
asksave = 1;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
keystatus[0x1f] = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x2e]) // C (make circle of points)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (highlightsectorcnt >= 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
newnumsectors = numsectors;
|
|
|
|
newnumwalls = numwalls;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
copysector(highlightsector[i],newnumsectors,newnumwalls,1);
|
|
|
|
newnumsectors++;
|
|
|
|
newnumwalls += sector[highlightsector[i]].wallnum;
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
checksectorpointer(wall[j].nextwall,wall[j].nextsector);
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)j,highlightsector[i]);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
highlightsector[i] = numsectors+i;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
numsectors = newnumsectors;
|
|
|
|
numwalls = newnumwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
newnumwalls = -1;
|
|
|
|
newnumsectors = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
updatenumsprites();
|
|
|
|
printmessage16("Sectors duplicated and stamped.");
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
else if (highlightcnt >= 0)
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((highlight[i]&0xc000) == 16384)
|
|
|
|
{
|
|
|
|
//duplicate sprite
|
|
|
|
k = (highlight[i]&16383);
|
|
|
|
j = insertsprite(sprite[k].sectnum,sprite[k].statnum);
|
|
|
|
Bmemcpy(&sprite[j],&sprite[k],sizeof(spritetype));
|
|
|
|
sprite[j].sectnum = sprite[k].sectnum; //Don't let memcpy overwrite sector!
|
2009-01-13 12:23:18 +00:00
|
|
|
setsprite(j,(vec3_t *)&sprite[j]);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
updatenumsprites();
|
|
|
|
printmessage16("Sprites duplicated and stamped.");
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (circlewall >= 0)
|
|
|
|
{
|
|
|
|
circlewall = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (linehighlight >= 0)
|
|
|
|
circlewall = linehighlight;
|
|
|
|
}
|
|
|
|
keystatus[0x2e] = 0;
|
|
|
|
}
|
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
bad = (keystatus[0x39]); //Gotta do this to save lots of 3 spaces!
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if (circlewall >= 0)
|
|
|
|
{
|
|
|
|
x1 = wall[circlewall].x;
|
|
|
|
y1 = wall[circlewall].y;
|
|
|
|
x2 = wall[wall[circlewall].point2].x;
|
|
|
|
y2 = wall[wall[circlewall].point2].y;
|
|
|
|
x3 = mousxplc;
|
|
|
|
y3 = mousyplc;
|
|
|
|
adjustmark(&x3,&y3,newnumwalls);
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint1 = dmulscale4(x3-x2,x1-x3,y1-y3,y3-y2);
|
|
|
|
tempint2 = dmulscale4(y1-y2,x1-x3,y1-y3,x2-x1);
|
|
|
|
if (tempint2 != 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t pointsize = 2;
|
2008-09-01 07:15:16 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
centerx = (((x1+x2) + scale(y1-y2,tempint1,tempint2))>>1);
|
|
|
|
centery = (((y1+y2) + scale(x2-x1,tempint1,tempint2))>>1);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
dax = mulscale14(centerx-pos.x,zoom);
|
|
|
|
day = mulscale14(centery-pos.y,zoom);
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(halfxdim16+dax-2,midydim16+day-2,halfxdim16+dax+2,midydim16+day+2,editorcolors[14]);
|
|
|
|
drawline16(halfxdim16+dax-2,midydim16+day+2,halfxdim16+dax+2,midydim16+day-2,editorcolors[14]);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
circleang1 = getangle(x1-centerx,y1-centery);
|
|
|
|
circleang2 = getangle(x2-centerx,y2-centery);
|
|
|
|
|
|
|
|
circleangdir = 1;
|
|
|
|
k = ((circleang2-circleang1)&2047);
|
|
|
|
if (mulscale4(x3-x1,y2-y1) < mulscale4(x2-x1,y3-y1))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
circleangdir = -1;
|
|
|
|
k = -((circleang1-circleang2)&2047);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
circlerad = (ksqrt(dmulscale4(centerx-x1,centerx-x1,centery-y1,centery-y1))<<2);
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=circlepoints; i>0; i--)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
j = ((circleang1 + scale(i,k,circlepoints+1))&2047);
|
|
|
|
dax = centerx+mulscale14(sintable[(j+512)&2047],circlerad);
|
|
|
|
day = centery+mulscale14(sintable[j],circlerad);
|
|
|
|
|
|
|
|
if (dax <= -editorgridextent) dax = -editorgridextent;
|
|
|
|
if (dax >= editorgridextent) dax = editorgridextent;
|
|
|
|
if (day <= -editorgridextent) day = -editorgridextent;
|
|
|
|
if (day >= editorgridextent) day = editorgridextent;
|
|
|
|
|
|
|
|
if (bad > 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
m = 0;
|
|
|
|
if (wall[circlewall].nextwall >= 0)
|
|
|
|
if (wall[circlewall].nextwall < circlewall) m = 1;
|
|
|
|
insertpoint(circlewall,dax,day);
|
|
|
|
circlewall += m;
|
|
|
|
}
|
2009-01-13 12:23:18 +00:00
|
|
|
dax = mulscale14(dax-pos.x,zoom);
|
|
|
|
day = mulscale14(day-pos.y,zoom);
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(halfxdim16+dax-pointsize,midydim16+day-pointsize,halfxdim16+dax+pointsize,midydim16+day-pointsize,editorcolors[14]);
|
|
|
|
drawline16(halfxdim16+dax+pointsize,midydim16+day-pointsize,halfxdim16+dax+pointsize,midydim16+day+pointsize,editorcolors[14]);
|
|
|
|
drawline16(halfxdim16+dax+pointsize,midydim16+day+pointsize,halfxdim16+dax-pointsize,midydim16+day+pointsize,editorcolors[14]);
|
|
|
|
drawline16(halfxdim16+dax-pointsize,midydim16+day+pointsize,halfxdim16+dax-pointsize,midydim16+day-pointsize,editorcolors[14]);
|
2008-09-01 07:15:16 +00:00
|
|
|
// drawcircle16(halfxdim16+dax, midydim16+day, 3, 14);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
if (bad > 0)
|
|
|
|
{
|
|
|
|
bad = 0;
|
|
|
|
keystatus[0x39] = 0;
|
|
|
|
asksave = 1;
|
|
|
|
printmessage16("Circle points inserted.");
|
|
|
|
circlewall = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bad > 0) //Space bar test
|
|
|
|
{
|
|
|
|
keystatus[0x39] = 0;
|
|
|
|
adjustmark(&mousxplc,&mousyplc,newnumwalls);
|
|
|
|
if (checkautoinsert(mousxplc,mousyplc,newnumwalls) == 1)
|
|
|
|
{
|
|
|
|
printmessage16("You must insert a point there first.");
|
|
|
|
bad = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bad > 0) //Space
|
|
|
|
{
|
|
|
|
if ((newnumwalls < numwalls) && (numwalls < MAXWALLS-1))
|
|
|
|
{
|
|
|
|
firstx = mousxplc, firsty = mousyplc; //Make first point
|
|
|
|
newnumwalls = numwalls;
|
|
|
|
suckwall = -1;
|
|
|
|
split = 0;
|
|
|
|
|
|
|
|
//clearbufbyte(&wall[newnumwalls],sizeof(walltype),0L);
|
|
|
|
memset(&wall[newnumwalls],0,sizeof(walltype));
|
|
|
|
wall[newnumwalls].extra = -1;
|
|
|
|
|
|
|
|
wall[newnumwalls].x = mousxplc;
|
|
|
|
wall[newnumwalls].y = mousyplc;
|
|
|
|
wall[newnumwalls].nextsector = -1;
|
|
|
|
wall[newnumwalls].nextwall = -1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((wall[i].x == mousxplc) && (wall[i].y == mousyplc))
|
|
|
|
suckwall = i;
|
|
|
|
wall[newnumwalls].point2 = newnumwalls+1;
|
|
|
|
printmessage16("Sector drawing started.");
|
|
|
|
newnumwalls++;
|
|
|
|
}
|
|
|
|
else
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
//if not back to first point
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((firstx != mousxplc) || (firsty != mousyplc)) //nextpoint
|
|
|
|
{
|
|
|
|
j = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((mousxplc == wall[i].x) && (mousyplc == wall[i].y))
|
|
|
|
j = 1;
|
|
|
|
if (j == 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
//check if starting to split a sector
|
|
|
|
if (newnumwalls == numwalls+1)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
dax = ((wall[numwalls].x+mousxplc)>>1);
|
|
|
|
day = ((wall[numwalls].y+mousyplc)>>1);
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (inside(dax,day,i) == 1)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
//check if first point at point of sector
|
2006-04-24 19:04:22 +00:00
|
|
|
m = -1;
|
|
|
|
startwall = sector[i].wallptr;
|
|
|
|
endwall = startwall + sector[i].wallnum - 1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=startwall; k<=endwall; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[k].x == wall[numwalls].x)
|
|
|
|
if (wall[k].y == wall[numwalls].y)
|
|
|
|
{
|
|
|
|
m = k;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (m >= 0)
|
|
|
|
if ((wall[wall[k].point2].x != mousxplc) || (wall[wall[k].point2].y != mousyplc))
|
2009-01-09 09:29:17 +00:00
|
|
|
if ((wall[lastwall((int16_t)k)].x != mousxplc) || (wall[lastwall((int16_t)k)].y != mousyplc))
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
split = 1;
|
|
|
|
splitsect = i;
|
|
|
|
splitstartwall = m;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//make new point
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//make sure not drawing over old red line
|
|
|
|
bad = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[i].nextwall >= 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((wall[i].x == mousxplc) && (wall[i].y == mousyplc))
|
|
|
|
if ((wall[wall[i].point2].x == wall[newnumwalls-1].x) && (wall[wall[i].point2].y == wall[newnumwalls-1].y))
|
|
|
|
bad = 1;
|
|
|
|
if ((wall[i].x == wall[newnumwalls-1].x) && (wall[i].y == wall[newnumwalls-1].y))
|
|
|
|
if ((wall[wall[i].point2].x == mousxplc) && (wall[wall[i].point2].y == mousyplc))
|
|
|
|
bad = 1;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (bad == 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
//clearbufbyte(&wall[newnumwalls],sizeof(walltype),0L);
|
|
|
|
memset(&wall[newnumwalls],0,sizeof(walltype));
|
|
|
|
wall[newnumwalls].extra = -1;
|
|
|
|
|
|
|
|
wall[newnumwalls].x = mousxplc;
|
|
|
|
wall[newnumwalls].y = mousyplc;
|
|
|
|
wall[newnumwalls].nextsector = -1;
|
|
|
|
wall[newnumwalls].nextwall = -1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((wall[i].x == mousxplc) && (wall[i].y == mousyplc))
|
|
|
|
suckwall = i;
|
|
|
|
wall[newnumwalls].point2 = newnumwalls+1;
|
|
|
|
newnumwalls++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printmessage16("You can't draw new lines over red lines.");
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//if not split and back to first point
|
|
|
|
if ((split == 0) && (firstx == mousxplc) && (firsty == mousyplc) && (newnumwalls >= numwalls+3))
|
|
|
|
{
|
|
|
|
wall[newnumwalls-1].point2 = numwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (suckwall == -1) //if no connections to other sectors
|
|
|
|
{
|
|
|
|
k = -1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (inside(firstx,firsty,i) == 1)
|
|
|
|
k = i;
|
|
|
|
if (k == -1) //if not inside another sector either
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
//add island sector
|
2006-04-24 19:04:22 +00:00
|
|
|
if (clockdir(numwalls) == 1)
|
|
|
|
flipwalls(numwalls,newnumwalls);
|
|
|
|
|
|
|
|
//clearbufbyte(§or[numsectors],sizeof(sectortype),0L);
|
|
|
|
memset(§or[numsectors],0,sizeof(sectortype));
|
|
|
|
sector[numsectors].extra = -1;
|
|
|
|
|
|
|
|
sector[numsectors].wallptr = numwalls;
|
|
|
|
sector[numsectors].wallnum = newnumwalls-numwalls;
|
|
|
|
sector[numsectors].ceilingz = (-32<<8);
|
|
|
|
sector[numsectors].floorz = (32<<8);
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
wall[i].cstat = 0;
|
|
|
|
wall[i].shade = 0;
|
|
|
|
wall[i].yrepeat = 8;
|
2009-01-09 09:29:17 +00:00
|
|
|
fixrepeats((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[i].picnum = 0;
|
|
|
|
wall[i].overpicnum = 0;
|
|
|
|
wall[i].nextsector = -1;
|
|
|
|
wall[i].nextwall = -1;
|
|
|
|
}
|
|
|
|
headspritesect[numsectors] = -1;
|
|
|
|
numsectors++;
|
|
|
|
}
|
|
|
|
else //else add loop to sector
|
|
|
|
{
|
|
|
|
if (clockdir(numwalls) == 0)
|
|
|
|
flipwalls(numwalls,newnumwalls);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
j = newnumwalls-numwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[k].wallnum += j;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=k+1; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[i].wallptr += j;
|
|
|
|
suckwall = sector[k].wallptr;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[i].nextwall >= suckwall)
|
|
|
|
wall[i].nextwall += j;
|
|
|
|
if (wall[i].point2 >= suckwall)
|
|
|
|
wall[i].point2 += j;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=newnumwalls-1; i>=suckwall; i--)
|
2006-04-24 19:04:22 +00:00
|
|
|
Bmemcpy(&wall[i+j],&wall[i],sizeof(walltype));
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<j; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
Bmemcpy(&wall[i+suckwall],&wall[i+newnumwalls],sizeof(walltype));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=suckwall; i<suckwall+j; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
wall[i].point2 += (suckwall-numwalls);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-03-15 21:04:35 +00:00
|
|
|
wall[i].cstat = wall[suckwall+j].cstat&~(1+16+32+64);
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[i].shade = wall[suckwall+j].shade;
|
|
|
|
wall[i].yrepeat = wall[suckwall+j].yrepeat;
|
2009-01-09 09:29:17 +00:00
|
|
|
fixrepeats((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[i].picnum = wall[suckwall+j].picnum;
|
|
|
|
wall[i].overpicnum = wall[suckwall+j].overpicnum;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[i].nextsector = -1;
|
|
|
|
wall[i].nextwall = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//add new sector with connections
|
|
|
|
if (clockdir(numwalls) == 1)
|
|
|
|
flipwalls(numwalls,newnumwalls);
|
|
|
|
|
|
|
|
//clearbufbyte(§or[numsectors],sizeof(sectortype),0L);
|
|
|
|
memset(§or[numsectors],0,sizeof(sectortype));
|
|
|
|
sector[numsectors].extra = -1;
|
|
|
|
|
|
|
|
sector[numsectors].wallptr = numwalls;
|
|
|
|
sector[numsectors].wallnum = newnumwalls-numwalls;
|
|
|
|
sucksect = sectorofwall(suckwall);
|
|
|
|
sector[numsectors].ceilingstat = sector[sucksect].ceilingstat;
|
|
|
|
sector[numsectors].floorstat = sector[sucksect].floorstat;
|
|
|
|
sector[numsectors].ceilingxpanning = sector[sucksect].ceilingxpanning;
|
|
|
|
sector[numsectors].floorxpanning = sector[sucksect].floorxpanning;
|
|
|
|
sector[numsectors].ceilingshade = sector[sucksect].ceilingshade;
|
|
|
|
sector[numsectors].floorshade = sector[sucksect].floorshade;
|
|
|
|
sector[numsectors].ceilingz = sector[sucksect].ceilingz;
|
|
|
|
sector[numsectors].floorz = sector[sucksect].floorz;
|
|
|
|
sector[numsectors].ceilingpicnum = sector[sucksect].ceilingpicnum;
|
|
|
|
sector[numsectors].floorpicnum = sector[sucksect].floorpicnum;
|
|
|
|
sector[numsectors].ceilingheinum = sector[sucksect].ceilingheinum;
|
|
|
|
sector[numsectors].floorheinum = sector[sucksect].floorheinum;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
wall[i].cstat = wall[suckwall].cstat;
|
|
|
|
wall[i].shade = wall[suckwall].shade;
|
|
|
|
wall[i].yrepeat = wall[suckwall].yrepeat;
|
2009-01-09 09:29:17 +00:00
|
|
|
fixrepeats((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[i].picnum = wall[suckwall].picnum;
|
|
|
|
wall[i].overpicnum = wall[suckwall].overpicnum;
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)i,(int16_t)numsectors);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
headspritesect[numsectors] = -1;
|
|
|
|
numsectors++;
|
|
|
|
}
|
|
|
|
numwalls = newnumwalls;
|
|
|
|
newnumwalls = -1;
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
if (split == 1)
|
|
|
|
{
|
|
|
|
//split sector
|
|
|
|
startwall = sector[splitsect].wallptr;
|
|
|
|
endwall = startwall + sector[splitsect].wallnum - 1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=startwall; k<=endwall; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[k].x == wall[newnumwalls-1].x)
|
|
|
|
if (wall[k].y == wall[newnumwalls-1].y)
|
|
|
|
{
|
|
|
|
bad = 0;
|
2009-01-09 09:29:17 +00:00
|
|
|
if (loopnumofsector(splitsect,splitstartwall) != loopnumofsector(splitsect,(int16_t)k))
|
2006-04-24 19:04:22 +00:00
|
|
|
bad = 1;
|
|
|
|
|
|
|
|
if (bad == 0)
|
|
|
|
{
|
|
|
|
//SPLIT IT!
|
|
|
|
//Split splitsect given: startwall,
|
|
|
|
// new points: numwalls to newnumwalls-2
|
|
|
|
|
|
|
|
splitendwall = k;
|
|
|
|
newnumwalls--; //first fix up the new walls
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
wall[i].cstat = wall[startwall].cstat;
|
|
|
|
wall[i].shade = wall[startwall].shade;
|
|
|
|
wall[i].yrepeat = wall[startwall].yrepeat;
|
2009-01-09 09:29:17 +00:00
|
|
|
fixrepeats((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[i].picnum = wall[startwall].picnum;
|
|
|
|
wall[i].overpicnum = wall[startwall].overpicnum;
|
|
|
|
|
|
|
|
wall[i].nextwall = -1;
|
|
|
|
wall[i].nextsector = -1;
|
|
|
|
wall[i].point2 = i+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
danumwalls = newnumwalls; //where to add more walls
|
|
|
|
m = splitendwall; //copy rest of loop next
|
|
|
|
while (m != splitstartwall)
|
|
|
|
{
|
|
|
|
Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype));
|
|
|
|
wall[danumwalls].point2 = danumwalls+1;
|
|
|
|
danumwalls++;
|
|
|
|
m = wall[m].point2;
|
|
|
|
}
|
|
|
|
wall[danumwalls-1].point2 = numwalls;
|
|
|
|
|
|
|
|
//Add other loops for 1st sector
|
|
|
|
loopnum = loopnumofsector(splitsect,splitstartwall);
|
|
|
|
i = loopnum;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
k = loopnumofsector(splitsect,(int16_t)j);
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((k != i) && (k != loopnum))
|
|
|
|
{
|
|
|
|
i = k;
|
|
|
|
if (loopinside(wall[j].x,wall[j].y,numwalls) == 1)
|
|
|
|
{
|
|
|
|
m = j; //copy loop
|
|
|
|
k = danumwalls;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype));
|
|
|
|
wall[danumwalls].point2 = danumwalls+1;
|
|
|
|
danumwalls++;
|
|
|
|
m = wall[m].point2;
|
|
|
|
}
|
|
|
|
while (m != j);
|
|
|
|
wall[danumwalls-1].point2 = k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
secondstartwall = danumwalls;
|
|
|
|
//copy split points for other sector backwards
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=newnumwalls; j>numwalls; j--)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
Bmemcpy(&wall[danumwalls],&wall[j],sizeof(walltype));
|
|
|
|
wall[danumwalls].nextwall = -1;
|
|
|
|
wall[danumwalls].nextsector = -1;
|
|
|
|
wall[danumwalls].point2 = danumwalls+1;
|
|
|
|
danumwalls++;
|
|
|
|
}
|
|
|
|
m = splitstartwall; //copy rest of loop next
|
|
|
|
while (m != splitendwall)
|
|
|
|
{
|
|
|
|
Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype));
|
|
|
|
wall[danumwalls].point2 = danumwalls+1;
|
|
|
|
danumwalls++;
|
|
|
|
m = wall[m].point2;
|
|
|
|
}
|
|
|
|
wall[danumwalls-1].point2 = secondstartwall;
|
|
|
|
|
|
|
|
//Add other loops for 2nd sector
|
|
|
|
loopnum = loopnumofsector(splitsect,splitstartwall);
|
|
|
|
i = loopnum;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
k = loopnumofsector(splitsect,(int16_t)j);
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((k != i) && (k != loopnum))
|
|
|
|
{
|
|
|
|
i = k;
|
|
|
|
if (loopinside(wall[j].x,wall[j].y,secondstartwall) == 1)
|
|
|
|
{
|
|
|
|
m = j; //copy loop
|
|
|
|
k = danumwalls;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype));
|
|
|
|
wall[danumwalls].point2 = danumwalls+1;
|
|
|
|
danumwalls++;
|
|
|
|
m = wall[m].point2;
|
|
|
|
}
|
|
|
|
while (m != j);
|
|
|
|
wall[danumwalls-1].point2 = k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//fix all next pointers on old sector line
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=numwalls; j<danumwalls; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
{
|
|
|
|
wall[wall[j].nextwall].nextwall = j;
|
|
|
|
if (j < secondstartwall)
|
|
|
|
wall[wall[j].nextwall].nextsector = numsectors;
|
|
|
|
else
|
|
|
|
wall[wall[j].nextwall].nextsector = numsectors+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//set all next pointers on split
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=numwalls; j<newnumwalls; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
m = secondstartwall+(newnumwalls-1-j);
|
|
|
|
wall[j].nextwall = m;
|
|
|
|
wall[j].nextsector = numsectors+1;
|
|
|
|
wall[m].nextwall = j;
|
|
|
|
wall[m].nextsector = numsectors;
|
|
|
|
}
|
|
|
|
//copy sector attributes & fix wall pointers
|
|
|
|
Bmemcpy(§or[numsectors],§or[splitsect],sizeof(sectortype));
|
|
|
|
Bmemcpy(§or[numsectors+1],§or[splitsect],sizeof(sectortype));
|
|
|
|
sector[numsectors].wallptr = numwalls;
|
|
|
|
sector[numsectors].wallnum = secondstartwall-numwalls;
|
|
|
|
sector[numsectors+1].wallptr = secondstartwall;
|
|
|
|
sector[numsectors+1].wallnum = danumwalls-secondstartwall;
|
|
|
|
|
|
|
|
//fix sprites
|
|
|
|
j = headspritesect[splitsect];
|
|
|
|
while (j != -1)
|
|
|
|
{
|
|
|
|
k = nextspritesect[j];
|
|
|
|
if (loopinside(sprite[j].x,sprite[j].y,numwalls) == 1)
|
|
|
|
changespritesect(j,numsectors);
|
|
|
|
//else if (loopinside(sprite[j].x,sprite[j].y,secondstartwall) == 1)
|
|
|
|
else //Make sure no sprites get left out & deleted!
|
|
|
|
changespritesect(j,numsectors+1);
|
|
|
|
j = k;
|
|
|
|
}
|
|
|
|
|
|
|
|
numsectors+=2;
|
|
|
|
|
|
|
|
//Back of number of walls of new sector for later
|
|
|
|
k = danumwalls-numwalls;
|
|
|
|
|
|
|
|
//clear out old sector's next pointers for clean deletesector
|
|
|
|
numwalls = danumwalls;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
wall[j].nextwall = -1;
|
|
|
|
wall[j].nextsector = -1;
|
|
|
|
}
|
|
|
|
deletesector(splitsect);
|
|
|
|
|
|
|
|
//Check pointers
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=numwalls-k; j<numwalls; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
checksectorpointer(wall[j].nextwall,wall[j].nextsector);
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)j,sectorofwall((int16_t)j));
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//k now safe to use as temp
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (m=numsectors-2; m<numsectors; m++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
j = headspritesect[m];
|
|
|
|
while (j != -1)
|
|
|
|
{
|
|
|
|
k = nextspritesect[j];
|
2009-01-13 12:23:18 +00:00
|
|
|
setsprite(j,(vec3_t *)&sprite[j]);
|
2006-04-24 19:04:22 +00:00
|
|
|
j = k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
newnumwalls = -1;
|
|
|
|
printmessage16("Sector split.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Sector split - actually loop joining
|
|
|
|
|
|
|
|
splitendwall = k;
|
|
|
|
newnumwalls--; //first fix up the new walls
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
wall[i].cstat = wall[startwall].cstat;
|
|
|
|
wall[i].shade = wall[startwall].shade;
|
|
|
|
wall[i].yrepeat = wall[startwall].yrepeat;
|
2009-01-09 09:29:17 +00:00
|
|
|
fixrepeats((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[i].picnum = wall[startwall].picnum;
|
|
|
|
wall[i].overpicnum = wall[startwall].overpicnum;
|
|
|
|
|
|
|
|
wall[i].nextwall = -1;
|
|
|
|
wall[i].nextsector = -1;
|
|
|
|
wall[i].point2 = i+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
danumwalls = newnumwalls; //where to add more walls
|
|
|
|
m = splitendwall; //copy rest of loop next
|
|
|
|
do
|
|
|
|
{
|
|
|
|
Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype));
|
|
|
|
wall[danumwalls].point2 = danumwalls+1;
|
|
|
|
danumwalls++;
|
|
|
|
m = wall[m].point2;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
while (m != splitendwall);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
//copy split points for other sector backwards
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=newnumwalls; j>numwalls; j--)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
Bmemcpy(&wall[danumwalls],&wall[j],sizeof(walltype));
|
|
|
|
wall[danumwalls].nextwall = -1;
|
|
|
|
wall[danumwalls].nextsector = -1;
|
|
|
|
wall[danumwalls].point2 = danumwalls+1;
|
|
|
|
danumwalls++;
|
|
|
|
}
|
|
|
|
|
|
|
|
m = splitstartwall; //copy rest of loop next
|
|
|
|
do
|
|
|
|
{
|
|
|
|
Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype));
|
|
|
|
wall[danumwalls].point2 = danumwalls+1;
|
|
|
|
danumwalls++;
|
|
|
|
m = wall[m].point2;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
while (m != splitstartwall);
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[danumwalls-1].point2 = numwalls;
|
|
|
|
|
|
|
|
//Add other loops to sector
|
|
|
|
loopnum = loopnumofsector(splitsect,splitstartwall);
|
|
|
|
i = loopnum;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
k = loopnumofsector(splitsect,(int16_t)j);
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((k != i) && (k != loopnumofsector(splitsect,splitstartwall)) && (k != loopnumofsector(splitsect,splitendwall)))
|
|
|
|
{
|
|
|
|
i = k;
|
|
|
|
m = j; k = danumwalls; //copy loop
|
|
|
|
do
|
|
|
|
{
|
|
|
|
Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype));
|
|
|
|
wall[danumwalls].point2 = danumwalls+1;
|
|
|
|
danumwalls++;
|
|
|
|
m = wall[m].point2;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
while (m != j);
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[danumwalls-1].point2 = k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//fix all next pointers on old sector line
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=numwalls; j<danumwalls; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
{
|
|
|
|
wall[wall[j].nextwall].nextwall = j;
|
|
|
|
wall[wall[j].nextwall].nextsector = numsectors;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//copy sector attributes & fix wall pointers
|
|
|
|
Bmemcpy(§or[numsectors],§or[splitsect],sizeof(sectortype));
|
|
|
|
sector[numsectors].wallptr = numwalls;
|
|
|
|
sector[numsectors].wallnum = danumwalls-numwalls;
|
|
|
|
|
|
|
|
//fix sprites
|
|
|
|
j = headspritesect[splitsect];
|
|
|
|
while (j != -1)
|
|
|
|
{
|
|
|
|
k = nextspritesect[j];
|
|
|
|
changespritesect(j,numsectors);
|
|
|
|
j = k;
|
|
|
|
}
|
|
|
|
|
|
|
|
numsectors++;
|
|
|
|
|
|
|
|
//Back of number of walls of new sector for later
|
|
|
|
k = danumwalls-numwalls;
|
|
|
|
|
|
|
|
//clear out old sector's next pointers for clean deletesector
|
|
|
|
numwalls = danumwalls;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
wall[j].nextwall = -1;
|
|
|
|
wall[j].nextsector = -1;
|
|
|
|
}
|
|
|
|
deletesector(splitsect);
|
|
|
|
|
|
|
|
//Check pointers
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=numwalls-k; j<numwalls; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
checksectorpointer(wall[j].nextwall,wall[j].nextsector);
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)j,numsectors-1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
newnumwalls = -1;
|
|
|
|
printmessage16("Loops joined.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x1c]) //Left Enter
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[0x1c] = 0;
|
|
|
|
if (keystatus[0x2a]&keystatus[0x1d])
|
|
|
|
{
|
|
|
|
printmessage16("CHECKING ALL POINTERS!");
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[i].wallptr;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<numwalls; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[j].point2 < startwall) startwall = wall[j].point2;
|
|
|
|
sector[i].wallptr = startwall;
|
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numsectors-2; i>=0; i--)
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[i].wallnum = sector[i+1].wallptr-sector[i].wallptr;
|
|
|
|
sector[numsectors-1].wallnum = numwalls-sector[numsectors-1].wallptr;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
wall[i].nextsector = -1;
|
|
|
|
wall[i].nextwall = -1;
|
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[i].wallptr;
|
|
|
|
endwall = startwall + sector[i].wallnum;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<endwall; j++)
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)j,(int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
printmessage16("ALL POINTERS CHECKED!");
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (linehighlight >= 0)
|
|
|
|
{
|
|
|
|
checksectorpointer(linehighlight,sectorofwall(linehighlight));
|
|
|
|
printmessage16("Highlighted line pointers checked.");
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-12-25 09:43:00 +00:00
|
|
|
if (keystatus[0x0e]) //Backspace
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-12-25 09:43:00 +00:00
|
|
|
if (newnumwalls >= numwalls)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-12-25 09:43:00 +00:00
|
|
|
if (newnumwalls > numwalls)
|
|
|
|
{
|
|
|
|
newnumwalls--;
|
|
|
|
asksave = 1;
|
|
|
|
keystatus[0x0e] = 0;
|
|
|
|
}
|
|
|
|
if (newnumwalls == numwalls)
|
|
|
|
{
|
|
|
|
newnumwalls = -1;
|
|
|
|
asksave = 1;
|
|
|
|
keystatus[0x0e] = 0;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2008-12-25 09:43:00 +00:00
|
|
|
else
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-12-30 03:41:21 +00:00
|
|
|
if (keystatus[buildkeys[BK_RUN]] || keystatus[0x36])
|
2008-12-28 23:27:24 +00:00
|
|
|
{
|
|
|
|
if (--graphicsmode < 0)
|
|
|
|
graphicsmode = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (++graphicsmode > 2)
|
|
|
|
graphicsmode = 0;
|
|
|
|
}
|
|
|
|
printmessage16("2D mode textures %s",
|
2009-02-19 16:47:54 +00:00
|
|
|
(graphicsmode == 2)?"enabled w/ animation":graphicsmode?"enabled":"disabled");
|
2006-04-24 19:04:22 +00:00
|
|
|
keystatus[0x0e] = 0;
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0xd3] && (keystatus[0x1d]||keystatus[0x9d]) && (numwalls >= 0))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
//sector delete
|
2006-04-24 19:04:22 +00:00
|
|
|
keystatus[0xd3] = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
sucksect = -1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (inside(mousxplc,mousyplc,i) == 1)
|
|
|
|
{
|
|
|
|
k = 0;
|
|
|
|
if (highlightsectorcnt >= 0)
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<highlightsectorcnt; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (highlightsector[j] == i)
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=highlightsectorcnt-1; j>=0; j--)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
deletesector(highlightsector[j]);
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=j-1; k>=0; k--)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (highlightsector[k] >= highlightsector[j])
|
|
|
|
highlightsector[k]--;
|
|
|
|
}
|
|
|
|
printmessage16("Highlighted sectors deleted.");
|
|
|
|
newnumwalls = -1;
|
|
|
|
k = 1;
|
|
|
|
highlightsectorcnt = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (k == 0)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
deletesector((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
highlightsectorcnt = -1;
|
|
|
|
printmessage16("Sector deleted.");
|
|
|
|
}
|
|
|
|
newnumwalls = -1;
|
|
|
|
asksave = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0xd3] && (pointhighlight >= 0))
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if ((pointhighlight&0xc000) == 16384) //Sprite Delete
|
|
|
|
{
|
|
|
|
deletesprite(pointhighlight&16383);
|
|
|
|
printmessage16("Sprite deleted.");
|
|
|
|
updatenumsprites();
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
keystatus[0xd3] = 0;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-08-28 23:15:11 +00:00
|
|
|
if (keystatus[0xd2] || keystatus[0x17]) //InsertPoint
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2006-04-13 20:47:06 +00:00
|
|
|
if (highlightsectorcnt >= 0)
|
|
|
|
{
|
|
|
|
newnumsectors = numsectors;
|
|
|
|
newnumwalls = numwalls;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
copysector(highlightsector[i],newnumsectors,newnumwalls,1);
|
|
|
|
newnumsectors++;
|
|
|
|
newnumwalls += sector[highlightsector[i]].wallnum;
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
checksectorpointer(wall[j].nextwall,wall[j].nextsector);
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)j,highlightsector[i]);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
highlightsector[i] = numsectors+i;
|
|
|
|
}
|
|
|
|
numsectors = newnumsectors;
|
|
|
|
numwalls = newnumwalls;
|
|
|
|
|
|
|
|
newnumwalls = -1;
|
|
|
|
newnumsectors = -1;
|
|
|
|
|
|
|
|
updatenumsprites();
|
|
|
|
printmessage16("Sectors duplicated and stamped.");
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
else if (highlightcnt >= 0)
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightcnt; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
if ((highlight[i]&0xc000) == 16384)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
//duplicate sprite
|
2006-04-13 20:47:06 +00:00
|
|
|
k = (highlight[i]&16383);
|
|
|
|
j = insertsprite(sprite[k].sectnum,sprite[k].statnum);
|
|
|
|
Bmemcpy(&sprite[j],&sprite[k],sizeof(spritetype));
|
|
|
|
sprite[j].sectnum = sprite[k].sectnum; //Don't let memcpy overwrite sector!
|
2009-01-13 12:23:18 +00:00
|
|
|
setsprite(j,(vec3_t *)&sprite[j]);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
updatenumsprites();
|
|
|
|
printmessage16("Sprites duplicated and stamped.");
|
|
|
|
asksave = 1;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
else if (linehighlight >= 0)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t wallsdrawn = newnumwalls-numwalls;
|
2008-10-31 10:08:51 +00:00
|
|
|
|
|
|
|
if (newnumwalls != -1)
|
|
|
|
{
|
|
|
|
newnumwalls = -1;
|
|
|
|
Bmemcpy(&wall[MAXWALLS-wallsdrawn],&wall[numwalls],sizeof(walltype) * wallsdrawn);
|
|
|
|
}
|
|
|
|
else wallsdrawn = -1;
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
getclosestpointonwall(mousxplc,mousyplc,(int32_t)linehighlight,&dax,&day);
|
2006-04-24 19:04:22 +00:00
|
|
|
adjustmark(&dax,&day,newnumwalls);
|
|
|
|
insertpoint(linehighlight,dax,day);
|
|
|
|
printmessage16("Point inserted.");
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
j = 0;
|
|
|
|
//Check to see if point was inserted over another point
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls-1; i>=0; i--) //delete points
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[i].x == wall[wall[i].point2].x)
|
|
|
|
if (wall[i].y == wall[wall[i].point2].y)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
deletepoint((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
j++;
|
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++) //make new red lines?
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if ((wall[i].x == dax) && (wall[i].y == day))
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)i,sectorofwall((int16_t)i));
|
|
|
|
fixrepeats((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else if ((wall[wall[i].point2].x == dax) && (wall[wall[i].point2].y == day))
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)i,sectorofwall((int16_t)i));
|
|
|
|
fixrepeats((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//if (j != 0)
|
|
|
|
//{
|
|
|
|
// dax = ((wall[linehighlight].x + wall[wall[linehighlight].point2].x)>>1);
|
|
|
|
// day = ((wall[linehighlight].y + wall[wall[linehighlight].point2].y)>>1);
|
|
|
|
// if ((dax != wall[linehighlight].x) || (day != wall[linehighlight].y))
|
|
|
|
// if ((dax != wall[wall[linehighlight].point2].x) || (day != wall[wall[linehighlight].point2].y))
|
|
|
|
// {
|
|
|
|
// insertpoint(linehighlight,dax,day);
|
|
|
|
// printmessage16("Point inserted at midpoint.");
|
|
|
|
// }
|
|
|
|
//}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-10-31 10:08:51 +00:00
|
|
|
if (wallsdrawn != -1)
|
|
|
|
{
|
|
|
|
Bmemcpy(&wall[numwalls],&wall[MAXWALLS-wallsdrawn],sizeof(walltype) * wallsdrawn);
|
|
|
|
newnumwalls = numwalls + wallsdrawn;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
2008-10-31 10:08:51 +00:00
|
|
|
wall[i].point2 = i+1;
|
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
asksave = 1;
|
|
|
|
}
|
2008-08-28 23:15:11 +00:00
|
|
|
keystatus[0xd2] = keystatus[0x17] = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
/*j = 0;
|
|
|
|
for(i=22-1;i>=0;i--) updatecrc16(j,kensig[i]);
|
|
|
|
if ((j&0xffff) != 0xebf)
|
|
|
|
{
|
|
|
|
printf("Don't screw with my name.\n");
|
|
|
|
exit(0);
|
|
|
|
}*/
|
|
|
|
//printext16(9L,336+9L,4,-1,kensig,0);
|
|
|
|
//printext16(8L,336+8L,12,-1,kensig,0);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
showframe(1);
|
|
|
|
synctics = totalclock-lockclock;
|
|
|
|
lockclock += synctics;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_MODE2D_3D]])
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
updatesector(pos.x,pos.y,&cursectnum);
|
2006-04-24 19:04:22 +00:00
|
|
|
if (cursectnum >= 0)
|
2008-05-16 00:23:33 +00:00
|
|
|
keystatus[buildkeys[BK_MODE2D_3D]] = 2;
|
2006-04-24 19:04:22 +00:00
|
|
|
else
|
|
|
|
printmessage16("Arrow must be inside a sector before entering 3D mode.");
|
|
|
|
}
|
2008-05-15 03:16:38 +00:00
|
|
|
|
|
|
|
// vvv PK ------------------------------------ (LShift) Ctrl-X: (prev) next map
|
|
|
|
// this is copied from 'L' (load map), but without copying the highlighted sectors
|
|
|
|
|
|
|
|
if (quickmapcycling && (keystatus[0x2d] > 0)) //X
|
|
|
|
{
|
|
|
|
if ((keystatus[0x1d]|keystatus[0x9d]) > 0) //Ctrl
|
|
|
|
{
|
2008-07-13 07:10:47 +00:00
|
|
|
nextmap:
|
2008-05-15 03:16:38 +00:00
|
|
|
// bad = 0;
|
|
|
|
i = menuselect_pk(keystatus[0x2a]>0 ? 0:1); // Left Shift: prev map
|
|
|
|
if (i < 0)
|
|
|
|
{
|
|
|
|
if (i == -2)
|
|
|
|
printmessage16("No .MAP files found.");
|
|
|
|
else if (i == -3)
|
|
|
|
printmessage16("Load map first!");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Bstrcpy(boardfilename, selectedboardfilename);
|
|
|
|
|
|
|
|
highlightcnt = -1;
|
|
|
|
sectorhighlightstat = -1;
|
|
|
|
newnumwalls = -1;
|
|
|
|
joinsector[0] = -1;
|
|
|
|
circlewall = -1;
|
|
|
|
circlepoints = 7;
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXSECTORS; i++) sector[i].extra = -1;
|
|
|
|
for (i=0; i<MAXWALLS; i++) wall[i].extra = -1;
|
|
|
|
for (i=0; i<MAXSPRITES; i++) sprite[i].extra = -1;
|
2008-05-15 03:16:38 +00:00
|
|
|
|
|
|
|
ExtPreLoadMap();
|
2009-01-13 12:23:18 +00:00
|
|
|
i = loadboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
|
|
|
if (i == -2) i = loadoldboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
|
|
|
oposz = pos.z;
|
2008-05-15 03:16:38 +00:00
|
|
|
if (i < 0)
|
|
|
|
{
|
2008-07-13 07:10:47 +00:00
|
|
|
// printmessage16("Invalid map format.");
|
|
|
|
goto nextmap;
|
2008-05-15 03:16:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ExtLoadMap(boardfilename);
|
|
|
|
|
2008-06-10 02:29:58 +00:00
|
|
|
if (mapversion < 7) printmessage16("Map %s loaded successfully and autoconverted to V7!",boardfilename);
|
|
|
|
else printmessage16("Map %s loaded successfully.",boardfilename);
|
2008-05-15 03:16:38 +00:00
|
|
|
}
|
|
|
|
updatenumsprites();
|
2009-01-13 12:23:18 +00:00
|
|
|
startposx = pos.x; //this is same
|
|
|
|
startposy = pos.y;
|
|
|
|
startposz = pos.z;
|
2008-05-15 03:16:38 +00:00
|
|
|
startang = ang;
|
|
|
|
startsectnum = cursectnum;
|
|
|
|
}
|
|
|
|
showframe(1);
|
|
|
|
keystatus[0x1c] = 0;
|
|
|
|
|
|
|
|
keystatus[0x2d]=keystatus[0x13]=0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ^^^ PK ------------------------------------
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
CANCEL:
|
2009-02-19 16:47:54 +00:00
|
|
|
if (keystatus[1] && joinsector[0] >= 0) {keystatus[1]=0; joinsector[0]=-1;}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[1])
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[1] = 0;
|
2009-05-01 06:35:27 +00:00
|
|
|
_printmessage16("(N)ew, (L)oad, (S)ave, save (A)s, (Q)uit");
|
2008-09-06 06:22:31 +00:00
|
|
|
// printext16(200L+248, ydim-STATUS2DSIZ+20L, 9, 0, "(U)ndo, (R)edo", 0);
|
2006-04-24 19:04:22 +00:00
|
|
|
showframe(1);
|
|
|
|
bflushchars();
|
|
|
|
bad = 1;
|
|
|
|
while (bad == 1)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
|
|
|
{
|
|
|
|
if (quitevent)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
quitevent = 0;
|
|
|
|
}
|
2007-01-12 05:49:09 +00:00
|
|
|
}
|
|
|
|
idle();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
ch = bgetchar();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[1])
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[1] = 0;
|
|
|
|
bad = 0;
|
2009-05-01 06:35:27 +00:00
|
|
|
// printmessage16("");
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else if (ch == 'n' || ch == 'N') //N
|
|
|
|
{
|
|
|
|
bad = 0;
|
2009-05-01 06:35:27 +00:00
|
|
|
_printmessage16("Are you sure you want to start a new board? (Y/N)");
|
2006-04-24 19:04:22 +00:00
|
|
|
showframe(1);
|
|
|
|
bflushchars(); ch = 0;
|
|
|
|
while (keystatus[1] == 0)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
|
|
|
{
|
|
|
|
if (quitevent)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
quitevent = 0;
|
|
|
|
}
|
2007-01-12 05:49:09 +00:00
|
|
|
}
|
|
|
|
idle();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
ch = bgetchar();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (ch == 'Y' || ch == 'y')
|
|
|
|
{
|
|
|
|
highlightsectorcnt = -1;
|
|
|
|
highlightcnt = -1;
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<(MAXWALLS>>3); i++) //Clear all highlights
|
2006-04-24 19:04:22 +00:00
|
|
|
show2dwall[i] = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<(MAXSPRITES>>3); i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
show2dsprite[i] = 0;
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXSECTORS; i++) sector[i].extra = -1;
|
|
|
|
for (i=0; i<MAXWALLS; i++) wall[i].extra = -1;
|
|
|
|
for (i=0; i<MAXSPRITES; i++) sprite[i].extra = -1;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
sectorhighlightstat = -1;
|
|
|
|
newnumwalls = -1;
|
|
|
|
joinsector[0] = -1;
|
|
|
|
circlewall = -1;
|
|
|
|
circlepoints = 7;
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.x = 32768; //new board!
|
|
|
|
pos.y = 32768;
|
|
|
|
pos.z = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
ang = 1536;
|
|
|
|
numsectors = 0;
|
|
|
|
numwalls = 0;
|
|
|
|
numsprites = 0;
|
|
|
|
cursectnum = -1;
|
|
|
|
initspritelists();
|
|
|
|
Bstrcpy(boardfilename,"newboard.map");
|
|
|
|
break;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if (ch == 'N' || ch == 'n' || ch == 13 || ch == ' ')
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-05-01 06:35:27 +00:00
|
|
|
// printmessage16("");
|
2006-04-24 19:04:22 +00:00
|
|
|
showframe(1);
|
|
|
|
}
|
|
|
|
else if (ch == 'l' || ch == 'L') //L
|
|
|
|
{
|
|
|
|
bad = 0;
|
|
|
|
i = menuselect();
|
|
|
|
if (i < 0)
|
|
|
|
{
|
|
|
|
if (i == -2)
|
|
|
|
printmessage16("No .MAP files found.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Bstrcpy(boardfilename, selectedboardfilename);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (highlightsectorcnt >= 0)
|
|
|
|
{
|
|
|
|
j = 0; k = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
j += sector[highlightsector[i]].wallnum;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
m = headspritesect[highlightsector[i]];
|
|
|
|
while (m != -1)
|
|
|
|
{
|
|
|
|
k++;
|
|
|
|
m = nextspritesect[m];
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
updatenumsprites();
|
|
|
|
if ((numsectors+highlightsectorcnt > MAXSECTORS) || (numwalls+j > MAXWALLS) || (numsprites+k > MAXSPRITES))
|
|
|
|
{
|
|
|
|
highlightsectorcnt = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Put sectors&walls to end of lists
|
|
|
|
j = MAXWALLS;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
j -= sector[highlightsector[i]].wallnum;
|
2009-01-09 09:29:17 +00:00
|
|
|
copysector(highlightsector[i],(int16_t)(MAXSECTORS-highlightsectorcnt+i),(int16_t)j,0);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//Put sprites to end of list
|
|
|
|
//DONT USE m BETWEEN HERE AND SPRITE RE-ATTACHING!
|
|
|
|
m = MAXSPRITES;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=MAXSPRITES-1; i>=0; i--)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (sprite[i].statnum < MAXSTATUS)
|
|
|
|
{
|
|
|
|
k = sprite[i].sectnum;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<highlightsectorcnt; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (highlightsector[j] == k)
|
|
|
|
{
|
|
|
|
m--;
|
|
|
|
if (i != m)
|
|
|
|
Bmemcpy(&sprite[m],&sprite[i],sizeof(spritetype));
|
|
|
|
|
|
|
|
//HACK - THESE 2 buffers back up .sectnum and .statnum
|
|
|
|
//for initspritelists() inside the loadboard call
|
|
|
|
//tsprite[m].picnum = MAXSECTORS-highlightsectorcnt+j;
|
|
|
|
//tsprite[m].owner = sprite[i].statnum;
|
|
|
|
|
|
|
|
// JBF: I see your hack and raise you another
|
|
|
|
spriteext[m].mdanimcur = MAXSECTORS-highlightsectorcnt+j;
|
|
|
|
spriteext[m].angoff = sprite[i].statnum;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
highlightcnt = -1;
|
|
|
|
sectorhighlightstat = -1;
|
|
|
|
newnumwalls = -1;
|
|
|
|
joinsector[0] = -1;
|
|
|
|
circlewall = -1;
|
|
|
|
circlepoints = 7;
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXSECTORS; i++) sector[i].extra = -1;
|
|
|
|
for (i=0; i<MAXWALLS; i++) wall[i].extra = -1;
|
|
|
|
for (i=0; i<MAXSPRITES; i++) sprite[i].extra = -1;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
ExtPreLoadMap();
|
2009-01-13 12:23:18 +00:00
|
|
|
i = loadboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
2008-02-02 16:38:30 +00:00
|
|
|
loadmhk();
|
2009-01-13 12:23:18 +00:00
|
|
|
if (i == -2) i = loadoldboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
|
|
|
oposz = pos.z;
|
2006-04-24 19:04:22 +00:00
|
|
|
if (i < 0)
|
|
|
|
{
|
|
|
|
printmessage16("Invalid map format.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ExtLoadMap(boardfilename);
|
|
|
|
|
|
|
|
if (highlightsectorcnt >= 0)
|
|
|
|
{
|
|
|
|
if ((numsectors+highlightsectorcnt > MAXSECTORS) || (sector[MAXSECTORS-highlightsectorcnt].wallptr < numwalls))
|
|
|
|
{
|
|
|
|
highlightsectorcnt = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Re-attach sectors&walls
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
copysector((int16_t)(MAXSECTORS-highlightsectorcnt+i),numsectors,numwalls,0);
|
2006-04-24 19:04:22 +00:00
|
|
|
highlightsector[i] = numsectors;
|
|
|
|
numwalls += sector[numsectors].wallnum;
|
|
|
|
numsectors++;
|
|
|
|
}
|
|
|
|
//Re-attach sprites
|
|
|
|
while (m < MAXSPRITES)
|
|
|
|
{
|
|
|
|
//HACK - THESE 2 buffers back up .sectnum and .statnum
|
|
|
|
//for initspritelists() inside the loadboard call
|
|
|
|
//tsprite[m].picnum = sprite[i].sectnum;
|
|
|
|
//tsprite[m].owner = sprite[i].statnum;
|
|
|
|
|
2008-09-26 17:20:10 +00:00
|
|
|
j = insertsprite(spriteext[m].mdanimcur+(numsectors-MAXSECTORS),spriteext[m].angoff);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bmemcpy(&sprite[j],&sprite[m],sizeof(spritetype));
|
|
|
|
//sprite[j].sectnum = tsprite[m].picnum+(numsectors-MAXSECTORS);
|
|
|
|
//sprite[j].statnum = tsprite[m].owner;
|
|
|
|
|
|
|
|
// JBF: I see your hack and raise you another
|
|
|
|
sprite[j].sectnum = spriteext[m].mdanimcur+(numsectors-MAXSECTORS);
|
|
|
|
sprite[j].statnum = spriteext[m].angoff;
|
|
|
|
spriteext[m].mdanimcur = spriteext[m].angoff = 0;
|
|
|
|
|
|
|
|
m++;
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
checksectorpointer(wall[j].nextwall,wall[j].nextsector);
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)j,highlightsector[i]);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-10 02:29:58 +00:00
|
|
|
if (mapversion < 7) printmessage16("Map %s loaded successfully and autoconverted to V7!",boardfilename);
|
|
|
|
else printmessage16("Map %s loaded successfully.",boardfilename);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
updatenumsprites();
|
2009-01-13 12:23:18 +00:00
|
|
|
startposx = pos.x; //this is same
|
|
|
|
startposy = pos.y;
|
|
|
|
startposz = pos.z;
|
2006-04-24 19:04:22 +00:00
|
|
|
startang = ang;
|
|
|
|
startsectnum = cursectnum;
|
|
|
|
}
|
|
|
|
showframe(1);
|
|
|
|
keystatus[0x1c] = 0;
|
|
|
|
}
|
|
|
|
else if (ch == 'a' || ch == 'A') //A
|
|
|
|
{
|
|
|
|
bad = 0;
|
|
|
|
|
|
|
|
Bstrcpy(selectedboardfilename, boardfilename);
|
|
|
|
if (Bstrrchr(boardfilename, '/'))
|
|
|
|
Bstrcpy(boardfilename, Bstrrchr(boardfilename, '/')+1);
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while ((boardfilename[i] != 0) && (i < 64))
|
|
|
|
i++;
|
|
|
|
if (boardfilename[i-4] == '.')
|
|
|
|
i -= 4;
|
|
|
|
boardfilename[i] = 0;
|
|
|
|
|
|
|
|
bflushchars();
|
|
|
|
while (bad == 0)
|
|
|
|
{
|
2008-06-06 01:06:43 +00:00
|
|
|
Bsprintf(buffer,"Save as: ^011%s", boardfilename);
|
|
|
|
if (totalclock & 32)
|
|
|
|
Bstrcat(buffer,"_");
|
2009-05-01 06:35:27 +00:00
|
|
|
_printmessage16(buffer);
|
2006-04-24 19:04:22 +00:00
|
|
|
showframe(1);
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (quitevent) quitevent = 0;
|
2007-01-12 05:49:09 +00:00
|
|
|
}
|
|
|
|
idle();
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
ch = bgetchar();
|
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[1]) bad = 1;
|
2006-04-24 19:04:22 +00:00
|
|
|
else if (ch == 13) bad = 2;
|
2007-12-12 17:42:14 +00:00
|
|
|
else if (ch > 0)
|
|
|
|
{
|
|
|
|
if (i > 0 && (ch == 8 || ch == 127))
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
i--;
|
|
|
|
boardfilename[i] = 0;
|
|
|
|
}
|
2008-06-09 23:41:54 +00:00
|
|
|
else if (i < 40 && ch > 32 && ch < 128)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
boardfilename[i++] = ch;
|
|
|
|
boardfilename[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bad == 1)
|
|
|
|
{
|
|
|
|
Bstrcpy(boardfilename, selectedboardfilename);
|
|
|
|
keystatus[1] = 0;
|
|
|
|
printmessage16("Operation cancelled");
|
|
|
|
showframe(1);
|
|
|
|
}
|
|
|
|
if (bad == 2)
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
char *f; int32_t res;
|
2006-04-24 19:04:22 +00:00
|
|
|
keystatus[0x1c] = 0;
|
|
|
|
|
|
|
|
boardfilename[i] = '.';
|
|
|
|
boardfilename[i+1] = 'm';
|
|
|
|
boardfilename[i+2] = 'a';
|
|
|
|
boardfilename[i+3] = 'p';
|
|
|
|
boardfilename[i+4] = 0;
|
|
|
|
|
|
|
|
if (Bstrrchr(selectedboardfilename,'/'))
|
|
|
|
Bstrcpy(Bstrrchr(selectedboardfilename, '/')+1, boardfilename);
|
|
|
|
else
|
|
|
|
Bstrcpy(selectedboardfilename, boardfilename);
|
|
|
|
if (pathsearchmode) f = selectedboardfilename;
|
2007-12-12 17:42:14 +00:00
|
|
|
else
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
// virtual filesystem mode can't save to directories so drop the file into
|
|
|
|
// the current directory
|
|
|
|
f = strrchr(selectedboardfilename, '/');
|
|
|
|
if (!f) f = selectedboardfilename; else f++;
|
|
|
|
}
|
|
|
|
Bsprintf(buffer,"Saving to %s...",f);
|
2009-05-01 06:35:27 +00:00
|
|
|
_printmessage16(buffer);
|
2006-04-24 19:04:22 +00:00
|
|
|
showframe(1);
|
|
|
|
|
|
|
|
fixspritesectors(); //Do this before saving!
|
|
|
|
updatesector(startposx,startposy,&startsectnum);
|
|
|
|
ExtPreSaveMap();
|
2008-02-01 03:36:54 +00:00
|
|
|
res=saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
|
2006-04-24 19:04:22 +00:00
|
|
|
ExtSaveMap(f);
|
2008-02-01 03:36:54 +00:00
|
|
|
printmessage16((res==0)?"Board saved.":"Saving board failed.");
|
2006-04-24 19:04:22 +00:00
|
|
|
Bstrcpy(boardfilename, selectedboardfilename);
|
|
|
|
}
|
|
|
|
bad = 0;
|
|
|
|
}
|
|
|
|
else if (ch == 's' || ch == 'S') //S
|
|
|
|
{
|
2008-09-12 02:07:44 +00:00
|
|
|
char *f;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t res;
|
2006-04-24 19:04:22 +00:00
|
|
|
bad = 0;
|
2009-05-01 06:35:27 +00:00
|
|
|
_printmessage16("Saving board...");
|
2006-04-24 19:04:22 +00:00
|
|
|
showframe(1);
|
|
|
|
fixspritesectors(); //Do this before saving!
|
|
|
|
updatesector(startposx,startposy,&startsectnum);
|
|
|
|
if (pathsearchmode) f = boardfilename;
|
2007-12-12 17:42:14 +00:00
|
|
|
else
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
// virtual filesystem mode can't save to directories so drop the file into
|
|
|
|
// the current directory
|
|
|
|
f = strrchr(boardfilename, '/');
|
|
|
|
if (!f) f = boardfilename; else f++;
|
|
|
|
}
|
|
|
|
ExtPreSaveMap();
|
2008-02-01 03:36:54 +00:00
|
|
|
res=saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
|
2006-04-24 19:04:22 +00:00
|
|
|
ExtSaveMap(f);
|
2008-02-01 03:36:54 +00:00
|
|
|
printmessage16((res==0)?"Board saved.":"Saving board failed.");
|
2006-04-24 19:04:22 +00:00
|
|
|
showframe(1);
|
|
|
|
}
|
|
|
|
else if (ch == 'q' || ch == 'Q') //Q
|
|
|
|
{
|
|
|
|
bad = 0;
|
2009-05-01 06:35:27 +00:00
|
|
|
_printmessage16("Are you sure you want to quit?");
|
2006-04-24 19:04:22 +00:00
|
|
|
showframe(1);
|
|
|
|
bflushchars();
|
2006-04-13 20:47:06 +00:00
|
|
|
while ((keystatus[1]|keystatus[0x2e]) == 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (quitevent) quitevent = 0;
|
2007-01-12 05:49:09 +00:00
|
|
|
}
|
|
|
|
idle();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
ch = bgetchar();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (ch == 'y' || ch == 'Y')
|
|
|
|
{
|
|
|
|
//QUIT!
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
_printmessage16("Save changes?");
|
2006-04-24 19:04:22 +00:00
|
|
|
showframe(1);
|
2006-04-13 20:47:06 +00:00
|
|
|
while ((keystatus[1]|keystatus[0x2e]) == 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (quitevent) break; // like saying no
|
2007-01-12 05:49:09 +00:00
|
|
|
}
|
|
|
|
idle();
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
ch = bgetchar();
|
|
|
|
|
|
|
|
if (ch == 'y' || ch == 'Y')
|
|
|
|
{
|
|
|
|
char *f;
|
|
|
|
fixspritesectors(); //Do this before saving!
|
|
|
|
updatesector(startposx,startposy,&startsectnum);
|
|
|
|
ExtPreSaveMap();
|
|
|
|
if (pathsearchmode) f = boardfilename;
|
2007-12-12 17:42:14 +00:00
|
|
|
else
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
// virtual filesystem mode can't save to directories so drop the file into
|
|
|
|
// the current directory
|
|
|
|
f = strrchr(boardfilename, '/');
|
|
|
|
if (!f) f = boardfilename; else f++;
|
|
|
|
}
|
|
|
|
saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
|
|
|
|
ExtSaveMap(f);
|
|
|
|
break;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ')
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
while (keystatus[1] || keystatus[0x2e])
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
keystatus[1] = 0;
|
|
|
|
keystatus[0x2e] = 0;
|
|
|
|
quitevent = 0;
|
|
|
|
printmessage16("Operation cancelled");
|
|
|
|
showframe(1);
|
|
|
|
goto CANCEL;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
clearfilenames();
|
|
|
|
uninittimer();
|
|
|
|
uninitinput();
|
|
|
|
ExtUnInit();
|
|
|
|
uninitengine();
|
|
|
|
exit(0);
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ')
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-05-01 06:35:27 +00:00
|
|
|
// printmessage16("");
|
2006-04-24 19:04:22 +00:00
|
|
|
showframe(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
clearkeys();
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//nextpage();
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<=endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
checksectorpointer(wall[j].nextwall,wall[j].nextsector);
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)j,highlightsector[i]);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
fixspritesectors();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (setgamemode(fullscreen,xdimgame,ydimgame,bppgame) < 0)
|
|
|
|
{
|
|
|
|
ExtUnInit();
|
|
|
|
uninitinput();
|
|
|
|
uninittimer();
|
2008-02-21 05:11:41 +00:00
|
|
|
initprintf("%d * %d not supported in this graphics mode\n",xdim,ydim);
|
2006-04-24 19:04:22 +00:00
|
|
|
uninitsystem();
|
|
|
|
clearfilenames();
|
|
|
|
exit(0);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-19 07:31:03 +00:00
|
|
|
setbrightness(brightness,palette,0);
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.z = oposz;
|
2006-04-24 19:04:22 +00:00
|
|
|
searchx = scale(searchx,xdimgame,xdim2d);
|
|
|
|
searchy = scale(searchy,ydimgame,ydim2d-STATUS2DSIZ);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void getpoint(int32_t searchxe, int32_t searchye, int32_t *x, int32_t *y)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
if (pos.x <= -editorgridextent) pos.x = -editorgridextent;
|
|
|
|
if (pos.x >= editorgridextent) pos.x = editorgridextent;
|
|
|
|
if (pos.y <= -editorgridextent) pos.y = -editorgridextent;
|
|
|
|
if (pos.y >= editorgridextent) pos.y = editorgridextent;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
*x = pos.x + divscale14(searchxe-halfxdim16,zoom);
|
|
|
|
*y = pos.y + divscale14(searchye-midydim16,zoom);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if (*x <= -editorgridextent) *x = -editorgridextent;
|
|
|
|
if (*x >= editorgridextent) *x = editorgridextent;
|
|
|
|
if (*y <= -editorgridextent) *y = -editorgridextent;
|
|
|
|
if (*y >= editorgridextent) *y = editorgridextent;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, dst, dist, closest, x1, y1, x2, y2, nx, ny;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (numwalls == 0)
|
|
|
|
return(-1);
|
2008-09-02 02:45:06 +00:00
|
|
|
|
|
|
|
if (mouseb & 1) return line;
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
dist = 1024;
|
2008-05-16 19:51:38 +00:00
|
|
|
closest = -1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
getclosestpointonwall(xplc,yplc,i,&nx,&ny);
|
|
|
|
dst = klabs(xplc-nx)+klabs(yplc-ny);
|
|
|
|
if (dst <= dist)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
dist = dst;
|
|
|
|
closest = i;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-05-16 19:51:38 +00:00
|
|
|
if (closest>=0 && wall[closest].nextwall >= 0)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
//if red line, allow highlighting of both sides
|
2006-04-24 19:04:22 +00:00
|
|
|
x1 = wall[closest].x;
|
|
|
|
y1 = wall[closest].y;
|
|
|
|
x2 = wall[wall[closest].point2].x;
|
|
|
|
y2 = wall[wall[closest].point2].y;
|
|
|
|
if (dmulscale32(xplc-x1,y2-y1,-(x2-x1),yplc-y1) >= 0)
|
|
|
|
closest = wall[closest].nextwall;
|
|
|
|
}
|
|
|
|
if ((pointhighlight&0xc000) == 16384) return (-1);
|
2006-12-15 01:09:25 +00:00
|
|
|
return(closest);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t getpointhighlight(int32_t xplc, int32_t yplc, int32_t point)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, dst, dist = 512, closest = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (numwalls == 0)
|
|
|
|
return(-1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-09-02 02:45:06 +00:00
|
|
|
if (mouseb & 1) return point;
|
|
|
|
|
2007-09-11 02:23:08 +00:00
|
|
|
if (grid < 1)
|
|
|
|
dist = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
dst = klabs(xplc-wall[i].x) + klabs(yplc-wall[i].y);
|
|
|
|
if (dst <= dist)
|
|
|
|
dist = dst, closest = i;
|
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
if (zoom >= 256)
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXSPRITES; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (sprite[i].statnum < MAXSTATUS)
|
|
|
|
{
|
|
|
|
dst = klabs(xplc-sprite[i].x) + klabs(yplc-sprite[i].y);
|
2008-10-09 21:09:16 +00:00
|
|
|
// was (dst <= dist), but this way, when duplicating sprites,
|
|
|
|
// the selected ones are dragged first
|
2009-04-26 20:51:00 +00:00
|
|
|
if (dst < dist || (dst == dist && (show2dsprite[i>>3]&(1<<(i&7)))))
|
2006-04-24 19:04:22 +00:00
|
|
|
dist = dst, closest = i+16384;
|
|
|
|
}
|
|
|
|
return(closest);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t adjustmark(int32_t *xplc, int32_t *yplc, int16_t danumwalls)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, dst, dist, dax, day, pointlockdist;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (danumwalls < 0)
|
|
|
|
danumwalls = numwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
pointlockdist = 0;
|
|
|
|
if ((grid > 0) && (gridlock > 0))
|
|
|
|
pointlockdist = (128>>grid);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
dist = pointlockdist;
|
|
|
|
dax = *xplc;
|
|
|
|
day = *yplc;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<danumwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
dst = klabs((*xplc)-wall[i].x) + klabs((*yplc)-wall[i].y);
|
|
|
|
if (dst < dist)
|
|
|
|
{
|
|
|
|
dist = dst;
|
|
|
|
dax = wall[i].x;
|
|
|
|
day = wall[i].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dist == pointlockdist)
|
|
|
|
if ((gridlock > 0) && (grid > 0))
|
|
|
|
{
|
|
|
|
dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
day = ((day+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
*xplc = dax;
|
|
|
|
*yplc = day;
|
|
|
|
return(0);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t checkautoinsert(int32_t dax, int32_t day, int16_t danumwalls)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, x1, y1, x2, y2;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (danumwalls < 0)
|
|
|
|
danumwalls = numwalls;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<danumwalls; i++) // Check if a point should be inserted
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
x1 = wall[i].x;
|
|
|
|
y1 = wall[i].y;
|
|
|
|
x2 = wall[wall[i].point2].x;
|
|
|
|
y2 = wall[wall[i].point2].y;
|
|
|
|
|
|
|
|
if ((x1 != dax) || (y1 != day))
|
|
|
|
if ((x2 != dax) || (y2 != day))
|
|
|
|
if (((x1 <= dax) && (dax <= x2)) || ((x2 <= dax) && (dax <= x1)))
|
|
|
|
if (((y1 <= day) && (day <= y2)) || ((y2 <= day) && (day <= y1)))
|
|
|
|
if ((dax-x1)*(y2-y1) == (day-y1)*(x2-x1))
|
|
|
|
return(1); //insertpoint((short)i,dax,day);
|
|
|
|
}
|
|
|
|
return(0);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t clockdir(int16_t wallstart) //Returns: 0 is CW, 1 is CCW
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t i, themin;
|
|
|
|
int32_t minx, tempint, x0, x1, x2, y0, y1, y2;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
minx = 0x7fffffff;
|
|
|
|
themin = -1;
|
|
|
|
i = wallstart-1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
if (wall[wall[i].point2].x < minx)
|
|
|
|
{
|
|
|
|
minx = wall[wall[i].point2].x;
|
|
|
|
themin = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while ((wall[i].point2 != wallstart) && (i < MAXWALLS));
|
|
|
|
|
|
|
|
x0 = wall[themin].x;
|
|
|
|
y0 = wall[themin].y;
|
|
|
|
x1 = wall[wall[themin].point2].x;
|
|
|
|
y1 = wall[wall[themin].point2].y;
|
|
|
|
x2 = wall[wall[wall[themin].point2].point2].x;
|
|
|
|
y2 = wall[wall[wall[themin].point2].point2].y;
|
|
|
|
|
|
|
|
if ((y1 >= y2) && (y1 <= y0)) return(0);
|
|
|
|
if ((y1 >= y0) && (y1 <= y2)) return(1);
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint = (x0-x1)*(y2-y1) - (x2-x1)*(y0-y1);
|
|
|
|
if (tempint < 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
return(0);
|
|
|
|
else
|
|
|
|
return(1);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void flipwalls(int16_t numwalls, int16_t newnumwalls)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j, nume, tempint;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
nume = newnumwalls-numwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<numwalls+(nume>>1); i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
j = numwalls+newnumwalls-i-1;
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint = wall[i].x; wall[i].x = wall[j].x; wall[j].x = tempint;
|
|
|
|
tempint = wall[i].y; wall[i].y = wall[j].y; wall[j].y = tempint;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void insertpoint(int16_t linehighlight, int32_t dax, int32_t day)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t sucksect;
|
|
|
|
int32_t i, j, k;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
j = linehighlight;
|
2009-01-09 09:29:17 +00:00
|
|
|
sucksect = sectorofwall((int16_t)j);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[sucksect].wallnum++;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=sucksect+1; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[i].wallptr++;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
movewalls((int32_t)j+1,+1L);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bmemcpy(&wall[j+1],&wall[j],sizeof(walltype));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[j].point2 = j+1;
|
|
|
|
wall[j+1].x = dax;
|
|
|
|
wall[j+1].y = day;
|
2009-01-09 09:29:17 +00:00
|
|
|
fixrepeats((int16_t)j);
|
|
|
|
fixrepeats((int16_t)j+1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
{
|
|
|
|
k = wall[j].nextwall;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
sucksect = sectorofwall((int16_t)k);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[sucksect].wallnum++;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=sucksect+1; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[i].wallptr++;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
movewalls((int32_t)k+1,+1L);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bmemcpy(&wall[k+1],&wall[k],sizeof(walltype));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[k].point2 = k+1;
|
|
|
|
wall[k+1].x = dax;
|
|
|
|
wall[k+1].y = day;
|
2009-01-09 09:29:17 +00:00
|
|
|
fixrepeats((int16_t)k);
|
|
|
|
fixrepeats((int16_t)k+1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
j = wall[k].nextwall;
|
|
|
|
wall[j].nextwall = k+1;
|
|
|
|
wall[j+1].nextwall = k;
|
|
|
|
wall[k].nextwall = j+1;
|
|
|
|
wall[k+1].nextwall = j;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void deletepoint(int16_t point)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j, k, sucksect;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
sucksect = sectorofwall(point);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[sucksect].wallnum--;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=sucksect+1; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[i].wallptr--;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
j = lastwall(point);
|
|
|
|
k = wall[point].point2;
|
|
|
|
wall[j].point2 = k;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
{
|
|
|
|
wall[wall[j].nextwall].nextwall = -1;
|
|
|
|
wall[wall[j].nextwall].nextsector = -1;
|
|
|
|
}
|
|
|
|
if (wall[point].nextwall >= 0)
|
|
|
|
{
|
|
|
|
wall[wall[point].nextwall].nextwall = -1;
|
|
|
|
wall[wall[point].nextwall].nextsector = -1;
|
|
|
|
}
|
2009-01-09 09:29:17 +00:00
|
|
|
movewalls((int32_t)point,-1L);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
checksectorpointer((int16_t)j,(int16_t)sucksect);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t deletesector(int16_t sucksect)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j, k, nextk, startwall, endwall;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
while (headspritesect[sucksect] >= 0)
|
|
|
|
deletesprite(headspritesect[sucksect]);
|
|
|
|
updatenumsprites();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
startwall = sector[sucksect].wallptr;
|
|
|
|
endwall = startwall + sector[sucksect].wallnum - 1;
|
|
|
|
j = sector[sucksect].wallnum;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=sucksect; i<numsectors-1; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
k = headspritesect[i+1];
|
|
|
|
while (k != -1)
|
|
|
|
{
|
|
|
|
nextk = nextspritesect[k];
|
2009-01-09 09:29:17 +00:00
|
|
|
changespritesect((int16_t)k,(int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
k = nextk;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
Bmemcpy(§or[i],§or[i+1],sizeof(sectortype));
|
|
|
|
sector[i].wallptr -= j;
|
|
|
|
}
|
|
|
|
numsectors--;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
j = endwall-startwall+1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=startwall; i<=endwall; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[i].nextwall != -1)
|
|
|
|
{
|
|
|
|
wall[wall[i].nextwall].nextwall = -1;
|
|
|
|
wall[wall[i].nextwall].nextsector = -1;
|
|
|
|
}
|
|
|
|
movewalls(startwall,-j);
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[i].nextwall >= startwall)
|
|
|
|
wall[i].nextsector--;
|
|
|
|
return(0);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void fixspritesectors(void)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j, dax, day, daz;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numsectors-1; i>=0; i--)
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((sector[i].wallnum <= 0) || (sector[i].wallptr >= numwalls))
|
2009-01-09 09:29:17 +00:00
|
|
|
deletesector((int16_t)i);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXSPRITES; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (sprite[i].statnum < MAXSTATUS)
|
|
|
|
{
|
|
|
|
dax = sprite[i].x;
|
|
|
|
day = sprite[i].y;
|
|
|
|
if (inside(dax,day,sprite[i].sectnum) != 1)
|
|
|
|
{
|
|
|
|
daz = ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2);
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<numsectors; j++)
|
2009-01-09 09:29:17 +00:00
|
|
|
if (inside(dax,day,(int16_t)j) == 1)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (sprite[i].z >= getceilzofslope(j,dax,day))
|
|
|
|
if (sprite[i].z-daz <= getflorzofslope(j,dax,day))
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
changespritesect((int16_t)i,(int16_t)j);
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t movewalls(int32_t start, int32_t offs)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (offs < 0) //Delete
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=start; i<numwalls+offs; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
Bmemcpy(&wall[i],&wall[i-offs],sizeof(walltype));
|
|
|
|
}
|
|
|
|
else if (offs > 0) //Insert
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls+offs-1; i>=start+offs; i--)
|
2006-04-24 19:04:22 +00:00
|
|
|
Bmemcpy(&wall[i],&wall[i-offs],sizeof(walltype));
|
|
|
|
}
|
|
|
|
numwalls += offs;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[i].nextwall >= start) wall[i].nextwall += offs;
|
|
|
|
if (wall[i].point2 >= start) wall[i].point2 += offs;
|
|
|
|
}
|
|
|
|
return(0);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t checksectorpointer(int16_t i, int16_t sectnum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t j, k, startwall, endwall, x1, y1, x2, y2;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
x1 = wall[i].x;
|
|
|
|
y1 = wall[i].y;
|
|
|
|
x2 = wall[wall[i].point2].x;
|
|
|
|
y2 = wall[wall[i].point2].y;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[i].nextwall >= 0) //Check for early exit
|
|
|
|
{
|
|
|
|
k = wall[i].nextwall;
|
|
|
|
if ((wall[k].x == x2) && (wall[k].y == y2))
|
|
|
|
if ((wall[wall[k].point2].x == x1) && (wall[wall[k].point2].y == y1))
|
|
|
|
return(0);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[i].nextsector = -1;
|
|
|
|
wall[i].nextwall = -1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<numsectors; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
startwall = sector[j].wallptr;
|
|
|
|
endwall = startwall + sector[j].wallnum - 1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=startwall; k<=endwall; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if ((wall[k].x == x2) && (wall[k].y == y2))
|
|
|
|
if ((wall[wall[k].point2].x == x1) && (wall[wall[k].point2].y == y1))
|
|
|
|
if (j != sectnum)
|
|
|
|
{
|
|
|
|
wall[i].nextsector = j;
|
|
|
|
wall[i].nextwall = k;
|
|
|
|
wall[k].nextsector = sectnum;
|
|
|
|
wall[k].nextwall = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(0);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void fixrepeats(int16_t i)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t dax, day, dist;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
dax = wall[wall[i].point2].x-wall[i].x;
|
|
|
|
day = wall[wall[i].point2].y-wall[i].y;
|
|
|
|
dist = ksqrt(dax*dax+day*day);
|
|
|
|
dax = wall[i].xrepeat; day = wall[i].yrepeat;
|
2009-01-09 09:29:17 +00:00
|
|
|
wall[i].xrepeat = (uint8_t)min(max(mulscale10(dist,day),1),255);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-09-03 04:20:46 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t overridepm16y = -1;
|
2008-09-03 04:20:46 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
void clearmidstatbar16(void)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
begindrawing();
|
|
|
|
ydim16 = ydim;
|
|
|
|
// clearbuf((char *)(frameplace + (bytesperline*(ydim-STATUS2DSIZ+25L))),(bytesperline*(STATUS2DSIZ-1-(25<<1))) >> 2, 0x08080808l);
|
2008-09-03 04:20:46 +00:00
|
|
|
if (overridepm16y < 0)
|
2008-09-03 14:02:42 +00:00
|
|
|
clearbuf((char *)(frameplace + (bytesperline*(ydim-STATUS2DSIZ+25L))),(bytesperline*(STATUS2DSIZ+2-(25<<1))) >> 2, 0x00000000l);
|
|
|
|
else
|
|
|
|
clearbuf((char *)(frameplace + (bytesperline*(ydim-overridepm16y+25L))),(bytesperline*(overridepm16y+2-(25<<1))) >> 2, 0x00000000l);
|
2009-05-01 06:35:27 +00:00
|
|
|
/*
|
|
|
|
drawline16(0,ydim-STATUS2DSIZ,0,ydim-1,editorcolors[7]);
|
|
|
|
drawline16(xdim-1,ydim-STATUS2DSIZ,xdim-1,ydim-1,editorcolors[7]);
|
|
|
|
*/
|
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2006-04-24 19:04:22 +00:00
|
|
|
enddrawing();
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-05-01 19:28:57 +00:00
|
|
|
void clearministatbar16(void)
|
|
|
|
{
|
|
|
|
int32_t i, col = whitecol - 16;
|
|
|
|
begindrawing();
|
|
|
|
|
|
|
|
for (i=ydim-STATUS2DSIZ2; i<ydim; i++)
|
|
|
|
{
|
|
|
|
// drawline256(0, i<<12, xdim<<12, i<<12, col);
|
|
|
|
clearbufbyte((char *)(frameplace + (i*bytesperline)), (bytesperline), ((int32_t)col<<24)|((int32_t)col<<16)|((int32_t)col<<8)|col);
|
|
|
|
col--;
|
|
|
|
if (col <= 0) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
clearbufbyte((char *)(frameplace + (i*bytesperline)), (ydim-i)*(bytesperline), 0);
|
|
|
|
|
|
|
|
Bsprintf(tempbuf, "Mapster32" VERSION);
|
|
|
|
printext16(xdim2d-(Bstrlen(tempbuf)<<3)-3,ydim2d-STATUS2DSIZ2+10L,editorcolors[4],-1,tempbuf,0);
|
|
|
|
printext16(xdim2d-(Bstrlen(tempbuf)<<3)-2,ydim2d-STATUS2DSIZ2+9L,editorcolors[12],-1,tempbuf,0);
|
|
|
|
|
|
|
|
enddrawing();
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t loopinside(int32_t x, int32_t y, int16_t startwall)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t x1, y1, x2, y2, tempint;
|
|
|
|
int16_t i, cnt;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
cnt = clockdir(startwall);
|
|
|
|
i = startwall;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
x1 = wall[i].x; x2 = wall[wall[i].point2].x;
|
|
|
|
if ((x1 >= x) || (x2 >= x))
|
|
|
|
{
|
|
|
|
y1 = wall[i].y; y2 = wall[wall[i].point2].y;
|
|
|
|
if (y1 > y2)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint = x1, x1 = x2, x2 = tempint;
|
|
|
|
tempint = y1, y1 = y2, y2 = tempint;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
if ((y1 <= y) && (y2 > y))
|
|
|
|
if (x1*(y-y2)+x2*(y1-y) <= x*(y1-y2))
|
|
|
|
cnt ^= 1;
|
|
|
|
}
|
|
|
|
i = wall[i].point2;
|
|
|
|
}
|
|
|
|
while (i != startwall);
|
|
|
|
return(cnt);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t numloopsofsector(int16_t sectnum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, numloops, startwall, endwall;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
numloops = 0;
|
|
|
|
startwall = sector[sectnum].wallptr;
|
|
|
|
endwall = startwall + sector[sectnum].wallnum;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=startwall; i<endwall; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[i].point2 < i) numloops++;
|
|
|
|
return(numloops);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t _getnumber16(char *namestart, int32_t num, int32_t maxnumber, char sign, void *(func)(int32_t))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
char buffer[80], ch;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t n, danum, oldnum;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
danum = (int32_t)num;
|
2006-04-24 19:04:22 +00:00
|
|
|
oldnum = danum;
|
|
|
|
bflushchars();
|
|
|
|
while (keystatus[0x1] == 0)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (quitevent) quitevent = 0;
|
2007-01-12 05:49:09 +00:00
|
|
|
}
|
|
|
|
idle();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
ch = bgetchar();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-09-06 06:22:31 +00:00
|
|
|
Bsprintf(buffer,"%s^011%d",namestart,danum);
|
2009-05-01 06:35:27 +00:00
|
|
|
n = Bstrlen(buffer);
|
2008-06-05 10:10:26 +00:00
|
|
|
if (totalclock & 32) Bstrcat(buffer,"_ ");
|
2009-05-01 06:35:27 +00:00
|
|
|
_printmessage16(buffer);
|
|
|
|
|
2008-09-06 06:22:31 +00:00
|
|
|
if (func != NULL)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
Bsprintf(buffer,"^011%s",(char *)func((int32_t)danum));
|
2009-05-01 06:35:27 +00:00
|
|
|
// printext16(200L-24, ydim-STATUS2DSIZ+20L, editorcolors[9], editorcolors[0], buffer, 0);
|
2009-05-01 19:28:57 +00:00
|
|
|
printext16(n<<3, ydim-STATUS2DSIZ+128, editorcolors[9], -1, buffer,0);
|
2008-09-06 06:22:31 +00:00
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
showframe(1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (ch >= '0' && ch <= '9')
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (danum >= 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
n = (danum*10)+(ch-'0');
|
2006-04-13 20:47:06 +00:00
|
|
|
if (n <= maxnumber) danum = n;
|
|
|
|
}
|
|
|
|
else if (sign) // this extra check isn't hurting anything
|
|
|
|
{
|
|
|
|
n = (danum*10)-(ch-'0');
|
|
|
|
if (n >= -maxnumber) danum = n;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if (ch == 8 || ch == 127) // backspace
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
danum /= 10;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if (ch == 13)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
oldnum = danum;
|
|
|
|
asksave = 1;
|
2009-05-01 06:35:27 +00:00
|
|
|
printmessage16(buffer);
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if (ch == '-' && sign) // negate
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
danum = -danum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
clearkeys();
|
2006-04-13 20:47:06 +00:00
|
|
|
return(oldnum);
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t _getnumber256(char *namestart, int32_t num, int32_t maxnumber, char sign, void *(func)(int32_t))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
char buffer[80], ch;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t n, danum, oldnum;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
danum = num;
|
2006-04-24 19:04:22 +00:00
|
|
|
oldnum = danum;
|
|
|
|
bflushchars();
|
|
|
|
while (keystatus[0x1] == 0)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (quitevent) quitevent = 0;
|
2006-12-11 22:23:56 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum);
|
2006-04-13 20:47:06 +00:00
|
|
|
#ifdef SUPERBUILD
|
2006-04-24 19:04:22 +00:00
|
|
|
ExtAnalyzeSprites();
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
drawmasks();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
ch = bgetchar();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-08-28 15:04:16 +00:00
|
|
|
if (keystatus[0x1]) break;
|
|
|
|
|
|
|
|
clearkeys();
|
|
|
|
|
2008-09-03 14:02:42 +00:00
|
|
|
mouseb = 0;
|
|
|
|
searchx = osearchx;
|
|
|
|
searchy = osearchy;
|
|
|
|
|
2008-08-28 15:04:16 +00:00
|
|
|
ExtCheckKeys();
|
|
|
|
|
2008-09-06 06:22:31 +00:00
|
|
|
Bsprintf(buffer,"%s%d",namestart,danum);
|
2008-06-06 01:06:43 +00:00
|
|
|
if (totalclock & 32) Bstrcat(buffer,"_ ");
|
2008-09-03 14:02:42 +00:00
|
|
|
printmessage256(0, 0, buffer);
|
2008-09-06 06:22:31 +00:00
|
|
|
if (func != NULL)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
Bsprintf(buffer,"%s",(char *)func((int32_t)danum));
|
2008-09-06 06:22:31 +00:00
|
|
|
printmessage256(0, 9, buffer);
|
|
|
|
}
|
2008-10-20 04:00:00 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
showframe(1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (ch >= '0' && ch <= '9')
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (danum >= 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
n = (danum*10)+(ch-'0');
|
2006-04-13 20:47:06 +00:00
|
|
|
if (n <= maxnumber) danum = n;
|
|
|
|
}
|
|
|
|
else if (sign)
|
|
|
|
{
|
|
|
|
n = (danum*10)-(ch-'0');
|
|
|
|
if (n >= -maxnumber) danum = n;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if (ch == 8 || ch == 127) // backspace
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
danum /= 10;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if (ch == 13)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
oldnum = danum;
|
|
|
|
asksave = 1;
|
|
|
|
break;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if (ch == '-' && sign) // negate
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
danum = -danum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
clearkeys();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
lockclock = totalclock; //Reset timing
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
return(oldnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
void clearfilenames(void)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
klistfree(finddirs);
|
|
|
|
klistfree(findfiles);
|
|
|
|
finddirs = findfiles = NULL;
|
|
|
|
numfiles = numdirs = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t getfilenames(char *path, char *kind)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
CACHE1D_FIND_REC *r;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
clearfilenames();
|
|
|
|
finddirs = klistpath(path,"*",CACHE1D_FIND_DIR|CACHE1D_FIND_DRIVE|(!pathsearchmode&&grponlymode?CACHE1D_OPT_NOSTACK:0));
|
|
|
|
findfiles = klistpath(path,kind,CACHE1D_FIND_FILE|(!pathsearchmode&&grponlymode?CACHE1D_OPT_NOSTACK:0));
|
|
|
|
for (r = finddirs; r; r=r->next) numdirs++;
|
|
|
|
for (r = findfiles; r; r=r->next) numfiles++;
|
|
|
|
|
|
|
|
finddirshigh = finddirs;
|
|
|
|
findfileshigh = findfiles;
|
|
|
|
currentlist = 0;
|
|
|
|
if (findfileshigh) currentlist = 1;
|
|
|
|
|
|
|
|
return(0);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-05-15 03:16:38 +00:00
|
|
|
// vvv PK ------------------------------------
|
|
|
|
// copied off menuselect
|
|
|
|
|
|
|
|
const char *g_oldpath=NULL;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t menuselect_pk(int32_t direction) // 20080104: jump to next (direction!=0) or prev (direction==0) file
|
2008-05-15 03:16:38 +00:00
|
|
|
{
|
|
|
|
const char *chptr;
|
|
|
|
|
|
|
|
if (!g_oldpath) return -3;
|
|
|
|
else Bmemcpy(selectedboardfilename, g_oldpath, BMAX_PATH);
|
|
|
|
|
|
|
|
if (pathsearchmode)
|
|
|
|
Bcanonicalisefilename(selectedboardfilename, 1); // clips off the last token and compresses relative path
|
|
|
|
else
|
|
|
|
Bcorrectfilename(selectedboardfilename, 1);
|
|
|
|
|
|
|
|
getfilenames(selectedboardfilename, "*.map");
|
|
|
|
|
|
|
|
chptr = strrchr(boardfilename,'/'); // PK
|
|
|
|
if (!chptr) chptr=boardfilename; else chptr++;
|
|
|
|
for (; findfileshigh; findfileshigh=findfileshigh->next)
|
|
|
|
{
|
|
|
|
if (!Bstrcmp(findfileshigh->name,chptr)) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!findfileshigh) findfileshigh=findfiles;
|
|
|
|
|
|
|
|
if (direction)
|
|
|
|
{
|
|
|
|
if (findfileshigh->next) findfileshigh=findfileshigh->next;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (findfileshigh->prev) findfileshigh=findfileshigh->prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bstrcat(selectedboardfilename, findfileshigh->name);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
// ^^^ PK ------------------------------------
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t menuselect(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t listsize = (ydim16-32)/8;
|
|
|
|
int32_t i;
|
2008-08-09 05:13:13 +00:00
|
|
|
char ch, buffer[96], /*PK*/ *chptr;
|
2006-04-24 19:04:22 +00:00
|
|
|
static char oldpath[BMAX_PATH];
|
|
|
|
CACHE1D_FIND_REC *dir;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t bakpathsearchmode = pathsearchmode;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-05-15 03:16:38 +00:00
|
|
|
g_oldpath=oldpath; //PK: need it in menuselect_pk
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
Bstrcpy(selectedboardfilename, oldpath);
|
|
|
|
if (pathsearchmode)
|
|
|
|
Bcanonicalisefilename(selectedboardfilename, 1); // clips off the last token and compresses relative path
|
|
|
|
else
|
|
|
|
Bcorrectfilename(selectedboardfilename, 1);
|
|
|
|
|
|
|
|
getfilenames(selectedboardfilename, "*.map");
|
|
|
|
|
2008-05-15 03:16:38 +00:00
|
|
|
// PK 20080103: start with last selected map
|
|
|
|
chptr = strrchr(boardfilename,'/');
|
|
|
|
if (!chptr) chptr=boardfilename; else chptr++;
|
|
|
|
for (; findfileshigh; findfileshigh=findfileshigh->next)
|
|
|
|
{
|
|
|
|
if (!Bstrcmp(findfileshigh->name,chptr)) break;
|
|
|
|
}
|
|
|
|
if (!findfileshigh) findfileshigh=findfiles;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
begindrawing();
|
2009-05-01 06:35:27 +00:00
|
|
|
_printmessage16("Select map file with arrow keys and enter.");
|
2006-04-24 19:04:22 +00:00
|
|
|
enddrawing();
|
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
do
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
begindrawing();
|
|
|
|
clearbuf((char *)frameplace, (bytesperline*ydim16) >> 2, 0l);
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (pathsearchmode)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
strcpy(buffer,"Local filesystem mode; press F for game filesystem.");
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-02 01:49:14 +00:00
|
|
|
Bsprintf(buffer,"Game filesystem %smode; press F for local filesystem or G for %s.",
|
2009-02-19 16:47:54 +00:00
|
|
|
grponlymode?"GRP-only ":"", grponlymode?"all files":"GRP contents only");
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2008-12-23 23:27:53 +00:00
|
|
|
printext16(halfxdim16-(8*strlen(buffer)/2), 4, editorcolors[12],editorcolors[0],buffer,0);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-08-09 05:13:13 +00:00
|
|
|
Bsnprintf(buffer,sizeof(buffer)-1,"(%d dirs, %d files) %s",numdirs,numfiles,selectedboardfilename);
|
2006-04-24 19:04:22 +00:00
|
|
|
buffer[sizeof(buffer)-1] = 0;
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim16-8-1,editorcolors[8],editorcolors[0],buffer,0);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (finddirshigh)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
dir = finddirshigh;
|
2008-08-08 23:04:05 +00:00
|
|
|
for (i=(listsize/2)-1; i>=0; i--)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2008-09-03 14:02:42 +00:00
|
|
|
if (!dir->prev) break;
|
2008-08-08 23:04:05 +00:00
|
|
|
else dir=dir->prev;
|
|
|
|
}
|
|
|
|
for (i=0; ((i<listsize) && dir); i++, dir=dir->next)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t c = (dir->type == CACHE1D_FIND_DIR ? 2 : 3); //PK
|
2006-04-24 19:04:22 +00:00
|
|
|
memset(buffer,0,sizeof(buffer));
|
2009-02-02 01:49:14 +00:00
|
|
|
Bstrncpy(buffer,dir->name,25);
|
2006-04-24 19:04:22 +00:00
|
|
|
if (strlen(buffer) == 25)
|
|
|
|
buffer[21] = buffer[22] = buffer[23] = '.', buffer[24] = 0;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (dir == finddirshigh)
|
|
|
|
{
|
2008-12-23 23:27:53 +00:00
|
|
|
if (currentlist == 0) printext16(8,16+8*i,editorcolors[c|8],editorcolors[0],"->",0);
|
|
|
|
printext16(32,16+8*i,editorcolors[c|8],editorcolors[0],buffer,0);
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-23 23:27:53 +00:00
|
|
|
printext16(32,16+8*i,editorcolors[c],editorcolors[0],buffer,0);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (findfileshigh)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
dir = findfileshigh;
|
2008-08-08 23:04:05 +00:00
|
|
|
for (i=(listsize/2)-1; i>=0; i--)
|
|
|
|
{
|
|
|
|
if (!dir->prev) break;
|
|
|
|
else dir=dir->prev;
|
|
|
|
}
|
|
|
|
for (i=0; ((i<listsize) && dir); i++, dir=dir->next)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
if (dir == findfileshigh)
|
|
|
|
{
|
2008-12-23 23:27:53 +00:00
|
|
|
if (currentlist == 1) printext16(240,16+8*i,editorcolors[7|8],editorcolors[0],"->",0);
|
|
|
|
printext16(240+24,16+8*i,editorcolors[7|8],editorcolors[0],dir->name,0);
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-23 23:27:53 +00:00
|
|
|
printext16(240+24,16+8*i,editorcolors[7],editorcolors[0],dir->name,0);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
enddrawing();
|
|
|
|
showframe(1);
|
|
|
|
|
|
|
|
keystatus[0xcb] = 0;
|
|
|
|
keystatus[0xcd] = 0;
|
|
|
|
keystatus[0xc8] = 0;
|
|
|
|
keystatus[0xd0] = 0;
|
|
|
|
keystatus[0x1c] = 0; //enter
|
|
|
|
keystatus[0xf] = 0; //tab
|
|
|
|
keystatus[1] = 0; //esc
|
|
|
|
ch = 0; //Interesting fakery of ch = getch()
|
|
|
|
while (ch == 0)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
|
|
|
{
|
|
|
|
if (quitevent)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
keystatus[1] = 1;
|
|
|
|
quitevent = 0;
|
|
|
|
}
|
2007-01-12 05:49:09 +00:00
|
|
|
}
|
|
|
|
idle();
|
2006-04-24 19:04:22 +00:00
|
|
|
ch = bgetchar();
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
// JBF 20040208: seek to first name matching pressed character
|
2006-04-24 19:04:22 +00:00
|
|
|
CACHE1D_FIND_REC *seeker = currentlist ? findfiles : finddirs;
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0xc7]||keystatus[0xcf]) // home/end
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
while (keystatus[0xcf]?seeker->next:seeker->prev)
|
2006-04-13 20:47:06 +00:00
|
|
|
seeker = keystatus[0xcf]?seeker->next:seeker->prev;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (seeker)
|
|
|
|
{
|
2006-04-13 20:47:06 +00:00
|
|
|
if (currentlist) findfileshigh = seeker;
|
|
|
|
else finddirshigh = seeker;
|
|
|
|
}
|
|
|
|
ch = keystatus[0xcf]?80:72;
|
|
|
|
keystatus[0xc7] = keystatus[0xcf] = 0;
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
else if (keystatus[0xc9]|keystatus[0xd1]) // page up/down
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
seeker = currentlist?findfileshigh:finddirshigh;
|
2009-05-01 06:35:27 +00:00
|
|
|
i = (ydim2d-STATUS2DSIZ2-48)>>5/*3*/; //PK
|
2008-05-15 03:16:38 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
while (i>0)
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
if (keystatus[0xd1]?seeker->next:seeker->prev)
|
2006-04-13 20:47:06 +00:00
|
|
|
seeker = keystatus[0xd1]?seeker->next:seeker->prev;
|
|
|
|
i--;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
if (seeker)
|
|
|
|
{
|
2006-04-13 20:47:06 +00:00
|
|
|
if (currentlist) findfileshigh = seeker;
|
|
|
|
else finddirshigh = seeker;
|
|
|
|
}
|
|
|
|
ch = keystatus[0xd1]?80:72;
|
|
|
|
keystatus[0xc9] = keystatus[0xd1] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char ch2;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9')))
|
|
|
|
{
|
2006-04-13 20:47:06 +00:00
|
|
|
if (ch >= 'a') ch -= ('a'-'A');
|
2007-12-12 17:42:14 +00:00
|
|
|
while (seeker)
|
|
|
|
{
|
2006-04-13 20:47:06 +00:00
|
|
|
ch2 = seeker->name[0];
|
|
|
|
if (ch2 >= 'a' && ch2 <= 'z') ch2 -= ('a'-'A');
|
|
|
|
if (ch2 == ch) break;
|
|
|
|
seeker = seeker->next;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
if (seeker)
|
|
|
|
{
|
2006-04-13 20:47:06 +00:00
|
|
|
if (currentlist) findfileshigh = seeker;
|
|
|
|
else finddirshigh = seeker;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0xcb]) ch = 9; // left arr
|
|
|
|
if (keystatus[0xcd]) ch = 9; // right arr
|
|
|
|
if (keystatus[0xc8]) ch = 72; // up arr
|
|
|
|
if (keystatus[0xd0]) ch = 80; // down arr
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
if (ch == 'f' || ch == 'F')
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
currentlist = 0;
|
|
|
|
pathsearchmode = 1-pathsearchmode;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (pathsearchmode)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
strcpy(selectedboardfilename, "");
|
|
|
|
Bcanonicalisefilename(selectedboardfilename, 0);
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else strcpy(selectedboardfilename, "/");
|
2006-04-24 19:04:22 +00:00
|
|
|
getfilenames(selectedboardfilename, "*.map");
|
|
|
|
Bstrcpy(oldpath,selectedboardfilename);
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if (ch == 'g' || ch == 'G')
|
|
|
|
{
|
|
|
|
if (!pathsearchmode)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
grponlymode = 1-grponlymode;
|
|
|
|
getfilenames(selectedboardfilename, "*.map");
|
|
|
|
Bstrcpy(oldpath,selectedboardfilename);
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if (ch == 9)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if ((currentlist == 0 && findfiles) || (currentlist == 1 && finddirs))
|
|
|
|
currentlist = 1-currentlist;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
2008-08-09 06:08:24 +00:00
|
|
|
else if (keystatus[0xc8] /*(ch == 75) || (ch == 72)*/)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
if (currentlist == 0)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (finddirshigh && finddirshigh->prev) finddirshigh = finddirshigh->prev;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (findfileshigh && findfileshigh->prev) findfileshigh = findfileshigh->prev;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
2008-08-09 06:08:24 +00:00
|
|
|
else if (keystatus[0xd0] /*(ch == 77) || (ch == 80)*/)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
if (currentlist == 0)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (finddirshigh && finddirshigh->next) finddirshigh = finddirshigh->next;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (findfileshigh && findfileshigh->next) findfileshigh = findfileshigh->next;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if ((ch == 13) && (currentlist == 0))
|
|
|
|
{
|
|
|
|
if (finddirshigh->type == CACHE1D_FIND_DRIVE)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
strcpy(selectedboardfilename, finddirshigh->name);
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
strcat(selectedboardfilename, finddirshigh->name);
|
|
|
|
}
|
|
|
|
strcat(selectedboardfilename, "/");
|
|
|
|
if (pathsearchmode)
|
|
|
|
Bcanonicalisefilename(selectedboardfilename, 1);
|
|
|
|
else
|
|
|
|
Bcorrectfilename(selectedboardfilename, 1);
|
|
|
|
|
|
|
|
Bstrcpy(oldpath,selectedboardfilename);
|
|
|
|
//printf("Changing directories to: %s\n", selectedboardfilename);
|
|
|
|
|
|
|
|
getfilenames(selectedboardfilename, "*.map");
|
|
|
|
ch = 0;
|
|
|
|
|
|
|
|
begindrawing();
|
|
|
|
clearbuf((char *)frameplace, (bytesperline*ydim16) >> 2, 0l);
|
|
|
|
enddrawing();
|
|
|
|
showframe(1);
|
|
|
|
}
|
|
|
|
if (ch == 13 && !findfileshigh) ch = 0;
|
|
|
|
}
|
|
|
|
while ((ch != 13) && (ch != 27));
|
|
|
|
if (ch == 13)
|
|
|
|
{
|
|
|
|
Bstrcat(selectedboardfilename, findfileshigh->name);
|
|
|
|
//printf("Selected file: %s\n", selectedboardfilename);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
pathsearchmode = bakpathsearchmode;
|
|
|
|
return(-1);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t fillsector(int16_t sectnum, char fillcolor)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t x1, x2, y1, y2, sy, y, tempint;
|
|
|
|
int32_t lborder, rborder, uborder, dborder, miny, maxy, dax;
|
|
|
|
int16_t z, zz, startwall, endwall, fillcnt;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
lborder = 0; rborder = xdim;
|
|
|
|
uborder = 0; dborder = ydim16;
|
|
|
|
|
|
|
|
if (sectnum == -1)
|
|
|
|
return(0);
|
|
|
|
miny = dborder-1;
|
|
|
|
maxy = uborder;
|
|
|
|
startwall = sector[sectnum].wallptr;
|
|
|
|
endwall = startwall + sector[sectnum].wallnum - 1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (z=startwall; z<=endwall; z++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
y1 = (((wall[z].y-pos.y)*zoom)>>14)+midydim16;
|
|
|
|
y2 = (((wall[wall[z].point2].y-pos.y)*zoom)>>14)+midydim16;
|
2006-04-24 19:04:22 +00:00
|
|
|
if (y1 < miny) miny = y1;
|
|
|
|
if (y2 < miny) miny = y2;
|
|
|
|
if (y1 > maxy) maxy = y1;
|
|
|
|
if (y2 > maxy) maxy = y2;
|
|
|
|
}
|
|
|
|
if (miny < uborder) miny = uborder;
|
|
|
|
if (maxy >= dborder) maxy = dborder-1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (sy=miny+((totalclock>>2)&3); sy<=maxy; sy+=3) // JBF 20040116: numframes%3 -> (totalclock>>2)&3
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2009-01-13 12:23:18 +00:00
|
|
|
y = pos.y+(((sy-midydim16)<<14)/zoom);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
fillist[0] = lborder; fillcnt = 1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (z=startwall; z<=endwall; z++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
x1 = wall[z].x; x2 = wall[wall[z].point2].x;
|
|
|
|
y1 = wall[z].y; y2 = wall[wall[z].point2].y;
|
|
|
|
if (y1 > y2)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint = x1; x1 = x2; x2 = tempint;
|
|
|
|
tempint = y1; y1 = y2; y2 = tempint;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
if ((y1 <= y) && (y2 > y))
|
|
|
|
//if (x1*(y-y2) + x2*(y1-y) <= 0)
|
|
|
|
{
|
|
|
|
dax = x1+scale(y-y1,x2-x1,y2-y1);
|
2009-01-13 12:23:18 +00:00
|
|
|
dax = (((dax-pos.x)*zoom)>>14)+halfxdim16;
|
2006-04-24 19:04:22 +00:00
|
|
|
if (dax >= lborder)
|
|
|
|
fillist[fillcnt++] = dax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fillcnt > 0)
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (z=1; z<fillcnt; z++)
|
|
|
|
for (zz=0; zz<z; zz++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (fillist[z] < fillist[zz])
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint = fillist[z]; fillist[z] = fillist[zz]; fillist[zz] = tempint;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (z=(fillcnt&1); z<fillcnt-1; z+=2)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (fillist[z] > rborder) break;
|
|
|
|
if (fillist[z+1] > rborder)
|
|
|
|
fillist[z+1] = rborder;
|
2008-12-23 23:27:53 +00:00
|
|
|
drawline16(fillist[z],sy,fillist[z+1],sy,editorcolors[fillcolor]);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(0);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t whitelinescan(int16_t dalinehighlight)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j, k;
|
|
|
|
int16_t sucksect, newnumwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
sucksect = sectorofwall(dalinehighlight);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
Bmemcpy(§or[numsectors],§or[sucksect],sizeof(sectortype));
|
|
|
|
sector[numsectors].wallptr = numwalls;
|
|
|
|
sector[numsectors].wallnum = 0;
|
|
|
|
i = dalinehighlight;
|
|
|
|
newnumwalls = numwalls;
|
|
|
|
do
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
j = lastwall((int16_t)i);
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
{
|
|
|
|
j = wall[j].point2;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=0; k<numwalls; k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[wall[k].point2].x == wall[j].x)
|
|
|
|
if (wall[wall[k].point2].y == wall[j].y)
|
|
|
|
if (wall[k].nextwall == -1)
|
|
|
|
{
|
|
|
|
j = k;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
Bmemcpy(&wall[newnumwalls],&wall[i],sizeof(walltype));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[newnumwalls].nextwall = j;
|
2009-01-09 09:29:17 +00:00
|
|
|
wall[newnumwalls].nextsector = sectorofwall((int16_t)j);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
newnumwalls++;
|
|
|
|
sector[numsectors].wallnum++;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
i = j;
|
|
|
|
}
|
|
|
|
while (i != dalinehighlight);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<newnumwalls-1; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[i].point2 = i+1;
|
|
|
|
wall[newnumwalls-1].point2 = numwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (clockdir(numwalls) == 1)
|
|
|
|
return(-1);
|
|
|
|
else
|
|
|
|
return(newnumwalls);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
#define loadbyte(fil,tempbuf,bufplc,dat) \
|
|
|
|
{ \
|
|
|
|
if (bufplc == 0) \
|
|
|
|
{ \
|
|
|
|
for(bufplc=0;bufplc<4096;bufplc++) \
|
|
|
|
tempbuf[bufplc] = 0; \
|
|
|
|
bufplc = 0; \
|
|
|
|
read(fil,tempbuf,4096); \
|
|
|
|
} \
|
|
|
|
dat = tempbuf[bufplc]; \
|
|
|
|
bufplc = ((bufplc+1)&4095); \
|
|
|
|
} \
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t loadnames(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
char buffer[80], firstch, ch;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t fil, i, num, buffercnt, bufplc;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
if ((fil = open("names.h",O_BINARY|O_RDWR,S_IREAD)) == -1) return(-1);
|
|
|
|
bufplc = 0;
|
|
|
|
do { loadbyte(fil,tempbuf,bufplc,firstch); } while (firstch != '#');
|
|
|
|
|
|
|
|
while ((firstch == '#') || (firstch == '/'))
|
|
|
|
{
|
|
|
|
do { loadbyte(fil,tempbuf,bufplc,ch); } while (ch > 32);
|
|
|
|
|
|
|
|
buffercnt = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
loadbyte(fil,tempbuf,bufplc,ch);
|
|
|
|
if (ch > 32) buffer[buffercnt++] = ch;
|
|
|
|
}
|
|
|
|
while (ch > 32);
|
|
|
|
|
|
|
|
num = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
loadbyte(fil,tempbuf,bufplc,ch);
|
|
|
|
if ((ch >= 48) && (ch <= 57)) num = num*10+(ch-48);
|
|
|
|
}
|
|
|
|
while (ch != 13);
|
|
|
|
for(i=0;i<buffercnt;i++) names[num][i] = buffer[i];
|
|
|
|
names[num][buffercnt] = 0;
|
|
|
|
|
|
|
|
loadbyte(fil,tempbuf,bufplc,firstch);
|
|
|
|
if (firstch == 10) loadbyte(fil,tempbuf,bufplc,firstch);
|
|
|
|
}
|
|
|
|
close(fil);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t loadnames(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
char buffer[1024], *p, *name, *number, *endptr;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t num, syms=0, line=0, a, comment=0;
|
2006-04-24 19:04:22 +00:00
|
|
|
BFILE *fp;
|
|
|
|
|
|
|
|
fp = fopenfrompath("NAMES.H","r");
|
2007-12-12 17:42:14 +00:00
|
|
|
if (!fp)
|
|
|
|
{
|
|
|
|
if ((fp = fopenfrompath("names.h","r")) == NULL)
|
|
|
|
{
|
2008-02-21 05:11:41 +00:00
|
|
|
initprintf("Failed to open NAMES.H\n");
|
2006-04-24 19:04:22 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//clearbufbyte(names, sizeof(names), 0);
|
|
|
|
memset(names,0,sizeof(names));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-02-21 05:11:41 +00:00
|
|
|
initprintf("Loading NAMES.H\n");
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
while (Bfgets(buffer, 1024, fp))
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
a = Bstrlen(buffer);
|
2007-12-12 17:42:14 +00:00
|
|
|
if (a >= 1)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (a > 1)
|
|
|
|
if (buffer[a-2] == '\r') buffer[a-2] = 0;
|
|
|
|
if (buffer[a-1] == '\n') buffer[a-1] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = buffer;
|
|
|
|
line++;
|
|
|
|
while (*p == 32) p++;
|
|
|
|
if (*p == 0) continue; // blank line
|
|
|
|
|
2008-05-16 19:51:38 +00:00
|
|
|
if (*p == '#' && !comment)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
p++;
|
|
|
|
while (*p == 32) p++;
|
|
|
|
if (*p == 0) continue; // null directive
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (!Bstrncmp(p, "define ", 7))
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
// #define_...
|
|
|
|
p += 7;
|
|
|
|
while (*p == 32) p++;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (*p == 0)
|
|
|
|
{
|
2008-02-21 05:11:41 +00:00
|
|
|
initprintf("Error: Malformed #define at line %d\n", line-1);
|
2006-04-24 19:04:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
name = p;
|
|
|
|
while (*p != 32 && *p != 0) p++;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (*p == 32)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
*(p++) = 0;
|
|
|
|
while (*p == 32) p++;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (*p == 0) // #define_NAME with no number
|
|
|
|
{
|
2008-02-21 05:11:41 +00:00
|
|
|
initprintf("Error: No number given for name \"%s\" (line %d)\n", name, line-1);
|
2006-04-24 19:04:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
number = p;
|
|
|
|
while (*p != 0) p++;
|
|
|
|
if (*p != 0) *p = 0;
|
|
|
|
|
|
|
|
// add to list
|
|
|
|
num = Bstrtol(number, &endptr, 10);
|
2007-12-12 17:42:14 +00:00
|
|
|
if (*endptr != 0)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
p = endptr;
|
|
|
|
goto badline;
|
|
|
|
}
|
|
|
|
//printf("Grokked \"%s\" -> \"%d\"\n", name, num);
|
2007-12-12 17:42:14 +00:00
|
|
|
if (num < 0 || num >= MAXTILES)
|
|
|
|
{
|
2008-02-21 05:11:41 +00:00
|
|
|
initprintf("Error: Constant %d for name \"%s\" out of range (line %d)\n", num, name, line-1);
|
2006-04-24 19:04:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Bstrlen(name) > 24)
|
2008-02-21 05:11:41 +00:00
|
|
|
initprintf("Warning: Name \"%s\" longer than 24 characters (line %d). Truncating.\n", name, line-1);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
Bstrncpy(names[num], name, 24);
|
|
|
|
names[num][24] = 0;
|
|
|
|
|
|
|
|
syms++;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else // #define_NAME with no number
|
|
|
|
{
|
2008-02-21 05:11:41 +00:00
|
|
|
initprintf("Error: No number given for name \"%s\" (line %d)\n", name, line-1);
|
2006-04-24 19:04:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else goto badline;
|
|
|
|
}
|
|
|
|
else if (*p == '/')
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
if (*(p+1) == '*') {comment++; continue;}
|
2006-04-24 19:04:22 +00:00
|
|
|
if (*(p+1) == '/') continue; // comment
|
|
|
|
}
|
2008-05-16 19:51:38 +00:00
|
|
|
else if (*p == '*' && p[1] == '/')
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
comment--; continue;
|
2008-05-16 19:51:38 +00:00
|
|
|
}
|
|
|
|
else if (comment)continue;
|
2006-04-13 20:47:06 +00:00
|
|
|
badline:
|
2008-02-21 05:11:41 +00:00
|
|
|
initprintf("Error: Invalid statement found at character %d on line %d\n", (p-buffer), line-1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2008-02-21 05:11:41 +00:00
|
|
|
initprintf("Read %d lines, loaded %d names.\n", line, syms);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
Bfclose(fp);
|
|
|
|
return 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void printcoords16(int32_t posxe, int32_t posye, int16_t ange)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
char snotbuf[80];
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i,m;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-10-31 10:08:51 +00:00
|
|
|
Bsprintf(snotbuf,"x:%d y:%d ang:%d",posxe,posye,ange);
|
2006-04-24 19:04:22 +00:00
|
|
|
i = 0;
|
|
|
|
while ((snotbuf[i] != 0) && (i < 30))
|
|
|
|
i++;
|
|
|
|
while (i < 30)
|
|
|
|
{
|
|
|
|
snotbuf[i] = 32;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
snotbuf[30] = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-05-01 19:28:57 +00:00
|
|
|
clearministatbar16();
|
|
|
|
|
|
|
|
printext16(8, ydim-STATUS2DSIZ+128, whitecol, -1, snotbuf,0);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-10-31 10:08:51 +00:00
|
|
|
m = (numsectors > MAXSECTORSV7 || numwalls > MAXWALLSV7 || numsprites > MAXSPRITESV7);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(snotbuf,"%d/%d sect. %d/%d walls %d/%d spri.",
|
2009-02-19 16:47:54 +00:00
|
|
|
numsectors,m?MAXSECTORSV8:MAXSECTORSV7,
|
|
|
|
numwalls,m?MAXWALLSV8:MAXWALLSV7,
|
|
|
|
numsprites,m?MAXSPRITESV8:MAXSPRITESV7);
|
2008-10-31 10:08:51 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
i = 0;
|
|
|
|
while ((snotbuf[i] != 0) && (i < 46))
|
|
|
|
i++;
|
|
|
|
while (i < 46)
|
|
|
|
{
|
|
|
|
snotbuf[i] = 32;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
snotbuf[46] = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-05-01 19:28:57 +00:00
|
|
|
printext16(264, ydim-STATUS2DSIZ+128, m?editorcolors[10]:whitecol, -1, snotbuf,0);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void updatenumsprites(void)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
numsprites = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXSPRITES; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
if (sprite[i].statnum < MAXSTATUS)
|
|
|
|
numsprites++;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void copysector(int16_t soursector, int16_t destsector, int16_t deststartwall, char copystat)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t j, k, m, newnumwalls, startwall, endwall;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
newnumwalls = deststartwall; //erase existing sector fragments
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//duplicate walls
|
|
|
|
startwall = sector[soursector].wallptr;
|
|
|
|
endwall = startwall + sector[soursector].wallnum;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<endwall; j++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
Bmemcpy(&wall[newnumwalls],&wall[j],sizeof(walltype));
|
|
|
|
wall[newnumwalls].point2 += deststartwall-startwall;
|
|
|
|
if (wall[newnumwalls].nextwall >= 0)
|
|
|
|
{
|
|
|
|
wall[newnumwalls].nextwall += deststartwall-startwall;
|
|
|
|
wall[newnumwalls].nextsector += destsector-soursector;
|
|
|
|
}
|
|
|
|
newnumwalls++;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//for(j=deststartwall;j<newnumwalls;j++)
|
|
|
|
//{
|
|
|
|
// if (wall[j].nextwall >= 0)
|
|
|
|
// checksectorpointer(wall[j].nextwall,wall[j].nextsector);
|
|
|
|
// checksectorpointer((short)j,destsector);
|
|
|
|
//}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (newnumwalls > deststartwall)
|
|
|
|
{
|
|
|
|
//duplicate sectors
|
|
|
|
Bmemcpy(§or[destsector],§or[soursector],sizeof(sectortype));
|
|
|
|
sector[destsector].wallptr = deststartwall;
|
|
|
|
sector[destsector].wallnum = newnumwalls-deststartwall;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (copystat == 1)
|
|
|
|
{
|
|
|
|
//duplicate sprites
|
|
|
|
j = headspritesect[soursector];
|
|
|
|
while (j >= 0)
|
|
|
|
{
|
|
|
|
k = nextspritesect[j];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
m = insertsprite(destsector,sprite[j].statnum);
|
|
|
|
Bmemcpy(&sprite[m],&sprite[j],sizeof(spritetype));
|
|
|
|
sprite[m].sectnum = destsector; //Don't let memcpy overwrite sector!
|
|
|
|
|
|
|
|
j = k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void showsectordata(int16_t sectnum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
char snotbuf[80];
|
2009-05-01 06:35:27 +00:00
|
|
|
int32_t col = 1, row = 0;
|
|
|
|
int32_t mode = (sectnum & 16384);
|
|
|
|
|
|
|
|
if (mode) row = 2;
|
|
|
|
sectnum &= ~16384;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-06-05 10:10:26 +00:00
|
|
|
Bsprintf(snotbuf,"^10Sector %d ^O(F7 to edit)",sectnum);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*96)-STATUS2DSIZ+32,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Firstwall: %d",sector[sectnum].wallptr);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*96)-STATUS2DSIZ+48,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Numberofwalls: %d",sector[sectnum].wallnum);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*96)-STATUS2DSIZ+56,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Firstsprite: %d",headspritesect[sectnum]);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*96)-STATUS2DSIZ+64,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Tags: %d, %d",sector[sectnum].hitag,sector[sectnum].lotag);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*96)-STATUS2DSIZ+72,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf," (0x%x), (0x%x)",sector[sectnum].hitag,sector[sectnum].lotag);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*96)-STATUS2DSIZ+80,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Extra: %d",sector[sectnum].extra);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*96)-STATUS2DSIZ+88,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Visibility: %d",sector[sectnum].visibility);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*96)-STATUS2DSIZ+96,editorcolors[11],-1,snotbuf,2);
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(snotbuf,"Pixel height: %d",(sector[sectnum].floorz-sector[sectnum].ceilingz)>>8);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*96)-STATUS2DSIZ+104,editorcolors[11],-1,snotbuf,2);
|
|
|
|
|
|
|
|
if (mode)
|
|
|
|
row--;
|
|
|
|
else col++;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+32,editorcolors[11],-1,"^10CEILINGS:^O",2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Flags (hex): %x",sector[sectnum].ceilingstat);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+48,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"(X,Y)pan: %d, %d",sector[sectnum].ceilingxpanning,sector[sectnum].ceilingypanning);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+56,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Shade byte: %d",sector[sectnum].ceilingshade);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+64,editorcolors[11],-1,snotbuf,2);
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(snotbuf,"Z-coordinate: %d",sector[sectnum].ceilingz);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+72,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Tile number: %d",sector[sectnum].ceilingpicnum);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+80,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Ceiling heinum: %d",sector[sectnum].ceilingheinum);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+88,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Palookup number: %d",sector[sectnum].ceilingpal);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+96,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
if (mode)
|
|
|
|
row--;
|
|
|
|
else col++;
|
|
|
|
|
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+32,editorcolors[11],-1,"^10FLOORS:^O",2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Flags (hex): %x",sector[sectnum].floorstat);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+48,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"(X,Y)pan: %d, %d",sector[sectnum].floorxpanning,sector[sectnum].floorypanning);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+56,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Shade byte: %d",sector[sectnum].floorshade);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+64,editorcolors[11],-1,snotbuf,2);
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(snotbuf,"Z-coordinate: %d",sector[sectnum].floorz);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+72,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Tile number: %d",sector[sectnum].floorpicnum);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+80,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Floor heinum: %d",sector[sectnum].floorheinum);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+88,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Palookup number: %d",sector[sectnum].floorpal);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+96,editorcolors[11],-1,snotbuf,2);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void showwalldata(int16_t wallnum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t dax, day, dist;
|
2006-04-24 19:04:22 +00:00
|
|
|
char snotbuf[80];
|
2009-05-01 06:35:27 +00:00
|
|
|
int32_t col = 1, row = 0;
|
|
|
|
int32_t mode = (wallnum & 16384);
|
|
|
|
|
|
|
|
if (mode) row = 2;
|
|
|
|
wallnum &= ~16384;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-06-05 10:10:26 +00:00
|
|
|
Bsprintf(snotbuf,"^10Wall %d ^O(F8 to edit)",wallnum);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+32,editorcolors[11],-1,snotbuf,2);
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(snotbuf,"X-coordinate: %d",wall[wallnum].x);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+48,editorcolors[11],-1,snotbuf,2);
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(snotbuf,"Y-coordinate: %d",wall[wallnum].y);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+56,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Point2: %d",wall[wallnum].point2);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+64,editorcolors[11],-1,snotbuf,2);
|
|
|
|
Bsprintf(snotbuf,"Sector: ^010%d",sectorofwall(wallnum));
|
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+72,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
Bsprintf(snotbuf,"Tags: %d, %d",wall[wallnum].hitag,wall[wallnum].lotag);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+88,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf," (0x%x), (0x%x)",wall[wallnum].hitag,wall[wallnum].lotag);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+96,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
if (mode)
|
|
|
|
row--;
|
|
|
|
else col++;
|
|
|
|
|
|
|
|
Bsprintf(snotbuf,"^10%s^O",names[wall[wallnum].picnum]);
|
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+32,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Flags (hex): %x",wall[wallnum].cstat);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+48,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Shade: %d",wall[wallnum].shade);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+56,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Pal: %d",wall[wallnum].pal);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+64,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"(X,Y)repeat: %d, %d",wall[wallnum].xrepeat,wall[wallnum].yrepeat);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+72,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"(X,Y)pan: %d, %d",wall[wallnum].xpanning,wall[wallnum].ypanning);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+80,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Tile number: %d",wall[wallnum].picnum);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+88,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"OverTile number: %d",wall[wallnum].overpicnum);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+96,editorcolors[11],-1,snotbuf,2);
|
|
|
|
|
|
|
|
if (mode)
|
|
|
|
row--;
|
|
|
|
else col++;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
Bsprintf(snotbuf,"nextsector: %d",wall[wallnum].nextsector);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+48,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"nextwall: %d",wall[wallnum].nextwall);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+56,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
Bsprintf(snotbuf,"Extra: %d",wall[wallnum].extra);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+72,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
dax = wall[wallnum].x-wall[wall[wallnum].point2].x;
|
|
|
|
day = wall[wallnum].y-wall[wall[wallnum].point2].y;
|
|
|
|
dist = ksqrt(dax*dax+day*day);
|
|
|
|
|
|
|
|
// TX 20050102 I'm not sure what unit dist<<4 is supposed to be, but dist itself is correct in terms of game coordinates as one would expect
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(snotbuf,"Wall length: %d",dist);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+96,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
dax = (int32_t)sectorofwall(wallnum);
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(snotbuf,"Pixel height: %d",(sector[dax].floorz-sector[dax].ceilingz)>>8);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+104,editorcolors[11],-1,snotbuf,2);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void showspritedata(int16_t spritenum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
char snotbuf[80];
|
2009-05-01 06:35:27 +00:00
|
|
|
int32_t col = 1, row = 0;
|
|
|
|
int32_t mode = (spritenum & 16384);
|
|
|
|
|
|
|
|
if (mode) row = 2;
|
|
|
|
spritenum &= ~16384;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-06-05 10:10:26 +00:00
|
|
|
Bsprintf(snotbuf,"^10Sprite %d ^O(F8 to edit)",spritenum);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+32,editorcolors[11],-1,snotbuf,2);
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(snotbuf,"X-coordinate: %d",sprite[spritenum].x);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+48,editorcolors[11],-1,snotbuf,2);
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(snotbuf,"Y-coordinate: %d",sprite[spritenum].y);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+56,editorcolors[11],-1,snotbuf,2);
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(snotbuf,"Z-coordinate: %d",sprite[spritenum].z);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+64,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
Bsprintf(snotbuf,"Sectnum: ^010%d",sprite[spritenum].sectnum);
|
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+72,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Statnum: %d",sprite[spritenum].statnum);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+80,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
Bsprintf(snotbuf,"Tags: %d, %d",sprite[spritenum].hitag,sprite[spritenum].lotag);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+96,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf," (0x%x), (0x%x)",sprite[spritenum].hitag,sprite[spritenum].lotag);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8,ydim-(row*80)-STATUS2DSIZ+104,editorcolors[11],-1,snotbuf,2);
|
|
|
|
|
|
|
|
if (mode)
|
|
|
|
row--;
|
|
|
|
else col++;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-08-28 23:15:11 +00:00
|
|
|
Bsprintf(snotbuf,"^10%s^O",names[sprite[spritenum].picnum]);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+32,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Flags (hex): %x",sprite[spritenum].cstat);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+48,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Shade: %d",sprite[spritenum].shade);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+56,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Pal: %d",sprite[spritenum].pal);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+64,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"(X,Y)repeat: %d, %d",sprite[spritenum].xrepeat,sprite[spritenum].yrepeat);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+72,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"(X,Y)offset: %d, %d",sprite[spritenum].xoffset,sprite[spritenum].yoffset);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+80,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Tile number: %d",sprite[spritenum].picnum);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+88,editorcolors[11],-1,snotbuf,2);
|
|
|
|
|
|
|
|
if (mode)
|
|
|
|
row--;
|
|
|
|
else col++;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
Bsprintf(snotbuf,"Angle (2048 degrees): %d",sprite[spritenum].ang);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+48,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"X-Velocity: %d",sprite[spritenum].xvel);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+56,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Y-Velocity: %d",sprite[spritenum].yvel);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+64,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Z-Velocity: %d",sprite[spritenum].zvel);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+72,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Owner: %d",sprite[spritenum].owner);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+80,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Clipdist: %d",sprite[spritenum].clipdist);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+88,editorcolors[11],-1,snotbuf,2);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bsprintf(snotbuf,"Extra: %d",sprite[spritenum].extra);
|
2009-05-01 06:35:27 +00:00
|
|
|
printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+96,editorcolors[11],-1,snotbuf,2);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void keytimerstuff(void)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t ltotalclock=0;
|
2006-04-24 19:04:22 +00:00
|
|
|
if (totalclock == ltotalclock) return;
|
|
|
|
ltotalclock=totalclock;
|
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_STRAFE]] == 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-05-15 03:16:38 +00:00
|
|
|
// PK: With GCC and Polymost, keyboard turning lags
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_TURNLEFT]]) angvel = max(angvel-pk_turnaccel /* 16 */,-128);
|
|
|
|
if (keystatus[buildkeys[BK_TURNRIGHT]]) angvel = min(angvel+pk_turnaccel /* 16 */,127);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_TURNLEFT]]) svel = min(svel+16,255); // svel and vel aren't even chars...
|
|
|
|
if (keystatus[buildkeys[BK_TURNRIGHT]]) svel = max(svel-16,-256);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[buildkeys[BK_MOVEFORWARD]]) vel = min(vel+16,255);
|
|
|
|
if (keystatus[buildkeys[BK_MOVEBACKWARD]]) vel = max(vel-16,-256);
|
|
|
|
/* if (keystatus[buildkeys[BK_STRAFELEFT]]) svel = min(svel+8,127);
|
|
|
|
if (keystatus[buildkeys[BK_STRAFERIGHT]]) svel = max(svel-8,-128); */
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-05-15 03:16:38 +00:00
|
|
|
if (angvel < 0) angvel = min(angvel+pk_turndecel /*12*/,0);
|
|
|
|
if (angvel > 0) angvel = max(angvel-pk_turndecel /*12*/,0);
|
2006-12-14 08:50:18 +00:00
|
|
|
if (svel < 0) svel = min(svel+6,0);
|
|
|
|
if (svel > 0) svel = max(svel-6,0);
|
|
|
|
if (vel < 0) vel = min(vel+6,0);
|
|
|
|
if (vel > 0) vel = max(vel-6,0);
|
2006-05-12 21:55:05 +00:00
|
|
|
/* if(mlook)
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.z -= (horiz-101)*(vel/40); */
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 02:29:58 +00:00
|
|
|
void _printmessage16(const char *fmt, ...)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, ybase;
|
2009-05-01 06:35:27 +00:00
|
|
|
char snotbuf[100];
|
|
|
|
char tmpstr[104];
|
2008-06-10 02:29:58 +00:00
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start(va, fmt);
|
2009-05-01 06:35:27 +00:00
|
|
|
Bvsnprintf(tmpstr, 104, fmt, va);
|
2008-06-10 02:29:58 +00:00
|
|
|
va_end(va);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
i = 0;
|
2009-05-01 06:35:27 +00:00
|
|
|
while ((tmpstr[i] != 0) && (i < 94))
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-06-10 02:29:58 +00:00
|
|
|
snotbuf[i] = tmpstr[i];
|
2006-04-24 19:04:22 +00:00
|
|
|
i++;
|
|
|
|
}
|
2009-05-01 19:28:57 +00:00
|
|
|
snotbuf[i] = 0;
|
2009-05-01 06:35:27 +00:00
|
|
|
if (lastpm16time == totalclock)
|
|
|
|
Bstrcpy(lastpm16buf, snotbuf);
|
2009-05-01 19:28:57 +00:00
|
|
|
|
|
|
|
clearministatbar16();
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
begindrawing();
|
2009-05-01 06:35:27 +00:00
|
|
|
ybase = (overridepm16y >= 0) ? ydim-overridepm16y : ydim-STATUS2DSIZ+128-8;
|
2009-05-01 19:28:57 +00:00
|
|
|
|
|
|
|
printext16((overridepm16y >= 0) ? 200L-24 : 8, ybase+8L, whitecol, -1, snotbuf, 0);
|
2006-04-24 19:04:22 +00:00
|
|
|
enddrawing();
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void printmessage256(int32_t x, int32_t y, char *name)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-09-03 10:47:19 +00:00
|
|
|
char snotbuf[64];
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
i = 0;
|
2008-09-03 10:47:19 +00:00
|
|
|
while ((name[i] != 0) && (i < 62))
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
snotbuf[i] = name[i];
|
|
|
|
i++;
|
|
|
|
}
|
2008-09-03 10:47:19 +00:00
|
|
|
while (i < 62)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
snotbuf[i] = 32;
|
|
|
|
i++;
|
|
|
|
}
|
2008-09-03 10:47:19 +00:00
|
|
|
snotbuf[62] = 0;
|
2008-09-03 14:02:42 +00:00
|
|
|
printext256(x+2,y+2,0,-1,snotbuf,0);
|
|
|
|
printext256(x,y,whitecol,-1,snotbuf,0);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//Find closest point (*dax, *day) on wall (dawall) to (x, y)
|
2009-01-09 09:29:17 +00:00
|
|
|
void getclosestpointonwall(int32_t x, int32_t y, int32_t dawall, int32_t *nx, int32_t *ny)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
walltype *wal;
|
2008-05-16 19:51:38 +00:00
|
|
|
int64 i, j, dx, dy;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
wal = &wall[dawall];
|
|
|
|
dx = wall[wal->point2].x-wal->x;
|
|
|
|
dy = wall[wal->point2].y-wal->y;
|
|
|
|
i = dx*(x-wal->x) + dy*(y-wal->y);
|
|
|
|
if (i <= 0) { *nx = wal->x; *ny = wal->y; return; }
|
|
|
|
j = dx*dx+dy*dy;
|
|
|
|
if (i >= j) { *nx = wal->x+dx; *ny = wal->y+dy; return; }
|
2008-05-16 19:51:38 +00:00
|
|
|
i=((i<<15)/j)<<15;
|
|
|
|
*nx = wal->x + ((dx*i)>>30);
|
|
|
|
*ny = wal->y + ((dy*i)>>30);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void initcrc(void)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j, k, a;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<256; j++) //Calculate CRC table
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
k = (j<<8); a = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=7; i>=0; i--)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (((k^a)&0x8000) > 0)
|
|
|
|
a = ((a<<1)&65535) ^ 0x1021; //0x1021 = genpoly
|
|
|
|
else
|
|
|
|
a = ((a<<1)&65535);
|
|
|
|
k = ((k<<1)&65535);
|
|
|
|
}
|
|
|
|
crctable[j] = (a&65535);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char visited[MAXWALLS];
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t GetWallZPeg(int32_t nWall)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t z=0, nSector, nNextSector;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
nSector = sectorofwall((int16_t)nWall);
|
2006-04-24 19:04:22 +00:00
|
|
|
nNextSector = wall[nWall].nextsector;
|
|
|
|
if (nNextSector == -1)
|
|
|
|
{
|
|
|
|
//1-sided wall
|
|
|
|
if (wall[nWall].cstat&4) z = sector[nSector].floorz;
|
|
|
|
else z = sector[nSector].ceilingz;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//2-sided wall
|
|
|
|
if (wall[nWall].cstat&4)
|
|
|
|
z = sector[nSector].ceilingz;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sector[nNextSector].ceilingz > sector[nSector].ceilingz)
|
|
|
|
z = sector[nNextSector].ceilingz; //top step
|
|
|
|
if (sector[nNextSector].floorz < sector[nSector].floorz)
|
|
|
|
z = sector[nNextSector].floorz; //bottom step
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(z);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void AlignWalls(int32_t nWall0, int32_t z0, int32_t nWall1, int32_t z1, int32_t nTile)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t n;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//do the x alignment
|
|
|
|
wall[nWall1].cstat &= ~0x0108; //Set to non-flip
|
2009-01-09 09:29:17 +00:00
|
|
|
wall[nWall1].xpanning = (uint8_t)((wall[nWall0].xpanning+(wall[nWall0].xrepeat<<3))%tilesizx[nTile]);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
z1 = GetWallZPeg(nWall1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (n=(picsiz[nTile]>>4); ((1<<n)<tilesizy[nTile]); n++);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[nWall1].yrepeat = wall[nWall0].yrepeat;
|
2009-01-09 09:29:17 +00:00
|
|
|
wall[nWall1].ypanning = (uint8_t)(wall[nWall0].ypanning+(((z1-z0)*wall[nWall0].yrepeat)>>(n+3)));
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void AutoAlignWalls(int32_t nWall0, int32_t ply)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t z0, z1, nTile, nWall1, branch, visible, nNextSector, nSector;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
nTile = wall[nWall0].picnum;
|
|
|
|
branch = 0;
|
|
|
|
if (ply == 0)
|
|
|
|
{
|
|
|
|
//clear visited bits
|
|
|
|
memset(visited,0,sizeof(visited));
|
|
|
|
visited[nWall0] = 1;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
z0 = GetWallZPeg(nWall0);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
nWall1 = wall[nWall0].point2;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//loop through walls at this vertex in CCW order
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
//break if this wall would connect us in a loop
|
|
|
|
if (visited[nWall1]) break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
visited[nWall1] = 1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//break if reached back of left wall
|
|
|
|
if (wall[nWall1].nextwall == nWall0) break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[nWall1].picnum == nTile)
|
|
|
|
{
|
|
|
|
z1 = GetWallZPeg(nWall1);
|
|
|
|
visible = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
nNextSector = wall[nWall1].nextsector;
|
|
|
|
if (nNextSector < 0)
|
|
|
|
visible = 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//ignore two sided walls that have no visible face
|
|
|
|
nSector = wall[wall[nWall1].nextwall].nextsector;
|
2009-01-09 09:29:17 +00:00
|
|
|
if (getceilzofslope((int16_t)nSector,wall[nWall1].x,wall[nWall1].y) <
|
|
|
|
getceilzofslope((int16_t)nNextSector,wall[nWall1].x,wall[nWall1].y))
|
2006-04-24 19:04:22 +00:00
|
|
|
visible = 1;
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
if (getflorzofslope((int16_t)nSector,wall[nWall1].x,wall[nWall1].y) >
|
|
|
|
getflorzofslope((int16_t)nNextSector,wall[nWall1].x,wall[nWall1].y))
|
2006-04-24 19:04:22 +00:00
|
|
|
visible = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (visible)
|
|
|
|
{
|
|
|
|
branch++;
|
|
|
|
AlignWalls(nWall0,z0,nWall1,z1,nTile);
|
|
|
|
|
|
|
|
//if wall was 1-sided, no need to recurse
|
|
|
|
if (wall[nWall1].nextwall < 0)
|
|
|
|
{
|
|
|
|
nWall0 = nWall1;
|
|
|
|
z0 = GetWallZPeg(nWall0);
|
|
|
|
nWall1 = wall[nWall0].point2;
|
|
|
|
branch = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
AutoAlignWalls(nWall1,ply+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wall[nWall1].nextwall < 0) break;
|
|
|
|
nWall1 = wall[wall[nWall1].nextwall].point2;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* vim:ts=4:
|
|
|
|
*/
|
|
|
|
|