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
|
2012-03-12 04:47:04 +00:00
|
|
|
// by Jonathon Fowler (jf@jonof.id.au)
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
#include "build.h"
|
|
|
|
#include "compat.h"
|
|
|
|
#include "pragmas.h"
|
|
|
|
#include "osd.h"
|
|
|
|
#include "cache1d.h"
|
|
|
|
#include "editor.h"
|
2012-03-28 19:42:16 +00:00
|
|
|
#include "common.h"
|
2015-09-27 21:17:59 +00:00
|
|
|
#include "colmatch.h"
|
2016-06-21 00:33:06 +00:00
|
|
|
#include "palette.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
#include "baselayer.h"
|
2012-11-25 04:26:37 +00:00
|
|
|
#include "renderlayer.h"
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
# include "winbits.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
|
|
|
|
2012-11-25 04:26:37 +00:00
|
|
|
|
2009-09-12 23:03:15 +00:00
|
|
|
#include "m32script.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2014-07-28 06:42:28 +00:00
|
|
|
char levelname[BMAX_PATH] = {0};
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
#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
|
|
|
|
2014-07-24 14:01:44 +00:00
|
|
|
static const char *CallExtGetVer(void);
|
|
|
|
static int32_t CallExtInit(void);
|
2016-01-12 10:30:56 +00:00
|
|
|
static int32_t CallExtPreInit(int32_t argc,char const * const * argv);
|
2014-07-28 06:42:28 +00:00
|
|
|
static int32_t CallExtPostStartupWindow(void);
|
2015-09-23 17:54:42 +00:00
|
|
|
static void CallExtPostInit(void);
|
2014-07-24 14:01:44 +00:00
|
|
|
static void CallExtUnInit(void);
|
|
|
|
static void CallExtPreCheckKeys(void);
|
|
|
|
static void CallExtAnalyzeSprites(int32_t, int32_t, int32_t, int32_t);
|
|
|
|
static void CallExtCheckKeys(void);
|
|
|
|
static void CallExtPreLoadMap(void);
|
|
|
|
static void CallExtSetupMapFilename(const char *mapname);
|
|
|
|
static void CallExtLoadMap(const char *mapname);
|
|
|
|
static int32_t CallExtPreSaveMap(void);
|
|
|
|
static void CallExtSaveMap(const char *mapname);
|
2015-07-10 21:19:41 +00:00
|
|
|
static inline const char *CallExtGetSectorCaption(int16_t sectnum) { return ExtGetSectorCaption(sectnum); }
|
|
|
|
static inline const char *CallExtGetWallCaption(int16_t wallnum) { return ExtGetWallCaption(wallnum); }
|
|
|
|
static inline const char *CallExtGetSpriteCaption(int16_t spritenum) { return ExtGetSpriteCaption(spritenum); }
|
2014-07-24 14:01:44 +00:00
|
|
|
static void CallExtShowSectorData(int16_t sectnum);
|
|
|
|
static void CallExtShowWallData(int16_t wallnum);
|
|
|
|
static void CallExtShowSpriteData(int16_t spritenum);
|
|
|
|
static void CallExtEditSectorData(int16_t sectnum);
|
|
|
|
static void CallExtEditWallData(int16_t wallnum);
|
|
|
|
static void CallExtEditSpriteData(int16_t spritenum);
|
|
|
|
// static const char *CallExtGetSectorType(int32_t lotag);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-09-16 19:17:48 +00:00
|
|
|
int8_t m32_clipping=2;
|
2012-08-20 21:26:36 +00:00
|
|
|
static int32_t m32_rotateang = 0;
|
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
|
|
|
|
2013-04-21 19:55:22 +00:00
|
|
|
// Start position
|
|
|
|
vec3_t startpos;
|
|
|
|
int16_t startang, startsectnum;
|
|
|
|
|
|
|
|
// Current position
|
2009-01-13 12:23:18 +00:00
|
|
|
vec3_t pos;
|
|
|
|
int32_t horiz = 100;
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t ang, cursectnum;
|
2013-02-19 20:35:14 +00:00
|
|
|
static int32_t hvel, vel, svel, angvel;
|
2013-02-28 17:30:11 +00:00
|
|
|
int32_t g_doHardcodedMovement = 1;
|
2011-05-15 22:37:24 +00:00
|
|
|
|
|
|
|
static int32_t mousexsurp = 0, mouseysurp = 0;
|
2015-01-11 04:52:15 +00:00
|
|
|
double msens = 1.0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t grponlymode = 0;
|
|
|
|
int32_t graphicsmode = 0;
|
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
|
|
|
|
2010-08-02 18:59:59 +00:00
|
|
|
// those ones save the respective 3d video vars while in 2d mode
|
|
|
|
// so that exiting from mapster32 in 2d mode saves the correct ones
|
2014-09-30 04:06:32 +00:00
|
|
|
float vid_gamma_3d=-1, vid_contrast_3d=-1, vid_brightness_3d=-1;
|
2010-08-02 18:59:59 +00:00
|
|
|
|
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
|
|
|
|
2013-03-21 09:49:12 +00:00
|
|
|
#ifndef GEKKO
|
2011-05-23 18:07:45 +00:00
|
|
|
int32_t g_maxCacheSize = 24<<20;
|
2013-03-21 09:49:12 +00:00
|
|
|
#else
|
|
|
|
int32_t g_maxCacheSize = 8<<20;
|
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static int16_t oldmousebstatus = 0;
|
2014-07-28 06:43:16 +00:00
|
|
|
|
|
|
|
char game_executable[BMAX_PATH] = {0};
|
|
|
|
|
2012-01-15 22:39:38 +00:00
|
|
|
int32_t zlock = 0x7fffffff, zmode = 0, kensplayerheight = 32;
|
2011-02-24 20:40:27 +00:00
|
|
|
//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];
|
2011-03-07 16:30:06 +00:00
|
|
|
const char *g_namesFileName = "NAMES.H";
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t asksave = 0;
|
|
|
|
int32_t osearchx, osearchy; //old search input
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
int32_t grid = 0, autogrid = 1, gridlock = 1, showtags = 2;
|
|
|
|
int32_t zoom = 768, gettilezoom = 1, ztarget = 768;
|
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
|
|
|
extern int32_t mapversion;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-12-05 17:39:52 +00:00
|
|
|
int16_t highlight[MAXWALLS+MAXSPRITES];
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t highlightsector[MAXSECTORS], highlightsectorcnt = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
extern char textfont[128][8];
|
|
|
|
|
2012-06-01 20:09:19 +00:00
|
|
|
int32_t tempsectornum = -1; // for auto ceiling/floor alignment
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t temppicnum, tempcstat, templotag, temphitag, tempextra;
|
2011-05-12 23:31:13 +00:00
|
|
|
uint32_t temppal, tempvis, tempxrepeat, tempyrepeat, tempxpanning=0, tempypanning=0;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t tempshade, tempxvel, tempyvel, tempzvel;
|
2016-11-01 01:35:41 +00:00
|
|
|
int32_t tempstatnum=0, tempblend=0;
|
2009-01-09 09:29:17 +00:00
|
|
|
char somethingintab = 255;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-06-01 20:09:19 +00:00
|
|
|
// Only valid when highlightsectorcnt>0 and no structural
|
|
|
|
// modifications (deleting/inserting sectors or points, setting new firstwall)
|
|
|
|
// have been made:
|
|
|
|
static int16_t onextwall[MAXWALLS]; // onextwall[i]>=0 implies wall[i].nextwall < 0
|
|
|
|
static void mkonwvalid(void) { chsecptr_onextwall = onextwall; }
|
|
|
|
static void mkonwinvalid(void) { chsecptr_onextwall = NULL; tempsectornum=-1; }
|
2012-06-01 20:09:22 +00:00
|
|
|
static void mkonwinvalid_keeptempsect(void) { chsecptr_onextwall = NULL; }
|
2012-06-01 20:09:19 +00:00
|
|
|
static int32_t onwisvalid(void) { return chsecptr_onextwall != NULL; }
|
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
int32_t mlook = 0, mskip=0;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t revertCTRL=0,scrollamount=3;
|
|
|
|
int32_t unrealedlook=1, quickmapcycling=1; //PK
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-05-05 16:21:33 +00:00
|
|
|
char program_origcwd[BMAX_PATH];
|
2011-06-16 19:39:22 +00:00
|
|
|
const char *mapster32_fullpath;
|
2009-05-05 16:21:33 +00:00
|
|
|
char *testplay_addparam = 0;
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
static char boardfilename[BMAX_PATH], selectedboardfilename[BMAX_PATH];
|
2011-10-31 19:50:06 +00:00
|
|
|
//extern char levelname[BMAX_PATH]; // in astub.c XXX: clean up this mess!!!
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2013-10-28 21:26:25 +00:00
|
|
|
void B_SetBoardFileName(const char *fn)
|
|
|
|
{
|
|
|
|
Bstrncpyz(boardfilename, fn, BMAX_PATH);
|
|
|
|
}
|
|
|
|
|
2012-03-28 19:42:16 +00:00
|
|
|
static fnlist_t fnlist;
|
|
|
|
static CACHE1D_FIND_REC *finddirshigh=NULL, *findfileshigh=NULL;
|
2009-01-09 09:29:17 +00:00
|
|
|
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];
|
2011-11-26 14:12:15 +00:00
|
|
|
// used for fillsector, batch point insertion, backup_highlighted_map
|
2011-07-09 17:36:02 +00:00
|
|
|
static int32_t tempxyar[MAXWALLS][2];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static int32_t mousx, mousy;
|
2011-05-22 21:52:22 +00:00
|
|
|
int16_t prefixtiles[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
2010-11-20 16:47:18 +00:00
|
|
|
uint8_t hlsectorbitmap[MAXSECTORS>>3]; // show2dsector is already taken...
|
2011-12-03 13:13:08 +00:00
|
|
|
static int32_t minhlsectorfloorz, numhlsecwalls;
|
2015-07-10 07:56:48 +00:00
|
|
|
int32_t searchlock = 0;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2012-06-26 19:50:02 +00:00
|
|
|
// used for:
|
|
|
|
// - hl_all_bunch_sectors_p
|
|
|
|
// - AlignWalls
|
|
|
|
// - trace_loop
|
|
|
|
static uint8_t visited[MAXWALLS>>3];
|
2011-03-05 12:59:27 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
int32_t m32_2d3dmode = 0;
|
|
|
|
int32_t m32_2d3dsize = 4;
|
2017-02-05 20:58:33 +00:00
|
|
|
vec2_t m32_2d3d = { 0xffff, 4 };
|
2015-07-08 03:34:42 +00:00
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int16_t numsectors, numwalls, numsprites;
|
2011-11-26 22:39:50 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
int16_t numyaxbunches;
|
|
|
|
int16_t *bunchnum; // [numsectors][2]
|
|
|
|
int16_t *ynextwall; // [numwalls][2]
|
|
|
|
#endif
|
2016-06-21 00:33:58 +00:00
|
|
|
usectortype *sector;
|
|
|
|
uwalltype *wall;
|
|
|
|
uspritetype *sprite;
|
2010-11-27 22:12:24 +00:00
|
|
|
} mapinfofull_t;
|
|
|
|
|
2012-07-08 21:47:23 +00:00
|
|
|
int32_t g_doScreenShot;
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
#define eitherALT (keystatus[0x38]|keystatus[0xb8])
|
|
|
|
#define eitherCTRL (keystatus[0x1d]|keystatus[0x9d])
|
|
|
|
#define eitherSHIFT (keystatus[0x2a]|keystatus[0x36])
|
|
|
|
|
|
|
|
#define DOWN_BK(BuildKey) (keystatus[buildkeys[BK_##BuildKey]])
|
|
|
|
|
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
|
|
|
|
2013-01-16 20:38:56 +00:00
|
|
|
int8_t keeptexturestretch = 1;
|
2010-11-27 22:12:24 +00:00
|
|
|
int8_t sideview_reversehrot = 0;
|
|
|
|
|
2017-07-05 05:37:55 +00:00
|
|
|
int16_t pointhighlightdist = 256;
|
2016-01-15 07:58:57 +00:00
|
|
|
int16_t linehighlightdist = 1024;
|
|
|
|
|
2009-05-08 23:13:12 +00:00
|
|
|
char lastpm16buf[156];
|
2009-05-01 06:35:27 +00:00
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
//static int32_t checksectorpointer_warn = 0;
|
2011-11-11 20:05:29 +00:00
|
|
|
static int32_t saveboard_savedtags, saveboard_fixedsprites;
|
2013-06-28 14:07:44 +00:00
|
|
|
static int32_t saveboard_canceled;
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2013-04-21 19:55:22 +00:00
|
|
|
static int32_t backup_highlighted_map(mapinfofull_t *mapinfo);
|
|
|
|
static int32_t restore_highlighted_map(mapinfofull_t *mapinfo, int32_t forreal);
|
|
|
|
static void SaveBoardAndPrintMessage(const char *fn);
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static int32_t adjustmark(int32_t *xplc, int32_t *yplc, int16_t danumwalls);
|
|
|
|
static void locktogrid(int32_t *dax, int32_t *day);
|
|
|
|
static int32_t checkautoinsert(int32_t dax, int32_t day, int16_t danumwalls);
|
2012-10-07 15:26:17 +00:00
|
|
|
static void keytimerstuff(void);
|
2010-05-18 05:14:17 +00:00
|
|
|
static void flipwalls(int16_t numwalls, int16_t newnumwalls);
|
2011-11-25 09:51:53 +00:00
|
|
|
static int32_t insertpoint(int16_t linehighlight, int32_t dax, int32_t day, int32_t *mapwallnum);
|
2012-04-08 15:52:49 +00:00
|
|
|
static void deletepoint(int16_t point, int32_t runi);
|
2010-05-18 05:14:17 +00:00
|
|
|
static int32_t deletesector(int16_t sucksect);
|
2011-03-13 11:59:32 +00:00
|
|
|
static int16_t whitelinescan(int16_t sucksect, int16_t dalinehighlight);
|
2012-10-07 15:26:17 +00:00
|
|
|
static void printcoords16(int32_t posxe, int32_t posye, int16_t ange);
|
|
|
|
static void overheadeditor(void);
|
2013-08-19 19:27:02 +00:00
|
|
|
static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line, int8_t ignore_pointhighlight);
|
2010-05-18 05:14:17 +00:00
|
|
|
static int32_t movewalls(int32_t start, int32_t offs);
|
2015-11-01 19:56:22 +00:00
|
|
|
static void loadnames(const char *namesfile);
|
2011-04-11 22:28:58 +00:00
|
|
|
static void getclosestpointonwall(int32_t x, int32_t y, int32_t dawall, int32_t *nx, int32_t *ny,
|
|
|
|
int32_t maybe_screen_coord_p);
|
2010-05-18 05:14:17 +00:00
|
|
|
static void initcrc(void);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static int32_t menuselect(void);
|
2015-07-08 03:34:46 +00:00
|
|
|
static int32_t menuselect_auto(int, int); //PK
|
2008-05-15 03:16:38 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
static int32_t insert_sprite_common(int32_t sucksect, int32_t dax, int32_t day);
|
|
|
|
static void correct_ornamented_sprite(int32_t i, int32_t hitw);
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static int32_t getfilenames(const char *path, const char *kind);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2013-05-12 18:51:19 +00:00
|
|
|
// Get basename of BUILD file name (forward slashes as directory separators).
|
|
|
|
static const char *getbasefn(const char *fn)
|
|
|
|
{
|
|
|
|
const char *slash = Bstrrchr(fn, '/');
|
|
|
|
return slash ? slash+1 : fn;
|
|
|
|
}
|
2013-04-21 19:55:22 +00:00
|
|
|
|
2012-10-07 15:26:17 +00:00
|
|
|
void clearkeys(void)
|
|
|
|
{
|
|
|
|
Bmemset(keystatus,0,sizeof(keystatus));
|
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2010-12-19 22:47:10 +00:00
|
|
|
#ifdef USE_OPENGL
|
2017-06-27 02:24:14 +00:00
|
|
|
int32_t osdcmd_restartvid(osdfuncparm_t const * const UNUSED(parm))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2017-06-27 02:24:14 +00:00
|
|
|
UNREFERENCED_CONST_PARAMETER(parm);
|
2008-03-23 00:06:42 +00:00
|
|
|
|
2013-05-30 09:13:32 +00:00
|
|
|
if (!in3dmode()) return OSDCMD_OK;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoResetMode();
|
|
|
|
if (videoSetGameMode(fullscreen,xdim,ydim,bpp))
|
2006-04-24 19:04:22 +00:00
|
|
|
OSD_Printf("restartvid: Reset failed...\n");
|
|
|
|
|
|
|
|
return OSDCMD_OK;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2012-01-27 15:03:34 +00:00
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2017-06-27 02:24:14 +00:00
|
|
|
static int32_t osdcmd_vidmode(osdfuncparm_t const * const parm)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2012-05-20 07:25:25 +00:00
|
|
|
int32_t newx = xdim, newy = ydim, newbpp = bpp, newfullscreen = fullscreen;
|
|
|
|
#ifdef USE_OPENGL
|
|
|
|
int32_t tmp;
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
switch (parm->numparms)
|
|
|
|
{
|
2012-01-27 15:03:34 +00:00
|
|
|
#ifdef USE_OPENGL
|
2006-04-24 19:04:22 +00:00
|
|
|
case 1: // bpp switch
|
2009-07-11 22:20:15 +00:00
|
|
|
tmp = Batol(parm->parms[0]);
|
2012-02-04 14:30:17 +00:00
|
|
|
if (!(tmp==8 || tmp==16 || tmp==32))
|
|
|
|
return OSDCMD_SHOWHELP;
|
|
|
|
newbpp = tmp;
|
2012-02-04 21:34:08 +00:00
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case 4: // fs, res, bpp switch
|
|
|
|
newfullscreen = (Batol(parm->parms[3]) != 0);
|
2017-07-18 20:53:41 +00:00
|
|
|
fallthrough__;
|
2006-04-24 19:04:22 +00:00
|
|
|
case 3: // res & bpp switch
|
2009-07-11 22:20:15 +00:00
|
|
|
tmp = Batol(parm->parms[2]);
|
2012-02-04 14:30:17 +00:00
|
|
|
if (!(tmp==8 || tmp==16 || tmp==32))
|
|
|
|
return OSDCMD_SHOWHELP;
|
|
|
|
newbpp = tmp;
|
2017-07-18 20:53:41 +00:00
|
|
|
fallthrough__;
|
2012-01-27 15:03:34 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
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
|
|
|
|
2013-05-30 09:13:32 +00:00
|
|
|
if (!in3dmode())
|
2008-02-21 05:11:41 +00:00
|
|
|
{
|
2018-04-12 21:02:51 +00:00
|
|
|
videoSet2dMode(newx,newy);
|
2008-02-21 05:11:41 +00:00
|
|
|
xdim2d = xdim;
|
|
|
|
ydim2d = ydim;
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoBeginDrawing(); //{{{
|
2010-07-03 08:53:57 +00:00
|
|
|
CLEARLINES2D(0, ydim16, 0);
|
2018-04-12 21:02:51 +00:00
|
|
|
videoEndDrawing(); //}}}
|
2008-02-21 05:11:41 +00:00
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2011-03-13 11:59:32 +00:00
|
|
|
|
2008-02-21 05:11:41 +00:00
|
|
|
return OSDCMD_OK;
|
|
|
|
}
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
if (videoSetGameMode(newfullscreen,newx,newy,newbpp))
|
2006-04-24 19:04:22 +00:00
|
|
|
OSD_Printf("vidmode: Mode change failed!\n");
|
2010-05-18 05:14:17 +00:00
|
|
|
|
|
|
|
xdimgame = newx;
|
|
|
|
ydimgame = newy;
|
|
|
|
bppgame = newbpp;
|
|
|
|
fullscreen = newfullscreen;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
return OSDCMD_OK;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-07-11 22:20:15 +00:00
|
|
|
|
|
|
|
#ifdef M32_SHOWDEBUG
|
2010-09-06 23:08:35 +00:00
|
|
|
char m32_debugstr[64][128];
|
|
|
|
int32_t m32_numdebuglines=0;
|
2009-07-11 22:20:15 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static void M32_drawdebug(void)
|
2009-07-11 22:20:15 +00:00
|
|
|
{
|
2012-01-19 21:57:22 +00:00
|
|
|
int32_t i;
|
|
|
|
int32_t x=4, y=8;
|
2009-07-11 22:20:15 +00:00
|
|
|
|
2011-02-15 21:02:43 +00:00
|
|
|
#if 0
|
|
|
|
{
|
|
|
|
static char tstr[128];
|
2011-03-17 23:37:38 +00:00
|
|
|
Bsprintf(tstr, "search... stat=%d, sector=%d, wall=%d (%d), isbottom=%d, asksave=%d",
|
|
|
|
searchstat, searchsector, searchwall, searchbottomwall, searchisbottom, asksave);
|
2011-02-15 21:02:43 +00:00
|
|
|
printext256(x,y,whitecol,0,tstr,xdimgame>640?0:1);
|
|
|
|
}
|
|
|
|
#endif
|
2011-03-08 23:02:38 +00:00
|
|
|
if (m32_numdebuglines>0)
|
2009-07-11 22:20:15 +00:00
|
|
|
{
|
2018-04-12 21:02:51 +00:00
|
|
|
videoBeginDrawing();
|
2011-05-07 18:23:34 +00:00
|
|
|
for (i=0; i<m32_numdebuglines && y<ydim-8; i++, y+=8)
|
2011-03-08 23:02:38 +00:00
|
|
|
printext256(x,y,whitecol,0,m32_debugstr[i],xdimgame>640?0:1);
|
2018-04-12 21:02:51 +00:00
|
|
|
videoEndDrawing();
|
2009-07-11 22:20:15 +00:00
|
|
|
}
|
|
|
|
m32_numdebuglines=0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2011-05-12 23:31:13 +00:00
|
|
|
// Check whether bunchnum has exactly one corresponding floor and ceiling
|
|
|
|
// and return it in this case. If not 1-to-1, return -1.
|
|
|
|
int32_t yax_is121(int16_t bunchnum, int16_t getfloor)
|
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
i = headsectbunch[0][bunchnum];
|
|
|
|
if (i<0 || nextsectbunch[0][i]>=0)
|
|
|
|
return -1;
|
|
|
|
i = headsectbunch[1][bunchnum];
|
|
|
|
if (i<0 || nextsectbunch[1][i]>=0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return headsectbunch[getfloor][bunchnum];
|
|
|
|
}
|
|
|
|
|
2011-05-29 23:10:51 +00:00
|
|
|
static int32_t yax_numsectsinbunch(int16_t bunchnum, int16_t cf)
|
|
|
|
{
|
|
|
|
int32_t i, n=0;
|
|
|
|
|
|
|
|
if (bunchnum<0 || bunchnum>=numyaxbunches)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
for (SECTORS_OF_BUNCH(bunchnum, cf, i))
|
|
|
|
n++;
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2011-05-02 16:58:11 +00:00
|
|
|
static void yax_fixreverselinks(int16_t oldwall, int16_t newwall)
|
2011-04-11 22:28:58 +00:00
|
|
|
{
|
2011-05-02 16:58:11 +00:00
|
|
|
int32_t cf, ynw;
|
|
|
|
for (cf=0; cf<2; cf++)
|
2011-04-11 22:28:58 +00:00
|
|
|
{
|
2011-05-02 16:58:11 +00:00
|
|
|
ynw = yax_getnextwall(oldwall, cf);
|
|
|
|
if (ynw >= 0)
|
|
|
|
yax_setnextwall(ynw, !cf, newwall);
|
2011-04-11 22:28:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-02 16:58:11 +00:00
|
|
|
static void yax_tweakwalls(int16_t start, int16_t offs)
|
|
|
|
{
|
|
|
|
int32_t i, nw, cf;
|
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
for (cf=0; cf<2; cf++)
|
|
|
|
{
|
|
|
|
nw = yax_getnextwall(i, cf);
|
|
|
|
if (nw >= start)
|
|
|
|
yax_setnextwall(i, cf, nw+offs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
static void yax_resetbunchnums(void)
|
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
|
|
|
|
for (i=0; i<MAXSECTORS; i++)
|
|
|
|
yax_setbunches(i, -1, -1);
|
2011-03-25 11:42:07 +00:00
|
|
|
yax_update(1);
|
2011-04-22 22:48:06 +00:00
|
|
|
yax_updategrays(pos.z);
|
2011-03-23 17:41:01 +00:00
|
|
|
}
|
|
|
|
|
2011-03-25 11:42:07 +00:00
|
|
|
// Whether a wall is constrained by sector extensions.
|
|
|
|
// If false, it's a wall that you can freely move around,
|
|
|
|
// attach points to, etc...
|
2011-10-30 19:48:13 +00:00
|
|
|
static int32_t yax_islockedwall(int16_t line)
|
2011-04-11 22:28:58 +00:00
|
|
|
{
|
2013-04-09 17:35:11 +00:00
|
|
|
#ifdef NEW_MAP_FORMAT
|
|
|
|
return (wall[line].upwall>=0 || wall[line].dnwall>=0);
|
|
|
|
#else
|
2011-04-11 22:28:58 +00:00
|
|
|
return !!(wall[line].cstat&YAX_NEXTWALLBITS);
|
2013-04-09 17:35:11 +00:00
|
|
|
#endif
|
2011-04-11 22:28:58 +00:00
|
|
|
}
|
2011-03-25 11:42:07 +00:00
|
|
|
|
2011-05-29 23:10:51 +00:00
|
|
|
# define DEFAULT_YAX_HEIGHT (2048<<4)
|
2011-03-13 11:59:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static void reset_default_mapstate(void)
|
|
|
|
{
|
|
|
|
pos.x = 32768; //new board!
|
|
|
|
pos.y = 32768;
|
|
|
|
pos.z = 0;
|
|
|
|
ang = 1536;
|
2011-03-23 17:41:01 +00:00
|
|
|
cursectnum = -1;
|
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
numsectors = 0;
|
|
|
|
numwalls = 0;
|
2011-03-23 17:41:01 +00:00
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
editorzrange[0] = INT32_MIN;
|
|
|
|
editorzrange[1] = INT32_MAX;
|
2011-05-07 18:23:34 +00:00
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
initspritelists();
|
2011-04-17 17:01:20 +00:00
|
|
|
taglab_init();
|
2018-04-12 21:03:30 +00:00
|
|
|
artClearMapArt();
|
2011-03-13 11:59:32 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_resetbunchnums();
|
|
|
|
#endif
|
2013-06-28 14:07:44 +00:00
|
|
|
g_loadedMapVersion = -1;
|
2011-03-13 11:59:32 +00:00
|
|
|
}
|
|
|
|
|
2011-11-25 09:51:06 +00:00
|
|
|
static void m32_keypresscallback(int32_t code, int32_t downp)
|
|
|
|
{
|
2011-11-25 09:51:21 +00:00
|
|
|
UNREFERENCED_PARAMETER(downp);
|
|
|
|
|
2011-11-25 09:51:06 +00:00
|
|
|
g_iReturnVar = code;
|
|
|
|
VM_OnEvent(EVENT_KEYPRESS, -1);
|
|
|
|
}
|
|
|
|
|
2012-02-16 19:25:42 +00:00
|
|
|
void M32_ResetFakeRORTiles(void)
|
|
|
|
{
|
|
|
|
#ifdef POLYMER
|
|
|
|
# ifdef YAX_ENABLE
|
|
|
|
// END_TWEAK ceiling/floor fake 'TROR' pics, see BEGIN_TWEAK in engine.c
|
2018-04-12 21:03:12 +00:00
|
|
|
if (videoGetRenderMode() == REND_POLYMER && showinvisibility)
|
2012-02-16 19:25:42 +00:00
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
|
|
|
|
for (i=0; i<numyaxbunches; i++)
|
|
|
|
{
|
|
|
|
yax_tweakpicnums(i, YAX_CEILING, 1);
|
|
|
|
yax_tweakpicnums(i, YAX_FLOOR, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-02-04 21:33:52 +00:00
|
|
|
void M32_DrawRoomsAndMasks(void)
|
|
|
|
{
|
2015-01-06 19:56:41 +00:00
|
|
|
static int srchwall = -1;
|
2015-05-10 10:55:30 +00:00
|
|
|
const int32_t tmpyx=yxaspect, tmpvr=viewingrange;
|
|
|
|
|
|
|
|
if (r_usenewaspect)
|
|
|
|
{
|
|
|
|
newaspect_enable = 1;
|
2018-04-12 21:02:51 +00:00
|
|
|
videoSetCorrectedAspect();
|
2015-05-10 10:55:30 +00:00
|
|
|
}
|
2015-01-06 19:56:41 +00:00
|
|
|
|
2013-04-05 17:53:31 +00:00
|
|
|
VM_OnEvent(EVENT_PREDRAW3DSCREEN, -1);
|
|
|
|
|
2012-02-04 21:33:52 +00:00
|
|
|
yax_preparedrawrooms();
|
|
|
|
drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum);
|
2014-07-24 14:01:44 +00:00
|
|
|
yax_drawrooms(CallExtAnalyzeSprites, cursectnum, 0, 0);
|
2012-02-04 21:33:52 +00:00
|
|
|
|
2015-01-06 19:56:41 +00:00
|
|
|
const int osearchwall=searchwall, osearchstat=searchstat;
|
|
|
|
if (srchwall >= 0)
|
|
|
|
{
|
|
|
|
// a.m32 states 'tduprot' and 'tduplin' need searchstat to check for
|
|
|
|
// whether we've hit a sprite, but these would be only set after the
|
|
|
|
// drawmasks(). Hence this hackish workaround.
|
|
|
|
searchstat = 3;
|
|
|
|
searchwall = srchwall;
|
|
|
|
}
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtAnalyzeSprites(0,0,0,0);
|
2015-01-06 19:56:41 +00:00
|
|
|
searchwall = osearchwall, searchstat=osearchstat;
|
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
renderDrawMasks();
|
2015-01-06 19:56:41 +00:00
|
|
|
srchwall = (searchstat == 3) ? searchwall : -1;
|
2012-02-16 19:25:42 +00:00
|
|
|
M32_ResetFakeRORTiles();
|
2012-02-04 21:33:52 +00:00
|
|
|
|
|
|
|
#ifdef POLYMER
|
2018-04-12 21:03:12 +00:00
|
|
|
if (videoGetRenderMode() == REND_POLYMER && searchit == 2)
|
2012-02-04 21:33:52 +00:00
|
|
|
{
|
|
|
|
polymer_editorpick();
|
|
|
|
drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum);
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtAnalyzeSprites(0,0,0,0);
|
2018-04-12 21:03:47 +00:00
|
|
|
renderDrawMasks();
|
2012-02-16 19:25:42 +00:00
|
|
|
M32_ResetFakeRORTiles();
|
2012-02-04 21:33:52 +00:00
|
|
|
}
|
|
|
|
#endif
|
2012-07-08 21:47:23 +00:00
|
|
|
|
|
|
|
VM_OnEvent(EVENT_DRAW3DSCREEN, -1);
|
|
|
|
|
|
|
|
if (g_doScreenShot)
|
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
videoCaptureScreen("mcapxxxx.tga", 0);
|
2012-07-08 21:47:23 +00:00
|
|
|
g_doScreenShot = 0;
|
|
|
|
}
|
2015-05-10 10:55:30 +00:00
|
|
|
|
|
|
|
if (r_usenewaspect)
|
|
|
|
{
|
|
|
|
newaspect_enable = 0;
|
2018-04-12 21:03:47 +00:00
|
|
|
renderSetAspect(tmpvr, tmpyx);
|
2015-05-10 10:55:30 +00:00
|
|
|
}
|
2012-02-04 21:33:52 +00:00
|
|
|
}
|
|
|
|
|
2015-08-08 11:03:07 +00:00
|
|
|
void M32_OnShowOSD(int32_t shown)
|
|
|
|
{
|
2018-04-12 21:02:31 +00:00
|
|
|
mouseLockToWindow((!shown) + 2);
|
2015-08-08 11:03:07 +00:00
|
|
|
}
|
|
|
|
|
2015-09-23 17:54:42 +00:00
|
|
|
static void M32_FatalEngineError(void)
|
|
|
|
{
|
|
|
|
wm_msgbox("Build Engine Initialization Error",
|
|
|
|
"There was a problem initializing the Build engine: %s", engineerrstr);
|
|
|
|
ERRprintf("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr);
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
2016-08-27 01:41:04 +00:00
|
|
|
int app_main(int argc, char const * const * argv)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-10-17 18:42:10 +00:00
|
|
|
#ifdef STARTUP_SETUP_WINDOW
|
|
|
|
char cmdsetup = 0;
|
|
|
|
#endif
|
|
|
|
char quitflag;
|
2015-02-08 18:48:30 +00:00
|
|
|
int32_t i;
|
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);
|
2013-08-12 15:18:19 +00:00
|
|
|
baselayer_osdcmd_vidmode_func = osdcmd_vidmode;
|
2012-01-27 15:03:34 +00:00
|
|
|
#else
|
|
|
|
OSD_RegisterFunction("vidmode","vidmode <xdim> <ydim>: immediately change the video mode",osdcmd_vidmode);
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
2013-08-12 15:18:19 +00:00
|
|
|
|
2014-07-28 06:43:16 +00:00
|
|
|
wm_setapptitle(AppProperName);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-09-06 23:08:35 +00:00
|
|
|
editstatus = 1;
|
2010-10-22 23:12:59 +00:00
|
|
|
|
2014-07-24 14:01:44 +00:00
|
|
|
if ((i = CallExtPreInit(argc,argv)) < 0) return -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-11-25 04:26:37 +00:00
|
|
|
#ifdef _WIN32
|
2006-04-24 19:04:22 +00:00
|
|
|
backgroundidle = 1;
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
for (i=1; i<argc; i++)
|
|
|
|
{
|
|
|
|
if (argv[i][0] == '-')
|
|
|
|
{
|
2011-10-17 18:42:10 +00:00
|
|
|
#ifdef STARTUP_SETUP_WINDOW
|
2010-05-18 05:14:17 +00:00
|
|
|
if (!Bstrcmp(argv[i], "-setup")) cmdsetup = 1;
|
2011-10-17 18:42:10 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (!Bstrcmp(argv[i], "-help") || !Bstrcmp(argv[i], "--help") || !Bstrcmp(argv[i], "-?"))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2014-07-28 06:43:16 +00:00
|
|
|
#ifdef WM_MSGBOX_WINDOW
|
|
|
|
wm_msgbox(AppProperName,
|
|
|
|
#else
|
|
|
|
Bprintf(
|
|
|
|
#endif
|
|
|
|
"%s\n"
|
|
|
|
"Syntax: %s [options] mapname\n"
|
2006-04-24 19:04:22 +00:00
|
|
|
"Options:\n"
|
|
|
|
"\t-grp\tUse an extra GRP or ZIP file.\n"
|
|
|
|
"\t-g\tSame as above.\n"
|
2011-10-17 18:42:10 +00:00
|
|
|
#ifdef STARTUP_SETUP_WINDOW
|
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
|
2014-07-28 06:43:16 +00:00
|
|
|
, AppProperName, AppTechnicalName);
|
2006-04-24 19:04:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2013-05-12 18:51:16 +00:00
|
|
|
|
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
|
|
|
|
2014-07-28 06:43:16 +00:00
|
|
|
OSD_SetFunctions(
|
|
|
|
NULL, NULL, NULL, NULL, NULL,
|
|
|
|
COMMON_clearbackground,
|
|
|
|
BGetTime,
|
2015-08-08 11:03:07 +00:00
|
|
|
M32_OnShowOSD
|
2014-07-28 06:43:16 +00:00
|
|
|
);
|
|
|
|
|
2014-07-28 06:42:28 +00:00
|
|
|
if (!getcwd(program_origcwd,BMAX_PATH))
|
|
|
|
program_origcwd[0] = '\0';
|
|
|
|
|
2014-07-28 06:43:16 +00:00
|
|
|
Bstrncpy(game_executable, DefaultGameLocalExec, sizeof(game_executable));
|
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
if (enginePreInit())
|
2015-09-23 17:54:42 +00:00
|
|
|
M32_FatalEngineError();
|
2014-11-22 12:27:57 +00:00
|
|
|
|
2014-07-24 14:01:44 +00:00
|
|
|
if ((i = CallExtInit()) < 0) return -1;
|
2014-07-28 06:42:28 +00:00
|
|
|
|
2011-10-17 18:42:10 +00:00
|
|
|
#ifdef STARTUP_SETUP_WINDOW
|
2007-12-12 17:42:14 +00:00
|
|
|
if (i || forcesetup || cmdsetup)
|
|
|
|
{
|
2011-01-16 02:50:27 +00:00
|
|
|
if (quitevent || !startwin_run())
|
2010-07-03 08:53:57 +00:00
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
engineUnInit();
|
2014-06-13 09:02:37 +00:00
|
|
|
Bexit(0);
|
2010-07-03 08:53:57 +00:00
|
|
|
}
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
|
|
|
|
2014-07-28 06:42:28 +00:00
|
|
|
if (CallExtPostStartupWindow() < 0) return -1;
|
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
loadnames(g_namesFileName);
|
2010-10-09 22:59:17 +00:00
|
|
|
|
2006-11-17 05:05:16 +00:00
|
|
|
if (initinput()) return -1;
|
2011-03-08 23:02:38 +00:00
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
mouseInit();
|
2006-11-17 05:05:16 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
timerInit(TIMERINTSPERSECOND);
|
|
|
|
timerSetCallback(keytimerstuff);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-04-12 21:03:30 +00:00
|
|
|
artLoadFiles("tiles000.art", g_maxCacheSize);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-10-10 06:57:57 +00:00
|
|
|
Bstrcpy(kensig,"Uses BUILD technology by Ken Silverman");
|
|
|
|
initcrc();
|
|
|
|
|
|
|
|
const char *defsfile = G_DefFile();
|
|
|
|
|
|
|
|
if (!loaddefinitionsfile(defsfile))
|
|
|
|
initprintf("Definitions file \"%s\" loaded.\n",defsfile);
|
|
|
|
|
2018-02-17 22:30:39 +00:00
|
|
|
for (char * m : g_defModules)
|
|
|
|
free(m);
|
|
|
|
g_defModules.clear();
|
2015-10-10 06:57:57 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
if (enginePostInit())
|
2015-10-10 06:57:57 +00:00
|
|
|
M32_FatalEngineError();
|
|
|
|
|
|
|
|
CallExtPostInit();
|
|
|
|
|
2011-04-22 22:48:06 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
// init dummy texture for YAX
|
|
|
|
// must be after loadpics(), which inits BUILD's cache
|
|
|
|
|
2011-05-23 22:42:39 +00:00
|
|
|
i = MAXTILES-1;
|
2016-08-28 21:26:51 +00:00
|
|
|
if (tilesiz[i].x==0 && tilesiz[i].y==0)
|
2011-05-23 22:42:39 +00:00
|
|
|
{
|
|
|
|
static char R[8*16] = { //
|
|
|
|
0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0,
|
|
|
|
0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0,
|
|
|
|
0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0,
|
|
|
|
0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0,
|
|
|
|
0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0,
|
|
|
|
0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0,
|
|
|
|
0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
char *newtile;
|
|
|
|
int32_t sx=32, sy=32, col, j;
|
|
|
|
|
|
|
|
walock[i] = 255; // permanent tile
|
|
|
|
picsiz[i] = 5 + (5<<4);
|
2014-09-30 04:14:21 +00:00
|
|
|
tilesiz[i].x = sx; tilesiz[i].y = sy;
|
2018-04-12 21:03:30 +00:00
|
|
|
cacheAllocateBlock(&waloff[i], sx*sy, &walock[i]);
|
2011-05-23 22:42:39 +00:00
|
|
|
newtile = (char *)waloff[i];
|
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
col = paletteGetClosestColor(128, 128, 0);
|
2011-05-23 22:42:39 +00:00
|
|
|
for (j=0; j<(signed)sizeof(R); j++)
|
|
|
|
R[j] *= col;
|
|
|
|
|
|
|
|
Bmemset(newtile, 0, sx*sy);
|
|
|
|
for (j=0; j<8; j++)
|
|
|
|
Bmemcpy(&newtile[32*j], &R[16*j], 16);
|
|
|
|
}
|
2011-04-22 22:48:06 +00:00
|
|
|
#endif
|
|
|
|
|
2012-03-18 08:50:41 +00:00
|
|
|
#ifdef HAVE_CLIPSHAPE_FEATURE
|
2018-04-12 21:03:47 +00:00
|
|
|
int k = engineLoadClipMaps();
|
2010-11-20 16:47:18 +00:00
|
|
|
if (k>0)
|
2010-10-31 19:54:03 +00:00
|
|
|
initprintf("There was an error loading the sprite clipping map (status %d).\n", k);
|
2012-03-18 08:50:41 +00:00
|
|
|
|
2018-02-17 22:30:39 +00:00
|
|
|
for (char * f : g_clipMapFiles)
|
|
|
|
free(f);
|
|
|
|
g_clipMapFiles.clear();
|
Inreased debugging level for catching oob accesses to 'main' arrays.
If enabled, this makes the following arrays be allocated statically:
spriteext, spritesmooth, sector, wall, sprite, tsprite, while
necessarily disabling the clipshape feature (because it relies on
setting sector/wall to different malloc'd block temporarily).
To compile, pass DEBUGANYWAY=1 in addition to RELEASE=0 to 'make',
and it's really only useful with CC=clang, of course.
git-svn-id: https://svn.eduke32.com/eduke32@2270 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-19 23:17:34 +00:00
|
|
|
#endif
|
2010-10-28 20:17:22 +00:00
|
|
|
|
2011-04-17 17:01:20 +00:00
|
|
|
taglab_init();
|
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
mkonwinvalid();
|
|
|
|
|
2017-06-23 03:58:01 +00:00
|
|
|
// executed once per init
|
|
|
|
OSD_Exec("m32_autoexec.cfg");
|
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
if (LoadBoard(boardfilename, 1))
|
2011-03-13 11:59:32 +00:00
|
|
|
reset_default_mapstate();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
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
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
keySetCallback(&m32_keypresscallback);
|
2015-08-08 11:03:07 +00:00
|
|
|
M32_OnShowOSD(0); // make sure the desktop's mouse cursor is hidden
|
2011-11-25 09:51:06 +00:00
|
|
|
|
2007-01-15 00:38:21 +00:00
|
|
|
if (cursectnum == -1)
|
|
|
|
{
|
2018-04-12 21:02:51 +00:00
|
|
|
vid_gamma_3d = g_videoGamma;
|
|
|
|
vid_brightness_3d = g_videoBrightness;
|
|
|
|
vid_contrast_3d = g_videoContrast;
|
2010-08-02 18:59:59 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
g_videoGamma = g_videoContrast = 1.0;
|
|
|
|
g_videoBrightness = 0.0;
|
2010-07-03 08:53:57 +00:00
|
|
|
|
2018-04-12 21:03:12 +00:00
|
|
|
videoSetPalette(0,0,0);
|
2018-04-12 21:02:51 +00:00
|
|
|
if (videoSetGameMode(fullscreen, xdim2d, ydim2d, 8) < 0)
|
2009-05-06 23:58:53 +00:00
|
|
|
{
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtUnInit();
|
2018-04-12 21:03:47 +00:00
|
|
|
engineUnInit();
|
2009-05-06 23:58:53 +00:00
|
|
|
Bprintf("%d * %d not supported in this graphics mode\n",xdim2d,ydim2d);
|
2014-06-13 09:02:37 +00:00
|
|
|
Bexit(0);
|
2009-05-06 23:58:53 +00:00
|
|
|
}
|
2010-08-11 22:37:45 +00:00
|
|
|
|
2013-10-08 10:00:25 +00:00
|
|
|
system_getcvars();
|
|
|
|
|
2007-01-15 00:38:21 +00:00
|
|
|
overheadeditor();
|
2008-05-16 00:23:33 +00:00
|
|
|
keystatus[buildkeys[BK_MODE2D_3D]] = 0;
|
2010-08-02 18:59:59 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
g_videoGamma = vid_gamma_3d;
|
|
|
|
g_videoContrast = vid_contrast_3d;
|
|
|
|
g_videoBrightness = vid_brightness_3d;
|
2010-08-02 18:59:59 +00:00
|
|
|
|
|
|
|
vid_gamma_3d = vid_contrast_3d = vid_brightness_3d = -1;
|
2010-07-03 08:53:57 +00:00
|
|
|
|
2018-04-12 21:03:12 +00:00
|
|
|
videoSetPalette(GAMMA_CALC,0,0);
|
2007-01-15 00:38:21 +00:00
|
|
|
}
|
2009-05-01 19:28:57 +00:00
|
|
|
else
|
|
|
|
{
|
2018-04-12 21:02:51 +00:00
|
|
|
if (videoSetGameMode(fullscreen, xdimgame, ydimgame, bppgame) < 0)
|
2009-05-01 19:28:57 +00:00
|
|
|
{
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtUnInit();
|
2018-04-12 21:03:47 +00:00
|
|
|
engineUnInit();
|
2009-05-01 19:28:57 +00:00
|
|
|
Bprintf("%d * %d not supported in this graphics mode\n",xdim,ydim);
|
2014-06-13 09:02:37 +00:00
|
|
|
Bexit(0);
|
2009-05-01 19:28:57 +00:00
|
|
|
}
|
2010-08-11 22:37:45 +00:00
|
|
|
|
2013-10-08 10:00:25 +00:00
|
|
|
system_getcvars();
|
|
|
|
|
2018-04-12 21:03:12 +00:00
|
|
|
videoSetPalette(GAMMA_CALC,0,0);
|
2009-05-01 19:28:57 +00:00
|
|
|
}
|
2011-01-16 00:23:39 +00:00
|
|
|
|
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
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoNextPage();
|
2010-05-29 05:03:02 +00:00
|
|
|
synctics = totalclock-lockclock;
|
|
|
|
lockclock += synctics;
|
|
|
|
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtPreCheckKeys();
|
2011-03-23 17:41:01 +00:00
|
|
|
|
2012-02-04 21:33:52 +00:00
|
|
|
M32_DrawRoomsAndMasks();
|
2009-07-17 21:47:04 +00:00
|
|
|
|
2013-12-20 07:24:09 +00:00
|
|
|
inputchecked = 1;
|
|
|
|
|
2009-07-11 22:20:15 +00:00
|
|
|
#ifdef M32_SHOWDEBUG
|
2010-09-06 23:08:35 +00:00
|
|
|
if (searchstat>=0 && (searchwall<0 || searchsector<0))
|
|
|
|
{
|
2011-04-14 20:48:08 +00:00
|
|
|
if (m32_numdebuglines<64)
|
|
|
|
Bsprintf(m32_debugstr[m32_numdebuglines++], "inconsistent search variables!");
|
2010-09-06 23:08:35 +00:00
|
|
|
searchstat = -1;
|
|
|
|
}
|
|
|
|
|
2009-07-11 22:20:15 +00:00
|
|
|
M32_drawdebug();
|
|
|
|
#endif
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtCheckKeys();
|
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;
|
2011-01-20 10:52:33 +00:00
|
|
|
|
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
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2006-04-24 19:04:22 +00:00
|
|
|
synctics = totalclock-lockclock;
|
|
|
|
lockclock += synctics;
|
|
|
|
|
|
|
|
while ((keystatus[1]|keystatus[0x1c]|keystatus[0x39]|keystatus[0x31]) == 0)
|
|
|
|
{
|
2009-08-05 22:37:48 +00:00
|
|
|
idle_waitevent();
|
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
|
|
|
}
|
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)
|
|
|
|
{
|
2011-02-10 23:15:02 +00:00
|
|
|
i = CheckMapCorruption(4, 0);
|
2011-01-16 00:23:39 +00:00
|
|
|
|
|
|
|
printext256(0,8,whitecol,0,i<4?"Save changes?":"Map is heavily corrupt. Save changes?",0);
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(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
|
|
|
{
|
2009-08-05 22:37:48 +00:00
|
|
|
idle_waitevent();
|
2006-12-11 21:56:00 +00:00
|
|
|
if (handleevents()) { if (quitevent) break; } // like saying no
|
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
|
|
|
{
|
2011-01-16 00:23:39 +00:00
|
|
|
keystatus[0x15] = keystatus[0x1c] = 0;
|
|
|
|
|
2013-06-28 14:07:44 +00:00
|
|
|
SaveBoard(NULL, M32_SB_ASKOV);
|
2011-01-16 00:23:39 +00:00
|
|
|
|
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
|
|
|
{
|
2011-01-16 00:23:39 +00:00
|
|
|
keystatus[1] = keystatus[0x2e] = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
quitevent = 0;
|
|
|
|
goto CANCEL;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtUnInit();
|
2011-09-15 17:03:29 +00:00
|
|
|
// clearfilenames();
|
2018-04-12 21:03:47 +00:00
|
|
|
engineUnInit();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-06-21 00:34:41 +00:00
|
|
|
return 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
|
|
|
static int32_t mhk=0;
|
2012-01-05 21:58:23 +00:00
|
|
|
static void loadmhk(int32_t domessage)
|
2008-02-02 16:38:30 +00:00
|
|
|
{
|
2013-05-06 19:43:38 +00:00
|
|
|
char levname[BMAX_PATH];
|
2008-02-02 16:38:30 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (!mhk)
|
|
|
|
return;
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
Bstrcpy(levname, boardfilename);
|
2013-05-06 19:43:38 +00:00
|
|
|
append_ext_UNSAFE(levname, ".mhk");
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
if (!engineLoadMHK(levname))
|
2011-01-16 00:23:39 +00:00
|
|
|
{
|
|
|
|
if (domessage)
|
2012-03-26 05:05:57 +00:00
|
|
|
message("Loaded map hack file \"%s\"",levname);
|
2011-01-16 00:23:39 +00:00
|
|
|
else
|
2012-03-26 05:05:57 +00:00
|
|
|
initprintf("Loaded map hack file \"%s\"\n",levname);
|
2011-01-16 00:23:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mhk=2;
|
|
|
|
if (domessage)
|
2012-03-26 05:05:57 +00:00
|
|
|
message("No maphack found for map \"%s\"",boardfilename);
|
2011-01-16 00:23:39 +00:00
|
|
|
}
|
2008-02-02 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
// this is spriteon{ceiling,ground}z from astub.c packed into
|
|
|
|
// one convenient function
|
|
|
|
void spriteoncfz(int32_t i, int32_t *czptr, int32_t *fzptr)
|
|
|
|
{
|
2012-11-17 19:46:43 +00:00
|
|
|
int32_t height, zofs;
|
2011-03-23 17:41:01 +00:00
|
|
|
|
2012-11-17 19:46:43 +00:00
|
|
|
getzsofslope(sprite[i].sectnum, sprite[i].x,sprite[i].y, czptr, fzptr);
|
|
|
|
if ((sprite[i].cstat&48)==32)
|
|
|
|
return;
|
|
|
|
|
|
|
|
zofs = spriteheightofs(i, &height, 0);
|
2011-03-23 17:41:01 +00:00
|
|
|
|
2012-11-17 19:46:43 +00:00
|
|
|
*czptr += height - zofs;
|
|
|
|
*fzptr -= zofs;
|
2011-03-23 17:41:01 +00:00
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
|
|
|
|
static void move_and_update(int32_t xvect, int32_t yvect, int32_t addshr)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-09-16 19:17:48 +00:00
|
|
|
if (m32_clipping==0)
|
2011-03-08 23:02:38 +00:00
|
|
|
{
|
|
|
|
pos.x += xvect>>(14+addshr);
|
|
|
|
pos.y += yvect>>(14+addshr);
|
|
|
|
updatesector(pos.x,pos.y, &cursectnum);
|
|
|
|
}
|
|
|
|
else
|
2011-09-16 19:17:48 +00:00
|
|
|
{
|
2011-03-08 23:02:38 +00:00
|
|
|
clipmove(&pos,&cursectnum, xvect>>addshr,yvect>>addshr,
|
2011-09-16 19:17:48 +00:00
|
|
|
128,4<<8,4<<8, (m32_clipping==1) ? 0 : CLIPMASK0);
|
|
|
|
}
|
2015-07-08 03:34:27 +00:00
|
|
|
|
|
|
|
if (in3dmode())
|
|
|
|
{
|
|
|
|
silentmessage("x:%d y:%d z:%d ang:%d horiz:%d", pos.x, pos.y, pos.z, ang, horiz);
|
|
|
|
getmessagetimeoff = totalclock+30;
|
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
static void mainloop_move(void)
|
2011-03-08 23:02:38 +00:00
|
|
|
{
|
|
|
|
int32_t xvect, yvect, doubvel;
|
|
|
|
|
|
|
|
if (angvel != 0) //ang += angvel * constant
|
|
|
|
{
|
2015-07-08 03:34:42 +00:00
|
|
|
if (eitherCTRL && m32_2d3dmode)
|
|
|
|
{
|
|
|
|
int x = m32_2d3d.x + (angvel / 32);
|
|
|
|
int xx = m32_2d3d.x + XSIZE_2D3D + (angvel / 32);
|
|
|
|
|
|
|
|
if (x > 4 && xx < xdim2d - 4)
|
|
|
|
{
|
|
|
|
silentmessage("2d3d x:%d y:%d", m32_2d3d.x, m32_2d3d.y);
|
|
|
|
m32_2d3d.x += (angvel / 32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//ENGINE calculates angvel for you
|
2011-03-08 23:02:38 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
//Lt. shift makes turn velocity 50% faster
|
|
|
|
doubvel = (synctics + DOWN_BK(RUN)*(synctics>>1));
|
2008-05-15 03:16:38 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
ang += ((angvel*doubvel)>>4);
|
|
|
|
ang &= 2047;
|
2015-07-08 03:34:27 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
if (in3dmode())
|
|
|
|
{
|
|
|
|
silentmessage("x:%d y:%d z:%d ang:%d horiz:%d", pos.x, pos.y, pos.z, ang, horiz);
|
|
|
|
getmessagetimeoff = totalclock+30;
|
|
|
|
}
|
2015-07-08 03:34:27 +00:00
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
}
|
|
|
|
if ((vel|svel) != 0)
|
|
|
|
{
|
2015-07-08 03:34:42 +00:00
|
|
|
if (eitherCTRL && m32_2d3dmode)
|
2008-05-16 19:51:38 +00:00
|
|
|
{
|
2015-07-08 03:34:42 +00:00
|
|
|
int y = m32_2d3d.y - (vel / 64);
|
|
|
|
int yy = m32_2d3d.y + YSIZE_2D3D - (vel / 64);
|
|
|
|
|
|
|
|
if (y > 4 && yy < ydim2d - STATUS2DSIZ2 - 4)
|
|
|
|
{
|
|
|
|
silentmessage("2d3d x:%d y:%d", m32_2d3d.x, m32_2d3d.y);
|
|
|
|
m32_2d3d.y -= (vel / 64);
|
|
|
|
}
|
2008-05-16 19:51:38 +00:00
|
|
|
}
|
2015-07-08 03:34:42 +00:00
|
|
|
else
|
|
|
|
|
2008-05-16 19:51:38 +00:00
|
|
|
{
|
2015-07-08 03:34:42 +00:00
|
|
|
//Lt. shift doubles forward velocity
|
|
|
|
doubvel = (1+(DOWN_BK(RUN)))*synctics;
|
|
|
|
|
|
|
|
xvect = 0;
|
|
|
|
yvect = 0;
|
2011-03-08 23:02:38 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
if (vel != 0)
|
|
|
|
{
|
2015-07-08 03:34:46 +00:00
|
|
|
xvect += ((vel*doubvel)>>3)*(int32_t) sintable[(ang+2560)&2047];
|
|
|
|
yvect += ((vel*doubvel)>>3)*(int32_t) sintable[(ang+2048)&2047];
|
2015-07-08 03:34:42 +00:00
|
|
|
}
|
|
|
|
if (svel != 0)
|
|
|
|
{
|
2015-07-08 03:34:46 +00:00
|
|
|
xvect += ((svel*doubvel)>>3)*(int32_t) sintable[(ang+2048)&2047];
|
|
|
|
yvect += ((svel*doubvel)>>3)*(int32_t) sintable[(ang+1536)&2047];
|
2015-07-08 03:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
move_and_update(xvect, yvect, 0);
|
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-26 21:58:26 +00:00
|
|
|
static void handle_sprite_in_clipboard(int32_t i)
|
|
|
|
{
|
|
|
|
if (somethingintab == 3)
|
|
|
|
{
|
|
|
|
int32_t j, k;
|
|
|
|
|
|
|
|
sprite[i].picnum = temppicnum;
|
2014-09-30 04:14:21 +00:00
|
|
|
if (tilesiz[temppicnum].x <= 0 || tilesiz[temppicnum].y <= 0)
|
2012-05-26 21:58:26 +00:00
|
|
|
{
|
|
|
|
j = 0;
|
|
|
|
for (k=0; k<MAXTILES; k++)
|
2014-09-30 04:14:21 +00:00
|
|
|
if (tilesiz[k].x > 0 && tilesiz[k].y > 0)
|
2012-05-26 21:58:26 +00:00
|
|
|
{
|
|
|
|
j = k;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sprite[i].picnum = j;
|
|
|
|
}
|
|
|
|
sprite[i].shade = tempshade;
|
2017-06-10 08:19:47 +00:00
|
|
|
sprite[i].blend = tempblend;
|
2012-05-26 21:58:26 +00:00
|
|
|
sprite[i].pal = temppal;
|
|
|
|
sprite[i].xrepeat = max(tempxrepeat, 1);
|
|
|
|
sprite[i].yrepeat = max(tempyrepeat, 1);
|
|
|
|
sprite[i].cstat = tempcstat;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
void editinput(void)
|
|
|
|
{
|
|
|
|
int32_t mousz, bstatus;
|
2012-05-26 21:58:26 +00:00
|
|
|
int32_t i, tempint=0;
|
2011-03-13 11:59:32 +00:00
|
|
|
int32_t goalz, xvect, yvect, hiz, loz, oposz;
|
2015-05-26 00:47:54 +00:00
|
|
|
int32_t hihit, lohit, omlook=mlook;
|
2011-03-08 23:02: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
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
mousz = 0;
|
2018-04-12 21:03:47 +00:00
|
|
|
mouseGetValues(&mousx,&mousy,&bstatus);
|
2011-03-08 23:02:38 +00:00
|
|
|
mousx = (mousx<<16) + mousexsurp;
|
|
|
|
mousy = (mousy<<16) + mouseysurp;
|
2008-09-04 23:11:48 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
if (unrealedlook && !mskip)
|
|
|
|
{
|
|
|
|
if (mlook==0 && (bstatus&(1|2|4))==2)
|
|
|
|
mlook = 3;
|
|
|
|
else if ((bstatus&(1|2|4))==1)
|
|
|
|
mlook = 3;
|
|
|
|
}
|
2008-09-04 23:11:48 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
ldiv_t ld;
|
2008-09-04 23:11:48 +00:00
|
|
|
if (mlook)
|
|
|
|
{
|
2011-03-08 23:02:38 +00:00
|
|
|
ld = ldiv(mousx, (int32_t)((1<<16)/(msens*0.5f))); mousx = ld.quot; mousexsurp = ld.rem;
|
|
|
|
ld = ldiv(mousy, (int32_t)((1<<16)/(msens*0.25f))); mousy = ld.quot; mouseysurp = ld.rem;
|
2008-09-04 23:11:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-08 23:02:38 +00:00
|
|
|
ld = ldiv(mousx, (int32_t)((1<<16)/msens)); mousx = ld.quot; mousexsurp = ld.rem;
|
|
|
|
ld = ldiv(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)
|
2011-03-08 23:02:38 +00:00
|
|
|
mlook = omlook;
|
2008-09-04 23:11:48 +00:00
|
|
|
|
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
|
|
|
{
|
2011-03-08 23:02:38 +00:00
|
|
|
if ((bstatus&(1|2|4))==1)
|
2008-05-15 03:16:38 +00:00
|
|
|
{
|
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
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
move_and_update(xvect, yvect, 0);
|
2008-05-15 03:16:38 +00:00
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
else if (!mlook && (bstatus&(1|2|4))==2)
|
2008-05-15 03:16:38 +00:00
|
|
|
{
|
|
|
|
mlook=2;
|
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
else if ((bstatus&(1|2|4))==(1|2))
|
2008-05-15 03:16:38 +00:00
|
|
|
{
|
|
|
|
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);
|
2011-03-08 23:02:38 +00:00
|
|
|
|
|
|
|
move_and_update(xvect, yvect, 0);
|
2008-05-15 03:16:38 +00:00
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
else if ((bstatus&(1|2|4))==4)
|
2008-05-15 03:16:38 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
pos.z += mousy*(((int32_t)sintable[(tempint+2048)&2047])>>(10-pk_uedaccel));
|
2008-05-15 03:16:38 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
move_and_update(xvect, yvect, 2);
|
2008-05-15 03:16:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-03 14:02:42 +00:00
|
|
|
if (mskip)
|
2011-03-08 23:02:38 +00:00
|
|
|
{
|
|
|
|
// mskip was set in astub.c to not trigger UEd mouse movements.
|
|
|
|
// Reset now.
|
|
|
|
mskip = 0;
|
|
|
|
}
|
2008-09-03 14:02:42 +00:00
|
|
|
else
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-03-08 23:02:38 +00:00
|
|
|
if (mlook && (unrealedlook==0 || (bstatus&(1|4))==0))
|
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
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
/*
|
|
|
|
if (mousy && !(mousy/4))
|
|
|
|
horiz--;
|
|
|
|
if (mousx && !(mousx/2))
|
|
|
|
ang++;
|
|
|
|
*/
|
2011-01-16 02:50:27 +00:00
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
inpclamp(&horiz, -99, 299);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2008-09-03 14:02:42 +00:00
|
|
|
if (mlook == 1)
|
|
|
|
{
|
|
|
|
searchx = xdim>>1;
|
|
|
|
searchy = ydim>>1;
|
|
|
|
}
|
|
|
|
osearchx = searchx-mousx;
|
|
|
|
osearchy = searchy-mousy;
|
2015-07-08 03:34:27 +00:00
|
|
|
|
2015-07-20 20:25:29 +00:00
|
|
|
if (mousx || mousy)
|
|
|
|
{
|
|
|
|
silentmessage("x:%d y:%d z:%d ang:%d horiz:%d", pos.x, pos.y, pos.z, ang, horiz);
|
|
|
|
getmessagetimeoff = totalclock+30;
|
|
|
|
}
|
2008-09-03 14:02:42 +00:00
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
else if (unrealedlook==0 || (bstatus&(1|2|4))==0)
|
2008-09-03 14:02:42 +00:00
|
|
|
{
|
|
|
|
osearchx = searchx;
|
|
|
|
osearchy = searchy;
|
|
|
|
searchx += mousx;
|
|
|
|
searchy += mousy;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
inpclamp(&searchx, 12, xdim-13);
|
|
|
|
inpclamp(&searchy, 12, ydim-13);
|
2008-09-03 14:02:42 +00:00
|
|
|
}
|
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
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (keystatus[0x43]) // F9
|
2008-02-02 16:38:30 +00:00
|
|
|
{
|
2010-05-29 05:03:02 +00:00
|
|
|
if (mhk)
|
|
|
|
{
|
|
|
|
Bmemset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
|
2011-03-05 12:59:27 +00:00
|
|
|
Bmemset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES+MAXUNIQHUDID));
|
2018-04-12 21:03:47 +00:00
|
|
|
engineClearLightsFromMHK();
|
2010-05-29 05:03:02 +00:00
|
|
|
mhk = 0;
|
2011-01-16 00:23:39 +00:00
|
|
|
message("Maphacks disabled");
|
2010-05-29 05:03:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mhk = 1;
|
2011-01-16 00:23:39 +00:00
|
|
|
loadmhk(1);
|
2010-05-29 05:03:02 +00:00
|
|
|
}
|
|
|
|
|
2008-02-02 16:38:30 +00:00
|
|
|
keystatus[0x43] = 0;
|
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
mainloop_move();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-09-16 19:17:48 +00:00
|
|
|
getzrange(&pos,cursectnum, &hiz,&hihit, &loz,&lohit, 128, (m32_clipping==1)?0:CLIPMASK0);
|
2011-04-14 20:48:08 +00:00
|
|
|
/*
|
|
|
|
{
|
|
|
|
int32_t his = !(hihit&32768), los = !(lohit&32768);
|
|
|
|
if (m32_numdebuglines<64)
|
|
|
|
Bsprintf(m32_debugstr[m32_numdebuglines++], "s%d: cf[%s%d, %s%d] z(%d, %d)", cursectnum,
|
|
|
|
his?"s":"w",hihit&16383, los?"s":"w",lohit&16383, hiz,loz);
|
|
|
|
}
|
|
|
|
*/
|
2011-03-13 11:59:32 +00:00
|
|
|
oposz = pos.z;
|
2006-04-24 19:04:22 +00:00
|
|
|
if (zmode == 0)
|
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
goalz = loz-(kensplayerheight<<8); //playerheight pixels above floor
|
|
|
|
if (goalz < hiz+(16<<8)) //ceiling&floor too close
|
|
|
|
goalz = (loz+hiz)>>1;
|
2006-04-24 19:04:22 +00:00
|
|
|
goalz += mousz;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
|
|
|
if (DOWN_BK(MOVEUP)) //A (stand high)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-08 23:02:38 +00:00
|
|
|
goalz -= (16<<8);
|
|
|
|
if (DOWN_BK(RUN))
|
2011-10-30 19:48:29 +00:00
|
|
|
goalz -= (24<<8);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
if (DOWN_BK(MOVEDOWN)) //Z (stand low)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-08 23:02:38 +00:00
|
|
|
goalz += (12<<8);
|
|
|
|
if (DOWN_BK(RUN))
|
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;
|
2010-05-18 05:14:17 +00:00
|
|
|
if (DOWN_BK(MOVEUP)) //A
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
if (eitherCTRL)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
horiz = max(-100,horiz-((DOWN_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);
|
2010-05-18 05:14:17 +00:00
|
|
|
DOWN_BK(MOVEUP) = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
if (DOWN_BK(MOVEDOWN)) //Z (stand low)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
if (eitherCTRL)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
horiz = min(300,horiz+((DOWN_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);
|
2010-05-18 05:14:17 +00:00
|
|
|
DOWN_BK(MOVEDOWN) = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-09-16 19:17:48 +00:00
|
|
|
if (m32_clipping)
|
2011-03-23 17:41:01 +00:00
|
|
|
inpclamp(&goalz, hiz+(4<<8), loz-(4<<8));
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (zmode == 1) goalz = loz-zlock;
|
2011-09-16 19:17:48 +00:00
|
|
|
if (m32_clipping && (goalz < hiz+(4<<8)))
|
2010-05-18 05:14:17 +00:00
|
|
|
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
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
//if (pos.z < goalz) hvel += (32<<DOWN_BK(RUN));
|
|
|
|
//if (pos.z > goalz) hvel -= (32<<DOWN_BK(RUN));
|
2011-03-08 23:02:38 +00:00
|
|
|
if (pos.z < goalz)
|
|
|
|
hvel = ((192*synctics)<<DOWN_BK(RUN));
|
|
|
|
else
|
|
|
|
hvel = -((192*synctics)<<DOWN_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
|
|
|
|
2011-09-16 19:17:48 +00:00
|
|
|
if (m32_clipping)
|
2008-04-27 22:47:47 +00:00
|
|
|
{
|
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
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
{
|
|
|
|
int16_t ocursectnum = cursectnum;
|
|
|
|
updatesectorz(pos.x,pos.y,pos.z, &cursectnum);
|
|
|
|
if (cursectnum<0)
|
|
|
|
{
|
|
|
|
if (zmode != 2)
|
|
|
|
pos.z = oposz; // don't allow to fall into infinity when in void space
|
|
|
|
cursectnum = ocursectnum;
|
|
|
|
}
|
|
|
|
}
|
2011-03-05 12:59:27 +00:00
|
|
|
|
2015-07-08 03:34:27 +00:00
|
|
|
if (pos.z != oposz && in3dmode())
|
|
|
|
{
|
|
|
|
silentmessage("x:%d y:%d z:%d ang:%d horiz:%d", pos.x, pos.y, pos.z, ang, horiz);
|
|
|
|
getmessagetimeoff = totalclock+30;
|
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
searchit = 2;
|
|
|
|
if (searchstat >= 0)
|
|
|
|
{
|
2011-03-17 23:37:38 +00:00
|
|
|
if ((bstatus&(1|2|4)) || keystatus[0x39]) // SPACE
|
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
|
|
|
{
|
2012-08-10 19:12:01 +00:00
|
|
|
hitdata_t hit;
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2015-05-26 00:47:54 +00:00
|
|
|
vec2_t da = { 16384, divscale14(searchx-(xdim>>1), xdim>>1) };
|
|
|
|
|
|
|
|
rotatepoint(zerovec, da, ang, &da);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-07-08 03:34:27 +00:00
|
|
|
#ifdef USE_OPENGL
|
2018-04-12 21:03:12 +00:00
|
|
|
if (videoGetRenderMode() == REND_POLYMOST)
|
2015-07-08 03:34:27 +00:00
|
|
|
hit = polymost_hitdata;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
hitscan((const vec3_t *)&pos,cursectnum, //Start position
|
2015-05-26 00:47:54 +00:00
|
|
|
da.x,da.y,(scale(searchy,200,ydim)-horiz)*2000, //vector of 3D ang
|
2012-08-10 19:12:01 +00:00
|
|
|
&hit,CLIPMASK1);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2012-08-10 19:12:01 +00:00
|
|
|
if (hit.sect >= 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2015-05-26 00:47:54 +00:00
|
|
|
da.x = hit.pos.x;
|
|
|
|
da.y = hit.pos.y;
|
2010-05-18 05:14:17 +00:00
|
|
|
if (gridlock && grid > 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-23 17:41:01 +00:00
|
|
|
if (AIMING_AT_WALL || AIMING_AT_MASKWALL)
|
2012-08-10 19:12:01 +00:00
|
|
|
hit.pos.z &= 0xfffffc00;
|
2006-04-24 19:04:22 +00:00
|
|
|
else
|
2015-05-26 00:47:54 +00:00
|
|
|
locktogrid(&da.x, &da.y);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
2015-05-26 00:47:54 +00:00
|
|
|
i = insert_sprite_common(hit.sect, da.x, da.y);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if (i < 0)
|
|
|
|
message("Couldn't insert sprite.");
|
2006-04-24 19:04:22 +00:00
|
|
|
else
|
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
int32_t cz, fz;
|
|
|
|
|
2012-05-26 21:58:26 +00:00
|
|
|
handle_sprite_in_clipboard(i);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
spriteoncfz(i, &cz, &fz);
|
2013-05-16 21:54:59 +00:00
|
|
|
sprite[i].z = clamp2(hit.pos.z, cz, fz);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
if (AIMING_AT_WALL || AIMING_AT_MASKWALL)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
sprite[i].cstat &= ~48;
|
|
|
|
sprite[i].cstat |= (16+64);
|
|
|
|
|
2012-08-10 19:12:01 +00:00
|
|
|
correct_ornamented_sprite(i, hit.wall);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
else
|
2014-09-30 04:14:21 +00:00
|
|
|
sprite[i].cstat |= (tilesiz[sprite[i].picnum].y>=32);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-07 16:30:06 +00:00
|
|
|
correct_sprite_yoffset(i);
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
asksave = 1;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
VM_OnEvent(EVENT_INSERTSPRITE3D, i);
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
keystatus[0x1f] = 0;
|
|
|
|
}
|
2011-02-24 20:40:27 +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
|
|
|
{
|
2011-03-23 17:41:01 +00:00
|
|
|
case SEARCH_CEILING:
|
|
|
|
case SEARCH_FLOOR:
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtShowSectorData(searchsector); break;
|
2011-03-23 17:41:01 +00:00
|
|
|
case SEARCH_WALL:
|
|
|
|
case SEARCH_MASKWALL:
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtShowWallData(searchwall); break;
|
2011-03-23 17:41:01 +00:00
|
|
|
case SEARCH_SPRITE:
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtShowSpriteData(searchwall); break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
|
|
|
|
keystatus[0x3f] = keystatus[0x40] = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
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
|
|
|
{
|
2011-03-23 17:41:01 +00:00
|
|
|
case SEARCH_CEILING:
|
|
|
|
case SEARCH_FLOOR:
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtEditSectorData(searchsector); break;
|
2011-03-23 17:41:01 +00:00
|
|
|
case SEARCH_WALL:
|
|
|
|
case SEARCH_MASKWALL:
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtEditWallData(searchwall); break;
|
2011-03-23 17:41:01 +00:00
|
|
|
case SEARCH_SPRITE:
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtEditSpriteData(searchwall); break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
|
|
|
|
keystatus[0x41] = keystatus[0x42] = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-07-03 08:53:57 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
if (keystatus[buildkeys[BK_MODE2D_3D]] && !m32_is2d3dmode()) // Enter
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-07-03 08:53:57 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
vid_gamma_3d = g_videoGamma;
|
|
|
|
vid_contrast_3d = g_videoContrast;
|
|
|
|
vid_brightness_3d = g_videoBrightness;
|
2010-08-02 18:59:59 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
g_videoGamma = g_videoContrast = 1.0;
|
|
|
|
g_videoBrightness = 0.0;
|
2010-07-03 08:53:57 +00:00
|
|
|
|
2018-04-12 21:03:12 +00:00
|
|
|
videoSetPalette(0,0,0);
|
2010-08-02 18:59:59 +00:00
|
|
|
|
2010-05-22 14:04:47 +00:00
|
|
|
keystatus[buildkeys[BK_MODE2D_3D]] = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
overheadeditor();
|
2010-05-22 14:04:47 +00:00
|
|
|
keystatus[buildkeys[BK_MODE2D_3D]] = 0;
|
2010-08-02 18:59:59 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
g_videoGamma = vid_gamma_3d;
|
|
|
|
g_videoContrast = vid_contrast_3d;
|
|
|
|
g_videoBrightness = vid_brightness_3d;
|
2010-08-02 18:59:59 +00:00
|
|
|
|
|
|
|
vid_gamma_3d = vid_contrast_3d = vid_brightness_3d = -1;
|
2010-07-03 08:53:57 +00:00
|
|
|
|
2018-04-12 21:03:12 +00:00
|
|
|
videoSetPalette(GAMMA_CALC,0,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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-06-21 00:34:41 +00:00
|
|
|
return dachar;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
|
|
|
|
////////////////////// OVERHEADEDITOR //////////////////////
|
|
|
|
|
2011-10-30 19:47:42 +00:00
|
|
|
// some 2d mode state
|
|
|
|
static struct overheadstate
|
|
|
|
{
|
2011-10-30 19:47:58 +00:00
|
|
|
// number of backed up drawn walls
|
|
|
|
int32_t bak_wallsdrawn;
|
|
|
|
|
2011-10-30 19:47:42 +00:00
|
|
|
// state related to line drawing
|
|
|
|
int16_t suckwall, split;
|
|
|
|
int16_t splitsect;
|
|
|
|
int16_t splitstartwall;
|
|
|
|
} ovh;
|
|
|
|
|
2011-04-22 22:48:06 +00:00
|
|
|
|
2012-10-01 17:52:13 +00:00
|
|
|
static int32_t inside_editor(const vec3_t *pos, int32_t searchx, int32_t searchy, int32_t zoom,
|
|
|
|
int32_t x, int32_t y, int16_t sectnum)
|
2011-03-05 12:59:27 +00:00
|
|
|
{
|
|
|
|
if (!m32_sideview)
|
|
|
|
return inside(x, y, sectnum);
|
|
|
|
|
|
|
|
// if in side-view mode, use the screen coords instead
|
|
|
|
{
|
|
|
|
int32_t dst = MAXSECTORS+M32_FIXME_SECTORS-1, i, oi;
|
|
|
|
int32_t srcw=sector[sectnum].wallptr, dstw=MAXWALLS;
|
|
|
|
int32_t ret;
|
|
|
|
|
|
|
|
if (sector[sectnum].wallnum > M32_FIXME_WALLS)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
Bmemcpy(§or[dst], §or[sectnum], sizeof(sectortype));
|
|
|
|
sector[dst].wallptr = dstw;
|
|
|
|
|
|
|
|
Bmemcpy(&wall[dstw], &wall[srcw], sector[dst].wallnum*sizeof(walltype));
|
|
|
|
for (i=dstw, oi=srcw; i<dstw+sector[dst].wallnum; i++, oi++)
|
|
|
|
{
|
|
|
|
wall[i].point2 += dstw-srcw;
|
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
editorGet2dScreenCoordinates(&wall[i].x, &wall[i].y, wall[i].x-pos->x, wall[i].y-pos->y, zoom);
|
2011-03-05 12:59:27 +00:00
|
|
|
wall[i].y += getscreenvdisp(getflorzofslope(sectnum,wall[oi].x,wall[oi].y)-pos->z, zoom);
|
|
|
|
wall[i].x += halfxdim16;
|
|
|
|
wall[i].y += midydim16;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = numsectors;
|
|
|
|
numsectors = dst+1;
|
|
|
|
ret = inside(searchx, searchy, dst);
|
|
|
|
numsectors = i;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-01 17:52:13 +00:00
|
|
|
int32_t inside_editor_curpos(int16_t sectnum)
|
|
|
|
{
|
|
|
|
// TODO: take care: mous[xy]plc global vs overheadeditor auto
|
|
|
|
return inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc, sectnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
static inline void drawline16base(int32_t bx, int32_t by, int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col)
|
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dLine(bx+x1, by+y1, bx+x2, by+y2, col);
|
2010-11-27 22:12:24 +00:00
|
|
|
}
|
|
|
|
|
2015-07-10 07:56:48 +00:00
|
|
|
void drawsmallabel(const char *text, char col, char backcol, char border, int32_t dax, int32_t day, int32_t daz)
|
2011-02-10 23:15:02 +00:00
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
editorGet2dScreenCoordinates(&dax,&day, dax-pos.x,day-pos.y, zoom);
|
2015-07-11 23:07:47 +00:00
|
|
|
|
2011-03-07 16:30:06 +00:00
|
|
|
if (m32_sideview)
|
|
|
|
day += getscreenvdisp(daz-pos.z, zoom);
|
|
|
|
|
2015-07-11 23:07:47 +00:00
|
|
|
int32_t const x1 = halfxdim16+dax-(Bstrlen(text)<<1);
|
|
|
|
int32_t const y1 = midydim16+day-4;
|
|
|
|
int32_t const x2 = x1 + (Bstrlen(text)<<2)+2;
|
|
|
|
int32_t const y2 = y1 + 7;
|
2011-02-13 15:15:37 +00:00
|
|
|
|
2015-07-10 07:56:48 +00:00
|
|
|
int f = mulscale8(x2-x1, zoom);
|
|
|
|
|
2015-07-11 23:07:47 +00:00
|
|
|
if ((x1 <= -f) || (x2 >= xdim + f) || (y1 <= -f) || (y2 >= ydim16 + f))
|
|
|
|
return;
|
|
|
|
|
|
|
|
printext16(x1,y1, col,backcol, text,1);
|
2015-07-10 07:56:48 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dLine(x1-2, y1-2, x2-2, y1-2, border);
|
|
|
|
editorDraw2dLine(x1-2, y2+1, x2-2, y2+1, border);
|
2015-07-10 07:56:48 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dLine(x1-3, y1-1, x1-3, y2+0, border);
|
|
|
|
editorDraw2dLine(x2-1, y1-1, x2-1, y2+0, border);
|
2015-07-10 07:56:48 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dLine(x1-1,y1-1, x2-3,y1-1, backcol);
|
|
|
|
editorDraw2dLine(x1-1,y2+0, x2-3,y2+0, backcol);
|
2015-07-10 07:56:48 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dLine(x1-2,y1+0, x1-2,y2-1, backcol);
|
|
|
|
editorDraw2dLine(x2-2,y1+0, x2-2,y2-1, backcol);
|
|
|
|
editorDraw2dLine(x2-3,y1+0, x2-3,y2+0, backcol);
|
2011-02-13 15:15:37 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoBeginDrawing(); //{{{
|
2015-07-11 23:07:47 +00:00
|
|
|
|
|
|
|
if ((unsigned)y1-1 < ydim16+0u && (unsigned) (x1-2) < xdim2d+0u && (unsigned) (x2-2) < xdim2d+0u)
|
|
|
|
{
|
|
|
|
drawpixel((char *) (frameplace + ((y1-1) * bytesperline) + (x1-2)), border);
|
|
|
|
drawpixel((char *) (frameplace + ((y1-1) * bytesperline) + (x2-2)), border);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((unsigned) y2 < ydim16+0u && (unsigned) (x1-2) < xdim2d+0u && (unsigned) (x2-2) < xdim2d+0u)
|
|
|
|
{
|
|
|
|
drawpixel((char *) (frameplace + ((y2) * bytesperline) + (x1-2)), border);
|
|
|
|
drawpixel((char *) (frameplace + ((y2) * bytesperline) + (x2-2)), border);
|
2011-02-13 15:15:37 +00:00
|
|
|
}
|
2015-07-11 23:07:47 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoEndDrawing();
|
2011-02-10 23:15:02 +00:00
|
|
|
}
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
// backup highlighted sectors with sprites as mapinfo for later restoration
|
|
|
|
// return values:
|
|
|
|
// -1: highlightsectorcnt<=0
|
|
|
|
// 0: ok
|
|
|
|
static int32_t backup_highlighted_map(mapinfofull_t *mapinfo)
|
|
|
|
{
|
|
|
|
int32_t i, j, k, m, tmpnumwalls=0, tmpnumsprites=0;
|
2012-01-20 22:12:11 +00:00
|
|
|
int16_t *const otonsect = (int16_t *)tempxyar; // STRICTALIASING
|
2011-11-26 22:39:50 +00:00
|
|
|
int16_t *const otonwall = ((int16_t *)tempxyar) + MAXWALLS;
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
int16_t otonbunch[YAX_MAXBUNCHES];
|
|
|
|
int16_t numsectsofbunch[YAX_MAXBUNCHES]; // ceilings + floors
|
|
|
|
#endif
|
2010-11-27 22:12:24 +00:00
|
|
|
|
|
|
|
if (highlightsectorcnt <= 0)
|
|
|
|
return -1;
|
|
|
|
|
2011-11-26 22:39:50 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
for (i=0; i<numyaxbunches; i++)
|
|
|
|
numsectsofbunch[i] = 0;
|
|
|
|
#endif
|
|
|
|
|
2011-11-26 14:12:59 +00:00
|
|
|
// set up old-->new mappings
|
2011-11-26 14:12:15 +00:00
|
|
|
j = 0;
|
|
|
|
k = 0;
|
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
{
|
|
|
|
int32_t startwall, endwall;
|
|
|
|
|
|
|
|
if (hlsectorbitmap[i>>3]&(1<<(i&7)))
|
|
|
|
{
|
2011-11-26 22:39:50 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
int16_t bn[2], cf;
|
|
|
|
|
|
|
|
yax_getbunches(i, &bn[0], &bn[1]);
|
|
|
|
for (cf=0; cf<2; cf++)
|
|
|
|
if (bn[cf] >= 0)
|
|
|
|
numsectsofbunch[bn[cf]]++;
|
|
|
|
#endif
|
2011-11-26 14:12:15 +00:00
|
|
|
otonsect[i] = j++;
|
|
|
|
|
|
|
|
for (WALLS_OF_SECTOR(i, m))
|
|
|
|
otonwall[m] = k++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
otonsect[i] = -1;
|
|
|
|
|
|
|
|
for (WALLS_OF_SECTOR(i, m))
|
|
|
|
otonwall[m] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-26 22:39:50 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
j = 0;
|
|
|
|
for (i=0; i<numyaxbunches; i++)
|
|
|
|
{
|
|
|
|
// only back up complete bunches
|
|
|
|
if (numsectsofbunch[i] == yax_numsectsinbunch(i, 0)+yax_numsectsinbunch(i, 1))
|
2012-08-26 22:08:27 +00:00
|
|
|
otonbunch[i] = j++; // kept bunch
|
2011-11-26 22:39:50 +00:00
|
|
|
else
|
2012-08-26 22:08:27 +00:00
|
|
|
otonbunch[i] = -1; // discarded bunch
|
2011-11-26 22:39:50 +00:00
|
|
|
}
|
|
|
|
mapinfo->numyaxbunches = j;
|
|
|
|
#endif
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
// count walls & sprites
|
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
|
|
|
{
|
|
|
|
tmpnumwalls += sector[highlightsector[i]].wallnum;
|
|
|
|
|
|
|
|
m = headspritesect[highlightsector[i]];
|
|
|
|
while (m != -1)
|
|
|
|
{
|
|
|
|
tmpnumsprites++;
|
|
|
|
m = nextspritesect[m];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// allocate temp storage
|
2016-06-21 00:33:58 +00:00
|
|
|
mapinfo->sector = (usectortype *)Xmalloc(highlightsectorcnt * sizeof(sectortype));
|
|
|
|
mapinfo->wall = (uwalltype *)Xmalloc(tmpnumwalls * sizeof(walltype));
|
2011-11-26 22:39:50 +00:00
|
|
|
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (mapinfo->numyaxbunches > 0)
|
|
|
|
{
|
2014-05-30 00:02:19 +00:00
|
|
|
mapinfo->bunchnum = (int16_t *)Xmalloc(highlightsectorcnt*2*sizeof(int16_t));
|
|
|
|
mapinfo->ynextwall = (int16_t *)Xmalloc(tmpnumwalls*2*sizeof(int16_t));
|
2011-11-26 22:39:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mapinfo->bunchnum = mapinfo->ynextwall = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
2011-11-26 14:12:59 +00:00
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
if (tmpnumsprites>0)
|
|
|
|
{
|
2016-06-21 00:33:58 +00:00
|
|
|
mapinfo->sprite = (uspritetype *)Xmalloc(tmpnumsprites * sizeof(spritetype));
|
2010-11-27 22:12:24 +00:00
|
|
|
}
|
2011-11-26 14:12:59 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// would never be accessed because mapinfo->numsprites is 0, but cleaner
|
|
|
|
mapinfo->sprite = NULL;
|
|
|
|
}
|
2010-11-27 22:12:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
// copy everything over
|
|
|
|
tmpnumwalls = 0;
|
|
|
|
tmpnumsprites = 0;
|
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
|
|
|
{
|
|
|
|
k = highlightsector[i];
|
|
|
|
Bmemcpy(&mapinfo->sector[i], §or[k], sizeof(sectortype));
|
|
|
|
mapinfo->sector[i].wallptr = tmpnumwalls;
|
|
|
|
|
2011-11-26 22:39:50 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2012-08-26 22:08:27 +00:00
|
|
|
if (mapinfo->numyaxbunches > 0 || numyaxbunches > 0)
|
2011-11-26 22:39:50 +00:00
|
|
|
{
|
|
|
|
int16_t bn[2];
|
|
|
|
|
|
|
|
yax_getbunches(k, &bn[0], &bn[1]);
|
|
|
|
for (j=0; j<2; j++)
|
2012-08-26 22:08:27 +00:00
|
|
|
{
|
|
|
|
// old bunchnum, new bunchnum
|
|
|
|
int32_t obn=bn[j], nbn=(obn>=0) ? otonbunch[obn] : -1;
|
|
|
|
|
|
|
|
if (mapinfo->numyaxbunches > 0)
|
|
|
|
mapinfo->bunchnum[2*i + j] = nbn;
|
2013-08-12 15:18:13 +00:00
|
|
|
|
2012-08-26 22:08:27 +00:00
|
|
|
if (obn >= 0 && nbn < 0)
|
|
|
|
{
|
2013-08-12 15:18:13 +00:00
|
|
|
// A bunch was discarded.
|
2016-06-21 00:33:58 +00:00
|
|
|
usectortype *const sec = &mapinfo->sector[i];
|
2013-08-12 15:18:13 +00:00
|
|
|
# if !defined NEW_MAP_FORMAT
|
2012-11-15 14:28:18 +00:00
|
|
|
uint16_t *const cs = j==YAX_CEILING ? &sec->ceilingstat : &sec->floorstat;
|
2012-08-26 22:08:27 +00:00
|
|
|
uint8_t *const xp = j==YAX_CEILING ? &sec->ceilingxpanning : &sec->floorxpanning;
|
|
|
|
|
|
|
|
*cs &= ~YAX_BIT;
|
|
|
|
*xp = 0;
|
2013-08-12 15:18:13 +00:00
|
|
|
# else
|
|
|
|
if (j == YAX_CEILING)
|
|
|
|
sec->ceilingbunch = -1;
|
|
|
|
else
|
|
|
|
sec->floorbunch = -1;
|
|
|
|
# endif
|
2012-08-26 22:08:27 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-26 22:39:50 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
for (j=0; j<sector[k].wallnum; j++)
|
|
|
|
{
|
2011-11-26 22:39:50 +00:00
|
|
|
m = sector[k].wallptr;
|
|
|
|
Bmemcpy(&mapinfo->wall[tmpnumwalls+j], &wall[m+j], sizeof(walltype));
|
|
|
|
mapinfo->wall[tmpnumwalls+j].point2 += (tmpnumwalls-m);
|
|
|
|
|
|
|
|
#ifdef YAX_ENABLE
|
2013-08-12 15:18:15 +00:00
|
|
|
if (mapinfo->numyaxbunches > 0 || numyaxbunches > 0)
|
2011-11-26 22:39:50 +00:00
|
|
|
{
|
2012-08-26 22:10:40 +00:00
|
|
|
int32_t cf;
|
2011-11-26 14:12:15 +00:00
|
|
|
|
2011-11-26 22:39:50 +00:00
|
|
|
for (cf=0; cf<2; cf++)
|
|
|
|
{
|
2012-08-26 22:10:40 +00:00
|
|
|
const int32_t ynw = yax_getnextwall(m+j, cf);
|
|
|
|
const int32_t nynw = (ynw >= 0) ? otonwall[ynw] : -1;
|
|
|
|
|
|
|
|
if (mapinfo->numyaxbunches > 0)
|
|
|
|
mapinfo->ynextwall[2*(tmpnumwalls+j) + cf] = nynw;
|
|
|
|
|
|
|
|
if (ynw >= 0 && nynw < 0) // CLEAR_YNEXTWALLS
|
|
|
|
YAX_PTRNEXTWALL(mapinfo->wall, tmpnumwalls+j, cf) = YAX_NEXTWALLDEFAULT(cf);
|
2011-11-26 22:39:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2011-11-26 14:12:15 +00:00
|
|
|
m = mapinfo->wall[tmpnumwalls+j].nextsector;
|
|
|
|
if (m < 0 || otonsect[m] < 0)
|
|
|
|
{
|
|
|
|
mapinfo->wall[tmpnumwalls+j].nextsector = -1;
|
|
|
|
mapinfo->wall[tmpnumwalls+j].nextwall = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mapinfo->wall[tmpnumwalls+j].nextsector = otonsect[m];
|
|
|
|
m = mapinfo->wall[tmpnumwalls+j].nextwall;
|
|
|
|
mapinfo->wall[tmpnumwalls+j].nextwall = otonwall[m];
|
|
|
|
}
|
2010-11-27 22:12:24 +00:00
|
|
|
}
|
|
|
|
tmpnumwalls += j;
|
|
|
|
|
|
|
|
m = headspritesect[highlightsector[i]];
|
|
|
|
while (m != -1)
|
|
|
|
{
|
|
|
|
Bmemcpy(&mapinfo->sprite[tmpnumsprites], &sprite[m], sizeof(spritetype));
|
2011-11-26 14:12:15 +00:00
|
|
|
mapinfo->sprite[tmpnumsprites].sectnum = otonsect[highlightsector[i]];
|
2010-11-27 22:12:24 +00:00
|
|
|
m = nextspritesect[m];
|
|
|
|
tmpnumsprites++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mapinfo->numsectors = highlightsectorcnt;
|
|
|
|
mapinfo->numwalls = tmpnumwalls;
|
|
|
|
mapinfo->numsprites = tmpnumsprites;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mapinfofull_free(mapinfofull_t *mapinfo)
|
|
|
|
{
|
|
|
|
Bfree(mapinfo->sector);
|
2011-11-26 22:39:50 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (mapinfo->numyaxbunches > 0)
|
|
|
|
{
|
|
|
|
Bfree(mapinfo->bunchnum);
|
|
|
|
Bfree(mapinfo->ynextwall);
|
|
|
|
}
|
|
|
|
#endif
|
2010-11-27 22:12:24 +00:00
|
|
|
Bfree(mapinfo->wall);
|
|
|
|
if (mapinfo->numsprites>0)
|
|
|
|
Bfree(mapinfo->sprite);
|
|
|
|
}
|
|
|
|
|
|
|
|
// restore map saved with backup_highlighted_map, also
|
|
|
|
// frees mapinfo's sector, wall, (sprite) in any case.
|
|
|
|
// return values:
|
|
|
|
// -1: limits exceeded
|
|
|
|
// 0: ok
|
2011-11-26 22:40:23 +00:00
|
|
|
// forreal: if 0, only test if we have enough space (same return values)
|
|
|
|
static int32_t restore_highlighted_map(mapinfofull_t *mapinfo, int32_t forreal)
|
2010-11-27 22:12:24 +00:00
|
|
|
{
|
2012-08-26 22:08:27 +00:00
|
|
|
int32_t i, j, onumsectors=numsectors, newnumsectors, newnumwalls;
|
2010-11-27 22:12:24 +00:00
|
|
|
|
|
|
|
if (numsectors+mapinfo->numsectors>MAXSECTORS || numwalls+mapinfo->numwalls>MAXWALLS
|
2011-11-26 22:39:50 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
|| numyaxbunches+mapinfo->numyaxbunches > YAX_MAXBUNCHES
|
|
|
|
#endif
|
2012-03-14 22:30:24 +00:00
|
|
|
|| Numsprites+mapinfo->numsprites>MAXSPRITES)
|
2010-11-27 22:12:24 +00:00
|
|
|
{
|
|
|
|
mapinfofull_free(mapinfo);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-11-26 22:40:23 +00:00
|
|
|
if (!forreal)
|
|
|
|
return 0;
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
newnumsectors = numsectors + mapinfo->numsectors;
|
|
|
|
newnumwalls = numwalls + mapinfo->numwalls;
|
|
|
|
|
|
|
|
// copy sectors & walls
|
|
|
|
Bmemcpy(§or[numsectors], mapinfo->sector, mapinfo->numsectors*sizeof(sectortype));
|
|
|
|
Bmemcpy(&wall[numwalls], mapinfo->wall, mapinfo->numwalls*sizeof(walltype));
|
|
|
|
|
|
|
|
// tweak index members
|
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
|
|
|
{
|
|
|
|
wall[i].point2 += numwalls;
|
2011-11-26 14:12:15 +00:00
|
|
|
|
|
|
|
if (wall[i].nextsector >= 0)
|
|
|
|
{
|
|
|
|
wall[i].nextsector += numsectors;
|
|
|
|
wall[i].nextwall += numwalls;
|
|
|
|
}
|
2011-11-26 22:39:50 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
for (j=0; j<2; j++)
|
|
|
|
{
|
|
|
|
if (mapinfo->numyaxbunches > 0)
|
2013-08-12 15:18:13 +00:00
|
|
|
{
|
2011-11-26 22:39:50 +00:00
|
|
|
yax_setnextwall(i, j, mapinfo->ynextwall[2*(i-numwalls) + j]>=0 ?
|
|
|
|
numwalls+mapinfo->ynextwall[2*(i-numwalls) + j] : -1);
|
2013-08-12 15:18:13 +00:00
|
|
|
}
|
2011-11-26 22:39:50 +00:00
|
|
|
else
|
2013-08-12 15:18:13 +00:00
|
|
|
{
|
|
|
|
# if !defined NEW_MAP_FORMAT
|
|
|
|
// XXX: When copying a TROR portion into a non-TROR map (e.g. a
|
|
|
|
// new one), tags denoting ynextwalls are left in place.
|
2012-08-26 22:10:40 +00:00
|
|
|
wall[i].cstat &= ~YAX_NEXTWALLBIT(j); // CLEAR_YNEXTWALLS
|
2013-08-12 15:18:13 +00:00
|
|
|
# else
|
|
|
|
yax_setnextwall(i, j, -1);
|
2013-04-09 17:35:11 +00:00
|
|
|
# endif
|
2013-08-12 15:18:13 +00:00
|
|
|
}
|
2011-11-26 22:39:50 +00:00
|
|
|
}
|
|
|
|
#endif
|
2010-11-27 22:12:24 +00:00
|
|
|
}
|
2011-11-26 22:39:50 +00:00
|
|
|
for (i=numsectors; i<newnumsectors; i++)
|
|
|
|
sector[i].wallptr += numwalls;
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2011-11-26 14:12:15 +00:00
|
|
|
// highlight copied sectors
|
2011-11-26 22:39:50 +00:00
|
|
|
|
2011-11-26 14:12:15 +00:00
|
|
|
numsectors = newnumsectors;
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap));
|
|
|
|
for (i=onumsectors; i<newnumsectors; i++)
|
2011-11-26 14:12:59 +00:00
|
|
|
{
|
2010-11-27 22:12:24 +00:00
|
|
|
hlsectorbitmap[i>>3] |= (1<<(i&7));
|
2011-11-26 22:39:50 +00:00
|
|
|
|
2011-11-26 14:12:59 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2011-11-26 22:39:50 +00:00
|
|
|
for (j=0; j<2; j++)
|
2012-08-26 22:08:27 +00:00
|
|
|
{
|
2011-11-26 22:39:50 +00:00
|
|
|
if (mapinfo->numyaxbunches > 0)
|
2012-08-26 22:08:27 +00:00
|
|
|
{
|
|
|
|
int32_t bn = mapinfo->bunchnum[2*(i-onumsectors)+j];
|
|
|
|
yax_setbunch(i, j, bn>=0 ? numyaxbunches+bn : -2);
|
|
|
|
// -2 clears forward yax-nextwall links.
|
|
|
|
// XXX: still may wrongly reset xpanning.
|
|
|
|
}
|
2011-11-26 22:39:50 +00:00
|
|
|
else
|
2012-08-26 22:08:27 +00:00
|
|
|
Bassert(yax_getbunch(i, j) < 0);
|
|
|
|
}
|
2011-11-26 14:12:59 +00:00
|
|
|
#endif
|
|
|
|
}
|
2010-11-27 22:12:24 +00:00
|
|
|
|
|
|
|
// insert sprites
|
|
|
|
for (i=0; i<mapinfo->numsprites; i++)
|
|
|
|
{
|
2016-06-21 00:33:58 +00:00
|
|
|
const uspritetype *srcspr = &mapinfo->sprite[i];
|
2013-06-22 11:31:15 +00:00
|
|
|
int32_t sect = onumsectors + srcspr->sectnum;
|
|
|
|
|
|
|
|
j = insertsprite(sect, srcspr->statnum);
|
|
|
|
Bassert(j >= 0);
|
|
|
|
Bmemcpy(&sprite[j], srcspr, sizeof(spritetype));
|
2010-11-27 22:12:24 +00:00
|
|
|
sprite[j].sectnum = sect;
|
|
|
|
}
|
|
|
|
|
2011-11-26 22:39:50 +00:00
|
|
|
mapinfofull_free(mapinfo);
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
numwalls = newnumwalls;
|
|
|
|
|
|
|
|
update_highlightsector();
|
|
|
|
|
2011-11-26 22:39:50 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (mapinfo->numyaxbunches > 0)
|
|
|
|
yax_update(0);
|
|
|
|
#endif
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-19 21:22:26 +00:00
|
|
|
static int32_t newnumwalls=-1;
|
|
|
|
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
void ovh_whiteoutgrab(int32_t restoreredwalls)
|
2010-05-18 05:14:17 +00:00
|
|
|
{
|
|
|
|
int32_t i, j, k, startwall, endwall;
|
2011-05-15 23:16:37 +00:00
|
|
|
#if 0
|
|
|
|
//def YAX_ENABLE
|
2011-05-15 22:37:24 +00:00
|
|
|
int16_t cb, fb;
|
|
|
|
#endif
|
|
|
|
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
if (restoreredwalls)
|
|
|
|
{
|
|
|
|
// restore onextwalls first
|
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
for (WALLS_OF_SECTOR(i, j))
|
|
|
|
checksectorpointer(j, i);
|
|
|
|
}
|
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
for (i=0; i<MAXWALLS; i++)
|
|
|
|
onextwall[i] = -1;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
|
|
|
//White out all bordering lines of grab that are
|
|
|
|
//not highlighted on both sides
|
|
|
|
for (i=highlightsectorcnt-1; i>=0; i--)
|
2011-04-14 20:48:08 +00:00
|
|
|
for (WALLS_OF_SECTOR(highlightsector[i], j))
|
2010-05-18 05:14:17 +00:00
|
|
|
{
|
2011-05-15 22:37:24 +00:00
|
|
|
if (wall[j].nextwall < 0)
|
|
|
|
continue;
|
2011-04-14 20:48:08 +00:00
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
k = wall[j].nextsector;
|
|
|
|
|
|
|
|
if (hlsectorbitmap[k>>3]&(1<<(k&7)))
|
|
|
|
continue;
|
|
|
|
#if 0
|
|
|
|
//def YAX_ENABLE
|
|
|
|
// internal red walls are kept red
|
|
|
|
yax_getbunches(highlightsector[i], &cb, &fb);
|
|
|
|
if (cb>=0 && yax_getbunch(k, YAX_CEILING)>=0)
|
|
|
|
continue;
|
|
|
|
if (fb>=0 && yax_getbunch(k, YAX_FLOOR)>=0)
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
onextwall[j] = wall[j].nextwall;
|
|
|
|
|
|
|
|
NEXTWALL(j).nextwall = -1;
|
|
|
|
NEXTWALL(j).nextsector = -1;
|
|
|
|
wall[j].nextwall = -1;
|
|
|
|
wall[j].nextsector = -1;
|
2010-05-18 05:14:17 +00:00
|
|
|
}
|
2011-05-15 22:37:24 +00:00
|
|
|
|
2011-11-25 09:50:40 +00:00
|
|
|
if (highlightsectorcnt > 0)
|
|
|
|
mkonwvalid();
|
|
|
|
else
|
2012-06-01 20:09:22 +00:00
|
|
|
mkonwinvalid_keeptempsect();
|
2010-05-18 05:14:17 +00:00
|
|
|
}
|
|
|
|
|
2011-11-26 22:40:23 +00:00
|
|
|
static void duplicate_selected_sectors(void)
|
|
|
|
{
|
|
|
|
mapinfofull_t mapinfo;
|
|
|
|
int32_t i, j, onumsectors;
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
int32_t onumyaxbunches;
|
|
|
|
#endif
|
|
|
|
int32_t minx=INT32_MAX, maxx=INT32_MIN, miny=INT32_MAX, maxy=INT32_MIN, dx, dy;
|
|
|
|
|
|
|
|
i = backup_highlighted_map(&mapinfo);
|
|
|
|
|
|
|
|
if (i < 0)
|
|
|
|
{
|
|
|
|
message("Out of memory!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = restore_highlighted_map(&mapinfo, 0);
|
|
|
|
if (i < 0)
|
|
|
|
{
|
|
|
|
// XXX: no, might be another limit too. Better message needed.
|
|
|
|
printmessage16("Copying sectors would exceed sector or wall limit.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// restoring would succeed, tweak things...
|
|
|
|
Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap));
|
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
|
|
|
{
|
|
|
|
int32_t startwall, endwall;
|
|
|
|
|
|
|
|
// first, make red lines of old selected sectors, effectively
|
|
|
|
// restoring the original state
|
|
|
|
for (WALLS_OF_SECTOR(highlightsector[i], j))
|
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
checksectorpointer(wall[j].nextwall,wall[j].nextsector);
|
|
|
|
checksectorpointer(j, highlightsector[i]);
|
|
|
|
|
|
|
|
minx = min(minx, wall[j].x);
|
|
|
|
maxx = max(maxx, wall[j].x);
|
|
|
|
miny = min(miny, wall[j].y);
|
|
|
|
maxy = max(maxy, wall[j].y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// displace walls & sprites of new sectors by a small amount:
|
|
|
|
// calculate displacement
|
|
|
|
if (grid>0 && grid<9)
|
|
|
|
dx = max(2048>>grid, 128);
|
|
|
|
else
|
|
|
|
dx = 512;
|
|
|
|
dy = -dx;
|
|
|
|
if (maxx+dx >= editorgridextent) dx*=-1;
|
|
|
|
if (minx+dx <= -editorgridextent) dx*=-1;
|
|
|
|
if (maxy+dy >= editorgridextent) dy*=-1;
|
|
|
|
if (miny+dy <= -editorgridextent) dy*=-1;
|
|
|
|
|
|
|
|
onumsectors = numsectors;
|
2011-12-25 15:33:02 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2011-11-26 22:40:23 +00:00
|
|
|
onumyaxbunches = numyaxbunches;
|
2011-12-25 15:33:02 +00:00
|
|
|
#endif
|
2011-11-26 22:40:23 +00:00
|
|
|
// restore! this will not fail.
|
|
|
|
restore_highlighted_map(&mapinfo, 1);
|
|
|
|
|
|
|
|
// displace
|
|
|
|
for (i=onumsectors; i<numsectors; i++)
|
|
|
|
{
|
|
|
|
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
|
|
|
|
{
|
|
|
|
wall[j].x += dx;
|
|
|
|
wall[j].y += dy;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j=headspritesect[i]; j>=0; j=nextspritesect[j])
|
|
|
|
{
|
|
|
|
sprite[j].x += dx;
|
|
|
|
sprite[j].y += dy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (numyaxbunches > onumyaxbunches)
|
|
|
|
printmessage16("Sectors duplicated, creating %d new bunches.", numyaxbunches-onumyaxbunches);
|
|
|
|
else
|
|
|
|
#endif
|
2015-07-17 00:12:48 +00:00
|
|
|
printmessage16("Sectors duplicated.");
|
2011-11-26 22:40:23 +00:00
|
|
|
asksave = 1;
|
|
|
|
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (numyaxbunches > onumyaxbunches)
|
|
|
|
yax_update(0);
|
|
|
|
#endif
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
}
|
|
|
|
|
2010-08-26 13:50:09 +00:00
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
static void duplicate_selected_sprites(void)
|
2010-08-26 13:50:09 +00:00
|
|
|
{
|
2010-11-27 22:12:24 +00:00
|
|
|
int32_t i, j, k=0;
|
|
|
|
|
|
|
|
for (i=0; i<highlightcnt; i++)
|
2012-03-14 22:30:42 +00:00
|
|
|
if ((highlight[i]&0xc000) == 16384)
|
|
|
|
k++;
|
2010-08-26 13:50:09 +00:00
|
|
|
|
2012-03-14 22:30:42 +00:00
|
|
|
if (Numsprites + k <= MAXSPRITES)
|
2010-08-26 13:50:09 +00:00
|
|
|
{
|
|
|
|
for (i=0; i<highlightcnt; i++)
|
|
|
|
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));
|
2010-11-27 22:12:24 +00:00
|
|
|
// sprite[j].sectnum = sprite[k].sectnum; //Don't let memcpy overwrite sector!
|
|
|
|
// setsprite(j,(vec3_t *)&sprite[j]);
|
2010-08-26 13:50:09 +00:00
|
|
|
}
|
2012-03-14 22:30:24 +00:00
|
|
|
|
2015-07-17 00:12:48 +00:00
|
|
|
printmessage16("Sprites duplicated.");
|
2010-08-26 13:50:09 +00:00
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printmessage16("Copying sprites would exceed sprite limit.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
static void correct_ornamented_sprite(int32_t i, int32_t hitw)
|
|
|
|
{
|
|
|
|
int32_t j;
|
|
|
|
|
|
|
|
if (hitw >= 0)
|
2012-10-01 17:52:13 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
sprite[i].ang = (getangle(POINT2(hitw).x-wall[hitw].x,
|
|
|
|
POINT2(hitw).y-wall[hitw].y)+512)&2047;
|
|
|
|
|
2012-10-01 17:52:13 +00:00
|
|
|
//Make sure sprite's in right sector
|
|
|
|
if (inside(sprite[i].x, sprite[i].y, sprite[i].sectnum) != 1)
|
|
|
|
{
|
|
|
|
j = wall[hitw].point2;
|
|
|
|
sprite[i].x -= ksgn(wall[j].y-wall[hitw].y);
|
|
|
|
sprite[i].y += ksgn(wall[j].x-wall[hitw].x);
|
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoSpriteOrnament(int32_t i)
|
|
|
|
{
|
2012-08-10 19:12:01 +00:00
|
|
|
hitdata_t hit;
|
2011-02-24 20:40:27 +00:00
|
|
|
|
|
|
|
hitscan((const vec3_t *)&sprite[i],sprite[i].sectnum,
|
|
|
|
sintable[(sprite[i].ang+1536)&2047],
|
|
|
|
sintable[(sprite[i].ang+1024)&2047],
|
|
|
|
0,
|
2012-08-10 19:12:01 +00:00
|
|
|
&hit,CLIPMASK1);
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2015-01-11 04:55:50 +00:00
|
|
|
if (hit.sect == -1)
|
|
|
|
return;
|
|
|
|
|
2012-08-10 19:12:01 +00:00
|
|
|
sprite[i].x = hit.pos.x;
|
|
|
|
sprite[i].y = hit.pos.y;
|
|
|
|
sprite[i].z = hit.pos.z;
|
|
|
|
changespritesect(i, hit.sect);
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2012-08-10 19:12:01 +00:00
|
|
|
correct_ornamented_sprite(i, hit.wall);
|
2011-02-24 20:40:27 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
void update_highlight(void)
|
2010-08-26 13:50:09 +00:00
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
|
|
|
|
highlightcnt = 0;
|
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
if (show2dwall[i>>3]&(1<<(i&7)))
|
|
|
|
highlight[highlightcnt++] = i;
|
|
|
|
for (i=0; i<MAXSPRITES; i++)
|
|
|
|
if (sprite[i].statnum < MAXSTATUS)
|
|
|
|
{
|
|
|
|
if (show2dsprite[i>>3]&(1<<(i&7)))
|
|
|
|
highlight[highlightcnt++] = i+16384;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
show2dsprite[i>>3] &= ~(1<<(i&7));
|
|
|
|
|
|
|
|
if (highlightcnt == 0)
|
|
|
|
highlightcnt = -1;
|
|
|
|
}
|
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
void update_highlightsector(void)
|
2010-11-20 16:47:18 +00:00
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
minhlsectorfloorz = INT32_MAX;
|
2011-12-03 13:13:08 +00:00
|
|
|
numhlsecwalls = 0;
|
2011-06-04 00:06:08 +00:00
|
|
|
|
2010-11-20 16:47:18 +00:00
|
|
|
highlightsectorcnt = 0;
|
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
if (hlsectorbitmap[i>>3]&(1<<(i&7)))
|
2011-06-04 00:06:08 +00:00
|
|
|
{
|
2010-11-20 16:47:18 +00:00
|
|
|
highlightsector[highlightsectorcnt++] = i;
|
2011-06-04 00:06:08 +00:00
|
|
|
minhlsectorfloorz = min(minhlsectorfloorz, sector[i].floorz);
|
2011-12-03 13:13:08 +00:00
|
|
|
numhlsecwalls += sector[i].wallnum;
|
2011-06-04 00:06:08 +00:00
|
|
|
}
|
2010-11-20 16:47:18 +00:00
|
|
|
|
|
|
|
if (highlightsectorcnt==0)
|
2011-06-04 00:06:08 +00:00
|
|
|
{
|
|
|
|
minhlsectorfloorz = 0;
|
2010-11-20 16:47:18 +00:00
|
|
|
highlightsectorcnt = -1;
|
2011-06-04 00:06:08 +00:00
|
|
|
}
|
2010-11-20 16:47:18 +00:00
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
// Get average point of sectors
|
|
|
|
static void get_sectors_center(const int16_t *sectors, int32_t numsecs, int32_t *cx, int32_t *cy)
|
|
|
|
{
|
|
|
|
int32_t i, j, k=0, dax = 0, day = 0;
|
|
|
|
int32_t startwall, endwall;
|
|
|
|
|
|
|
|
for (i=0; i<numsecs; i++)
|
|
|
|
{
|
|
|
|
for (WALLS_OF_SECTOR(sectors[i], j))
|
|
|
|
{
|
|
|
|
dax += wall[j].x;
|
|
|
|
day += wall[j].y;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (k > 0)
|
|
|
|
{
|
|
|
|
dax /= k;
|
|
|
|
day /= k;
|
|
|
|
}
|
|
|
|
|
|
|
|
*cx = dax;
|
|
|
|
*cy = day;
|
|
|
|
}
|
|
|
|
|
2011-10-30 19:47:26 +00:00
|
|
|
static int32_t insert_sprite_common(int32_t sectnum, int32_t dax, int32_t day)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
|
|
|
int32_t i, j, k;
|
|
|
|
|
2011-10-30 19:47:26 +00:00
|
|
|
i = insertsprite(sectnum,0);
|
2011-02-24 20:40:27 +00:00
|
|
|
if (i < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
sprite[i].x = dax, sprite[i].y = day;
|
|
|
|
sprite[i].cstat = DEFAULT_SPRITE_CSTAT;
|
|
|
|
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;
|
|
|
|
|
|
|
|
Bmemset(localartfreq, 0, sizeof(localartfreq));
|
|
|
|
for (k=0; k<MAXSPRITES; k++)
|
2011-09-25 15:11:28 +00:00
|
|
|
if (sprite[k].statnum < MAXSTATUS && k!=i)
|
|
|
|
localartfreq[sprite[k].picnum]++;
|
2011-02-24 20:40:27 +00:00
|
|
|
|
|
|
|
j = 0;
|
|
|
|
for (k=0; k<MAXTILES; k++)
|
|
|
|
if (localartfreq[k] > localartfreq[j])
|
|
|
|
j = k;
|
|
|
|
|
|
|
|
if (localartfreq[j] > 0)
|
|
|
|
sprite[i].picnum = j;
|
|
|
|
else
|
|
|
|
sprite[i].picnum = 0;
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2011-03-07 16:30:06 +00:00
|
|
|
void correct_sprite_yoffset(int32_t i)
|
|
|
|
{
|
2012-11-17 19:46:28 +00:00
|
|
|
int32_t tileyofs = picanm[sprite[i].picnum].yofs;
|
2014-09-30 04:14:21 +00:00
|
|
|
int32_t tileysiz = tilesiz[sprite[i].picnum].y;
|
2011-03-07 16:30:06 +00:00
|
|
|
|
|
|
|
if (klabs(tileyofs) >= tileysiz)
|
|
|
|
{
|
|
|
|
tileyofs *= -1;
|
|
|
|
if (tileyofs == 128)
|
|
|
|
tileyofs = 127;
|
|
|
|
|
|
|
|
sprite[i].yoffset = tileyofs;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sprite[i].yoffset = 0;
|
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2011-05-23 22:42:39 +00:00
|
|
|
// keepcol >= 0 && <256: keep that idx-color
|
|
|
|
// keepcol < 0: keep none
|
|
|
|
// keepcol >= 256: 0x00ffffff is mask for 3 colors
|
2011-04-22 22:48:06 +00:00
|
|
|
void fade_editor_screen(int32_t keepcol)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
2011-05-23 22:42:39 +00:00
|
|
|
char blackcol=0, greycol=whitecol-25, *cp;
|
|
|
|
int32_t pix, i, threecols = (keepcol >= 256);
|
2012-11-15 14:28:41 +00:00
|
|
|
char cols[3] = {(char)(keepcol&0xff), (char)((keepcol>>8)&0xff), (char)((keepcol>>16)&0xff)};
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoBeginDrawing();
|
2011-02-24 20:40:27 +00:00
|
|
|
cp = (char *)frameplace;
|
|
|
|
for (i=0; i<bytesperline*(ydim-STATUS2DSIZ2); i++, cp++)
|
2011-04-22 22:48:06 +00:00
|
|
|
{
|
2011-05-23 22:42:39 +00:00
|
|
|
pix = (uint8_t)(*cp);
|
|
|
|
|
|
|
|
if (!threecols && pix == keepcol)
|
2011-04-22 22:48:06 +00:00
|
|
|
continue;
|
2011-05-23 22:42:39 +00:00
|
|
|
if (threecols)
|
|
|
|
if (pix==cols[0] || pix==cols[1] || pix==cols[2])
|
|
|
|
continue;
|
2011-04-22 22:48:06 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if (*cp==greycol)
|
|
|
|
*cp = blackcol;
|
|
|
|
else if (*cp != blackcol)
|
|
|
|
*cp = greycol;
|
2011-04-22 22:48:06 +00:00
|
|
|
}
|
2018-04-12 21:02:51 +00:00
|
|
|
videoEndDrawing();
|
|
|
|
videoShowFrame(1);
|
2011-02-24 20:40:27 +00:00
|
|
|
}
|
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
static void copy_some_wall_members(int16_t dst, int16_t src, int32_t reset_some)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
2016-06-21 00:33:58 +00:00
|
|
|
static uwalltype nullwall;
|
2015-01-11 04:56:38 +00:00
|
|
|
walltype * const dstwal = &wall[dst];
|
2016-06-21 00:33:58 +00:00
|
|
|
const uwalltype *srcwal = src >= 0 ? (uwalltype *)&wall[src] : &nullwall;
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2012-11-09 22:31:02 +00:00
|
|
|
memset(&nullwall, 0, sizeof(nullwall));
|
|
|
|
nullwall.yrepeat = 8;
|
|
|
|
nullwall.extra = -1;
|
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
if (reset_some)
|
|
|
|
{
|
|
|
|
dstwal->cstat = srcwal->cstat;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dstwal->cstat &= ~(4+8+256);
|
|
|
|
dstwal->cstat |= (srcwal->cstat&(4+8+256));
|
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
dstwal->shade = srcwal->shade;
|
|
|
|
dstwal->yrepeat = srcwal->yrepeat;
|
2011-02-28 18:37:49 +00:00
|
|
|
fixrepeats(dst); // xrepeat
|
2011-02-24 20:40:27 +00:00
|
|
|
dstwal->picnum = srcwal->picnum;
|
|
|
|
dstwal->overpicnum = srcwal->overpicnum;
|
|
|
|
|
|
|
|
dstwal->pal = srcwal->pal;
|
|
|
|
dstwal->xpanning = srcwal->xpanning;
|
|
|
|
dstwal->ypanning = srcwal->ypanning;
|
2011-05-15 22:37:24 +00:00
|
|
|
|
|
|
|
if (reset_some)
|
|
|
|
{
|
|
|
|
dstwal->nextwall = -1;
|
|
|
|
dstwal->nextsector = -1;
|
|
|
|
|
|
|
|
dstwal->lotag = 0; //srcwal->lotag;
|
|
|
|
dstwal->hitag = 0; //srcwal->hitag;
|
|
|
|
dstwal->extra = -1; //srcwal->extra;
|
2011-04-14 20:48:08 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2011-05-15 22:37:24 +00:00
|
|
|
yax_setnextwall(dst, YAX_CEILING, -1);
|
|
|
|
yax_setnextwall(dst, YAX_FLOOR, -1);
|
2011-04-14 20:48:08 +00:00
|
|
|
#endif
|
2011-05-15 22:37:24 +00:00
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
}
|
|
|
|
|
2011-10-30 19:47:42 +00:00
|
|
|
static void init_new_wall1(int16_t *suckwall_ret, int32_t mousxplc, int32_t mousyplc)
|
2011-04-22 22:48:06 +00:00
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
|
|
|
|
Bmemset(&wall[newnumwalls], 0, sizeof(walltype));
|
|
|
|
wall[newnumwalls].extra = -1;
|
|
|
|
|
2011-10-30 19:47:42 +00:00
|
|
|
wall[newnumwalls].x = mousxplc;
|
|
|
|
wall[newnumwalls].y = mousyplc;
|
2011-04-22 22:48:06 +00:00
|
|
|
wall[newnumwalls].nextsector = -1;
|
|
|
|
wall[newnumwalls].nextwall = -1;
|
|
|
|
|
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
{
|
|
|
|
YAX_SKIPWALL(i);
|
|
|
|
if (wall[i].nextwall >= 0)
|
|
|
|
YAX_SKIPWALL(wall[i].nextwall);
|
|
|
|
|
2011-10-30 19:47:42 +00:00
|
|
|
if (wall[i].x == mousxplc && wall[i].y == mousyplc)
|
|
|
|
*suckwall_ret = i;
|
2011-04-22 22:48:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wall[newnumwalls].point2 = newnumwalls+1;
|
|
|
|
newnumwalls++;
|
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
// helpers for often needed ops:
|
2011-03-13 11:59:32 +00:00
|
|
|
static int32_t do_while_copyloop1(int16_t startwall, int16_t endwall,
|
|
|
|
int16_t *danumwalls, int16_t lastpoint2)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
2011-03-13 11:59:32 +00:00
|
|
|
int32_t m = startwall;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (*danumwalls >= MAXWALLS + M32_FIXME_WALLS)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
Bmemcpy(&wall[*danumwalls], &wall[m], sizeof(walltype));
|
|
|
|
wall[*danumwalls].point2 = *danumwalls+1;
|
|
|
|
(*danumwalls)++;
|
|
|
|
m = wall[m].point2;
|
|
|
|
}
|
|
|
|
while (m != endwall);
|
2011-02-27 19:13:44 +00:00
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
if (lastpoint2 >= 0)
|
|
|
|
wall[(*danumwalls)-1].point2 = lastpoint2;
|
2011-02-27 19:13:44 +00:00
|
|
|
|
|
|
|
return 0;
|
2011-02-24 20:40:27 +00:00
|
|
|
}
|
|
|
|
|
2011-03-02 21:21:47 +00:00
|
|
|
static void updatesprite1(int16_t i)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
2011-03-02 21:21:47 +00:00
|
|
|
setsprite(i, (vec3_t *)&sprite[i]);
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2011-03-07 22:56:00 +00:00
|
|
|
if (sprite[i].sectnum>=0)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
2011-03-23 17:41:01 +00:00
|
|
|
int32_t cz, fz;
|
|
|
|
spriteoncfz(i, &cz, &fz);
|
|
|
|
inpclamp(&sprite[i].z, cz, fz);
|
2011-02-24 20:40:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2011-07-04 21:20:59 +00:00
|
|
|
// highlighted OR grayed-out sectors:
|
|
|
|
static uint8_t hlorgraysectbitmap[MAXSECTORS>>3];
|
2011-03-23 17:41:01 +00:00
|
|
|
static int32_t ask_above_or_below(void);
|
2011-07-04 21:20:59 +00:00
|
|
|
#else
|
|
|
|
# define hlorgraysectbitmap hlsectorbitmap
|
2011-03-13 11:59:32 +00:00
|
|
|
#endif
|
2011-03-02 21:21:47 +00:00
|
|
|
|
|
|
|
// returns:
|
|
|
|
// 0: continue
|
|
|
|
// >0: newnumwalls
|
|
|
|
// <0: error
|
2011-04-14 20:48:08 +00:00
|
|
|
// ignore_ret and refsect_ret are for the 'auto-red-wall' feature
|
2011-04-11 22:28:58 +00:00
|
|
|
static int32_t trace_loop(int32_t j, uint8_t *visitedwall, int16_t *ignore_ret, int16_t *refsect_ret,
|
|
|
|
int16_t trace_loop_yaxcf)
|
2011-03-02 21:21:47 +00:00
|
|
|
{
|
|
|
|
int16_t refsect, ignore;
|
|
|
|
int32_t k, n, refwall;
|
2011-05-15 23:16:37 +00:00
|
|
|
#if 0
|
|
|
|
//def YAX_ENABLE
|
2011-05-15 22:37:24 +00:00
|
|
|
int32_t yaxp = (ignore_ret==NULL); // bleh
|
|
|
|
#else
|
2011-04-11 22:28:58 +00:00
|
|
|
UNREFERENCED_PARAMETER(trace_loop_yaxcf);
|
|
|
|
#endif
|
|
|
|
|
2011-03-02 21:21:47 +00:00
|
|
|
if (wall[j].nextwall>=0 || (visitedwall[j>>3]&(1<<(j&7))))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
n=2*MAXWALLS; // simple inf loop check
|
|
|
|
refwall = j;
|
|
|
|
k = numwalls;
|
|
|
|
|
|
|
|
ignore = 0;
|
|
|
|
|
|
|
|
if (ignore_ret)
|
|
|
|
{
|
|
|
|
refsect = -1;
|
2011-07-04 21:20:59 +00:00
|
|
|
updatesectorexclude(wall[j].x, wall[j].y, &refsect, hlorgraysectbitmap);
|
2011-03-02 21:21:47 +00:00
|
|
|
if (refsect<0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (j!=refwall && visitedwall[j>>3]&(1<<(j&7)))
|
|
|
|
ignore = 1;
|
|
|
|
visitedwall[j>>3] |= (1<<(j&7));
|
|
|
|
|
|
|
|
if (ignore_ret)
|
|
|
|
{
|
|
|
|
if (inside(wall[j].x, wall[j].y, refsect) != 1)
|
|
|
|
ignore = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ignore)
|
|
|
|
{
|
|
|
|
if (k>=MAXWALLS)
|
|
|
|
{
|
|
|
|
message("Wall limits exceeded while tracing outer loop.");
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
if (ignore_ret) // auto-red wall feature
|
|
|
|
onextwall[k] = onextwall[j];
|
|
|
|
|
2011-03-02 21:21:47 +00:00
|
|
|
Bmemcpy(&wall[k], &wall[j], sizeof(walltype));
|
|
|
|
wall[k].point2 = k+1;
|
2011-04-14 20:48:08 +00:00
|
|
|
// TODO: protect lotag/extra; see also hl-sector copying stuff
|
2011-03-02 21:21:47 +00:00
|
|
|
wall[k].nextsector = wall[k].nextwall = wall[k].extra = -1;
|
2011-04-11 22:28:58 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (trace_loop_yaxcf >= 0)
|
|
|
|
yax_setnextwall(k, trace_loop_yaxcf, j);
|
|
|
|
#endif
|
2011-03-02 21:21:47 +00:00
|
|
|
k++;
|
|
|
|
}
|
|
|
|
|
|
|
|
j = wall[j].point2;
|
|
|
|
n--;
|
|
|
|
|
|
|
|
while (wall[j].nextwall>=0 && n>0)
|
|
|
|
{
|
2011-05-15 22:37:24 +00:00
|
|
|
#if 0
|
|
|
|
//def YAX_ENABLE
|
|
|
|
if (yaxp)
|
|
|
|
{
|
|
|
|
int32_t ns = wall[j].nextsector;
|
|
|
|
if ((hlsectorbitmap[ns>>3]&(1<<(ns&7)))==0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2011-03-02 21:21:47 +00:00
|
|
|
j = wall[wall[j].nextwall].point2;
|
|
|
|
// if (j!=refwall && (visitedwall[j>>3]&(1<<(j&7))))
|
|
|
|
// ignore = 1;
|
|
|
|
// visitedwall[j>>3] |= (1<<(j&7));
|
|
|
|
n--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (j!=refwall && n>0);
|
|
|
|
|
|
|
|
if (j!=refwall)
|
|
|
|
{
|
|
|
|
message("internal error while tracing outer loop: didn't reach refwall");
|
|
|
|
return -3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ignore_ret)
|
2011-03-05 12:59:27 +00:00
|
|
|
{
|
2011-03-02 21:21:47 +00:00
|
|
|
*ignore_ret = ignore;
|
2011-03-05 12:59:27 +00:00
|
|
|
if (refsect_ret)
|
|
|
|
*refsect_ret = refsect;
|
|
|
|
}
|
2011-03-02 21:21:47 +00:00
|
|
|
|
|
|
|
return k;
|
|
|
|
}
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2011-10-30 19:47:26 +00:00
|
|
|
// Backup drawn walls for carrying out other operations in the middle.
|
2011-10-30 19:47:42 +00:00
|
|
|
// 0: back up, set newnumwalls to -1
|
|
|
|
// 1: restore drawn walls and free mem
|
|
|
|
// 2: only free memory needed for backing up walls but don't restore walls
|
|
|
|
// (use this if the map has been mangled too much for a safe restoration)
|
2011-10-30 19:47:26 +00:00
|
|
|
// Context that needs special treatment: suckwall, splitsect, splitstartwall
|
2011-03-08 23:02:38 +00:00
|
|
|
static int32_t backup_drawn_walls(int32_t restore)
|
|
|
|
{
|
2016-06-21 00:33:58 +00:00
|
|
|
static uwalltype *tmpwall;
|
2011-03-08 23:02:38 +00:00
|
|
|
|
|
|
|
// back up
|
|
|
|
if (restore==0)
|
|
|
|
{
|
2011-10-30 19:47:58 +00:00
|
|
|
// ovh.bak_wallsdrawn should be 0 here
|
|
|
|
|
|
|
|
if (newnumwalls != -1)
|
2011-03-08 23:02:38 +00:00
|
|
|
{
|
2011-10-30 19:47:58 +00:00
|
|
|
if (newnumwalls <= numwalls) // shouldn't happen
|
|
|
|
return 2;
|
2011-03-08 23:02:38 +00:00
|
|
|
|
2013-01-05 13:09:34 +00:00
|
|
|
Bfree(tmpwall);
|
2016-06-21 00:33:58 +00:00
|
|
|
tmpwall = (uwalltype *)Xmalloc((newnumwalls-numwalls) * sizeof(walltype));
|
2011-03-08 23:02:38 +00:00
|
|
|
|
2011-10-30 19:47:58 +00:00
|
|
|
ovh.bak_wallsdrawn = newnumwalls-numwalls;
|
|
|
|
|
|
|
|
Bmemcpy(tmpwall, &wall[numwalls], ovh.bak_wallsdrawn*sizeof(walltype));
|
2011-03-08 23:02:38 +00:00
|
|
|
newnumwalls = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-30 19:47:58 +00:00
|
|
|
// restore/clear
|
|
|
|
if (tmpwall)
|
2011-03-08 23:02:38 +00:00
|
|
|
{
|
2011-10-30 19:47:58 +00:00
|
|
|
if (restore==1) // really restore
|
2011-10-30 19:47:42 +00:00
|
|
|
{
|
2013-01-05 13:09:34 +00:00
|
|
|
const int32_t nnumwalls = numwalls + ovh.bak_wallsdrawn;
|
|
|
|
|
|
|
|
if (nnumwalls < MAXWALLS) // else, silently discard drawn walls
|
|
|
|
{
|
|
|
|
int32_t i;
|
2011-03-08 23:02:38 +00:00
|
|
|
|
2013-01-05 13:09:34 +00:00
|
|
|
Bmemcpy(&wall[numwalls], tmpwall, ovh.bak_wallsdrawn*sizeof(walltype));
|
2011-10-30 19:47:42 +00:00
|
|
|
|
2013-01-05 13:09:34 +00:00
|
|
|
newnumwalls = nnumwalls;
|
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
|
|
|
wall[i].point2 = i+1;
|
|
|
|
}
|
2011-10-30 19:47:42 +00:00
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
|
2015-09-23 17:55:31 +00:00
|
|
|
DO_FREE_AND_NULL(tmpwall);
|
2011-10-30 19:47:58 +00:00
|
|
|
|
|
|
|
ovh.bak_wallsdrawn = 0;
|
2011-03-08 23:02:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-20 21:27:42 +00:00
|
|
|
// VARIOUS RESETTING FUNCTIONS
|
2011-03-13 11:59:32 +00:00
|
|
|
#define RESET_EDITOR_VARS() do { \
|
|
|
|
sectorhighlightstat = -1; \
|
|
|
|
newnumwalls = -1; \
|
|
|
|
joinsector[0] = -1; \
|
|
|
|
circlewall = -1; \
|
|
|
|
circlepoints = 7; \
|
|
|
|
} while (0)
|
|
|
|
|
2012-08-20 21:27:42 +00:00
|
|
|
void reset_highlightsector(void)
|
|
|
|
{
|
|
|
|
Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap));
|
|
|
|
update_highlightsector();
|
|
|
|
}
|
|
|
|
|
|
|
|
void reset_highlight(void) // walls and sprites
|
|
|
|
{
|
|
|
|
Bmemset(show2dwall, 0, sizeof(show2dwall));
|
|
|
|
Bmemset(show2dsprite, 0, sizeof(show2dsprite));
|
|
|
|
update_highlight();
|
|
|
|
}
|
2011-06-04 00:06:08 +00:00
|
|
|
|
2011-04-22 22:48:06 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2011-05-22 21:52:22 +00:00
|
|
|
static int32_t collnumsects[2];
|
|
|
|
static int16_t collsectlist[2][MAXSECTORS];
|
|
|
|
static uint8_t collsectbitmap[2][MAXSECTORS>>3];
|
|
|
|
|
2011-05-23 22:42:39 +00:00
|
|
|
static void collect_sectors1(int16_t *sectlist, uint8_t *sectbitmap, int32_t *numsectptr,
|
2011-06-04 00:06:08 +00:00
|
|
|
int16_t startsec, int32_t alsoyaxnext, int32_t alsoonw)
|
2011-05-22 21:52:22 +00:00
|
|
|
{
|
|
|
|
int32_t j, startwall, endwall, sectcnt;
|
|
|
|
|
|
|
|
bfirst_search_init(sectlist, sectbitmap, numsectptr, MAXSECTORS, startsec);
|
|
|
|
|
|
|
|
for (sectcnt=0; sectcnt<*numsectptr; sectcnt++)
|
2011-05-23 22:42:39 +00:00
|
|
|
{
|
2011-05-22 21:52:22 +00:00
|
|
|
for (WALLS_OF_SECTOR(sectlist[sectcnt], j))
|
2011-06-04 00:06:08 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextsector >= 0)
|
|
|
|
bfirst_search_try(sectlist, sectbitmap, numsectptr, wall[j].nextsector);
|
|
|
|
else if (alsoonw && onextwall[j]>=0)
|
|
|
|
bfirst_search_try(sectlist, sectbitmap, numsectptr, sectorofwall(onextwall[j]));
|
|
|
|
}
|
2011-05-23 22:42:39 +00:00
|
|
|
|
|
|
|
if (alsoyaxnext)
|
|
|
|
{
|
|
|
|
int16_t bn[2], cf;
|
|
|
|
yax_getbunches(sectlist[sectcnt], &bn[0], &bn[1]);
|
|
|
|
for (cf=0; cf<2; cf++)
|
|
|
|
if (bn[cf]>=0)
|
|
|
|
{
|
|
|
|
for (SECTORS_OF_BUNCH(bn[cf], !cf, j))
|
|
|
|
bfirst_search_try(sectlist, sectbitmap, numsectptr, j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-05-22 21:52:22 +00:00
|
|
|
}
|
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
|
|
|
|
static int32_t sectors_components(int16_t hlsectcnt, const int16_t *hlsectors, int32_t alsoyaxnext, int32_t alsoonw);
|
|
|
|
static int32_t highlighted_sectors_components(int32_t alsoyaxnext, int32_t alsoonw)
|
|
|
|
{
|
|
|
|
return sectors_components(highlightsectorcnt, highlightsector, alsoyaxnext, alsoonw);
|
|
|
|
}
|
|
|
|
|
2011-05-22 21:52:22 +00:00
|
|
|
// whether all highlighted sectors are in one (returns 1), two (2)
|
|
|
|
// or more (>2) connected components wrt the nextsector relation
|
|
|
|
// -1 means error
|
2011-05-23 22:42:39 +00:00
|
|
|
// alsoyaxnext: also consider "yax-nextsector" relation
|
2011-06-04 00:06:08 +00:00
|
|
|
// alsoonw: also consider "old-nextwall" relation (must be valid)
|
|
|
|
static int32_t sectors_components(int16_t hlsectcnt, const int16_t *hlsector, int32_t alsoyaxnext, int32_t alsoonw)
|
2011-04-22 22:48:06 +00:00
|
|
|
{
|
2011-05-22 21:52:22 +00:00
|
|
|
int32_t j, k, tmp;
|
2011-04-22 22:48:06 +00:00
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
if (hlsectcnt<1)
|
2011-04-22 22:48:06 +00:00
|
|
|
return 0;
|
|
|
|
|
2011-05-23 22:42:39 +00:00
|
|
|
collect_sectors1(collsectlist[0], collsectbitmap[0], &collnumsects[0],
|
2011-06-04 00:06:08 +00:00
|
|
|
hlsector[0], alsoyaxnext, alsoonw);
|
2011-04-22 22:48:06 +00:00
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
for (k=1; k<hlsectcnt; k++)
|
2011-05-22 21:52:22 +00:00
|
|
|
{
|
2011-06-04 00:06:08 +00:00
|
|
|
j = hlsector[k];
|
2011-05-22 21:52:22 +00:00
|
|
|
if ((collsectbitmap[0][j>>3]&(1<<(j&7)))==0)
|
|
|
|
{
|
|
|
|
// sector j not collected --> more than 1 conn. comp.
|
2011-05-23 22:42:39 +00:00
|
|
|
collect_sectors1(collsectlist[1], collsectbitmap[1], &collnumsects[1],
|
2011-06-04 00:06:08 +00:00
|
|
|
j, alsoyaxnext, alsoonw);
|
2011-05-22 21:52:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
if (k == hlsectcnt)
|
2011-05-22 21:52:22 +00:00
|
|
|
return 1;
|
2011-04-22 22:48:06 +00:00
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
for (k=0; k<hlsectcnt; k++)
|
2011-04-22 22:48:06 +00:00
|
|
|
{
|
2011-06-04 00:06:08 +00:00
|
|
|
j = hlsector[k];
|
2011-05-22 21:52:22 +00:00
|
|
|
tmp = (((collsectbitmap[0][j>>3]&(1<<(j&7)))!=0) + (((collsectbitmap[1][j>>3]&(1<<(j&7)))!=0)<<1));
|
|
|
|
|
|
|
|
if (tmp==3)
|
|
|
|
return -1; // components only weakly connected
|
|
|
|
|
|
|
|
if (tmp==0)
|
|
|
|
return 3; // sector j not reached
|
2011-04-22 22:48:06 +00:00
|
|
|
}
|
|
|
|
|
2011-05-22 21:52:22 +00:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2013-09-21 13:38:44 +00:00
|
|
|
static int cmpgeomwal1(const void *w1, const void *w2)
|
2011-05-22 21:52:22 +00:00
|
|
|
{
|
2016-06-21 00:33:58 +00:00
|
|
|
uwalltype const * const wal1 = (uwalltype *)&wall[B_UNBUF16(w1)];
|
|
|
|
uwalltype const * const wal2 = (uwalltype *)&wall[B_UNBUF16(w2)];
|
2011-05-22 21:52:22 +00:00
|
|
|
|
|
|
|
if (wal1->x == wal2->x)
|
|
|
|
return wal1->y - wal2->y;
|
|
|
|
|
|
|
|
return wal1->x - wal2->x;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sort_walls_geometrically(int16_t *wallist, int32_t nwalls)
|
|
|
|
{
|
2013-09-21 13:38:44 +00:00
|
|
|
qsort(wallist, nwalls, sizeof(int16_t), &cmpgeomwal1);
|
2011-04-22 22:48:06 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-05-30 18:10:45 +00:00
|
|
|
void SetFirstWall(int32_t sectnum, int32_t wallnum, int32_t alsoynw)
|
2011-05-29 23:10:51 +00:00
|
|
|
{
|
|
|
|
#ifdef YAX_ENABLE
|
2013-05-30 18:10:45 +00:00
|
|
|
int32_t i, j, k=0;
|
|
|
|
#endif
|
|
|
|
const sectortype *sec = §or[sectnum];
|
2011-05-29 23:10:51 +00:00
|
|
|
|
2013-05-30 18:10:45 +00:00
|
|
|
if (sec->wallptr == wallnum)
|
|
|
|
{
|
|
|
|
message("Wall %d already first wall of sector %d", wallnum, sectnum);
|
|
|
|
return;
|
|
|
|
}
|
2011-05-29 23:10:51 +00:00
|
|
|
|
2013-05-30 18:10:45 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (alsoynw)
|
2011-05-29 23:10:51 +00:00
|
|
|
{
|
2013-05-30 18:10:45 +00:00
|
|
|
// Also consider upper/lower TROR neighbor walls.
|
|
|
|
int32_t startwall, endwall;
|
|
|
|
int16_t cf;
|
2011-05-29 23:10:51 +00:00
|
|
|
|
2013-05-30 18:10:45 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
wall[i].cstat &= ~(1<<14);
|
|
|
|
|
|
|
|
for (cf=0; cf<2; cf++)
|
2011-05-29 23:10:51 +00:00
|
|
|
{
|
2013-05-30 18:10:45 +00:00
|
|
|
int16_t bunchnum;
|
|
|
|
int32_t tempsect=sectnum, tempwall=wallnum;
|
|
|
|
|
|
|
|
while ((bunchnum = yax_getbunch(tempsect, cf)) >= 0 &&
|
|
|
|
(tempsect=yax_is121(bunchnum, cf)) >= 0)
|
|
|
|
{
|
|
|
|
tempwall = yax_getnextwall(tempwall, cf);
|
|
|
|
if (tempwall < 0)
|
|
|
|
break; // corrupt!
|
|
|
|
wall[tempwall].cstat |= (1<<14);
|
|
|
|
}
|
2011-05-29 23:10:51 +00:00
|
|
|
}
|
|
|
|
|
2013-05-30 18:10:45 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
for (WALLS_OF_SECTOR(i, j))
|
2011-05-29 23:10:51 +00:00
|
|
|
{
|
2013-05-30 18:10:45 +00:00
|
|
|
if (wall[j].cstat & (1<<14))
|
|
|
|
{
|
|
|
|
setfirstwall(i, j);
|
|
|
|
k++;
|
|
|
|
break;
|
|
|
|
}
|
2011-05-29 23:10:51 +00:00
|
|
|
}
|
2013-05-30 18:10:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Only consider aimed at wall <wallnum>.
|
|
|
|
int16_t cb = yax_getbunch(sectnum, YAX_CEILING);
|
|
|
|
int16_t fb = yax_getbunch(sectnum, YAX_FLOOR);
|
|
|
|
|
|
|
|
if ((cb>=0 && (sec->ceilingstat&2)) || (fb >= 0 && (sec->floorstat&2)))
|
|
|
|
{
|
|
|
|
message("Extended ceilings/floors must not be sloped to set first wall");
|
|
|
|
return;
|
2011-05-29 23:10:51 +00:00
|
|
|
}
|
2013-05-30 18:10:45 +00:00
|
|
|
}
|
2011-05-29 23:10:51 +00:00
|
|
|
|
|
|
|
if (k > 0)
|
|
|
|
message("Set first walls (sector[].wallptr) for %d sectors", k+1);
|
2013-05-30 18:10:45 +00:00
|
|
|
|
|
|
|
if (k == 0)
|
2011-05-29 23:10:51 +00:00
|
|
|
#endif
|
|
|
|
message("This wall now sector %d's first wall (sector[].wallptr)", sectnum);
|
|
|
|
|
|
|
|
setfirstwall(sectnum, wallnum);
|
2012-06-01 20:09:19 +00:00
|
|
|
|
2012-06-01 20:09:22 +00:00
|
|
|
mkonwinvalid_keeptempsect();
|
2012-06-01 20:09:19 +00:00
|
|
|
|
2011-05-29 23:10:51 +00:00
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
|
2015-09-05 08:30:59 +00:00
|
|
|
void handlesecthighlight1(int32_t i, int32_t sub, int32_t nograycheck)
|
2011-05-29 23:10:51 +00:00
|
|
|
{
|
|
|
|
int32_t j;
|
|
|
|
|
|
|
|
if (sub)
|
|
|
|
{
|
|
|
|
hlsectorbitmap[i>>3] &= ~(1<<(i&7));
|
|
|
|
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
|
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
checksectorpointer(wall[j].nextwall,wall[j].nextsector);
|
|
|
|
checksectorpointer(j, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (nograycheck || (graysectbitmap[i>>3]&(1<<(i&7)))==0)
|
|
|
|
hlsectorbitmap[i>>3] |= (1<<(i&7));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
// 1: good, 0: bad
|
|
|
|
static int32_t hl_all_bunch_sectors_p()
|
|
|
|
{
|
|
|
|
uint8_t *const havebunch = visited;
|
|
|
|
int16_t cf, cb, fb;
|
|
|
|
int32_t i, j;
|
|
|
|
|
|
|
|
if (numyaxbunches > 0)
|
|
|
|
{
|
|
|
|
Bmemset(havebunch, 0, (numyaxbunches+7)>>3);
|
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
|
|
|
{
|
|
|
|
yax_getbunches(highlightsector[i], &cb, &fb);
|
|
|
|
if (cb>=0)
|
|
|
|
havebunch[cb>>3] |= (1<<(cb&7));
|
|
|
|
if (fb>=0)
|
|
|
|
havebunch[fb>>3] |= (1<<(fb&7));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<numyaxbunches; i++)
|
|
|
|
{
|
|
|
|
if ((havebunch[i>>3] & (1<<(i&7)))==0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (cf=0; cf<2; cf++)
|
|
|
|
for (SECTORS_OF_BUNCH(i,cf, j))
|
|
|
|
if ((hlsectorbitmap[j>>3]&(1<<(j&7)))==0)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-07-09 17:36:02 +00:00
|
|
|
static int32_t find_nextwall(int32_t sectnum, int32_t sectnum2)
|
|
|
|
{
|
|
|
|
int32_t j, startwall, endwall;
|
|
|
|
|
|
|
|
if (sectnum<0 || sectnum2<0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
for (WALLS_OF_SECTOR(sectnum, j))
|
|
|
|
if (wall[j].nextsector == sectnum2)
|
|
|
|
return j;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-10-30 19:48:29 +00:00
|
|
|
static int32_t bakframe_fillandfade(char **origframeptr, int32_t sectnum, const char *querystr)
|
|
|
|
{
|
|
|
|
if (!*origframeptr)
|
|
|
|
{
|
2014-05-30 00:02:19 +00:00
|
|
|
*origframeptr = (char *)Xmalloc(xdim*ydim);
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoBeginDrawing();
|
2014-05-30 00:02:19 +00:00
|
|
|
Bmemcpy(*origframeptr, (char *)frameplace, xdim*ydim);
|
2018-04-12 21:02:51 +00:00
|
|
|
videoEndDrawing();
|
2011-10-30 19:48:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-12 21:02:51 +00:00
|
|
|
videoBeginDrawing();
|
2011-10-30 19:48:29 +00:00
|
|
|
Bmemcpy((char *)frameplace, *origframeptr, xdim*ydim);
|
2018-04-12 21:02:51 +00:00
|
|
|
videoEndDrawing();
|
2011-10-30 19:48:29 +00:00
|
|
|
}
|
|
|
|
|
2015-10-31 15:13:32 +00:00
|
|
|
fillsector_notrans(sectnum, editorcolors[9]);
|
2011-10-30 19:48:29 +00:00
|
|
|
fade_editor_screen(editorcolors[9]);
|
|
|
|
|
|
|
|
return ask_if_sure(querystr, 0);
|
|
|
|
}
|
|
|
|
|
2016-07-04 14:09:08 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
static void M32_MarkPointInsertion(int32_t thewall)
|
|
|
|
{
|
|
|
|
int32_t i, tmpcf;
|
|
|
|
int32_t nextw = wall[thewall].nextwall;
|
|
|
|
|
|
|
|
// round 1
|
|
|
|
for (YAX_ITER_WALLS(thewall, i, tmpcf))
|
|
|
|
wall[i].cstat |= (1<<14);
|
|
|
|
if (nextw >= 0)
|
|
|
|
for (YAX_ITER_WALLS(nextw, i, tmpcf))
|
|
|
|
wall[i].cstat |= (1<<14);
|
|
|
|
// round 2 (enough?)
|
|
|
|
for (YAX_ITER_WALLS(thewall, i, tmpcf))
|
|
|
|
if (wall[i].nextwall >= 0 && (wall[wall[i].nextwall].cstat&(1<<14))==0)
|
|
|
|
wall[wall[i].nextwall].cstat |= (1<<14);
|
|
|
|
if (nextw >= 0)
|
|
|
|
for (YAX_ITER_WALLS(nextw, i, tmpcf))
|
|
|
|
if (wall[i].nextwall >= 0 && (wall[wall[i].nextwall].cstat&(1<<14))==0)
|
|
|
|
wall[wall[i].nextwall].cstat |= (1<<14);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-01-05 13:09:34 +00:00
|
|
|
// High-level insert point, handles TROR constrained walls too
|
|
|
|
// onewnumwalls: old numwalls + drawn walls.
|
|
|
|
// <mapwallnum>: see insertpoint()
|
|
|
|
// Returns:
|
|
|
|
// 0 if wall limit would be reached.
|
|
|
|
// 1 if inserted point on a plain white or 2 points on a plain red wall.
|
|
|
|
// N >= 2 if inserted N points on TROR-constrained wall.
|
2016-06-05 04:46:28 +00:00
|
|
|
// N|(EXPECTED<<16) if inserted N points but EXPECTED walls were expected.
|
2011-11-25 09:51:53 +00:00
|
|
|
static int32_t M32_InsertPoint(int32_t thewall, int32_t dax, int32_t day, int32_t onewnumwalls, int32_t *mapwallnum)
|
2011-11-25 09:51:21 +00:00
|
|
|
{
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
int32_t nextw = wall[thewall].nextwall;
|
2016-07-04 14:09:08 +00:00
|
|
|
int32_t i, j, k, m;
|
2011-11-25 09:51:21 +00:00
|
|
|
|
|
|
|
if (yax_islockedwall(thewall) || (nextw>=0 && yax_islockedwall(nextw)))
|
|
|
|
{
|
|
|
|
// yax'ed wall -- first find out which walls are affected
|
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
wall[i].cstat &= ~(1<<14);
|
|
|
|
|
2016-07-04 14:09:08 +00:00
|
|
|
M32_MarkPointInsertion(thewall);
|
2011-11-25 09:51:21 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
for (i=0; i < numwalls; i++)
|
2016-07-04 14:09:08 +00:00
|
|
|
if (wall[i].cstat&(1<<14))
|
|
|
|
M32_MarkPointInsertion(i);
|
|
|
|
|
2011-11-25 09:51:21 +00:00
|
|
|
j = 0;
|
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
j += !!(wall[i].cstat&(1<<14));
|
|
|
|
if (max(numwalls,onewnumwalls)+j > MAXWALLS)
|
|
|
|
{
|
|
|
|
return 0; // no points inserted, would exceed limits
|
|
|
|
}
|
2011-11-25 09:51:53 +00:00
|
|
|
|
|
|
|
// the actual insertion!
|
2011-11-25 09:51:21 +00:00
|
|
|
m = 0;
|
2011-11-25 09:51:53 +00:00
|
|
|
for (i=0; i<numwalls /* rises with ins. */; i++)
|
2011-11-25 09:51:21 +00:00
|
|
|
{
|
|
|
|
if (wall[i].cstat&(1<<14))
|
|
|
|
if (wall[i].nextwall<0 || i<wall[i].nextwall) // || !(NEXTWALL(i).cstat&(1<<14)) ??
|
|
|
|
{
|
2011-11-25 09:51:53 +00:00
|
|
|
m += insertpoint(i, dax,day, mapwallnum);
|
2011-11-25 09:51:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
{
|
|
|
|
if (wall[i].cstat&(1<<14))
|
|
|
|
{
|
|
|
|
wall[i].cstat &= ~(1<<14);
|
|
|
|
k = yax_getnextwall(i+1, YAX_CEILING);
|
|
|
|
if (k >= 0)
|
|
|
|
yax_setnextwall(i+1, YAX_CEILING, k+1);
|
|
|
|
k = yax_getnextwall(i+1, YAX_FLOOR);
|
|
|
|
if (k >= 0)
|
|
|
|
yax_setnextwall(i+1, YAX_FLOOR, k+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m==j)
|
|
|
|
return m;
|
|
|
|
else
|
|
|
|
return m|(j<<16);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2011-11-25 09:51:53 +00:00
|
|
|
insertpoint(thewall, dax,day, mapwallnum);
|
2011-11-25 09:51:21 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-30 19:48:29 +00:00
|
|
|
|
2012-06-20 20:55:03 +00:00
|
|
|
// based on lineintersect in engine.c, but lines are considered as infinitely
|
|
|
|
// extending
|
|
|
|
void inflineintersect(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
|
|
|
int32_t x3, int32_t y3, int32_t x4, int32_t y4,
|
|
|
|
int32_t *intx, int32_t *inty, int32_t *sign12, int32_t *sign34)
|
|
|
|
{
|
|
|
|
//p1 to p2 is a line segment
|
|
|
|
int64_t x21, y21, x34, y34, x31, y31, bot, topt, topu, t;
|
|
|
|
|
|
|
|
x21 = x2-x1; x34 = x3-x4;
|
|
|
|
y21 = y2-y1; y34 = y3-y4;
|
|
|
|
bot = x21*y34 - y21*x34;
|
|
|
|
if (bot >= 0)
|
|
|
|
{
|
|
|
|
if (bot == 0) { *sign12 = *sign34 = 0; return; };
|
|
|
|
x31 = x3-x1; y31 = y3-y1;
|
|
|
|
topt = x31*y34 - y31*x34;
|
|
|
|
topu = x21*y31 - y21*x31;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x31 = x3-x1; y31 = y3-y1;
|
|
|
|
topt = x31*y34 - y31*x34;
|
|
|
|
topu = x21*y31 - y21*x31;
|
|
|
|
}
|
|
|
|
|
|
|
|
t = (topt*(1<<24))/bot;
|
|
|
|
*intx = x1 + ((x21*t)>>24);
|
|
|
|
*inty = y1 + ((y21*t)>>24);
|
|
|
|
|
|
|
|
*sign12 = topt < 0 ? -1 : 1;
|
|
|
|
*sign34 = topu < 0 ? -1 : 1;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-25 09:51:53 +00:00
|
|
|
static int32_t lineintersect2v(const vec2_t *p1, const vec2_t *p2, // line segment 1
|
|
|
|
const vec2_t *q1, const vec2_t *q2, // line segment 2
|
|
|
|
vec2_t *pint)
|
|
|
|
{
|
|
|
|
int32_t intz;
|
2015-01-11 04:56:38 +00:00
|
|
|
return lintersect(p1->x, p1->y, 0, p2->x, p2->y, 0,
|
2011-11-25 09:51:53 +00:00
|
|
|
q1->x, q1->y, q2->x, q2->y,
|
|
|
|
&pint->x, &pint->y, &intz);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int32_t vec2eq(const vec2_t *v1, const vec2_t *v2)
|
|
|
|
{
|
|
|
|
return (v1->x==v2->x && v1->y==v2->y);
|
|
|
|
}
|
|
|
|
|
2013-08-23 17:01:13 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
// After auto-creating inner sector <ns> in existing sector <os>, we need to
|
|
|
|
// see if some sprites contained in <os> need to change their sector.
|
|
|
|
static void CorrectSpriteSectnums(int32_t os, int32_t ns)
|
|
|
|
{
|
|
|
|
int32_t i, ni;
|
|
|
|
|
|
|
|
for (SPRITES_OF_SECT_SAFE(os, i, ni))
|
|
|
|
{
|
|
|
|
if (inside(sprite[i].x, sprite[i].y, ns)==1)
|
|
|
|
changespritesect(i, ns);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-11-25 09:52:37 +00:00
|
|
|
// precondition: [numwalls, newnumwalls-1] form a new loop (may be of wrong orientation)
|
2011-11-25 09:53:07 +00:00
|
|
|
// ret_ofirstwallofs: if != NULL, *ret_ofirstwallofs will contain the offset of the old
|
|
|
|
// first wall from the new first wall of the sector k, and the automatic
|
|
|
|
// restoring of the old first wll will not be carried out
|
2011-11-25 09:52:37 +00:00
|
|
|
// returns:
|
|
|
|
// -1, -2: errors
|
|
|
|
// 0, 1: OK, 1 means it was an extended sector and an inner loop has been added automatically
|
2011-11-25 09:53:07 +00:00
|
|
|
static int32_t AddLoopToSector(int32_t k, int32_t *ret_ofirstwallofs)
|
2011-11-25 09:52:37 +00:00
|
|
|
{
|
|
|
|
int32_t extendedSector=0, firstwall, i, j;
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
int16_t cbunch, fbunch;
|
|
|
|
int32_t newnumwalls2;
|
|
|
|
|
|
|
|
yax_getbunches(k, &cbunch, &fbunch);
|
|
|
|
extendedSector = (cbunch>=0 || fbunch>=0);
|
|
|
|
#endif
|
|
|
|
j = newnumwalls-numwalls;
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
newnumwalls2 = newnumwalls + j;
|
|
|
|
|
|
|
|
if (extendedSector)
|
|
|
|
{
|
|
|
|
if ((cbunch>=0 && (sector[k].ceilingstat&2))
|
|
|
|
|| (fbunch>=0 && (sector[k].floorstat&2)))
|
|
|
|
{
|
2011-11-25 09:52:52 +00:00
|
|
|
printmessage16("Sloped extended sectors cannot be subdivided.");
|
2011-11-25 09:52:37 +00:00
|
|
|
newnumwalls--;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newnumwalls + j > MAXWALLS || numsectors+1 > MAXSECTORS)
|
|
|
|
{
|
|
|
|
message("Automatically adding inner sector to new extended sector would exceed limits!");
|
|
|
|
newnumwalls--;
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2011-11-25 09:53:07 +00:00
|
|
|
if (clockdir(numwalls) == CLOCKDIR_CW)
|
2011-11-25 09:52:37 +00:00
|
|
|
flipwalls(numwalls,newnumwalls);
|
|
|
|
|
|
|
|
sector[k].wallnum += j;
|
|
|
|
for (i=k+1; i<numsectors; i++)
|
|
|
|
sector[i].wallptr += j;
|
|
|
|
firstwall = sector[k].wallptr;
|
|
|
|
|
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
{
|
|
|
|
if (wall[i].nextwall >= firstwall)
|
|
|
|
wall[i].nextwall += j;
|
|
|
|
if (wall[i].point2 >= firstwall)
|
|
|
|
wall[i].point2 += j;
|
|
|
|
}
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_tweakwalls(firstwall, j);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Bmemmove(&wall[firstwall+j], &wall[firstwall], (newnumwalls-firstwall)*sizeof(walltype));
|
|
|
|
// add new loop to beginning of sector
|
|
|
|
Bmemmove(&wall[firstwall], &wall[newnumwalls], j*sizeof(walltype));
|
|
|
|
|
|
|
|
for (i=firstwall; i<firstwall+j; i++)
|
|
|
|
{
|
|
|
|
wall[i].point2 += (firstwall-numwalls);
|
|
|
|
|
|
|
|
copy_some_wall_members(i, firstwall+j, 1);
|
|
|
|
wall[i].cstat &= ~(1+16+32+64);
|
|
|
|
}
|
|
|
|
|
|
|
|
numwalls = newnumwalls;
|
|
|
|
newnumwalls = -1;
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (extendedSector)
|
|
|
|
{
|
|
|
|
newnumwalls = whitelinescan(k, firstwall);
|
|
|
|
if (newnumwalls != newnumwalls2)
|
|
|
|
message("AddLoopToSector: newnumwalls != newnumwalls2!!! WTF?");
|
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
|
|
|
{
|
|
|
|
NEXTWALL(i).nextwall = i;
|
|
|
|
NEXTWALL(i).nextsector = numsectors;
|
|
|
|
}
|
|
|
|
|
|
|
|
yax_setbunches(numsectors, cbunch, fbunch);
|
|
|
|
|
|
|
|
numwalls = newnumwalls;
|
|
|
|
newnumwalls = -1;
|
|
|
|
numsectors++;
|
2013-08-23 17:01:13 +00:00
|
|
|
|
|
|
|
CorrectSpriteSectnums(k, numsectors-1);
|
2011-11-25 09:52:37 +00:00
|
|
|
}
|
|
|
|
#endif
|
2011-11-25 09:53:07 +00:00
|
|
|
if (ret_ofirstwallofs)
|
|
|
|
*ret_ofirstwallofs = j;
|
|
|
|
else
|
|
|
|
setfirstwall(k, firstwall+j); // restore old first wall
|
2011-11-25 09:52:37 +00:00
|
|
|
|
|
|
|
return extendedSector;
|
|
|
|
}
|
|
|
|
|
2012-11-03 19:32:39 +00:00
|
|
|
int32_t select_sprite_tag(int32_t spritenum)
|
|
|
|
{
|
|
|
|
int32_t lt = taglab_linktags(1, spritenum);
|
|
|
|
spritetype *spr = &sprite[spritenum];
|
|
|
|
|
|
|
|
if (lt==0)
|
|
|
|
return INT32_MIN;
|
|
|
|
|
|
|
|
if (lt&1)
|
|
|
|
return spr->lotag;
|
|
|
|
if (lt&2)
|
|
|
|
return spr->hitag;
|
|
|
|
if (lt&4)
|
|
|
|
return spr->extra;
|
|
|
|
if (lt&8)
|
|
|
|
return spr->xvel;
|
|
|
|
if (lt&16)
|
|
|
|
return spr->yvel;
|
|
|
|
if (lt&32)
|
|
|
|
return spr->zvel;
|
|
|
|
if (lt&64)
|
|
|
|
return spr->extra;
|
|
|
|
|
|
|
|
return INT32_MIN;
|
|
|
|
}
|
|
|
|
|
2012-11-04 23:03:22 +00:00
|
|
|
static void drawlinebetween(const vec3_t *v1, const vec3_t *v2, int32_t col, uint32_t pat)
|
2012-11-03 19:32:39 +00:00
|
|
|
{
|
|
|
|
// based on m32exec.c/drawline*
|
|
|
|
const int32_t xofs=halfxdim16, yofs=midydim16;
|
|
|
|
const uint32_t opat=drawlinepat;
|
|
|
|
|
|
|
|
int32_t x1, x2, y1, y2;
|
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
editorGet2dScreenCoordinates(&x1,&y1, v1->x-pos.x,v1->y-pos.y, zoom);
|
|
|
|
editorGet2dScreenCoordinates(&x2,&y2, v2->x-pos.x,v2->y-pos.y, zoom);
|
2012-11-03 19:32:39 +00:00
|
|
|
|
|
|
|
if (m32_sideview)
|
|
|
|
{
|
2012-11-04 23:03:22 +00:00
|
|
|
y1 += getscreenvdisp(v1->z-pos.z,zoom);
|
|
|
|
y2 += getscreenvdisp(v2->z-pos.z,zoom);
|
2012-11-03 19:32:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
drawlinepat = pat;
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dLine(xofs+x1,yofs+y1, xofs+x2,yofs+y2, col);
|
2012-11-03 19:32:39 +00:00
|
|
|
drawlinepat = opat;
|
|
|
|
}
|
2011-11-25 09:53:07 +00:00
|
|
|
|
2012-11-04 23:03:22 +00:00
|
|
|
// world -> screen coords for overhead mode
|
|
|
|
void ovhscrcoords(int32_t x, int32_t y, int32_t *scrx, int32_t *scry)
|
|
|
|
{
|
|
|
|
*scrx = halfxdim16 + mulscale14(x-pos.x, zoom);
|
|
|
|
*scry = midydim16 + mulscale14(y-pos.y, zoom);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_cross(int32_t centerx, int32_t centery, int32_t radius, int32_t col)
|
|
|
|
{
|
|
|
|
int32_t dax, day;
|
|
|
|
ovhscrcoords(centerx, centery, &dax, &day);
|
|
|
|
drawline16base(dax, day, -radius,-radius, +radius,+radius, col);
|
|
|
|
drawline16base(dax, day, -radius,+radius, +radius,-radius, col);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_square(int32_t dax, int32_t day, int32_t ps, int32_t col)
|
|
|
|
{
|
|
|
|
ovhscrcoords(dax, day, &dax, &day);
|
|
|
|
drawline16base(dax, day, -ps,-ps, +ps,-ps, col);
|
|
|
|
drawline16base(dax, day, +ps,-ps, +ps,+ps, col);
|
|
|
|
drawline16base(dax, day, +ps,+ps, -ps,+ps, col);
|
|
|
|
drawline16base(dax, day, -ps,+ps, -ps,-ps, col);
|
|
|
|
}
|
|
|
|
|
|
|
|
//// Interactive Scaling
|
|
|
|
static struct {
|
|
|
|
int8_t active, rotatep;
|
2015-05-26 00:47:54 +00:00
|
|
|
vec2_t piv; // pivot point
|
2012-11-04 23:03:22 +00:00
|
|
|
int32_t dragx, dragy; // dragged point
|
|
|
|
int32_t xsc, ysc, ang;
|
|
|
|
} isc;
|
|
|
|
|
|
|
|
static void isc_transform(int32_t *x, int32_t *y)
|
|
|
|
{
|
|
|
|
if (!isc.rotatep)
|
|
|
|
{
|
2015-05-26 00:47:54 +00:00
|
|
|
*x = isc.piv.x + mulscale16(*x-isc.piv.x, isc.xsc);
|
|
|
|
*y = isc.piv.y + mulscale16(*y-isc.piv.y, isc.ysc);
|
2012-11-04 23:03:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-26 00:47:54 +00:00
|
|
|
vec2_t v = { *x, *y };
|
|
|
|
rotatepoint(isc.piv, v, isc.ang, &v);
|
|
|
|
*x = v.x;
|
|
|
|
*y = v.y;
|
2012-11-04 23:03:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-10 07:56:48 +00:00
|
|
|
static void drawspritelabel(int i)
|
|
|
|
{
|
2015-07-11 14:13:04 +00:00
|
|
|
// XXX: oob 'i' may happen, such as passing pointhighlight-16384 when
|
|
|
|
// pointhighlight == -1.
|
|
|
|
if ((unsigned)i >= MAXSPRITES)
|
|
|
|
return;
|
|
|
|
|
2015-07-10 07:56:48 +00:00
|
|
|
const char *dabuffer = CallExtGetSpriteCaption(i);
|
|
|
|
|
2015-07-10 21:19:41 +00:00
|
|
|
if (!dabuffer[0])
|
|
|
|
return;
|
2015-07-10 07:56:48 +00:00
|
|
|
|
2015-11-14 23:40:59 +00:00
|
|
|
// KEEPINSYNC drawscreen_drawsprite()
|
2016-06-21 00:33:58 +00:00
|
|
|
uspritetype const * s = (uspritetype *)&sprite[i];
|
2016-03-15 22:17:04 +00:00
|
|
|
uint8_t const spritecol = spritecol2d[s->picnum][(s->cstat&1)];
|
2018-04-12 21:03:47 +00:00
|
|
|
int col = spritecol ? editorcolors[spritecol] : editorGet2dSpriteColor(i);
|
2016-03-15 22:17:04 +00:00
|
|
|
int const blocking = s->cstat & 1;
|
|
|
|
int bordercol = blocking ? editorcolors[5] : col;
|
2015-07-10 07:56:48 +00:00
|
|
|
|
2016-03-14 00:08:02 +00:00
|
|
|
// group selection
|
2015-07-17 00:12:48 +00:00
|
|
|
if (show2dsprite[i>>3]&pow2char[i&7])
|
2015-11-20 20:26:52 +00:00
|
|
|
{
|
2016-03-14 00:08:02 +00:00
|
|
|
bordercol = editorcolors[14];
|
|
|
|
col = bordercol - (M32_THROB>>1);
|
2015-11-20 20:26:52 +00:00
|
|
|
}
|
2015-07-17 00:12:48 +00:00
|
|
|
else if (i == pointhighlight - 16384)
|
2016-03-14 00:08:02 +00:00
|
|
|
{
|
|
|
|
if (spritecol >= 8 && spritecol <= 15)
|
|
|
|
col -= M32_THROB>>1;
|
|
|
|
else col += M32_THROB>>2;
|
|
|
|
|
2016-03-15 22:17:04 +00:00
|
|
|
if (bordercol > col && !blocking)
|
2016-03-14 00:08:02 +00:00
|
|
|
bordercol = col;
|
|
|
|
}
|
|
|
|
|
2016-03-15 22:17:04 +00:00
|
|
|
else if (s->sectnum < 0)
|
2016-03-14 00:08:02 +00:00
|
|
|
col = bordercol = editorcolors[4]; // red
|
2015-07-10 07:56:48 +00:00
|
|
|
|
2016-03-15 22:17:04 +00:00
|
|
|
drawsmallabel(dabuffer, editorcolors[0], col, bordercol, s->x, s->y, s->z);
|
2015-07-10 07:56:48 +00:00
|
|
|
}
|
|
|
|
|
2012-11-04 23:03:22 +00:00
|
|
|
#define EDITING_MAP_P() (newnumwalls>=0 || joinsector[0]>=0 || circlewall>=0 || (bstatus&1) || isc.active)
|
|
|
|
|
|
|
|
#define HLMEMBERX(Hl, Member) (*(((Hl)&16384) ? &sprite[(Hl)&16383].Member : &wall[Hl].Member))
|
|
|
|
#define HLMEMBER(Hlidx, Member) HLMEMBERX(highlight[Hlidx], Member)
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
void overheadeditor(void)
|
|
|
|
{
|
2011-10-30 19:47:26 +00:00
|
|
|
char buffer[80];
|
2011-04-11 22:28:58 +00:00
|
|
|
const char *dabuffer;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j, k, m=0, mousxplc, mousyplc, firstx=0, firsty=0, oposz, col;
|
2011-10-30 19:47:26 +00:00
|
|
|
int32_t numwalls_bak;
|
2011-10-17 18:42:10 +00:00
|
|
|
int32_t startwall=0, endwall, dax, day, x1, y1, x2, y2, x3, y3; //, x4, y4;
|
2011-03-08 23:02:38 +00:00
|
|
|
int32_t highlightx1, highlighty1, highlightx2, highlighty2;
|
2011-10-30 19:47:42 +00:00
|
|
|
int16_t bad, joinsector[2];
|
2012-11-04 23:03:22 +00:00
|
|
|
int32_t bstatus, mousewaitmask=0;
|
2011-10-30 19:47:26 +00:00
|
|
|
int16_t circlepoints;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t sectorhighlightx=0, sectorhighlighty=0;
|
|
|
|
int16_t cursectorhighlight, sectorhighlightstat;
|
2011-10-30 19:47:26 +00:00
|
|
|
int32_t prefixarg = 0, tsign;
|
2018-04-12 21:02:51 +00:00
|
|
|
int32_t resetsynctics = 0, lasttick=timerGetTicks(), waitdelay=totalclock, lastdraw=timerGetTicks();
|
2017-02-05 20:58:33 +00:00
|
|
|
int32_t olen[2] = {0, 0}, dragwall[2] = {-1, -1};
|
2015-07-11 17:06:30 +00:00
|
|
|
int16_t linehighlight2 = -1;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-10-30 19:47:42 +00:00
|
|
|
ovh.suckwall = -1;
|
|
|
|
ovh.split = 0;
|
|
|
|
ovh.splitsect = -1;
|
|
|
|
ovh.splitstartwall = -1;
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoSet2dMode(xdim2d,ydim2d);
|
2006-04-24 19:04:22 +00:00
|
|
|
xdim2d = xdim;
|
|
|
|
ydim2d = ydim;
|
|
|
|
|
|
|
|
osearchx = searchx;
|
|
|
|
osearchy = searchy;
|
|
|
|
|
2010-09-06 23:08:35 +00:00
|
|
|
searchx = clamp(scale(searchx,xdim2d,xdimgame), 8, xdim2d-8-1);
|
|
|
|
searchy = clamp(scale(searchy,ydim2d-STATUS2DSIZ2,ydimgame), 8, ydim2d-STATUS2DSIZ-8-1);
|
2009-01-13 12:23:18 +00:00
|
|
|
oposz = pos.z;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-05-07 18:23:34 +00:00
|
|
|
yax_updategrays(pos.z);
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoBeginDrawing(); //{{{
|
2010-05-22 14:04:47 +00:00
|
|
|
CLEARLINES2D(0, ydim, 0);
|
2018-04-12 21:02:51 +00:00
|
|
|
videoEndDrawing(); //}}}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2011-01-20 10:52:33 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
cursectorhighlight = -1;
|
|
|
|
lastpm16time = -1;
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
update_highlightsector();
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
ovh_whiteoutgrab(0);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-11-20 16:47:18 +00:00
|
|
|
highlightcnt = -1;
|
2010-05-18 05:14:17 +00:00
|
|
|
Bmemset(show2dwall, 0, sizeof(show2dwall)); //Clear all highlights
|
|
|
|
Bmemset(show2dsprite, 0, sizeof(show2dsprite));
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
RESET_EDITOR_VARS();
|
2006-04-24 19:04:22 +00:00
|
|
|
bstatus = 0;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2008-05-16 00:23:33 +00:00
|
|
|
while ((keystatus[buildkeys[BK_MODE2D_3D]]>>1) == 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2012-11-04 23:03:22 +00:00
|
|
|
int32_t mousx, mousy;
|
|
|
|
|
2015-07-08 03:34:46 +00:00
|
|
|
if (zoom < ztarget)
|
|
|
|
{
|
|
|
|
if ((ztarget - zoom) >> 3)
|
2015-07-11 23:07:47 +00:00
|
|
|
zoom += synctics * ((ztarget - zoom) >> 3);
|
2015-07-08 03:34:46 +00:00
|
|
|
else zoom++;
|
|
|
|
zoom = min(zoom, ztarget);
|
|
|
|
}
|
|
|
|
else if (zoom > ztarget)
|
|
|
|
{
|
|
|
|
if ((zoom - ztarget) >> 3)
|
2015-07-11 23:07:47 +00:00
|
|
|
zoom -= synctics * ((zoom - ztarget) >> 3);
|
2015-07-08 03:34:46 +00:00
|
|
|
else zoom--;
|
|
|
|
zoom = max(zoom, ztarget);
|
|
|
|
}
|
2015-07-08 03:34:42 +00:00
|
|
|
|
2015-07-17 00:12:48 +00:00
|
|
|
if (!((vel|angvel|svel) || m32_is2d3dmode() || ztarget != zoom//DOWN_BK(MOVEFORWARD) || DOWN_BK(MOVEBACKWARD) || DOWN_BK(TURNLEFT) || DOWN_BK(TURNRIGHT)
|
2011-01-16 02:50:27 +00:00
|
|
|
|| DOWN_BK(MOVEUP) || DOWN_BK(MOVEDOWN) || keystatus[0x10] || keystatus[0x11]
|
|
|
|
|| keystatus[0x48] || keystatus[0x4b] || keystatus[0x4d] || keystatus[0x50] // keypad keys
|
2015-07-10 07:56:35 +00:00
|
|
|
|| bstatus || OSD_IsMoving()))
|
2010-05-10 21:23:30 +00:00
|
|
|
{
|
2010-05-19 10:02:35 +00:00
|
|
|
if (totalclock > waitdelay)
|
|
|
|
{
|
2015-07-09 03:55:24 +00:00
|
|
|
uint32_t ms = 50;// (highlightsectorcnt>0) ? 75 : 200;
|
2010-05-19 10:02:35 +00:00
|
|
|
// wait for event, timeout after 200 ms - (last loop time)
|
2018-04-12 21:02:51 +00:00
|
|
|
idle_waitevent_timeout(ms - min(timerGetTicks()-lasttick, ms));
|
2010-05-19 10:02:35 +00:00
|
|
|
// have synctics reset to 0 after we've slept to avoid zooming out to the max instantly
|
|
|
|
resetsynctics = 1;
|
|
|
|
}
|
2010-05-10 21:23:30 +00:00
|
|
|
}
|
2015-07-09 03:55:24 +00:00
|
|
|
else waitdelay = totalclock + 6; // should be 50 ms
|
2010-05-19 10:02:35 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
lasttick = timerGetTicks();
|
2010-05-02 23:27:30 +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
|
|
|
|
2010-05-10 21:23:30 +00:00
|
|
|
if (resetsynctics)
|
|
|
|
{
|
|
|
|
resetsynctics = 0;
|
|
|
|
lockclock = totalclock;
|
|
|
|
synctics = 0;
|
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
OSD_DispatchQueued();
|
|
|
|
|
2009-05-06 23:58:53 +00:00
|
|
|
if (totalclock < 120*3)
|
2010-05-02 23:27:30 +00:00
|
|
|
printmessage16("Uses BUILD technology by Ken Silverman.");
|
2009-05-06 23:58:53 +00:00
|
|
|
else if (totalclock < 120*6)
|
|
|
|
{
|
|
|
|
printmessage16("Press F1 for help. This is a test release; always keep backups of your maps.");
|
|
|
|
// printext16(8L,ydim-STATUS2DSIZ+32L,editorcolors[9],-1,kensig,0);
|
|
|
|
}
|
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
if (!m32_is2d3dmode())
|
2012-11-04 23:03:22 +00:00
|
|
|
{
|
2015-07-08 03:34:42 +00:00
|
|
|
oldmousebstatus = bstatus;
|
2018-04-12 21:03:47 +00:00
|
|
|
mouseGetValues(&mousx, &mousy, &bstatus);
|
2012-11-04 23:03:22 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
{
|
|
|
|
int32_t bs = bstatus;
|
|
|
|
bstatus &= ~mousewaitmask;
|
|
|
|
mousewaitmask &= bs;
|
|
|
|
}
|
2010-05-02 23:27:30 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
mousx = (mousx<<16)+mousexsurp;
|
|
|
|
mousy = (mousy<<16)+mouseysurp;
|
|
|
|
{
|
|
|
|
ldiv_t ld;
|
|
|
|
ld = ldiv(mousx, 1<<16); mousx = ld.quot; mousexsurp = ld.rem;
|
|
|
|
ld = ldiv(mousy, 1<<16); mousy = ld.quot; mouseysurp = ld.rem;
|
|
|
|
}
|
|
|
|
searchx += mousx;
|
|
|
|
searchy += mousy;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
inpclamp(&searchx, 8, xdim-8-1);
|
|
|
|
inpclamp(&searchy, 8, ydim-8-1);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
mainloop_move();
|
|
|
|
|
|
|
|
getpoint(searchx, searchy, &mousxplc, &mousyplc);
|
|
|
|
linehighlight = getlinehighlight(mousxplc, mousyplc, linehighlight, 0);
|
|
|
|
linehighlight2 = getlinehighlight(mousxplc, mousyplc, linehighlight, 1);
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if (newnumwalls >= numwalls)
|
|
|
|
{
|
2010-05-28 23:08:32 +00:00
|
|
|
// if we're in the process of drawing a wall, set the end point's coordinates
|
2006-04-24 19:04:22 +00:00
|
|
|
dax = mousxplc;
|
|
|
|
day = mousyplc;
|
2011-11-25 09:52:08 +00:00
|
|
|
adjustmark(&dax,&day,numwalls+!ovh.split);
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[newnumwalls].x = dax;
|
|
|
|
wall[newnumwalls].y = day;
|
|
|
|
}
|
|
|
|
|
2010-07-03 08:53:57 +00:00
|
|
|
ydim16 = ydim;// - STATUS2DSIZ2;
|
|
|
|
midydim16 = ydim>>1;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-10-30 19:47:26 +00:00
|
|
|
numwalls_bak = numwalls;
|
2006-04-24 19:04:22 +00:00
|
|
|
numwalls = newnumwalls;
|
2011-02-24 20:40:27 +00:00
|
|
|
if (numwalls < 0)
|
2011-10-30 19:47:26 +00:00
|
|
|
numwalls = numwalls_bak;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
if ((timerGetTicks() - lastdraw) >= 5 || (vel|angvel|svel) || DOWN_BK(MOVEUP) || DOWN_BK(MOVEDOWN)
|
2011-01-16 02:50:27 +00:00
|
|
|
|| mousx || mousy || bstatus || keystatus[0x10] || keystatus[0x11]
|
|
|
|
|| newnumwalls>=0 || OSD_IsMoving())
|
2010-05-18 05:14:17 +00:00
|
|
|
{
|
2018-04-12 21:02:51 +00:00
|
|
|
lastdraw = timerGetTicks();
|
2010-05-19 10:02:35 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
clear2dscreen();
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
editorSetup2dSideView();
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2015-08-15 21:28:05 +00:00
|
|
|
VM_OnEvent(EVENT_PREDRAW2DSCREEN, -1);
|
|
|
|
|
2015-07-08 03:34:31 +00:00
|
|
|
if (graphicsmode && (!m32_sideview || m32_sideelev == 512))
|
2010-05-18 05:14:17 +00:00
|
|
|
{
|
2011-09-17 14:25:42 +00:00
|
|
|
Bmemset(show2dsector, 0, sizeof(show2dsector));
|
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
{
|
|
|
|
YAX_SKIPSECTOR(i);
|
|
|
|
show2dsector[i>>3] |= (1<<(i&7));
|
|
|
|
}
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoSetViewableArea(0, 0, xdim-1, ydim16-1);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
|
|
|
if (graphicsmode == 2)
|
|
|
|
totalclocklock = totalclock;
|
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
renderDrawMapView(pos.x, pos.y, zoom, m32_sideview ? (3584 - m32_sideang) & 2047: 1536);
|
2010-05-18 05:14:17 +00:00
|
|
|
}
|
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dGrid(pos.x,pos.y,pos.z,cursectnum,ang,zoom,grid);
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtPreCheckKeys();
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dScreen(&pos,cursectnum,ang,zoom,grid);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-07-11 23:07:47 +00:00
|
|
|
// Draw brown arrow (start)
|
2018-04-12 21:03:47 +00:00
|
|
|
editorGet2dScreenCoordinates(&x2, &y2, startpos.x-pos.x,startpos.y-pos.y, zoom);
|
2015-07-11 23:07:47 +00:00
|
|
|
if (m32_sideview)
|
|
|
|
y2 += getscreenvdisp(startpos.z-pos.z, zoom);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2015-07-11 23:07:47 +00:00
|
|
|
int32_t cx = halfxdim16+x2;
|
|
|
|
int32_t cy = midydim16+y2;
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoBeginDrawing(); //{{{ LOCK_FRAME_1
|
2015-07-25 17:23:20 +00:00
|
|
|
|
2015-07-11 23:07:47 +00:00
|
|
|
if ((cx >= 2 && cx <= xdim-3) && (cy >= 2 && cy <= ydim16-3))
|
|
|
|
{
|
|
|
|
int16_t angofs = m32_sideview ? m32_sideang : 0;
|
|
|
|
x1 = mulscale11(sintable[(startang+angofs+2560)&2047],zoom) / 768;
|
|
|
|
y1 = mulscale11(sintable[(startang+angofs+2048)&2047],zoom) / 768;
|
|
|
|
i = scalescreeny(x1);
|
|
|
|
j = scalescreeny(y1);
|
|
|
|
drawline16base(cx,cy, x1,j, -x1,-j, editorcolors[6]);
|
|
|
|
drawline16base(cx,cy, x1,j, +y1,-i, editorcolors[6]);
|
|
|
|
drawline16base(cx,cy, x1,j, -y1,+i, editorcolors[6]);
|
2010-05-18 05:14:17 +00:00
|
|
|
}
|
|
|
|
|
2012-11-04 23:03:22 +00:00
|
|
|
if (keystatus[0x2a] && (pointhighlight&16384) && highlightcnt<=0) // LShift
|
2012-11-03 19:32:39 +00:00
|
|
|
{
|
|
|
|
// draw lines to linking sprites
|
|
|
|
const int32_t refspritenum = pointhighlight&16383;
|
|
|
|
const int32_t reftag = select_sprite_tag(refspritenum);
|
|
|
|
|
|
|
|
if (reftag != INT32_MIN)
|
|
|
|
{
|
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
for (SPRITES_OF_SECT(i, j))
|
|
|
|
if (reftag==select_sprite_tag(j))
|
2012-11-04 23:03:22 +00:00
|
|
|
drawlinebetween((vec3_t *)&sprite[refspritenum], (vec3_t *)&sprite[j],
|
|
|
|
editorcolors[12], 0x33333333);
|
2012-11-03 19:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-17 17:01:20 +00:00
|
|
|
if (showtags)
|
2010-05-18 05:14:17 +00:00
|
|
|
{
|
|
|
|
if (zoom >= 768)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
int16_t secshort = i;
|
|
|
|
|
2011-04-28 21:28:33 +00:00
|
|
|
YAX_SKIPSECTOR(i);
|
|
|
|
|
2014-07-24 14:01:44 +00:00
|
|
|
dabuffer = CallExtGetSectorCaption(i);
|
2011-02-24 20:40:27 +00:00
|
|
|
if (dabuffer[0] == 0)
|
|
|
|
continue;
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
get_sectors_center(&secshort, 1, &dax, &day);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2015-07-10 07:56:48 +00:00
|
|
|
drawsmallabel(dabuffer, editorcolors[0], editorcolors[7], editorcolors[7] - 3, dax, day, getflorzofslope(i,dax,day));
|
2010-05-18 05:14:17 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
x3 = pos.x + divscale14(-halfxdim16,zoom);
|
|
|
|
y3 = pos.y + divscale14(-(midydim16-4),zoom);
|
2011-10-17 18:42:10 +00:00
|
|
|
// x4 = pos.x + divscale14(halfxdim16,zoom);
|
|
|
|
// y4 = pos.y + divscale14(ydim16-(midydim16-4),zoom);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (newnumwalls >= 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-10-30 19:47:26 +00:00
|
|
|
for (i=newnumwalls; i>=numwalls_bak; i--)
|
2010-05-18 05:14:17 +00:00
|
|
|
wall[i].cstat |= (1<<14);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
i = numwalls-1;
|
2012-02-01 21:51:26 +00:00
|
|
|
j = numsectors-1; // might be -1 if empty map!
|
2010-05-18 05:14:17 +00:00
|
|
|
if (newnumwalls >= 0)
|
|
|
|
i = newnumwalls-1;
|
2011-10-30 19:47:26 +00:00
|
|
|
for (; i>=0; i--)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2015-01-11 04:56:38 +00:00
|
|
|
walltype const * const wal = &wall[i];
|
2011-10-30 19:47:26 +00:00
|
|
|
|
2012-02-01 21:51:26 +00:00
|
|
|
if (j>=0 && sector[j].wallptr > i)
|
2011-04-11 22:28:58 +00:00
|
|
|
j--;
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if (zoom < 768 && !(wal->cstat & (1<<14)))
|
|
|
|
continue;
|
2011-02-10 23:15:02 +00:00
|
|
|
|
2011-04-28 21:28:33 +00:00
|
|
|
YAX_SKIPWALL(i);
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
//Get average point of wall
|
2011-04-11 22:28:58 +00:00
|
|
|
// if ((dax > x3) && (dax < x4) && (day > y3) && (day < y4))
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2014-07-24 14:01:44 +00:00
|
|
|
dabuffer = CallExtGetWallCaption(i);
|
2011-03-07 16:30:06 +00:00
|
|
|
if (dabuffer[0] == 0)
|
|
|
|
continue;
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2011-04-11 22:28:58 +00:00
|
|
|
dax = (wal->x+wall[wal->point2].x)>>1;
|
|
|
|
day = (wal->y+wall[wal->point2].y)>>1;
|
2015-07-10 07:56:48 +00:00
|
|
|
drawsmallabel(dabuffer, editorcolors[0], editorcolors[31], editorcolors[31] - 3, dax, day, (i >= numwalls || j<0) ? 0 : getflorzofslope(j, dax,day));
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (zoom >= 768)
|
2011-08-18 22:01:01 +00:00
|
|
|
{
|
2013-03-29 15:59:14 +00:00
|
|
|
int32_t alwaysshowgray = get_alwaysshowgray();
|
2011-08-18 22:01:01 +00:00
|
|
|
|
2011-04-28 21:28:33 +00:00
|
|
|
for (i=0, k=0; (m32_sideview && k<m32_swcnt) || (!m32_sideview && i<MAXSPRITES); i++, k++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-11-27 22:12:24 +00:00
|
|
|
if (m32_sideview)
|
|
|
|
{
|
2011-04-28 21:28:33 +00:00
|
|
|
i = m32_wallsprite[k];
|
2010-11-27 22:12:24 +00:00
|
|
|
if (i<MAXWALLS)
|
|
|
|
continue;
|
|
|
|
i = i-MAXWALLS;
|
|
|
|
}
|
2011-04-28 21:28:33 +00:00
|
|
|
else
|
|
|
|
if (sprite[i].statnum == MAXSTATUS)
|
|
|
|
continue;
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2011-08-18 22:01:01 +00:00
|
|
|
if ((!m32_sideview || !alwaysshowgray) && sprite[i].sectnum >= 0)
|
2011-04-28 21:28:33 +00:00
|
|
|
YAX_SKIPSECTOR(sprite[i].sectnum);
|
|
|
|
|
2015-07-10 07:56:48 +00:00
|
|
|
drawspritelabel(i);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2015-07-10 07:56:48 +00:00
|
|
|
|
|
|
|
if (pointhighlight & 16384)
|
|
|
|
drawspritelabel(pointhighlight - 16384);
|
2011-08-18 22:01:01 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-03-07 16:30:06 +00:00
|
|
|
// stick this event right between begin- end enddrawing()...
|
|
|
|
// also after the above label stuff so users can redefine them
|
|
|
|
VM_OnEvent(EVENT_DRAW2DSCREEN, -1);
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
printcoords16(pos.x,pos.y,ang);
|
|
|
|
|
2011-10-30 19:47:26 +00:00
|
|
|
numwalls = numwalls_bak;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-03-05 12:59:27 +00:00
|
|
|
if (highlightsectorcnt >= 0)
|
2011-03-07 16:30:06 +00:00
|
|
|
{
|
2010-11-20 16:47:18 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
if (hlsectorbitmap[i>>3]&(1<<(i&7)))
|
2011-04-22 22:48:06 +00:00
|
|
|
fillsector(i, -1);
|
2011-03-07 16:30:06 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2012-11-04 23:03:22 +00:00
|
|
|
if (keystatus[0x2a]) // LShift
|
2010-05-18 05:14:17 +00:00
|
|
|
{
|
2015-07-08 03:34:42 +00:00
|
|
|
if (!m32_is2d3dmode() && (m32_sideview || highlightcnt <= 0))
|
2012-11-04 23:03:22 +00:00
|
|
|
{
|
|
|
|
drawlinepat = 0x00ff00ff;
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dLine(searchx,0, searchx,ydim2d-1, editorcolors[15]);
|
|
|
|
editorDraw2dLine(0,searchy, xdim2d-1,searchy, editorcolors[15]);
|
2012-11-04 23:03:22 +00:00
|
|
|
drawlinepat = 0xffffffff;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2012-11-04 23:03:22 +00:00
|
|
|
_printmessage16("(%d,%d)",mousxplc,mousyplc);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// do interactive scaling
|
|
|
|
if (!isc.active)
|
|
|
|
{
|
|
|
|
if (pointhighlight >= 0 && (bstatus&3))
|
|
|
|
{
|
|
|
|
// initialize by finding pivot point
|
|
|
|
int32_t minx=INT32_MAX, miny=INT32_MAX;
|
|
|
|
int32_t maxx=INT32_MIN, maxy=INT32_MIN;
|
|
|
|
|
|
|
|
isc.rotatep = ((bstatus&3)==2);
|
|
|
|
bstatus &= ~3;
|
|
|
|
|
|
|
|
for (i=0; i<highlightcnt; i++)
|
|
|
|
{
|
|
|
|
minx = min(minx, HLMEMBER(i, x));
|
|
|
|
miny = min(miny, HLMEMBER(i, y));
|
|
|
|
maxx = max(maxx, HLMEMBER(i, x));
|
|
|
|
maxy = max(maxy, HLMEMBER(i, y));
|
|
|
|
}
|
|
|
|
|
2015-05-26 00:47:54 +00:00
|
|
|
isc.piv.x = (minx+maxx)/2;
|
|
|
|
isc.piv.y = (miny+maxy)/2;
|
2012-11-04 23:03:22 +00:00
|
|
|
|
|
|
|
isc.dragx = HLMEMBERX(pointhighlight, x);
|
|
|
|
isc.dragy = HLMEMBERX(pointhighlight, y);
|
|
|
|
|
|
|
|
isc.xsc = isc.ysc = 1<<16;
|
|
|
|
isc.ang = 0;
|
|
|
|
|
|
|
|
isc.active = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (bstatus&3)
|
|
|
|
{
|
|
|
|
// drag/rotate the reference point
|
2015-05-26 00:47:54 +00:00
|
|
|
const int32_t pivx=isc.piv.x, pivy=isc.piv.y;
|
2012-11-04 23:03:22 +00:00
|
|
|
const int32_t dragx=isc.dragx, dragy=isc.dragy;
|
|
|
|
int32_t mxplc=mousxplc, myplc=mousyplc, xsc=1<<16, ysc=1<<16;
|
|
|
|
|
|
|
|
const int32_t dx=dragx-pivx, dy=dragy-pivy;
|
|
|
|
int32_t mdx, mdy;
|
|
|
|
|
|
|
|
bstatus &= ~3;
|
|
|
|
|
|
|
|
draw_cross(pivx, pivy, 3, editorcolors[14]);
|
|
|
|
|
|
|
|
adjustmark(&mxplc, &myplc, numwalls);
|
|
|
|
mdx = mxplc-pivx;
|
|
|
|
mdy = myplc-pivy;
|
|
|
|
|
|
|
|
if (!isc.rotatep)
|
|
|
|
{
|
|
|
|
if (mdx != 0 && dx != 0 && klabs(dx) >= 8)
|
|
|
|
xsc = min(klabs(divscale16(mdx, dx)), 1<<18);
|
|
|
|
if (mdy != 0 && dy != 0 && klabs(dy) >= 8)
|
|
|
|
ysc = min(klabs(divscale16(mdy, dy)), 1<<18);
|
|
|
|
|
|
|
|
if (eitherCTRL)
|
|
|
|
xsc = ysc = max(xsc, ysc);
|
|
|
|
|
|
|
|
isc.xsc = xsc;
|
|
|
|
isc.ysc = ysc;
|
|
|
|
|
|
|
|
printmessage16("scale x=%.3f y=%.3f", (double)xsc/65536, (double)ysc/65536);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
isc.ang = getangle(mdx, mdy) - getangle(dx, dy);
|
|
|
|
printmessage16("rotate ang %d", isc.ang);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<highlightcnt; i++)
|
|
|
|
{
|
|
|
|
int32_t x=HLMEMBER(i, x), y=HLMEMBER(i, y);
|
|
|
|
|
|
|
|
isc_transform(&x, &y);
|
|
|
|
|
|
|
|
draw_square(x, y, 2, editorcolors[15]);
|
|
|
|
|
|
|
|
if ((highlight[i]&16384)==0)
|
|
|
|
{
|
2015-01-11 04:56:38 +00:00
|
|
|
walltype const * const wal = &wall[highlight[i]];
|
2012-11-04 23:03:22 +00:00
|
|
|
const int32_t p2=wal->point2, hlp=(show2dwall[p2>>3]&(1<<(p2&7)));
|
|
|
|
vec3_t v1 = { x, y, 0 }, v2 = { wall[p2].x, wall[p2].y, 0 };
|
|
|
|
|
|
|
|
isc_transform(&v2.x, &v2.y);
|
|
|
|
if (!hlp)
|
|
|
|
{
|
|
|
|
v2.x = wall[p2].x;
|
|
|
|
v2.y = wall[p2].y;
|
|
|
|
}
|
|
|
|
|
|
|
|
drawlinebetween(&v1, &v2, !hlp ? 8 :
|
2015-11-14 23:40:59 +00:00
|
|
|
editorcolors[wal->nextwall >= 0 ? 12 : 7],
|
2012-11-04 23:03:22 +00:00
|
|
|
0x11111111);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// finish interactive scaling
|
|
|
|
isc.active = 0;
|
|
|
|
|
|
|
|
if ((!isc.rotatep && (isc.xsc!=1<<16 || isc.ysc!=1<<16)) ||
|
|
|
|
(isc.rotatep && (isc.ang!=0)))
|
|
|
|
{
|
|
|
|
for (i=0; i<highlightcnt; i++)
|
|
|
|
{
|
|
|
|
int32_t *x=&HLMEMBER(i, x), *y=&HLMEMBER(i, y);
|
|
|
|
|
|
|
|
isc_transform(x, y);
|
|
|
|
|
|
|
|
if (isc.rotatep && (highlight[i]&16384))
|
|
|
|
{
|
|
|
|
spritetype *spr = &sprite[highlight[i]&16383];
|
|
|
|
spr->ang = (spr->ang + isc.ang)&2047;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isc.rotatep)
|
|
|
|
message("Highlights scaled by x=%.3f y=%.3f",
|
|
|
|
(double)isc.xsc/65536, (double)isc.ysc/65536);
|
|
|
|
else
|
|
|
|
message("Highlights rotated by %d BUILD degrees", isc.ang);
|
|
|
|
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printmessage16(" ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (isc.active)
|
|
|
|
{
|
|
|
|
isc.active = 0;
|
|
|
|
|
|
|
|
printmessage16("Aborted interactive %s.", isc.rotatep ? "rotation" : "scaling");
|
|
|
|
bstatus &= ~3;
|
|
|
|
mousewaitmask = 3;
|
|
|
|
pointhighlight = -1;
|
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
}
|
2012-11-04 23:03:22 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dLine(searchx,0, searchx,8, editorcolors[15]);
|
|
|
|
editorDraw2dLine(0,searchy, 8,searchy, editorcolors[15]);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
// 2d3d mode
|
2015-07-17 00:12:48 +00:00
|
|
|
if (m32_2d3dmode && m32_2d3d_resolutions_match())
|
2011-01-16 00:23:39 +00:00
|
|
|
{
|
2015-08-15 21:28:49 +00:00
|
|
|
#ifdef USE_OPENGL
|
2015-07-08 03:34:42 +00:00
|
|
|
int bakrendmode = rendmode;
|
2015-08-15 21:28:49 +00:00
|
|
|
#endif
|
2017-02-05 20:58:33 +00:00
|
|
|
vec2_t bdim = { xdim, ydim };
|
2011-02-13 15:15:37 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
xdim = xdim2d;
|
|
|
|
ydim = ydim2d;
|
2015-08-15 21:28:49 +00:00
|
|
|
#ifdef USE_OPENGL
|
2015-07-08 03:34:42 +00:00
|
|
|
rendmode = REND_CLASSIC;
|
2015-08-15 21:28:49 +00:00
|
|
|
#endif
|
2015-07-08 03:34:42 +00:00
|
|
|
|
|
|
|
if (m32_2d3d.x + XSIZE_2D3D > xdim2d - 4)
|
|
|
|
m32_2d3d.x = xdim2d - 4 - XSIZE_2D3D;
|
|
|
|
|
|
|
|
if (m32_2d3d.y + YSIZE_2D3D > ydim2d - 4 - STATUS2DSIZ2)
|
|
|
|
m32_2d3d.y = ydim2d - 4 - YSIZE_2D3D - STATUS2DSIZ2;
|
|
|
|
|
2015-07-17 00:12:48 +00:00
|
|
|
updatesectorz(pos.x, pos.y, pos.z, &cursectnum);
|
2015-07-08 03:34:42 +00:00
|
|
|
|
2015-07-17 00:12:48 +00:00
|
|
|
if (cursectnum == -1)
|
|
|
|
updatesector(pos.x, pos.y, &cursectnum);
|
|
|
|
|
|
|
|
if (cursectnum != -1)
|
|
|
|
{
|
|
|
|
int32_t cz, fz;
|
2015-07-08 03:34:42 +00:00
|
|
|
|
2015-07-17 00:12:48 +00:00
|
|
|
getzsofslope(cursectnum, pos.x, pos.y, &cz, &fz);
|
2015-07-08 03:34:42 +00:00
|
|
|
|
2015-07-17 00:12:48 +00:00
|
|
|
inpclamp(&pos.z, cz+(4<<8), fz-(4<<8));
|
2015-07-08 03:34:42 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoEndDrawing();
|
|
|
|
videoSetViewableArea(m32_2d3d.x, m32_2d3d.y, m32_2d3d.x + XSIZE_2D3D, m32_2d3d.y + YSIZE_2D3D);
|
|
|
|
videoClearViewableArea(-1);
|
2011-02-13 15:15:37 +00:00
|
|
|
|
2017-02-05 20:58:33 +00:00
|
|
|
vec2_t osearch = { searchx, searchy };
|
2015-07-17 00:12:48 +00:00
|
|
|
|
|
|
|
searchx -= m32_2d3d.x;
|
|
|
|
searchy -= m32_2d3d.y;
|
|
|
|
|
|
|
|
M32_DrawRoomsAndMasks();
|
2018-04-12 21:02:51 +00:00
|
|
|
videoSetViewableArea(0, 0, xdim2d-1, ydim2d-1);
|
2015-07-17 00:12:48 +00:00
|
|
|
|
2015-08-15 21:28:49 +00:00
|
|
|
#ifdef USE_OPENGL
|
2015-07-17 00:12:48 +00:00
|
|
|
rendmode = bakrendmode;
|
2015-08-15 21:28:49 +00:00
|
|
|
#endif
|
2015-07-17 00:12:48 +00:00
|
|
|
xdim = bdim.x;
|
|
|
|
ydim = bdim.y;
|
|
|
|
searchx = osearch.x;
|
|
|
|
searchy = osearch.y;
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoBeginDrawing();
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dLine(m32_2d3d.x, m32_2d3d.y, m32_2d3d.x + XSIZE_2D3D, m32_2d3d.y, editorcolors[15]);
|
|
|
|
editorDraw2dLine(m32_2d3d.x + XSIZE_2D3D, m32_2d3d.y, m32_2d3d.x + XSIZE_2D3D, m32_2d3d.y + YSIZE_2D3D, editorcolors[15]);
|
|
|
|
editorDraw2dLine(m32_2d3d.x, m32_2d3d.y, m32_2d3d.x, m32_2d3d.y + YSIZE_2D3D, editorcolors[15]);
|
|
|
|
editorDraw2dLine(m32_2d3d.x, m32_2d3d.y + YSIZE_2D3D, m32_2d3d.x + XSIZE_2D3D, m32_2d3d.y + YSIZE_2D3D, editorcolors[15]);
|
2015-07-17 00:12:48 +00:00
|
|
|
}
|
2011-01-16 00:23:39 +00:00
|
|
|
}
|
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
if (!m32_is2d3dmode())
|
2010-08-26 13:50:09 +00:00
|
|
|
{
|
2015-07-08 03:34:42 +00:00
|
|
|
////// draw mouse pointer
|
2015-07-17 00:12:48 +00:00
|
|
|
|
|
|
|
col = editorcolors[0];
|
|
|
|
|
|
|
|
drawline16base(searchx+1, searchy+1, +0, -8, +0, -1, col);
|
|
|
|
drawline16base(searchx+1, searchy+1, +0, 1, +0, 8, col);
|
|
|
|
|
|
|
|
drawline16base(searchx+1, searchy+1, -8, 0, -1, 0, col);
|
|
|
|
drawline16base(searchx+1, searchy+1, 1, 0, 8, 0, col);
|
|
|
|
|
2015-07-10 07:56:48 +00:00
|
|
|
col = searchlock ? editorcolors[13] : editorcolors[15 - 3*gridlock];
|
2015-07-17 00:12:48 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
if (joinsector[0] >= 0)
|
|
|
|
col = editorcolors[11];
|
|
|
|
|
|
|
|
if (numcorruptthings>0)
|
2010-08-26 13:50:09 +00:00
|
|
|
{
|
2015-07-08 03:34:42 +00:00
|
|
|
static char cbuf[64];
|
2010-08-26 13:50:09 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
if ((pointhighlight&16384)==0)
|
|
|
|
{
|
|
|
|
// If aiming at wall, check whether it is corrupt, and print a
|
|
|
|
// warning message near the mouse pointer if that is the case.
|
|
|
|
for (i=0; i<numcorruptthings; i++)
|
|
|
|
if ((corruptthings[i]&CORRUPT_MASK)==CORRUPT_WALL &&
|
|
|
|
(corruptthings[i]&(MAXWALLS-1))==pointhighlight)
|
|
|
|
{
|
|
|
|
col = editorcolors[13];
|
|
|
|
printext16(searchx+6, searchy-6-8, editorcolors[13], editorcolors[0], "corrupt wall", 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-07-24 15:15:57 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
Bsprintf(cbuf, "Map corrupt (level %d): %s%d errors", corruptlevel,
|
|
|
|
numcorruptthings>=MAXCORRUPTTHINGS ? ">=" : "", numcorruptthings);
|
2015-07-17 00:12:48 +00:00
|
|
|
printext16(8, 8, editorcolors[13]+(M32_THROB>>2), editorcolors[0], cbuf, 0);
|
2015-07-08 03:34:42 +00:00
|
|
|
}
|
2011-11-26 22:40:07 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
if (highlightsectorcnt==0 || highlightcnt==0)
|
2011-07-24 15:15:57 +00:00
|
|
|
{
|
2015-07-08 03:34:42 +00:00
|
|
|
if (keystatus[0x27] || keystatus[0x28]) // ' and ;
|
|
|
|
{
|
|
|
|
col = editorcolors[14];
|
|
|
|
|
|
|
|
drawline16base(searchx+16, searchy-16, -4, 0, +4, 0, col);
|
|
|
|
if (keystatus[0x28])
|
|
|
|
drawline16base(searchx+16, searchy-16, 0, -4, 0, +4, col);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (highlightsectorcnt == 0)
|
|
|
|
if (keystatus[0x36])
|
|
|
|
printext16(searchx+6, searchy-2+8, editorcolors[12], -1, "ALL", 0);
|
|
|
|
|
|
|
|
if (highlightcnt == 0)
|
|
|
|
{
|
|
|
|
if (eitherCTRL && (highlightx1!=highlightx2 || highlighty1!=highlighty2))
|
|
|
|
printext16(searchx+6, searchy-6-8, editorcolors[12], -1, "SPR ONLY", 0);
|
2011-07-24 15:15:57 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2015-07-08 03:34:42 +00:00
|
|
|
if (keystatus[0xcf]) // End
|
|
|
|
printext16(searchx+6, searchy-2+8, editorcolors[12], -1, "ALL", 0);
|
2011-07-24 15:15:57 +00:00
|
|
|
#endif
|
2015-07-08 03:34:42 +00:00
|
|
|
}
|
2011-07-24 15:15:57 +00:00
|
|
|
}
|
2010-08-26 13:50:09 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
drawline16base(searchx, searchy, +0, -8, +0, -1, col);
|
2015-07-08 03:34:46 +00:00
|
|
|
drawline16base(searchx, searchy, +0, 1, +0, 8, col);
|
|
|
|
|
|
|
|
drawline16base(searchx, searchy, -8, 0, -1, 0, col);
|
|
|
|
drawline16base(searchx, searchy, 1, 0, 8, 0, col);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
////// Draw the white pixel closest to mouse cursor on linehighlight
|
|
|
|
if (linehighlight>=0)
|
2011-04-11 22:28:58 +00:00
|
|
|
{
|
2015-07-08 03:34:42 +00:00
|
|
|
char col = wall[linehighlight].nextsector >= 0 ? editorcolors[15] : editorcolors[5];
|
|
|
|
|
|
|
|
if (m32_sideview)
|
|
|
|
{
|
|
|
|
getclosestpointonwall(searchx, searchy, linehighlight, &dax, &day, 1);
|
|
|
|
drawline16base(dax, day, 0, 0, 0, 0, col);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
getclosestpointonwall(mousxplc, mousyplc, linehighlight, &dax, &day, 0);
|
|
|
|
ovhscrcoords(dax, day, &x2, &y2);
|
|
|
|
drawline16base(x2, y2, 0, 0, 0, 0, col);
|
|
|
|
}
|
2011-04-11 22:28:58 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
}
|
2011-01-20 10:52:33 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoEndDrawing(); //}}} LOCK_FRAME_1
|
2010-05-18 05:14:17 +00:00
|
|
|
|
|
|
|
OSD_Draw();
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2013-12-20 07:24:09 +00:00
|
|
|
inputchecked = 1;
|
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
VM_OnEvent(EVENT_PREKEYS2D, -1);
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtCheckKeys(); // TX 20050101, it makes more sense to have this here so keys can be overwritten with new functions in bstub.c
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
// 2d3d mode
|
|
|
|
if (m32_is2d3dmode())
|
|
|
|
goto nokeys;
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
// Flip/mirror sector Ed Coolidge
|
|
|
|
if (keystatus[0x2d] || keystatus[0x15]) // X or Y (2D)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
int32_t about_x=keystatus[0x2d];
|
2011-02-24 20:40:27 +00:00
|
|
|
int32_t doMirror = eitherALT; // mirror walls and wall/floor sprites
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (highlightsectorcnt > 0 && !hl_all_bunch_sectors_p())
|
|
|
|
{
|
|
|
|
printmessage16("To flip extended sectors, all sectors of a bunch must be selected");
|
2011-12-21 18:42:32 +00:00
|
|
|
keystatus[0x2d] = keystatus[0x15] = 0;
|
2011-06-04 00:06:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
if (highlightsectorcnt > 0)
|
|
|
|
{
|
2012-01-20 22:12:11 +00:00
|
|
|
int16_t *const otonwall = onextwall; // OK, since we make old-nextwalls invalid
|
|
|
|
|
|
|
|
mkonwinvalid();
|
|
|
|
|
2010-05-22 14:04:47 +00:00
|
|
|
keystatus[0x2d] = keystatus[0x15] = 0;
|
|
|
|
|
2012-01-20 22:12:11 +00:00
|
|
|
for (j=0; j<numwalls; j++)
|
|
|
|
otonwall[j] = j;
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
get_sectors_center(highlightsector, highlightsectorcnt, &dax, &day);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (gridlock && grid > 0)
|
|
|
|
locktogrid(&dax, &day);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
int32_t startofloop, endofloop;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t numtoswap = -1;
|
|
|
|
int32_t w=0;
|
2016-06-21 00:33:58 +00:00
|
|
|
uwalltype tempwall;
|
2006-10-17 01:12:31 +00:00
|
|
|
|
|
|
|
startofloop = startwall = sector[highlightsector[i]].wallptr;
|
|
|
|
endofloop = endwall = startwall+sector[highlightsector[i]].wallnum-1;
|
2011-02-24 20:40:27 +00:00
|
|
|
#if 0
|
|
|
|
if (doMirror)
|
|
|
|
{
|
|
|
|
//mirror sector textures
|
|
|
|
sector[highlightsector[i]].ceilingstat ^= 0x10;
|
|
|
|
sector[highlightsector[i]].floorstat ^= 0x10;
|
|
|
|
}
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
//save position of wall at start of loop
|
|
|
|
x3 = wall[startofloop].x;
|
|
|
|
y3 = wall[startofloop].y;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
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
|
2010-05-18 05:14:17 +00:00
|
|
|
if (about_x)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
wall[j].x = dax-POINT2(j).x+dax; //flip wall.x about dax
|
|
|
|
wall[j].y = POINT2(j).y;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
wall[j].x = POINT2(j).x;
|
|
|
|
wall[j].y = day-POINT2(j).y+day; //flip wall.y about day
|
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if (doMirror)
|
2010-05-18 05:14:17 +00:00
|
|
|
wall[j].cstat ^= 8; //mirror walls about dax/day
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if (wall[j].point2==startofloop) //check if j is end of loop
|
|
|
|
{
|
|
|
|
endofloop = j;
|
2010-05-18 05:14:17 +00:00
|
|
|
if (about_x)
|
|
|
|
{
|
|
|
|
wall[endofloop].x = dax-x3+dax; //flip wall.x about dax
|
|
|
|
wall[endofloop].y = y3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wall[endofloop].x = x3;
|
|
|
|
wall[endofloop].y = day-y3+day; //flip wall.y about dax
|
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//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
|
|
|
{
|
2011-02-24 20:40:27 +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));
|
2012-01-20 22:12:11 +00:00
|
|
|
|
|
|
|
otonwall[startofloop+w] = endofloop-w+1;
|
|
|
|
otonwall[endofloop-w+1] = startofloop+w;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//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)
|
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
if (about_x)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
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
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if (doMirror && (sprite[j].cstat & 0x30))
|
2010-05-18 05:14:17 +00:00
|
|
|
sprite[j].cstat ^= 4; // mirror sprites about dax/day (don't mirror monsters)
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
j = nextspritesect[j];
|
|
|
|
}
|
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2012-01-20 22:12:11 +00:00
|
|
|
// finally, construct the nextwalls and yax-nextwalls
|
|
|
|
// for the new arrangement!
|
2011-09-30 13:52:02 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
|
|
|
{
|
2012-06-20 20:54:59 +00:00
|
|
|
for (WALLS_OF_SECTOR(highlightsector[i], j))
|
2012-01-20 22:12:11 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
wall[j].nextwall = otonwall[wall[j].nextwall];
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
{
|
|
|
|
int32_t cf, ynw;
|
|
|
|
for (cf=0; cf<2; cf++)
|
|
|
|
if ((ynw = yax_getnextwall(j, cf)) >= 0)
|
|
|
|
yax_setnextwall(j, cf, otonwall[ynw]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2011-09-30 13:52:02 +00:00
|
|
|
}
|
|
|
|
|
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;
|
2010-12-05 17:39:52 +00:00
|
|
|
//__clearscreen_beforecapture__
|
2018-04-12 21:03:47 +00:00
|
|
|
videoCaptureScreen("captxxxx.tga", eitherSHIFT);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
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);
|
2013-08-19 19:27:02 +00:00
|
|
|
linehighlight = getlinehighlight(mousxplc, mousyplc, linehighlight, 0);
|
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;
|
2010-05-18 05:14:17 +00:00
|
|
|
if ((wall[linehighlight].nextwall >= 0) && !eitherSHIFT)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
NEXTWALL(linehighlight).cstat &= ~(1+64);
|
|
|
|
NEXTWALL(linehighlight).cstat |= (wall[linehighlight].cstat&1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
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;
|
2010-05-18 05:14:17 +00:00
|
|
|
if (eitherALT) //ALT-F (relative alignmment flip)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2013-08-19 19:27:02 +00:00
|
|
|
linehighlight = getlinehighlight(mousxplc, mousyplc, linehighlight, 0);
|
2006-04-24 19:04:22 +00:00
|
|
|
if (linehighlight >= 0)
|
2013-05-30 18:10:45 +00:00
|
|
|
SetFirstWall(sectorofwall(linehighlight), linehighlight, 1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2011-02-24 20:40:27 +00:00
|
|
|
DoSpriteOrnament(pointhighlight&16383);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
tsign = 0;
|
|
|
|
if (keystatus[0x33] || (bstatus&33)==33) // , (2D)
|
|
|
|
tsign = +1;
|
|
|
|
if (keystatus[0x34] || (bstatus&17)==17) // . (2D)
|
|
|
|
tsign = -1;
|
2008-09-03 04:20:46 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (tsign)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-06-04 00:06:08 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (highlightsectorcnt > 0 && !hl_all_bunch_sectors_p())
|
|
|
|
{
|
|
|
|
printmessage16("To rotate ext. sectors, all sectors of a bunch must be selected");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
if (highlightsectorcnt > 0)
|
|
|
|
{
|
2012-08-20 21:26:36 +00:00
|
|
|
int32_t smoothRotation = eitherSHIFT, manualAngle = eitherALT;
|
2015-05-26 00:47:54 +00:00
|
|
|
vec2_t da = { dax, day };
|
2012-08-20 21:26:36 +00:00
|
|
|
|
|
|
|
if (manualAngle)
|
|
|
|
{
|
|
|
|
tsign = getnumber16("Rotation BUILD angle: ", 0, 2047, 1);
|
|
|
|
if (tsign==0)
|
|
|
|
{
|
|
|
|
printmessage16(" ");
|
|
|
|
goto rotate_hlsect_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
printmessage16("Rotated highlighted sectors by %d BUILD degrees", tsign);
|
|
|
|
tsign &= 2047;
|
|
|
|
smoothRotation = 1;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-05-26 00:47:54 +00:00
|
|
|
get_sectors_center(highlightsector, highlightsectorcnt, &da.x, &da.y);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-08-20 21:26:00 +00:00
|
|
|
if (!smoothRotation)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
if (gridlock && grid > 0)
|
2015-05-26 00:47:54 +00:00
|
|
|
locktogrid(&da.x, &da.y);
|
2012-08-20 21:26:00 +00:00
|
|
|
|
|
|
|
tsign *= 512;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-05-26 00:47:54 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-02-10 23:15:02 +00:00
|
|
|
for (WALLS_OF_SECTOR(highlightsector[i], j))
|
2015-05-26 00:47:54 +00:00
|
|
|
rotatepoint(da, *(vec2_t *)&wall[j], tsign&2047, (vec2_t *)&wall[j].x);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
for (j=headspritesect[highlightsector[i]]; j != -1; j=nextspritesect[j])
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2015-05-26 00:47:54 +00:00
|
|
|
rotatepoint(da, *(vec2_t *)&sprite[j], tsign&2047, (vec2_t *)&sprite[j].x);
|
2012-08-20 21:26:00 +00:00
|
|
|
sprite[j].ang = (sprite[j].ang+tsign)&2047;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2012-08-20 21:26:36 +00:00
|
|
|
m32_rotateang += tsign;
|
|
|
|
m32_rotateang &= 2047;
|
|
|
|
asksave = 1;
|
|
|
|
rotate_hlsect_out:
|
|
|
|
if (!smoothRotation || manualAngle)
|
2011-02-24 20:40:27 +00:00
|
|
|
keystatus[0x33] = keystatus[0x34] = 0;
|
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
g_mouseBits &= ~(16|32);
|
2010-05-18 05:14:17 +00:00
|
|
|
bstatus &= ~(16|32);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pointhighlight >= 16384)
|
|
|
|
{
|
|
|
|
i = pointhighlight-16384;
|
2010-05-18 05:14:17 +00:00
|
|
|
if (eitherSHIFT)
|
2011-02-24 20:40:27 +00:00
|
|
|
sprite[i].ang = (sprite[i].ang-tsign)&2047;
|
2006-04-24 19:04:22 +00:00
|
|
|
else
|
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
sprite[i].ang = (sprite[i].ang-128*tsign)&2047;
|
2010-05-18 05:14:17 +00:00
|
|
|
keystatus[0x33] = keystatus[0x34] = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
g_mouseBits &= ~(16|32);
|
2010-05-18 05:14:17 +00:00
|
|
|
bstatus &= ~(16|32);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-18 05:14:17 +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
|
|
|
{
|
2012-10-01 17:52:30 +00:00
|
|
|
startpos = pos;
|
2006-04-24 19:04:22 +00:00
|
|
|
startang = ang;
|
|
|
|
startsectnum = cursectnum;
|
|
|
|
keystatus[0x46] = 0;
|
|
|
|
asksave = 1;
|
2013-11-16 18:47:16 +00:00
|
|
|
|
|
|
|
printmessage16("Set starting position");
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-03-07 16:30:06 +00:00
|
|
|
#if 1
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x3f]) //F5
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtShowSectorData(0);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x40]) //F6
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (pointhighlight >= 16384)
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtShowSpriteData(pointhighlight-16384);
|
2006-04-24 19:04:22 +00:00
|
|
|
else if (linehighlight >= 0)
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtShowWallData(linehighlight);
|
2009-05-25 21:47:08 +00:00
|
|
|
else
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtShowWallData(0);
|
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++)
|
2011-04-22 22:48:06 +00:00
|
|
|
if (inside_editor_curpos(i) == 1)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-08-06 11:50:45 +00:00
|
|
|
YAX_SKIPSECTOR(i);
|
|
|
|
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtEditSectorData(i);
|
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)
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtEditSpriteData(pointhighlight-16384);
|
2006-04-24 19:04:22 +00:00
|
|
|
else if (linehighlight >= 0)
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtEditWallData(linehighlight);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-03-07 16:30:06 +00:00
|
|
|
#endif
|
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;
|
2010-05-18 05:14:17 +00:00
|
|
|
if (eitherCTRL) //Ctrl-H
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-09-02 02:45:06 +00:00
|
|
|
pointhighlight = getpointhighlight(mousxplc, mousyplc, pointhighlight);
|
2013-08-19 19:27:02 +00:00
|
|
|
linehighlight = getlinehighlight(mousxplc, mousyplc, linehighlight, 0);
|
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;
|
2010-05-18 05:14:17 +00:00
|
|
|
if ((wall[linehighlight].nextwall >= 0) && !eitherSHIFT)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
NEXTWALL(linehighlight).cstat &= ~64;
|
|
|
|
NEXTWALL(linehighlight).cstat |= (wall[linehighlight].cstat&64);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
else if (eitherALT) //ALT
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (pointhighlight >= 16384)
|
|
|
|
{
|
|
|
|
i = pointhighlight-16384;
|
2011-04-17 17:01:20 +00:00
|
|
|
j = taglab_linktags(1, i);
|
|
|
|
j = 2*(j&2);
|
2011-02-24 20:40:27 +00:00
|
|
|
Bsprintf(buffer, "Sprite (%d) Hi-tag: ", i);
|
2011-04-17 17:01:20 +00:00
|
|
|
sprite[i].hitag = getnumber16(buffer, sprite[i].hitag, BTAG_MAX, 0+j);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else if (linehighlight >= 0)
|
|
|
|
{
|
|
|
|
i = linehighlight;
|
2011-04-17 17:01:20 +00:00
|
|
|
j = taglab_linktags(1, i);
|
|
|
|
j = 2*(j&2);
|
2011-02-24 20:40:27 +00:00
|
|
|
Bsprintf(buffer, "Wall (%d) Hi-tag: ", i);
|
2011-04-17 17:01:20 +00:00
|
|
|
wall[i].hitag = getnumber16(buffer, wall[i].hitag, BTAG_MAX, 0+j);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2011-04-22 22:48:06 +00:00
|
|
|
if (inside_editor_curpos(i) == 1)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-08-06 11:50:45 +00:00
|
|
|
YAX_SKIPSECTOR(i);
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
Bsprintf(buffer, "Sector (%d) Hi-tag: ", i);
|
|
|
|
sector[i].hitag = getnumber16(buffer, sector[i].hitag, BTAG_MAX, 0);
|
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++)
|
2011-04-22 22:48:06 +00:00
|
|
|
if (inside_editor_curpos(i) == 1)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-08-06 11:50:45 +00:00
|
|
|
YAX_SKIPSECTOR(i);
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
Bsprintf(buffer, "Sector (%d) Ceilingpal: ", i);
|
2011-03-17 23:37:38 +00:00
|
|
|
sector[i].ceilingpal = getnumber16(buffer, sector[i].ceilingpal, M32_MAXPALOOKUPS, 0);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
Bsprintf(buffer, "Sector (%d) Floorpal: ", i);
|
2011-03-17 23:37:38 +00:00
|
|
|
sector[i].floorpal = getnumber16(buffer, sector[i].floorpal, M32_MAXPALOOKUPS, 0);
|
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
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
keystatus[0x12] = 0;
|
|
|
|
|
2011-03-02 21:21:47 +00:00
|
|
|
if (!eitherCTRL)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-02 21:21:47 +00:00
|
|
|
if (pointhighlight >= 16384)
|
|
|
|
{
|
|
|
|
i = pointhighlight-16384;
|
|
|
|
Bsprintf(buffer, "Sprite (%d) Status list: ", i);
|
|
|
|
changespritestat(i, getnumber16(buffer, sprite[i].statnum, MAXSTATUS-1, 0));
|
|
|
|
}
|
|
|
|
}
|
2011-03-13 11:59:32 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
else if (highlightsectorcnt > 0 && newnumwalls < 0)
|
2011-03-02 21:21:47 +00:00
|
|
|
{
|
|
|
|
////////// YAX //////////
|
|
|
|
static const char *cfs[2] = {"ceiling", "floor"};
|
|
|
|
|
2011-05-29 23:10:51 +00:00
|
|
|
int32_t cf, thez, ulz[2]={0,0};
|
|
|
|
int16_t bn, sandwichbunch=-1;
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
if (numyaxbunches==YAX_MAXBUNCHES)
|
|
|
|
{
|
|
|
|
message("Bunch limit of %d reached, cannot extend", YAX_MAXBUNCHES);
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
if (highlighted_sectors_components(0,0) != 1)
|
2011-04-22 22:48:06 +00:00
|
|
|
{
|
|
|
|
message("Sectors to extend must be in one connected component");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
2011-03-02 21:21:47 +00:00
|
|
|
cf = ask_above_or_below();
|
2011-03-05 12:59:27 +00:00
|
|
|
if (cf==-1)
|
2011-03-02 21:21:47 +00:00
|
|
|
goto end_yax;
|
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
thez = SECTORFLD(highlightsector[0],z, cf);
|
2011-03-05 12:59:27 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2011-03-02 21:21:47 +00:00
|
|
|
{
|
2011-05-29 23:10:51 +00:00
|
|
|
bn = yax_getbunch(highlightsector[i], cf);
|
|
|
|
|
|
|
|
if (sandwichbunch >= 0 && bn!=sandwichbunch)
|
2011-03-05 12:59:27 +00:00
|
|
|
{
|
2011-05-29 23:10:51 +00:00
|
|
|
message("When sandwiching extension, must select only sectors of one bunch");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bn >= 0)
|
|
|
|
{
|
|
|
|
if (cf==YAX_FLOOR)
|
|
|
|
{
|
|
|
|
if (sandwichbunch < 0 && i!=0)
|
|
|
|
{
|
|
|
|
message("When sandwiching extension, must select only sectors of the bunch");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
sandwichbunch = bn;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message("Sector %d's %s is already extended", highlightsector[i], cfs[cf]);
|
|
|
|
goto end_yax;
|
|
|
|
}
|
2011-03-05 12:59:27 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
if (SECTORFLD(highlightsector[i],z, cf) != thez)
|
2011-03-02 21:21:47 +00:00
|
|
|
{
|
2012-06-13 23:13:15 +00:00
|
|
|
message("Sector %d's %s height doesn't match sector %d's",
|
2011-12-03 13:13:44 +00:00
|
|
|
highlightsector[i], cfs[cf], highlightsector[0]);
|
2011-03-02 21:21:47 +00:00
|
|
|
goto end_yax;
|
|
|
|
}
|
2011-03-23 17:41:01 +00:00
|
|
|
|
2011-05-29 23:10:51 +00:00
|
|
|
if ((sandwichbunch>=0 || highlightsectorcnt>1) && SECTORFLD(highlightsector[i],stat, cf)&2)
|
2011-03-02 21:21:47 +00:00
|
|
|
{
|
2011-05-29 23:10:51 +00:00
|
|
|
message("Sector %ss must not be sloped%s", cfs[cf],
|
|
|
|
sandwichbunch>=0 ? "" : "if extending more than one");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sandwichbunch >= 0)
|
|
|
|
{
|
|
|
|
// cf==YAX_FLOOR here
|
|
|
|
|
|
|
|
int32_t tempz, oldfz, swsecheight = DEFAULT_YAX_HEIGHT/4;
|
|
|
|
// highest floor z of lower sectors, lowest ceiling z of these sectors
|
|
|
|
int32_t minfloorz = INT32_MAX, maxceilz = INT32_MIN;
|
|
|
|
|
|
|
|
// some preparation for making the sandwich
|
|
|
|
if (highlightsectorcnt != yax_numsectsinbunch(sandwichbunch, YAX_FLOOR))
|
|
|
|
{
|
|
|
|
message("When sandwiching extension, must select all sectors of the bunch");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
|
|
|
// "for i in sectors of sandwichbunch(floor)" is now the same as
|
|
|
|
// "for i in highlighted sectors"
|
|
|
|
|
|
|
|
oldfz = sector[highlightsector[0]].floorz;
|
|
|
|
|
|
|
|
// check if enough room in z
|
|
|
|
for (SECTORS_OF_BUNCH(sandwichbunch, YAX_CEILING, i))
|
|
|
|
for (WALLS_OF_SECTOR(i, j))
|
|
|
|
{
|
|
|
|
tempz = getflorzofslope(i, wall[j].x, wall[j].y);
|
|
|
|
minfloorz = min(minfloorz, tempz);
|
|
|
|
}
|
|
|
|
for (SECTORS_OF_BUNCH(sandwichbunch, YAX_FLOOR, i))
|
|
|
|
for (WALLS_OF_SECTOR(i, j))
|
|
|
|
{
|
|
|
|
tempz = getceilzofslope(i, wall[j].x, wall[j].y);
|
|
|
|
maxceilz = max(maxceilz, tempz);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (minfloorz - maxceilz < 2*swsecheight)
|
|
|
|
{
|
|
|
|
message("Too little z headroom for sandwiching, need at least %d",
|
|
|
|
2*swsecheight);
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maxceilz >= oldfz || oldfz >= minfloorz)
|
|
|
|
{
|
|
|
|
message("Internal error while sandwiching: oldfz out of bounds");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
|
|
|
// maxceilz ---|
|
|
|
|
// ^ |
|
|
|
|
// ulz[0] ^
|
|
|
|
// ^ oldfz
|
|
|
|
// ulz[1] ^
|
|
|
|
// ^ |
|
|
|
|
// minfloorz ---|
|
|
|
|
|
2012-11-15 14:28:41 +00:00
|
|
|
ulz[0] = (int32_t)(oldfz - swsecheight*((double)(oldfz-maxceilz)/(minfloorz-maxceilz)));
|
2011-05-29 23:10:51 +00:00
|
|
|
ulz[0] &= ~255;
|
|
|
|
ulz[1] = ulz[0] + swsecheight;
|
|
|
|
|
2011-06-26 21:59:42 +00:00
|
|
|
if (maxceilz >= ulz[0] || ulz[1] >= minfloorz)
|
2011-05-29 23:10:51 +00:00
|
|
|
{
|
|
|
|
message("Too little z headroom for sandwiching");
|
2011-03-02 21:21:47 +00:00
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
}
|
2011-03-05 12:59:27 +00:00
|
|
|
|
|
|
|
m = numwalls;
|
|
|
|
Bmemset(visited, 0, sizeof(visited));
|
|
|
|
// construct!
|
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
|
|
|
for (WALLS_OF_SECTOR(highlightsector[i], j))
|
|
|
|
{
|
2011-04-11 22:28:58 +00:00
|
|
|
k = trace_loop(j, visited, NULL, NULL, !cf);
|
2011-03-05 12:59:27 +00:00
|
|
|
if (k == 0)
|
|
|
|
continue;
|
|
|
|
else if (k < 0)
|
|
|
|
{
|
|
|
|
numwalls = m;
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
//message("loop");
|
|
|
|
wall[k-1].point2 = numwalls;
|
|
|
|
numwalls = k;
|
|
|
|
}
|
|
|
|
|
2011-04-11 22:28:58 +00:00
|
|
|
for (i=m; i<numwalls; i++) // try
|
|
|
|
{
|
|
|
|
j = YAX_NEXTWALL(i, !cf);
|
|
|
|
if (j < 0)
|
|
|
|
{
|
|
|
|
message("Internal error while constructing sector: "
|
|
|
|
"YAX_NEXTWALL(%d, %d)<0!", i, !cf);
|
|
|
|
numwalls = m;
|
|
|
|
goto end_yax;
|
|
|
|
}
|
2011-05-29 23:10:51 +00:00
|
|
|
if (sandwichbunch >= 0)
|
|
|
|
{
|
|
|
|
if (YAX_NEXTWALL(j, cf) < 0)
|
|
|
|
{
|
|
|
|
message("Internal error while sandwiching (2): "
|
|
|
|
"YAX_NEXTWALL(%d, %d)<0!", j, cf);
|
|
|
|
numwalls = m;
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
}
|
2011-04-11 22:28:58 +00:00
|
|
|
}
|
|
|
|
for (i=m; i<numwalls; i++) // do!
|
|
|
|
{
|
|
|
|
j = YAX_NEXTWALL(i, !cf);
|
2011-05-29 23:10:51 +00:00
|
|
|
|
|
|
|
if (sandwichbunch >= 0)
|
|
|
|
{
|
|
|
|
int16_t oynw = YAX_NEXTWALL(j, cf);
|
|
|
|
yax_setnextwall(j, cf, i);
|
|
|
|
yax_setnextwall(i, cf, oynw);
|
|
|
|
yax_setnextwall(oynw, !cf, i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
yax_setnextwall(j, cf, i);
|
|
|
|
}
|
2011-04-11 22:28:58 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
// create new sector based on first highlighted one
|
2011-03-05 12:59:27 +00:00
|
|
|
i = highlightsector[0];
|
|
|
|
Bmemcpy(§or[numsectors], §or[i], sizeof(sectortype));
|
|
|
|
sector[numsectors].wallptr = m;
|
|
|
|
sector[numsectors].wallnum = numwalls-m;
|
|
|
|
|
2011-05-29 23:10:51 +00:00
|
|
|
if (sandwichbunch < 0)
|
|
|
|
{
|
|
|
|
if (SECTORFLD(i,stat, cf)&2)
|
|
|
|
setslope(numsectors, !cf, SECTORFLD(i,heinum, cf));
|
|
|
|
else
|
|
|
|
setslope(numsectors, !cf, 0);
|
|
|
|
setslope(numsectors, cf, 0);
|
2011-04-22 22:48:06 +00:00
|
|
|
|
2011-05-29 23:10:51 +00:00
|
|
|
SECTORFLD(numsectors,z, !cf) = SECTORFLD(i,z, cf);
|
|
|
|
SECTORFLD(numsectors,z, cf) = SECTORFLD(i,z, cf) - (1-2*cf)*DEFAULT_YAX_HEIGHT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (SECTORS_OF_BUNCH(sandwichbunch, cf, i))
|
|
|
|
sector[i].floorz = ulz[0];
|
|
|
|
sector[numsectors].ceilingz = ulz[0];
|
|
|
|
sector[numsectors].floorz = ulz[1];
|
|
|
|
for (SECTORS_OF_BUNCH(sandwichbunch, !cf, i))
|
|
|
|
sector[i].ceilingz = ulz[1];
|
|
|
|
}
|
2011-03-05 12:59:27 +00:00
|
|
|
|
|
|
|
newnumwalls = numwalls;
|
|
|
|
numwalls = m;
|
|
|
|
|
2011-05-29 23:10:51 +00:00
|
|
|
SECTORFLD(numsectors,stat, !cf) &= ~1; // no plax
|
|
|
|
|
2011-03-05 12:59:27 +00:00
|
|
|
// restore red walls of the selected sectors
|
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
|
|
|
{
|
2011-04-22 22:48:06 +00:00
|
|
|
SECTORFLD(highlightsector[i],stat, cf) &= ~1; // no plax
|
|
|
|
|
2011-03-05 12:59:27 +00:00
|
|
|
for (WALLS_OF_SECTOR(highlightsector[i], j))
|
|
|
|
if (wall[j].nextwall < 0)
|
|
|
|
checksectorpointer(j, highlightsector[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// link
|
2011-05-29 23:10:51 +00:00
|
|
|
if (sandwichbunch < 0)
|
|
|
|
{
|
|
|
|
yax_setbunch(numsectors, !cf, numyaxbunches);
|
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
|
|
|
yax_setbunch(highlightsector[i], cf, numyaxbunches);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
yax_setbunch(numsectors, !cf, sandwichbunch);
|
|
|
|
// also relink
|
|
|
|
yax_setbunch(numsectors, cf, numyaxbunches);
|
|
|
|
for (SECTORS_OF_BUNCH(sandwichbunch, !cf, i))
|
|
|
|
yax_setbunch(i, !cf, numyaxbunches);
|
|
|
|
}
|
2011-03-05 12:59:27 +00:00
|
|
|
|
|
|
|
numwalls = newnumwalls;
|
|
|
|
newnumwalls = -1;
|
|
|
|
|
|
|
|
numsectors++;
|
2011-03-23 17:41:01 +00:00
|
|
|
yax_update(0);
|
2011-04-22 22:48:06 +00:00
|
|
|
yax_updategrays(pos.z);
|
2011-03-05 12:59:27 +00:00
|
|
|
|
2012-08-20 21:27:42 +00:00
|
|
|
reset_highlightsector();
|
2011-03-13 11:59:32 +00:00
|
|
|
|
2011-05-29 23:10:51 +00:00
|
|
|
if (sandwichbunch < 0)
|
|
|
|
message("Extended %ss of highlighted sectors, creating bunch %d",
|
|
|
|
cfs[cf], numyaxbunches-1);
|
|
|
|
else
|
|
|
|
message("Sandwiched bunch %d, creating bunch %d",
|
|
|
|
sandwichbunch, numyaxbunches-1);
|
2011-04-09 13:27:08 +00:00
|
|
|
asksave = 1;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-11-25 09:53:07 +00:00
|
|
|
else if (highlightcnt > 0)
|
|
|
|
{
|
|
|
|
/// 'punch' wall loop through extension
|
|
|
|
|
|
|
|
int32_t loopstartwall = -1, numloopwalls, cf;
|
|
|
|
int32_t srcsect, dstsect, ofirstwallofs;
|
|
|
|
int16_t cb, fb, bunchnum;
|
|
|
|
|
|
|
|
if (EDITING_MAP_P())
|
|
|
|
{
|
|
|
|
printmessage16("Must not be editing map to punch loop");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numyaxbunches >= YAX_MAXBUNCHES)
|
|
|
|
{
|
|
|
|
message("TROR bunch limit reached, cannot punch loop");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
|
|
|
// determine start wall
|
|
|
|
for (i=0; i<highlightcnt; i++)
|
2011-11-25 13:46:48 +00:00
|
|
|
{
|
|
|
|
j = highlight[i];
|
|
|
|
|
|
|
|
if (j&16384)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// we only want loop-starting walls
|
|
|
|
if (j>0 && wall[j-1].point2==j)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (clockdir(j)==CLOCKDIR_CCW)
|
2011-11-25 09:53:07 +00:00
|
|
|
{
|
2011-11-25 13:46:48 +00:00
|
|
|
YAX_SKIPWALL(j);
|
2011-11-25 09:53:07 +00:00
|
|
|
|
|
|
|
if (loopstartwall >= 0)
|
|
|
|
{
|
|
|
|
message("Must have a unique highlighted CCW loop to punch");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
2011-11-25 13:46:48 +00:00
|
|
|
loopstartwall = j;
|
2011-11-25 09:53:07 +00:00
|
|
|
}
|
2011-11-25 13:46:48 +00:00
|
|
|
}
|
2011-11-25 09:53:07 +00:00
|
|
|
|
|
|
|
if (loopstartwall == -1)
|
|
|
|
{
|
2012-11-03 19:32:32 +00:00
|
|
|
message("Didn't find any non-grayed out CCW loop start walls");
|
2011-11-25 09:53:07 +00:00
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
|
|
|
// determine sector
|
|
|
|
srcsect = sectorofwall(loopstartwall);
|
|
|
|
yax_getbunches(srcsect, &cb, &fb);
|
|
|
|
if (cb < 0 && fb < 0)
|
|
|
|
{
|
|
|
|
message("Ceiling or floor must be extended to punch loop");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// determine c/f
|
|
|
|
cf = -1;
|
|
|
|
if (fb < 0)
|
|
|
|
cf = YAX_CEILING;
|
|
|
|
else if (cb < 0)
|
|
|
|
cf = YAX_FLOOR;
|
|
|
|
|
2012-11-03 19:32:32 +00:00
|
|
|
fade_editor_screen(-1);
|
|
|
|
|
2011-11-25 09:53:07 +00:00
|
|
|
// query top/bottom
|
|
|
|
if (cf == -1)
|
|
|
|
{
|
|
|
|
char dachars[2] = {'a', 'z'};
|
|
|
|
cf = editor_ask_function("Punch loop above (a) or below (z)?", dachars, 2);
|
|
|
|
if (cf == -1)
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// ask even if only one choice -- I find it more
|
|
|
|
// consistent with 'extend sector' this way
|
|
|
|
if (-1 == editor_ask_function(cf==YAX_CEILING ? "Punch loop above (a)?" :
|
|
|
|
"Punch loop below (z)?", cf==YAX_CEILING?"a":"z", 1))
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
|
|
|
bunchnum = (cf==YAX_CEILING) ? cb : fb;
|
|
|
|
|
|
|
|
// check 1
|
|
|
|
j = loopstartwall; // will be real start wall of loop
|
|
|
|
numloopwalls = 1; // will be number of walls in loop
|
|
|
|
for (i=wall[loopstartwall].point2; i!=loopstartwall; i=wall[i].point2)
|
|
|
|
{
|
|
|
|
numloopwalls++;
|
|
|
|
if (i < j)
|
|
|
|
j = i;
|
|
|
|
|
|
|
|
if ((show2dwall[i>>3]&(1<<(i&7)))==0)
|
|
|
|
{
|
|
|
|
message("All loop points must be highlighted to punch");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (yax_getnextwall(loopstartwall, cf) >= 0 || yax_getnextwall(i, cf) >= 0)
|
|
|
|
{
|
|
|
|
// somewhat redundant, since it would also be caught by check 2
|
|
|
|
message("Loop walls must not already have TROR neighbors");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wall[loopstartwall].nextwall < 0 || wall[i].nextwall < 0)
|
|
|
|
{
|
|
|
|
message("INTERNAL ERROR: All loop walls are expected to be red");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
loopstartwall = j;
|
|
|
|
|
|
|
|
if (numwalls + 2*numloopwalls > MAXWALLS || numsectors+1 > MAXSECTORS)
|
|
|
|
{
|
|
|
|
message("Punching loop through extension would exceed limits");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get other-side sector, j==loopstartwall
|
2012-10-01 17:52:18 +00:00
|
|
|
dstsect = yax_getneighborsect(wall[j].x, wall[j].y, srcsect, cf);
|
2011-11-25 09:53:07 +00:00
|
|
|
if (dstsect < 0)
|
|
|
|
{
|
|
|
|
message("Punch loop INTERNAL ERROR: dstsect < 0. Map corrupt?");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check 2
|
|
|
|
i = loopstartwall;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
j = wall[i].point2;
|
|
|
|
|
|
|
|
for (WALLS_OF_SECTOR(dstsect, k))
|
|
|
|
{
|
|
|
|
vec2_t pint;
|
|
|
|
if (lineintersect2v((vec2_t *)&wall[i], (vec2_t *)&wall[j],
|
|
|
|
(vec2_t *)&wall[k], (vec2_t *)&POINT2(k), &pint))
|
|
|
|
{
|
|
|
|
message("Loop lines must not intersect any destination sector's walls");
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while ((i = j) != loopstartwall);
|
|
|
|
|
|
|
|
// construct new loop and (dummy yet) sector
|
|
|
|
Bmemcpy(&wall[numwalls], &wall[loopstartwall], numloopwalls*sizeof(walltype));
|
|
|
|
newnumwalls = numwalls+numloopwalls;
|
|
|
|
|
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
|
|
|
{
|
|
|
|
wall[i].point2 += (numwalls - loopstartwall);
|
|
|
|
wall[i].nextsector = wall[i].nextwall = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sector[numsectors].wallptr = numwalls;
|
|
|
|
sector[numsectors].wallnum = numloopwalls;
|
|
|
|
numsectors++; // temp
|
|
|
|
|
|
|
|
// check 3
|
|
|
|
for (SECTORS_OF_BUNCH(bunchnum, !cf, i))
|
|
|
|
for (WALLS_OF_SECTOR(i, j))
|
|
|
|
{
|
2011-11-25 13:46:48 +00:00
|
|
|
if (inside(wall[j].x, wall[j].y, numsectors-1)==1)
|
2011-11-25 09:53:07 +00:00
|
|
|
{
|
|
|
|
numsectors--;
|
|
|
|
newnumwalls = -1;
|
|
|
|
message("A point of bunch %d's sectors lies inside the loop to punch",
|
|
|
|
bunchnum);
|
|
|
|
goto end_yax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
numsectors--;
|
|
|
|
|
|
|
|
// clear wall & sprite highlights
|
|
|
|
// TODO: see about consistency with update_highlight() after other ops
|
2012-08-20 21:27:42 +00:00
|
|
|
reset_highlight();
|
2011-11-25 09:53:07 +00:00
|
|
|
|
|
|
|
// construct the loop!
|
|
|
|
i = AddLoopToSector(dstsect, &ofirstwallofs);
|
|
|
|
|
|
|
|
if (i <= 0)
|
|
|
|
{
|
|
|
|
message("Punch loop INTERNAL ERROR with AddLoopToSector!");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int32_t oneinnersect = -1, innerdstsect = numsectors-1;
|
|
|
|
|
|
|
|
if (dstsect < srcsect)
|
|
|
|
loopstartwall += numloopwalls;
|
|
|
|
|
|
|
|
/// handle bunchnums! (specifically, create a new one)
|
|
|
|
|
|
|
|
// collect sectors inside source loop; for that, first break the
|
|
|
|
// inner->outer nextwall links
|
|
|
|
for (i=loopstartwall; i<loopstartwall+numloopwalls; i++)
|
|
|
|
{
|
|
|
|
// all src loop walls are red!
|
|
|
|
NEXTWALL(i).nextwall = NEXTWALL(i).nextsector = -1;
|
|
|
|
oneinnersect = wall[i].nextsector;
|
|
|
|
}
|
|
|
|
|
|
|
|
// vvv
|
|
|
|
// expect oneinnersect >= 0 here! Assumption: we collect exactly
|
|
|
|
// one connected component of sectors
|
|
|
|
collect_sectors1(collsectlist[0], collsectbitmap[0],
|
|
|
|
&collnumsects[0], oneinnersect, 0, 0);
|
|
|
|
|
|
|
|
// set new bunchnums
|
|
|
|
for (i=0; i<collnumsects[0]; i++)
|
|
|
|
yax_setbunch(collsectlist[0][i], cf, numyaxbunches);
|
|
|
|
yax_setbunch(innerdstsect, !cf, numyaxbunches);
|
|
|
|
// ^^^
|
|
|
|
|
|
|
|
// restore inner->outer nextwall links
|
|
|
|
for (i=loopstartwall; i<loopstartwall+numloopwalls; i++)
|
|
|
|
{
|
|
|
|
NEXTWALL(i).nextwall = i;
|
|
|
|
NEXTWALL(i).nextsector = srcsect;
|
|
|
|
|
|
|
|
// set yax-nextwalls!
|
|
|
|
j = (i-loopstartwall) + sector[dstsect].wallptr;
|
|
|
|
yax_setnextwall(i, cf, j);
|
|
|
|
yax_setnextwall(j, !cf, i);
|
|
|
|
|
|
|
|
yax_setnextwall(wall[i].nextwall, cf, wall[j].nextwall);
|
|
|
|
yax_setnextwall(wall[j].nextwall, !cf, wall[i].nextwall);
|
|
|
|
}
|
|
|
|
|
|
|
|
setfirstwall(dstsect, sector[dstsect].wallptr+ofirstwallofs);
|
|
|
|
|
|
|
|
message("Punched loop starting w/ wall %d into %s sector %d%s",
|
|
|
|
loopstartwall, cf==YAX_CEILING?"upper":"lower", dstsect,
|
|
|
|
(oneinnersect>=0) ? "" : " (ERRORS)");
|
|
|
|
}
|
|
|
|
|
|
|
|
mkonwinvalid();
|
|
|
|
asksave = 1;
|
|
|
|
|
|
|
|
yax_update(0);
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
}
|
|
|
|
end_yax: ;
|
2011-03-13 11:59:32 +00:00
|
|
|
#endif
|
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 (highlightsectorcnt < 0)
|
|
|
|
{
|
2015-07-17 00:12:48 +00:00
|
|
|
if (((bstatus & 5) == 1 && highlightcnt <= 0) || ((bstatus & 5) == 1 && pointhighlight == -1) || keystatus[0x36]) //Right shift (point highlighting)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (highlightcnt == 0)
|
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
int32_t xx[] = { highlightx1, highlightx1, searchx, searchx, highlightx1 };
|
|
|
|
int32_t yy[] = { highlighty1, searchy, searchy, highlighty1, highlighty1 };
|
|
|
|
|
2010-08-26 13:50:09 +00:00
|
|
|
highlightx2 = searchx;
|
|
|
|
highlighty2 = searchy;
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2015-07-17 00:12:48 +00:00
|
|
|
plotlines2d(xx, yy, 5, -editorcolors[14]);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2015-07-08 03:34:46 +00:00
|
|
|
else if (pointhighlight == -1 || keystatus[0x36])
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
highlightcnt = 0;
|
2010-08-26 13:50:09 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
highlightx1 = searchx;
|
|
|
|
highlighty1 = searchy;
|
|
|
|
highlightx2 = searchx;
|
2011-03-05 12:59:27 +00:00
|
|
|
highlighty2 = searchy;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (highlightcnt == 0)
|
|
|
|
{
|
2011-05-24 21:46:51 +00:00
|
|
|
int32_t add=keystatus[0x28], sub=(!add && keystatus[0x27]), setop=(add||sub);
|
|
|
|
|
2011-03-05 12:59:27 +00:00
|
|
|
if (!m32_sideview)
|
|
|
|
{
|
|
|
|
getpoint(highlightx1,highlighty1, &highlightx1,&highlighty1);
|
|
|
|
getpoint(highlightx2,highlighty2, &highlightx2,&highlighty2);
|
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (highlightx1 > highlightx2)
|
2010-05-18 05:14:17 +00:00
|
|
|
swaplong(&highlightx1, &highlightx2);
|
2006-04-24 19:04:22 +00:00
|
|
|
if (highlighty1 > highlighty2)
|
2010-05-18 05:14:17 +00:00
|
|
|
swaplong(&highlighty1, &highlighty2);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-02 21:21:47 +00:00
|
|
|
// Ctrl+RShift: select all wall-points of highlighted wall's loop:
|
2011-03-05 12:59:27 +00:00
|
|
|
if (eitherCTRL && highlightx1==highlightx2 && highlighty1==highlighty2)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-05-24 21:46:51 +00:00
|
|
|
if (!setop)
|
|
|
|
{
|
|
|
|
Bmemset(show2dwall, 0, sizeof(show2dwall));
|
|
|
|
Bmemset(show2dsprite, 0, sizeof(show2dsprite));
|
|
|
|
}
|
2010-08-26 13:50:09 +00:00
|
|
|
|
2011-03-02 21:21:47 +00:00
|
|
|
if (linehighlight >= 0 && linehighlight < MAXWALLS)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
i = linehighlight;
|
|
|
|
do
|
|
|
|
{
|
2011-05-24 21:46:51 +00:00
|
|
|
if (!sub)
|
|
|
|
show2dwall[i>>3] |= (1<<(i&7));
|
|
|
|
else
|
|
|
|
show2dwall[i>>3] &= ~(1<<(i&7));
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-11-25 09:53:07 +00:00
|
|
|
// XXX: this selects too many walls, need something more like
|
|
|
|
// those of dragpoint() -- could be still too many for
|
|
|
|
// loop punching though
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<numwalls; j++)
|
2010-05-18 05:14:17 +00:00
|
|
|
if (j!=i && wall[j].x==wall[i].x && wall[j].y==wall[i].y)
|
2011-05-24 21:46:51 +00:00
|
|
|
{
|
|
|
|
if (!sub)
|
|
|
|
show2dwall[j>>3] |= (1<<(j&7));
|
|
|
|
else
|
|
|
|
show2dwall[j>>3] &= ~(1<<(j&7));
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
i = wall[i].point2;
|
|
|
|
}
|
|
|
|
while (i != linehighlight);
|
|
|
|
}
|
2010-08-26 13:50:09 +00:00
|
|
|
|
|
|
|
update_highlight();
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-05 12:59:27 +00:00
|
|
|
int32_t tx, ty, onlySprites=eitherCTRL;
|
2013-01-16 20:38:41 +00:00
|
|
|
int32_t accum_dragged_verts = 0;
|
2010-08-26 13:50:09 +00:00
|
|
|
|
|
|
|
if (!setop)
|
|
|
|
{
|
|
|
|
Bmemset(show2dwall, 0, sizeof(show2dwall));
|
|
|
|
Bmemset(show2dsprite, 0, sizeof(show2dsprite));
|
|
|
|
}
|
|
|
|
|
2011-05-29 12:30:38 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
wall[i].cstat &= ~(1<<14);
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
2011-03-05 12:59:27 +00:00
|
|
|
{
|
|
|
|
if (onlySprites)
|
|
|
|
break;
|
|
|
|
|
2011-05-29 12:30:38 +00:00
|
|
|
YAX_SKIPWALL(i);
|
|
|
|
|
2011-03-05 12:59:27 +00:00
|
|
|
if (!m32_sideview)
|
|
|
|
{
|
|
|
|
tx = wall[i].x;
|
|
|
|
ty = wall[i].y;
|
2011-05-29 12:30:38 +00:00
|
|
|
// wall[i].cstat &= ~(1<<14);
|
2011-03-05 12:59:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
editorGet2dScreenCoordinates(&tx,&ty, wall[i].x-pos.x,wall[i].y-pos.y, zoom);
|
2011-03-05 12:59:27 +00:00
|
|
|
ty += getscreenvdisp(
|
|
|
|
getflorzofslope(sectorofwall(i), wall[i].x,wall[i].y)-pos.z, zoom);
|
|
|
|
tx += halfxdim16;
|
|
|
|
ty += midydim16;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tx >= highlightx1 && tx <= highlightx2 &&
|
|
|
|
ty >= highlighty1 && ty <= highlighty2)
|
2010-08-26 13:50:09 +00:00
|
|
|
{
|
|
|
|
if (!sub)
|
2011-05-29 12:30:38 +00:00
|
|
|
{
|
|
|
|
if (numgraysects > 0 || m32_sideview)
|
|
|
|
{
|
2013-01-16 20:38:41 +00:00
|
|
|
// Only called to find out which walls would get dragged:
|
|
|
|
dragpoint(i, wall[i].x, wall[i].y, accum_dragged_verts);
|
|
|
|
accum_dragged_verts = 1;
|
2011-05-29 12:30:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
show2dwall[i>>3] |= (1<<(i&7));
|
|
|
|
}
|
2011-05-24 21:46:51 +00:00
|
|
|
else
|
2010-08-26 13:50:09 +00:00
|
|
|
show2dwall[i>>3] &= ~(1<<(i&7));
|
|
|
|
}
|
2011-03-05 12:59:27 +00:00
|
|
|
}
|
|
|
|
|
2011-05-29 12:30:38 +00:00
|
|
|
if (!sub && (numgraysects > 0 || m32_sideview))
|
|
|
|
{
|
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
if (wall[i].cstat&(1<<14))
|
|
|
|
show2dwall[i>>3] |= (1<<(i&7));
|
|
|
|
}
|
2011-03-13 11:59:32 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXSPRITES; i++)
|
2011-03-05 12:59:27 +00:00
|
|
|
{
|
|
|
|
if (sprite[i].statnum == MAXSTATUS)
|
|
|
|
continue;
|
|
|
|
|
2011-07-24 15:15:57 +00:00
|
|
|
// v v v: if END pressed, also permit sprites from grayed out sectors
|
|
|
|
if (!keystatus[0xcf] && (unsigned)sprite[i].sectnum < MAXSECTORS)
|
2011-05-29 12:30:38 +00:00
|
|
|
YAX_SKIPSECTOR(sprite[i].sectnum);
|
|
|
|
|
2011-03-05 12:59:27 +00:00
|
|
|
if (!m32_sideview)
|
|
|
|
{
|
|
|
|
tx = sprite[i].x;
|
|
|
|
ty = sprite[i].y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
editorGet2dScreenCoordinates(&tx,&ty, sprite[i].x-pos.x,sprite[i].y-pos.y, zoom);
|
2011-03-05 12:59:27 +00:00
|
|
|
ty += getscreenvdisp(sprite[i].z-pos.z, zoom);
|
|
|
|
tx += halfxdim16;
|
|
|
|
ty += midydim16;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tx >= highlightx1 && tx <= highlightx2 &&
|
|
|
|
ty >= highlighty1 && ty <= highlighty2)
|
2010-08-26 13:50:09 +00:00
|
|
|
{
|
|
|
|
if (!sub)
|
2010-10-31 19:54:03 +00:00
|
|
|
{
|
|
|
|
if (sprite[i].sectnum >= 0) // don't allow to select sprites in null space
|
|
|
|
show2dsprite[i>>3] |= (1<<(i&7));
|
|
|
|
}
|
2010-08-26 13:50:09 +00:00
|
|
|
else
|
|
|
|
show2dsprite[i>>3] &= ~(1<<(i&7));
|
|
|
|
}
|
2011-03-05 12:59:27 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-08-26 13:50:09 +00:00
|
|
|
update_highlight();
|
2011-07-04 21:20:59 +00:00
|
|
|
|
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
wall[i].cstat &= ~(1<<14);
|
2010-08-26 13:50:09 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-26 13:50:09 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (highlightcnt < 0)
|
|
|
|
{
|
2015-07-25 17:23:17 +00:00
|
|
|
if (((bstatus & 4) && highlightsectorcnt <= 0) || ((bstatus & 4) && linehighlight == -1)
|
|
|
|
|| keystatus[0xb8]) //Right alt (sector highlighting)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (highlightsectorcnt == 0)
|
|
|
|
{
|
2011-03-02 21:21:47 +00:00
|
|
|
if (!eitherCTRL)
|
|
|
|
{
|
|
|
|
int32_t xx[] = { highlightx1, highlightx1, searchx, searchx, highlightx1 };
|
|
|
|
int32_t yy[] = { highlighty1, searchy, searchy, highlighty1, highlighty1 };
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2011-03-02 21:21:47 +00:00
|
|
|
highlightx2 = searchx;
|
|
|
|
highlighty2 = searchy;
|
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2015-07-17 00:12:48 +00:00
|
|
|
plotlines2d(xx, yy, 5, -editorcolors[10]);
|
2011-03-02 21:21:47 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-08-26 13:50:09 +00:00
|
|
|
else
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-07-04 21:20:59 +00:00
|
|
|
// didmakered: 'bad'!
|
2015-10-31 15:13:29 +00:00
|
|
|
int32_t didmakered = (highlightsectorcnt<0) || eitherCTRL, hadouterpoint=0;
|
2011-07-04 21:20:59 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2011-12-09 19:09:45 +00:00
|
|
|
for (i=0; i<MAXSECTORS>>3; i++)
|
2011-07-04 21:20:59 +00:00
|
|
|
hlorgraysectbitmap[i] = hlsectorbitmap[i]|graysectbitmap[i];
|
|
|
|
#endif
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-07-04 21:20:59 +00:00
|
|
|
int16_t tmpsect = -1;
|
|
|
|
|
2011-02-10 23:15:02 +00:00
|
|
|
for (WALLS_OF_SECTOR(highlightsector[i], j))
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-04-14 20:48:08 +00:00
|
|
|
// if (wall[j].nextwall >= 0)
|
|
|
|
// checksectorpointer(wall[j].nextwall,wall[j].nextsector);
|
|
|
|
if (wall[j].nextwall < 0)
|
|
|
|
didmakered |= !!checksectorpointer(j, highlightsector[i]);
|
2011-02-13 21:48:22 +00:00
|
|
|
|
|
|
|
if (!didmakered)
|
|
|
|
{
|
2011-07-04 21:20:59 +00:00
|
|
|
updatesectorexclude(wall[j].x, wall[j].y, &tmpsect, hlorgraysectbitmap);
|
|
|
|
if (tmpsect<0)
|
2011-02-13 21:48:22 +00:00
|
|
|
hadouterpoint = 1;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-07-04 21:20:59 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2015-10-31 19:35:25 +00:00
|
|
|
int16_t cb, fb;
|
2011-07-04 21:20:59 +00:00
|
|
|
|
2015-10-31 19:35:25 +00:00
|
|
|
yax_getbunches(highlightsector[i], &cb, &fb);
|
|
|
|
if (cb>=0 || fb>=0)
|
|
|
|
{
|
|
|
|
// TROR stuff in the pasted sectors would really
|
|
|
|
// complicate things, so don't allow this
|
|
|
|
didmakered=1;
|
2011-07-04 21:20:59 +00:00
|
|
|
}
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2011-02-13 21:48:22 +00:00
|
|
|
if (!didmakered && !hadouterpoint && newnumwalls<0)
|
2011-02-10 23:15:02 +00:00
|
|
|
{
|
2011-07-04 21:20:59 +00:00
|
|
|
// fade the screen to have the user's attention
|
|
|
|
fade_editor_screen(-1);
|
2011-02-10 23:15:02 +00:00
|
|
|
|
2011-07-04 21:20:59 +00:00
|
|
|
didmakered |= !ask_if_sure("Insert outer loop and make red walls? (Y/N)", 0);
|
|
|
|
clearkeys();
|
2011-02-10 23:15:02 +00:00
|
|
|
}
|
|
|
|
|
2011-03-02 21:21:47 +00:00
|
|
|
if (!didmakered && !hadouterpoint && newnumwalls<0)
|
2010-11-27 22:12:24 +00:00
|
|
|
{
|
2011-03-02 21:21:47 +00:00
|
|
|
int16_t ignore, refsect;
|
|
|
|
int32_t n;
|
2011-07-04 21:20:59 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
int16_t refsectbn[2]={-1,-1};
|
|
|
|
int32_t refextcf=-1;
|
|
|
|
#endif
|
2011-03-05 12:59:27 +00:00
|
|
|
Bmemset(visited, 0, sizeof(visited));
|
2010-11-27 22:12:24 +00:00
|
|
|
|
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
|
|
|
{
|
2011-02-10 23:15:02 +00:00
|
|
|
for (WALLS_OF_SECTOR(highlightsector[i], j))
|
|
|
|
{
|
2011-04-11 22:28:58 +00:00
|
|
|
k = trace_loop(j, visited, &ignore, &refsect, -1);
|
2011-03-02 21:21:47 +00:00
|
|
|
if (k == 0)
|
2011-02-10 23:15:02 +00:00
|
|
|
continue;
|
2011-03-02 21:21:47 +00:00
|
|
|
else if (k < 0)
|
2011-07-04 21:20:59 +00:00
|
|
|
goto end_autoredwall;
|
2011-02-10 23:15:02 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
if (ignore)
|
|
|
|
continue;
|
2011-07-04 21:20:59 +00:00
|
|
|
|
|
|
|
// done tracing one outer loop
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_getbunches(refsect, &refsectbn[0], &refsectbn[1]);
|
|
|
|
if (refsectbn[0]>=0 || refsectbn[1]>=0)
|
|
|
|
{
|
|
|
|
if (refsectbn[0]>=0 && refsectbn[1]>=0)
|
|
|
|
{
|
|
|
|
// at least one of ceiling/floor must be non-extended
|
|
|
|
didmakered = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// ... and the other must be non-sloped
|
|
|
|
refextcf = (refsectbn[1]>=0);
|
|
|
|
if (SECTORFLD(refsect,stat, !refextcf)&2)
|
|
|
|
didmakered = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (didmakered)
|
|
|
|
goto end_autoredwall;
|
|
|
|
|
|
|
|
if (refextcf >= 0)
|
|
|
|
{
|
|
|
|
int32_t refz = SECTORFLD(refsect,z, refextcf), tmpsect;
|
|
|
|
int32_t neededzofs=0;
|
|
|
|
|
|
|
|
// the reference sector is extended on one side
|
|
|
|
// (given by refextcf) and non-sloped on the other
|
|
|
|
if (highlighted_sectors_components(0,0) != 1)
|
|
|
|
{
|
|
|
|
message("Highlighted sectors must be in one connected component");
|
|
|
|
goto end_autoredwall;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (m=0; m<highlightsectorcnt; m++)
|
|
|
|
{
|
|
|
|
tmpsect = highlightsector[m];
|
|
|
|
yax_setbunch(tmpsect, refextcf, refsectbn[refextcf]);
|
|
|
|
// walls: not needed, since they're all inner to the bunch
|
|
|
|
|
|
|
|
SECTORFLD(tmpsect,z, refextcf) = refz;
|
|
|
|
setslope(tmpsect, refextcf, 0);
|
|
|
|
if (refextcf==0)
|
|
|
|
neededzofs = max(neededzofs, refz-sector[tmpsect].floorz);
|
|
|
|
else
|
|
|
|
neededzofs = max(neededzofs, sector[tmpsect].ceilingz-refz);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (neededzofs > 0)
|
|
|
|
{
|
|
|
|
neededzofs += ksgn(neededzofs)*(512<<4);
|
|
|
|
neededzofs &= ~((256<<4)-1);
|
|
|
|
if (refextcf==1)
|
|
|
|
neededzofs *= -1;
|
|
|
|
for (m=0; m<highlightsectorcnt; m++)
|
|
|
|
SECTORFLD(highlightsector[m],z, !refextcf) += neededzofs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2011-03-08 23:02:38 +00:00
|
|
|
wall[k-1].point2 = numwalls; // close the loop
|
|
|
|
newnumwalls = k;
|
|
|
|
n = (newnumwalls-numwalls); // number of walls in just constructed loop
|
|
|
|
|
2011-11-25 09:53:07 +00:00
|
|
|
if (clockdir(numwalls)==CLOCKDIR_CW)
|
2011-02-10 23:15:02 +00:00
|
|
|
{
|
2011-03-08 23:02:38 +00:00
|
|
|
int16_t begwalltomove = sector[refsect].wallptr+sector[refsect].wallnum;
|
2011-05-15 22:37:24 +00:00
|
|
|
int32_t onwwasvalid = onwisvalid();
|
2011-02-10 23:15:02 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
flipwalls(numwalls, newnumwalls);
|
|
|
|
|
|
|
|
sector[refsect].wallnum += n;
|
|
|
|
if (refsect != numsectors-1)
|
2010-11-27 22:12:24 +00:00
|
|
|
{
|
2016-06-21 00:33:58 +00:00
|
|
|
uwalltype *tmpwall = (uwalltype *)Xmalloc(n * sizeof(walltype));
|
2014-05-30 00:02:19 +00:00
|
|
|
int16_t *tmponw = (int16_t *)Xmalloc(n * sizeof(int16_t));
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
for (m=0; m<numwalls; m++)
|
2010-11-27 22:12:24 +00:00
|
|
|
{
|
2011-03-08 23:02:38 +00:00
|
|
|
if (wall[m].nextwall >= begwalltomove)
|
|
|
|
wall[m].nextwall += n;
|
2011-02-10 23:15:02 +00:00
|
|
|
}
|
2011-04-11 22:28:58 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_tweakwalls(begwalltomove, n);
|
|
|
|
#endif
|
2011-03-08 23:02:38 +00:00
|
|
|
for (m=refsect+1; m<numsectors; m++)
|
|
|
|
sector[m].wallptr += n;
|
|
|
|
for (m=begwalltomove; m<numwalls; m++)
|
|
|
|
wall[m].point2 += n;
|
|
|
|
for (m=numwalls; m<newnumwalls; m++)
|
|
|
|
wall[m].point2 += (begwalltomove-numwalls);
|
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
Bmemcpy(tmponw, &onextwall[numwalls], n*sizeof(int16_t));
|
|
|
|
Bmemmove(&onextwall[begwalltomove+n], &onextwall[begwalltomove],
|
|
|
|
(numwalls-begwalltomove)*sizeof(int16_t));
|
|
|
|
Bmemcpy(&onextwall[begwalltomove], tmponw, n*sizeof(int16_t));
|
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
Bmemcpy(tmpwall, &wall[numwalls], n*sizeof(walltype));
|
2011-05-15 22:37:24 +00:00
|
|
|
Bmemmove(&wall[begwalltomove+n], &wall[begwalltomove],
|
|
|
|
(numwalls-begwalltomove)*sizeof(walltype));
|
2011-03-08 23:02:38 +00:00
|
|
|
Bmemcpy(&wall[begwalltomove], tmpwall, n*sizeof(walltype));
|
|
|
|
|
|
|
|
Bfree(tmpwall);
|
2011-05-15 22:37:24 +00:00
|
|
|
Bfree(tmponw);
|
2011-03-08 23:02:38 +00:00
|
|
|
}
|
|
|
|
numwalls = newnumwalls;
|
|
|
|
newnumwalls = -1;
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
mkonwinvalid();
|
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
for (m=begwalltomove; m<begwalltomove+n; m++)
|
2011-05-15 22:37:24 +00:00
|
|
|
if (checksectorpointer(m, refsect) > 0)
|
|
|
|
if (onwwasvalid && onextwall[wall[m].nextwall]>=0)
|
|
|
|
{
|
2011-07-04 21:20:59 +00:00
|
|
|
//initprintf("%d %d\n", m, onextwall[wall[m].nextwall]);
|
2011-05-15 22:37:24 +00:00
|
|
|
copy_some_wall_members(m, onextwall[wall[m].nextwall], 0);
|
|
|
|
}
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2011-07-04 21:20:59 +00:00
|
|
|
#ifndef YAX_ENABLE
|
2011-03-08 23:02:38 +00:00
|
|
|
message("Attached new inner loop to sector %d", refsect);
|
2011-07-04 21:20:59 +00:00
|
|
|
#else
|
|
|
|
{
|
|
|
|
const char *cfstr[2] = {"ceiling","floor"};
|
|
|
|
message("Attached new inner loop to %s%ssector %d",
|
|
|
|
refextcf>=0 ? cfstr[refextcf] : "",
|
|
|
|
refextcf>=0 ? "-extended " : "", refsect);
|
|
|
|
}
|
|
|
|
|
2011-09-30 13:52:02 +00:00
|
|
|
asksave = 1;
|
|
|
|
|
2011-07-04 21:20:59 +00:00
|
|
|
if (refextcf >= 0)
|
|
|
|
{
|
|
|
|
yax_update(0);
|
|
|
|
goto end_autoredwall;
|
|
|
|
}
|
|
|
|
#endif
|
2010-11-27 22:12:24 +00:00
|
|
|
}
|
2011-02-10 23:15:02 +00:00
|
|
|
}
|
2010-11-27 22:12:24 +00:00
|
|
|
}
|
2011-07-04 21:20:59 +00:00
|
|
|
end_autoredwall:
|
2010-11-27 22:12:24 +00:00
|
|
|
newnumwalls = -1;
|
2011-07-04 21:20:59 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
#endif
|
2011-03-02 21:21:47 +00:00
|
|
|
}
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
highlightx1 = searchx;
|
|
|
|
highlighty1 = searchy;
|
|
|
|
highlightx2 = searchx;
|
2011-03-02 21:21:47 +00:00
|
|
|
highlighty2 = searchy;
|
2006-04-24 19:04:22 +00:00
|
|
|
highlightsectorcnt = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (highlightsectorcnt == 0)
|
|
|
|
{
|
2015-10-31 15:13:29 +00:00
|
|
|
int32_t const add=keystatus[0x28], sub=(!add && keystatus[0x27]), setop=(add||sub);
|
|
|
|
int32_t const pointsel = eitherCTRL;
|
|
|
|
int32_t tx,ty;
|
2011-05-29 23:10:51 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
// home: ceilings, end: floors
|
|
|
|
int32_t fb, bunchsel = keystatus[0xcf] ? 1 : (keystatus[0xc7] ? 0 : -1);
|
|
|
|
uint8_t bunchbitmap[YAX_MAXBUNCHES>>3];
|
|
|
|
Bmemset(bunchbitmap, 0, sizeof(bunchbitmap));
|
|
|
|
#endif
|
2011-03-05 12:59:27 +00:00
|
|
|
if (!m32_sideview)
|
|
|
|
{
|
|
|
|
getpoint(highlightx1,highlighty1, &highlightx1,&highlighty1);
|
|
|
|
getpoint(highlightx2,highlighty2, &highlightx2,&highlighty2);
|
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-03-02 21:21:47 +00:00
|
|
|
if (!pointsel)
|
|
|
|
{
|
|
|
|
if (highlightx1 > highlightx2)
|
|
|
|
swaplong(&highlightx1, &highlightx2);
|
|
|
|
if (highlighty1 > highlighty2)
|
|
|
|
swaplong(&highlighty1, &highlighty2);
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-11-20 16:47:18 +00:00
|
|
|
if (!setop)
|
|
|
|
Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap));
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-02 21:21:47 +00:00
|
|
|
if (pointsel)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-05 12:59:27 +00:00
|
|
|
bad = (inside_editor(&pos, searchx,searchy, zoom, highlightx2, highlighty2, i)!=1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-03-02 21:21:47 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
bad = 0;
|
|
|
|
for (WALLS_OF_SECTOR(i, j))
|
|
|
|
{
|
2011-03-05 12:59:27 +00:00
|
|
|
if (!m32_sideview)
|
|
|
|
{
|
|
|
|
tx = wall[j].x;
|
|
|
|
ty = wall[j].y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
editorGet2dScreenCoordinates(&tx,&ty, wall[j].x-pos.x,wall[j].y-pos.y, zoom);
|
2011-03-05 12:59:27 +00:00
|
|
|
ty += getscreenvdisp(getflorzofslope(i, wall[j].x,wall[j].y)-pos.z, zoom);
|
|
|
|
tx += halfxdim16;
|
|
|
|
ty += midydim16;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tx < highlightx1 || tx > highlightx2) bad = 1;
|
|
|
|
if (ty < highlighty1 || ty > highlighty2) bad = 1;
|
2011-03-02 21:21:47 +00:00
|
|
|
if (bad == 1) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (bad == 0)
|
2010-11-20 16:47:18 +00:00
|
|
|
{
|
2011-05-29 23:10:51 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (bunchsel!=-1 && (fb = yax_getbunch(i, YAX_FLOOR))>=0)
|
2010-11-20 16:47:18 +00:00
|
|
|
{
|
2011-05-29 23:10:51 +00:00
|
|
|
if ((sub || (graysectbitmap[i>>3]&(1<<(i&7)))==0) &&
|
|
|
|
(bunchbitmap[fb>>3]&(1<<(fb&7)))==0)
|
2010-11-20 16:47:18 +00:00
|
|
|
{
|
2011-05-29 23:10:51 +00:00
|
|
|
bunchbitmap[fb>>3] |= (1<<(fb&7));
|
|
|
|
for (SECTORS_OF_BUNCH(fb, bunchsel, j))
|
|
|
|
handlesecthighlight1(j, sub, 1);
|
2010-11-20 16:47:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-05-29 23:10:51 +00:00
|
|
|
#endif
|
2011-11-26 22:40:07 +00:00
|
|
|
handlesecthighlight1(i, sub, eitherSHIFT);
|
2010-11-20 16:47:18 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-11-20 16:47:18 +00:00
|
|
|
update_highlightsector();
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
ovh_whiteoutgrab(0);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (((bstatus&1) < (oldmousebstatus&1)) && highlightsectorcnt < 0) //after dragging
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-04-22 22:48:06 +00:00
|
|
|
int32_t runi, numdelpoints=0;
|
2011-10-30 19:47:42 +00:00
|
|
|
int32_t havedrawnwalls = (newnumwalls!=-1), restorestat=1;
|
|
|
|
|
|
|
|
// restorestat is set to 2 whenever the drawn walls should NOT be
|
|
|
|
// restored afterwards
|
2008-10-31 10:08:51 +00:00
|
|
|
|
2011-10-30 19:47:58 +00:00
|
|
|
int32_t err = backup_drawn_walls(0);
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
{
|
|
|
|
message("Error backing up drawn walls (code %d)!", err);
|
2011-03-08 23:02:38 +00:00
|
|
|
goto end_after_dragging;
|
2011-10-30 19:47:58 +00:00
|
|
|
}
|
2008-10-31 10:08:51 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
j = 1;
|
2011-05-12 23:31:13 +00:00
|
|
|
for (i=0; i<highlightcnt; i++)
|
|
|
|
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)
|
2011-02-24 20:40:27 +00:00
|
|
|
updatesprite1(highlight[i]&16383);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else if ((pointhighlight&0xc000) == 16384)
|
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
updatesprite1(pointhighlight&16383);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2011-05-12 23:31:13 +00:00
|
|
|
|
|
|
|
for (i=0; i<2; i++)
|
|
|
|
{
|
|
|
|
if (dragwall[i] < 0)
|
|
|
|
break;
|
|
|
|
|
2013-01-16 20:38:56 +00:00
|
|
|
if (keeptexturestretch && olen[i] != 0)
|
2011-05-12 23:31:13 +00:00
|
|
|
{
|
2011-09-15 19:31:44 +00:00
|
|
|
#ifndef YAX_ENABLE
|
|
|
|
j = dragwall[i];
|
|
|
|
#else
|
|
|
|
int32_t cf;
|
|
|
|
for (YAX_ITER_WALLS(dragwall[i], j, cf))
|
|
|
|
#endif
|
2011-05-12 23:31:13 +00:00
|
|
|
{
|
2011-09-15 19:31:44 +00:00
|
|
|
int32_t nw = wall[j].nextwall;
|
|
|
|
|
|
|
|
k = getlenbyrep(olen[i], wall[j].xrepeat);
|
|
|
|
fixxrepeat(j, k);
|
|
|
|
if (nw >= 0)
|
|
|
|
{
|
|
|
|
k = getlenbyrep(olen[i], wall[nw].xrepeat);
|
|
|
|
fixxrepeat(nw, k);
|
|
|
|
}
|
2011-05-12 23:31:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else if ((pointhighlight&0xc000) == 16384)
|
|
|
|
{
|
|
|
|
dax = sprite[pointhighlight&16383].x;
|
|
|
|
day = sprite[pointhighlight&16383].y;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-05-12 23:31:13 +00:00
|
|
|
dragwall[0] = dragwall[1] = -1;
|
|
|
|
|
2012-11-13 10:50:13 +00:00
|
|
|
// attempt to delete some points
|
2012-04-08 15:52:49 +00:00
|
|
|
for (runi=0; runi<3; runi++) // check, tweak, carry out
|
|
|
|
for (i=numwalls-1; i>=0; i--)
|
2010-05-18 05:14:17 +00:00
|
|
|
{
|
2011-05-02 16:58:11 +00:00
|
|
|
if (runi==0)
|
|
|
|
wall[i].cstat &= ~(1<<14);
|
|
|
|
|
2012-04-08 15:52:49 +00:00
|
|
|
if (wall[i].x == POINT2(i).x && wall[i].y == POINT2(i).y)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
2011-10-30 19:47:42 +00:00
|
|
|
if (havedrawnwalls)
|
|
|
|
{
|
|
|
|
if (i==ovh.suckwall || (ovh.split && i==ovh.splitstartwall))
|
|
|
|
{
|
|
|
|
// if we're about to delete a wall that participates
|
|
|
|
// in splitting, discard the already drawn walls
|
|
|
|
restorestat = 2;
|
|
|
|
}
|
|
|
|
else if (runi == 1)
|
|
|
|
{
|
|
|
|
// correct drawn wall anchors
|
|
|
|
if (ovh.suckwall > i)
|
|
|
|
ovh.suckwall--;
|
|
|
|
if (ovh.split && ovh.splitstartwall > i)
|
|
|
|
ovh.splitstartwall--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-08 15:52:49 +00:00
|
|
|
if (runi == 0)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
2012-04-08 15:52:49 +00:00
|
|
|
int32_t sectnum = sectorofwall(i);
|
|
|
|
if (sector[sectnum].wallnum <= 3)
|
|
|
|
{
|
|
|
|
message("Deleting wall %d would leave sector %d with %d walls.",
|
|
|
|
i, sectnum, sector[sectnum].wallnum-1);
|
|
|
|
goto end_after_dragging;
|
|
|
|
}
|
|
|
|
|
|
|
|
sectnum = wall[i].nextsector;
|
|
|
|
if (sectnum >= 0 && sector[sectnum].wallnum <= 3)
|
|
|
|
{
|
|
|
|
message("Deleting wall %d would leave sector %d with %d walls.",
|
|
|
|
i, sectnum, sector[sectnum].wallnum-1);
|
|
|
|
goto end_after_dragging;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
deletepoint(i, runi);
|
|
|
|
if (runi==2)
|
|
|
|
numdelpoints++;
|
2011-02-24 20:40:27 +00:00
|
|
|
}
|
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
}
|
2008-10-31 10:08:51 +00:00
|
|
|
|
2011-04-22 22:48:06 +00:00
|
|
|
if (numdelpoints)
|
|
|
|
{
|
|
|
|
if (numdelpoints > 1)
|
2011-10-30 19:47:42 +00:00
|
|
|
message("Deleted %d points%s", numdelpoints,
|
|
|
|
(havedrawnwalls && restorestat==2) ? " and cleared drawn walls":"");
|
2011-04-22 22:48:06 +00:00
|
|
|
else
|
2011-10-30 19:47:42 +00:00
|
|
|
printmessage16("Point deleted%s", (havedrawnwalls && restorestat==2) ?
|
|
|
|
", cleared drawn walls":"");
|
2011-04-22 22:48:06 +00:00
|
|
|
asksave = 1;
|
|
|
|
}
|
2011-05-02 16:58:11 +00:00
|
|
|
else
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-05-02 16:58:11 +00:00
|
|
|
for (i=0; i<numwalls; i++) //make new red lines?
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-09-22 16:52:32 +00:00
|
|
|
YAX_SKIPWALL(i);
|
|
|
|
|
2011-05-02 16:58:11 +00:00
|
|
|
if ((wall[i].x == dax && wall[i].y == day)
|
|
|
|
|| (POINT2(i).x == dax && POINT2(i).y == day))
|
|
|
|
{
|
|
|
|
checksectorpointer(i, sectorofwall(i));
|
2011-02-25 22:10:25 +00:00
|
|
|
// fixrepeats(i);
|
2011-05-02 16:58:11 +00:00
|
|
|
asksave = 1;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-02 16:58:11 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_update(0);
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
#endif
|
2011-04-22 22:48:06 +00:00
|
|
|
end_after_dragging:
|
2011-10-30 19:47:42 +00:00
|
|
|
backup_drawn_walls(restorestat);
|
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) > 0) //drag points
|
|
|
|
{
|
|
|
|
if (highlightsectorcnt > 0)
|
|
|
|
{
|
|
|
|
if ((bstatus&1) > (oldmousebstatus&1))
|
|
|
|
{
|
|
|
|
newnumwalls = -1;
|
|
|
|
sectorhighlightstat = -1;
|
2009-10-01 20:14:36 +00:00
|
|
|
|
|
|
|
// updatesector(mousxplc,mousyplc,&cursectorhighlight);
|
|
|
|
cursectorhighlight = -1;
|
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2011-04-22 22:48:06 +00:00
|
|
|
if (inside_editor_curpos(highlightsector[i])==1)
|
2009-10-01 20:14:36 +00:00
|
|
|
{
|
|
|
|
cursectorhighlight = highlightsector[i];
|
|
|
|
break;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-03-02 21:21:47 +00:00
|
|
|
if (cursectorhighlight >= 0 && cursectorhighlight < numsectors)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-06-04 00:06:08 +00:00
|
|
|
//You clicked inside one of the flashing sectors!
|
|
|
|
sectorhighlightstat = 1;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
dax = mousxplc;
|
|
|
|
day = mousyplc;
|
|
|
|
if (gridlock && grid > 0)
|
|
|
|
locktogrid(&dax, &day);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
sectorhighlightx = dax;
|
|
|
|
sectorhighlighty = day;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sectorhighlightstat == 1)
|
|
|
|
{
|
|
|
|
dax = mousxplc;
|
|
|
|
day = mousyplc;
|
2010-05-18 05:14:17 +00:00
|
|
|
if (gridlock && grid > 0)
|
|
|
|
locktogrid(&dax, &day);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
dax -= sectorhighlightx;
|
|
|
|
day -= sectorhighlighty;
|
|
|
|
sectorhighlightx += dax;
|
|
|
|
sectorhighlighty += day;
|
2011-05-15 22:37:24 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2011-06-04 00:06:08 +00:00
|
|
|
if (!hl_all_bunch_sectors_p())
|
2011-05-15 22:37:24 +00:00
|
|
|
printmessage16("To drag extended sectors, all sectors of a bunch must be selected");
|
|
|
|
else
|
|
|
|
#endif
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<highlightsectorcnt; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-02-10 23:15:02 +00:00
|
|
|
for (WALLS_OF_SECTOR(highlightsector[i], 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
|
|
|
}
|
2011-03-02 21:21:47 +00:00
|
|
|
else //if (highlightsectorcnt <= 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if ((bstatus&1) > (oldmousebstatus&1))
|
2011-05-12 23:31:13 +00:00
|
|
|
{
|
2008-09-02 02:45:06 +00:00
|
|
|
pointhighlight = getpointhighlight(mousxplc, mousyplc, pointhighlight);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
if (pointhighlight >= 0 && (pointhighlight&0xc000)==0)
|
2011-05-12 23:31:13 +00:00
|
|
|
{
|
|
|
|
dragwall[0] = lastwall(pointhighlight);
|
|
|
|
dragwall[1] = pointhighlight;
|
|
|
|
olen[0] = wallength(dragwall[0]);
|
|
|
|
olen[1] = wallength(dragwall[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-05 17:39:52 +00:00
|
|
|
if (pointhighlight >= 0 && (!m32_sideview || m32_sideelev>=32))
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-12-05 17:39:52 +00:00
|
|
|
if (m32_sideview)
|
|
|
|
{
|
|
|
|
int32_t dz;
|
|
|
|
if (pointhighlight>=16384)
|
|
|
|
dz = sprite[pointhighlight&16383].z - pos.z;
|
|
|
|
else
|
|
|
|
dz = getflorzofslope(sectorofwall(pointhighlight),
|
|
|
|
wall[pointhighlight].x, wall[pointhighlight].y) - pos.z;
|
|
|
|
getinvdisplacement(&dax,&day, -dz);
|
|
|
|
dax += mousxplc;
|
|
|
|
day += mousyplc;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dax = mousxplc;
|
|
|
|
day = mousyplc;
|
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (gridlock && grid > 0)
|
|
|
|
locktogrid(&dax, &day);
|
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;
|
|
|
|
}
|
2010-12-05 17:39:52 +00:00
|
|
|
|
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
|
|
|
|
{
|
2011-06-29 19:57:05 +00:00
|
|
|
spritetype *daspr = &sprite[highlight[i]&16383];
|
|
|
|
|
|
|
|
daspr->x += dax;
|
|
|
|
daspr->y += day;
|
2011-08-09 16:03:56 +00:00
|
|
|
setspritez(daspr-sprite, (const vec3_t *)daspr);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((pointhighlight&0xc000) == 0)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
|
|
|
if (newnumwalls >= numwalls &&
|
|
|
|
wall[pointhighlight].x==firstx && wall[pointhighlight].y==firsty)
|
|
|
|
{
|
|
|
|
printmessage16("Can't drag point where drawing started.");
|
|
|
|
goto end_point_dragging;
|
|
|
|
}
|
|
|
|
|
2013-01-16 20:38:41 +00:00
|
|
|
dragpoint(pointhighlight,dax,day,2);
|
2011-05-29 12:30:38 +00:00
|
|
|
wall[lastwall(pointhighlight)].cstat |= (1<<14);
|
2011-02-24 20:40:27 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
else if ((pointhighlight&0xc000) == 16384)
|
|
|
|
{
|
2012-01-30 18:25:13 +00:00
|
|
|
int32_t daspr=pointhighlight&16383;
|
|
|
|
int16_t osec=sprite[daspr].sectnum, nsec=osec;
|
2009-10-01 19:43:15 +00:00
|
|
|
vec3_t vec, ovec;
|
|
|
|
|
|
|
|
Bmemcpy(&ovec, (vec3_t *)&sprite[daspr], sizeof(vec3_t));
|
|
|
|
vec.x = dax;
|
|
|
|
vec.y = day;
|
|
|
|
vec.z = sprite[daspr].z;
|
2011-08-09 16:03:56 +00:00
|
|
|
if (setspritez(daspr, &vec) == -1 && osec>=0)
|
2012-01-30 18:25:13 +00:00
|
|
|
{
|
2012-10-01 17:52:09 +00:00
|
|
|
updatesectorbreadth(dax, day, &nsec);
|
2011-02-10 23:15:02 +00:00
|
|
|
|
2012-01-30 18:25:13 +00:00
|
|
|
if (nsec >= 0)
|
|
|
|
{
|
|
|
|
sprite[daspr].x = dax;
|
|
|
|
sprite[daspr].y = day;
|
|
|
|
// z updating is after we released the mouse button
|
|
|
|
if (sprite[daspr].sectnum != nsec)
|
|
|
|
changespritesect(daspr, nsec);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Bmemcpy(&sprite[daspr], &ovec, sizeof(vec3_t));
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2012-01-30 18:25:13 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
else //if ((bstatus&1) == 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2008-09-02 02:45:06 +00:00
|
|
|
pointhighlight = getpointhighlight(mousxplc, mousyplc, pointhighlight);
|
2006-04-24 19:04:22 +00:00
|
|
|
sectorhighlightstat = -1;
|
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
end_point_dragging:
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-07-23 23:51:30 +00:00
|
|
|
if (bstatus&(2) && (!(bstatus&5) || pointhighlight > 0 || highlightcnt > 0 || highlightsectorcnt > 0)) // change arrow position
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
if (eitherCTRL)
|
2009-05-01 06:35:27 +00:00
|
|
|
{
|
|
|
|
int16_t cursectornum;
|
|
|
|
|
|
|
|
for (cursectornum=0; cursectornum<numsectors; cursectornum++)
|
2011-04-22 22:48:06 +00:00
|
|
|
if (inside_editor_curpos(cursectornum) == 1)
|
2009-05-01 06:35:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (cursectornum < numsectors)
|
|
|
|
{
|
|
|
|
if (pointhighlight >= 16384)
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtEditSpriteData(pointhighlight-16384);
|
2011-07-04 21:20:59 +00:00
|
|
|
else if ((linehighlight >= 0) && ((bstatus&1) || sectorofwall(linehighlight) == cursectornum))
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtEditWallData(linehighlight);
|
2009-05-01 06:35:27 +00:00
|
|
|
else if (cursectornum >= 0)
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtEditSectorData(cursectornum);
|
2009-05-01 06:35:27 +00:00
|
|
|
}
|
|
|
|
|
2015-07-17 00:12:48 +00:00
|
|
|
bstatus &= ~2;
|
2009-05-01 06:35:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-27 22:12:24 +00:00
|
|
|
if (m32_sideview && (bstatus&4))
|
|
|
|
{
|
|
|
|
pos.z += divscale18(searchy-midydim16,zoom);
|
|
|
|
getpoint(searchx,midydim16, &pos.x, &pos.y);
|
2011-04-22 22:48:06 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
#endif
|
2010-11-27 22:12:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pos.x = mousxplc;
|
|
|
|
pos.y = mousyplc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m32_sideview)
|
|
|
|
{
|
|
|
|
int32_t opat=drawlinepat;
|
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
y1 = INT32_MAX;
|
2010-11-27 22:12:24 +00:00
|
|
|
|
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
{
|
|
|
|
if (inside(pos.x, pos.y, i)==1)
|
|
|
|
{
|
2010-12-05 17:39:52 +00:00
|
|
|
day = getscreenvdisp(getflorzofslope(i, pos.x, pos.y)-pos.z, zoom);
|
2010-11-27 22:12:24 +00:00
|
|
|
|
|
|
|
x2 = max(4, mulscale14(64,zoom));
|
|
|
|
y2 = scalescreeny(x2);
|
|
|
|
|
|
|
|
if (klabs(day) < y1)
|
|
|
|
y1 = day;
|
|
|
|
|
2010-12-05 17:39:52 +00:00
|
|
|
drawline16base(halfxdim16, midydim16+day, -x2,-y2, x2,y2, editorcolors[14]);
|
|
|
|
drawline16base(halfxdim16, midydim16+day, -x2,y2, x2,-y2, editorcolors[14]);
|
2010-11-27 22:12:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-05 17:39:52 +00:00
|
|
|
drawlinepat = 0x11111111;
|
2011-05-15 22:37:24 +00:00
|
|
|
if (y1 != INT32_MAX)
|
2010-12-05 17:39:52 +00:00
|
|
|
drawline16base(halfxdim16,midydim16, 0,0, 0,y1, editorcolors[14]);
|
2011-02-13 21:48:22 +00:00
|
|
|
// else
|
|
|
|
// drawline16base(halfxdim16,midydim16, 0,0, 0,getscreenvdisp(-pos.z, zoom), editorcolors[14]);
|
2010-12-05 17:39:52 +00:00
|
|
|
drawlinepat = opat;
|
2010-11-27 22:12:24 +00:00
|
|
|
}
|
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
searchx = halfxdim16;
|
|
|
|
searchy = midydim16;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2015-07-08 03:34:42 +00:00
|
|
|
// else if ((oldmousebstatus&6) > 0)
|
2010-11-27 22:12:24 +00:00
|
|
|
updatesectorz(pos.x,pos.y,pos.z,&cursectnum);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-02-13 21:48:22 +00:00
|
|
|
if (circlewall != -1 && (keystatus[0x4a] || ((bstatus&32) && !eitherCTRL))) // -, mousewheel down
|
2008-06-03 07:54:20 +00:00
|
|
|
{
|
|
|
|
if (circlepoints > 1)
|
|
|
|
circlepoints--;
|
|
|
|
keystatus[0x4a] = 0;
|
2018-04-12 21:02:31 +00:00
|
|
|
g_mouseBits &= ~32;
|
2008-06-03 07:54:20 +00:00
|
|
|
bstatus &= ~32;
|
|
|
|
}
|
2011-02-13 21:48:22 +00:00
|
|
|
if (circlewall != -1 && (keystatus[0x4e] || ((bstatus&16) && !eitherCTRL))) // +, mousewheel up
|
2008-06-03 07:54:20 +00:00
|
|
|
{
|
|
|
|
if (circlepoints < 63)
|
|
|
|
circlepoints++;
|
|
|
|
keystatus[0x4e] = 0;
|
2018-04-12 21:02:31 +00:00
|
|
|
g_mouseBits &= ~16;
|
2008-06-03 07:54:20 +00:00
|
|
|
bstatus &= ~16;
|
|
|
|
}
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
if (keystatus[0x3d]) // F3
|
2007-02-15 01:45:38 +00:00
|
|
|
{
|
2010-11-27 22:12:24 +00:00
|
|
|
keystatus[0x3d]=0;
|
2011-11-25 09:53:07 +00:00
|
|
|
if (!m32_sideview && EDITING_MAP_P())
|
2010-11-27 22:12:24 +00:00
|
|
|
message("Must not be editing map while switching to side view mode.");
|
|
|
|
else
|
2007-02-15 01:45:38 +00:00
|
|
|
{
|
2010-11-27 22:12:24 +00:00
|
|
|
m32_sideview = !m32_sideview;
|
2011-03-02 21:21:47 +00:00
|
|
|
printmessage16("Side view %s", m32_sideview?"enabled":"disabled");
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
}
|
2010-11-27 22:12:24 +00:00
|
|
|
|
|
|
|
if (m32_sideview && (keystatus[0x10] || keystatus[0x11]))
|
2007-02-15 01:45:38 +00:00
|
|
|
{
|
2010-11-27 22:12:24 +00:00
|
|
|
if (eitherCTRL)
|
2007-02-15 01:45:38 +00:00
|
|
|
{
|
2010-12-05 17:39:52 +00:00
|
|
|
if (m32_sideang&63)
|
|
|
|
{
|
|
|
|
m32_sideang += (1-2*keystatus[0x10])*(1-2*sideview_reversehrot)*32;
|
|
|
|
m32_sideang &= (2047&~63);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m32_sideang += (1-2*keystatus[0x10])*(1-2*sideview_reversehrot)*64;
|
|
|
|
m32_sideang &= 2047;
|
|
|
|
}
|
|
|
|
|
|
|
|
keystatus[0x10] = keystatus[0x11] = 0;
|
2010-11-27 22:12:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-05 17:39:52 +00:00
|
|
|
m32_sideang += (1-2*keystatus[0x10])*(1-2*sideview_reversehrot)*synctics<<(eitherSHIFT*2);
|
2010-11-27 22:12:24 +00:00
|
|
|
m32_sideang &= 2047;
|
|
|
|
}
|
|
|
|
_printmessage16("Sideview angle: %d", (int32_t)m32_sideang);
|
|
|
|
}
|
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
if (m32_sideview && (eitherSHIFT || (bstatus&(16|32))))
|
2010-11-27 22:12:24 +00:00
|
|
|
{
|
2011-02-13 21:48:22 +00:00
|
|
|
if ((DOWN_BK(MOVEUP) || (bstatus&16)) && m32_sideelev < 512)
|
2010-11-27 22:12:24 +00:00
|
|
|
{
|
2013-12-20 07:24:09 +00:00
|
|
|
if (DOWN_BK(MOVEUP))
|
|
|
|
m32_sideelev += synctics<<1;
|
|
|
|
if (bstatus&16)
|
|
|
|
m32_sideelev += 4<<1;
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
if (m32_sideelev > 512)
|
|
|
|
m32_sideelev = 512;
|
|
|
|
_printmessage16("Sideview elevation: %d", m32_sideelev);
|
|
|
|
}
|
2011-02-13 21:48:22 +00:00
|
|
|
if ((DOWN_BK(MOVEDOWN) || (bstatus&32)) && m32_sideelev > 0)
|
2010-11-27 22:12:24 +00:00
|
|
|
{
|
2013-12-20 07:24:09 +00:00
|
|
|
if (DOWN_BK(MOVEDOWN))
|
|
|
|
m32_sideelev -= synctics<<1;
|
|
|
|
if (bstatus&32)
|
|
|
|
m32_sideelev -= 4<<1;
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
if (m32_sideelev < 0)
|
|
|
|
m32_sideelev = 0;
|
|
|
|
_printmessage16("Sideview elevation: %d", m32_sideelev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-13 21:48:22 +00:00
|
|
|
int32_t didzoom=0;
|
|
|
|
|
2015-07-11 23:07:47 +00:00
|
|
|
if ((DOWN_BK(MOVEUP) || (bstatus&16)) && zoom < 39936)
|
2010-11-27 22:12:24 +00:00
|
|
|
{
|
2013-12-20 07:24:09 +00:00
|
|
|
if (DOWN_BK(MOVEUP))
|
2015-07-09 03:55:24 +00:00
|
|
|
{
|
2015-07-08 03:34:46 +00:00
|
|
|
ztarget += (synctics*(ztarget>>4))>>(eitherSHIFT<<1);
|
2015-07-09 03:55:24 +00:00
|
|
|
|
|
|
|
if (zoom < 64)
|
|
|
|
ztarget += (synctics*(ztarget>>4)) * (eitherSHIFT);
|
|
|
|
}
|
2013-12-20 07:24:09 +00:00
|
|
|
if (bstatus&16)
|
2015-07-08 03:34:42 +00:00
|
|
|
ztarget += 4*(ztarget>>4);
|
2013-12-20 07:24:09 +00:00
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
if (zoom < 24) zoom += 2;
|
2011-02-13 21:48:22 +00:00
|
|
|
didzoom = 1;
|
2010-11-27 22:12:24 +00:00
|
|
|
}
|
2015-07-09 03:55:24 +00:00
|
|
|
if ((DOWN_BK(MOVEDOWN) || (bstatus&32)) && zoom > 16)
|
2010-11-27 22:12:24 +00:00
|
|
|
{
|
2013-12-20 07:24:09 +00:00
|
|
|
if (DOWN_BK(MOVEDOWN))
|
2015-07-09 03:55:24 +00:00
|
|
|
{
|
2015-07-08 03:34:46 +00:00
|
|
|
ztarget -= (synctics*(ztarget>>4))>>(eitherSHIFT<<1);
|
2015-07-09 03:55:24 +00:00
|
|
|
|
|
|
|
if (zoom < 64)
|
|
|
|
ztarget -= (synctics * (ztarget >> 4)) * (eitherSHIFT);
|
|
|
|
}
|
2013-12-20 07:24:09 +00:00
|
|
|
if (bstatus&32)
|
2015-07-08 03:34:42 +00:00
|
|
|
ztarget -= 4*(ztarget>>4);
|
2013-12-20 07:24:09 +00:00
|
|
|
|
2011-02-13 21:48:22 +00:00
|
|
|
didzoom = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (didzoom)
|
|
|
|
{
|
|
|
|
if (eitherALT)
|
2010-11-27 22:12:24 +00:00
|
|
|
{
|
|
|
|
searchx = halfxdim16;
|
|
|
|
searchy = midydim16;
|
|
|
|
pos.x = mousxplc;
|
|
|
|
pos.y = mousyplc;
|
|
|
|
}
|
2015-07-11 23:07:47 +00:00
|
|
|
ztarget = clamp(ztarget, 16, 39936);
|
2015-07-09 03:55:24 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
_printmessage16("Zoom: %d",ztarget);
|
2007-02-15 01:45:38 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
|
2015-07-09 03:55:24 +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
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
keystatus[0x22] = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
grid++;
|
|
|
|
if (grid == 7) grid = 0;
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[0x26]) // L (grid lock)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
keystatus[0x26] = 0;
|
2015-07-10 07:56:48 +00:00
|
|
|
|
|
|
|
if (eitherSHIFT)
|
|
|
|
{
|
|
|
|
searchlock = 1-searchlock;
|
|
|
|
silentmessage("Selection lock %s", searchlock ? "on" : "off");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gridlock = !gridlock;
|
|
|
|
silentmessage("Grid locking %s", gridlock ? "on" : "off");
|
|
|
|
}
|
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
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
keystatus[0x24] = 0;
|
|
|
|
|
|
|
|
if (newnumwalls >= 0)
|
|
|
|
{
|
|
|
|
printmessage16("Can't join sectors while editing.");
|
|
|
|
goto end_join_sectors;
|
|
|
|
}
|
|
|
|
|
2011-05-23 22:42:39 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2011-05-22 21:52:22 +00:00
|
|
|
if (highlightsectorcnt > 0 && eitherCTRL)
|
|
|
|
{
|
|
|
|
// [component][ceiling(0) or floor(1)]
|
2011-05-23 22:42:39 +00:00
|
|
|
// compstat: &1: "has extension", &2: "differ in z", &4: "sloped", -1: "uninited"
|
|
|
|
int32_t cf, comp, compstat[2][2]={{-1,-1},{-1,-1}}, compcfz[2][2];
|
2011-05-22 21:52:22 +00:00
|
|
|
|
2011-05-23 22:42:39 +00:00
|
|
|
// joinstat: join what to what?
|
2011-05-22 21:52:22 +00:00
|
|
|
// &1: ceil(comp 0) <-> flor(comp 1), &2: flor(comp 0) <-> ceil(comp 1)
|
|
|
|
// (doesn't yet say which is stationary)
|
2011-05-23 22:42:39 +00:00
|
|
|
// movestat: which component can be displaced?
|
|
|
|
// &1: first, &2: second
|
2011-06-04 00:06:08 +00:00
|
|
|
int32_t askres, joinstat, needsdisp, moveonwp;
|
|
|
|
int32_t movestat, dx=0,dy=0,dz, delayerr=0;
|
2011-05-22 21:52:22 +00:00
|
|
|
|
|
|
|
int32_t numouterwalls[2] = {0,0}, numowals;
|
2011-06-04 00:06:08 +00:00
|
|
|
static int16_t outerwall[2][MAXWALLS];
|
2016-06-21 00:33:58 +00:00
|
|
|
const uwalltype *wal0, *wal1, *wal0p2, *wal1p2;
|
2011-05-22 21:52:22 +00:00
|
|
|
|
|
|
|
// join sector ceilings/floors to a new bunch
|
|
|
|
if (numyaxbunches==YAX_MAXBUNCHES)
|
|
|
|
{
|
|
|
|
message("Bunch limit of %d reached, cannot join", YAX_MAXBUNCHES);
|
|
|
|
goto end_join_sectors;
|
|
|
|
}
|
|
|
|
|
|
|
|
// first, see whether we have exactly two connected components
|
|
|
|
// wrt wall[].nextsector
|
2011-06-04 00:06:08 +00:00
|
|
|
if (highlighted_sectors_components(0,0) != 2)
|
2011-05-22 21:52:22 +00:00
|
|
|
{
|
|
|
|
message("Sectors must be partitioned in two components to join");
|
|
|
|
goto end_join_sectors;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (k=0; k<highlightsectorcnt; k++)
|
|
|
|
{
|
|
|
|
j = highlightsector[k];
|
|
|
|
comp = !!(collsectbitmap[1][j>>3]&(1<<(j&7)));
|
|
|
|
|
|
|
|
for (cf=0; cf<2; cf++)
|
|
|
|
{
|
2011-05-23 22:42:39 +00:00
|
|
|
if (compstat[comp][cf]==-1)
|
|
|
|
{
|
|
|
|
compstat[comp][cf] = 0;
|
2011-05-22 21:52:22 +00:00
|
|
|
compcfz[comp][cf] = SECTORFLD(j,z, cf);
|
2011-05-23 22:42:39 +00:00
|
|
|
}
|
2011-05-22 21:52:22 +00:00
|
|
|
|
|
|
|
if (yax_getbunch(j, cf)>=0)
|
|
|
|
compstat[comp][cf] |= 1;
|
|
|
|
if (SECTORFLD(j,z, cf) != compcfz[comp][cf])
|
|
|
|
compstat[comp][cf] |= 2;
|
|
|
|
if (SECTORFLD(j,stat, cf)&2)
|
|
|
|
compstat[comp][cf] |= 4;
|
|
|
|
|
|
|
|
compcfz[comp][cf] = SECTORFLD(j,z, cf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check for consistency
|
|
|
|
joinstat = 0;
|
|
|
|
if (!compstat[0][YAX_CEILING] && !compstat[1][YAX_FLOOR])
|
|
|
|
joinstat |= 1;
|
|
|
|
if (!compstat[0][YAX_FLOOR] && !compstat[1][YAX_CEILING])
|
|
|
|
joinstat |= 2;
|
|
|
|
|
|
|
|
if (joinstat==0)
|
|
|
|
{
|
|
|
|
message("No consistent joining combination found");
|
2011-07-30 13:03:07 +00:00
|
|
|
OSD_Printf("comp0: c=%d,f=%d; comp1: c=%d,f=%d (1:extended, 2:z mismatch, 4:sloped)\n",
|
|
|
|
compstat[0][YAX_CEILING], compstat[0][YAX_FLOOR],
|
|
|
|
compstat[1][YAX_CEILING], compstat[1][YAX_FLOOR]);
|
2011-05-23 22:42:39 +00:00
|
|
|
//for (i=0; i<2; i++) for (j=0; j<2; j++) message("%d", compstat[i][j]);
|
2011-05-22 21:52:22 +00:00
|
|
|
goto end_join_sectors;
|
|
|
|
}
|
|
|
|
if (joinstat==3)
|
|
|
|
{
|
|
|
|
if (compcfz[0][YAX_CEILING] != compstat[1][YAX_FLOOR])
|
|
|
|
joinstat &= 1;
|
|
|
|
if (compcfz[0][YAX_CEILING] != compstat[1][YAX_FLOOR])
|
|
|
|
joinstat &= 2;
|
|
|
|
|
|
|
|
if (joinstat == 0)
|
|
|
|
joinstat = 3; // we couldn't disambiguate
|
|
|
|
}
|
|
|
|
|
|
|
|
for (comp=0; comp<2; comp++)
|
|
|
|
for (k=0; k<collnumsects[comp]; k++)
|
|
|
|
{
|
|
|
|
i = collsectlist[comp][k];
|
|
|
|
for (WALLS_OF_SECTOR(i, j))
|
|
|
|
if (wall[j].nextwall < 0)
|
|
|
|
outerwall[comp][numouterwalls[comp]++] = j;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numouterwalls[0] != numouterwalls[1])
|
|
|
|
{
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
message("Number of outer walls must be equal for both components"
|
|
|
|
" (have %d and %d)", numouterwalls[0], numouterwalls[1]);
|
2011-06-04 00:06:08 +00:00
|
|
|
if (numouterwalls[0]>0 && numouterwalls[1]>0)
|
|
|
|
delayerr = 1;
|
|
|
|
else
|
|
|
|
goto end_join_sectors;
|
2011-05-22 21:52:22 +00:00
|
|
|
}
|
2011-06-04 00:06:08 +00:00
|
|
|
numowals = min(numouterwalls[0], numouterwalls[1]);
|
2011-05-22 21:52:22 +00:00
|
|
|
|
|
|
|
// now sort outer walls 'geometrically'
|
|
|
|
for (comp=0; comp<2; comp++)
|
|
|
|
sort_walls_geometrically(outerwall[comp], numouterwalls[comp]);
|
|
|
|
|
|
|
|
for (k=0; k<numowals; k++)
|
|
|
|
{
|
2016-06-21 00:33:58 +00:00
|
|
|
wal0 = (uwalltype *)&wall[outerwall[0][k]];
|
|
|
|
wal1 = (uwalltype *)&wall[outerwall[1][k]];
|
2011-05-22 21:52:22 +00:00
|
|
|
|
2016-06-21 00:33:58 +00:00
|
|
|
wal0p2 = (uwalltype *)&wall[wal0->point2];
|
|
|
|
wal1p2 = (uwalltype *)&wall[wal1->point2];
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
|
2011-05-22 21:52:22 +00:00
|
|
|
if (k==0)
|
|
|
|
{
|
|
|
|
dx = wal1->x - wal0->x;
|
|
|
|
dy = wal1->y - wal0->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wal1->x - wal0->x != dx || wal1->y - wal0->y != dy ||
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
wal1p2->x - wal0p2->x != dx || wal1p2->y - wal0p2->y != dy)
|
2011-05-22 21:52:22 +00:00
|
|
|
{
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
pos.x = wal0->x + (wal0p2->x - wal0->x)/4;
|
|
|
|
pos.y = wal0->y + (wal0p2->y - wal0->y)/4;
|
2016-06-21 00:33:58 +00:00
|
|
|
pos.z = getflorzofslope(sectorofwall(wal0-(uwalltype *)wall), pos.x, pos.y);
|
2011-06-04 00:06:08 +00:00
|
|
|
|
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
|
|
|
if (!delayerr)
|
|
|
|
message("Outer wall coordinates must coincide for both components");
|
2016-06-21 00:33:58 +00:00
|
|
|
OSD_Printf("wal0:%d (%d,%d)--(%d,%d)\n",(int)(wal0-(uwalltype *)wall),
|
2015-01-11 04:56:38 +00:00
|
|
|
wal0->x,wal0->y, wal0p2->x,wal0p2->y);
|
2016-06-21 00:33:58 +00:00
|
|
|
OSD_Printf("wal1:%d (%d,%d)--(%d,%d)\n",(int)(wal1-(uwalltype *)wall),
|
2015-01-11 04:56:38 +00:00
|
|
|
wal1->x,wal1->y, wal1p2->x,wal1p2->y);
|
2011-06-04 00:06:08 +00:00
|
|
|
|
2011-05-22 21:52:22 +00:00
|
|
|
goto end_join_sectors;
|
|
|
|
}
|
|
|
|
}
|
2011-05-23 22:42:39 +00:00
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
if (delayerr)
|
|
|
|
goto end_join_sectors;
|
|
|
|
|
2011-05-23 22:42:39 +00:00
|
|
|
if (joinstat == 3)
|
|
|
|
{
|
|
|
|
char askchars[2] = {'1', 'v'};
|
|
|
|
|
|
|
|
// now is a good time to ask...
|
|
|
|
for (comp=0; comp<2; comp++)
|
|
|
|
for (k=0; k<collnumsects[comp]; k++)
|
2015-10-31 15:13:32 +00:00
|
|
|
fillsector_notrans(collsectlist[comp][k], comp==0 ? 159 : editorcolors[11]);
|
2011-05-23 22:42:39 +00:00
|
|
|
|
|
|
|
fade_editor_screen(editorcolors[11] | (159<<8));
|
2015-10-31 15:13:32 +00:00
|
|
|
|
2015-10-31 15:13:33 +00:00
|
|
|
char buffer[128];
|
|
|
|
Bsnprintf(buffer, sizeof(buffer), "Z differences | yellow ceiling w/ blue floor: %d, vice versa: %d",
|
|
|
|
compcfz[YAX_CEILING][0]-compcfz[YAX_FLOOR][1],
|
|
|
|
compcfz[YAX_CEILING][1]-compcfz[YAX_FLOOR][0]);
|
|
|
|
printext16(8, ydim-STATUS2DSIZ2-12, editorcolors[15], -1, buffer, 0);
|
|
|
|
|
|
|
|
askres = editor_ask_function("Connect yellow ceiling w/ blue floor (1) or (v)ice versa?", askchars, 2);
|
2011-05-23 22:42:39 +00:00
|
|
|
if (askres==-1)
|
|
|
|
goto end_join_sectors;
|
|
|
|
joinstat &= (1<<askres);
|
|
|
|
}
|
|
|
|
|
|
|
|
joinstat--; // 0:ceil(0)<->flor(1), 1:ceil(1)<->flor(0)
|
|
|
|
|
|
|
|
dz = compcfz[1][!joinstat] - compcfz[0][joinstat];
|
|
|
|
needsdisp = (dx || dy || dz);
|
|
|
|
|
|
|
|
if (needsdisp)
|
|
|
|
{
|
2011-05-29 23:10:51 +00:00
|
|
|
// a component is more likely to be displaced if it's not
|
|
|
|
// extended on the non-joining side
|
2011-05-29 12:30:38 +00:00
|
|
|
movestat = (!(compstat[0][!joinstat]&1)) | ((!(compstat[1][joinstat]&1))<<1);
|
2011-05-23 22:42:39 +00:00
|
|
|
if (!movestat)
|
|
|
|
{
|
2011-05-29 23:10:51 +00:00
|
|
|
movestat = 3;
|
|
|
|
// message("Internal error while TROR-joining: movestat inconsistent!");
|
|
|
|
// goto end_join_sectors;
|
2011-05-23 22:42:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (movestat==3)
|
|
|
|
{
|
|
|
|
char askchars[2] = {'y', 'b'};
|
|
|
|
|
|
|
|
for (comp=0; comp<2; comp++)
|
|
|
|
for (k=0; k<collnumsects[comp]; k++)
|
2015-10-31 15:13:32 +00:00
|
|
|
fillsector_notrans(collsectlist[comp][k], comp==0 ? 159 : editorcolors[11]);
|
2011-05-23 22:42:39 +00:00
|
|
|
|
|
|
|
fade_editor_screen(editorcolors[11] | (159<<8));
|
|
|
|
askres = editor_ask_function("Move (y)ellow or (b)lue component?", askchars, 2);
|
|
|
|
if (askres==-1)
|
|
|
|
goto end_join_sectors;
|
|
|
|
movestat &= (1<<askres);
|
|
|
|
}
|
|
|
|
|
|
|
|
movestat--; // 0:move 1st, 1:move 2nd component
|
|
|
|
if (movestat==1)
|
|
|
|
dx*=-1, dy*=-1, dz*=-1;
|
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
moveonwp = 0;
|
|
|
|
if (onwisvalid())
|
|
|
|
{
|
|
|
|
static int16_t ocollsectlist[MAXSECTORS];
|
|
|
|
static uint8_t tcollbitmap[MAXSECTORS>>3];
|
|
|
|
int16_t ocollnumsects=collnumsects[movestat], tmpsect;
|
|
|
|
|
|
|
|
Bmemcpy(ocollsectlist, collsectlist[movestat], ocollnumsects*sizeof(int16_t));
|
|
|
|
Bmemset(tcollbitmap, 0, sizeof(tcollbitmap));
|
|
|
|
|
|
|
|
for (k=0; k<ocollnumsects; k++)
|
|
|
|
for (WALLS_OF_SECTOR(ocollsectlist[k], j))
|
|
|
|
{
|
|
|
|
if (onextwall[j] < 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
tmpsect = sectorofwall(onextwall[j]);
|
|
|
|
sectors_components(1, &tmpsect, 1,0);
|
|
|
|
|
|
|
|
for (m=0; m<(numsectors+7)>>3; m++)
|
|
|
|
tcollbitmap[m] |= collsectbitmap[0][m];
|
|
|
|
moveonwp = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (moveonwp)
|
|
|
|
{
|
|
|
|
int32_t movecol = movestat==0 ? 159 : editorcolors[11];
|
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
if (tcollbitmap[i>>3]&(1<<(i&7)))
|
2015-10-31 15:13:32 +00:00
|
|
|
fillsector_notrans(i, editorcolors[12]);
|
2011-06-04 00:06:08 +00:00
|
|
|
|
|
|
|
fade_editor_screen(editorcolors[12] | (movecol<<8));
|
|
|
|
moveonwp = ask_if_sure("Also move formerly wall-connected sectors?",0);
|
|
|
|
if (moveonwp==-1)
|
|
|
|
goto end_join_sectors;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-23 22:42:39 +00:00
|
|
|
// now need to collect them wrt. the nextsector but also
|
|
|
|
// the yax-nextsector relation
|
2011-06-04 00:06:08 +00:00
|
|
|
if (highlighted_sectors_components(1,moveonwp) != 2)
|
2011-05-23 22:42:39 +00:00
|
|
|
{
|
|
|
|
message("Must not have TROR connections between the two components");
|
|
|
|
goto end_join_sectors;
|
|
|
|
}
|
|
|
|
|
|
|
|
// displace!
|
|
|
|
for (k=0; k<collnumsects[movestat]; k++)
|
|
|
|
{
|
|
|
|
i = collsectlist[movestat][k];
|
|
|
|
|
|
|
|
sector[i].floorz += dz;
|
|
|
|
sector[i].ceilingz += dz;
|
|
|
|
|
|
|
|
for (WALLS_OF_SECTOR(i, j))
|
|
|
|
{
|
|
|
|
wall[j].x += dx;
|
|
|
|
wall[j].y += dy;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j=headspritesect[i]; j>=0; j=nextspritesect[j])
|
|
|
|
{
|
|
|
|
sprite[j].x += dx;
|
|
|
|
sprite[j].y += dy;
|
|
|
|
sprite[j].z += dz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
// restore old components, i.e. only the bunch sectors
|
|
|
|
highlighted_sectors_components(0,0);
|
2011-05-23 22:42:39 +00:00
|
|
|
|
|
|
|
} // end if (needsdisp)
|
|
|
|
|
|
|
|
/*** construct the YAX connection! ***/
|
|
|
|
for (comp=0; comp<2; comp++)
|
|
|
|
{
|
2011-06-04 00:06:08 +00:00
|
|
|
// walls
|
|
|
|
for (j=0; j<numowals; j++)
|
|
|
|
yax_setnextwall(outerwall[comp][j], comp^joinstat, outerwall[!comp][j]);
|
|
|
|
|
2011-05-23 22:42:39 +00:00
|
|
|
// sectors
|
|
|
|
for (k=0; k<collnumsects[comp]; k++)
|
|
|
|
{
|
|
|
|
i = collsectlist[comp][k];
|
|
|
|
yax_setbunch(i, comp^joinstat, numyaxbunches);
|
|
|
|
SECTORFLD(i,stat, comp^joinstat) &= ~1; // no plax
|
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
// restore red walls AFTER setting nextwalls
|
|
|
|
// (see checksectorpointer() for why)
|
2011-05-23 22:42:39 +00:00
|
|
|
for (WALLS_OF_SECTOR(i, j))
|
|
|
|
if (wall[j].nextwall < 0)
|
|
|
|
checksectorpointer(j, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-20 21:27:42 +00:00
|
|
|
reset_highlightsector();
|
2011-05-23 22:42:39 +00:00
|
|
|
|
|
|
|
yax_update(0);
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
|
|
|
|
message("Joined highlighted sectors to new bunch %d", numyaxbunches);
|
|
|
|
asksave = 1;
|
2011-05-22 21:52:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif // defined YAX_ENABLE
|
2011-02-24 20:40:27 +00:00
|
|
|
if (joinsector[0] < 0)
|
|
|
|
{
|
2011-10-30 19:48:29 +00:00
|
|
|
int32_t numjoincandidates = 0;
|
|
|
|
char *origframe=NULL;
|
|
|
|
|
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
{
|
|
|
|
YAX_SKIPSECTOR(i);
|
|
|
|
numjoincandidates += (inside_editor_curpos(i) == 1);
|
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2011-05-02 16:58:11 +00:00
|
|
|
{
|
|
|
|
YAX_SKIPSECTOR(i);
|
2011-04-22 22:48:06 +00:00
|
|
|
if (inside_editor_curpos(i) == 1)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
2011-10-30 19:48:29 +00:00
|
|
|
if (numjoincandidates > 1)
|
|
|
|
{
|
|
|
|
if (!bakframe_fillandfade(&origframe, i, "Use this as first joining sector? (Y/N)"))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
joinsector[0] = i;
|
|
|
|
printmessage16("Join sector - press J again on sector to join with.");
|
|
|
|
break;
|
|
|
|
}
|
2011-05-02 16:58:11 +00:00
|
|
|
}
|
2011-10-30 19:48:29 +00:00
|
|
|
|
2015-09-23 17:55:31 +00:00
|
|
|
Bfree(origframe);
|
2011-02-24 20:40:27 +00:00
|
|
|
}
|
|
|
|
else
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-10-30 19:48:29 +00:00
|
|
|
char *origframe = NULL;
|
|
|
|
int32_t numjoincandidates = 0;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
joinsector[1] = -1;
|
2008-10-31 10:08:51 +00:00
|
|
|
|
2011-10-30 19:48:29 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
{
|
|
|
|
YAX_SKIPSECTOR(i);
|
|
|
|
numjoincandidates += (inside_editor_curpos(i) == 1);
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2008-10-31 10:08:51 +00:00
|
|
|
{
|
2011-05-02 16:58:11 +00:00
|
|
|
YAX_SKIPSECTOR(i);
|
|
|
|
|
2011-04-22 22:48:06 +00:00
|
|
|
if (inside_editor_curpos(i) == 1)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-10-30 19:48:29 +00:00
|
|
|
if (numjoincandidates > 1)
|
|
|
|
{
|
|
|
|
if (!bakframe_fillandfade(&origframe, i, "Use this as second joining sector? (Y/N)"))
|
|
|
|
continue;
|
2011-11-25 09:52:08 +00:00
|
|
|
|
2015-09-23 17:55:31 +00:00
|
|
|
DO_FREE_AND_NULL(origframe);
|
2011-10-30 19:48:29 +00:00
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
joinsector[1] = i;
|
2015-02-08 18:48:30 +00:00
|
|
|
|
|
|
|
const int s1to0wall = find_nextwall(i, joinsector[0]);
|
|
|
|
const int s0to1wall = s1to0wall == -1 ? -1 : wall[s1to0wall].nextwall;
|
2011-03-23 17:41:01 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2015-02-08 18:48:30 +00:00
|
|
|
int16_t jbn[2][2]; // [join index][c/f]
|
|
|
|
|
2011-07-09 17:36:02 +00:00
|
|
|
for (k=0; k<2; k++)
|
|
|
|
yax_getbunches(joinsector[k], &jbn[k][YAX_CEILING], &jbn[k][YAX_FLOOR]);
|
2011-03-23 17:41:01 +00:00
|
|
|
#endif
|
2011-02-24 20:40:27 +00:00
|
|
|
// pressing J into the same sector is the same as saying 'no'
|
2011-07-13 16:42:29 +00:00
|
|
|
// v----------------v
|
2011-07-09 17:36:02 +00:00
|
|
|
if (s1to0wall == -1 && i != joinsector[0])
|
2008-10-31 10:08:51 +00:00
|
|
|
{
|
2012-06-13 23:13:15 +00:00
|
|
|
int32_t good = 1;
|
2011-03-23 17:41:01 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2011-07-09 17:36:02 +00:00
|
|
|
if (jbn[0][0]>=0 || jbn[0][1]>=0 || jbn[1][0]>=0 || jbn[1][1]>=0)
|
2011-03-23 17:41:01 +00:00
|
|
|
{
|
2011-05-02 16:58:11 +00:00
|
|
|
message("Joining non-adjacent extended sectors not allowed!");
|
2012-06-13 23:13:15 +00:00
|
|
|
good = 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (!m32_script_expertmode)
|
|
|
|
{
|
|
|
|
message("Joining non-adjacent disabled in non-expert mode");
|
|
|
|
good = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!good)
|
|
|
|
{
|
2011-03-23 17:41:01 +00:00
|
|
|
joinsector[0] = joinsector[1] = -1;
|
|
|
|
goto end_join_sectors;
|
|
|
|
}
|
2012-06-13 23:13:15 +00:00
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
{
|
2015-10-31 15:13:32 +00:00
|
|
|
fillsector_notrans(i, editorcolors[9]);
|
|
|
|
fillsector_notrans(joinsector[0], editorcolors[9]);
|
2011-05-02 16:58:11 +00:00
|
|
|
fade_editor_screen(editorcolors[9]);
|
2008-10-31 10:08:51 +00:00
|
|
|
|
2012-06-13 23:13:15 +00:00
|
|
|
if (!ask_if_sure("Really join non-adjacent sectors? (Y/N)", 0))
|
2011-03-23 17:41:01 +00:00
|
|
|
joinsector[1] = joinsector[0];
|
|
|
|
}
|
2008-10-31 10:08:51 +00:00
|
|
|
}
|
2011-03-23 17:41:01 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2015-02-08 18:48:30 +00:00
|
|
|
// unequal bunchnums (bitmap): 1:above, 2:below
|
|
|
|
int uneqbn =
|
|
|
|
(jbn[0][YAX_CEILING] != jbn[1][YAX_CEILING]) |
|
|
|
|
((jbn[0][YAX_FLOOR] != jbn[1][YAX_FLOOR])<<1);
|
|
|
|
|
2011-07-09 17:36:02 +00:00
|
|
|
if (uneqbn)
|
2011-03-23 17:41:01 +00:00
|
|
|
{
|
2011-07-09 17:36:02 +00:00
|
|
|
const int32_t cf=YAX_FLOOR;
|
2015-02-08 18:48:30 +00:00
|
|
|
int32_t whybad=0;
|
2011-07-09 17:36:02 +00:00
|
|
|
|
|
|
|
if (uneqbn == 1)
|
|
|
|
{
|
2011-09-15 17:02:35 +00:00
|
|
|
OSD_Printf("Can't join two sectors with different ceiling bunchnums."
|
2012-11-03 19:32:32 +00:00
|
|
|
" To make them equal, join their upper neighbor's floors.\n");
|
2011-07-09 17:36:02 +00:00
|
|
|
printmessage16("Can't join two sectors with different ceiling bunchnums. See OSD");
|
|
|
|
joinsector[0] = joinsector[1] = -1;
|
|
|
|
goto end_join_sectors;
|
|
|
|
}
|
2011-09-15 17:02:35 +00:00
|
|
|
if (s0to1wall < 0)
|
|
|
|
{
|
|
|
|
printmessage16("INTERNAL ERROR: nextwalls inconsistent!");
|
|
|
|
joinsector[0] = joinsector[1] = -1;
|
|
|
|
goto end_join_sectors;
|
|
|
|
}
|
2011-07-09 17:36:02 +00:00
|
|
|
|
|
|
|
// both must be extended
|
|
|
|
if (jbn[0][cf]<0 || jbn[1][cf]<0)
|
|
|
|
uneqbn &= ~(1<<cf), whybad|=1;
|
|
|
|
// if any sloped, can't join
|
|
|
|
if ((SECTORFLD(joinsector[0],stat, cf)&2) || (SECTORFLD(joinsector[1],stat, cf)&2))
|
|
|
|
uneqbn &= ~(1<<cf), whybad|=2;
|
|
|
|
// if on unequal heights, can't join either
|
|
|
|
if (SECTORFLD(joinsector[0],z, cf) != SECTORFLD(joinsector[1],z, cf))
|
|
|
|
uneqbn &= ~(1<<cf), whybad|=4;
|
|
|
|
|
|
|
|
// check whether the lower neighbors have a red-wall link to each other
|
2015-02-08 18:48:30 +00:00
|
|
|
const int jsynw[2] = {
|
|
|
|
yax_getnextwall(s0to1wall, cf),
|
|
|
|
yax_getnextwall(s1to0wall, cf)
|
|
|
|
};
|
|
|
|
|
2011-07-09 17:36:02 +00:00
|
|
|
if (jsynw[0]<0 || jsynw[1]<0) // this shouldn't happen
|
2015-02-08 18:48:30 +00:00
|
|
|
{
|
2011-07-09 17:36:02 +00:00
|
|
|
uneqbn &= ~(1<<cf), whybad|=8;
|
2015-02-08 18:48:30 +00:00
|
|
|
}
|
2011-07-09 17:36:02 +00:00
|
|
|
else if (wall[jsynw[1]].nextwall != jsynw[0])
|
|
|
|
{
|
2011-09-15 17:02:35 +00:00
|
|
|
// if (find_nextwall(sectorofwall(jsynw[1]), sectorofwall(jsynw[0])) < 0)
|
2011-07-09 17:36:02 +00:00
|
|
|
uneqbn &= ~(1<<cf), whybad|=16;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((uneqbn&2)==0)
|
|
|
|
{
|
2011-10-30 19:48:29 +00:00
|
|
|
#if 0
|
|
|
|
if (whybad==1+8 && jbn[0][cf]>=0 && jbn[1][cf]<0)
|
2011-07-13 16:42:29 +00:00
|
|
|
{
|
|
|
|
// 1st join sector extended, 2nd not... let's see
|
|
|
|
// if the latter is inner to the former one
|
|
|
|
|
2011-09-15 17:02:35 +00:00
|
|
|
int32_t lowerstartsec = yax_vnextsec(s0to1wall, cf);
|
|
|
|
|
|
|
|
m = (lowerstartsec < 0)<<1;
|
2011-07-13 16:42:29 +00:00
|
|
|
for (WALLS_OF_SECTOR(joinsector[1], k))
|
2011-09-15 17:02:35 +00:00
|
|
|
{
|
|
|
|
if (m) break;
|
|
|
|
|
|
|
|
m |= (wall[k].nextsector>=0 && wall[k].nextsector != joinsector[0]);
|
|
|
|
m |= (wall[k].nextwall>=0 && yax_vnextsec(wall[k].nextwall, cf)!=lowerstartsec)<<1;
|
|
|
|
}
|
2011-07-13 16:42:29 +00:00
|
|
|
|
2011-09-15 17:02:35 +00:00
|
|
|
if (m==0)
|
2011-07-13 16:42:29 +00:00
|
|
|
{
|
|
|
|
yax_setbunch(joinsector[1], YAX_FLOOR, jbn[0][cf]);
|
|
|
|
yax_update(0);
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
asksave = 1;
|
|
|
|
|
|
|
|
printmessage16("Added sector %d's floor to bunch %d",
|
|
|
|
joinsector[1], jbn[0][cf]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-15 17:02:35 +00:00
|
|
|
if (m&1)
|
|
|
|
{
|
|
|
|
message("Can't add sector %d's floor to bunch %d: not inner to sector %d",
|
|
|
|
joinsector[1], jbn[0][cf], joinsector[0]);
|
|
|
|
}
|
|
|
|
else // if (m&2)
|
|
|
|
{
|
|
|
|
message("Can't add sector %d's floor to bunch %d: must have lower neighbor",
|
|
|
|
joinsector[1], jbn[0][cf]);
|
|
|
|
}
|
2011-07-13 16:42:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-10-30 19:48:29 +00:00
|
|
|
#endif
|
2011-07-13 16:42:29 +00:00
|
|
|
{
|
|
|
|
if (whybad&1)
|
|
|
|
message("Can't make floor bunchnums equal: both floors must be extended");
|
|
|
|
else if (whybad&2)
|
|
|
|
message("Can't make floor bunchnums equal: both floors must be non-sloped");
|
|
|
|
else if (whybad&4)
|
|
|
|
message("Can't make floor bunchnums equal: both floors must have equal height");
|
|
|
|
else if (whybad&8)
|
|
|
|
message("Can't make floor bunchnums equal: INTERNAL ERROR");
|
|
|
|
else if (whybad&16)
|
|
|
|
message("Can't make floor bunchnums equal: lower neighbors must be linked");
|
|
|
|
}
|
2011-07-09 17:36:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int32_t vcf, newbn, ynw;
|
|
|
|
|
|
|
|
// we're good to go for making floor bunchnums equal
|
|
|
|
for (SECTORS_OF_BUNCH(jbn[1][cf], YAX_FLOOR, k))
|
|
|
|
yax_setbunch(k, YAX_FLOOR, jbn[0][cf]);
|
|
|
|
for (SECTORS_OF_BUNCH(jbn[1][cf], YAX_CEILING, k))
|
|
|
|
yax_setbunch(k, YAX_CEILING, jbn[0][cf]);
|
|
|
|
|
|
|
|
yax_update(0);
|
|
|
|
// now we can iterate the sectors with the new bunchnums
|
|
|
|
newbn = yax_getbunch(joinsector[0], cf);
|
|
|
|
|
|
|
|
// clear all yax-nextwall links on walls that are inside the bunch
|
|
|
|
for (vcf=0; vcf<2; vcf++)
|
|
|
|
for (SECTORS_OF_BUNCH(newbn, vcf, k))
|
|
|
|
for (WALLS_OF_SECTOR(k, m))
|
|
|
|
{
|
|
|
|
ynw = yax_getnextwall(m, vcf);
|
|
|
|
if (ynw < 0 || wall[m].nextsector < 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (yax_getbunch(wall[m].nextsector, vcf) == newbn)
|
|
|
|
{
|
|
|
|
yax_setnextwall(ynw, !vcf, -1);
|
|
|
|
yax_setnextwall(m, vcf, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// shouldn't be needed again for the editor, but can't harm either:
|
|
|
|
yax_update(0);
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
|
|
|
|
printmessage16("Made sector %d and %d floor bunchnums equal",
|
|
|
|
joinsector[0], joinsector[1]);
|
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
joinsector[0] = joinsector[1] = -1;
|
2011-10-30 19:48:29 +00:00
|
|
|
goto end_join_sectors;
|
2011-03-23 17:41:01 +00:00
|
|
|
}
|
|
|
|
#endif
|
2011-02-24 20:40:27 +00:00
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2008-10-31 10:08:51 +00:00
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if (joinsector[1] < 0 || joinsector[0] == joinsector[1])
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
printmessage16("No sectors joined.");
|
|
|
|
joinsector[0] = -1;
|
|
|
|
goto end_join_sectors;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
wall[i].cstat &= ~(1<<14);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
newnumwalls = numwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
for (k=0; k<2; k++)
|
|
|
|
{
|
|
|
|
for (WALLS_OF_SECTOR(joinsector[k], j))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
int32_t loopnum=MAXWALLS*2;
|
|
|
|
|
|
|
|
if (wall[j].cstat & (1<<14))
|
|
|
|
continue;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if (wall[j].nextsector == joinsector[1-k])
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
wall[j].cstat |= (1<<14);
|
|
|
|
continue;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
i = j;
|
|
|
|
m = newnumwalls;
|
2015-02-08 18:48:30 +00:00
|
|
|
int joink = k;
|
2011-02-24 20:40:27 +00:00
|
|
|
do
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
if (newnumwalls >= MAXWALLS + M32_FIXME_WALLS)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-02-27 19:13:44 +00:00
|
|
|
message("Joining sectors failed: not enough space beyond wall[]");
|
|
|
|
joinsector[0] = -1;
|
2011-02-24 20:40:27 +00:00
|
|
|
newnumwalls = -1;
|
|
|
|
|
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
wall[i].cstat &= ~(1<<14);
|
|
|
|
|
|
|
|
goto end_join_sectors;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
Bmemcpy(&wall[newnumwalls], &wall[i], sizeof(walltype));
|
2011-05-02 16:58:11 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_fixreverselinks(newnumwalls, newnumwalls);
|
|
|
|
#endif
|
2011-02-24 20:40:27 +00:00
|
|
|
wall[newnumwalls].point2 = newnumwalls+1;
|
|
|
|
newnumwalls++;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
wall[i].cstat |= (1<<14);
|
|
|
|
|
|
|
|
i = wall[i].point2;
|
|
|
|
if (wall[i].nextsector == joinsector[1-joink])
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
i = NEXTWALL(i).point2;
|
|
|
|
joink = 1 - joink;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
|
|
|
|
loopnum--;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
while (loopnum>0 && ((wall[i].cstat & (1<<14))==0)
|
|
|
|
&& (wall[i].nextsector != joinsector[1-joink]));
|
|
|
|
|
|
|
|
wall[newnumwalls-1].point2 = m;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if (loopnum==0)
|
|
|
|
{
|
2011-05-02 16:58:11 +00:00
|
|
|
message("internal error while joining sectors: infloop!");
|
2011-02-24 20:40:27 +00:00
|
|
|
newnumwalls = -1;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if (newnumwalls > numwalls)
|
|
|
|
{
|
|
|
|
Bmemcpy(§or[numsectors], §or[joinsector[0]], sizeof(sectortype));
|
|
|
|
sector[numsectors].wallptr = numwalls;
|
|
|
|
sector[numsectors].wallnum = newnumwalls-numwalls;
|
|
|
|
|
|
|
|
//fix sprites
|
|
|
|
for (i=0; i<2; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
j = headspritesect[joinsector[i]];
|
|
|
|
while (j != -1)
|
|
|
|
{
|
|
|
|
k = nextspritesect[j];
|
|
|
|
changespritesect(j, numsectors);
|
|
|
|
j = k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
numsectors++;
|
|
|
|
|
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
|
|
|
{
|
|
|
|
if (wall[i].nextwall >= 0)
|
|
|
|
{
|
|
|
|
NEXTWALL(i).nextwall = i;
|
|
|
|
NEXTWALL(i).nextsector = numsectors-1;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
|
|
|
|
numwalls = newnumwalls;
|
|
|
|
newnumwalls = -1;
|
|
|
|
|
2011-07-09 17:36:02 +00:00
|
|
|
// clean out nextwall links for deletesector
|
2011-02-24 20:40:27 +00:00
|
|
|
for (k=0; k<2; k++)
|
|
|
|
for (WALLS_OF_SECTOR(joinsector[k], j))
|
2011-07-09 17:36:02 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
wall[j].nextwall = wall[j].nextsector = -1;
|
2011-07-09 17:36:02 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_setnextwall(j, YAX_CEILING, -1);
|
|
|
|
yax_setnextwall(j, YAX_FLOOR, -1);
|
|
|
|
#endif
|
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
|
|
|
|
deletesector(joinsector[0]);
|
|
|
|
if (joinsector[0] < joinsector[1])
|
|
|
|
joinsector[1]--;
|
|
|
|
deletesector(joinsector[1]);
|
|
|
|
|
|
|
|
printmessage16("Sectors joined.");
|
2011-05-15 22:37:24 +00:00
|
|
|
mkonwinvalid();
|
2011-03-02 21:21:47 +00:00
|
|
|
asksave = 1;
|
2011-04-22 22:48:06 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_update(0);
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
#endif
|
2011-02-24 20:40:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
joinsector[0] = -1;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-25 09:52:08 +00:00
|
|
|
end_join_sectors:
|
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;
|
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (eitherALT && keystatus[0x1f]) //ALT-S
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
keystatus[0x1f] = 0;
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (linehighlight >= 0 && wall[linehighlight].nextwall == -1)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-13 11:59:32 +00:00
|
|
|
newnumwalls = whitelinescan(sectorofwall(linehighlight), linehighlight);
|
2011-02-24 20:40:27 +00:00
|
|
|
if (newnumwalls < numwalls)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
printmessage16("Can't make a sector out there.");
|
2011-02-24 20:40:27 +00:00
|
|
|
newnumwalls = -1;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-05-28 23:08:32 +00:00
|
|
|
else if (newnumwalls > MAXWALLS)
|
|
|
|
{
|
|
|
|
printmessage16("Making new sector from inner loop would exceed wall limits.");
|
|
|
|
newnumwalls = -1;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
else
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
NEXTWALL(i).nextwall = i;
|
|
|
|
NEXTWALL(i).nextsector = numsectors;
|
2011-09-12 15:03:51 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_setnextwall(i, YAX_CEILING, -1);
|
|
|
|
yax_setnextwall(i, YAX_FLOOR, -1);
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-05-07 18:23:34 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_setbunches(numsectors, -1, -1);
|
|
|
|
yax_update(0);
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
numwalls = newnumwalls;
|
|
|
|
newnumwalls = -1;
|
|
|
|
numsectors++;
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2011-09-12 15:03:51 +00:00
|
|
|
asksave = 1;
|
2006-04-24 19:04:22 +00:00
|
|
|
printmessage16("Inner loop made into new sector.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-05-16 00:23:33 +00:00
|
|
|
else if (keystatus[0x1f]) //S
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-10-30 19:47:26 +00:00
|
|
|
int16_t sucksect = -1;
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
keystatus[0x1f] = 0;
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2011-05-02 16:58:11 +00:00
|
|
|
{
|
|
|
|
YAX_SKIPSECTOR(i);
|
2011-04-22 22:48:06 +00:00
|
|
|
if (inside_editor_curpos(i) == 1)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
sucksect = i;
|
|
|
|
break;
|
|
|
|
}
|
2011-05-02 16:58:11 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if (sucksect >= 0)
|
|
|
|
{
|
|
|
|
dax = mousxplc;
|
|
|
|
day = mousyplc;
|
2010-05-18 05:14:17 +00:00
|
|
|
if (gridlock && grid > 0)
|
|
|
|
locktogrid(&dax, &day);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
i = insert_sprite_common(sucksect, dax, day);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if (i < 0)
|
|
|
|
printmessage16("Couldn't insert sprite.");
|
2006-04-24 19:04:22 +00:00
|
|
|
else
|
2008-05-16 20:15:43 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
sprite[i].z = getflorzofslope(sucksect,dax,day);
|
|
|
|
// PK
|
|
|
|
if (prefixarg)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
sprite[i].picnum = prefixarg;
|
|
|
|
sprite[i].xrepeat = sprite[i].yrepeat = 48;
|
|
|
|
prefixarg = 0;
|
|
|
|
}
|
2012-05-26 21:58:26 +00:00
|
|
|
else handle_sprite_in_clipboard(i);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2014-09-30 04:14:21 +00:00
|
|
|
if (tilesiz[sprite[i].picnum].y >= 32)
|
2011-02-24 20:40:27 +00:00
|
|
|
sprite[i].cstat |= 1;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-07 16:30:06 +00:00
|
|
|
correct_sprite_yoffset(i);
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
printmessage16("Sprite inserted.");
|
2012-03-14 22:30:24 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
asksave = 1;
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
VM_OnEvent(EVENT_INSERTSPRITE2D, i);
|
|
|
|
}
|
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
|
|
|
{
|
2011-05-15 22:37:24 +00:00
|
|
|
if (highlightsectorcnt > 0)
|
2010-08-26 13:50:09 +00:00
|
|
|
duplicate_selected_sectors();
|
2011-05-15 22:37:24 +00:00
|
|
|
else if (highlightcnt > 0)
|
2010-08-26 13:50:09 +00:00
|
|
|
duplicate_selected_sprites();
|
2006-04-24 19:04:22 +00:00
|
|
|
else if (circlewall >= 0)
|
|
|
|
{
|
|
|
|
circlewall = -1;
|
|
|
|
}
|
2011-11-25 09:50:07 +00:00
|
|
|
else if (!m32_sideview)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (linehighlight >= 0)
|
2011-03-23 17:41:01 +00:00
|
|
|
{
|
2013-01-05 13:09:34 +00:00
|
|
|
#if 0 //def YAX_ENABLE
|
2011-10-30 19:48:13 +00:00
|
|
|
j = linehighlight;
|
|
|
|
|
|
|
|
if (yax_islockedwall(j) ||
|
|
|
|
(wall[j].nextwall >= 0 && yax_islockedwall(wall[j].nextwall)))
|
2011-03-23 17:41:01 +00:00
|
|
|
printmessage16("Can't make circle in wall constrained by sector extension.");
|
|
|
|
else
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
circlewall = linehighlight;
|
2011-03-23 17:41:01 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-11-25 09:50:07 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
keystatus[0x2e] = 0;
|
|
|
|
}
|
|
|
|
|
2015-07-08 03:34:31 +00:00
|
|
|
bad = keystatus[0x39] && (!m32_sideview || m32_sideelev == 512); //Gotta do this to save lots of 3 spaces!
|
|
|
|
|
|
|
|
if (keystatus[0x39] && !bad)
|
|
|
|
message("Unable to create sectors in angled sideview mode.");
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if (circlewall >= 0)
|
|
|
|
{
|
2011-10-30 19:47:26 +00:00
|
|
|
int32_t tempint1, tempint2;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
x1 = wall[circlewall].x;
|
|
|
|
y1 = wall[circlewall].y;
|
2010-05-18 05:14:17 +00:00
|
|
|
x2 = POINT2(circlewall).x;
|
|
|
|
y2 = POINT2(circlewall).y;
|
2006-04-24 19:04:22 +00:00
|
|
|
x3 = mousxplc;
|
|
|
|
y3 = mousyplc;
|
|
|
|
adjustmark(&x3,&y3,newnumwalls);
|
2010-05-18 05:14:17 +00:00
|
|
|
tempint1 = dmulscale4(x3-x2,x1-x3, y1-y3,y3-y2);
|
|
|
|
tempint2 = dmulscale4(y1-y2,x1-x3, y1-y3,x2-x1);
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (tempint2 != 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2013-01-05 13:09:34 +00:00
|
|
|
int32_t goodtogo, err=0;
|
2008-09-01 07:15:16 +00:00
|
|
|
|
2013-01-05 13:09:34 +00:00
|
|
|
const int32_t centerx = ((x1+x2) + scale(y1-y2,tempint1,tempint2))>>1;
|
|
|
|
const int32_t centery = ((y1+y2) + scale(x2-x1,tempint1,tempint2))>>1;
|
|
|
|
const int32_t circlerad = ksqrt(dmulscale4(centerx-x1,centerx-x1, centery-y1,centery-y1))<<2;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2013-01-05 13:09:34 +00:00
|
|
|
const int32_t circleang1 = getangle(x1-centerx,y1-centery);
|
|
|
|
const int32_t circleang2 = getangle(x2-centerx,y2-centery);
|
|
|
|
|
|
|
|
const int32_t redw = (int32_t)(wall[circlewall].nextwall >= 0);
|
|
|
|
int32_t insdpoints = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2013-01-05 13:09:34 +00:00
|
|
|
draw_cross(centerx, centery, 2, editorcolors[14]);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
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
|
|
|
k = -((circleang1-circleang2)&2047);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 13:09:34 +00:00
|
|
|
// XXX: Still too permissive for TROR insertion
|
|
|
|
goodtogo = (numwalls+(1+redw)*circlepoints <= MAXWALLS);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-10-30 19:47:58 +00:00
|
|
|
if (bad > 0 && goodtogo)
|
|
|
|
{
|
|
|
|
err = backup_drawn_walls(0);
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
{
|
|
|
|
message("Error backing up drawn walls (code %d)!", err);
|
|
|
|
goodtogo = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=circlepoints; i>0; i--)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2013-01-05 13:09:34 +00:00
|
|
|
const int32_t ps = 2;
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
j = (circleang1 + scale(i,k,circlepoints+1))&2047;
|
|
|
|
dax = centerx + mulscale14(sintable[(j+512)&2047],circlerad);
|
|
|
|
day = centery + mulscale14(sintable[j],circlerad);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
inpclamp(&dax, -editorgridextent, editorgridextent);
|
|
|
|
inpclamp(&day, -editorgridextent, editorgridextent);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-05-28 23:08:32 +00:00
|
|
|
if (bad > 0 && goodtogo)
|
2013-01-05 13:09:34 +00:00
|
|
|
{
|
|
|
|
int32_t inspts = M32_InsertPoint(circlewall, dax,day, -1, &circlewall);
|
|
|
|
|
|
|
|
if (inspts==0)
|
|
|
|
{
|
|
|
|
message("Wall limit exceeded while inserting points.");
|
|
|
|
goto end_circle_insertion;
|
|
|
|
}
|
|
|
|
else if (inspts >= 65536)
|
|
|
|
{
|
|
|
|
message("ERR: Inserted %d points for constr. wall (exp. %d; %d already ins'd)",
|
|
|
|
inspts&65535, inspts>>16, insdpoints);
|
|
|
|
goto end_circle_insertion;
|
|
|
|
}
|
|
|
|
|
|
|
|
insdpoints += inspts;
|
|
|
|
}
|
2010-05-28 23:08:32 +00:00
|
|
|
|
2012-11-04 23:03:22 +00:00
|
|
|
draw_square(dax, day, ps, editorcolors[14]);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2010-05-28 23:08:32 +00:00
|
|
|
|
2011-10-30 19:47:58 +00:00
|
|
|
if (bad > 0 && goodtogo)
|
|
|
|
backup_drawn_walls(1);
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (bad > 0)
|
|
|
|
{
|
2010-05-28 23:08:32 +00:00
|
|
|
if (goodtogo)
|
|
|
|
{
|
|
|
|
asksave = 1;
|
|
|
|
printmessage16("Circle points inserted.");
|
2013-01-05 13:09:34 +00:00
|
|
|
end_circle_insertion:
|
2010-05-28 23:08:32 +00:00
|
|
|
circlewall = -1;
|
2011-05-15 22:37:24 +00:00
|
|
|
mkonwinvalid();
|
2010-05-28 23:08:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
printmessage16("Inserting circle points would exceed wall limit.");
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-25 09:50:21 +00:00
|
|
|
|
|
|
|
bad = 0;
|
|
|
|
keystatus[0x39] = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bad > 0) //Space bar test
|
|
|
|
{
|
|
|
|
keystatus[0x39] = 0;
|
|
|
|
adjustmark(&mousxplc,&mousyplc,newnumwalls);
|
2010-05-28 23:08:32 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (checkautoinsert(mousxplc,mousyplc,newnumwalls) == 1)
|
|
|
|
{
|
|
|
|
printmessage16("You must insert a point there first.");
|
|
|
|
bad = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-27 19:13:44 +00:00
|
|
|
if (bad > 0) //Space
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-28 23:08:32 +00:00
|
|
|
if (newnumwalls < numwalls) // starting wall drawing
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
if (numwalls >= MAXWALLS-1)
|
|
|
|
{
|
|
|
|
// whatever we do, we will need at least two new walls
|
|
|
|
printmessage16("Can't start sector drawing: wall limit reached.");
|
|
|
|
goto end_space_handling;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numsectors >= MAXSECTORS)
|
|
|
|
{
|
|
|
|
printmessage16("Can't start sector drawing: sector limit reached.");
|
|
|
|
goto end_space_handling;
|
|
|
|
}
|
|
|
|
|
2010-05-28 23:08:32 +00:00
|
|
|
firstx = mousxplc;
|
|
|
|
firsty = mousyplc; //Make first point
|
2006-04-24 19:04:22 +00:00
|
|
|
newnumwalls = numwalls;
|
2011-10-30 19:47:42 +00:00
|
|
|
ovh.suckwall = -1;
|
|
|
|
ovh.split = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-10-30 19:47:42 +00:00
|
|
|
init_new_wall1(&ovh.suckwall, mousxplc, mousyplc);
|
2011-02-24 20:40:27 +00:00
|
|
|
|
|
|
|
printmessage16("Sector drawing started.");
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
else // 2nd point and up...
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
//if not back to first point
|
2010-05-28 23:08:32 +00:00
|
|
|
if (firstx != mousxplc || firsty != mousyplc) //nextpoint
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
if (newnumwalls>=MAXWALLS)
|
|
|
|
{
|
|
|
|
printmessage16("Inserting another point would exceed wall limit.");
|
|
|
|
goto end_space_handling;
|
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
j = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
2010-05-28 23:08:32 +00:00
|
|
|
if (mousxplc == wall[i].x && mousyplc == wall[i].y)
|
2006-04-24 19:04:22 +00:00
|
|
|
j = 1;
|
2010-05-28 23:08:32 +00:00
|
|
|
|
|
|
|
if (j == 0) // if new point is not on a position of already drawn points
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
// on the second point insertion, check if starting to split a sector
|
2006-04-24 19:04:22 +00:00
|
|
|
if (newnumwalls == numwalls+1)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +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++)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
2011-04-22 22:48:06 +00:00
|
|
|
YAX_SKIPSECTOR(i);
|
2011-02-24 20:40:27 +00:00
|
|
|
if (inside(dax,day,i) != 1)
|
|
|
|
continue;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
//check if first point at point of sector
|
|
|
|
m = -1;
|
|
|
|
for (WALLS_OF_SECTOR(i, k))
|
|
|
|
if (wall[k].x==wall[numwalls].x && wall[k].y==wall[numwalls].y)
|
|
|
|
{
|
2011-04-22 22:48:06 +00:00
|
|
|
YAX_SKIPWALL(k);
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
m = k;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if the second insertion is not on a neighboring point of the first one...
|
|
|
|
if (m>=0 && (POINT2(k).x != mousxplc || POINT2(k).y != mousyplc))
|
|
|
|
if (wall[lastwall(k)].x != mousxplc || wall[lastwall(k)].y != mousyplc)
|
|
|
|
{
|
2011-10-30 19:47:42 +00:00
|
|
|
ovh.split = 1;
|
|
|
|
ovh.splitsect = i;
|
|
|
|
ovh.splitstartwall = m;
|
2011-02-24 20:40:27 +00:00
|
|
|
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
|
|
|
{
|
2011-04-22 22:48:06 +00:00
|
|
|
YAX_SKIPWALL(i);
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[i].nextwall >= 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
int32_t lastwalx = wall[newnumwalls-1].x;
|
|
|
|
int32_t lastwaly = wall[newnumwalls-1].y;
|
|
|
|
|
2011-04-22 22:48:06 +00:00
|
|
|
YAX_SKIPWALL(wall[i].nextwall);
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (wall[i].x == mousxplc && wall[i].y == mousyplc)
|
2011-02-24 20:40:27 +00:00
|
|
|
if (POINT2(i).x == lastwalx && POINT2(i).y == lastwaly)
|
2006-04-24 19:04:22 +00:00
|
|
|
bad = 1;
|
2011-02-24 20:40:27 +00:00
|
|
|
if (wall[i].x == lastwalx && wall[i].y == lastwaly)
|
2010-05-18 05:14:17 +00:00
|
|
|
if (POINT2(i).x == mousxplc && POINT2(i).y == mousyplc)
|
2006-04-24 19:04:22 +00:00
|
|
|
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
|
|
|
{
|
2011-10-30 19:47:42 +00:00
|
|
|
init_new_wall1(&ovh.suckwall, mousxplc, mousyplc);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printmessage16("You can't draw new lines over red lines.");
|
2011-02-27 19:13:44 +00:00
|
|
|
goto end_space_handling;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-27 19:13:44 +00:00
|
|
|
////////// newnumwalls is at most MAXWALLS here //////////
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//if not split and back to first point
|
2011-10-30 19:47:42 +00:00
|
|
|
if (!ovh.split && newnumwalls >= numwalls+3
|
2011-02-27 19:13:44 +00:00
|
|
|
&& firstx==mousxplc && firsty==mousyplc)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
wall[newnumwalls-1].point2 = numwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-10-30 19:47:42 +00:00
|
|
|
if (ovh.suckwall == -1) //if no connections to other sectors
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
k = -1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2011-02-27 19:13:44 +00:00
|
|
|
{
|
2011-04-22 22:48:06 +00:00
|
|
|
YAX_SKIPSECTOR(i);
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (inside(firstx,firsty,i) == 1)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
2011-02-27 19:13:44 +00:00
|
|
|
// if all points inside that one sector i,
|
|
|
|
// will add an inner loop
|
2011-02-24 20:40:27 +00:00
|
|
|
for (j=numwalls+1; j<newnumwalls; j++)
|
|
|
|
{
|
2012-10-01 17:52:13 +00:00
|
|
|
if (inside(wall[j].x, wall[j].y, i) != 1)
|
2011-02-27 19:13:44 +00:00
|
|
|
goto check_next_sector;
|
2011-02-24 20:40:27 +00:00
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
k = i;
|
2011-02-24 20:40:27 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-02-27 19:13:44 +00:00
|
|
|
check_next_sector: ;
|
|
|
|
}
|
2010-05-28 23:08:32 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (k == -1) //if not inside another sector either
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
//add island sector
|
2011-11-25 09:53:07 +00:00
|
|
|
if (clockdir(numwalls) == CLOCKDIR_CCW)
|
2006-04-24 19:04:22 +00:00
|
|
|
flipwalls(numwalls,newnumwalls);
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
Bmemset(§or[numsectors], 0, sizeof(sectortype));
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[numsectors].extra = -1;
|
|
|
|
|
|
|
|
sector[numsectors].wallptr = numwalls;
|
|
|
|
sector[numsectors].wallnum = newnumwalls-numwalls;
|
2011-03-13 11:59:32 +00:00
|
|
|
sector[numsectors].ceilingz = -(32<<8);
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[numsectors].floorz = (32<<8);
|
2010-05-28 23:08:32 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
2011-05-15 22:37:24 +00:00
|
|
|
copy_some_wall_members(i, -1, 1);
|
2011-03-13 11:59:32 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_setbunches(numsectors, -1, -1);
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
headspritesect[numsectors] = -1;
|
|
|
|
numsectors++;
|
2011-02-27 19:13:44 +00:00
|
|
|
|
2011-03-14 17:36:46 +00:00
|
|
|
numwalls = newnumwalls;
|
|
|
|
newnumwalls = -1;
|
|
|
|
|
2011-02-27 19:13:44 +00:00
|
|
|
printmessage16("Created new sector %d", numsectors-1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else //else add loop to sector
|
|
|
|
{
|
2011-11-25 09:53:07 +00:00
|
|
|
int32_t ret = AddLoopToSector(k, NULL);
|
2011-03-13 11:59:32 +00:00
|
|
|
|
2011-11-25 09:52:37 +00:00
|
|
|
if (ret < 0)
|
|
|
|
goto end_space_handling;
|
2011-03-13 11:59:32 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2011-11-25 09:52:37 +00:00
|
|
|
else if (ret > 0)
|
2011-03-13 11:59:32 +00:00
|
|
|
printmessage16("Added inner loop to sector %d and made new inner sector", k);
|
|
|
|
else
|
|
|
|
#endif
|
2011-11-25 09:52:37 +00:00
|
|
|
printmessage16("Added inner loop to sector %d", k);
|
2011-05-15 22:37:24 +00:00
|
|
|
mkonwinvalid();
|
2011-09-30 13:52:02 +00:00
|
|
|
asksave = 1;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
else // if connected to at least one other sector
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-10-30 19:47:26 +00:00
|
|
|
int16_t sucksect;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//add new sector with connections
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2011-11-25 09:53:07 +00:00
|
|
|
if (clockdir(numwalls) == CLOCKDIR_CCW)
|
2006-04-24 19:04:22 +00:00
|
|
|
flipwalls(numwalls,newnumwalls);
|
|
|
|
|
2011-05-02 16:58:11 +00:00
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
|
|
|
{
|
2011-10-30 19:47:42 +00:00
|
|
|
copy_some_wall_members(i, ovh.suckwall, 1);
|
2011-09-20 19:12:42 +00:00
|
|
|
wall[i].cstat &= ~(1+16+32+64);
|
|
|
|
|
2011-05-02 16:58:11 +00:00
|
|
|
if (checksectorpointer(i, numsectors) > 0)
|
|
|
|
{
|
|
|
|
// if new red line, prefer the other-side wall as base
|
2011-10-30 19:47:42 +00:00
|
|
|
ovh.suckwall = wall[i].nextwall;
|
2011-05-02 16:58:11 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-30 19:47:42 +00:00
|
|
|
sucksect = sectorofwall(ovh.suckwall);
|
2011-02-27 19:13:44 +00:00
|
|
|
|
|
|
|
if (numsectors != sucksect)
|
|
|
|
Bmemcpy(§or[numsectors], §or[sucksect], sizeof(sectortype));
|
|
|
|
|
|
|
|
sector[numsectors].wallptr = numwalls;
|
|
|
|
sector[numsectors].wallnum = newnumwalls-numwalls;
|
|
|
|
|
|
|
|
sector[numsectors].extra = -1;
|
|
|
|
sector[numsectors].lotag = sector[numsectors].hitag = 0;
|
|
|
|
|
2011-09-01 18:37:53 +00:00
|
|
|
setslope(numsectors, YAX_CEILING, 0);
|
|
|
|
setslope(numsectors, YAX_FLOOR, 0);
|
|
|
|
|
2011-02-27 19:13:44 +00:00
|
|
|
sector[numsectors].ceilingpal = sector[numsectors].floorpal = 0;
|
2011-03-13 11:59:32 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_setbunches(numsectors, -1, -1);
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
headspritesect[numsectors] = -1;
|
|
|
|
numsectors++;
|
2011-02-27 19:13:44 +00:00
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
numwalls = newnumwalls;
|
|
|
|
newnumwalls = -1;
|
|
|
|
|
2011-05-02 16:58:11 +00:00
|
|
|
message("Created new sector %d based on sector %d", numsectors-1, sucksect);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-05-28 23:08:32 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
asksave = 1;
|
2011-04-14 20:48:08 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_update(0);
|
2011-04-22 22:48:06 +00:00
|
|
|
yax_updategrays(pos.z);
|
2011-04-14 20:48:08 +00:00
|
|
|
#endif
|
2011-02-27 19:13:44 +00:00
|
|
|
|
|
|
|
goto end_space_handling;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-02-27 19:13:44 +00:00
|
|
|
////////// split sector //////////
|
2011-10-30 19:47:42 +00:00
|
|
|
else if (ovh.split == 1)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-02-27 19:13:44 +00:00
|
|
|
int16_t danumwalls, splitendwall, doSectorSplit;
|
|
|
|
int16_t secondstartwall=-1; // used only with splitting
|
2011-03-08 23:02:38 +00:00
|
|
|
int32_t expectedNumwalls = numwalls+2*(newnumwalls-numwalls-1), loopnum;
|
2012-11-13 10:50:13 +00:00
|
|
|
int32_t firstwallflag;
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
int16_t cb, fb;
|
|
|
|
#endif
|
2011-10-30 19:47:42 +00:00
|
|
|
startwall = sector[ovh.splitsect].wallptr;
|
|
|
|
endwall = startwall + sector[ovh.splitsect].wallnum - 1;
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2012-11-13 10:50:13 +00:00
|
|
|
firstwallflag = (startwall==ovh.splitstartwall || startwall==lastwall(ovh.splitstartwall));
|
|
|
|
|
2010-04-19 21:22:26 +00:00
|
|
|
// OSD_Printf("numwalls: %d, newnumwalls: %d\n", numwalls, newnumwalls);
|
2011-03-08 23:02:38 +00:00
|
|
|
i = -1;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=startwall; k<=endwall; k++)
|
2011-03-08 23:02:38 +00:00
|
|
|
if (wall[k].x == wall[newnumwalls-1].x && wall[k].y == wall[newnumwalls-1].y)
|
2010-05-18 05:14:17 +00:00
|
|
|
{
|
2011-03-08 23:02:38 +00:00
|
|
|
i = k;
|
2011-02-24 20:40:27 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-03-13 11:59:32 +00:00
|
|
|
// vvvv shouldn't happen, but you never know...
|
2011-10-30 19:47:42 +00:00
|
|
|
if (i==-1 || k==ovh.splitstartwall)
|
2011-03-08 23:02:38 +00:00
|
|
|
goto end_space_handling;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
splitendwall = k;
|
2011-10-30 19:47:42 +00:00
|
|
|
doSectorSplit = (loopnumofsector(ovh.splitsect,ovh.splitstartwall)
|
|
|
|
== loopnumofsector(ovh.splitsect,splitendwall));
|
2011-02-27 19:13:44 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
if (expectedNumwalls > MAXWALLS)
|
|
|
|
{
|
|
|
|
printmessage16("%s would exceed wall limit.", bad==0 ?
|
|
|
|
"Splitting sector" : "Joining sector loops");
|
|
|
|
newnumwalls--;
|
2011-11-25 09:52:52 +00:00
|
|
|
goto end_space_handling;
|
2011-03-08 23:02:38 +00:00
|
|
|
}
|
2011-11-25 09:52:52 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2012-11-13 10:50:13 +00:00
|
|
|
yax_getbunches(ovh.splitsect, &cb, &fb);
|
2011-11-25 09:52:52 +00:00
|
|
|
|
2012-11-13 10:50:13 +00:00
|
|
|
if ((cb>=0 && (sector[ovh.splitsect].ceilingstat&2))
|
|
|
|
|| (fb>=0 && (sector[ovh.splitsect].floorstat&2)))
|
|
|
|
{
|
|
|
|
printmessage16("Sloped extended sectors cannot be split.");
|
|
|
|
newnumwalls--;
|
|
|
|
goto end_space_handling;
|
2011-11-25 09:52:52 +00:00
|
|
|
}
|
|
|
|
#endif
|
2011-03-08 23:02:38 +00:00
|
|
|
////////// common code for splitting/loop joining //////////
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
newnumwalls--; //first fix up the new walls
|
|
|
|
for (i=numwalls; i<newnumwalls; i++)
|
|
|
|
{
|
2011-05-15 22:37:24 +00:00
|
|
|
copy_some_wall_members(i, startwall, 1);
|
2011-03-08 23:02:38 +00:00
|
|
|
wall[i].point2 = i+1;
|
|
|
|
}
|
2011-02-27 19:13:44 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
danumwalls = newnumwalls; //where to add more walls
|
2011-02-27 19:13:44 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
if (doSectorSplit)
|
|
|
|
{
|
|
|
|
// Copy outer loop of first sector
|
2011-10-30 19:47:42 +00:00
|
|
|
if (do_while_copyloop1(splitendwall, ovh.splitstartwall, &danumwalls, numwalls))
|
2011-03-13 11:59:32 +00:00
|
|
|
goto split_not_enough_walls;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
//Add other loops for 1st sector
|
2011-10-30 19:47:42 +00:00
|
|
|
i = loopnum = loopnumofsector(ovh.splitsect,ovh.splitstartwall);
|
2011-02-27 19:13:44 +00:00
|
|
|
|
|
|
|
for (j=startwall; j<=endwall; j++)
|
|
|
|
{
|
2011-10-30 19:47:42 +00:00
|
|
|
k = loopnumofsector(ovh.splitsect,j);
|
2011-03-08 23:02:38 +00:00
|
|
|
if (k == i)
|
2011-02-27 19:13:44 +00:00
|
|
|
continue;
|
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
if (k == loopnum)
|
2011-02-27 19:13:44 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
i = k;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
if (loopinside(wall[j].x,wall[j].y, numwalls) != 1)
|
2011-02-27 19:13:44 +00:00
|
|
|
continue;
|
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
if (do_while_copyloop1(j, j, &danumwalls, danumwalls))
|
|
|
|
goto split_not_enough_walls;
|
2011-02-27 19:13:44 +00:00
|
|
|
}
|
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
secondstartwall = danumwalls;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-13 11:59:32 +00:00
|
|
|
if (do_while_copyloop1(splitendwall, splitendwall, &danumwalls, -1))
|
|
|
|
goto split_not_enough_walls;
|
2011-03-08 23:02:38 +00:00
|
|
|
}
|
2011-02-27 19:13:44 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
//copy split points for other sector backwards
|
|
|
|
for (j=newnumwalls; j>numwalls; j--)
|
|
|
|
{
|
|
|
|
Bmemcpy(&wall[danumwalls], &wall[j], sizeof(walltype));
|
|
|
|
wall[danumwalls].nextwall = -1;
|
|
|
|
wall[danumwalls].nextsector = -1;
|
|
|
|
wall[danumwalls].point2 = danumwalls+1;
|
2011-05-02 16:58:11 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_setnextwall(danumwalls,YAX_CEILING, -1);
|
|
|
|
yax_setnextwall(danumwalls,YAX_FLOOR, -1);
|
|
|
|
#endif
|
2011-03-08 23:02:38 +00:00
|
|
|
danumwalls++;
|
|
|
|
}
|
2011-02-27 19:13:44 +00:00
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
//copy rest of loop next
|
2011-03-08 23:02:38 +00:00
|
|
|
if (doSectorSplit)
|
|
|
|
{
|
2011-10-30 19:47:42 +00:00
|
|
|
if (do_while_copyloop1(ovh.splitstartwall, splitendwall, &danumwalls, secondstartwall))
|
2011-03-13 11:59:32 +00:00
|
|
|
goto split_not_enough_walls;
|
2011-03-08 23:02:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-10-30 19:47:42 +00:00
|
|
|
if (do_while_copyloop1(ovh.splitstartwall, ovh.splitstartwall, &danumwalls, numwalls))
|
2011-03-13 11:59:32 +00:00
|
|
|
goto split_not_enough_walls;
|
2011-03-08 23:02:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Add other loops for 2nd sector
|
2011-10-30 19:47:42 +00:00
|
|
|
i = loopnum = loopnumofsector(ovh.splitsect,ovh.splitstartwall);
|
2011-03-08 23:02:38 +00:00
|
|
|
|
|
|
|
for (j=startwall; j<=endwall; j++)
|
|
|
|
{
|
2011-10-30 19:47:42 +00:00
|
|
|
k = loopnumofsector(ovh.splitsect, j);
|
2011-03-08 23:02:38 +00:00
|
|
|
if (k==i)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (doSectorSplit && k==loopnum)
|
|
|
|
continue;
|
2014-08-08 20:02:53 +00:00
|
|
|
if (!doSectorSplit && (k == loopnumofsector(ovh.splitsect,ovh.splitstartwall) ||
|
|
|
|
k == loopnumofsector(ovh.splitsect,splitendwall)))
|
2011-03-08 23:02:38 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
i = k;
|
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
// was loopinside(... , secondstartwall) != 1, but this way there are
|
|
|
|
// no duplicate or left-out loops (can happen with convoluted geometry)
|
|
|
|
if (doSectorSplit && (loopinside(wall[j].x,wall[j].y, numwalls) != 0))
|
2011-03-08 23:02:38 +00:00
|
|
|
continue;
|
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
if (do_while_copyloop1(j, j, &danumwalls, danumwalls))
|
|
|
|
goto split_not_enough_walls;
|
2011-03-08 23:02:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//fix all next pointers on old sector line
|
|
|
|
for (j=numwalls; j<danumwalls; j++)
|
|
|
|
{
|
2011-05-02 16:58:11 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2011-05-12 23:31:13 +00:00
|
|
|
// if (doSectorSplit || (j!=numwalls && j!=danumwalls-1))
|
|
|
|
yax_fixreverselinks(j, j);
|
2011-05-02 16:58:11 +00:00
|
|
|
#endif
|
2011-03-08 23:02:38 +00:00
|
|
|
if (wall[j].nextwall >= 0)
|
2011-02-27 19:13:44 +00:00
|
|
|
{
|
2011-03-08 23:02:38 +00:00
|
|
|
NEXTWALL(j).nextwall = j;
|
|
|
|
|
|
|
|
if (!doSectorSplit || j < secondstartwall)
|
|
|
|
NEXTWALL(j).nextsector = numsectors;
|
|
|
|
else
|
|
|
|
NEXTWALL(j).nextsector = numsectors+1;
|
2011-02-27 19:13:44 +00:00
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
//copy sector attributes & fix wall pointers
|
2011-10-30 19:47:42 +00:00
|
|
|
Bmemcpy(§or[numsectors], §or[ovh.splitsect], sizeof(sectortype));
|
2011-03-13 11:59:32 +00:00
|
|
|
sector[numsectors].wallptr = numwalls;
|
|
|
|
sector[numsectors].wallnum = (doSectorSplit?secondstartwall:danumwalls) - numwalls;
|
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
if (doSectorSplit)
|
|
|
|
{
|
|
|
|
//set all next pointers on split
|
|
|
|
for (j=numwalls; j<newnumwalls; j++)
|
2011-02-27 19:13:44 +00:00
|
|
|
{
|
2011-03-08 23:02:38 +00:00
|
|
|
m = secondstartwall+(newnumwalls-1-j);
|
|
|
|
wall[j].nextwall = m;
|
|
|
|
wall[j].nextsector = numsectors+1;
|
|
|
|
wall[m].nextwall = j;
|
|
|
|
wall[m].nextsector = numsectors;
|
2011-02-27 19:13:44 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-10-30 19:47:42 +00:00
|
|
|
Bmemcpy(§or[numsectors+1], §or[ovh.splitsect], sizeof(sectortype));
|
2011-03-08 23:02:38 +00:00
|
|
|
sector[numsectors+1].wallptr = secondstartwall;
|
|
|
|
sector[numsectors+1].wallnum = danumwalls-secondstartwall;
|
|
|
|
}
|
|
|
|
|
|
|
|
//fix sprites
|
2011-10-30 19:47:42 +00:00
|
|
|
j = headspritesect[ovh.splitsect];
|
2011-03-08 23:02:38 +00:00
|
|
|
while (j != -1)
|
|
|
|
{
|
|
|
|
k = nextspritesect[j];
|
|
|
|
if (!doSectorSplit || 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 += 1 + doSectorSplit;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2014-08-08 20:02:53 +00:00
|
|
|
k = danumwalls-numwalls; //Back up number of walls of new sector for later
|
2011-03-08 23:02:38 +00:00
|
|
|
numwalls = danumwalls;
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
//clear out old sector's next pointers for clean deletesector
|
|
|
|
for (j=startwall; j<=endwall; j++)
|
2011-05-23 14:22:32 +00:00
|
|
|
{
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
// same thing for yax-nextwalls (only forward links!)
|
|
|
|
yax_setnextwall(j, YAX_CEILING, -1);
|
|
|
|
yax_setnextwall(j, YAX_FLOOR, -1);
|
|
|
|
#endif
|
2011-03-08 23:02:38 +00:00
|
|
|
wall[j].nextwall = wall[j].nextsector = -1;
|
2011-05-23 14:22:32 +00:00
|
|
|
}
|
2011-10-30 19:47:42 +00:00
|
|
|
deletesector(ovh.splitsect);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
//Check pointers
|
|
|
|
for (j=numwalls-k; j<numwalls; j++)
|
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
checksectorpointer(wall[j].nextwall, wall[j].nextsector);
|
|
|
|
checksectorpointer(j, sectorofwall(j));
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
//k now safe to use as temp
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
if (numwalls==expectedNumwalls)
|
|
|
|
{
|
2012-11-13 10:50:13 +00:00
|
|
|
if (doSectorSplit && cb<0 && fb<0)
|
|
|
|
{
|
|
|
|
if (firstwallflag)
|
|
|
|
{
|
|
|
|
int32_t rhsnew1stwall = sector[numsectors-2].wallptr;
|
|
|
|
int32_t lhsotherwall = wall[rhsnew1stwall].nextwall;
|
|
|
|
|
|
|
|
Bassert(lhsotherwall >= 0);
|
|
|
|
|
|
|
|
setfirstwall(numsectors-2, lastwall(rhsnew1stwall));
|
|
|
|
setfirstwall(numsectors-1, wall[lhsotherwall].point2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
message("%s", doSectorSplit ? "Sector split." : "Loops joined.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message("%s WARNING: CREATED %d MORE WALLS THAN EXPECTED!",
|
|
|
|
doSectorSplit ? "Sector split." : "Loops joined.",
|
2011-03-13 11:59:32 +00:00
|
|
|
numwalls-expectedNumwalls);
|
2011-03-08 23:02:38 +00:00
|
|
|
// this would display 'num* out of bounds' but this corruption
|
2011-03-13 11:59:32 +00:00
|
|
|
// is almost as bad... (shouldn't happen anymore)
|
2011-03-08 23:02:38 +00:00
|
|
|
if (numcorruptthings < MAXCORRUPTTHINGS)
|
|
|
|
corruptthings[numcorruptthings++] = 0;
|
|
|
|
corruptlevel = 5;
|
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
if (0)
|
|
|
|
{
|
2011-03-13 11:59:32 +00:00
|
|
|
split_not_enough_walls:
|
2011-03-08 23:02:38 +00:00
|
|
|
message("%s failed: not enough space beyond wall[]",
|
|
|
|
doSectorSplit ? "Splitting sectors" : "Joining loops");
|
2011-02-24 20:40:27 +00:00
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
|
|
|
|
newnumwalls = -1;
|
2011-04-14 20:48:08 +00:00
|
|
|
asksave = 1;
|
2011-05-15 22:37:24 +00:00
|
|
|
|
|
|
|
mkonwinvalid();
|
2011-04-14 20:48:08 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_update(0);
|
2011-04-22 22:48:06 +00:00
|
|
|
yax_updategrays(pos.z);
|
2011-04-14 20:48:08 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
end_space_handling:
|
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;
|
2011-02-24 20:40:27 +00:00
|
|
|
if (keystatus[0x2a] && keystatus[0x1d]) // LCtrl+LShift
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-11-25 09:51:36 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (numyaxbunches == 0 ||
|
|
|
|
(fade_editor_screen(-1), ask_if_sure("Really check all wall pointers in TROR map?", 0)))
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-11-25 09:51:36 +00:00
|
|
|
printmessage16("CHECKING ALL POINTERS!");
|
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
{
|
|
|
|
startwall = sector[i].wallptr;
|
|
|
|
for (j=startwall; j<numwalls; j++)
|
|
|
|
if (startwall > wall[j].point2)
|
|
|
|
startwall = wall[j].point2;
|
|
|
|
sector[i].wallptr = startwall;
|
|
|
|
}
|
|
|
|
for (i=numsectors-2; i>=0; i--)
|
|
|
|
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
|
|
|
|
2011-11-25 09:51:36 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
|
|
|
{
|
|
|
|
wall[i].nextsector = -1;
|
|
|
|
wall[i].nextwall = -1;
|
|
|
|
}
|
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
{
|
|
|
|
for (WALLS_OF_SECTOR(i, j))
|
|
|
|
checksectorpointer(j, i);
|
|
|
|
}
|
|
|
|
printmessage16("ALL POINTERS CHECKED!");
|
|
|
|
asksave = 1;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-25 09:51:36 +00:00
|
|
|
else // NOT (LCtrl + LShift)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-11-25 09:51:53 +00:00
|
|
|
if (newnumwalls > numwalls) // batch insert points
|
|
|
|
{
|
2013-01-05 13:09:34 +00:00
|
|
|
const int32_t numdrawnwalls = newnumwalls-numwalls;
|
2011-11-25 09:51:53 +00:00
|
|
|
vec2_t *point = (vec2_t *)tempxyar; // [MAXWALLS][2]
|
|
|
|
int32_t insdpoints = 0;
|
|
|
|
|
|
|
|
// back up the points of the line strip
|
|
|
|
for (i=0; i<numdrawnwalls+1; i++)
|
|
|
|
{
|
|
|
|
point[i].x = wall[numwalls+i].x;
|
|
|
|
point[i].y = wall[numwalls+i].y;
|
|
|
|
}
|
|
|
|
|
|
|
|
newnumwalls = -1;
|
2018-04-23 10:15:12 +00:00
|
|
|
char touchedwall[(MAXWALLS+7)>>3];
|
2011-11-25 09:51:53 +00:00
|
|
|
|
|
|
|
for (i=0; i<numdrawnwalls; i++)
|
|
|
|
{
|
2018-04-23 10:15:12 +00:00
|
|
|
Bmemset(touchedwall, 0, sizeof(touchedwall));
|
|
|
|
|
2011-11-25 09:51:53 +00:00
|
|
|
for (j=numwalls-1; j>=0; j--) /* j may be modified in loop */
|
|
|
|
{
|
|
|
|
vec2_t pint;
|
|
|
|
int32_t inspts;
|
|
|
|
|
|
|
|
YAX_SKIPWALL(j);
|
|
|
|
|
2018-04-23 10:15:12 +00:00
|
|
|
if (wall[j].nextwall >= 0 && (touchedwall[wall[j].nextwall>>3] & pow2char[wall[j].nextwall&7]))
|
|
|
|
continue;
|
|
|
|
|
2011-11-25 09:51:53 +00:00
|
|
|
if (!lineintersect2v((vec2_t *)&wall[j], (vec2_t *)&POINT2(j),
|
|
|
|
&point[i], &point[i+1], &pint))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (vec2eq(&pint, (vec2_t *)&wall[j]) || vec2eq(&pint, (vec2_t *)&POINT2(j)))
|
|
|
|
continue;
|
|
|
|
|
2018-04-23 10:15:12 +00:00
|
|
|
touchedwall[j>>3] |= (1<<(j&7));
|
|
|
|
|
2011-11-25 09:51:53 +00:00
|
|
|
inspts = M32_InsertPoint(j, pint.x, pint.y, -1, &j); /* maybe modify j */
|
|
|
|
|
|
|
|
if (inspts==0)
|
|
|
|
{
|
|
|
|
printmessage16("Wall limit exceeded while inserting points.");
|
|
|
|
goto end_batch_insert_points;
|
|
|
|
}
|
2013-01-05 13:09:34 +00:00
|
|
|
else if (inspts >= 65536)
|
2011-11-25 09:51:53 +00:00
|
|
|
{
|
|
|
|
message("ERR: Inserted %d points for constr. wall (exp. %d; %d already ins'd)",
|
|
|
|
inspts&65535, inspts>>16, insdpoints);
|
|
|
|
goto end_batch_insert_points;
|
|
|
|
}
|
2013-01-05 13:09:34 +00:00
|
|
|
|
|
|
|
insdpoints += inspts;
|
2011-11-25 09:51:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
message("Batch-inserted %d points in total", insdpoints);
|
|
|
|
end_batch_insert_points:
|
|
|
|
|
|
|
|
if (insdpoints != 0)
|
|
|
|
{
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
#endif
|
2012-06-01 20:09:22 +00:00
|
|
|
mkonwinvalid_keeptempsect();
|
2011-11-25 09:51:53 +00:00
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (linehighlight >= 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
checksectorpointer(linehighlight,sectorofwall(linehighlight));
|
2011-04-14 20:48:08 +00:00
|
|
|
printmessage16("Checked pointers of highlighted line.");
|
2006-04-24 19:04:22 +00:00
|
|
|
asksave = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-04-23 10:15:17 +00:00
|
|
|
static int32_t backspace_last = 0;
|
|
|
|
|
|
|
|
if (keystatus[0x0e]) //Backspace
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2018-04-23 10:15:17 +00:00
|
|
|
keystatus[0x0e] = 0;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2018-04-23 10:15:17 +00:00
|
|
|
if (newnumwalls >= numwalls)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2018-04-23 10:15:17 +00:00
|
|
|
backspace_last = 1;
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2018-04-23 10:15:17 +00:00
|
|
|
if (newnumwalls == numwalls+1 || keystatus[0x1d]) // LCtrl: delete all newly drawn walls
|
|
|
|
newnumwalls = -1;
|
|
|
|
else
|
|
|
|
newnumwalls--;
|
|
|
|
}
|
|
|
|
else if (backspace_last==0)
|
|
|
|
{
|
|
|
|
graphicsmode += (1-2*(DOWN_BK(RUN) || keystatus[0x36]))+3;
|
|
|
|
graphicsmode %= 3;
|
|
|
|
printmessage16("2D mode textures %s",
|
|
|
|
(graphicsmode == 2)?"enabled w/ animation":graphicsmode?"enabled":"disabled");
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-23 10:15:17 +00:00
|
|
|
else
|
|
|
|
backspace_last = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-03-08 23:02:38 +00:00
|
|
|
if (keystatus[0xd3] && eitherCTRL && numwalls > 0) //sector delete
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2011-10-30 19:48:29 +00:00
|
|
|
int32_t numdelsectors = 0;
|
2011-04-22 22:48:06 +00:00
|
|
|
char *origframe=NULL;
|
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
int16_t cb, fb;
|
2011-06-26 23:29:51 +00:00
|
|
|
uint8_t bunchbitmap[YAX_MAXBUNCHES>>3];
|
2011-06-29 19:57:05 +00:00
|
|
|
Bmemset(bunchbitmap, 0, sizeof(bunchbitmap));
|
2011-03-13 11:59:32 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
keystatus[0xd3] = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
2011-04-22 22:48:06 +00:00
|
|
|
YAX_SKIPSECTOR(i);
|
|
|
|
numdelsectors += (inside_editor_curpos(i) == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
{
|
2012-11-04 23:03:22 +00:00
|
|
|
if (highlightsectorcnt <= 0 || !keystatus[0x2a]) // LShift
|
2011-05-29 23:10:51 +00:00
|
|
|
{
|
|
|
|
YAX_SKIPSECTOR(i);
|
2011-04-22 22:48:06 +00:00
|
|
|
|
2011-05-29 23:10:51 +00:00
|
|
|
if (inside_editor_curpos(i) != 1)
|
|
|
|
continue;
|
|
|
|
}
|
2011-04-22 22:48:06 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
k = 0;
|
2011-05-29 23:10:51 +00:00
|
|
|
if (highlightsectorcnt > 0)
|
2011-03-13 11:59:32 +00:00
|
|
|
{
|
2011-05-29 23:10:51 +00:00
|
|
|
// LShift: force highlighted sector deleting
|
|
|
|
if (keystatus[0x2a] || (hlsectorbitmap[i>>3]&(1<<(i&7))))
|
|
|
|
{
|
|
|
|
for (j=highlightsectorcnt-1; j>=0; j--)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
2011-03-13 11:59:32 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2011-05-29 23:10:51 +00:00
|
|
|
yax_getbunches(highlightsector[j], &cb, &fb);
|
2011-06-26 23:29:51 +00:00
|
|
|
if (cb>=0) bunchbitmap[cb>>3] |= (1<<(cb&7));
|
|
|
|
if (fb>=0) bunchbitmap[fb>>3] |= (1<<(fb&7));
|
2011-03-13 11:59:32 +00:00
|
|
|
#endif
|
2011-05-29 23:10:51 +00:00
|
|
|
deletesector(highlightsector[j]);
|
|
|
|
for (k=j-1; k>=0; k--)
|
|
|
|
if (highlightsector[k] >= highlightsector[j])
|
|
|
|
highlightsector[k]--;
|
2011-02-24 20:40:27 +00:00
|
|
|
}
|
2011-05-29 23:10:51 +00:00
|
|
|
|
|
|
|
printmessage16("Highlighted sectors deleted.");
|
|
|
|
mkonwinvalid();
|
|
|
|
k = 1;
|
|
|
|
}
|
2011-03-13 11:59:32 +00:00
|
|
|
}
|
2010-08-26 13:50:09 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if (k == 0)
|
|
|
|
{
|
2011-04-22 22:48:06 +00:00
|
|
|
if (numdelsectors > 1)
|
|
|
|
{
|
2011-10-30 19:48:29 +00:00
|
|
|
if (!bakframe_fillandfade(&origframe, i, "Delete this sector? (Y/N)"))
|
2011-04-22 22:48:06 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_getbunches(i, &cb, &fb);
|
2011-06-26 23:29:51 +00:00
|
|
|
if (cb>=0) bunchbitmap[cb>>3] |= (1<<(cb&7));
|
|
|
|
if (fb>=0) bunchbitmap[fb>>3] |= (1<<(fb&7));
|
2011-03-13 11:59:32 +00:00
|
|
|
#endif
|
2011-02-24 20:40:27 +00:00
|
|
|
deletesector(i);
|
2011-05-15 22:37:24 +00:00
|
|
|
mkonwinvalid();
|
2011-02-24 20:40:27 +00:00
|
|
|
printmessage16("Sector deleted.");
|
|
|
|
}
|
2010-08-26 13:50:09 +00:00
|
|
|
|
2015-09-23 17:55:31 +00:00
|
|
|
Bfree(origframe);
|
2011-04-22 22:48:06 +00:00
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
for (j=0; j<numsectors; j++)
|
|
|
|
{
|
|
|
|
yax_getbunches(j, &cb, &fb);
|
2011-06-29 19:57:05 +00:00
|
|
|
if (cb>=0 && (bunchbitmap[cb>>3] & (1<<(cb&7))))
|
2011-03-13 11:59:32 +00:00
|
|
|
yax_setbunch(j, YAX_CEILING, -1);
|
2011-06-29 19:57:05 +00:00
|
|
|
if (fb>=0 && (bunchbitmap[fb>>3] & (1<<(fb&7))))
|
2011-03-13 11:59:32 +00:00
|
|
|
yax_setbunch(j, YAX_FLOOR, -1);
|
|
|
|
}
|
|
|
|
#endif
|
2012-08-20 21:27:42 +00:00
|
|
|
reset_highlightsector();
|
|
|
|
reset_highlight();
|
2010-08-26 13:50:09 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
newnumwalls = -1;
|
|
|
|
asksave = 1;
|
2011-04-22 22:48:06 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_update(0);
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
#endif
|
2011-02-24 20:40:27 +00:00
|
|
|
break;
|
|
|
|
}
|
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[0xd3] && (pointhighlight >= 0))
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if ((pointhighlight&0xc000) == 16384) //Sprite Delete
|
|
|
|
{
|
|
|
|
deletesprite(pointhighlight&16383);
|
|
|
|
printmessage16("Sprite deleted.");
|
2012-03-14 22:30:24 +00:00
|
|
|
|
2010-08-26 13:50:09 +00:00
|
|
|
update_highlight();
|
2006-04-24 19:04:22 +00:00
|
|
|
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
|
2011-01-16 02:50:27 +00:00
|
|
|
{
|
2011-05-15 22:37:24 +00:00
|
|
|
if (highlightsectorcnt > 0)
|
2010-08-26 13:50:09 +00:00
|
|
|
duplicate_selected_sectors();
|
2011-05-15 22:37:24 +00:00
|
|
|
else if (highlightcnt > 0)
|
2010-08-26 13:50:09 +00:00
|
|
|
duplicate_selected_sprites();
|
2013-08-19 19:27:02 +00:00
|
|
|
else if (linehighlight2 >= 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-08 23:02:38 +00:00
|
|
|
int32_t onewnumwalls = newnumwalls;
|
2013-08-19 19:27:02 +00:00
|
|
|
int32_t wallis2sided = (wall[linehighlight2].nextwall>=0);
|
2008-10-31 10:08:51 +00:00
|
|
|
|
2011-10-30 19:47:58 +00:00
|
|
|
int32_t err = backup_drawn_walls(0);
|
|
|
|
|
|
|
|
if (err)
|
2008-10-31 10:08:51 +00:00
|
|
|
{
|
2011-10-30 19:47:58 +00:00
|
|
|
message("Error backing up drawn walls (code %d)!", err);
|
2008-10-31 10:08:51 +00:00
|
|
|
}
|
2011-03-08 23:02:38 +00:00
|
|
|
else if (max(numwalls,onewnumwalls) >= MAXWALLS-wallis2sided)
|
|
|
|
{
|
2010-04-19 21:22:26 +00:00
|
|
|
printmessage16("Inserting point would exceed wall limit.");
|
2011-03-08 23:02:38 +00:00
|
|
|
}
|
2010-04-19 21:22:26 +00:00
|
|
|
else
|
|
|
|
{
|
2011-04-11 22:28:58 +00:00
|
|
|
getclosestpointonwall(m32_sideview?searchx:mousxplc, m32_sideview?searchy:mousyplc,
|
2013-08-19 19:27:02 +00:00
|
|
|
linehighlight2, &dax,&day, 1);
|
|
|
|
i = linehighlight2;
|
2011-04-11 22:28:58 +00:00
|
|
|
if (m32_sideview)
|
|
|
|
{
|
|
|
|
int32_t y_p, d, dx, dy, frac;
|
|
|
|
|
|
|
|
dx = dax - m32_wallscreenxy[i][0];
|
|
|
|
dy = day - m32_wallscreenxy[i][1];
|
|
|
|
d = max(dx, dy);
|
|
|
|
y_p = (dy>dx);
|
|
|
|
|
|
|
|
if (d==0)
|
|
|
|
goto point_not_inserted;
|
|
|
|
|
|
|
|
frac = divscale24(d, m32_wallscreenxy[wall[i].point2][y_p]-m32_wallscreenxy[i][y_p]);
|
|
|
|
dax = POINT2(i).x - wall[i].x;
|
|
|
|
day = POINT2(i).y - wall[i].y;
|
|
|
|
dax = wall[i].x + mulscale24(dax,frac);
|
|
|
|
day = wall[i].y + mulscale24(day,frac);
|
|
|
|
}
|
|
|
|
|
|
|
|
adjustmark(&dax,&day, newnumwalls);
|
2011-03-13 11:59:32 +00:00
|
|
|
if ((wall[i].x == dax && wall[i].y == day) || (POINT2(i).x == dax && POINT2(i).y == day))
|
2010-05-18 05:14:17 +00:00
|
|
|
{
|
2011-04-11 22:28:58 +00:00
|
|
|
point_not_inserted:
|
2011-10-30 19:48:29 +00:00
|
|
|
printmessage16("Point not inserted.");
|
2011-03-13 11:59:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-19 19:27:02 +00:00
|
|
|
int32_t insdpoints = M32_InsertPoint(linehighlight2, dax, day, onewnumwalls, NULL);
|
2011-04-14 20:48:08 +00:00
|
|
|
|
2011-11-25 09:51:21 +00:00
|
|
|
if (insdpoints == 0)
|
2011-03-25 11:42:07 +00:00
|
|
|
{
|
2011-11-25 09:51:21 +00:00
|
|
|
printmessage16("Inserting points would exceed wall limit.");
|
|
|
|
goto end_insert_points;
|
2011-03-25 11:42:07 +00:00
|
|
|
}
|
2011-11-25 09:51:21 +00:00
|
|
|
else if (insdpoints == 1)
|
2011-03-23 17:41:01 +00:00
|
|
|
{
|
|
|
|
printmessage16("Point inserted.");
|
|
|
|
}
|
2011-11-25 09:51:21 +00:00
|
|
|
else if (insdpoints > 1 && insdpoints < 65536)
|
|
|
|
{
|
|
|
|
message("Inserted %d points for constrained wall.", insdpoints);
|
|
|
|
}
|
|
|
|
else // insdpoints >= 65536
|
|
|
|
{
|
|
|
|
message("Inserted %d points for constrained wall (expected %d, WTF?).",
|
|
|
|
insdpoints&65535, insdpoints>>16);
|
|
|
|
}
|
|
|
|
|
2011-04-22 22:48:06 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_updategrays(pos.z);
|
|
|
|
#endif
|
2012-06-01 20:09:22 +00:00
|
|
|
mkonwinvalid_keeptempsect();
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-25 09:51:21 +00:00
|
|
|
|
2011-04-14 20:48:08 +00:00
|
|
|
end_insert_points:
|
2011-03-08 23:02:38 +00:00
|
|
|
backup_drawn_walls(1);
|
2008-10-31 10:08:51 +00:00
|
|
|
|
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");
|
2014-06-13 09:02:37 +00:00
|
|
|
Bexit(0);
|
2006-04-24 19:04:22 +00:00
|
|
|
}*/
|
|
|
|
//printext16(9L,336+9L,4,-1,kensig,0);
|
|
|
|
//printext16(8L,336+8L,12,-1,kensig,0);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-07-08 03:34:42 +00:00
|
|
|
nokeys:
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2006-04-24 19:04:22 +00:00
|
|
|
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
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (quickmapcycling && keystatus[0x2d]) //X
|
2008-05-15 03:16:38 +00:00
|
|
|
{
|
2015-07-08 03:34:46 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (eitherCTRL) //Ctrl
|
2008-05-15 03:16:38 +00:00
|
|
|
{
|
2016-09-10 05:20:55 +00:00
|
|
|
if (asksave)
|
|
|
|
message("You have unsaved changes.");
|
2008-05-15 03:16:38 +00:00
|
|
|
else
|
|
|
|
{
|
2016-09-10 05:20:55 +00:00
|
|
|
int skip = 0;
|
|
|
|
nextmap:
|
|
|
|
// bad = 0;
|
|
|
|
i = menuselect_auto(keystatus[0x2a] ? 0 : 1, skip); // LShift: prev map
|
|
|
|
if (i < 0)
|
2015-07-08 03:34:46 +00:00
|
|
|
{
|
2016-09-10 05:20:55 +00:00
|
|
|
if (i == -1)
|
|
|
|
message("No more map files.");
|
|
|
|
else if (i == -2)
|
|
|
|
message("No .MAP files found.");
|
2015-07-08 03:34:46 +00:00
|
|
|
}
|
2016-09-10 05:20:55 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (LoadBoard(NULL, 4))
|
|
|
|
{
|
|
|
|
skip = 2;
|
|
|
|
goto nextmap;
|
|
|
|
}
|
2010-11-20 16:47:18 +00:00
|
|
|
|
2016-09-10 05:20:55 +00:00
|
|
|
RESET_EDITOR_VARS();
|
|
|
|
oposz = pos.z;
|
|
|
|
}
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2016-09-10 05:20:55 +00:00
|
|
|
keystatus[0x1c] = 0;
|
2008-05-15 03:16:38 +00:00
|
|
|
|
2016-09-10 05:20:55 +00:00
|
|
|
keystatus[0x2d]=keystatus[0x13]=0;
|
2008-05-15 03:16:38 +00:00
|
|
|
|
2016-09-10 05:20:55 +00:00
|
|
|
}
|
2008-05-15 03:16:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// ^^^ PK ------------------------------------
|
|
|
|
|
2009-09-16 22:24:24 +00:00
|
|
|
if (keystatus[1] && joinsector[0] >= 0)
|
|
|
|
{
|
|
|
|
keystatus[1]=0;
|
|
|
|
joinsector[0]=-1;
|
|
|
|
printmessage16("No sectors joined.");
|
|
|
|
}
|
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
CANCEL:
|
2008-05-16 00:23:33 +00:00
|
|
|
if (keystatus[1])
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
keystatus[1] = 0;
|
2011-08-20 11:54:16 +00:00
|
|
|
#if M32_UNDO
|
2009-05-05 21:25:06 +00:00
|
|
|
_printmessage16("(N)ew, (L)oad, (S)ave, save (A)s, (T)est map, (U)ndo, (R)edo, (Q)uit");
|
2011-08-20 11:54:16 +00:00
|
|
|
#else
|
|
|
|
_printmessage16("(N)ew, (L)oad, (S)ave, save (A)s, (T)est map, (Q)uit");
|
|
|
|
#endif
|
2012-10-01 17:52:44 +00:00
|
|
|
printext16(16*8, ydim-STATUS2DSIZ2-12, editorcolors[15], -1, GetSaveBoardFilename(NULL), 0);
|
2011-10-31 19:49:43 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2018-04-12 21:02:31 +00:00
|
|
|
keyFlushChars();
|
2006-04-24 19:04:22 +00:00
|
|
|
bad = 1;
|
|
|
|
while (bad == 1)
|
|
|
|
{
|
2011-10-30 19:47:26 +00:00
|
|
|
char ch;
|
|
|
|
|
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
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
ch = keyGetChar();
|
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;
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2016-12-26 06:02:06 +00:00
|
|
|
if (ask_if_sure("Are you sure you want to start a new board? (Y/N)", 0))
|
2011-01-16 00:23:39 +00:00
|
|
|
{
|
|
|
|
int32_t bakstat=-1;
|
|
|
|
mapinfofull_t bakmap;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
if (highlightsectorcnt > 0)
|
|
|
|
bakstat = backup_highlighted_map(&bakmap);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
// Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap));
|
|
|
|
// highlightsectorcnt = -1;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
highlightcnt = -1;
|
|
|
|
//Clear all highlights
|
|
|
|
Bmemset(show2dwall, 0, sizeof(show2dwall));
|
|
|
|
Bmemset(show2dsprite, 0, sizeof(show2dsprite));
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-01-16 00:23:39 +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;
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
RESET_EDITOR_VARS();
|
2011-05-15 22:37:24 +00:00
|
|
|
mkonwinvalid();
|
2011-03-13 11:59:32 +00:00
|
|
|
|
|
|
|
reset_default_mapstate();
|
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
Bstrcpy(boardfilename,"newboard.map");
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtLoadMap(boardfilename);
|
2011-08-20 11:54:16 +00:00
|
|
|
#if M32_UNDO
|
2011-01-16 00:23:39 +00:00
|
|
|
map_undoredo_free();
|
2011-08-20 11:54:16 +00:00
|
|
|
#endif
|
2011-01-16 00:23:39 +00:00
|
|
|
if (bakstat==0)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2011-11-26 22:40:23 +00:00
|
|
|
bakstat = restore_highlighted_map(&bakmap, 1);
|
2011-01-16 00:23:39 +00:00
|
|
|
if (bakstat == -1)
|
2014-03-04 22:20:05 +00:00
|
|
|
{
|
2011-01-16 00:23:39 +00:00
|
|
|
message("Can't copy highlighted portion of old map: limits exceeded.");
|
2014-03-04 22:20:05 +00:00
|
|
|
reset_highlightsector();
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2011-09-12 15:03:51 +00:00
|
|
|
CheckMapCorruption(4, 0);
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2016-12-26 06:02:06 +00:00
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else if (ch == 'l' || ch == 'L') //L
|
|
|
|
{
|
|
|
|
bad = 0;
|
|
|
|
i = menuselect();
|
|
|
|
if (i < 0)
|
|
|
|
{
|
|
|
|
if (i == -2)
|
|
|
|
printmessage16("No .MAP files found.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-06 19:43:42 +00:00
|
|
|
int32_t bakstat=-1, ret;
|
2010-11-27 22:12:24 +00:00
|
|
|
mapinfofull_t bakmap;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
if (highlightsectorcnt > 0)
|
|
|
|
bakstat = backup_highlighted_map(&bakmap);
|
2013-05-06 19:43:42 +00:00
|
|
|
|
|
|
|
ret = LoadBoard(NULL, 4);
|
|
|
|
if (ret)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2013-06-28 14:07:44 +00:00
|
|
|
message("^13Invalid map format, nothing loaded (code %d).", ret);
|
2010-11-27 22:12:24 +00:00
|
|
|
if (bakstat==0)
|
|
|
|
mapinfofull_free(&bakmap);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-13 11:59:32 +00:00
|
|
|
RESET_EDITOR_VARS();
|
2011-01-16 00:23:39 +00:00
|
|
|
oposz = pos.z;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
if (bakstat==0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-11-26 22:40:23 +00:00
|
|
|
bakstat = restore_highlighted_map(&bakmap, 1);
|
2010-11-27 22:12:24 +00:00
|
|
|
if (bakstat == -1)
|
2014-03-04 22:20:05 +00:00
|
|
|
{
|
2010-11-27 22:12:24 +00:00
|
|
|
message("Can't copy highlighted portion of old map: limits exceeded.");
|
2014-03-04 22:20:05 +00:00
|
|
|
reset_highlightsector();
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2006-04-24 19:04:22 +00:00
|
|
|
keystatus[0x1c] = 0;
|
|
|
|
}
|
|
|
|
else if (ch == 'a' || ch == 'A') //A
|
|
|
|
{
|
2011-02-10 23:15:02 +00:00
|
|
|
int32_t corrupt = CheckMapCorruption(4, 0);
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
bad = 0;
|
|
|
|
|
2013-05-12 18:51:19 +00:00
|
|
|
// Back up full name.
|
2006-04-24 19:04:22 +00:00
|
|
|
Bstrcpy(selectedboardfilename, boardfilename);
|
2013-05-12 18:51:19 +00:00
|
|
|
|
|
|
|
// Get base name.
|
|
|
|
{
|
|
|
|
const char *basefn = getbasefn(boardfilename);
|
|
|
|
|
|
|
|
if (basefn != boardfilename)
|
|
|
|
Bmemmove(boardfilename, basefn, Bstrlen(basefn)+1);
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
i = 0;
|
2013-05-12 18:51:16 +00:00
|
|
|
while (boardfilename[i] != 0 && i < 64)
|
2006-04-24 19:04:22 +00:00
|
|
|
i++;
|
2013-10-28 21:26:30 +00:00
|
|
|
if (i >= 4 && boardfilename[i-4] == '.')
|
2006-04-24 19:04:22 +00:00
|
|
|
i -= 4;
|
|
|
|
boardfilename[i] = 0;
|
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
keyFlushChars();
|
2006-04-24 19:04:22 +00:00
|
|
|
while (bad == 0)
|
|
|
|
{
|
2011-01-16 00:23:39 +00:00
|
|
|
_printmessage16("%sSave as: ^011%s%s", corrupt>=4?"(map corrupt) ":"",
|
|
|
|
boardfilename, (totalclock&32)?"_":"");
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
2010-05-18 05:14:17 +00:00
|
|
|
quitevent = 0;
|
|
|
|
|
2007-01-12 05:49:09 +00:00
|
|
|
idle();
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
ch = keyGetChar();
|
2006-04-24 19:04:22 +00:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-14 21:32:28 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (bad == 1)
|
|
|
|
{
|
|
|
|
Bstrcpy(boardfilename, selectedboardfilename);
|
|
|
|
keystatus[1] = 0;
|
|
|
|
printmessage16("Operation cancelled");
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-08-14 21:32:28 +00:00
|
|
|
else if (bad == 2)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-01-16 00:23:39 +00:00
|
|
|
char *slash;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
keystatus[0x1c] = 0;
|
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
Bstrcpy(&boardfilename[i], ".map");
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2013-05-12 18:51:19 +00:00
|
|
|
// Update full name with new basename.
|
2011-01-16 00:23:39 +00:00
|
|
|
slash = Bstrrchr(selectedboardfilename,'/');
|
|
|
|
Bstrcpy(slash ? slash+1 : selectedboardfilename, boardfilename);
|
|
|
|
|
2011-11-11 20:05:29 +00:00
|
|
|
SaveBoardAndPrintMessage(selectedboardfilename);
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
Bstrcpy(boardfilename, selectedboardfilename);
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtSetupMapFilename(boardfilename);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
bad = 0;
|
|
|
|
}
|
|
|
|
else if (ch == 's' || ch == 'S') //S
|
|
|
|
{
|
|
|
|
bad = 0;
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2011-02-10 23:15:02 +00:00
|
|
|
if (CheckMapCorruption(4, 0)>=4)
|
2011-05-29 23:10:51 +00:00
|
|
|
{
|
|
|
|
fade_editor_screen(-1);
|
2011-04-22 22:48:06 +00:00
|
|
|
if (!ask_if_sure("Map is corrupt. Are you sure you want to save? (Y/N)", 0))
|
2011-01-16 00:23:39 +00:00
|
|
|
break;
|
2011-05-29 23:10:51 +00:00
|
|
|
}
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2011-11-11 20:05:29 +00:00
|
|
|
SaveBoardAndPrintMessage(NULL);
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2009-05-05 16:21:33 +00:00
|
|
|
else if (ch == 't' || ch == 'T')
|
|
|
|
{
|
2015-08-29 17:43:40 +00:00
|
|
|
bad = 0;
|
2009-05-05 16:21:33 +00:00
|
|
|
test_map(0);
|
|
|
|
}
|
2011-08-20 11:54:16 +00:00
|
|
|
#if M32_UNDO
|
2009-05-05 21:25:06 +00:00
|
|
|
else if (ch == 'u' || ch == 'U')
|
|
|
|
{
|
|
|
|
bad = 0;
|
|
|
|
if (map_undoredo(0)) printmessage16("Nothing to undo!");
|
|
|
|
else printmessage16("Revision %d undone",map_revision);
|
|
|
|
}
|
|
|
|
else if (ch == 'r' || ch == 'R')
|
|
|
|
{
|
|
|
|
bad = 0;
|
|
|
|
if (map_undoredo(1)) printmessage16("Nothing to redo!");
|
|
|
|
else printmessage16("Restored revision %d",map_revision-1);
|
|
|
|
}
|
2011-08-20 11:54:16 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
else if (ch == 'q' || ch == 'Q') //Q
|
|
|
|
{
|
|
|
|
bad = 0;
|
2011-01-16 00:23:39 +00:00
|
|
|
|
|
|
|
if (ask_if_sure("Are you sure you want to quit?", 0))
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-01-16 00:23:39 +00:00
|
|
|
//QUIT!
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-02-10 23:15:02 +00:00
|
|
|
int32_t corrupt = CheckMapCorruption(4, 0);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if (ask_if_sure(corrupt<4?"Save changes?":"Map corrupt. Save changes?", 2+(corrupt>=4)))
|
2013-06-28 14:07:44 +00:00
|
|
|
SaveBoard(NULL, M32_SB_ASKOV);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
while (keystatus[1] || keystatus[0x2e])
|
|
|
|
{
|
|
|
|
keystatus[1] = 0;
|
|
|
|
keystatus[0x2e] = 0;
|
|
|
|
quitevent = 0;
|
|
|
|
printmessage16("Operation cancelled");
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2011-01-16 00:23:39 +00:00
|
|
|
goto CANCEL;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtUnInit();
|
2011-03-13 11:59:32 +00:00
|
|
|
// clearfilenames();
|
2018-04-12 21:03:47 +00:00
|
|
|
engineUnInit();
|
2011-09-15 17:03:29 +00:00
|
|
|
|
2014-06-13 09:02:37 +00:00
|
|
|
Bexit(0);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
// printmessage16("");
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
clearkeys();
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_OnEvent(EVENT_KEYS2D, -1);
|
2009-09-16 22:24:24 +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
|
|
|
{
|
2011-02-10 23:15:02 +00:00
|
|
|
for (WALLS_OF_SECTOR(highlightsector[i], j))
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
if (wall[j].nextwall >= 0)
|
2011-02-24 20:40:27 +00:00
|
|
|
checksectorpointer(wall[j].nextwall, wall[j].nextsector);
|
|
|
|
checksectorpointer(j, highlightsector[i]);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2012-06-01 20:09:22 +00:00
|
|
|
mkonwinvalid_keeptempsect();
|
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
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
if (videoSetGameMode(fullscreen,xdimgame,ydimgame,bppgame) < 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-02-10 23:15:02 +00:00
|
|
|
initprintf("%d * %d not supported in this graphics mode\n",xdim,ydim);
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtUnInit();
|
2011-03-13 11:59:32 +00:00
|
|
|
// clearfilenames();
|
2018-04-12 21:03:47 +00:00
|
|
|
engineUnInit();
|
2014-06-13 09:02:37 +00:00
|
|
|
Bexit(1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-04-12 21:03:12 +00:00
|
|
|
videoSetPalette(GAMMA_CALC,0,0);
|
2011-01-16 02:50:27 +00:00
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
pos.z = oposz;
|
2010-09-06 23:08:35 +00:00
|
|
|
|
|
|
|
searchx = clamp(scale(searchx,xdimgame,xdim2d), 8, xdimgame-8-1);
|
|
|
|
searchy = clamp(scale(searchy,ydimgame,ydim2d-STATUS2DSIZ), 8, ydimgame-8-1);
|
2009-09-12 23:03:15 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_OnEvent(EVENT_ENTER3DMODE, -1);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
// flags:
|
|
|
|
// 1: quit_is_yes
|
|
|
|
// 2: don't clear keys on return
|
2011-05-23 22:42:39 +00:00
|
|
|
int32_t ask_if_sure(const char *query, uint32_t flags)
|
2011-01-16 00:23:39 +00:00
|
|
|
{
|
|
|
|
char ch;
|
2011-02-24 20:40:27 +00:00
|
|
|
int32_t ret=-1;
|
2011-01-16 00:23:39 +00:00
|
|
|
|
|
|
|
if (!query)
|
|
|
|
_printmessage16("Are you sure?");
|
|
|
|
else
|
|
|
|
_printmessage16("%s", query);
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2018-04-12 21:02:31 +00:00
|
|
|
keyFlushChars();
|
2011-02-10 23:15:02 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
while ((keystatus[1]|keystatus[0x2e]) == 0 && ret==-1)
|
2011-01-16 00:23:39 +00:00
|
|
|
{
|
|
|
|
if (handleevents())
|
|
|
|
{
|
|
|
|
if (quitevent)
|
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
if (flags&1)
|
2011-01-16 00:23:39 +00:00
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
quitevent = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
idle();
|
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
ch = keyGetChar();
|
2011-01-16 00:23:39 +00:00
|
|
|
|
|
|
|
if (ch == 'y' || ch == 'Y')
|
2011-02-24 20:40:27 +00:00
|
|
|
ret = 1;
|
2011-01-16 00:23:39 +00:00
|
|
|
else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ')
|
2011-02-24 20:40:27 +00:00
|
|
|
ret = 0;
|
2011-01-16 00:23:39 +00:00
|
|
|
}
|
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if ((flags&2)==0)
|
|
|
|
clearkeys();
|
|
|
|
|
|
|
|
if (ret >= 0)
|
|
|
|
return ret;
|
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-05-23 22:42:39 +00:00
|
|
|
int32_t editor_ask_function(const char *question, const char *dachars, int32_t numchars)
|
2011-03-02 21:21:47 +00:00
|
|
|
{
|
|
|
|
char ch;
|
2011-04-28 21:28:33 +00:00
|
|
|
int32_t i, ret=-1;
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2011-04-28 21:28:33 +00:00
|
|
|
_printmessage16("%s", question);
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2018-04-12 21:02:31 +00:00
|
|
|
keyFlushChars();
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2011-04-28 21:28:33 +00:00
|
|
|
// 'c' is cancel too, but can be overridden
|
2011-03-05 12:59:27 +00:00
|
|
|
while ((keystatus[1]|keystatus[0x2e]) == 0 && ret==-1)
|
2011-03-02 21:21:47 +00:00
|
|
|
{
|
|
|
|
if (handleevents())
|
|
|
|
quitevent = 0;
|
|
|
|
|
|
|
|
idle();
|
2018-04-12 21:02:31 +00:00
|
|
|
ch = keyGetChar();
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2011-04-28 21:28:33 +00:00
|
|
|
for (i=0; i<numchars; i++)
|
|
|
|
if (ch==Btolower(dachars[i]) || ch==Btoupper(dachars[i]))
|
|
|
|
ret = i;
|
2011-03-02 21:21:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
clearkeys();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2011-04-28 21:28:33 +00:00
|
|
|
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
static int32_t ask_above_or_below(void)
|
|
|
|
{
|
|
|
|
char dachars[2] = {'a', 'z'};
|
|
|
|
return editor_ask_function("Extend above (a) or below (z)?", dachars, 2);
|
|
|
|
}
|
2011-03-13 11:59:32 +00:00
|
|
|
#endif
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2011-11-11 20:05:29 +00:00
|
|
|
static void SaveBoardAndPrintMessage(const char *fn)
|
|
|
|
{
|
|
|
|
const char *f;
|
|
|
|
|
|
|
|
_printmessage16("Saving board...");
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2011-11-11 20:05:29 +00:00
|
|
|
|
2013-06-28 14:07:44 +00:00
|
|
|
f = SaveBoard(fn, M32_SB_ASKOV);
|
2011-11-11 20:05:29 +00:00
|
|
|
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
if (saveboard_fixedsprites)
|
2013-04-09 17:35:14 +00:00
|
|
|
message("Saved board %sto %s (changed sectnums of %d sprites).",
|
|
|
|
saveboard_savedtags?"and tags ":"", f, saveboard_fixedsprites);
|
2011-11-11 20:05:29 +00:00
|
|
|
else
|
2013-04-09 17:35:14 +00:00
|
|
|
message("Saved board %sto %s.", saveboard_savedtags?"and tags ":"", f);
|
2011-11-11 20:05:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-28 14:07:44 +00:00
|
|
|
if (!saveboard_canceled)
|
|
|
|
{
|
|
|
|
if (saveboard_fixedsprites)
|
|
|
|
message("^13SAVING BOARD FAILED (changed sectnums of %d sprites).",
|
|
|
|
saveboard_fixedsprites);
|
|
|
|
else
|
|
|
|
message("^13SAVING BOARD FAILED.");
|
|
|
|
}
|
2011-11-11 20:05:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-01 17:52:44 +00:00
|
|
|
// get the file name of the file that would be written if SaveBoard(fn, 0) was called
|
|
|
|
const char *GetSaveBoardFilename(const char *fn)
|
2011-10-31 19:49:43 +00:00
|
|
|
{
|
2012-10-01 17:52:44 +00:00
|
|
|
if (!fn)
|
|
|
|
fn = boardfilename;
|
2011-10-31 19:49:43 +00:00
|
|
|
|
|
|
|
if (pathsearchmode)
|
2013-05-12 18:51:19 +00:00
|
|
|
return fn;
|
2011-10-31 19:49:43 +00:00
|
|
|
|
2013-05-12 18:51:19 +00:00
|
|
|
// virtual filesystem mode can't save to directories so drop the file into
|
|
|
|
// the current directory
|
|
|
|
return getbasefn(fn);
|
2011-10-31 19:49:43 +00:00
|
|
|
}
|
|
|
|
|
2013-06-28 14:07:44 +00:00
|
|
|
// flags: see enum SaveBoardFlags.
|
|
|
|
// returns: NULL on failure, file name on success.
|
2011-01-16 00:23:39 +00:00
|
|
|
const char *SaveBoard(const char *fn, uint32_t flags)
|
|
|
|
{
|
|
|
|
int32_t ret;
|
2012-10-01 17:52:44 +00:00
|
|
|
const char *f = GetSaveBoardFilename(fn);
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2013-06-28 14:07:44 +00:00
|
|
|
saveboard_canceled = 0;
|
|
|
|
#ifdef NEW_MAP_FORMAT
|
|
|
|
if ((flags&M32_SB_ASKOV) && mapversion>=10 &&
|
|
|
|
g_loadedMapVersion != -1 && g_loadedMapVersion < mapversion)
|
|
|
|
{
|
|
|
|
char question[128];
|
2013-08-12 15:18:13 +00:00
|
|
|
// XXX: This message is potentially confusing if the user is "Saving
|
|
|
|
// As" to a new file name.
|
2013-06-28 14:07:44 +00:00
|
|
|
Bsnprintf(question, sizeof(question), "Are you sure to overwrite a version "
|
|
|
|
"V%d map with a V%d map-text one?", g_loadedMapVersion, mapversion);
|
|
|
|
|
|
|
|
if (AskIfSure(question))
|
|
|
|
{
|
|
|
|
message("Cancelled saving board");
|
|
|
|
saveboard_canceled = 1;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2011-04-17 17:01:20 +00:00
|
|
|
|
2013-06-28 14:07:44 +00:00
|
|
|
saveboard_savedtags = 0;
|
2014-07-24 14:01:44 +00:00
|
|
|
saveboard_fixedsprites = CallExtPreSaveMap();
|
2013-06-28 14:07:44 +00:00
|
|
|
|
2012-10-01 17:52:30 +00:00
|
|
|
ret = saveboard(f, &startpos, startang, startsectnum);
|
2013-06-28 14:07:44 +00:00
|
|
|
if ((flags&M32_SB_NOEXT)==0)
|
2011-04-17 17:01:20 +00:00
|
|
|
{
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtSaveMap(f);
|
2011-04-17 17:01:20 +00:00
|
|
|
saveboard_savedtags = !taglab_save(f);
|
|
|
|
}
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2012-10-01 17:52:44 +00:00
|
|
|
return (ret==0) ? f : NULL;
|
2011-01-16 00:23:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// flags: 1: for running on Mapster32 init
|
|
|
|
// 4: passed to loadboard flags (no polymer_loadboard); implies no maphack loading
|
2013-06-28 14:07:44 +00:00
|
|
|
// returns:
|
|
|
|
// 0 on success,
|
|
|
|
// <0 on failure.
|
2011-01-16 00:23:39 +00:00
|
|
|
int32_t LoadBoard(const char *filename, uint32_t flags)
|
|
|
|
{
|
2013-04-09 17:35:11 +00:00
|
|
|
int32_t i, tagstat;
|
|
|
|
const int32_t loadingflags = (!pathsearchmode && grponlymode) ? 2 : 0;
|
2011-01-16 00:23:39 +00:00
|
|
|
|
|
|
|
if (!filename)
|
|
|
|
filename = selectedboardfilename;
|
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
editorzrange[0] = INT32_MIN;
|
|
|
|
editorzrange[1] = INT32_MAX;
|
2011-05-07 18:23:34 +00:00
|
|
|
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtPreLoadMap();
|
2018-04-12 21:03:47 +00:00
|
|
|
i = engineLoadBoard(filename, (flags&4)|loadingflags, &pos, &ang, &cursectnum);
|
2011-04-17 17:01:20 +00:00
|
|
|
if (i == -2)
|
2018-04-12 21:03:47 +00:00
|
|
|
i = engineLoadBoardV5V6(filename,loadingflags, &pos, &ang, &cursectnum);
|
2013-04-25 21:10:22 +00:00
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
if (i < 0)
|
|
|
|
{
|
|
|
|
// printmessage16("Invalid map format.");
|
|
|
|
return i;
|
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2013-06-28 14:07:44 +00:00
|
|
|
// Success, so copy the file name.
|
|
|
|
if (filename != boardfilename)
|
|
|
|
Bstrcpy(boardfilename, filename);
|
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
mkonwinvalid();
|
|
|
|
|
2011-05-07 18:23:34 +00:00
|
|
|
highlightcnt = -1;
|
|
|
|
Bmemset(show2dwall, 0, sizeof(show2dwall)); //Clear all highlights
|
2011-10-30 19:48:29 +00:00
|
|
|
Bmemset(show2dsprite, 0, sizeof(show2dsprite));
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2011-04-17 17:01:20 +00:00
|
|
|
if ((flags&4)==0)
|
|
|
|
loadmhk(0);
|
|
|
|
|
|
|
|
tagstat = taglab_load(boardfilename, loadingflags);
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtLoadMap(boardfilename);
|
2011-04-17 17:01:20 +00:00
|
|
|
|
|
|
|
{
|
2013-04-21 19:55:22 +00:00
|
|
|
char msgtail[64];
|
|
|
|
const int32_t ci = CheckMapCorruption(4, 0);
|
|
|
|
|
2013-05-10 12:31:35 +00:00
|
|
|
if (ci == 5)
|
|
|
|
Bstrcpy(msgtail, "^12(EXTREME corruption)");
|
|
|
|
else if (ci == 4)
|
2013-04-21 19:55:22 +00:00
|
|
|
Bstrcpy(msgtail, "^12(HEAVY corruption)");
|
|
|
|
else if (i > 0)
|
|
|
|
Bsprintf(msgtail, "^14(removed %d sprites)", i);
|
|
|
|
else if (ci >= 1 && ci < 4)
|
|
|
|
Bstrcpy(msgtail, "^14(moderate corruption)");
|
|
|
|
else
|
|
|
|
Bstrcpy(msgtail, "successfully");
|
|
|
|
|
2013-06-28 14:07:44 +00:00
|
|
|
message("Loaded V%d map %s%s %s", g_loadedMapVersion,
|
|
|
|
boardfilename, tagstat==0?" w/tags":"", msgtail);
|
2011-01-16 00:23:39 +00:00
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2012-10-01 17:52:30 +00:00
|
|
|
startpos = pos; //this is same
|
2011-01-16 00:23:39 +00:00
|
|
|
startang = ang;
|
|
|
|
startsectnum = cursectnum;
|
2016-09-10 05:20:55 +00:00
|
|
|
asksave = 0;
|
2011-01-16 00:23:39 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2011-03-23 17:41:01 +00:00
|
|
|
inpclamp(&pos.x, -editorgridextent, editorgridextent);
|
|
|
|
inpclamp(&pos.y, -editorgridextent, editorgridextent);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
searchxe -= halfxdim16;
|
|
|
|
searchye -= midydim16;
|
|
|
|
|
2015-05-26 00:47:54 +00:00
|
|
|
vec2_t svec = { searchxe ,searchye };
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
if (m32_sideview)
|
|
|
|
{
|
|
|
|
if (m32_sidesin!=0)
|
2015-05-26 00:47:54 +00:00
|
|
|
svec.y = divscale14(svec.y, m32_sidesin);
|
|
|
|
rotatepoint(zerovec, svec, -m32_sideang, &svec);
|
2010-11-27 22:12:24 +00:00
|
|
|
}
|
|
|
|
|
2015-05-26 00:47:54 +00:00
|
|
|
*x = pos.x + divscale14(svec.x,zoom);
|
|
|
|
*y = pos.y + divscale14(svec.y,zoom);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
inpclamp(x, -editorgridextent, editorgridextent);
|
|
|
|
inpclamp(y, -editorgridextent, editorgridextent);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2013-08-19 19:27:02 +00:00
|
|
|
static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line, int8_t ignore_pointhighlight)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-04-22 22:48:06 +00:00
|
|
|
int32_t i, j, dst, dist, closest, x1, y1, x2, y2, nx, ny;
|
2011-04-11 22:28:58 +00:00
|
|
|
int32_t daxplc, dayplc;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (numwalls == 0)
|
2011-03-13 11:59:32 +00:00
|
|
|
return -1;
|
2008-09-02 02:45:06 +00:00
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
if (g_mouseBits & 1 || searchlock)
|
2010-05-18 05:14:17 +00:00
|
|
|
return line;
|
2008-09-02 02:45:06 +00:00
|
|
|
|
2013-08-19 19:27:02 +00:00
|
|
|
if (!ignore_pointhighlight && (pointhighlight&0xc000) == 16384)
|
2011-03-13 11:59:32 +00:00
|
|
|
return -1;
|
2010-12-05 17:39:52 +00:00
|
|
|
|
2016-01-15 07:58:57 +00:00
|
|
|
dist = linehighlightdist;
|
2011-04-11 22:28:58 +00:00
|
|
|
if (m32_sideview)
|
|
|
|
{
|
|
|
|
daxplc = searchx;
|
|
|
|
dayplc = searchy;
|
|
|
|
dist = mulscale14(dist, zoom);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
daxplc = xplc;
|
|
|
|
dayplc = yplc;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2011-04-22 22:48:06 +00:00
|
|
|
if (!m32_sideview)
|
|
|
|
YAX_SKIPWALL(i);
|
|
|
|
|
2011-04-11 22:28:58 +00:00
|
|
|
getclosestpointonwall(daxplc,dayplc, i, &nx,&ny, 1);
|
|
|
|
dst = klabs(daxplc-nx) + klabs(dayplc-ny);
|
2006-04-24 19:04:22 +00:00
|
|
|
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
|
|
|
|
2012-01-20 15:48:03 +00:00
|
|
|
if (closest>=0 && (j = wall[closest].nextwall) >= 0)
|
2011-04-22 22:48:06 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (m32_sideview || ((graywallbitmap[j>>3]&(1<<(j&7)))==0))
|
|
|
|
#endif
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
//if red line, allow highlighting of both sides
|
2011-04-14 20:48:08 +00:00
|
|
|
if (m32_sideview)
|
|
|
|
{
|
|
|
|
x1 = m32_wallscreenxy[closest][0];
|
|
|
|
y1 = m32_wallscreenxy[closest][1];
|
|
|
|
x2 = m32_wallscreenxy[wall[closest].point2][0];
|
|
|
|
y2 = m32_wallscreenxy[wall[closest].point2][1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x1 = wall[closest].x;
|
|
|
|
y1 = wall[closest].y;
|
|
|
|
x2 = POINT2(closest).x;
|
|
|
|
y2 = POINT2(closest).y;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = wall[closest].nextwall;
|
|
|
|
if (!m32_sideview ||
|
2015-05-03 07:03:48 +00:00
|
|
|
((B_UNBUF64(m32_wallscreenxy[closest]) == B_UNBUF64(m32_wallscreenxy[wall[j].point2])) &&
|
|
|
|
(B_UNBUF64(m32_wallscreenxy[wall[closest].point2]) == B_UNBUF64(m32_wallscreenxy[j]))))
|
2011-04-14 20:48:08 +00:00
|
|
|
if (dmulscale32(daxplc-x1,y2-y1,-(x2-x1),dayplc-y1) >= 0)
|
2011-04-22 22:48:06 +00:00
|
|
|
closest = j;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-12-05 17:39:52 +00:00
|
|
|
|
2011-03-13 11:59:32 +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
|
|
|
{
|
2016-01-15 07:58:57 +00:00
|
|
|
int32_t i, j, dst, dist = pointhighlightdist, closest = -1;
|
2010-12-05 17:39:52 +00:00
|
|
|
int32_t dax,day;
|
2013-03-29 15:59:14 +00:00
|
|
|
int32_t alwaysshowgray = get_alwaysshowgray();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (numwalls == 0)
|
2011-03-13 11:59:32 +00:00
|
|
|
return -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
if (g_mouseBits & 1 || searchlock)
|
2010-05-18 05:14:17 +00:00
|
|
|
return point;
|
2008-09-02 02:45:06 +00:00
|
|
|
|
2007-09-11 02:23:08 +00:00
|
|
|
if (grid < 1)
|
|
|
|
dist = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-12-05 17:39:52 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2011-04-22 22:48:06 +00:00
|
|
|
{
|
2011-08-18 22:01:01 +00:00
|
|
|
if (!m32_sideview || !alwaysshowgray)
|
2011-04-22 22:48:06 +00:00
|
|
|
YAX_SKIPSECTOR(i);
|
|
|
|
|
2010-12-05 17:39:52 +00:00
|
|
|
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
|
|
|
|
{
|
|
|
|
if (!m32_sideview)
|
|
|
|
dst = klabs(xplc-wall[j].x) + klabs(yplc-wall[j].y);
|
|
|
|
else
|
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
editorGet2dScreenCoordinates(&dax,&day, wall[j].x-pos.x,wall[j].y-pos.y, zoom);
|
2010-12-05 17:39:52 +00:00
|
|
|
day += getscreenvdisp(getflorzofslope(i, wall[j].x,wall[j].y)-pos.z, zoom);
|
|
|
|
|
|
|
|
if (halfxdim16+dax < 0 || halfxdim16+dax >= xdim || midydim16+day < 0 || midydim16+day >= ydim)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
dst = klabs(halfxdim16+dax-searchx) + klabs(midydim16+day-searchy);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dst <= dist)
|
2011-02-21 23:08:21 +00:00
|
|
|
{
|
|
|
|
// prefer white walls
|
2011-02-28 18:37:49 +00:00
|
|
|
if (dst<dist || closest==-1 || (wall[j].nextwall>=0)-(wall[closest].nextwall>=0) <= 0)
|
2011-02-21 23:08:21 +00:00
|
|
|
dist = dst, closest = j;
|
|
|
|
}
|
2010-12-05 17:39:52 +00:00
|
|
|
}
|
2011-04-22 22:48:06 +00:00
|
|
|
}
|
2010-12-05 17:39:52 +00:00
|
|
|
|
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)
|
|
|
|
{
|
2011-08-18 22:01:01 +00:00
|
|
|
if ((!m32_sideview || !alwaysshowgray) && sprite[i].sectnum >= 0)
|
2011-04-22 22:48:06 +00:00
|
|
|
YAX_SKIPSECTOR(sprite[i].sectnum);
|
|
|
|
|
2010-12-05 17:39:52 +00:00
|
|
|
if (!m32_sideview)
|
2011-04-22 22:48:06 +00:00
|
|
|
{
|
2010-12-05 17:39:52 +00:00
|
|
|
dst = klabs(xplc-sprite[i].x) + klabs(yplc-sprite[i].y);
|
2011-04-22 22:48:06 +00:00
|
|
|
}
|
2010-12-05 17:39:52 +00:00
|
|
|
else
|
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
editorGet2dScreenCoordinates(&dax,&day, sprite[i].x-pos.x,sprite[i].y-pos.y, zoom);
|
2010-12-05 17:39:52 +00:00
|
|
|
day += getscreenvdisp(sprite[i].z-pos.z, zoom);
|
|
|
|
|
|
|
|
if (halfxdim16+dax < 0 || halfxdim16+dax >= xdim || midydim16+day < 0 || midydim16+day >= ydim)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
dst = klabs(halfxdim16+dax-searchx) + klabs(midydim16+day-searchy);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2010-12-05 17:39:52 +00:00
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
return closest;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static void locktogrid(int32_t *dax, int32_t *day)
|
|
|
|
{
|
|
|
|
*dax = ((*dax+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
*day = ((*day+(1024>>grid))&(0xffffffff<<(11-grid)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static 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;
|
2010-05-18 05:14:17 +00:00
|
|
|
if (grid > 0 && gridlock)
|
2011-11-25 09:52:08 +00:00
|
|
|
pointlockdist = (256>>grid);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
dist = pointlockdist;
|
|
|
|
dax = *xplc;
|
|
|
|
day = *yplc;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<danumwalls; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-05-02 16:58:11 +00:00
|
|
|
YAX_SKIPWALL(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)
|
2010-05-18 05:14:17 +00:00
|
|
|
if (gridlock && grid > 0)
|
|
|
|
locktogrid(&dax, &day);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
*xplc = dax;
|
|
|
|
*yplc = day;
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2016-06-21 00:34:41 +00:00
|
|
|
return 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static 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;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
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
|
|
|
{
|
2011-05-02 16:58:11 +00:00
|
|
|
YAX_SKIPWALL(i);
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
x1 = wall[i].x;
|
|
|
|
y1 = wall[i].y;
|
2010-05-18 05:14:17 +00:00
|
|
|
x2 = POINT2(i).x;
|
|
|
|
y2 = POINT2(i).y;
|
|
|
|
|
|
|
|
if ((x1 != dax || y1 != day) && (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))
|
2014-08-08 20:02:53 +00:00
|
|
|
return 1; //insertpoint((short)i,dax,day,NULL);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2014-08-08 20:02:53 +00:00
|
|
|
return 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-08 20:02:53 +00:00
|
|
|
// <wallstart> has to be the starting (i.e. least index) wall of a loop!
|
|
|
|
// Returns: CLOCKDIR_CW or CLOCKDIR_CCW.
|
2014-08-08 20:02:54 +00:00
|
|
|
int32_t clockdir(int32_t wallstart)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2014-08-08 20:02:53 +00:00
|
|
|
int32_t tempint, x0, x1, x2, y0, y1, y2;
|
|
|
|
|
|
|
|
int32_t minx = 0x7fffffff;
|
|
|
|
int32_t themin = -1;
|
|
|
|
int32_t i = wallstart-1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
i++;
|
2010-05-18 05:14:17 +00:00
|
|
|
if (POINT2(i).x < minx)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
minx = POINT2(i).x;
|
2006-04-24 19:04:22 +00:00
|
|
|
themin = i;
|
|
|
|
}
|
|
|
|
}
|
2014-08-08 20:02:53 +00:00
|
|
|
while (wall[i].point2 != wallstart && i < MAXWALLS-1);
|
|
|
|
// NOTE: the i < MAXWALLS-1 check is really only safety against either
|
|
|
|
// - a really corrupt map, or
|
|
|
|
// - misuse of clockdir() where <wallstart> is not the starting wall of
|
|
|
|
// the very last loop
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
x0 = wall[themin].x;
|
|
|
|
y0 = wall[themin].y;
|
2010-05-18 05:14:17 +00:00
|
|
|
x1 = POINT2(themin).x;
|
|
|
|
y1 = POINT2(themin).y;
|
|
|
|
x2 = POINT2(wall[themin].point2).x;
|
|
|
|
y2 = POINT2(wall[themin].point2).y;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2014-08-31 11:15:19 +00:00
|
|
|
if (y2 <= y1 && y1 <= y0)
|
2014-08-08 20:02:53 +00:00
|
|
|
return CLOCKDIR_CW;
|
2014-08-31 11:15:19 +00:00
|
|
|
if (y0 <= y1 && y1 <= y2)
|
2014-08-08 20:02:53 +00:00
|
|
|
return CLOCKDIR_CCW;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
tempint = (x0-x1)*(y2-y1) - (x2-x1)*(y0-y1);
|
|
|
|
if (tempint < 0)
|
2014-08-08 20:02:53 +00:00
|
|
|
return CLOCKDIR_CW;
|
2006-04-24 19:04:22 +00:00
|
|
|
else
|
2014-08-08 20:02:53 +00:00
|
|
|
return CLOCKDIR_CCW;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static void flipwalls(int16_t numwalls, int16_t newnumwalls)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-05-15 22:37:24 +00:00
|
|
|
int32_t i, j, nume;
|
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;
|
2011-05-15 22:37:24 +00:00
|
|
|
|
|
|
|
swapshort(&onextwall[i], &onextwall[j]);
|
|
|
|
|
|
|
|
swaplong(&wall[i].x, &wall[j].x);
|
|
|
|
swaplong(&wall[i].y, &wall[j].y);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2013-01-16 20:38:46 +00:00
|
|
|
static void do_insertpoint(int32_t w, int32_t dax, int32_t day, int32_t *mapwallnum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2013-01-16 20:38:46 +00:00
|
|
|
int32_t i;
|
|
|
|
const int32_t sucksect = sectorofwall(w);
|
|
|
|
const uint32_t lenbyrep = getlenbyrep(wallength(w), wall[w].xrepeat);
|
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
|
|
|
|
2013-01-16 20:38:46 +00:00
|
|
|
if (mapwallnum && *mapwallnum >= w+1)
|
2011-11-25 09:51:53 +00:00
|
|
|
(*mapwallnum)++;
|
2013-01-16 20:38:46 +00:00
|
|
|
|
|
|
|
movewalls(w+1, +1);
|
|
|
|
Bmemcpy(&wall[w+1], &wall[w], sizeof(walltype));
|
2011-04-14 20:48:08 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2013-01-16 20:38:46 +00:00
|
|
|
wall[w+1].cstat &= ~(1<<14);
|
2011-04-14 20:48:08 +00:00
|
|
|
#endif
|
2013-01-16 20:38:46 +00:00
|
|
|
wall[w].point2 = w+1;
|
|
|
|
wall[w+1].x = dax;
|
|
|
|
wall[w+1].y = day;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2013-01-16 20:38:46 +00:00
|
|
|
fixxrepeat(w, lenbyrep);
|
|
|
|
AlignWallPoint2(w);
|
|
|
|
fixxrepeat(w+1, lenbyrep);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2013-01-16 20:38:46 +00:00
|
|
|
// Returns number of points inserted (1; or 2 if wall had a nextwall).
|
|
|
|
// *mapwallnum is set to the new wallnum of the former (pre-insertpoint) *mapwallnum
|
|
|
|
// (the new one can only be >= than the old one; ptr may be NULL if we don't care)
|
|
|
|
static int32_t insertpoint(int16_t linehighlight, int32_t dax, int32_t day, int32_t *mapwallnum)
|
|
|
|
{
|
|
|
|
int32_t j = linehighlight;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2013-01-16 20:38:46 +00:00
|
|
|
do_insertpoint(j, dax, day, mapwallnum);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2013-01-16 20:38:46 +00:00
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
{
|
|
|
|
int32_t k = wall[j].nextwall;
|
|
|
|
|
|
|
|
do_insertpoint(k, dax, day, mapwallnum);
|
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;
|
2011-10-30 19:47:58 +00:00
|
|
|
|
|
|
|
return 2;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-10-30 19:47:58 +00:00
|
|
|
|
|
|
|
return 1;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2012-04-08 15:52:49 +00:00
|
|
|
// runi: 0=check (forbidden), 1=prepare, 2=do!
|
|
|
|
static void deletepoint(int16_t point, int32_t runi)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-05-02 16:58:11 +00:00
|
|
|
int32_t i, j, sucksect;
|
|
|
|
|
2012-04-08 15:52:49 +00:00
|
|
|
Bassert(runi != 0);
|
2011-05-02 16:58:11 +00:00
|
|
|
|
2012-04-08 15:52:49 +00:00
|
|
|
if (runi==1)
|
2011-05-02 16:58:11 +00:00
|
|
|
{
|
|
|
|
i = wall[point].nextwall;
|
|
|
|
if (i >= 0)
|
|
|
|
{
|
|
|
|
NEXTWALL(i).nextwall = NEXTWALL(i).nextsector = -1;
|
|
|
|
wall[i].nextwall = wall[i].nextsector = -1;
|
|
|
|
}
|
|
|
|
|
2012-04-08 15:52:49 +00:00
|
|
|
return;
|
2011-05-02 16:58:11 +00:00
|
|
|
}
|
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);
|
2011-05-02 16:58:11 +00:00
|
|
|
wall[j].point2 = wall[point].point2;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-05-02 16:58:11 +00:00
|
|
|
#if 0
|
2006-04-24 19:04:22 +00:00
|
|
|
if (wall[j].nextwall >= 0)
|
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
NEXTWALL(j).nextwall = -1;
|
|
|
|
NEXTWALL(j).nextsector = -1;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
if (wall[point].nextwall >= 0)
|
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
NEXTWALL(point).nextwall = -1;
|
|
|
|
NEXTWALL(point).nextsector = -1;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-05-02 16:58:11 +00:00
|
|
|
#endif
|
2011-02-24 20:40:27 +00:00
|
|
|
movewalls(point, -1);
|
|
|
|
|
2011-05-02 16:58:11 +00:00
|
|
|
// checksectorpointer(j, sucksect);
|
|
|
|
|
2012-04-08 15:52:49 +00:00
|
|
|
return;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static 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]);
|
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
|
|
|
|
2011-05-22 21:52:22 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_setbunches(sucksect, -1, -1);
|
|
|
|
#endif
|
|
|
|
|
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];
|
2011-02-24 20:40:27 +00:00
|
|
|
changespritesect(k, i);
|
2006-04-24 19:04:22 +00:00
|
|
|
k = nextk;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
Bmemcpy(§or[i], §or[i+1], sizeof(sectortype));
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[i].wallptr -= j;
|
|
|
|
}
|
|
|
|
numsectors--;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=startwall; i<=endwall; i++)
|
2011-05-22 21:52:22 +00:00
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
if (wall[i].nextwall >= 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
NEXTWALL(i).nextwall = -1;
|
|
|
|
NEXTWALL(i).nextsector = -1;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-05-22 21:52:22 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
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--;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2016-06-21 00:34:41 +00:00
|
|
|
return 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-11-11 20:05:29 +00:00
|
|
|
int32_t fixspritesectors(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2013-04-21 19:55:18 +00:00
|
|
|
int32_t i;
|
2011-11-11 20:05:29 +00:00
|
|
|
int32_t numfixedsprites = 0, printfirsttime = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numsectors-1; i>=0; i--)
|
2011-02-24 20:40:27 +00:00
|
|
|
if (sector[i].wallnum <= 0 || sector[i].wallptr >= numwalls)
|
2011-11-11 20:05:29 +00:00
|
|
|
{
|
2012-06-01 20:09:22 +00:00
|
|
|
// XXX: This is not the best course of action for
|
|
|
|
// such great corruption.
|
2011-02-24 20:40:27 +00:00
|
|
|
deletesector(i);
|
2012-06-01 20:09:22 +00:00
|
|
|
mkonwinvalid();
|
|
|
|
initprintf("NOTE: Deleted sector %d which had corrupt .wallnum or .wallptr\n", i);
|
2011-11-11 20:05:29 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
if (m32_script_expertmode)
|
2011-11-11 20:05:29 +00:00
|
|
|
return 0;
|
2011-03-13 11:59:32 +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)
|
|
|
|
{
|
2013-04-21 19:55:18 +00:00
|
|
|
const int32_t dax=sprite[i].x, day=sprite[i].y;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (inside(dax,day,sprite[i].sectnum) != 1)
|
|
|
|
{
|
2013-04-21 19:55:18 +00:00
|
|
|
int32_t j, cz, fz;
|
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
spriteoncfz(i, &cz, &fz);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<numsectors; j++)
|
2011-03-23 17:41:01 +00:00
|
|
|
{
|
2013-06-22 11:31:15 +00:00
|
|
|
if (cz <= sprite[i].z && sprite[i].z <= fz && inside(dax,day, j) == 1)
|
2011-02-24 20:40:27 +00:00
|
|
|
{
|
2013-06-22 11:31:15 +00:00
|
|
|
if (fixmaponsave_sprites || (unsigned)sprite[i].sectnum >= numsectors+0u)
|
2011-11-11 20:05:29 +00:00
|
|
|
{
|
|
|
|
if (printfirsttime == 0)
|
|
|
|
{
|
|
|
|
initprintf("--------------------\n");
|
|
|
|
printfirsttime = 1;
|
|
|
|
}
|
2014-11-25 21:08:58 +00:00
|
|
|
initprintf("Changed sectnum of sprite #%d from %d to %d\n",
|
2013-04-21 19:55:18 +00:00
|
|
|
i, TrackerCast(sprite[i].sectnum), j);
|
2013-06-22 11:31:15 +00:00
|
|
|
|
2011-11-11 20:05:29 +00:00
|
|
|
changespritesect(i, j);
|
2013-06-22 11:31:15 +00:00
|
|
|
numfixedsprites++;
|
2011-11-11 20:05:29 +00:00
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-03-23 17:41:01 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-11 20:05:29 +00:00
|
|
|
|
|
|
|
return numfixedsprites;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static 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++)
|
2011-02-24 20:40:27 +00:00
|
|
|
Bmemcpy(&wall[i], &wall[i-offs], sizeof(walltype));
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else if (offs > 0) //Insert
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=numwalls+offs-1; i>=start+offs; i--)
|
2011-02-24 20:40:27 +00:00
|
|
|
Bmemcpy(&wall[i], &wall[i-offs], sizeof(walltype));
|
2011-10-30 19:47:58 +00:00
|
|
|
|
|
|
|
if (ovh.bak_wallsdrawn > 0)
|
|
|
|
{
|
|
|
|
if (ovh.suckwall >= start)
|
|
|
|
ovh.suckwall += offs;
|
|
|
|
if (ovh.splitstartwall >= start)
|
|
|
|
ovh.splitstartwall += offs;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
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;
|
|
|
|
}
|
2011-04-11 22:28:58 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
yax_tweakwalls(start, offs);
|
|
|
|
#endif
|
2011-02-24 20:40:27 +00:00
|
|
|
|
2016-06-21 00:34:41 +00:00
|
|
|
return 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-02-25 22:10:25 +00:00
|
|
|
int32_t wallength(int16_t i)
|
|
|
|
{
|
|
|
|
int64_t dax = POINT2(i).x - wall[i].x;
|
|
|
|
int64_t day = POINT2(i).y - wall[i].y;
|
|
|
|
#if 1 //def POLYMOST
|
|
|
|
int64_t hypsq = dax*dax + day*day;
|
2011-05-15 22:37:24 +00:00
|
|
|
if (hypsq > (int64_t)INT32_MAX)
|
2011-02-25 22:10:25 +00:00
|
|
|
return (int32_t)sqrt((double)hypsq);
|
|
|
|
else
|
2012-07-01 22:11:14 +00:00
|
|
|
return ksqrt((uint32_t)hypsq);
|
2011-02-25 22:10:25 +00:00
|
|
|
#else
|
|
|
|
return ksqrt(dax*dax + day*day);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void fixrepeats(int16_t i)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
int32_t dist = wallength(i);
|
|
|
|
int32_t day = wall[i].yrepeat;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
wall[i].xrepeat = clamp(mulscale10(dist,day), 1, 255);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-05-07 18:23:34 +00:00
|
|
|
uint32_t getlenbyrep(int32_t len, int32_t repeat)
|
|
|
|
{
|
|
|
|
if (repeat <= 0)
|
|
|
|
return ((uint32_t)len)<<12;
|
|
|
|
|
|
|
|
return divscale12(len, repeat);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fixxrepeat(int16_t wallnum, uint32_t lenrepquot) // lenrepquot: divscale12(wallength,xrepeat)
|
2011-02-25 22:10:25 +00:00
|
|
|
{
|
|
|
|
if (lenrepquot != 0)
|
2011-03-17 23:37:38 +00:00
|
|
|
{
|
2011-05-07 18:23:34 +00:00
|
|
|
uint32_t res = (((wallength(wallnum)<<12)+(1<<11))/lenrepquot);
|
|
|
|
wall[wallnum].xrepeat = clamp(res, 1, 255);
|
2011-03-17 23:37:38 +00:00
|
|
|
}
|
2011-02-25 22:10:25 +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)
|
|
|
|
{
|
2010-05-22 14:04:47 +00:00
|
|
|
int32_t y = overridepm16y<0 ? STATUS2DSIZ : overridepm16y;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoBeginDrawing();
|
2010-05-22 14:04:47 +00:00
|
|
|
CLEARLINES2D(ydim-y+25, STATUS2DSIZ+2-(25<<1), 0);
|
2018-04-12 21:02:51 +00:00
|
|
|
videoEndDrawing();
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static void clearministatbar16(void)
|
2009-05-01 19:28:57 +00:00
|
|
|
{
|
2015-07-09 05:58:00 +00:00
|
|
|
int32_t i, col = editorcolors[25];
|
2010-05-22 14:04:47 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoBeginDrawing();
|
2009-05-01 19:28:57 +00:00
|
|
|
|
2015-07-08 03:34:46 +00:00
|
|
|
for (i=ydim-STATUS2DSIZ2; i<ydim; i+=2)
|
2009-05-01 19:28:57 +00:00
|
|
|
{
|
|
|
|
// drawline256(0, i<<12, xdim<<12, i<<12, col);
|
2010-05-22 14:04:47 +00:00
|
|
|
CLEARLINES2D(i, 1, (col<<24)|(col<<16)|(col<<8)|col);
|
2015-07-08 03:34:46 +00:00
|
|
|
CLEARLINES2D(i+1, 1, (col<<24)|(col<<16)|(col<<8)|col);
|
2009-05-01 19:28:57 +00:00
|
|
|
col--;
|
|
|
|
if (col <= 0) break;
|
|
|
|
}
|
|
|
|
|
2010-05-22 14:04:47 +00:00
|
|
|
CLEARLINES2D(i, ydim-i, 0);
|
2009-05-01 19:28:57 +00:00
|
|
|
|
2011-07-09 17:36:02 +00:00
|
|
|
if (xdim >= 800)
|
|
|
|
{
|
2014-07-28 06:43:16 +00:00
|
|
|
Bsnprintf(tempbuf, sizeof(tempbuf), "%s %s", AppProperName, CallExtGetVer());
|
2011-07-09 17:36:02 +00:00
|
|
|
printext16(xdim2d-(Bstrlen(tempbuf)<<3)-3, ydim2d-STATUS2DSIZ2+10, editorcolors[4],-1, tempbuf, 0);
|
|
|
|
printext16(xdim2d-(Bstrlen(tempbuf)<<3)-2, ydim2d-STATUS2DSIZ2+9, editorcolors[12],-1, tempbuf, 0);
|
|
|
|
}
|
2009-05-01 19:28:57 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoEndDrawing();
|
2009-05-01 19:28:57 +00:00
|
|
|
}
|
|
|
|
|
2014-08-08 20:02:53 +00:00
|
|
|
// <startwall> has to be the starting wall of a loop!
|
|
|
|
//
|
|
|
|
// Assuming that <startwall> indicates a CW (outer) loop, the return value can
|
|
|
|
// be seen as a boolean of whether (x,y) is inside it.
|
|
|
|
//
|
|
|
|
// XXX: this function suffers from asymmetry issues in degenerate cases,
|
|
|
|
// similar to how inside() did before r3898.
|
2014-08-08 20:02:54 +00:00
|
|
|
int32_t loopinside(int32_t x, int32_t y, int16_t startwall)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:41:21 +00:00
|
|
|
bssize_t cnt = clockdir(startwall);
|
2014-08-08 20:02:53 +00:00
|
|
|
int32_t i = startwall;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
do
|
|
|
|
{
|
2014-08-08 20:02:53 +00:00
|
|
|
int32_t x1 = wall[i].x;
|
|
|
|
int32_t x2 = POINT2(i).x;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2014-08-08 20:02:53 +00:00
|
|
|
if (x <= x1 || x <= x2)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2014-08-08 20:02:53 +00:00
|
|
|
int32_t y1 = wall[i].y;
|
|
|
|
int32_t y2 = POINT2(i).y;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (y1 > y2)
|
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
swaplong(&x1, &x2);
|
|
|
|
swaplong(&y1, &y2);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2014-08-08 20:02:53 +00:00
|
|
|
|
|
|
|
if (y1 <= y && y < y2)
|
2014-08-16 18:32:47 +00:00
|
|
|
if ((uint64_t)x1*(y-y2) + (uint64_t)x2*(y1-y) <= (uint64_t)x*(y1-y2))
|
2006-04-24 19:04:22 +00:00
|
|
|
cnt ^= 1;
|
|
|
|
}
|
2014-08-08 20:02:53 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
i = wall[i].point2;
|
|
|
|
}
|
|
|
|
while (i != startwall);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2014-08-08 20:02:53 +00:00
|
|
|
return cnt;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
#if 0
|
|
|
|
static 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++;
|
2016-06-21 00:34:41 +00:00
|
|
|
return numloops;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-04-17 17:01:20 +00:00
|
|
|
int32_t getnumber_internal1(char ch, int32_t *danumptr, int32_t maxnumber, char sign)
|
2011-03-13 11:59:32 +00:00
|
|
|
{
|
|
|
|
int32_t danum = *danumptr;
|
|
|
|
|
|
|
|
if (ch >= '0' && ch <= '9')
|
|
|
|
{
|
|
|
|
int64_t nbig;
|
|
|
|
if (danum >= 0)
|
|
|
|
{
|
|
|
|
nbig = ((int64_t)danum*10)+(ch-'0');
|
|
|
|
if (nbig <= (int64_t)maxnumber) danum = nbig;
|
|
|
|
}
|
|
|
|
else if (sign) // this extra check isn't hurting anything
|
|
|
|
{
|
|
|
|
nbig = ((int64_t)danum*10)-(ch-'0');
|
|
|
|
if (nbig >= (int64_t)(-maxnumber)) danum = nbig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ch == 8 || ch == 127) // backspace
|
|
|
|
{
|
|
|
|
danum /= 10;
|
|
|
|
}
|
|
|
|
else if (ch == 13)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (ch == '-' && sign) // negate
|
|
|
|
{
|
|
|
|
danum = -danum;
|
|
|
|
}
|
|
|
|
|
|
|
|
*danumptr = danum;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-17 17:01:20 +00:00
|
|
|
int32_t getnumber_autocomplete(const char *namestart, char ch, int32_t *danum, int32_t flags)
|
|
|
|
{
|
|
|
|
if (flags!=1 && flags!=2)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (flags==2 && *danum<0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (isalpha(ch))
|
|
|
|
{
|
|
|
|
char b[2];
|
|
|
|
const char *gotstr;
|
|
|
|
int32_t i, diddel;
|
|
|
|
|
|
|
|
b[0] = ch;
|
|
|
|
b[1] = 0;
|
|
|
|
gotstr = getstring_simple(namestart, b, (flags==1)?sizeof(names[0])-1:TAGLAB_MAX-1, flags);
|
|
|
|
if (!gotstr || !gotstr[0])
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (flags==1)
|
|
|
|
{
|
|
|
|
for (i=0; i<MAXTILES; i++)
|
|
|
|
if (!Bstrcasecmp(names[i], gotstr))
|
|
|
|
{
|
|
|
|
*danum = i;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i = taglab_gettag(gotstr);
|
|
|
|
//initprintf("taglab: s=%s, i=%d\n",gotstr,i);
|
|
|
|
if (i > 0)
|
|
|
|
{
|
|
|
|
*danum = i;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// insert new tag
|
|
|
|
if (*danum > 0 && *danum<32768)
|
|
|
|
{
|
|
|
|
diddel = taglab_add(gotstr, *danum);
|
2012-03-26 05:05:57 +00:00
|
|
|
message("Added label \"%s\" for tag %d%s%s", gotstr, *danum,
|
2011-04-17 17:01:20 +00:00
|
|
|
diddel?", deleting old ":"",
|
|
|
|
(!diddel)?"":(diddel==1?"label":"tag"));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (*danum==0)
|
|
|
|
{
|
2014-05-06 22:15:19 +00:00
|
|
|
i = taglab_getnextfreetag(NULL);
|
2011-04-17 17:01:20 +00:00
|
|
|
if (i >= 1)
|
|
|
|
{
|
|
|
|
*danum = i;
|
|
|
|
diddel = taglab_add(gotstr, *danum);
|
2012-03-26 05:05:57 +00:00
|
|
|
message("%sadded label \"%s\" for tag %d%s%s",
|
2011-04-17 17:01:20 +00:00
|
|
|
diddel?"Auto-":"Automatically ", gotstr, *danum,
|
|
|
|
diddel?", deleting old ":"",
|
|
|
|
(!diddel)?"":(diddel==1?"label":"tag"));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-03 17:22:25 +00:00
|
|
|
// sign is now used for more than one flag (also _getnumber256):
|
2011-04-17 17:01:20 +00:00
|
|
|
// 1: sign
|
|
|
|
// 2: autocomplete names
|
|
|
|
// 4: autocomplete taglabels
|
2011-04-28 21:28:33 +00:00
|
|
|
// 8: return -1 if cancelled
|
2013-09-21 13:38:44 +00:00
|
|
|
int32_t _getnumber16(const char *namestart, int32_t num, int32_t maxnumber, char sign, const char *(func)(int32_t))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-08-03 17:22:25 +00:00
|
|
|
char buffer[80], ournamestart[80-17], ch;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t n, danum, oldnum;
|
2011-08-03 17:22:25 +00:00
|
|
|
uint8_t flags = (sign&(2|4|8))>>1;
|
2011-04-17 17:01:20 +00:00
|
|
|
sign &= 1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
danum = num;
|
2006-04-24 19:04:22 +00:00
|
|
|
oldnum = danum;
|
2011-03-13 11:59:32 +00:00
|
|
|
|
2011-08-03 17:22:25 +00:00
|
|
|
// need to have 4+11+2==17 chars room at the end
|
|
|
|
// ("^011", max. string length of an int32, "_ ")
|
2012-03-28 19:43:21 +00:00
|
|
|
Bstrncpyz(ournamestart, namestart, sizeof(ournamestart));
|
2011-08-03 17:22:25 +00:00
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
keyFlushChars();
|
2006-04-24 19:04:22 +00:00
|
|
|
while (keystatus[0x1] == 0)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
2011-03-13 11:59:32 +00:00
|
|
|
quitevent = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
idle();
|
2018-04-12 21:02:31 +00:00
|
|
|
ch = keyGetChar();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-08-03 17:22:25 +00:00
|
|
|
Bsprintf(buffer, "%s^011%d", ournamestart, danum);
|
|
|
|
n = Bstrlen(buffer); // maximum is 62+4+11 == 77
|
|
|
|
if (totalclock & 32)
|
|
|
|
Bstrcat(buffer,"_ ");
|
|
|
|
// max strlen now 79
|
2010-12-19 22:47:10 +00:00
|
|
|
_printmessage16("%s", buffer);
|
2009-05-01 06:35:27 +00:00
|
|
|
|
2008-09-06 06:22:31 +00:00
|
|
|
if (func != NULL)
|
|
|
|
{
|
2013-09-21 13:38:44 +00:00
|
|
|
Bsnprintf(buffer, sizeof(buffer), "%s", func(danum));
|
2009-05-01 06:35:27 +00:00
|
|
|
// printext16(200L-24, ydim-STATUS2DSIZ+20L, editorcolors[9], editorcolors[0], buffer, 0);
|
2011-04-17 17:01:20 +00:00
|
|
|
printext16(n<<3, ydim-STATUS2DSIZ+128, editorcolors[11], -1, buffer,0);
|
2008-09-06 06:22:31 +00:00
|
|
|
}
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-04-17 17:01:20 +00:00
|
|
|
n = 0;
|
|
|
|
if (getnumber_internal1(ch, &danum, maxnumber, sign) ||
|
2011-08-03 17:22:25 +00:00
|
|
|
(n=getnumber_autocomplete(ournamestart, ch, &danum, flags&(1+2))))
|
2011-04-17 17:01:20 +00:00
|
|
|
{
|
|
|
|
if (flags==1 || n==0)
|
|
|
|
printmessage16("%s", buffer);
|
|
|
|
if (danum != oldnum)
|
|
|
|
asksave = 1;
|
|
|
|
oldnum = danum;
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
2011-04-17 17:01:20 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-03-13 11:59:32 +00:00
|
|
|
|
2011-04-28 21:28:33 +00:00
|
|
|
if (keystatus[0x1] && (flags&4))
|
|
|
|
oldnum = -1;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
clearkeys();
|
2011-03-13 11:59:32 +00:00
|
|
|
|
|
|
|
return oldnum;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-05-22 21:52:22 +00:00
|
|
|
static void getnumber_clearline(void)
|
|
|
|
{
|
|
|
|
char cbuf[128];
|
|
|
|
int32_t i;
|
|
|
|
for (i=0; i<min(xdim>>3, (signed)sizeof(cbuf)-1); i++)
|
|
|
|
cbuf[i] = ' ';
|
|
|
|
cbuf[i] = 0;
|
|
|
|
printext256(0, 0, whitecol, 0, cbuf, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// sign: |16: don't draw scene
|
2013-09-21 13:38:44 +00:00
|
|
|
int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, char sign, const char *(func)(int32_t))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-08-03 17:22:25 +00:00
|
|
|
char buffer[80], ournamestart[80-13], ch;
|
2010-08-16 13:56:49 +00:00
|
|
|
int32_t danum, oldnum;
|
2011-08-03 17:22:25 +00:00
|
|
|
uint8_t flags = (sign&(2|4|8|16))>>1;
|
2011-04-17 17:01:20 +00:00
|
|
|
sign &= 1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
danum = num;
|
2006-04-24 19:04:22 +00:00
|
|
|
oldnum = danum;
|
2011-03-13 11:59:32 +00:00
|
|
|
|
2011-08-03 17:22:25 +00:00
|
|
|
// need to have 11+2==13 chars room at the end
|
|
|
|
// (max. string length of an int32, "_ ")
|
2012-03-28 19:43:21 +00:00
|
|
|
Bstrncpyz(ournamestart, namestart, sizeof(ournamestart));
|
2011-08-03 17:22:25 +00:00
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
keyFlushChars();
|
2006-04-24 19:04:22 +00:00
|
|
|
while (keystatus[0x1] == 0)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
if (handleevents())
|
2010-05-18 05:14:17 +00:00
|
|
|
quitevent = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-05-22 21:52:22 +00:00
|
|
|
if ((flags&8)==0)
|
2012-02-04 21:33:52 +00:00
|
|
|
M32_DrawRoomsAndMasks();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
ch = keyGetChar();
|
2011-03-13 11:59:32 +00:00
|
|
|
if (keystatus[0x1])
|
|
|
|
break;
|
2008-08-28 15:04:16 +00:00
|
|
|
clearkeys();
|
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
g_mouseBits = 0;
|
2008-09-03 14:02:42 +00:00
|
|
|
searchx = osearchx;
|
|
|
|
searchy = osearchy;
|
|
|
|
|
2013-12-20 07:24:09 +00:00
|
|
|
inputchecked = 1;
|
|
|
|
|
2011-05-22 21:52:22 +00:00
|
|
|
if ((flags&8)==0)
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtCheckKeys();
|
2011-05-22 21:52:22 +00:00
|
|
|
|
|
|
|
getnumber_clearline();
|
2008-08-28 15:04:16 +00:00
|
|
|
|
2011-08-03 17:22:25 +00:00
|
|
|
Bsprintf(buffer,"%s%d",ournamestart,danum);
|
|
|
|
// max strlen now 66+11==77
|
|
|
|
if (totalclock & 32)
|
|
|
|
Bstrcat(buffer,"_ ");
|
|
|
|
// max strlen now 79
|
2008-09-03 14:02:42 +00:00
|
|
|
printmessage256(0, 0, buffer);
|
2008-09-06 06:22:31 +00:00
|
|
|
if (func != NULL)
|
|
|
|
{
|
2013-09-21 13:38:44 +00:00
|
|
|
Bsnprintf(buffer, sizeof(buffer), "%s", func(danum));
|
2008-09-06 06:22:31 +00:00
|
|
|
printmessage256(0, 9, buffer);
|
|
|
|
}
|
2008-10-20 04:00:00 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-04-17 17:01:20 +00:00
|
|
|
if (getnumber_internal1(ch, &danum, maxnumber, sign) ||
|
2011-08-03 17:22:25 +00:00
|
|
|
getnumber_autocomplete(ournamestart, ch, &danum, flags&(1+2)))
|
2011-04-17 17:01:20 +00:00
|
|
|
{
|
|
|
|
if (danum != oldnum)
|
|
|
|
asksave = 1;
|
|
|
|
oldnum = danum;
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
2011-04-17 17:01:20 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-03-13 11:59:32 +00:00
|
|
|
|
2011-08-03 17:22:25 +00:00
|
|
|
if (keystatus[0x1] && (flags&4))
|
|
|
|
oldnum = -1;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
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
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
return oldnum;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-08-14 21:32:28 +00:00
|
|
|
// querystr: e.g. "Name: ", must be !=NULL
|
|
|
|
// defaultstr: can be NULL
|
|
|
|
// NO overflow checks are done when copying them!
|
|
|
|
// maxlen: maximum length of entry string, if ==1, enter single char
|
2011-04-17 17:01:20 +00:00
|
|
|
// completion: 0=none, 1=names[][], 2=taglabels
|
|
|
|
const char *getstring_simple(const char *querystr, const char *defaultstr, int32_t maxlen, int32_t completion)
|
2010-08-14 21:32:28 +00:00
|
|
|
{
|
|
|
|
static char buf[128];
|
2011-04-17 17:01:20 +00:00
|
|
|
int32_t ei=0, qrylen=0, maxidx, havecompl=0;
|
2010-08-14 21:32:28 +00:00
|
|
|
char ch;
|
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
keyFlushChars();
|
2010-08-14 21:32:28 +00:00
|
|
|
clearkeys();
|
|
|
|
|
|
|
|
Bmemset(buf, 0, sizeof(buf));
|
|
|
|
|
|
|
|
qrylen = Bstrlen(querystr);
|
|
|
|
Bmemcpy(buf, querystr, qrylen);
|
|
|
|
|
2011-04-17 17:01:20 +00:00
|
|
|
if (maxlen==0)
|
|
|
|
maxlen = 64;
|
|
|
|
|
|
|
|
maxidx = min((signed)sizeof(buf), xdim>>3);
|
|
|
|
|
2010-08-14 21:32:28 +00:00
|
|
|
ei = qrylen;
|
|
|
|
|
|
|
|
if (defaultstr)
|
|
|
|
{
|
|
|
|
int32_t deflen = Bstrlen(defaultstr);
|
|
|
|
Bmemcpy(&buf[ei], defaultstr, deflen);
|
|
|
|
ei += deflen;
|
|
|
|
}
|
|
|
|
|
2011-04-17 17:01:20 +00:00
|
|
|
buf[ei] = '_';
|
|
|
|
buf[ei+1] = 0;
|
2010-08-14 21:32:28 +00:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
2013-05-30 09:13:32 +00:00
|
|
|
if (in3dmode())
|
2011-05-22 21:52:22 +00:00
|
|
|
getnumber_clearline();
|
2011-04-17 17:01:20 +00:00
|
|
|
|
2013-05-30 09:13:32 +00:00
|
|
|
if (in3dmode())
|
2011-04-17 17:01:20 +00:00
|
|
|
printext256(0, 0, whitecol, 0, buf, 0);
|
|
|
|
else
|
|
|
|
_printmessage16("%s", buf);
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2010-08-14 21:32:28 +00:00
|
|
|
|
|
|
|
if (handleevents())
|
|
|
|
quitevent = 0;
|
|
|
|
|
2011-04-17 17:01:20 +00:00
|
|
|
idle();
|
2018-04-12 21:02:31 +00:00
|
|
|
ch = keyGetChar();
|
2010-08-14 21:32:28 +00:00
|
|
|
|
|
|
|
if (ch==13)
|
2010-08-16 13:56:49 +00:00
|
|
|
{
|
|
|
|
if (maxlen != 1)
|
|
|
|
buf[ei] = 0;
|
2010-08-14 21:32:28 +00:00
|
|
|
break;
|
2010-08-16 13:56:49 +00:00
|
|
|
}
|
2010-08-14 21:32:28 +00:00
|
|
|
else if (keystatus[1])
|
|
|
|
{
|
|
|
|
clearkeys();
|
2011-04-17 17:01:20 +00:00
|
|
|
return completion ? NULL : defaultstr;
|
2010-08-14 21:32:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (maxlen!=1)
|
|
|
|
{
|
2011-04-17 17:01:20 +00:00
|
|
|
// blink...
|
|
|
|
if (totalclock&32)
|
|
|
|
{
|
|
|
|
buf[ei] = '_';
|
|
|
|
buf[ei+1] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buf[ei] = 0;
|
|
|
|
}
|
|
|
|
|
2010-08-14 21:32:28 +00:00
|
|
|
if (ei>qrylen && (ch==8 || ch==127))
|
2010-08-16 13:56:49 +00:00
|
|
|
{
|
2011-04-17 17:01:20 +00:00
|
|
|
buf[ei--] = 0;
|
|
|
|
buf[ei] = '_';
|
|
|
|
havecompl = 0;
|
2010-08-16 13:56:49 +00:00
|
|
|
}
|
2011-04-17 17:01:20 +00:00
|
|
|
else if (ei<maxidx-2 && ei-qrylen<maxlen && isprint(ch))
|
2010-08-14 21:32:28 +00:00
|
|
|
{
|
2011-04-17 17:01:20 +00:00
|
|
|
if (completion==2 && ch==' ')
|
|
|
|
ch = '_';
|
2010-08-14 21:32:28 +00:00
|
|
|
buf[ei++] = ch;
|
2010-08-16 13:56:49 +00:00
|
|
|
buf[ei] = '_';
|
|
|
|
buf[ei+1] = 0;
|
2010-08-14 21:32:28 +00:00
|
|
|
}
|
2011-04-17 17:01:20 +00:00
|
|
|
|
|
|
|
if (completion && ((ei>qrylen && ch==9) || havecompl)) // tab: maybe do auto-completion
|
|
|
|
{
|
|
|
|
char cmpbuf[128];
|
|
|
|
char completions[3][16];
|
|
|
|
const char *cmpstr;
|
|
|
|
int32_t len=ei-qrylen, i, j, k=len, first=1, numcompl=0;
|
|
|
|
|
|
|
|
Bmemcpy(cmpbuf, &buf[qrylen], len);
|
|
|
|
cmpbuf[len] = 0;
|
|
|
|
|
|
|
|
for (i=(completion!=1); i<((completion==1)?MAXTILES:32768); i++)
|
|
|
|
{
|
|
|
|
cmpstr = (completion==1) ? names[i] : taglab_getlabel(i);
|
|
|
|
if (!cmpstr)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (Bstrncasecmp(cmpbuf, cmpstr, len) || Bstrlen(cmpstr)==(unsigned)len) // compare the prefix
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (ch==9)
|
|
|
|
{
|
|
|
|
if (first)
|
|
|
|
{
|
|
|
|
Bstrncpy(cmpbuf+len, cmpstr+len, sizeof(cmpbuf)-len);
|
|
|
|
cmpbuf[sizeof(cmpbuf)-1] = 0;
|
|
|
|
first = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (k=len; cmpstr[k] && cmpbuf[k] && Btolower(cmpstr[k])==Btolower(cmpbuf[k]); k++)
|
|
|
|
/* nop */;
|
|
|
|
cmpbuf[k] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numcompl<3)
|
|
|
|
{
|
2012-03-28 19:43:21 +00:00
|
|
|
Bstrncpyz(completions[numcompl], cmpstr+len, sizeof(completions[0]));
|
|
|
|
|
2011-04-17 17:01:20 +00:00
|
|
|
for (k=0; completions[numcompl][k]; k++)
|
|
|
|
completions[numcompl][k] = Btolower(completions[numcompl][k]);
|
|
|
|
numcompl++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (k=len; cmpbuf[k]; k++)
|
|
|
|
cmpbuf[k] = Btolower(cmpbuf[k]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ei = qrylen;
|
|
|
|
for (i=0; i<k && i<maxlen && ei<maxidx-2; i++)
|
|
|
|
buf[ei++] = cmpbuf[i];
|
|
|
|
|
|
|
|
if (k==len && numcompl>0) // no chars autocompleted/completion request
|
|
|
|
{
|
|
|
|
buf[ei] = '{';
|
|
|
|
buf[ei+1] = 0;
|
|
|
|
|
|
|
|
i = ei+1;
|
|
|
|
for (k=0; k<numcompl; k++)
|
|
|
|
{
|
|
|
|
j = 0;
|
|
|
|
while (i<maxidx-1 && completions[k][j])
|
|
|
|
buf[i++] = completions[k][j++];
|
|
|
|
if (i<maxidx-1)
|
|
|
|
buf[i++] = (k==numcompl-1) ? '}' : ',';
|
|
|
|
}
|
|
|
|
buf[i] = 0;
|
|
|
|
|
|
|
|
havecompl = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buf[ei] = '_';
|
|
|
|
buf[ei+1] = 0;
|
|
|
|
}
|
|
|
|
}
|
2010-08-14 21:32:28 +00:00
|
|
|
}
|
2011-01-16 02:50:27 +00:00
|
|
|
else
|
2010-08-14 21:32:28 +00:00
|
|
|
{
|
|
|
|
if (isalnum(ch) || ch==' ')
|
|
|
|
buf[ei] = Btoupper(ch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clearkeys();
|
|
|
|
|
|
|
|
return buf+qrylen;
|
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static int32_t getfilenames(const char *path, const char *kind)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2012-03-28 19:42:16 +00:00
|
|
|
const int32_t addflags = (!pathsearchmode && grponlymode ? CACHE1D_OPT_NOSTACK : 0);
|
|
|
|
|
|
|
|
fnlist_getnames(&fnlist, path, kind, addflags|CACHE1D_FIND_DRIVE, addflags);
|
|
|
|
|
|
|
|
finddirshigh = fnlist.finddirs;
|
|
|
|
findfileshigh = fnlist.findfiles;
|
|
|
|
currentlist = (findfileshigh != NULL);
|
|
|
|
|
2016-06-21 00:34:41 +00:00
|
|
|
return 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2013-05-12 18:51:16 +00:00
|
|
|
static void tweak_sboardfilename(void)
|
2008-05-15 03:16:38 +00:00
|
|
|
{
|
|
|
|
if (pathsearchmode)
|
|
|
|
Bcanonicalisefilename(selectedboardfilename, 1); // clips off the last token and compresses relative path
|
|
|
|
else
|
|
|
|
Bcorrectfilename(selectedboardfilename, 1);
|
2013-05-12 18:51:16 +00:00
|
|
|
}
|
2008-05-15 03:16:38 +00:00
|
|
|
|
2013-05-12 18:51:16 +00:00
|
|
|
////////// FILE SELECTION MENU //////////
|
|
|
|
|
|
|
|
static char g_oldpath[BMAX_PATH];
|
|
|
|
|
|
|
|
static void menuselect_try_findlast(void)
|
|
|
|
{
|
|
|
|
// PK 20080103: start with last selected map
|
2013-05-12 18:51:19 +00:00
|
|
|
const char *boardbasename = getbasefn(boardfilename);
|
2008-05-15 03:16:38 +00:00
|
|
|
|
|
|
|
for (; findfileshigh; findfileshigh=findfileshigh->next)
|
2013-05-12 18:51:16 +00:00
|
|
|
if (!Bstrcmp(findfileshigh->name, boardbasename))
|
2011-01-16 00:23:39 +00:00
|
|
|
break;
|
2008-05-15 03:16:38 +00:00
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
if (!findfileshigh)
|
2012-03-28 19:42:16 +00:00
|
|
|
findfileshigh = fnlist.findfiles;
|
2013-05-12 18:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// vvv PK ------------------------------------
|
|
|
|
// copied off menuselect
|
|
|
|
|
2015-07-08 03:34:46 +00:00
|
|
|
static int32_t menuselect_auto(int direction, int skip) // 20080104: jump to next (direction!=0) or prev (direction==0) file
|
2013-05-12 18:51:16 +00:00
|
|
|
{
|
|
|
|
Bstrcpy(selectedboardfilename, g_oldpath);
|
|
|
|
tweak_sboardfilename();
|
|
|
|
|
|
|
|
getfilenames(selectedboardfilename, "*.map");
|
|
|
|
if (fnlist.numfiles==0)
|
|
|
|
return -2;
|
|
|
|
|
|
|
|
menuselect_try_findlast();
|
2008-05-15 03:16:38 +00:00
|
|
|
|
2015-07-08 03:34:46 +00:00
|
|
|
do
|
2008-05-15 03:16:38 +00:00
|
|
|
{
|
2015-07-08 03:34:46 +00:00
|
|
|
if (direction)
|
|
|
|
{
|
|
|
|
if (findfileshigh->next)
|
|
|
|
findfileshigh=findfileshigh->next;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
2011-01-16 00:23:39 +00:00
|
|
|
else
|
2015-07-08 03:34:46 +00:00
|
|
|
{
|
|
|
|
if (findfileshigh->prev)
|
|
|
|
findfileshigh=findfileshigh->prev;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} while (skip--);
|
2008-05-15 03:16:38 +00:00
|
|
|
|
|
|
|
Bstrcat(selectedboardfilename, findfileshigh->name);
|
|
|
|
|
2013-05-12 18:51:16 +00:00
|
|
|
return 0;
|
2008-05-15 03:16:38 +00:00
|
|
|
}
|
|
|
|
// ^^^ PK ------------------------------------
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static int32_t menuselect(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2010-07-03 08:53:57 +00:00
|
|
|
int32_t listsize;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2013-05-12 18:51:16 +00:00
|
|
|
char ch, buffer[96];
|
|
|
|
const int32_t bakpathsearchmode = pathsearchmode;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2013-05-12 18:51:16 +00:00
|
|
|
Bstrcpy(selectedboardfilename, g_oldpath);
|
|
|
|
tweak_sboardfilename();
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
getfilenames(selectedboardfilename, "*.map");
|
|
|
|
|
2013-05-12 18:51:16 +00:00
|
|
|
menuselect_try_findlast();
|
2008-05-15 03:16:38 +00:00
|
|
|
|
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
|
|
|
|
2009-05-01 06:35:27 +00:00
|
|
|
ydim16 = ydim-STATUS2DSIZ2;
|
2010-07-03 08:53:57 +00:00
|
|
|
listsize = (ydim16-32)/9;
|
2009-05-01 06:35:27 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
do
|
|
|
|
{
|
2018-04-12 21:02:51 +00:00
|
|
|
videoBeginDrawing(); //{{{
|
2010-05-22 14:04:47 +00:00
|
|
|
|
|
|
|
CLEARLINES2D(0, ydim16, 0);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (pathsearchmode)
|
2011-01-16 00:23:39 +00:00
|
|
|
Bstrcpy(buffer,"Local filesystem mode. Ctrl-F: game filesystem");
|
2007-12-12 17:42:14 +00:00
|
|
|
else
|
2013-05-12 18:51:16 +00:00
|
|
|
Bsnprintf(buffer, sizeof(buffer),
|
|
|
|
"Game filesystem %smode. Ctrl-F: local filesystem, Ctrl-G: %s",
|
|
|
|
grponlymode?"GRP-only ":"", grponlymode?"all files":"GRP contents only");
|
2010-05-18 05:14:17 +00:00
|
|
|
|
|
|
|
printext16(halfxdim16-(8*Bstrlen(buffer)/2), 4, editorcolors[12],editorcolors[0],buffer,0);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2013-05-12 18:51:16 +00:00
|
|
|
Bsnprintf(buffer, sizeof(buffer), "(%d dirs, %d files) %s",
|
2012-03-28 19:42:16 +00:00
|
|
|
fnlist.numdirs, fnlist.numfiles, selectedboardfilename);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
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)
|
|
|
|
{
|
2013-05-12 18:51:16 +00:00
|
|
|
const CACHE1D_FIND_REC *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
|
2010-05-22 14:04:47 +00:00
|
|
|
Bmemset(buffer,0,sizeof(buffer));
|
2009-02-02 01:49:14 +00:00
|
|
|
Bstrncpy(buffer,dir->name,25);
|
2010-05-18 05:14:17 +00:00
|
|
|
if (Bstrlen(buffer) == 25)
|
2006-04-24 19:04:22 +00:00
|
|
|
buffer[21] = buffer[22] = buffer[23] = '.', buffer[24] = 0;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (dir == finddirshigh)
|
|
|
|
{
|
2009-05-06 23:58:53 +00:00
|
|
|
if (currentlist == 0) printext16(8,16+9*i,editorcolors[c|8],editorcolors[0],"->",0);
|
|
|
|
printext16(32,16+9*i,editorcolors[c|8],editorcolors[0],buffer,0);
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-05-06 23:58:53 +00:00
|
|
|
printext16(32,16+9*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)
|
|
|
|
{
|
2013-05-12 18:51:16 +00:00
|
|
|
const CACHE1D_FIND_REC *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;
|
|
|
|
}
|
2013-05-12 18:51:16 +00:00
|
|
|
for (i=0; (i<listsize && dir); i++, dir=dir->next)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
if (dir == findfileshigh)
|
|
|
|
{
|
2009-05-06 23:58:53 +00:00
|
|
|
if (currentlist == 1) printext16(240,16+9*i,editorcolors[7|8],editorcolors[0],"->",0);
|
|
|
|
printext16(240+24,16+9*i,editorcolors[7|8],editorcolors[0],dir->name,0);
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-05-06 23:58:53 +00:00
|
|
|
printext16(240+24,16+9*i,editorcolors[7],editorcolors[0],dir->name,0);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-20 10:52:33 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoEndDrawing(); //}}}
|
|
|
|
videoShowFrame(1);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
keystatus[0xcb] = 0;
|
|
|
|
keystatus[0xcd] = 0;
|
|
|
|
keystatus[0xc8] = 0;
|
|
|
|
keystatus[0xd0] = 0;
|
|
|
|
keystatus[0x1c] = 0; //enter
|
2014-07-06 00:11:01 +00:00
|
|
|
keystatus[0x0e] = 0; //backspace
|
2006-04-24 19:04:22 +00:00
|
|
|
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;
|
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2007-01-12 05:49:09 +00:00
|
|
|
idle();
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
ch = keyGetChar();
|
2011-01-16 00:23:39 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
// JBF 20040208: seek to first name matching pressed character
|
2012-03-28 19:42:16 +00:00
|
|
|
CACHE1D_FIND_REC *seeker = currentlist ? fnlist.findfiles : fnlist.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;
|
2011-01-16 00:23:39 +00:00
|
|
|
if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
|
|
|
|
(ch >= '0' && ch <= '9') || (ch=='_')))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2011-01-16 00:23:39 +00:00
|
|
|
#ifdef _WIN32
|
2006-04-13 20:47:06 +00:00
|
|
|
if (ch >= 'a') ch -= ('a'-'A');
|
2011-01-16 00:23:39 +00:00
|
|
|
#endif
|
2007-12-12 17:42:14 +00:00
|
|
|
while (seeker)
|
|
|
|
{
|
2006-04-13 20:47:06 +00:00
|
|
|
ch2 = seeker->name[0];
|
2011-01-16 00:23:39 +00:00
|
|
|
#ifdef _WIN32
|
2006-04-13 20:47:06 +00:00
|
|
|
if (ch2 >= 'a' && ch2 <= 'z') ch2 -= ('a'-'A');
|
2011-01-16 00:23:39 +00:00
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
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
|
|
|
}
|
2011-01-03 22:04:20 +00:00
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
if (ch==6) // Ctrl-F
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
currentlist = 0;
|
|
|
|
pathsearchmode = 1-pathsearchmode;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (pathsearchmode)
|
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
Bstrcpy(selectedboardfilename, "");
|
2006-04-24 19:04:22 +00:00
|
|
|
Bcanonicalisefilename(selectedboardfilename, 0);
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
else Bstrcpy(selectedboardfilename, "/");
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
getfilenames(selectedboardfilename, "*.map");
|
2013-05-12 18:51:16 +00:00
|
|
|
Bstrcpy(g_oldpath, selectedboardfilename);
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
2011-01-16 00:23:39 +00:00
|
|
|
else if (ch==7) // Ctrl-G
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
if (!pathsearchmode)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
grponlymode = 1-grponlymode;
|
|
|
|
getfilenames(selectedboardfilename, "*.map");
|
2013-05-12 18:51:16 +00:00
|
|
|
Bstrcpy(g_oldpath, selectedboardfilename);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else if (ch == 9)
|
|
|
|
{
|
2012-03-28 19:42:16 +00:00
|
|
|
if ((currentlist == 0 && fnlist.findfiles) || (currentlist == 1 && fnlist.finddirs))
|
2006-04-24 19:04:22 +00:00
|
|
|
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)
|
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
if (finddirshigh && finddirshigh->prev)
|
|
|
|
finddirshigh = finddirshigh->prev;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
if (findfileshigh && findfileshigh->prev)
|
|
|
|
findfileshigh = findfileshigh->prev;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
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)
|
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
if (finddirshigh && finddirshigh->next)
|
|
|
|
finddirshigh = finddirshigh->next;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
if (findfileshigh && findfileshigh->next)
|
|
|
|
findfileshigh = findfileshigh->next;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
2014-07-06 00:11:01 +00:00
|
|
|
else if (keystatus[0x0e]) // backspace
|
|
|
|
{
|
|
|
|
Bstrcat(selectedboardfilename, "../");
|
|
|
|
tweak_sboardfilename();
|
|
|
|
Bstrcpy(g_oldpath, selectedboardfilename);
|
|
|
|
getfilenames(selectedboardfilename, "*.map");
|
|
|
|
keystatus[0x0e] = 0;
|
|
|
|
}
|
2013-05-12 18:51:16 +00:00
|
|
|
else if (ch == 13 && currentlist == 0)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
if (finddirshigh->type == CACHE1D_FIND_DRIVE)
|
2010-05-18 05:14:17 +00:00
|
|
|
Bstrcpy(selectedboardfilename, finddirshigh->name);
|
2007-12-12 17:42:14 +00:00
|
|
|
else
|
2010-05-18 05:14:17 +00:00
|
|
|
Bstrcat(selectedboardfilename, finddirshigh->name);
|
|
|
|
|
|
|
|
Bstrcat(selectedboardfilename, "/");
|
2013-05-12 18:51:16 +00:00
|
|
|
tweak_sboardfilename();
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2013-05-12 18:51:16 +00:00
|
|
|
Bstrcpy(g_oldpath, selectedboardfilename);
|
2006-04-24 19:04:22 +00:00
|
|
|
//printf("Changing directories to: %s\n", selectedboardfilename);
|
|
|
|
|
2014-07-06 00:11:01 +00:00
|
|
|
if (finddirshigh == fnlist.finddirs)
|
|
|
|
{
|
|
|
|
getfilenames(selectedboardfilename, "*.map");
|
|
|
|
currentlist = 0;
|
|
|
|
}
|
|
|
|
else getfilenames(selectedboardfilename, "*.map");;
|
|
|
|
|
2016-06-05 04:46:28 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
ch = 0;
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoBeginDrawing();
|
2010-05-22 14:04:47 +00:00
|
|
|
CLEARLINES2D(0, ydim16, 0);
|
2018-04-12 21:02:51 +00:00
|
|
|
videoEndDrawing();
|
|
|
|
videoShowFrame(1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-01-03 22:04:20 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (ch == 13 && !findfileshigh) ch = 0;
|
|
|
|
}
|
2013-05-12 18:51:16 +00:00
|
|
|
while (ch != 13 && ch != 27);
|
2011-01-03 22:04:20 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (ch == 13)
|
|
|
|
{
|
|
|
|
Bstrcat(selectedboardfilename, findfileshigh->name);
|
|
|
|
//printf("Selected file: %s\n", selectedboardfilename);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2013-05-12 18:51:16 +00:00
|
|
|
return 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-01-03 22:04:20 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
pathsearchmode = bakpathsearchmode;
|
2011-01-03 22:04:20 +00:00
|
|
|
|
2013-05-12 18:51:16 +00:00
|
|
|
return -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2015-07-25 17:23:17 +00:00
|
|
|
#if 0
|
2011-06-04 00:06:08 +00:00
|
|
|
static inline int32_t imod(int32_t a, int32_t b)
|
|
|
|
{
|
2013-05-12 18:51:16 +00:00
|
|
|
if (a >= 0)
|
|
|
|
return a%b;
|
|
|
|
|
|
|
|
return ((a+1)%b)+b-1;
|
2011-06-04 00:06:08 +00:00
|
|
|
}
|
2015-07-25 17:23:17 +00:00
|
|
|
#endif
|
2011-06-04 00:06:08 +00:00
|
|
|
|
2015-10-31 15:13:32 +00:00
|
|
|
int32_t fillsector_maybetrans(int16_t sectnum, int32_t fillcolor, uint8_t dotrans)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2015-07-17 00:12:48 +00:00
|
|
|
if (sectnum == -1)
|
|
|
|
return 0;
|
|
|
|
|
2011-06-04 00:06:08 +00:00
|
|
|
int32_t x1, x2, y1, y2, sy, y, daminy;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t lborder, rborder, uborder, dborder, miny, maxy, dax;
|
|
|
|
int16_t z, zz, startwall, endwall, fillcnt;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-04-22 22:48:06 +00:00
|
|
|
char col;
|
|
|
|
|
2015-07-17 00:12:48 +00:00
|
|
|
if (fillcolor == -1)
|
|
|
|
col = editorcolors[14]-(M32_THROB>>1);
|
2011-04-22 22:48:06 +00:00
|
|
|
else
|
|
|
|
col = fillcolor;
|
2010-11-27 22:12:24 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
lborder = 0; rborder = xdim;
|
2011-06-04 00:06:08 +00:00
|
|
|
y = OSD_GetRowsCur();
|
|
|
|
uborder = (y>=0)?(y+1)*8:0; dborder = ydim16-STATUS2DSIZ2;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
miny = dborder-1;
|
|
|
|
maxy = uborder;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
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
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
editorGet2dScreenCoordinates(&x1,&y1, wall[z].x-pos.x,wall[z].y-pos.y, zoom);
|
2011-03-05 12:59:27 +00:00
|
|
|
if (m32_sideview)
|
|
|
|
y1 += getscreenvdisp(getflorzofslope(sectnum,wall[z].x,wall[z].y)-pos.z, zoom);
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2011-03-05 12:59:27 +00:00
|
|
|
x1 += halfxdim16;
|
|
|
|
y1 += midydim16;
|
|
|
|
|
|
|
|
if (m32_sideview)
|
|
|
|
{
|
2011-03-13 11:59:32 +00:00
|
|
|
tempxyar[z][0] = x1;
|
|
|
|
tempxyar[z][1] = y1;
|
2011-03-05 12:59:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
miny = min(miny, y1);
|
|
|
|
maxy = max(maxy, y1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (miny < uborder) miny = uborder;
|
|
|
|
if (maxy >= dborder) maxy = dborder-1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-07-17 00:12:48 +00:00
|
|
|
daminy = miny;// +2 - imod(miny+2, 3);
|
2011-06-04 00:06:08 +00:00
|
|
|
if (sector[sectnum].floorz > minhlsectorfloorz)
|
|
|
|
daminy++;
|
|
|
|
|
2010-11-27 22:12:24 +00:00
|
|
|
//+((totalclock>>2)&3)
|
2015-07-17 00:12:48 +00:00
|
|
|
for (sy=daminy; sy<=maxy; sy++) // JBF 20040116: numframes%3 -> (totalclock>>2)&3
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-02 21:21:47 +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
|
|
|
{
|
2011-03-05 12:59:27 +00:00
|
|
|
if (m32_sideview)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-13 11:59:32 +00:00
|
|
|
x1 = tempxyar[z][0];
|
|
|
|
y1 = tempxyar[z][1];
|
|
|
|
x2 = tempxyar[wall[z].point2][0];
|
|
|
|
y2 = tempxyar[wall[z].point2][1];
|
2011-03-05 12:59:27 +00:00
|
|
|
|
|
|
|
if (y1 > y2)
|
|
|
|
{
|
|
|
|
swaplong(&x1, &x2);
|
|
|
|
swaplong(&y1, &y2);
|
|
|
|
}
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2011-03-05 12:59:27 +00:00
|
|
|
if (y1 <= sy && sy < y2)
|
|
|
|
{
|
2014-03-22 09:25:15 +00:00
|
|
|
if (fillcnt == ARRAY_SIZE(fillist))
|
2011-03-05 12:59:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
x1 += scale(sy-y1, x2-x1, y2-y1);
|
|
|
|
fillist[fillcnt++] = x1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-05 12:59:27 +00:00
|
|
|
x1 = wall[z].x; x2 = POINT2(z).x;
|
|
|
|
y1 = wall[z].y; y2 = POINT2(z).y;
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2011-03-05 12:59:27 +00:00
|
|
|
if (y1 > y2)
|
|
|
|
{
|
|
|
|
swaplong(&x1, &x2);
|
|
|
|
swaplong(&y1, &y2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (y1 <= y && y < y2)
|
|
|
|
//if (x1*(y-y2) + x2*(y1-y) <= 0)
|
|
|
|
{
|
|
|
|
dax = x1 + scale(y-y1, x2-x1, y2-y1);
|
|
|
|
dax = halfxdim16 + (((dax-pos.x)*zoom)>>14);
|
|
|
|
if (dax >= lborder)
|
|
|
|
{
|
2014-03-22 09:25:15 +00:00
|
|
|
if (fillcnt == ARRAY_SIZE(fillist))
|
2011-03-05 12:59:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
fillist[fillcnt++] = dax;
|
|
|
|
}
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
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])
|
2011-03-02 21:21:47 +00:00
|
|
|
swaplong(&fillist[z], &fillist[zz]);
|
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
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
if (fillist[z] > rborder)
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
if (fillist[z+1] > rborder)
|
|
|
|
fillist[z+1] = rborder;
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
editorDraw2dLine(fillist[z]+1,sy, fillist[z+1]-1,sy, dotrans ? -col : col); //editorcolors[fillcolor]
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2016-06-21 00:34:41 +00:00
|
|
|
return 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
static int16_t whitelinescan(int16_t sucksect, int16_t dalinehighlight)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j, k;
|
2011-03-13 11:59:32 +00:00
|
|
|
int16_t tnewnumwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
if (numsectors >= MAXSECTORS)
|
|
|
|
return MAXWALLS+1;
|
|
|
|
|
|
|
|
Bmemcpy(§or[numsectors], §or[sucksect], sizeof(sectortype));
|
2006-04-24 19:04:22 +00:00
|
|
|
sector[numsectors].wallptr = numwalls;
|
|
|
|
sector[numsectors].wallnum = 0;
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
i = dalinehighlight;
|
2011-02-24 20:40:27 +00:00
|
|
|
tnewnumwalls = numwalls;
|
2006-04-24 19:04:22 +00:00
|
|
|
do
|
|
|
|
{
|
2011-02-24 20:40:27 +00:00
|
|
|
if (tnewnumwalls >= MAXWALLS)
|
|
|
|
return MAXWALLS+1;
|
|
|
|
|
|
|
|
j = lastwall(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
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
if (POINT2(k).x == wall[j].x && POINT2(k).y == wall[j].y)
|
|
|
|
if (wall[k].nextwall == -1)
|
|
|
|
{
|
|
|
|
j = k;
|
|
|
|
break;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
Bmemcpy(&wall[tnewnumwalls], &wall[i], sizeof(walltype));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
wall[tnewnumwalls].nextwall = j;
|
|
|
|
wall[tnewnumwalls].nextsector = sectorofwall(j);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
tnewnumwalls++;
|
2006-04-24 19:04:22 +00:00
|
|
|
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
|
|
|
|
2011-02-24 20:40:27 +00:00
|
|
|
for (i=numwalls; i<tnewnumwalls-1; i++)
|
2006-04-24 19:04:22 +00:00
|
|
|
wall[i].point2 = i+1;
|
2011-02-24 20:40:27 +00:00
|
|
|
wall[tnewnumwalls-1].point2 = numwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2014-01-28 19:03:47 +00:00
|
|
|
return (clockdir(numwalls) == CLOCKDIR_CCW) ? -1 : tnewnumwalls;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
//
|
|
|
|
// names.h loading
|
|
|
|
//
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
enum {
|
|
|
|
T_INCLUDE = 0,
|
|
|
|
T_DEFINE = 1,
|
2011-03-07 16:30:06 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
T_DUMMY,
|
|
|
|
};
|
2011-03-07 16:30:06 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
static int32_t parsenamesfile(scriptfile *script)
|
|
|
|
{
|
2015-11-14 17:21:15 +00:00
|
|
|
int32_t syms = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
tokenlist const tokens[] =
|
|
|
|
{
|
|
|
|
{ "include", T_INCLUDE },
|
|
|
|
{ "#include", T_INCLUDE },
|
|
|
|
{ "define", T_DEFINE },
|
|
|
|
{ "#define", T_DEFINE },
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
{ "dynamicremap", T_DUMMY },
|
|
|
|
};
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
while (1)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2015-11-01 19:56:22 +00:00
|
|
|
int32_t tokn = getatoken(script,tokens,ARRAY_SIZE(tokens));
|
|
|
|
char *cmdtokptr = script->ltextptr;
|
|
|
|
switch (tokn)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2015-11-01 19:56:22 +00:00
|
|
|
case T_INCLUDE:
|
|
|
|
{
|
|
|
|
char *fn;
|
|
|
|
if (scriptfile_getstring(script,&fn))
|
|
|
|
{
|
|
|
|
initprintf("Error: Malformed include on line %s:%d\n",
|
|
|
|
script->filename,scriptfile_getlinum(script,cmdtokptr));
|
|
|
|
break;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
scriptfile *included;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
included = scriptfile_fromfile(fn);
|
|
|
|
if (!included)
|
|
|
|
{
|
|
|
|
initprintf("Error: Failed including %s on line %s:%d\n",
|
|
|
|
fn, script->filename,scriptfile_getlinum(script,cmdtokptr));
|
|
|
|
break;
|
|
|
|
}
|
2011-08-20 23:28:14 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
initprintf("Including: %s\n", fn);
|
|
|
|
|
|
|
|
syms += parsenamesfile(included);
|
|
|
|
scriptfile_close(included);
|
|
|
|
|
|
|
|
break;
|
2011-08-20 23:28:14 +00:00
|
|
|
}
|
2015-11-01 19:56:22 +00:00
|
|
|
case T_DEFINE:
|
2011-08-20 23:28:14 +00:00
|
|
|
{
|
2015-11-01 19:56:22 +00:00
|
|
|
char *name;
|
|
|
|
int32_t number;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
if (scriptfile_getstring(script,&name))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2015-11-01 19:56:22 +00:00
|
|
|
initprintf("Error: Malformed define on line %s:%d\n",
|
|
|
|
script->filename, scriptfile_getlinum(script,cmdtokptr));
|
|
|
|
break;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
if (scriptfile_getsymbol(script,&number))
|
|
|
|
{
|
|
|
|
initprintf("Error: No number given for name \"%s\" on line %s:%d\n",
|
|
|
|
name, script->filename, scriptfile_getlinum(script,cmdtokptr));
|
|
|
|
break;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
if ((unsigned)number >= MAXTILES)
|
|
|
|
{
|
|
|
|
initprintf("Error: Constant %d for name \"%s\" out of range on line %s:%d\n",
|
|
|
|
number, name, script->filename, scriptfile_getlinum(script,cmdtokptr));
|
|
|
|
break;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
if (Bstrlen(name) > 24)
|
|
|
|
initprintf("Warning: Truncating name \"%s\" to 24 characters on line %s:%d\n",
|
|
|
|
name, script->filename, scriptfile_getlinum(script,cmdtokptr));
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
Bstrncpyz(names[number], name, 25);
|
|
|
|
name = names[number];
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
++syms;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
if (scriptfile_addsymbolvalue(name,number) < 0)
|
|
|
|
initprintf("Warning: Symbol %s was NOT redefined to %d on line %s:%d\n",
|
|
|
|
name, number, script->filename, scriptfile_getlinum(script,cmdtokptr));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_EOF:
|
|
|
|
return syms;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
return syms;
|
|
|
|
}
|
2011-08-20 23:28:14 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
static void loadnames(const char *namesfile)
|
|
|
|
{
|
|
|
|
scriptfile *script = scriptfile_fromfile(namesfile);
|
2011-08-20 23:28:14 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
if (!script)
|
|
|
|
return;
|
2011-08-20 23:28:14 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
initprintf("Loading names file: %s\n", namesfile);
|
2011-08-20 23:28:14 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
int32_t const syms = parsenamesfile(script);
|
|
|
|
initprintf("Loaded %d names.\n", syms);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-11-01 19:56:22 +00:00
|
|
|
scriptfile_close(script);
|
|
|
|
|
|
|
|
scriptfile_clearsymbols();
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2015-11-01 19:56:22 +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
|
|
|
{
|
2012-08-20 21:26:36 +00:00
|
|
|
char snotbuf[128];
|
2011-03-05 12:59:27 +00:00
|
|
|
int32_t i, m;
|
2011-03-23 17:41:01 +00:00
|
|
|
int32_t v8 = (numsectors > MAXSECTORSV7 || numwalls > MAXWALLSV7 ||
|
2012-03-14 22:30:24 +00:00
|
|
|
Numsprites > MAXSPRITESV7 || numyaxbunches > 0);
|
2011-08-20 11:54:16 +00:00
|
|
|
#if M32_UNDO
|
2009-05-05 20:01:23 +00:00
|
|
|
Bsprintf(snotbuf,"x:%d y:%d ang:%d r%d",posxe,posye,ange,map_revision-1);
|
2011-08-20 11:54:16 +00:00
|
|
|
#else
|
|
|
|
Bsprintf(snotbuf,"x:%d y:%d ang:%d",posxe,posye,ange);
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
i = 0;
|
2009-05-05 20:01:23 +00:00
|
|
|
while ((snotbuf[i] != 0) && (i < 33))
|
2006-04-24 19:04:22 +00:00
|
|
|
i++;
|
2009-05-05 20:01:23 +00:00
|
|
|
while (i < 33)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
snotbuf[i] = 32;
|
|
|
|
i++;
|
|
|
|
}
|
2009-05-05 20:01:23 +00:00
|
|
|
snotbuf[33] = 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
|
|
|
|
2011-03-05 12:59:27 +00:00
|
|
|
if (highlightcnt<=0 && highlightsectorcnt<=0)
|
|
|
|
{
|
2011-07-09 17:36:02 +00:00
|
|
|
m = Bsprintf(snotbuf,"%d/%d %s. %d",
|
|
|
|
numsectors, v8?MAXSECTORSV8:MAXSECTORSV7,
|
|
|
|
numyaxbunches>0 ? "SEC":"sec", numwalls);
|
|
|
|
if (numyaxbunches > 0)
|
|
|
|
{
|
|
|
|
if (xdim >= 800)
|
|
|
|
Bsprintf(&snotbuf[m], "/%d wal. %d/16k spr. %d/256 bn.",
|
2012-03-14 22:30:24 +00:00
|
|
|
MAXWALLSV8, Numsprites, numyaxbunches);
|
2011-07-09 17:36:02 +00:00
|
|
|
else
|
|
|
|
Bsprintf(&snotbuf[m], " wal. %d spr. %d/256 bn.",
|
2012-03-14 22:30:24 +00:00
|
|
|
Numsprites, numyaxbunches);
|
2011-07-09 17:36:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (xdim >= 800)
|
|
|
|
Bsprintf(&snotbuf[m], "/%d wal. %d/%d spr.",
|
2012-03-14 22:30:24 +00:00
|
|
|
v8?MAXWALLSV8:MAXWALLSV7, Numsprites,
|
2011-07-09 17:36:02 +00:00
|
|
|
v8?MAXSPRITESV8:MAXSPRITESV7);
|
|
|
|
else
|
|
|
|
Bsprintf(&snotbuf[m], "/%dk wal. %d/%dk spr.",
|
2012-03-14 22:30:24 +00:00
|
|
|
(v8?MAXWALLSV8:MAXWALLSV7)/1000, Numsprites,
|
2011-07-09 17:36:02 +00:00
|
|
|
(v8?MAXSPRITESV8:MAXSPRITESV7)/1000);
|
|
|
|
}
|
2011-03-05 12:59:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (highlightcnt>0)
|
|
|
|
{
|
|
|
|
m = 0;
|
|
|
|
for (i=0; i<highlightcnt; i++)
|
|
|
|
m += !!(highlight[i]&16384);
|
|
|
|
Bsprintf(snotbuf, "%d sprites, %d walls selected", m, highlightcnt-m);
|
|
|
|
}
|
|
|
|
else if (highlightsectorcnt>0)
|
2012-08-20 21:26:36 +00:00
|
|
|
{
|
|
|
|
int32_t ii=Bsprintf(snotbuf, "%d sectors with a total of %d walls selected",
|
|
|
|
highlightsectorcnt, numhlsecwalls);
|
|
|
|
if (m32_rotateang)
|
|
|
|
Bsprintf(&snotbuf[ii], " (ang=%d)", m32_rotateang);
|
|
|
|
}
|
2011-03-05 12:59:27 +00:00
|
|
|
else
|
2012-08-20 21:26:36 +00:00
|
|
|
{
|
2011-03-05 12:59:27 +00:00
|
|
|
snotbuf[0] = 0;
|
2012-08-20 21:26:36 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-07-09 17:36:02 +00:00
|
|
|
v8 = 1; // yellow color
|
2011-03-05 12:59:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m = xdim/8 - 264/8;
|
|
|
|
m = clamp(m, 1, (signed)sizeof(snotbuf)-1);
|
2008-10-31 10:08:51 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
i = 0;
|
2011-03-05 12:59:27 +00:00
|
|
|
while (snotbuf[i] && i < m)
|
2006-04-24 19:04:22 +00:00
|
|
|
i++;
|
2011-03-05 12:59:27 +00:00
|
|
|
while (i < m)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
snotbuf[i] = 32;
|
|
|
|
i++;
|
|
|
|
}
|
2011-03-05 12:59:27 +00:00
|
|
|
snotbuf[m] = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-03-05 12:59:27 +00:00
|
|
|
printext16(264, ydim-STATUS2DSIZ+128, v8?editorcolors[10]:whitecol, -1, snotbuf,0);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2012-11-15 14:28:04 +00:00
|
|
|
#define DOPRINT(Yofs, fmt, ...) do { \
|
2014-11-25 21:08:58 +00:00
|
|
|
Bsprintf(snotbuf, fmt, ## __VA_ARGS__); \
|
2012-11-15 14:28:04 +00:00
|
|
|
printext16(8+col*200, ydim/*-(row*96)*/-STATUS2DSIZ+Yofs, color, -1, snotbuf, 0); \
|
|
|
|
} while (0)
|
2010-05-22 14:04:47 +00:00
|
|
|
|
2010-08-17 20:00:44 +00:00
|
|
|
void showsectordata(int16_t sectnum, int16_t small)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
char snotbuf[80];
|
2010-05-22 14:04:47 +00:00
|
|
|
int32_t col=0; //,row = 0;
|
2010-08-17 20:00:44 +00:00
|
|
|
int32_t color = small ? whitecol : editorcolors[11];
|
2009-05-05 16:21:33 +00:00
|
|
|
|
2015-04-11 13:53:07 +00:00
|
|
|
const sectortype *const sec = §or[sectnum];
|
2010-05-02 23:27:30 +00:00
|
|
|
|
2010-08-17 20:00:44 +00:00
|
|
|
if (small)
|
2009-05-05 16:21:33 +00:00
|
|
|
{
|
2014-07-24 14:01:44 +00:00
|
|
|
_printmessage16("^10Sector %d %s ^O(F7 to edit)", sectnum, CallExtGetSectorCaption(sectnum));
|
2010-05-02 23:27:30 +00:00
|
|
|
return;
|
2009-05-05 16:21:33 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-05-22 14:04:47 +00:00
|
|
|
DOPRINT(32, "^10Sector %d", sectnum);
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(48, "Firstwall: %d", TrackerCast(sec->wallptr));
|
|
|
|
DOPRINT(56, "Numberofwalls: %d", TrackerCast(sec->wallnum));
|
2010-05-22 14:04:47 +00:00
|
|
|
DOPRINT(64, "Firstsprite: %d", headspritesect[sectnum]);
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(72, "Tags: %d, %d", TrackerCast(sec->hitag), TrackerCast(sec->lotag));
|
|
|
|
DOPRINT(80, " (0x%x), (0x%x)", TrackerCast(sec->hitag), TrackerCast(sec->lotag));
|
|
|
|
DOPRINT(88, "Extra: %d", TrackerCast(sec->extra));
|
|
|
|
DOPRINT(96, "Visibility: %d", TrackerCast(sec->visibility));
|
2010-05-22 14:04:47 +00:00
|
|
|
DOPRINT(104, "Pixel height: %d", (sec->floorz-sec->ceilingz)>>8);
|
2009-05-01 06:35:27 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
col++;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-05-22 14:04:47 +00:00
|
|
|
DOPRINT(32, "^10CEILING:^O");
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(48, "Flags (hex): %x", TrackerCast(sec->ceilingstat));
|
2011-03-23 17:41:01 +00:00
|
|
|
{
|
|
|
|
int32_t xp=sec->ceilingxpanning, yp=sec->ceilingypanning;
|
2013-04-09 17:35:11 +00:00
|
|
|
#ifdef YAX_ENABLE__COMPAT
|
2015-04-11 13:53:07 +00:00
|
|
|
if (yax_getbunch(sectnum, YAX_CEILING) >= 0)
|
2011-03-23 17:41:01 +00:00
|
|
|
xp = yp = 0;
|
|
|
|
#endif
|
|
|
|
DOPRINT(56, "(X,Y)pan: %d, %d", xp, yp);
|
|
|
|
}
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(64, "Shade byte: %d", TrackerCast(sec->ceilingshade));
|
|
|
|
DOPRINT(72, "Z-coordinate: %d", TrackerCast(sec->ceilingz));
|
|
|
|
DOPRINT(80, "Tile number: %d", TrackerCast(sec->ceilingpicnum));
|
|
|
|
DOPRINT(88, "Ceiling heinum: %d", TrackerCast(sec->ceilingheinum));
|
|
|
|
DOPRINT(96, "Palookup number: %d", TrackerCast(sec->ceilingpal));
|
2011-03-23 17:41:01 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
DOPRINT(104, "Bunch number: %d", yax_getbunch(sectnum, YAX_CEILING));
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
col++;
|
2009-05-01 06:35:27 +00:00
|
|
|
|
2010-05-22 14:04:47 +00:00
|
|
|
DOPRINT(32, "^10FLOOR:^O");
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(48, "Flags (hex): %x", TrackerCast(sec->floorstat));
|
2011-03-23 17:41:01 +00:00
|
|
|
{
|
|
|
|
int32_t xp=sec->floorxpanning, yp=sec->floorypanning;
|
2013-04-09 17:35:11 +00:00
|
|
|
#ifdef YAX_ENABLE__COMPAT
|
2015-04-11 13:53:07 +00:00
|
|
|
if (yax_getbunch(sectnum, YAX_FLOOR) >= 0)
|
2011-03-23 17:41:01 +00:00
|
|
|
xp = yp = 0;
|
|
|
|
#endif
|
|
|
|
DOPRINT(56, "(X,Y)pan: %d, %d", xp, yp);
|
|
|
|
}
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(64, "Shade byte: %d", TrackerCast(sec->floorshade));
|
|
|
|
DOPRINT(72, "Z-coordinate: %d", TrackerCast(sec->floorz));
|
|
|
|
DOPRINT(80, "Tile number: %d", TrackerCast(sec->floorpicnum));
|
|
|
|
DOPRINT(88, "Floor heinum: %d", TrackerCast(sec->floorheinum));
|
|
|
|
DOPRINT(96, "Palookup number: %d", TrackerCast(sec->floorpal));
|
2011-03-23 17:41:01 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
DOPRINT(104, "Bunch number: %d", yax_getbunch(sectnum, YAX_FLOOR));
|
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-08-17 20:00:44 +00:00
|
|
|
void showwalldata(int16_t wallnum, int16_t small)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2015-01-11 04:56:38 +00:00
|
|
|
walltype const * const wal = &wall[wallnum];
|
2010-05-22 14:04:47 +00:00
|
|
|
int32_t sec;
|
2006-04-24 19:04:22 +00:00
|
|
|
char snotbuf[80];
|
2010-05-22 14:04:47 +00:00
|
|
|
int32_t col=0; //, row = 0;
|
2010-08-17 20:00:44 +00:00
|
|
|
int32_t color = small ? whitecol : editorcolors[11];
|
2009-05-05 16:21:33 +00:00
|
|
|
|
2010-08-17 20:00:44 +00:00
|
|
|
if (small)
|
2009-05-05 16:21:33 +00:00
|
|
|
{
|
2011-04-11 22:28:58 +00:00
|
|
|
_printmessage16("^10Wall %d %s ^O(F8 to edit)", wallnum,
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtGetWallCaption(wallnum));
|
2010-05-02 23:27:30 +00:00
|
|
|
return;
|
2009-05-05 16:21:33 +00:00
|
|
|
}
|
2009-05-01 06:35:27 +00:00
|
|
|
|
2010-05-22 14:04:47 +00:00
|
|
|
DOPRINT(32, "^10Wall %d", wallnum);
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(48, "X-coordinate: %d", TrackerCast(wal->x));
|
|
|
|
DOPRINT(56, "Y-coordinate: %d", TrackerCast(wal->y));
|
|
|
|
DOPRINT(64, "Point2: %d", TrackerCast(wal->point2));
|
2010-05-22 14:04:47 +00:00
|
|
|
DOPRINT(72, "Sector: ^010%d", sectorofwall(wallnum));
|
|
|
|
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(88, "Tags: %d, %d", TrackerCast(wal->hitag), TrackerCast(wal->lotag));
|
|
|
|
DOPRINT(96, " (0x%x), (0x%x)", TrackerCast(wal->hitag), TrackerCast(wal->lotag));
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
col++;
|
2009-05-01 06:35:27 +00:00
|
|
|
|
2010-05-22 14:04:47 +00:00
|
|
|
DOPRINT(32, "^10%s^O", (wal->picnum>=0 && wal->picnum<MAXTILES) ? names[wal->picnum] : "!INVALID!");
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(48, "Flags (hex): %x", TrackerCast(wal->cstat));
|
|
|
|
DOPRINT(56, "Shade: %d", TrackerCast(wal->shade));
|
|
|
|
DOPRINT(64, "Pal: %d", TrackerCast(wal->pal));
|
|
|
|
DOPRINT(72, "(X,Y)repeat: %d, %d", TrackerCast(wal->xrepeat), TrackerCast(wal->yrepeat));
|
|
|
|
DOPRINT(80, "(X,Y)pan: %d, %d", TrackerCast(wal->xpanning), TrackerCast(wal->ypanning));
|
|
|
|
DOPRINT(88, "Tile number: %d", TrackerCast(wal->picnum));
|
|
|
|
DOPRINT(96, "OverTile number: %d", TrackerCast(wal->overpicnum));
|
2009-05-01 06:35:27 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
col++;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(48-(small?16:0), "nextsector: %d", TrackerCast(wal->nextsector));
|
|
|
|
DOPRINT(56-(small?16:0), "nextwall: %d", TrackerCast(wal->nextwall));
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(72-(small?16:0), "Extra: %d", TrackerCast(wal->extra));
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
// 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
|
2010-08-17 20:00:44 +00:00
|
|
|
DOPRINT(96-(small?16:0), "Wall length: %d", wallength(wallnum));
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-05-22 14:04:47 +00:00
|
|
|
sec = sectorofwall(wallnum);
|
2010-08-17 20:00:44 +00:00
|
|
|
DOPRINT(104-(small?16:0), "Pixel height: %d", (sector[sec].floorz-sector[sec].ceilingz)>>8);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-08-17 20:00:44 +00:00
|
|
|
void showspritedata(int16_t spritenum, int16_t small)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2010-05-22 14:04:47 +00:00
|
|
|
spritetype *spr;
|
2006-04-24 19:04:22 +00:00
|
|
|
char snotbuf[80];
|
2010-05-22 14:04:47 +00:00
|
|
|
int32_t col=0; //, row = 0;
|
2010-08-17 20:00:44 +00:00
|
|
|
int32_t color = small ? whitecol : editorcolors[11];
|
2009-05-05 16:21:33 +00:00
|
|
|
|
2010-05-22 14:04:47 +00:00
|
|
|
spr = &sprite[spritenum];
|
2010-05-02 23:27:30 +00:00
|
|
|
|
2010-08-17 20:00:44 +00:00
|
|
|
if (small)
|
2009-05-05 16:21:33 +00:00
|
|
|
{
|
2014-07-24 14:01:44 +00:00
|
|
|
_printmessage16("^10Sprite %d %s ^O(F8 to edit)",spritenum, CallExtGetSpriteCaption(spritenum));
|
2010-05-02 23:27:30 +00:00
|
|
|
return;
|
2009-05-05 16:21:33 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-05-22 14:04:47 +00:00
|
|
|
DOPRINT(32, "^10Sprite %d", spritenum);
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(48, "X-coordinate: %d", TrackerCast(spr->x));
|
|
|
|
DOPRINT(56, "Y-coordinate: %d", TrackerCast(spr->y));
|
|
|
|
DOPRINT(64, "Z-coordinate: %d", TrackerCast(spr->z));
|
2010-05-22 14:04:47 +00:00
|
|
|
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(72, "Sectnum: ^010%d", TrackerCast(spr->sectnum));
|
|
|
|
DOPRINT(80, "Statnum: %d", TrackerCast(spr->statnum));
|
2010-05-22 14:04:47 +00:00
|
|
|
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(96, "Tags: %d, %d", TrackerCast(spr->hitag), TrackerCast(spr->lotag));
|
|
|
|
DOPRINT(104, " (0x%x), (0x%x)", TrackerCast(spr->hitag), TrackerCast(spr->lotag));
|
2009-05-01 06:35:27 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
col++;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2011-04-17 17:01:20 +00:00
|
|
|
DOPRINT(32, "^10,0 ^O"); // 24 blanks
|
2010-05-22 14:04:47 +00:00
|
|
|
DOPRINT(32, "^10%s^O", (spr->picnum>=0 && spr->picnum<MAXTILES) ? names[spr->picnum] : "!INVALID!");
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(48, "Flags (hex): %x", TrackerCast(spr->cstat));
|
|
|
|
DOPRINT(56, "Shade: %d", TrackerCast(spr->shade));
|
|
|
|
DOPRINT(64, "Pal: %d", TrackerCast(spr->pal));
|
2014-02-22 19:38:49 +00:00
|
|
|
DOPRINT(72, "Blend: %d", TrackerCast(spr->blend));
|
|
|
|
DOPRINT(80, "(X,Y)repeat: %d, %d", TrackerCast(spr->xrepeat), TrackerCast(spr->yrepeat));
|
|
|
|
DOPRINT(88, "(X,Y)offset: %d, %d", TrackerCast(spr->xoffset), TrackerCast(spr->yoffset));
|
|
|
|
DOPRINT(96, "Tile number: %d", TrackerCast(spr->picnum));
|
2009-05-01 06:35:27 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
col++;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2012-11-26 08:26:04 +00:00
|
|
|
DOPRINT(48, "Angle (2048 degrees): %d", TrackerCast(spr->ang));
|
|
|
|
DOPRINT(56, "X-Velocity: %d", TrackerCast(spr->xvel));
|
|
|
|
DOPRINT(64, "Y-Velocity: %d", TrackerCast(spr->yvel));
|
|
|
|
DOPRINT(72, "Z-Velocity: %d", TrackerCast(spr->zvel));
|
|
|
|
DOPRINT(80, "Owner: %d", TrackerCast(spr->owner));
|
|
|
|
DOPRINT(88, "Clipdist: %d", TrackerCast(spr->clipdist));
|
|
|
|
DOPRINT(96, "Extra: %d", TrackerCast(spr->extra));
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-05-22 14:04:47 +00:00
|
|
|
#undef DOPRINT
|
|
|
|
|
|
|
|
// gets called once per totalclock increment since last call
|
2013-02-19 20:35:14 +00:00
|
|
|
static void keytimerstuff(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2013-02-19 20:35:14 +00:00
|
|
|
if (!g_doHardcodedMovement)
|
|
|
|
return;
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
if (DOWN_BK(STRAFE) == 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2015-07-08 03:34:46 +00:00
|
|
|
if (DOWN_BK(TURNLEFT)) angvel = max(angvel-pk_turnaccel, -127);
|
2010-05-18 05:14:17 +00:00
|
|
|
if (DOWN_BK(TURNRIGHT)) angvel = min(angvel+pk_turnaccel, 127);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
if (DOWN_BK(TURNLEFT)) svel = min(svel+16, 255); // svel and vel aren't even chars...
|
2015-07-08 03:34:46 +00:00
|
|
|
if (DOWN_BK(TURNRIGHT)) svel = max(svel-16, -255);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-05-18 05:14:17 +00:00
|
|
|
if (DOWN_BK(MOVEFORWARD)) vel = min(vel+16, 255);
|
2015-07-08 03:34:46 +00:00
|
|
|
if (DOWN_BK(MOVEBACKWARD)) vel = max(vel-16, -255);
|
2010-05-18 05:14:17 +00:00
|
|
|
/* if (DOWN_BK(STRAFELEFT)) svel = min(svel+8, 127);
|
|
|
|
if (DOWN_BK(STRAFERIGHT)) svel = max(svel-8, -128); */
|
|
|
|
|
|
|
|
if (angvel < 0) angvel = min(angvel+pk_turndecel, 0);
|
|
|
|
if (angvel > 0) angvel = max(angvel-pk_turndecel, 0);
|
|
|
|
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);
|
2010-05-22 14:04:47 +00:00
|
|
|
/* if(mlook) pos.z -= (horiz-101)*(vel/40); */
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-12-19 22:47:10 +00:00
|
|
|
#if 0
|
2010-05-18 05:14:17 +00:00
|
|
|
int32_t snfillprintf(char *outbuf, size_t bufsiz, int32_t fill, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
char tmpstr[256];
|
|
|
|
int32_t nwritten, ofs;
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start(va, fmt);
|
|
|
|
nwritten = Bvsnprintf(tmpstr, bufsiz, fmt, va);
|
|
|
|
va_end(va);
|
|
|
|
|
|
|
|
ofs = min(nwritten, (signed)bufsiz-1);
|
|
|
|
Bmemset(outbuf, fill, bufsiz-ofs);
|
2011-01-16 02:50:27 +00:00
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
return ofs;
|
|
|
|
}
|
2010-12-19 22:47:10 +00:00
|
|
|
#endif
|
2010-05-18 05:14:17 +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-08 23:13:12 +00:00
|
|
|
char snotbuf[156];
|
|
|
|
char tmpstr[160];
|
2008-06-10 02:29:58 +00:00
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start(va, fmt);
|
2011-08-03 17:22:25 +00:00
|
|
|
Bvsnprintf(tmpstr, sizeof(tmpstr), 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;
|
2010-05-18 05:14:17 +00:00
|
|
|
while (tmpstr[i] && i < 146)
|
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();
|
|
|
|
|
2009-05-05 16:21:33 +00:00
|
|
|
ybase = ydim-STATUS2DSIZ+128-8;
|
2009-05-01 19:28:57 +00:00
|
|
|
|
2011-03-13 11:59:32 +00:00
|
|
|
printext16(8, ybase+8, whitecol, -1, snotbuf, 0);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
void printmessage256(int32_t x, int32_t y, const char *name)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2010-05-18 05:14:17 +00:00
|
|
|
char snotbuf[80];
|
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;
|
2010-05-18 05:14:17 +00:00
|
|
|
while (name[i] && 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)
|
2011-04-11 22:28:58 +00:00
|
|
|
static void getclosestpointonwall(int32_t x, int32_t y, int32_t dawall, int32_t *nx, int32_t *ny,
|
|
|
|
int32_t maybe_screen_coord_p)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-04-11 22:28:58 +00:00
|
|
|
int64_t i, j, wx,wy, wx2,wy2, dx, dy;
|
|
|
|
|
|
|
|
if (m32_sideview && maybe_screen_coord_p)
|
|
|
|
{
|
|
|
|
wx = m32_wallscreenxy[dawall][0];
|
|
|
|
wy = m32_wallscreenxy[dawall][1];
|
|
|
|
wx2 = m32_wallscreenxy[wall[dawall].point2][0];
|
|
|
|
wy2 = m32_wallscreenxy[wall[dawall].point2][1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wx = wall[dawall].x;
|
|
|
|
wy = wall[dawall].y;
|
|
|
|
wx2 = POINT2(dawall).x;
|
|
|
|
wy2 = POINT2(dawall).y;
|
|
|
|
}
|
|
|
|
|
|
|
|
dx = wx2 - wx;
|
|
|
|
dy = wy2 - wy;
|
|
|
|
i = dx*(x-wx) + dy*(y-wy);
|
|
|
|
if (i <= 0) { *nx = wx; *ny = wy; return; }
|
|
|
|
j = dx*dx + dy*dy;
|
|
|
|
if (i >= j) { *nx = wx2; *ny = wy2; return; }
|
2008-05-16 19:51:38 +00:00
|
|
|
i=((i<<15)/j)<<15;
|
2011-04-11 22:28:58 +00:00
|
|
|
*nx = wx + ((dx*i)>>30);
|
|
|
|
*ny = wy + ((dy*i)>>30);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
static void initcrc(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2011-03-17 23:37:38 +00:00
|
|
|
static int32_t GetWallBaseZ(int32_t wallnum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2012-06-26 19:50:02 +00:00
|
|
|
int32_t z=0;
|
2011-03-17 23:37:38 +00:00
|
|
|
|
2012-06-26 19:50:02 +00:00
|
|
|
const int32_t sectnum = sectorofwall(wallnum);
|
|
|
|
const int32_t nextsec = wall[wallnum].nextsector;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-03-17 23:37:38 +00:00
|
|
|
if (nextsec == -1) //1-sided wall
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-17 23:37:38 +00:00
|
|
|
if (wall[wallnum].cstat&4) // floor-aligned
|
|
|
|
z = sector[sectnum].floorz;
|
|
|
|
else
|
|
|
|
z = sector[sectnum].ceilingz;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-03-17 23:37:38 +00:00
|
|
|
else //2-sided wall
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-17 23:37:38 +00:00
|
|
|
if (wall[wallnum].cstat&4)
|
|
|
|
z = sector[sectnum].ceilingz;
|
2006-04-24 19:04:22 +00:00
|
|
|
else
|
|
|
|
{
|
2011-03-17 23:37:38 +00:00
|
|
|
if (sector[nextsec].ceilingz > sector[sectnum].ceilingz)
|
|
|
|
z = sector[nextsec].ceilingz; //top step
|
|
|
|
if (sector[nextsec].floorz < sector[sectnum].floorz)
|
|
|
|
z = sector[nextsec].floorz; //bottom step
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2012-06-26 19:50:02 +00:00
|
|
|
|
|
|
|
return z;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2013-01-16 20:38:50 +00:00
|
|
|
|
|
|
|
////////// AUTOMATIC WALL ALIGNMENT //////////
|
|
|
|
|
2014-01-24 21:39:03 +00:00
|
|
|
static void AlignWalls_(int32_t tilenum, int32_t z0, int32_t z1, int32_t doxpanning,
|
|
|
|
int32_t w0_pan, int32_t w0_rep, int32_t w1_pan, int32_t w1_rep)
|
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
|
|
|
|
2014-09-30 04:14:21 +00:00
|
|
|
if (tilesiz[tilenum].x==0 || tilesiz[tilenum].y==0)
|
2011-08-08 19:30:24 +00:00
|
|
|
return;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//do the x alignment
|
2011-12-12 23:18:35 +00:00
|
|
|
if (doxpanning)
|
2014-09-30 04:14:21 +00:00
|
|
|
wall[w1_pan].xpanning = (uint8_t)((wall[w0_pan].xpanning + (wall[w0_rep].xrepeat<<3))%tilesiz[tilenum].x);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-01-12 10:31:12 +00:00
|
|
|
for (n=picsiz[tilenum]>>4; (1<<n)<tilesiz[tilenum].y; n++) { }
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2014-01-24 21:39:03 +00:00
|
|
|
wall[w1_rep].yrepeat = wall[w0_rep].yrepeat;
|
|
|
|
wall[w1_pan].ypanning = (uint8_t)(wall[w0_pan].ypanning + (((z1-z0)*wall[w0_rep].yrepeat)>>(n+3)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void AlignWalls(int32_t w0, int32_t z0, int32_t w1, int32_t z1, int32_t doxpanning)
|
|
|
|
{
|
|
|
|
AlignWalls_(wall[w0].picnum, z0, z1, doxpanning, w0, w0, w1, w1);
|
2011-03-17 23:37:38 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-03-17 23:37:38 +00:00
|
|
|
void AlignWallPoint2(int32_t w0)
|
|
|
|
{
|
|
|
|
int32_t w1 = wall[w0].point2;
|
2011-12-12 23:18:35 +00:00
|
|
|
AlignWalls(w0,GetWallBaseZ(w0), w1,GetWallBaseZ(w1), 1);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-05-12 23:31:13 +00:00
|
|
|
#define ALIGN_WALLS_CSTAT_MASK (4+8+256)
|
|
|
|
|
2014-01-24 21:39:03 +00:00
|
|
|
static int32_t AlignGetWall(int32_t botswap, int32_t w)
|
|
|
|
{
|
|
|
|
return botswap && (wall[w].cstat&2) && wall[w].nextwall >= 0 ? wall[w].nextwall : w;
|
|
|
|
}
|
|
|
|
|
2011-05-07 18:23:34 +00:00
|
|
|
// flags:
|
2013-01-16 20:38:50 +00:00
|
|
|
// 1: more than once
|
|
|
|
// 2: (unused)
|
2011-05-07 18:23:34 +00:00
|
|
|
// 4: carry pixel width from first wall over to the rest
|
2011-12-12 23:18:35 +00:00
|
|
|
// 8: align TROR nextwalls
|
2012-12-13 22:21:22 +00:00
|
|
|
// 16: iterate lastwall()s (point2 in reverse)
|
2014-01-24 21:39:03 +00:00
|
|
|
// 32: use special logic for 'bottom-swapped' walls
|
2011-05-07 18:23:34 +00:00
|
|
|
int32_t AutoAlignWalls(int32_t w0, uint32_t flags, int32_t nrecurs)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-05-12 23:31:13 +00:00
|
|
|
static int32_t numaligned, wall0, cstat0;
|
2011-05-07 18:23:34 +00:00
|
|
|
static uint32_t lenrepquot;
|
2014-01-24 21:39:03 +00:00
|
|
|
|
2012-12-13 22:21:22 +00:00
|
|
|
const int32_t totheleft = flags&16;
|
2014-01-24 21:39:03 +00:00
|
|
|
const int32_t botswap = flags&32;
|
2011-03-17 23:37:38 +00:00
|
|
|
|
2012-12-13 12:41:28 +00:00
|
|
|
int32_t z0 = GetWallBaseZ(w0);
|
2012-12-13 22:21:22 +00:00
|
|
|
int32_t w1 = totheleft ? lastwall(w0) : wall[w0].point2;
|
2014-01-24 21:39:03 +00:00
|
|
|
|
|
|
|
int32_t w0b = AlignGetWall(botswap, w0);
|
|
|
|
const int32_t tilenum = wall[w0b].picnum;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-03-17 23:37:38 +00:00
|
|
|
if (nrecurs == 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
|
|
|
//clear visited bits
|
2011-03-05 12:59:27 +00:00
|
|
|
Bmemset(visited, 0, sizeof(visited));
|
2011-03-17 23:37:38 +00:00
|
|
|
visited[w0>>3] |= (1<<(w0&7));
|
|
|
|
numaligned = 0;
|
2011-05-07 18:23:34 +00:00
|
|
|
lenrepquot = getlenbyrep(wallength(w0), wall[w0].xrepeat);
|
|
|
|
wall0 = w0;
|
2014-01-24 21:39:03 +00:00
|
|
|
cstat0 = wall[w0b].cstat & ALIGN_WALLS_CSTAT_MASK; // top/bottom orientation; x/y-flip
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-12-12 23:18:35 +00:00
|
|
|
//loop through walls at this vertex in point2 order
|
2006-04-24 19:04:22 +00:00
|
|
|
while (1)
|
|
|
|
{
|
2014-01-24 21:39:03 +00:00
|
|
|
int32_t w1b = AlignGetWall(botswap, w1);
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//break if this wall would connect us in a loop
|
2011-03-17 23:37:38 +00:00
|
|
|
if (visited[w1>>3]&(1<<(w1&7)))
|
2011-03-05 12:59:27 +00:00
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-03-17 23:37:38 +00:00
|
|
|
visited[w1>>3] |= (1<<(w1&7));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-12-12 23:18:35 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (flags&8)
|
|
|
|
{
|
|
|
|
int32_t cf, ynw;
|
|
|
|
|
|
|
|
for (cf=0; cf<2; cf++)
|
|
|
|
{
|
|
|
|
ynw = yax_getnextwall(w0, cf);
|
|
|
|
|
|
|
|
if (ynw >= 0 && wall[ynw].picnum==tilenum && (visited[ynw>>3]&(1<<(ynw&7)))==0)
|
|
|
|
{
|
|
|
|
wall[ynw].xrepeat = wall[w0].xrepeat;
|
|
|
|
wall[ynw].xpanning = wall[w0].xpanning;
|
|
|
|
AlignWalls(w0,z0, ynw,GetWallBaseZ(ynw), 0); // initial vertical alignment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2012-06-26 19:50:02 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//break if reached back of left wall
|
2011-03-17 23:37:38 +00:00
|
|
|
if (wall[w1].nextwall == w0)
|
2011-03-05 12:59:27 +00:00
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2014-01-24 21:39:03 +00:00
|
|
|
if (wall[w1b].picnum == tilenum)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2012-12-13 12:41:28 +00:00
|
|
|
int32_t visible = 1;
|
2012-06-26 19:50:02 +00:00
|
|
|
const int32_t nextsec = wall[w1].nextsector;
|
|
|
|
|
2012-12-13 12:41:28 +00:00
|
|
|
if (nextsec >= 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-17 23:37:38 +00:00
|
|
|
int32_t cz,fz, czn,fzn;
|
2012-06-26 19:50:02 +00:00
|
|
|
const int32_t sectnum = NEXTWALL(w1).nextsector;
|
2011-03-17 23:37:38 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//ignore two sided walls that have no visible face
|
2012-12-13 12:41:28 +00:00
|
|
|
// TODO: can be more precise (i.e. taking into account the wall face)
|
|
|
|
// ... needs to be factored out from some engine code maybe...
|
|
|
|
// as is the whole "z base" determination.
|
2011-03-17 23:37:38 +00:00
|
|
|
getzsofslope(sectnum, wall[w1].x,wall[w1].y, &cz, &fz);
|
|
|
|
getzsofslope(nextsec, wall[w1].x,wall[w1].y, &czn, &fzn);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2012-12-13 12:41:28 +00:00
|
|
|
if (czn <= cz && fzn >= fz)
|
|
|
|
visible = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (visible)
|
|
|
|
{
|
2012-12-13 12:41:28 +00:00
|
|
|
const int32_t z1 = GetWallBaseZ(w1);
|
|
|
|
|
|
|
|
if ((flags&4) && w1!=wall0)
|
|
|
|
fixxrepeat(w1, lenrepquot);
|
2014-01-24 21:39:03 +00:00
|
|
|
AlignWalls_(tilenum,z0, z1, 1, w0b, w0, w1b, w1);
|
|
|
|
wall[w1b].cstat &= ~ALIGN_WALLS_CSTAT_MASK;
|
|
|
|
wall[w1b].cstat |= cstat0;
|
2011-05-07 18:23:34 +00:00
|
|
|
numaligned++;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2013-01-16 20:38:50 +00:00
|
|
|
if ((flags&1)==0)
|
|
|
|
return 1;
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
//if wall was 1-sided, no need to recurse
|
2011-03-17 23:37:38 +00:00
|
|
|
if (wall[w1].nextwall < 0)
|
2006-04-24 19:04:22 +00:00
|
|
|
{
|
2011-03-17 23:37:38 +00:00
|
|
|
w0 = w1;
|
2014-01-24 21:39:03 +00:00
|
|
|
w0b = AlignGetWall(botswap, w0);
|
2011-03-17 23:37:38 +00:00
|
|
|
z0 = GetWallBaseZ(w0);
|
2012-12-13 22:21:22 +00:00
|
|
|
w1 = totheleft ? lastwall(w0) : wall[w0].point2;
|
2012-12-13 12:41:28 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
2012-12-13 12:41:28 +00:00
|
|
|
|
2013-01-16 20:38:50 +00:00
|
|
|
AutoAlignWalls(w1, flags, nrecurs+1);
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-16 20:38:50 +00:00
|
|
|
if (wall[w1].nextwall < 0)
|
2011-05-07 18:23:34 +00:00
|
|
|
break;
|
2012-12-13 22:21:22 +00:00
|
|
|
w1 = totheleft ? lastwall(wall[w1].nextwall) : NEXTWALL(w1).point2;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2011-03-17 23:37:38 +00:00
|
|
|
|
|
|
|
return numaligned;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-01-03 22:04:20 +00:00
|
|
|
#define PLAYTEST_MAPNAME "autosave_playtest.map"
|
|
|
|
|
2009-05-05 16:21:33 +00:00
|
|
|
void test_map(int32_t mode)
|
|
|
|
{
|
|
|
|
if (!mode)
|
|
|
|
updatesector(pos.x, pos.y, &cursectnum);
|
|
|
|
else
|
2012-10-01 17:52:30 +00:00
|
|
|
updatesector(startpos.x, startpos.y, &startsectnum);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-04-09 19:21:39 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
if (fullscreen)
|
|
|
|
{
|
|
|
|
printmessage16("Must be in windowed mode to test map!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-05-05 16:21:33 +00:00
|
|
|
if ((!mode && cursectnum >= 0) || (mode && startsectnum >= 0))
|
|
|
|
{
|
2016-01-11 05:06:10 +00:00
|
|
|
char const *param = " -map " PLAYTEST_MAPNAME " -noinstancechecking";
|
2009-05-05 16:21:33 +00:00
|
|
|
char current_cwd[BMAX_PATH];
|
|
|
|
int32_t slen = 0;
|
|
|
|
BFILE *fp;
|
|
|
|
|
|
|
|
if ((program_origcwd[0] == '\0') || !getcwd(current_cwd, BMAX_PATH))
|
|
|
|
current_cwd[0] = '\0';
|
|
|
|
else // Before we check if file exists, for the case there's no absolute path.
|
2014-10-29 17:05:15 +00:00
|
|
|
Bchdir(program_origcwd);
|
2009-05-05 16:21:33 +00:00
|
|
|
|
|
|
|
fp = fopen(game_executable, "rb"); // File exists?
|
|
|
|
if (fp != NULL)
|
|
|
|
fclose(fp);
|
|
|
|
else
|
|
|
|
{
|
2016-01-12 10:30:48 +00:00
|
|
|
char const * lastslash = (char const *)Bstrrchr(mapster32_fullpath, '/');
|
2009-05-05 16:21:33 +00:00
|
|
|
#ifdef _WIN32
|
2016-01-12 10:30:48 +00:00
|
|
|
char const * lastbackslash = (char const *)Bstrrchr(mapster32_fullpath, '\\');
|
|
|
|
lastslash = max(lastslash, lastbackslash);
|
2009-05-05 16:21:33 +00:00
|
|
|
#endif
|
2016-01-12 10:30:48 +00:00
|
|
|
if (lastslash)
|
2009-05-05 16:21:33 +00:00
|
|
|
{
|
2016-01-12 10:30:48 +00:00
|
|
|
slen = lastslash-mapster32_fullpath+1;
|
2009-05-05 16:21:33 +00:00
|
|
|
Bstrncpy(game_executable, mapster32_fullpath, slen);
|
2015-06-07 09:55:41 +00:00
|
|
|
Bstrncpy(game_executable+slen, DefaultGameExec, sizeof(game_executable)-slen);
|
2009-05-05 16:21:33 +00:00
|
|
|
}
|
|
|
|
else
|
2014-07-28 06:43:16 +00:00
|
|
|
Bstrncpy(game_executable, DefaultGameLocalExec, sizeof(game_executable));
|
2009-05-05 16:21:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (current_cwd[0] != '\0') // Temporarily changing back,
|
2014-10-29 17:05:15 +00:00
|
|
|
Bchdir(current_cwd); // after checking if file exists.
|
2009-05-05 16:21:33 +00:00
|
|
|
|
|
|
|
if (testplay_addparam)
|
|
|
|
slen = Bstrlen(testplay_addparam);
|
|
|
|
|
|
|
|
// Considering the NULL character, quatation marks
|
|
|
|
// and a possible extra space not in testplay_addparam,
|
|
|
|
// the length should be Bstrlen(game_executable)+Bstrlen(param)+(slen+1)+2+1.
|
|
|
|
|
2016-01-12 10:30:48 +00:00
|
|
|
char *fullparam = (char *)Xmalloc(Bstrlen(game_executable)+Bstrlen(param)+slen+4);
|
2009-05-05 16:21:33 +00:00
|
|
|
Bsprintf(fullparam,"\"%s\"",game_executable);
|
|
|
|
|
|
|
|
if (testplay_addparam)
|
|
|
|
{
|
|
|
|
Bstrcat(fullparam, " ");
|
|
|
|
Bstrcat(fullparam, testplay_addparam);
|
|
|
|
}
|
|
|
|
Bstrcat(fullparam, param);
|
|
|
|
|
2014-07-24 14:01:44 +00:00
|
|
|
CallExtPreSaveMap();
|
2009-05-05 16:21:33 +00:00
|
|
|
if (mode)
|
2012-10-01 17:52:30 +00:00
|
|
|
saveboard(PLAYTEST_MAPNAME, &startpos, startang, startsectnum);
|
2009-05-05 16:21:33 +00:00
|
|
|
else
|
2012-10-01 17:52:30 +00:00
|
|
|
saveboard(PLAYTEST_MAPNAME, &pos, ang, cursectnum);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2011-01-03 22:04:20 +00:00
|
|
|
message("Board saved to " PLAYTEST_MAPNAME ". Starting the game...");
|
2010-09-06 23:08:35 +00:00
|
|
|
OSD_Printf("...as `%s'\n", fullparam);
|
2010-05-18 05:14:17 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoShowFrame(1);
|
2018-04-12 21:02:31 +00:00
|
|
|
mouseUninit();
|
2009-05-05 16:21:33 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
{
|
|
|
|
STARTUPINFO si;
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
|
|
|
|
ZeroMemory(&si,sizeof(si));
|
|
|
|
ZeroMemory(&pi,sizeof(pi));
|
|
|
|
si.cb = sizeof(si);
|
|
|
|
|
|
|
|
if (!CreateProcess(NULL,fullparam,NULL,NULL,0,0,NULL,NULL,&si,&pi))
|
2010-09-06 23:08:35 +00:00
|
|
|
message("Error launching the game!");
|
2009-05-05 16:21:33 +00:00
|
|
|
else WaitForSingleObject(pi.hProcess,INFINITE);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (current_cwd[0] != '\0')
|
|
|
|
{
|
2014-10-29 17:05:15 +00:00
|
|
|
Bchdir(program_origcwd);
|
2010-10-28 20:17:22 +00:00
|
|
|
if (system(fullparam))
|
|
|
|
message("Error launching the game!");
|
2014-10-29 17:05:15 +00:00
|
|
|
Bchdir(current_cwd);
|
2009-05-05 16:21:33 +00:00
|
|
|
}
|
|
|
|
else system(fullparam);
|
|
|
|
#endif
|
|
|
|
printmessage16("Game process exited");
|
2018-04-12 21:02:31 +00:00
|
|
|
mouseInit();
|
2010-05-18 05:14:17 +00:00
|
|
|
clearkeys();
|
2009-05-05 16:21:33 +00:00
|
|
|
|
|
|
|
Bfree(fullparam);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printmessage16("Position must be in valid player space to test map!");
|
2009-05-08 23:13:12 +00:00
|
|
|
}
|
2014-07-24 14:01:44 +00:00
|
|
|
|
2014-07-28 06:43:16 +00:00
|
|
|
void app_crashhandler(void)
|
|
|
|
{
|
|
|
|
if (levelname[0])
|
|
|
|
{
|
|
|
|
append_ext_UNSAFE(levelname, "_crash.map");
|
|
|
|
SaveBoard(levelname, M32_SB_NOEXT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-24 14:01:44 +00:00
|
|
|
// These will be more useful in the future...
|
|
|
|
static const char *CallExtGetVer(void)
|
|
|
|
{
|
|
|
|
return ExtGetVer();
|
|
|
|
}
|
|
|
|
static int32_t CallExtInit(void)
|
|
|
|
{
|
|
|
|
return ExtInit();
|
|
|
|
}
|
2016-01-12 10:30:56 +00:00
|
|
|
static int32_t CallExtPreInit(int32_t argc,char const * const * argv)
|
2014-07-24 14:01:44 +00:00
|
|
|
{
|
|
|
|
return ExtPreInit(argc, argv);
|
|
|
|
}
|
2014-07-28 06:42:28 +00:00
|
|
|
static int32_t CallExtPostStartupWindow(void)
|
|
|
|
{
|
|
|
|
return ExtPostStartupWindow();
|
|
|
|
}
|
2015-09-23 17:54:42 +00:00
|
|
|
static void CallExtPostInit(void)
|
|
|
|
{
|
|
|
|
return ExtPostInit();
|
|
|
|
}
|
2014-07-24 14:01:44 +00:00
|
|
|
static void CallExtUnInit(void)
|
|
|
|
{
|
|
|
|
ExtUnInit();
|
|
|
|
}
|
|
|
|
static void CallExtPreCheckKeys(void)
|
|
|
|
{
|
|
|
|
ExtPreCheckKeys();
|
|
|
|
}
|
|
|
|
static void CallExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothr)
|
|
|
|
{
|
|
|
|
ExtAnalyzeSprites(ourx, oury, oura, smoothr);
|
|
|
|
VM_OnEvent(EVENT_ANALYZESPRITES, -1);
|
|
|
|
}
|
|
|
|
static void CallExtCheckKeys(void)
|
|
|
|
{
|
|
|
|
ExtCheckKeys();
|
|
|
|
}
|
|
|
|
static void CallExtPreLoadMap(void)
|
|
|
|
{
|
|
|
|
VM_OnEvent(EVENT_PRELOADMAP, -1);
|
|
|
|
ExtPreLoadMap();
|
|
|
|
}
|
|
|
|
static void CallExtSetupMapFilename(const char *mapname)
|
|
|
|
{
|
2014-07-28 06:43:16 +00:00
|
|
|
Bstrncpy(levelname, mapname, sizeof(levelname));
|
|
|
|
|
|
|
|
Bsnprintf(tempbuf, sizeof(tempbuf), "%s - %s", AppProperName, mapname);
|
|
|
|
wm_setapptitle(tempbuf);
|
|
|
|
|
2014-07-24 14:01:44 +00:00
|
|
|
ExtSetupMapFilename(mapname);
|
|
|
|
}
|
|
|
|
static void CallExtLoadMap(const char *mapname)
|
|
|
|
{
|
2014-07-28 06:43:16 +00:00
|
|
|
CallExtSetupMapFilename(mapname);
|
2014-07-24 14:01:44 +00:00
|
|
|
ExtLoadMap(mapname);
|
|
|
|
VM_OnEvent(EVENT_LOADMAP, -1);
|
|
|
|
}
|
|
|
|
static int32_t CallExtPreSaveMap(void)
|
|
|
|
{
|
|
|
|
VM_OnEvent(EVENT_PRESAVEMAP, -1);
|
|
|
|
return ExtPreSaveMap();
|
|
|
|
}
|
|
|
|
static void CallExtSaveMap(const char *mapname)
|
|
|
|
{
|
|
|
|
ExtSaveMap(mapname);
|
2014-07-28 06:43:16 +00:00
|
|
|
saveboard("backup.map", &pos, ang, cursectnum);
|
2014-07-24 14:01:44 +00:00
|
|
|
VM_OnEvent(EVENT_SAVEMAP, -1);
|
|
|
|
}
|
|
|
|
static void CallExtShowSectorData(int16_t sectnum)
|
|
|
|
{
|
|
|
|
ExtShowSectorData(sectnum);
|
|
|
|
}
|
|
|
|
static void CallExtShowWallData(int16_t wallnum)
|
|
|
|
{
|
|
|
|
ExtShowWallData(wallnum);
|
|
|
|
}
|
|
|
|
static void CallExtShowSpriteData(int16_t spritenum)
|
|
|
|
{
|
|
|
|
ExtShowSpriteData(spritenum);
|
|
|
|
}
|
|
|
|
static void CallExtEditSectorData(int16_t sectnum)
|
|
|
|
{
|
|
|
|
ExtEditSectorData(sectnum);
|
|
|
|
}
|
|
|
|
static void CallExtEditWallData(int16_t wallnum)
|
|
|
|
{
|
|
|
|
ExtEditWallData(wallnum);
|
|
|
|
}
|
|
|
|
static void CallExtEditSpriteData(int16_t spritenum)
|
|
|
|
{
|
|
|
|
ExtEditSpriteData(spritenum);
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
static const char *CallExtGetSectorType(int32_t lotag)
|
|
|
|
{
|
|
|
|
return ExtGetSectorType(lotag);
|
|
|
|
}
|
|
|
|
#endif
|