mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
* Include file cleanup by dragging most declarations into editor.h
* more useful auto-red wall feature: if no structure-changing operations have been applied after highlighting and duplicating, now also paste 'visual' fields of outer walls (this is one example of the use of a system that temporarily keeps track of nextwalls for former red lines) * multi-pkies now have individual parallaxyscale git-svn-id: https://svn.eduke32.com/eduke32@1886 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
682981b50e
commit
873375025f
12 changed files with 599 additions and 341 deletions
|
@ -82,6 +82,9 @@ void yax_updategrays(int32_t posze);
|
|||
# define YAX_ITER_WALLS(Wal, Itervar, Cfvar) Cfvar=0, Itervar=(Wal); Itervar!=-1; \
|
||||
Itervar=yax_getnextwall(Itervar, Cfvar), (void)(Itervar==-1 && Cfvar==0 && (Cfvar=1) && (Itervar=yax_getnextwall((Wal), Cfvar)))
|
||||
|
||||
# define SECTORS_OF_BUNCH(Bunchnum, Cf, Itervar) Itervar = headsectbunch[Cf][Bunchnum]; \
|
||||
Itervar != -1; Itervar = nextsectbunch[Cf][Itervar]
|
||||
|
||||
extern int16_t yax_bunchnum[MAXSECTORS][2];
|
||||
extern int16_t yax_nextwall[MAXWALLS][2];
|
||||
|
||||
|
@ -305,6 +308,7 @@ EXTERN int16_t startumost[MAXXDIM], startdmost[MAXXDIM];
|
|||
EXTERN int16_t pskyoff[MAXPSKYTILES], pskybits;
|
||||
// new multi-psky -- up to MAXPSKYMULTIS
|
||||
EXTERN int16_t pskynummultis;
|
||||
EXTERN int32_t pskymultiyscale[MAXPSKYMULTIS];
|
||||
EXTERN int16_t pskymultilist[MAXPSKYMULTIS], pskymultibits[MAXPSKYMULTIS];
|
||||
EXTERN int16_t pskymultioff[MAXPSKYMULTIS][MAXPSKYTILES];
|
||||
|
||||
|
@ -571,6 +575,8 @@ void updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum) ATTRIBUT
|
|||
int32_t inside(int32_t x, int32_t y, int16_t sectnum);
|
||||
void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day);
|
||||
void setfirstwall(int16_t sectnum, int16_t newfirstwall);
|
||||
|
||||
extern const int16_t *chsecptr_onextwall;
|
||||
int32_t checksectorpointer(int16_t i, int16_t sectnum);
|
||||
|
||||
void getmousevalues(int32_t *mousx, int32_t *mousy, int32_t *bstatus) ATTRIBUTE((nonnull(1,2,3)));
|
||||
|
|
|
@ -36,11 +36,24 @@ extern "C" {
|
|||
#define BK_CONSOLE 19
|
||||
#define NUMBUILDKEYS 20
|
||||
|
||||
extern int32_t horiz;
|
||||
extern vec3_t pos;
|
||||
extern int16_t ang, cursectnum;
|
||||
|
||||
extern int16_t editstatus, searchit;
|
||||
extern int32_t searchx, searchy, osearchx, osearchy; //search input
|
||||
|
||||
extern int32_t qsetmode;
|
||||
extern int16_t searchsector, searchwall, searchstat;
|
||||
extern int16_t searchsector, searchwall, searchstat; //search output
|
||||
extern int16_t searchbottomwall, searchisbottom;
|
||||
extern int32_t zmode, kensplayerheight, zlock;
|
||||
|
||||
extern int16_t highlightsector[MAXSECTORS], highlightsectorcnt;
|
||||
extern int16_t highlight[MAXWALLS+MAXSPRITES];
|
||||
extern int16_t asksave;
|
||||
|
||||
extern int16_t pointhighlight, linehighlight, highlightcnt;
|
||||
|
||||
#define DEFAULT_SPRITE_CSTAT 0
|
||||
//extern int16_t defaultspritecstat;
|
||||
|
||||
|
@ -49,10 +62,17 @@ extern uint32_t temppal, tempvis, tempxrepeat, tempyrepeat, tempxpanning, tempyp
|
|||
extern int32_t tempshade, tempxvel, tempyvel, tempzvel;
|
||||
extern char somethingintab;
|
||||
|
||||
extern char names[MAXTILES][25];
|
||||
extern uint8_t buildkeys[NUMBUILDKEYS];
|
||||
|
||||
extern double vid_gamma_3d, vid_contrast_3d, vid_brightness_3d;
|
||||
extern double msens;
|
||||
|
||||
extern int32_t startposx, startposy, startposz;
|
||||
extern int16_t startang, startsectnum;
|
||||
|
||||
extern int32_t lastpm16time, synctics;
|
||||
extern int32_t halfxdim16, midydim16, zoom;
|
||||
extern int32_t ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d, forcesetup;
|
||||
extern int32_t unrealedlook, quickmapcycling;
|
||||
extern int32_t pk_turnaccel,pk_turndecel,pk_uedaccel;
|
||||
|
@ -61,11 +81,22 @@ extern int32_t autosave;
|
|||
extern int32_t mlook;
|
||||
extern int16_t prefixtiles[16];
|
||||
|
||||
extern int32_t numsprites;
|
||||
extern int32_t showfirstwall;
|
||||
|
||||
extern int32_t graphicsmode;
|
||||
|
||||
extern int32_t grid, autogrid;
|
||||
extern int32_t editorgridextent; // in engine.c
|
||||
|
||||
extern char game_executable[BMAX_PATH];
|
||||
extern char program_origcwd[BMAX_PATH];
|
||||
extern char *mapster32_fullpath;
|
||||
extern char *testplay_addparam;
|
||||
extern const char *g_namesFileName;
|
||||
|
||||
extern const char *defsfilename; // set in bstub.c
|
||||
|
||||
extern int32_t m32_osd_tryscript;
|
||||
extern int32_t showheightindicators;
|
||||
extern int32_t showambiencesounds;
|
||||
|
@ -77,6 +108,10 @@ extern uint8_t graywallbitmap[MAXWALLS>>3];
|
|||
int32_t yax_is121(int16_t bunchnum, int16_t getfloor);
|
||||
#endif
|
||||
|
||||
extern int32_t map_revision;
|
||||
extern int32_t map_undoredo(int32_t dir);
|
||||
extern void map_undoredo_free(void);
|
||||
|
||||
// editor side view
|
||||
extern int32_t m32_sideview;
|
||||
extern int32_t m32_sideelev;
|
||||
|
|
|
@ -185,36 +185,9 @@ extern hashtable_t h_arrays;
|
|||
extern hashtable_t h_gamefuncs;
|
||||
|
||||
|
||||
extern int16_t asksave;
|
||||
|
||||
extern vec3_t pos;
|
||||
extern int16_t ang;
|
||||
extern int32_t horiz;
|
||||
extern int16_t cursectnum;
|
||||
extern int32_t searchx, searchy;
|
||||
|
||||
extern int16_t pointhighlight;
|
||||
extern int16_t linehighlight;
|
||||
extern int16_t highlightcnt;
|
||||
extern int16_t highlightsectorcnt;
|
||||
|
||||
extern int32_t startposx;
|
||||
extern int32_t startposy;
|
||||
extern int32_t startposz;
|
||||
extern int16_t startang;
|
||||
extern int16_t startsectnum;
|
||||
|
||||
extern int32_t mousxplc;
|
||||
extern int32_t mousyplc;
|
||||
|
||||
extern int16_t highlight[];
|
||||
extern int16_t highlightsector[];
|
||||
|
||||
extern int32_t numsprites;
|
||||
|
||||
extern int32_t zoom;
|
||||
extern int32_t halfxdim16, midydim16;
|
||||
|
||||
|
||||
// gamevar bytecode format:
|
||||
|
||||
|
|
|
@ -27,12 +27,8 @@ static char kensig[64];
|
|||
|
||||
extern const char *ExtGetVer(void);
|
||||
|
||||
extern char spritecol2d[MAXTILES][2];
|
||||
|
||||
char noclip=0;
|
||||
|
||||
int32_t vel, svel, angvel;
|
||||
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// up, down, left, right, lshift, rctrl, lctrl, space
|
||||
// 8 9 10 11 12 13
|
||||
|
@ -48,15 +44,13 @@ uint8_t buildkeys[NUMBUILDKEYS] =
|
|||
|
||||
vec3_t pos;
|
||||
int32_t horiz = 100;
|
||||
static int32_t mousexsurp = 0, mouseysurp = 0;
|
||||
int16_t ang, cursectnum;
|
||||
int32_t hvel;
|
||||
int32_t hvel, vel, svel, angvel;
|
||||
|
||||
static int32_t mousexsurp = 0, mouseysurp = 0;
|
||||
|
||||
int32_t grponlymode = 0;
|
||||
extern int32_t editorgridextent; // in engine.c
|
||||
extern double msens;
|
||||
int32_t graphicsmode = 0;
|
||||
extern int32_t xyaspect;
|
||||
extern int32_t totalclocklock;
|
||||
|
||||
int32_t synctics = 0, lockclock = 0;
|
||||
|
@ -65,17 +59,10 @@ int32_t synctics = 0, lockclock = 0;
|
|||
// so that exiting from mapster32 in 2d mode saves the correct ones
|
||||
double vid_gamma_3d=-1, vid_contrast_3d=-1, vid_brightness_3d=-1;
|
||||
|
||||
extern char vgacompatible;
|
||||
|
||||
extern char picsiz[MAXTILES];
|
||||
extern int32_t startposx, startposy, startposz;
|
||||
extern int16_t startang, startsectnum;
|
||||
extern int32_t ydim16, halfxdim16, midydim16;
|
||||
extern intptr_t frameplace;
|
||||
int32_t xdim2d = 640, ydim2d = 480, xdimgame = 640, ydimgame = 480, bppgame = 8;
|
||||
int32_t forcesetup = 1;
|
||||
|
||||
extern int32_t cachesize, artsize;
|
||||
//extern int32_t cachesize, artsize;
|
||||
|
||||
static int16_t oldmousebstatus = 0;
|
||||
char game_executable[BMAX_PATH] = DEFAULT_GAME_LOCAL_EXEC;
|
||||
|
@ -91,12 +78,8 @@ char names[MAXTILES][25];
|
|||
const char *g_namesFileName = "NAMES.H";
|
||||
|
||||
int16_t asksave = 0;
|
||||
extern int16_t editstatus, searchit;
|
||||
extern int32_t searchx, searchy; //search input
|
||||
extern int16_t searchsector, searchwall, searchstat; //search output
|
||||
int32_t osearchx, osearchy; //old search input
|
||||
|
||||
extern int16_t pointhighlight, linehighlight, highlightcnt;
|
||||
int32_t grid = 3, autogrid = 0, gridlock = 1, showtags = 2;
|
||||
int32_t zoom = 768, gettilezoom = 1;
|
||||
int32_t lastpm16time = 0;
|
||||
|
@ -108,6 +91,14 @@ int16_t highlight[MAXWALLS+MAXSPRITES];
|
|||
int16_t highlightsector[MAXSECTORS], highlightsectorcnt = -1;
|
||||
extern char textfont[128][8];
|
||||
|
||||
// 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];
|
||||
static void mkonwvalid(void) { chsecptr_onextwall = onextwall; }
|
||||
static void mkonwinvalid(void) { chsecptr_onextwall = NULL; }
|
||||
static int32_t onwisvalid(void) { return chsecptr_onextwall != NULL; }
|
||||
|
||||
int32_t temppicnum, tempcstat, templotag, temphitag, tempextra;
|
||||
uint32_t temppal, tempvis, tempxrepeat, tempyrepeat, tempxpanning=0, tempypanning=0;
|
||||
int32_t tempshade, tempxvel, tempyvel, tempzvel;
|
||||
|
@ -229,17 +220,12 @@ static void correct_ornamented_sprite(int32_t i, int32_t hitw);
|
|||
static int32_t getfilenames(const char *path, const char *kind);
|
||||
static void clearfilenames(void);
|
||||
void loadmhk(int32_t domessage);
|
||||
extern int32_t map_revision;
|
||||
extern int32_t map_undoredo(int32_t dir);
|
||||
extern void map_undoredo_free(void);
|
||||
|
||||
void clearkeys(void) { Bmemset(keystatus,0,sizeof(keystatus)); }
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
static int32_t osdcmd_restartvid(const osdfuncparm_t *parm)
|
||||
{
|
||||
extern int32_t qsetmode;
|
||||
|
||||
UNREFERENCED_PARAMETER(parm);
|
||||
|
||||
if (qsetmode != 200) return OSDCMD_OK;
|
||||
|
@ -254,7 +240,6 @@ static int32_t osdcmd_restartvid(const osdfuncparm_t *parm)
|
|||
static int32_t osdcmd_vidmode(const osdfuncparm_t *parm)
|
||||
{
|
||||
int32_t newx = xdim, newy = ydim, newbpp = bpp, newfullscreen = fullscreen, tmp;
|
||||
extern int32_t qsetmode;
|
||||
|
||||
switch (parm->numparms)
|
||||
{
|
||||
|
@ -304,10 +289,6 @@ static int32_t osdcmd_vidmode(const osdfuncparm_t *parm)
|
|||
}
|
||||
#endif
|
||||
|
||||
extern int32_t startwin_run(void);
|
||||
|
||||
extern char *defsfilename; // set in bstub.c
|
||||
|
||||
|
||||
#ifdef M32_SHOWDEBUG
|
||||
char m32_debugstr[64][128];
|
||||
|
@ -426,8 +407,8 @@ static void reset_default_mapstate(void)
|
|||
numwalls = 0;
|
||||
numsprites = 0;
|
||||
|
||||
editorzrange[0] = INT_MIN;
|
||||
editorzrange[1] = INT_MAX;
|
||||
editorzrange[0] = INT32_MIN;
|
||||
editorzrange[1] = INT32_MAX;
|
||||
|
||||
initspritelists();
|
||||
taglab_init();
|
||||
|
@ -507,6 +488,8 @@ int32_t app_main(int32_t argc, const char **argv)
|
|||
#if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2)
|
||||
if (i || forcesetup || cmdsetup)
|
||||
{
|
||||
extern int32_t startwin_run(void);
|
||||
|
||||
if (quitevent || !startwin_run())
|
||||
{
|
||||
uninitengine();
|
||||
|
@ -581,6 +564,8 @@ int32_t app_main(int32_t argc, const char **argv)
|
|||
|
||||
taglab_init();
|
||||
|
||||
mkonwinvalid();
|
||||
|
||||
if (LoadBoard(boardfilename, 1))
|
||||
reset_default_mapstate();
|
||||
|
||||
|
@ -760,8 +745,9 @@ CANCEL:
|
|||
// uninitengine();
|
||||
uninitsystem();
|
||||
|
||||
Bprintf("Memory status: %d(%d) bytes\n",cachesize,artsize);
|
||||
Bprintf("%s\n",kensig);
|
||||
// not reached...
|
||||
// Bprintf("Memory status: %d(%d) bytes\n",cachesize,artsize);
|
||||
// Bprintf("%s\n",kensig);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -1331,17 +1317,6 @@ char changechar(char dachar, int32_t dadir, char smooshyalign, char boundcheck)
|
|||
|
||||
////////////////////// OVERHEADEDITOR //////////////////////
|
||||
|
||||
#if 0
|
||||
static int32_t inside_nogray(int32_t x, int32_t y, int16_t sectnum)
|
||||
{
|
||||
#ifdef YAX_ENABLE
|
||||
if (sectnum>=0 && (graysectbitmap[sectnum>>3]&(1<<(sectnum&7))))
|
||||
return 0;
|
||||
#endif
|
||||
return inside(x, y, sectnum);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int32_t inside_editor_curpos(int16_t sectnum)
|
||||
{
|
||||
return inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc, sectnum);
|
||||
|
@ -1571,33 +1546,62 @@ static int32_t newnumwalls=-1;
|
|||
static void ovh_whiteoutgrab(void)
|
||||
{
|
||||
int32_t i, j, k, startwall, endwall;
|
||||
#ifdef YAX_ENABLE
|
||||
int16_t cb, fb;
|
||||
#endif
|
||||
|
||||
for (i=0; i<MAXWALLS; i++)
|
||||
onextwall[i] = -1;
|
||||
|
||||
//White out all bordering lines of grab that are
|
||||
//not highlighted on both sides
|
||||
for (i=highlightsectorcnt-1; i>=0; i--)
|
||||
{
|
||||
for (WALLS_OF_SECTOR(highlightsector[i], j))
|
||||
{
|
||||
if (wall[j].nextwall >= 0)
|
||||
{
|
||||
k = wall[j].nextsector;
|
||||
if (wall[j].nextwall < 0)
|
||||
continue;
|
||||
|
||||
if ((hlsectorbitmap[k>>3]&(1<<(k&7)))==0)
|
||||
{
|
||||
NEXTWALL(j).nextwall = -1;
|
||||
NEXTWALL(j).nextsector = -1;
|
||||
wall[j].nextwall = -1;
|
||||
wall[j].nextsector = -1;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
mkonwvalid();
|
||||
}
|
||||
|
||||
static void duplicate_selected_sectors(void)
|
||||
{
|
||||
int32_t i, j, startwall, endwall, newnumsectors, newwalls = 0;
|
||||
int32_t minx=INT_MAX, maxx=INT_MIN, miny=INT_MAX, maxy=INT_MIN, dx, dy;
|
||||
int32_t minx=INT32_MAX, maxx=INT32_MIN, miny=INT32_MAX, maxy=INT32_MIN, dx, dy;
|
||||
#ifdef YAX_ENABLE
|
||||
int16_t cb, fb;
|
||||
|
||||
for (i=0; i<highlightsectorcnt; i++)
|
||||
{
|
||||
yax_getbunches(highlightsector[i], &cb, &fb);
|
||||
if (cb>=0 || fb>=0)
|
||||
{
|
||||
printmessage16("Cannot duplicate extended sectors!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i=0; i<highlightsectorcnt; i++)
|
||||
newwalls += sector[highlightsector[i]].wallnum;
|
||||
|
@ -1925,33 +1929,45 @@ void fade_editor_screen(int32_t keepcol)
|
|||
showframe(1);
|
||||
}
|
||||
|
||||
static void copy_some_wall_members(int16_t dst, int16_t src)
|
||||
static void copy_some_wall_members(int16_t dst, int16_t src, int32_t reset_some)
|
||||
{
|
||||
// x y p2 nw ns cs p op sh pl xr yr xp yp lo hi ex
|
||||
static const walltype nullwall = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, -1 };
|
||||
walltype *dstwal=&wall[dst];
|
||||
const walltype *srcwal = src >= 0 ? &wall[src] : &nullwall;
|
||||
|
||||
dstwal->cstat = srcwal->cstat;
|
||||
if (reset_some)
|
||||
{
|
||||
dstwal->cstat = srcwal->cstat;
|
||||
}
|
||||
else
|
||||
{
|
||||
dstwal->cstat &= ~(4+8+256);
|
||||
dstwal->cstat |= (srcwal->cstat&(4+8+256));
|
||||
}
|
||||
dstwal->shade = srcwal->shade;
|
||||
dstwal->yrepeat = srcwal->yrepeat;
|
||||
fixrepeats(dst); // xrepeat
|
||||
dstwal->picnum = srcwal->picnum;
|
||||
dstwal->overpicnum = srcwal->overpicnum;
|
||||
|
||||
dstwal->nextwall = -1;
|
||||
dstwal->nextsector = -1;
|
||||
|
||||
dstwal->pal = srcwal->pal;
|
||||
dstwal->xpanning = srcwal->xpanning;
|
||||
dstwal->ypanning = srcwal->ypanning;
|
||||
dstwal->lotag = 0; //srcwal->lotag;
|
||||
dstwal->hitag = 0; //srcwal->hitag;
|
||||
dstwal->extra = -1; //srcwal->extra;
|
||||
|
||||
if (reset_some)
|
||||
{
|
||||
dstwal->nextwall = -1;
|
||||
dstwal->nextsector = -1;
|
||||
|
||||
dstwal->lotag = 0; //srcwal->lotag;
|
||||
dstwal->hitag = 0; //srcwal->hitag;
|
||||
dstwal->extra = -1; //srcwal->extra;
|
||||
#ifdef YAX_ENABLE
|
||||
yax_setnextwall(dst, YAX_CEILING, -1);
|
||||
yax_setnextwall(dst, YAX_FLOOR, -1);
|
||||
yax_setnextwall(dst, YAX_CEILING, -1);
|
||||
yax_setnextwall(dst, YAX_FLOOR, -1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void init_new_wall1(int16_t *suckwall, int32_t *mousxplc, int32_t *mousyplc)
|
||||
|
@ -2031,8 +2047,9 @@ static int32_t trace_loop(int32_t j, uint8_t *visitedwall, int16_t *ignore_ret,
|
|||
{
|
||||
int16_t refsect, ignore;
|
||||
int32_t k, n, refwall;
|
||||
|
||||
#ifndef YAX_ENABLE
|
||||
#ifdef YAX_ENABLE
|
||||
int32_t yaxp = (ignore_ret==NULL); // bleh
|
||||
#else
|
||||
UNREFERENCED_PARAMETER(trace_loop_yaxcf);
|
||||
#endif
|
||||
|
||||
|
@ -2073,6 +2090,9 @@ static int32_t trace_loop(int32_t j, uint8_t *visitedwall, int16_t *ignore_ret,
|
|||
return -2;
|
||||
}
|
||||
|
||||
if (ignore_ret) // auto-red wall feature
|
||||
onextwall[k] = onextwall[j];
|
||||
|
||||
Bmemcpy(&wall[k], &wall[j], sizeof(walltype));
|
||||
wall[k].point2 = k+1;
|
||||
// TODO: protect lotag/extra; see also hl-sector copying stuff
|
||||
|
@ -2089,6 +2109,15 @@ static int32_t trace_loop(int32_t j, uint8_t *visitedwall, int16_t *ignore_ret,
|
|||
|
||||
while (wall[j].nextwall>=0 && n>0)
|
||||
{
|
||||
#if 0
|
||||
//def YAX_ENABLE
|
||||
if (yaxp)
|
||||
{
|
||||
int32_t ns = wall[j].nextsector;
|
||||
if ((hlsectorbitmap[ns>>3]&(1<<(ns&7)))==0)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
j = wall[wall[j].nextwall].point2;
|
||||
// if (j!=refwall && (visitedwall[j>>3]&(1<<(j&7))))
|
||||
// ignore = 1;
|
||||
|
@ -2843,6 +2872,7 @@ void overheadeditor(void)
|
|||
#endif
|
||||
printmessage16("This wall now sector %d's first wall (sector[].wallptr)", secti);
|
||||
setfirstwall(secti, linehighlight);
|
||||
mkonwinvalid();
|
||||
asksave = 1;
|
||||
}
|
||||
}
|
||||
|
@ -3075,6 +3105,12 @@ void overheadeditor(void)
|
|||
|
||||
int32_t cf, thez;
|
||||
|
||||
if (numyaxbunches==YAX_MAXBUNCHES)
|
||||
{
|
||||
message("Bunch limit of %d reached, cannot extend", YAX_MAXBUNCHES);
|
||||
goto end_yax;
|
||||
}
|
||||
|
||||
if (!highlighted_sectors_in_one_component())
|
||||
{
|
||||
message("Sectors to extend must be in one connected component");
|
||||
|
@ -3160,15 +3196,6 @@ void overheadeditor(void)
|
|||
SECTORFLD(numsectors,z, !cf) = SECTORFLD(i,z, cf);
|
||||
SECTORFLD(numsectors,z, cf) = SECTORFLD(i,z, cf) - (1-2*cf)*DEFAULT_YAX_HEIGHT;
|
||||
|
||||
k = -1; // nextbunchnum
|
||||
for (i=0; i<numsectors; i++)
|
||||
{
|
||||
int16_t cb, fb;
|
||||
yax_getbunches(i, &cb, &fb);
|
||||
k = max(k, max(cb, fb));
|
||||
}
|
||||
k++;
|
||||
|
||||
newnumwalls = numwalls;
|
||||
numwalls = m;
|
||||
|
||||
|
@ -3183,9 +3210,9 @@ void overheadeditor(void)
|
|||
}
|
||||
|
||||
// link
|
||||
yax_setbunch(numsectors, !cf, k);
|
||||
yax_setbunch(numsectors, !cf, numyaxbunches);
|
||||
for (i=0; i<highlightsectorcnt; i++)
|
||||
yax_setbunch(highlightsector[i], cf, k);
|
||||
yax_setbunch(highlightsector[i], cf, numyaxbunches);
|
||||
|
||||
numwalls = newnumwalls;
|
||||
newnumwalls = -1;
|
||||
|
@ -3197,7 +3224,8 @@ void overheadeditor(void)
|
|||
Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap));
|
||||
update_highlightsector();
|
||||
|
||||
message("Extended %ss of highlighted sectors, creating bunch %d", cfs[cf], k);
|
||||
message("Extended %ss of highlighted sectors, creating bunch %d",
|
||||
cfs[cf], numyaxbunches);
|
||||
asksave = 1;
|
||||
end_yax: ;
|
||||
}
|
||||
|
@ -3433,11 +3461,21 @@ end_yax: ;
|
|||
|
||||
if (!didmakered && !hadouterpoint && newnumwalls<0)
|
||||
{
|
||||
// fade the screen to have the user's attention
|
||||
fade_editor_screen(-1);
|
||||
#ifdef YAX_ENABLE
|
||||
int16_t cb, fb;
|
||||
|
||||
didmakered |= !ask_if_sure("Insert outer loop and make red walls? (Y/N)", 0);
|
||||
clearkeys();
|
||||
yax_getbunches(tmprefsect, &cb, &fb);
|
||||
if (cb>=0 || fb>=0)
|
||||
didmakered = 1;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// fade the screen to have the user's attention
|
||||
fade_editor_screen(-1);
|
||||
|
||||
didmakered |= !ask_if_sure("Insert outer loop and make red walls? (Y/N)", 0);
|
||||
clearkeys();
|
||||
}
|
||||
}
|
||||
|
||||
if (!didmakered && !hadouterpoint && newnumwalls<0)
|
||||
|
@ -3470,6 +3508,7 @@ end_yax: ;
|
|||
if (clockdir(numwalls)==0)
|
||||
{
|
||||
int16_t begwalltomove = sector[refsect].wallptr+sector[refsect].wallnum;
|
||||
int32_t onwwasvalid = onwisvalid();
|
||||
|
||||
flipwalls(numwalls, newnumwalls);
|
||||
|
||||
|
@ -3477,8 +3516,9 @@ end_yax: ;
|
|||
if (refsect != numsectors-1)
|
||||
{
|
||||
walltype *tmpwall = Bmalloc(n * sizeof(walltype));
|
||||
int16_t *tmponw = Bmalloc(n * sizeof(int16_t));
|
||||
|
||||
if (!tmpwall)
|
||||
if (!tmpwall || !tmponw)
|
||||
{
|
||||
message("out of memory!");
|
||||
ExtUnInit();
|
||||
|
@ -3501,17 +3541,31 @@ end_yax: ;
|
|||
for (m=numwalls; m<newnumwalls; m++)
|
||||
wall[m].point2 += (begwalltomove-numwalls);
|
||||
|
||||
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));
|
||||
|
||||
Bmemcpy(tmpwall, &wall[numwalls], n*sizeof(walltype));
|
||||
Bmemmove(&wall[begwalltomove+n], &wall[begwalltomove], (numwalls-begwalltomove)*sizeof(walltype));
|
||||
Bmemmove(&wall[begwalltomove+n], &wall[begwalltomove],
|
||||
(numwalls-begwalltomove)*sizeof(walltype));
|
||||
Bmemcpy(&wall[begwalltomove], tmpwall, n*sizeof(walltype));
|
||||
|
||||
Bfree(tmpwall);
|
||||
Bfree(tmponw);
|
||||
}
|
||||
numwalls = newnumwalls;
|
||||
newnumwalls = -1;
|
||||
|
||||
mkonwinvalid();
|
||||
|
||||
for (m=begwalltomove; m<begwalltomove+n; m++)
|
||||
checksectorpointer(m, refsect);
|
||||
if (checksectorpointer(m, refsect) > 0)
|
||||
if (onwwasvalid && onextwall[wall[m].nextwall]>=0)
|
||||
{
|
||||
initprintf("%d %d\n", m, onextwall[wall[m].nextwall]);
|
||||
copy_some_wall_members(m, onextwall[wall[m].nextwall], 0);
|
||||
}
|
||||
|
||||
message("Attached new inner loop to sector %d", refsect);
|
||||
}
|
||||
|
@ -3760,6 +3814,10 @@ end_after_dragging:
|
|||
}
|
||||
else if (sectorhighlightstat == 1)
|
||||
{
|
||||
#ifdef YAX_ENABLE
|
||||
uint8_t *const havebunch = visited;
|
||||
int16_t cf, cb, fb, good=1;
|
||||
#endif
|
||||
dax = mousxplc;
|
||||
day = mousyplc;
|
||||
if (gridlock && grid > 0)
|
||||
|
@ -3769,7 +3827,39 @@ end_after_dragging:
|
|||
day -= sectorhighlighty;
|
||||
sectorhighlightx += dax;
|
||||
sectorhighlighty += day;
|
||||
#ifdef YAX_ENABLE
|
||||
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)
|
||||
{
|
||||
good = 0;
|
||||
goto try_dragging_sectors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try_dragging_sectors:
|
||||
if (!good)
|
||||
printmessage16("To drag extended sectors, all sectors of a bunch must be selected");
|
||||
else
|
||||
#endif
|
||||
for (i=0; i<highlightsectorcnt; i++)
|
||||
{
|
||||
for (WALLS_OF_SECTOR(highlightsector[i], j))
|
||||
|
@ -3800,7 +3890,7 @@ end_after_dragging:
|
|||
{
|
||||
pointhighlight = getpointhighlight(mousxplc, mousyplc, pointhighlight);
|
||||
|
||||
if (pointhighlight >= 0)
|
||||
if (pointhighlight >= 0 && (pointhighlight&0xc000)==0)
|
||||
{
|
||||
dragwall[0] = lastwall(pointhighlight);
|
||||
dragwall[1] = pointhighlight;
|
||||
|
@ -3959,7 +4049,7 @@ end_point_dragging:
|
|||
{
|
||||
int32_t opat=drawlinepat;
|
||||
|
||||
y1 = INT_MAX;
|
||||
y1 = INT32_MAX;
|
||||
|
||||
for (i=0; i<numsectors; i++)
|
||||
{
|
||||
|
@ -3979,7 +4069,7 @@ end_point_dragging:
|
|||
}
|
||||
|
||||
drawlinepat = 0x11111111;
|
||||
if (y1 != INT_MAX)
|
||||
if (y1 != INT32_MAX)
|
||||
drawline16base(halfxdim16,midydim16, 0,0, 0,y1, editorcolors[14]);
|
||||
// else
|
||||
// drawline16base(halfxdim16,midydim16, 0,0, 0,getscreenvdisp(-pos.z, zoom), editorcolors[14]);
|
||||
|
@ -4310,6 +4400,7 @@ end_point_dragging:
|
|||
deletesector(joinsector[1]);
|
||||
|
||||
printmessage16("Sectors joined.");
|
||||
mkonwinvalid();
|
||||
asksave = 1;
|
||||
#ifdef YAX_ENABLE
|
||||
yax_update(0);
|
||||
|
@ -4440,9 +4531,9 @@ end_join_sectors:
|
|||
|
||||
if (keystatus[0x2e]) // C (make circle of points)
|
||||
{
|
||||
if (highlightsectorcnt >= 0)
|
||||
if (highlightsectorcnt > 0)
|
||||
duplicate_selected_sectors();
|
||||
else if (highlightcnt >= 0)
|
||||
else if (highlightcnt > 0)
|
||||
duplicate_selected_sprites();
|
||||
|
||||
else if (circlewall >= 0)
|
||||
|
@ -4539,6 +4630,8 @@ end_join_sectors:
|
|||
asksave = 1;
|
||||
printmessage16("Circle points inserted.");
|
||||
circlewall = -1;
|
||||
|
||||
mkonwinvalid();
|
||||
}
|
||||
else
|
||||
printmessage16("Inserting circle points would exceed wall limit.");
|
||||
|
@ -4722,7 +4815,7 @@ check_next_sector: ;
|
|||
sector[numsectors].floorz = (32<<8);
|
||||
|
||||
for (i=numwalls; i<newnumwalls; i++)
|
||||
copy_some_wall_members(i, -1);
|
||||
copy_some_wall_members(i, -1, 1);
|
||||
#ifdef YAX_ENABLE
|
||||
yax_setbunches(numsectors, -1, -1);
|
||||
#endif
|
||||
|
@ -4790,7 +4883,7 @@ check_next_sector: ;
|
|||
{
|
||||
wall[i].point2 += (suckwall-numwalls);
|
||||
|
||||
copy_some_wall_members(i, suckwall+j);
|
||||
copy_some_wall_members(i, suckwall+j, 1);
|
||||
wall[i].cstat &= ~(1+16+32+64);
|
||||
}
|
||||
|
||||
|
@ -4822,6 +4915,7 @@ check_next_sector: ;
|
|||
else
|
||||
#endif
|
||||
printmessage16("Added inner loop to sector %d", k);
|
||||
mkonwinvalid();
|
||||
}
|
||||
}
|
||||
else // if connected to at least one other sector
|
||||
|
@ -4833,7 +4927,7 @@ check_next_sector: ;
|
|||
|
||||
for (i=numwalls; i<newnumwalls; i++)
|
||||
{
|
||||
copy_some_wall_members(i, suckwall);
|
||||
copy_some_wall_members(i, suckwall, 1);
|
||||
if (checksectorpointer(i, numsectors) > 0)
|
||||
{
|
||||
// if new red line, prefer the other-side wall as base
|
||||
|
@ -4914,7 +5008,7 @@ check_next_sector: ;
|
|||
newnumwalls--; //first fix up the new walls
|
||||
for (i=numwalls; i<newnumwalls; i++)
|
||||
{
|
||||
copy_some_wall_members(i, startwall);
|
||||
copy_some_wall_members(i, startwall, 1);
|
||||
wall[i].point2 = i+1;
|
||||
}
|
||||
|
||||
|
@ -5104,6 +5198,8 @@ split_not_enough_walls:
|
|||
|
||||
newnumwalls = -1;
|
||||
asksave = 1;
|
||||
|
||||
mkonwinvalid();
|
||||
#ifdef YAX_ENABLE
|
||||
yax_update(0);
|
||||
yax_updategrays(pos.z);
|
||||
|
@ -5231,6 +5327,7 @@ end_space_handling:
|
|||
}
|
||||
|
||||
printmessage16("Highlighted sectors deleted.");
|
||||
mkonwinvalid();
|
||||
k = 1;
|
||||
break;
|
||||
}
|
||||
|
@ -5271,6 +5368,7 @@ end_space_handling:
|
|||
if (fb>=0) hlsectorbitmap[fb>>3] |= (1<<(fb&7));
|
||||
#endif
|
||||
deletesector(i);
|
||||
mkonwinvalid();
|
||||
printmessage16("Sector deleted.");
|
||||
}
|
||||
|
||||
|
@ -5318,9 +5416,9 @@ end_space_handling:
|
|||
|
||||
if (keystatus[0xd2] || keystatus[0x17]) //InsertPoint
|
||||
{
|
||||
if (highlightsectorcnt >= 0)
|
||||
if (highlightsectorcnt > 0)
|
||||
duplicate_selected_sectors();
|
||||
else if (highlightcnt >= 0)
|
||||
else if (highlightcnt > 0)
|
||||
duplicate_selected_sprites();
|
||||
else if (linehighlight >= 0)
|
||||
{
|
||||
|
@ -5426,6 +5524,7 @@ point_not_inserted:
|
|||
}
|
||||
}
|
||||
|
||||
mkonwinvalid();
|
||||
if (m==j)
|
||||
message("Inserted %d points for constrained wall.", m);
|
||||
else
|
||||
|
@ -5435,6 +5534,7 @@ point_not_inserted:
|
|||
#endif
|
||||
{
|
||||
insertpoint(linehighlight, dax,day);
|
||||
mkonwinvalid();
|
||||
printmessage16("Point inserted.");
|
||||
}
|
||||
#ifdef YAX_ENABLE
|
||||
|
@ -5572,6 +5672,7 @@ CANCEL:
|
|||
for (i=0; i<MAXSPRITES; i++) sprite[i].extra = -1;
|
||||
|
||||
RESET_EDITOR_VARS();
|
||||
mkonwinvalid();
|
||||
|
||||
reset_default_mapstate();
|
||||
|
||||
|
@ -5972,8 +6073,8 @@ int32_t LoadBoard(const char *filename, uint32_t flags)
|
|||
for (i=0; i<MAXWALLS; i++) wall[i].extra = -1;
|
||||
for (i=0; i<MAXSPRITES; i++) sprite[i].extra = -1;
|
||||
|
||||
editorzrange[0] = INT_MIN;
|
||||
editorzrange[1] = INT_MAX;
|
||||
editorzrange[0] = INT32_MIN;
|
||||
editorzrange[1] = INT32_MAX;
|
||||
|
||||
ExtPreLoadMap();
|
||||
i = loadboard(boardfilename,(flags&4)|loadingflags, &pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
||||
|
@ -5985,6 +6086,8 @@ int32_t LoadBoard(const char *filename, uint32_t flags)
|
|||
return i;
|
||||
}
|
||||
|
||||
mkonwinvalid();
|
||||
|
||||
highlightcnt = -1;
|
||||
Bmemset(show2dwall, 0, sizeof(show2dwall)); //Clear all highlights
|
||||
Bmemset(show2dsprite, 0, sizeof(show2dsprite));
|
||||
|
@ -6292,15 +6395,18 @@ static int32_t clockdir(int16_t wallstart) //Returns: 0 is CW, 1 is CCW
|
|||
|
||||
static void flipwalls(int16_t numwalls, int16_t newnumwalls)
|
||||
{
|
||||
int32_t i, j, nume, tempint;
|
||||
int32_t i, j, nume;
|
||||
|
||||
nume = newnumwalls-numwalls;
|
||||
|
||||
for (i=numwalls; i<numwalls+(nume>>1); i++)
|
||||
{
|
||||
j = numwalls+newnumwalls-i-1;
|
||||
tempint = wall[i].x; wall[i].x = wall[j].x; wall[j].x = tempint;
|
||||
tempint = wall[i].y; wall[i].y = wall[j].y; wall[j].y = tempint;
|
||||
|
||||
swapshort(&onextwall[i], &onextwall[j]);
|
||||
|
||||
swaplong(&wall[i].x, &wall[j].x);
|
||||
swaplong(&wall[i].y, &wall[j].y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6527,7 +6633,7 @@ int32_t wallength(int16_t i)
|
|||
int64_t day = POINT2(i).y - wall[i].y;
|
||||
#if 1 //def POLYMOST
|
||||
int64_t hypsq = dax*dax + day*day;
|
||||
if (hypsq > (int64_t)INT_MAX)
|
||||
if (hypsq > (int64_t)INT32_MAX)
|
||||
return (int32_t)sqrt((double)hypsq);
|
||||
else
|
||||
return ksqrt((int32_t)hypsq);
|
||||
|
@ -7854,7 +7960,11 @@ static void copysector(int16_t soursector, int16_t destsector, int16_t deststart
|
|||
Bmemcpy(&wall[newnumwalls], &wall[j], sizeof(walltype));
|
||||
wall[newnumwalls].point2 += deststartwall-startwall;
|
||||
|
||||
if (wall[newnumwalls].nextwall >= 0)
|
||||
if (wall[newnumwalls].nextwall < 0)
|
||||
{
|
||||
onextwall[newnumwalls] = onextwall[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
k = wall[newnumwalls].nextsector;
|
||||
if (oldtonewsect && oldtonewsect[k]>=0)
|
||||
|
@ -7891,6 +8001,7 @@ nonextsector:
|
|||
// wall[newnumwalls].nextwall += deststartwall-startwall;
|
||||
// wall[newnumwalls].nextsector += destsector-soursector;
|
||||
}
|
||||
|
||||
newnumwalls++;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,10 +72,7 @@ extern char default_buildkeys[NUMBUILDKEYS];
|
|||
static char *const keys = default_buildkeys;
|
||||
extern char remap[256];
|
||||
extern int32_t remapinit;
|
||||
extern double msens;
|
||||
extern int32_t editorgridextent, grid, autogrid;
|
||||
static int32_t default_grid=3;
|
||||
extern int32_t graphicsmode;
|
||||
extern int32_t AmbienceToggle, MixRate;
|
||||
extern int32_t ParentalLock;
|
||||
|
||||
|
|
|
@ -192,8 +192,10 @@ int16_t editstatus = 0;
|
|||
extern char m32_debugstr[64][128];
|
||||
extern int32_t m32_numdebuglines;
|
||||
# define yaxdebug(fmt, ...) do { if (m32_numdebuglines<64) Bsnprintf(m32_debugstr[m32_numdebuglines++], 128, fmt, ##__VA_ARGS__); } while (0)
|
||||
# define yaxprintf(fmt, ...) do { initprintf(fmt, ##__VA_ARGS__); } while (0)
|
||||
#else
|
||||
# define yaxdebug(fmt, ...)
|
||||
# define yaxprintf(fmt, ...)
|
||||
#endif
|
||||
|
||||
uint8_t graysectbitmap[MAXSECTORS>>3];
|
||||
|
@ -212,15 +214,16 @@ void yax_updategrays(int32_t posze)
|
|||
Bmemset(graysectbitmap, 0, sizeof(graysectbitmap));
|
||||
Bmemset(graywallbitmap, 0, sizeof(graywallbitmap));
|
||||
|
||||
// update grayouts due to editorzrange
|
||||
for (i=0; i<numsectors; i++)
|
||||
{
|
||||
#ifdef YAX_ENABLE
|
||||
int16_t cb, fb;
|
||||
|
||||
yax_getbunches(i, &cb, &fb);
|
||||
// update grayouts due to yax
|
||||
k = ((cb<0 || sector[i].ceilingz < posze) && (fb<0 || posze <= sector[i].floorz));
|
||||
#endif
|
||||
// update grayouts due to editorzrange
|
||||
k &= (sector[i].ceilingz >= editorzrange[0] && sector[i].floorz <= editorzrange[1]);
|
||||
|
||||
if (!k) // outside bounds, gray out!
|
||||
|
@ -242,7 +245,7 @@ static int32_t scansector_retfast = 0;
|
|||
static int32_t scansector_collectsprites = 1;
|
||||
static int32_t yax_globalcf = -1;
|
||||
static int32_t yax_globallev = YAX_MAXDRAWS;
|
||||
//static int32_t yax_globalbunch = -1;
|
||||
static int32_t yax_globalbunch = -1;
|
||||
|
||||
// duplicated tsprites
|
||||
// [i]:
|
||||
|
@ -256,27 +259,10 @@ static int16_t yax_tsprite[1 + 2*YAX_MAXDRAWS][MAXSPRITESONSCREEN];
|
|||
int16_t yax_bunchnum[MAXSECTORS][2];
|
||||
int16_t yax_nextwall[MAXWALLS][2];
|
||||
|
||||
static int32_t yax_islockededge(/*int16_t sec,*/ int16_t line, int16_t cf)
|
||||
#if 1
|
||||
static int32_t yax_islockededge(int16_t line, int16_t cf)
|
||||
{
|
||||
// UNREFERENCED_PARAMETER(sec);
|
||||
return !!(wall[line].cstat&(YAX_NEXTWALLBIT(cf)));
|
||||
}
|
||||
#else
|
||||
{
|
||||
int16_t bunchnum, nextbunch;
|
||||
int16_t ns = wall[line].nextsector;
|
||||
|
||||
bunchnum = yax_getbunch(sec, cf);
|
||||
|
||||
if (ns < 0)
|
||||
return (bunchnum >= 0);
|
||||
|
||||
nextbunch = yax_getbunch(ns, cf);
|
||||
|
||||
return (bunchnum != nextbunch);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define YAX_BUNCHNUM(Sect, Cf) (*(§or[Sect].ceilingxpanning + 8*Cf))
|
||||
|
||||
|
@ -364,17 +350,17 @@ void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall)
|
|||
}
|
||||
}
|
||||
|
||||
//// in-struct --> array transfer; list construction
|
||||
//// in-struct --> array transfer (only resetstat==0); list construction
|
||||
// resetstat: 0: reset and read data from structs and construct linked lists etc.
|
||||
// 1: only reset
|
||||
// 2: read data from game-time arrays and construct linked lists etc.
|
||||
void yax_update(int32_t resetstat)
|
||||
{
|
||||
// TODO: always make bunchnums consecutive
|
||||
int32_t i, j, oeditstatus=editstatus;
|
||||
int16_t cb, fb, tmpsect;
|
||||
|
||||
numyaxbunches = 0;
|
||||
if (resetstat != 2)
|
||||
numyaxbunches = 0;
|
||||
|
||||
for (i=0; i<MAXSECTORS; i++)
|
||||
{
|
||||
|
@ -393,6 +379,47 @@ void yax_update(int32_t resetstat)
|
|||
|
||||
// constuct singly linked list of sectors-of-bunch
|
||||
editstatus = (resetstat==0); // read bunchnums directly from the sector struct!
|
||||
|
||||
if (resetstat==0)
|
||||
{
|
||||
// make bunchnums consecutive
|
||||
uint8_t *const havebunch = (uint8_t *)tempbuf;
|
||||
uint8_t *const bunchmap = havebunch + (YAX_MAXBUNCHES>>3);
|
||||
int32_t dasub = 0;
|
||||
|
||||
Bmemset(havebunch, 0, YAX_MAXBUNCHES>>3);
|
||||
for (i=0; i<numsectors; i++)
|
||||
{
|
||||
yax_getbunches(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<YAX_MAXBUNCHES; i++)
|
||||
{
|
||||
if ((havebunch[i>>3]&(1<<(i&7)))==0)
|
||||
{
|
||||
bunchmap[i] = 255;
|
||||
dasub++;
|
||||
continue;
|
||||
}
|
||||
|
||||
bunchmap[i] = i-dasub;
|
||||
}
|
||||
|
||||
for (i=0; i<numsectors; i++)
|
||||
{
|
||||
yax_getbunches(i, &cb, &fb);
|
||||
if (cb>=0)
|
||||
yax_setbunch(i, YAX_CEILING, bunchmap[cb]);
|
||||
if (fb>=0)
|
||||
yax_setbunch(i, YAX_FLOOR, bunchmap[fb]);
|
||||
}
|
||||
}
|
||||
|
||||
// in-struct --> array transfer (resetstat==0) and list construction
|
||||
for (i=numsectors-1; i>=0; i--)
|
||||
{
|
||||
yax_getbunches(i, &cb, &fb);
|
||||
|
@ -457,7 +484,7 @@ int32_t yax_getneighborsect(int32_t x, int32_t y, int32_t sectnum, int32_t cf, i
|
|||
if (bunchnum < 0)
|
||||
return -1;
|
||||
|
||||
for (i=headsectbunch[!cf][bunchnum]; i!=-1; i=nextsectbunch[!cf][i])
|
||||
for (SECTORS_OF_BUNCH(bunchnum, !cf, i))
|
||||
if (inside(x, y, i)==1)
|
||||
{
|
||||
if (ret_bunchnum)
|
||||
|
@ -468,95 +495,115 @@ int32_t yax_getneighborsect(int32_t x, int32_t y, int32_t sectnum, int32_t cf, i
|
|||
return -1;
|
||||
}
|
||||
|
||||
// indexed as a list:
|
||||
static int16_t bunches[2][YAX_MAXBUNCHES];
|
||||
// indexed with bunchnums directly:
|
||||
static int16_t bunchsec[YAX_MAXBUNCHES], bunchdist[YAX_MAXBUNCHES];
|
||||
|
||||
static int32_t ymostallocsize = 0; // numyaxbunches*xdimen (no sizeof(int16_t) here!)
|
||||
static int16_t *yumost=NULL, *ydmost=NULL; // used as if [numyaxbunches][xdimen]
|
||||
static uint8_t haveymost[YAX_MAXBUNCHES>>3];
|
||||
|
||||
// adapted from build.c
|
||||
static void yax_getclosestpointonwall(int32_t dawall, int32_t *closestx, int32_t *closesty)
|
||||
{
|
||||
int64_t i, j, wx,wy, wx2,wy2, dx, dy;
|
||||
|
||||
wx = wall[dawall].x;
|
||||
wy = wall[dawall].y;
|
||||
wx2 = wall[wall[dawall].point2].x;
|
||||
wy2 = wall[wall[dawall].point2].y;
|
||||
|
||||
dx = wx2 - wx;
|
||||
dy = wy2 - wy;
|
||||
i = dx*(globalposx-wx) + dy*(globalposy-wy);
|
||||
if (i <= 0) { *closestx = wx; *closesty = wy; return; }
|
||||
j = dx*dx + dy*dy;
|
||||
if (i >= j) { *closestx = wx2; *closesty = wy2; return; }
|
||||
i=((i<<15)/j)<<15;
|
||||
*closestx = wx + ((dx*i)>>30);
|
||||
*closesty = wy + ((dy*i)>>30);
|
||||
}
|
||||
|
||||
static inline int32_t yax_walldist(int32_t w)
|
||||
{
|
||||
return klabs(wall[w].x-globalposx) + klabs(wall[w].y-globalposy);
|
||||
int32_t closestx, closesty;
|
||||
|
||||
yax_getclosestpointonwall(w, &closestx, &closesty);
|
||||
return klabs(closestx-globalposx) + klabs(closesty-globalposy);
|
||||
|
||||
// return klabs(wall[w].x-globalposx) + klabs(wall[w].y-globalposy);
|
||||
}
|
||||
|
||||
static int yax_cmpbunches(const int16_t *b1, const int16_t *b2)
|
||||
// calculate distances to bunches and best start-drawing sectors
|
||||
static void yax_scanbunches(int32_t bbeg, int32_t numhere, const uint8_t *lastgotsector)
|
||||
{
|
||||
int32_t s1,s2, w1,w2;
|
||||
int32_t bnchcnt, bunchnum, j, k, w, ns;
|
||||
int32_t startwall, endwall;
|
||||
|
||||
s1 = headsectbunch[yax_globalcf][*b1];
|
||||
s2 = headsectbunch[yax_globalcf][*b2];
|
||||
scansector_retfast = 1;
|
||||
scansector_collectsprites = 0;
|
||||
|
||||
w1 = sector[s1].wallptr;
|
||||
w2 = sector[s2].wallptr;
|
||||
|
||||
#if 1
|
||||
return (yax_walldist(w2) - yax_walldist(w1));
|
||||
#else
|
||||
for (bnchcnt=bbeg; bnchcnt<bbeg+numhere; bnchcnt++)
|
||||
{
|
||||
int64_t dx1,dy1, dx2,dy2, r;
|
||||
int32_t walldist, bestsec=-1;
|
||||
int32_t bestwalldist=INT32_MAX, bestbestdist=INT32_MAX;
|
||||
|
||||
dx1 = wall[w1].x-globalposx; dy1 = wall[w1].y-globalposy;
|
||||
dx2 = wall[w2].x-globalposx; dy2 = wall[w2].y-globalposy;
|
||||
bunchnum = bunches[yax_globalcf][bnchcnt];
|
||||
|
||||
r = (dx2*dx2 + dy2*dy2) - (dx1*dx1 + dy1*dy1);
|
||||
if (r > 0)
|
||||
return 1;
|
||||
return r>>63;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int32_t yax_getbestsector(int32_t bunchnum, int32_t cf, const int16_t *ourbunch, int16_t sectnum)
|
||||
{
|
||||
int32_t k;
|
||||
|
||||
if (bunchnum==ourbunch[cf])
|
||||
{
|
||||
k = yax_getneighborsect(globalposx, globalposy, sectnum, cf, NULL);
|
||||
if (k >= 0)
|
||||
return k;
|
||||
}
|
||||
|
||||
{
|
||||
int32_t j, walldist, bestsec=-1, bestwalldist=INT32_MAX;
|
||||
int32_t startwall, endwall, checkthis;
|
||||
|
||||
scansector_retfast = 1;
|
||||
scansector_collectsprites = 0;
|
||||
for (k = headsectbunch[!cf][bunchnum]; k != -1; k = nextsectbunch[!cf][k])
|
||||
for (SECTORS_OF_BUNCH(bunchnum,!yax_globalcf, k))
|
||||
{
|
||||
int32_t checkthisec = 0;
|
||||
|
||||
if (inside(globalposx, globalposy, k)==1)
|
||||
{
|
||||
bestsec = k;
|
||||
bestbestdist = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
startwall = sector[k].wallptr;
|
||||
endwall = startwall+sector[k].wallnum;
|
||||
|
||||
checkthis = 0;
|
||||
for (j=startwall; j<endwall; j++)
|
||||
{
|
||||
/*
|
||||
if (wall[j].nextsector == globalcursectnum)
|
||||
{
|
||||
scansector_collectsprites = 1;
|
||||
scansector_retfast = 0;
|
||||
return k;
|
||||
}
|
||||
if ((w=yax_getnextwall(j,!yax_globalcf))>=0)
|
||||
if ((ns=wall[w].nextsector)>=0)
|
||||
if ((lastgotsector[ns>>3]&(1<<(ns&7)))==0)
|
||||
continue;
|
||||
*/
|
||||
walldist = yax_walldist(j);
|
||||
if (walldist < bestwalldist)
|
||||
{
|
||||
checkthis = 1;
|
||||
checkthisec = 1;
|
||||
bestwalldist = walldist;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkthis)
|
||||
if (checkthisec)
|
||||
{
|
||||
numscans = numbunches = 0;
|
||||
scansector(k);
|
||||
if (numbunches > 0)
|
||||
{
|
||||
bestsec = k;
|
||||
bestbestdist = bestwalldist;
|
||||
}
|
||||
}
|
||||
}
|
||||
scansector_collectsprites = 1;
|
||||
scansector_retfast = 0;
|
||||
|
||||
if (bestsec < 0)
|
||||
bestsec = headsectbunch[!cf][bunchnum];
|
||||
|
||||
return bestsec;
|
||||
bunchsec[bunchnum] = bestsec;
|
||||
bunchdist[bunchnum] = bestbestdist;
|
||||
}
|
||||
|
||||
scansector_collectsprites = 1;
|
||||
scansector_retfast = 0;
|
||||
}
|
||||
|
||||
static int yax_cmpbunches(const int16_t *b1, const int16_t *b2)
|
||||
{
|
||||
return (bunchdist[*b2] - bunchdist[*b1]);
|
||||
}
|
||||
|
||||
static void yax_tweakpicnums(int32_t bunchnum, int32_t cf, int32_t restore)
|
||||
|
@ -564,7 +611,7 @@ static void yax_tweakpicnums(int32_t bunchnum, int32_t cf, int32_t restore)
|
|||
static int16_t opicnum[2][MAXSECTORS];
|
||||
int32_t i;
|
||||
|
||||
for (i=headsectbunch[cf][bunchnum]; i!=-1; i=nextsectbunch[cf][i])
|
||||
for (SECTORS_OF_BUNCH(bunchnum, cf, i))
|
||||
if ((SECTORFLD(i,stat, cf)&(128+256))==0)
|
||||
{
|
||||
if (!restore)
|
||||
|
@ -638,12 +685,26 @@ void yax_preparedrawrooms(void)
|
|||
|
||||
g_nodraw = 1;
|
||||
Bmemset(yax_spritesortcnt, 0, sizeof(yax_spritesortcnt));
|
||||
Bmemset(haveymost, 0, (numyaxbunches+7)>>3);
|
||||
|
||||
if (ymostallocsize < xdimen*numyaxbunches)
|
||||
{
|
||||
ymostallocsize = xdimen*numyaxbunches;
|
||||
yumost = Brealloc(yumost, ymostallocsize*sizeof(int16_t));
|
||||
ydmost = Brealloc(ydmost, ymostallocsize*sizeof(int16_t));
|
||||
|
||||
if (!yumost || !ydmost)
|
||||
{
|
||||
initprintf("OUT OF MEMORY in yax_preparedrawrooms!\n");
|
||||
uninitengine();
|
||||
exit(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectnum)
|
||||
{
|
||||
static uint8_t havebunch[YAX_MAXBUNCHES>>3];
|
||||
static int16_t bunches[2][YAX_MAXBUNCHES], bestsec[2][YAX_MAXBUNCHES];
|
||||
|
||||
int32_t i, j, k, lev, cf;
|
||||
int32_t bnchcnt, bnchnum[2] = {0,0}, maxlev[2];
|
||||
|
@ -699,6 +760,12 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
|
|||
j = yax_getbunch(i, cf);
|
||||
if (j >= 0 && !(havebunch[j>>3]&(1<<(j&7))))
|
||||
{
|
||||
if ((haveymost[j>>3]&(1<<(j&7)))==0)
|
||||
{
|
||||
yaxdebug("%s, l %d: skipped bunch %d (no *most)", cf?"v":"^", lev, j);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((SECTORFLD(i,stat, cf)&2) ||
|
||||
(cf==0 && globalposz > sector[i].ceilingz) ||
|
||||
(cf==1 && globalposz < sector[i].floorz))
|
||||
|
@ -714,26 +781,27 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
|
|||
if (numhere > 0)
|
||||
{
|
||||
// found bunches -- need to fake-draw
|
||||
if (numhere > 1 && lev != YAX_MAXDRAWS-1)
|
||||
Bmemset(lgotsector, 0, (numsectors+7)>>3);
|
||||
|
||||
yax_scanbunches(bbeg, numhere, (uint8_t *)gotsector);
|
||||
|
||||
qsort(&bunches[cf][bbeg], numhere, sizeof(int16_t),
|
||||
(int(*)(const void *, const void *))&yax_cmpbunches);
|
||||
|
||||
if (numhere > 1 && lev != YAX_MAXDRAWS-1)
|
||||
Bmemset(lgotsector, 0, (numsectors+7)>>3);
|
||||
|
||||
for (bnchcnt=bbeg; bnchcnt < bbeg+numhere; bnchcnt++)
|
||||
{
|
||||
j = bunches[cf][bnchcnt]; // the actual bunchnum...
|
||||
// yax_globalbunch = j;
|
||||
yax_globalbunch = j;
|
||||
#ifdef YAX_DEBUG
|
||||
t=getticks();
|
||||
#endif
|
||||
k = yax_getbestsector(j, cf, ourbunch, sectnum);
|
||||
bestsec[cf][bnchcnt] = k;
|
||||
k = bunchsec[j];
|
||||
|
||||
if (k < 0)
|
||||
{
|
||||
#ifdef YAX_DEBUG
|
||||
initprintf("%s, l %d: skipped bunch %d\n", cf?"v":"^", lev, j);
|
||||
#endif
|
||||
yaxprintf("%s, l %d: skipped bunch %d\n", cf?"v":"^", lev, j);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -770,7 +838,7 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
|
|||
}
|
||||
}
|
||||
|
||||
yax_globalcf = -1;
|
||||
// yax_globalcf = -1;
|
||||
|
||||
// now comes the real drawing!
|
||||
g_nodraw = 0;
|
||||
|
@ -785,6 +853,8 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
|
|||
|
||||
for (cf=0; cf<2; cf++)
|
||||
{
|
||||
yax_globalcf = cf;
|
||||
|
||||
for (lev=maxlev[cf]; lev>=0; lev--)
|
||||
{
|
||||
yax_globallev = YAX_MAXDRAWS + (-1 + 2*cf)*(lev+1);
|
||||
|
@ -793,8 +863,8 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
|
|||
for (bnchcnt=bnchbeg[lev][cf]; bnchcnt<bnchend[lev][cf]; bnchcnt++)
|
||||
{
|
||||
j = bunches[cf][bnchcnt]; // the actual bunchnum...
|
||||
k = bestsec[cf][bnchcnt]; // best start-drawing sector
|
||||
// yax_globalbunch = j;
|
||||
k = bunchsec[j]; // best start-drawing sector
|
||||
yax_globalbunch = j;
|
||||
#ifdef YAX_DEBUG
|
||||
t=getticks();
|
||||
#endif
|
||||
|
@ -822,6 +892,8 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
|
|||
#ifdef YAX_DEBUG
|
||||
t=getticks();
|
||||
#endif
|
||||
yax_globalcf = -1; // remove?
|
||||
yax_globalbunch = -1;
|
||||
yax_globallev = YAX_MAXDRAWS;
|
||||
scansector_collectsprites = 0;
|
||||
|
||||
|
@ -840,6 +912,31 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
|
|||
#ifdef ENGINE_SCREENSHOT_DEBUG
|
||||
engine_screenshot = 0;
|
||||
#endif
|
||||
|
||||
#ifdef YAX_DEBUG_YMOSTS
|
||||
begindrawing();
|
||||
for (i=0; i<numyaxbunches; i++)
|
||||
{
|
||||
int32_t x, x1;
|
||||
char purple = getclosestcol(63, 0, 63);
|
||||
char yellow = getclosestcol(63, 63, 0);
|
||||
|
||||
if ((haveymost[i>>3]&(1<<i&7))==0)
|
||||
continue;
|
||||
|
||||
x1 = i*xdimen;
|
||||
|
||||
for (x=x1; x<x1+xdimen; x++)
|
||||
{
|
||||
if (yumost[x] >= 0 && yumost[x] < ydim)
|
||||
*((char *)frameplace + yumost[x]*bytesperline + x-x1) = purple;
|
||||
|
||||
if (ydmost[x]-1 >= 0 && ydmost[x]-1 < ydim)
|
||||
*((char *)frameplace + (ydmost[x]-1)*bytesperline + x-x1) = yellow;
|
||||
}
|
||||
}
|
||||
enddrawing();
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef YAX_BUNCHNUM
|
||||
|
@ -1408,6 +1505,10 @@ int32_t clipmapinfo_load(const char *filename)
|
|||
|
||||
////// //////
|
||||
|
||||
#define WALLS_ARE_CONSISTENT(k) ((wall[k].x == x2 && wall[k].y == y2) \
|
||||
&& ((wall[wall[k].point2]).x == x1 && (wall[wall[k].point2]).y == y1))
|
||||
|
||||
const int16_t *chsecptr_onextwall = NULL;
|
||||
|
||||
int32_t checksectorpointer(int16_t i, int16_t sectnum)
|
||||
{
|
||||
|
@ -1432,15 +1533,29 @@ int32_t checksectorpointer(int16_t i, int16_t sectnum)
|
|||
k = wall[i].nextwall;
|
||||
if (k >= 0) //Check for early exit
|
||||
{
|
||||
if (wall[k].x == x2 && wall[k].y == y2)
|
||||
if ((wall[wall[k].point2]).x == x1 && (wall[wall[k].point2]).y == y1)
|
||||
return 0;
|
||||
if (WALLS_ARE_CONSISTENT(k))
|
||||
return 0;
|
||||
|
||||
wall[k].nextwall = wall[k].nextsector = -1;
|
||||
}
|
||||
|
||||
wall[i].nextsector = wall[i].nextwall = -1;
|
||||
|
||||
if (chsecptr_onextwall && (k=chsecptr_onextwall[i])>=0 && wall[k].nextwall<0)
|
||||
{
|
||||
if (WALLS_ARE_CONSISTENT(k))
|
||||
{
|
||||
j = sectorofwall(k);
|
||||
|
||||
wall[i].nextsector = j;
|
||||
wall[i].nextwall = k;
|
||||
wall[k].nextsector = sectnum;
|
||||
wall[k].nextwall = i;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (j=0; j<numsectors; j++)
|
||||
{
|
||||
if (j == sectnum)
|
||||
|
@ -1449,13 +1564,10 @@ int32_t checksectorpointer(int16_t i, int16_t sectnum)
|
|||
YAX_SKIPSECTOR(j);
|
||||
|
||||
startwall = sector[j].wallptr;
|
||||
endwall = startwall + sector[j].wallnum - 1;
|
||||
for (k=startwall; k<=endwall; k++)
|
||||
endwall = startwall + sector[j].wallnum;
|
||||
for (k=startwall; k<endwall; k++)
|
||||
{
|
||||
if (wall[k].x != x2 || wall[k].y != y2)
|
||||
continue;
|
||||
|
||||
if (wall[wall[k].point2].x != x1 || wall[wall[k].point2].y != y1)
|
||||
if (!WALLS_ARE_CONSISTENT(k))
|
||||
continue;
|
||||
|
||||
// Don't create link if the other side is connected to another wall.
|
||||
|
@ -1474,9 +1586,12 @@ int32_t checksectorpointer(int16_t i, int16_t sectnum)
|
|||
numnewwalls++;
|
||||
}
|
||||
}
|
||||
return(numnewwalls);
|
||||
|
||||
return numnewwalls;
|
||||
}
|
||||
|
||||
#undef WALLS_ARE_CONSISTENT
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && !defined(NOASM)
|
||||
|
||||
|
@ -3774,6 +3889,7 @@ static void parascan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat, i
|
|||
int32_t j, k, l, m, n, x, z, wallnum, nextsectnum, globalhorizbak;
|
||||
int16_t *topptr, *botptr;
|
||||
|
||||
int32_t dapyscale;
|
||||
int16_t dapskybits;
|
||||
static const int16_t zeropskyoff[MAXPSKYTILES];
|
||||
const int16_t *dapskyoff;
|
||||
|
@ -3784,8 +3900,6 @@ static void parascan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat, i
|
|||
sectnum = thesector[bunchfirst[bunch]]; sec = §or[sectnum];
|
||||
|
||||
globalhorizbak = globalhoriz;
|
||||
if (parallaxyscale != 65536)
|
||||
globalhoriz = mulscale16(globalhoriz-(ydimen>>1),parallaxyscale) + (ydimen>>1);
|
||||
globvis = globalpisibility;
|
||||
//globalorientation = 0L;
|
||||
if (sec->visibility != 0) globvis = mulscale4(globvis,(int32_t)((uint8_t)(sec->visibility+16)));
|
||||
|
@ -3822,6 +3936,7 @@ static void parascan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat, i
|
|||
|
||||
dapskyoff = zeropskyoff;
|
||||
dapskybits = pskybits;
|
||||
dapyscale = parallaxyscale;
|
||||
|
||||
for (j=0; j<pskynummultis; j++)
|
||||
{
|
||||
|
@ -3829,10 +3944,14 @@ static void parascan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat, i
|
|||
{
|
||||
dapskybits = pskymultibits[j];
|
||||
dapskyoff = pskymultioff[j];
|
||||
dapyscale = pskymultiyscale[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dapyscale != 65536)
|
||||
globalhoriz = mulscale16(globalhoriz-(ydimen>>1),dapyscale) + (ydimen>>1);
|
||||
|
||||
k = 11 - (picsiz[globalpicnum]&15) - dapskybits;
|
||||
x = -1;
|
||||
|
||||
|
@ -3941,6 +4060,10 @@ static void drawalls(int32_t bunch)
|
|||
int32_t z, wallnum, sectnum, nextsectnum;
|
||||
int32_t startsmostwallcnt, startsmostcnt, gotswall;
|
||||
char andwstat1, andwstat2;
|
||||
#ifdef YAX_ENABLE
|
||||
int32_t baselevp, checkcf;
|
||||
int16_t bn[2];
|
||||
#endif
|
||||
|
||||
z = bunchfirst[bunch];
|
||||
sectnum = thesector[z]; sec = §or[sectnum];
|
||||
|
@ -3953,7 +4076,45 @@ static void drawalls(int32_t bunch)
|
|||
}
|
||||
|
||||
#ifdef YAX_ENABLE
|
||||
if (!g_nodraw)
|
||||
if (g_nodraw)
|
||||
{
|
||||
baselevp = (yax_globallev == YAX_MAXDRAWS);
|
||||
|
||||
yax_getbunches(sectnum, &bn[0], &bn[1]);
|
||||
checkcf = (bn[0]>=0) + ((bn[1]>=0)<<1);
|
||||
if (!baselevp)
|
||||
checkcf &= (1<<yax_globalcf);
|
||||
|
||||
if ((andwstat1&3) == 3) // ceilings clipped
|
||||
checkcf &= ~1;
|
||||
if ((andwstat2&12) == 12) // floors clipped
|
||||
checkcf &= ~2;
|
||||
|
||||
for (i=0; i<2; i++)
|
||||
if (checkcf&(1<<i))
|
||||
{
|
||||
if ((haveymost[bn[i]>>3]&(1<<(bn[i]&7)))==0)
|
||||
{
|
||||
// init yax *most arrays for that bunch
|
||||
haveymost[bn[i]>>3] |= (1<<(bn[i]&7));
|
||||
for (x=xdimen*bn[i]; x<xdimen*(bn[i]+1); x++)
|
||||
{
|
||||
yumost[x] = ydimen;
|
||||
ydmost[x] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
x1 = bn[i]*xdimen;
|
||||
for (x=x1+xb1[bunchfirst[bunch]]; x<=x1+xb2[bunchlast[bunch]]; x++)
|
||||
{
|
||||
// if (i==YAX_CEILING)
|
||||
yumost[x] = min(yumost[x], umost[x-x1]);
|
||||
// else
|
||||
ydmost[x] = max(ydmost[x], dmost[x-x1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if ((andwstat1&3) != 3) //draw ceilings
|
||||
|
@ -4344,10 +4505,10 @@ static void drawalls(int32_t bunch)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (umost[x] >= 0 || umost[x] < ydim)
|
||||
if (umost[x] >= 0 && umost[x] < ydim)
|
||||
*((char *)frameplace + umost[x]*bytesperline + x) = purple;
|
||||
|
||||
if (dmost[x]-1 >= 0 || dmost[x]-1 < ydim)
|
||||
if (dmost[x]-1 >= 0 && dmost[x]-1 < ydim)
|
||||
*((char *)frameplace + (dmost[x]-1)*bytesperline + x) = yellow;
|
||||
}
|
||||
|
||||
|
@ -7447,6 +7608,22 @@ void drawrooms(int32_t daposx, int32_t daposy, int32_t daposz,
|
|||
numhits = xdimen; numscans = 0; numbunches = 0;
|
||||
maskwallcnt = 0; smostwallcnt = 0; smostcnt = 0; spritesortcnt = 0;
|
||||
|
||||
#ifdef YAX_ENABLE
|
||||
if (yax_globallev != YAX_MAXDRAWS)
|
||||
{
|
||||
j = yax_globalbunch*xdimen;
|
||||
|
||||
Bmemcpy(umost, yumost+j, xdimen*sizeof(int16_t));
|
||||
Bmemcpy(dmost, ydmost+j, xdimen*sizeof(int16_t));
|
||||
|
||||
for (i=0; i<xdimen; i++)
|
||||
if (umost[i] > dmost[i])
|
||||
numhits--;
|
||||
|
||||
// yaxdebug("cf %d, tlev %d, bunch %d: numhits=%d", yax_globalcf, yax_globallev, yax_globalbunch, numhits);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (globalcursectnum >= MAXSECTORS)
|
||||
globalcursectnum -= MAXSECTORS;
|
||||
else
|
||||
|
@ -12116,7 +12293,8 @@ restart_grand:
|
|||
cb = yax_getbunch(origclipsectorlist[i], YAX_CEILING);
|
||||
if (cb < 0)
|
||||
continue;
|
||||
for (j=headsectbunch[YAX_FLOOR][cb]; j!=-1; j=nextsectbunch[YAX_FLOOR][j])
|
||||
|
||||
for (SECTORS_OF_BUNCH(cb,YAX_FLOOR, j))
|
||||
if (inside(pos->x,pos->y, j)==1)
|
||||
{
|
||||
clipsectorlist[clipsectnum++] = j;
|
||||
|
@ -12150,7 +12328,8 @@ restart_grand:
|
|||
fb = yax_getbunch(origclipsectorlist[i], YAX_FLOOR);
|
||||
if (fb < 0)
|
||||
continue;
|
||||
for (j=headsectbunch[YAX_CEILING][fb]; j!=-1; j=nextsectbunch[YAX_CEILING][j])
|
||||
|
||||
for (SECTORS_OF_BUNCH(fb, YAX_CEILING, j))
|
||||
if (inside(pos->x,pos->y, j)==1)
|
||||
{
|
||||
clipsectorlist[clipsectnum++] = j;
|
||||
|
|
|
@ -262,12 +262,8 @@ static void DeletePolymerLights(void)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
extern int32_t graphicsmode;
|
||||
|
||||
extern int32_t mskip;
|
||||
extern int16_t capturecount;
|
||||
extern int32_t editorgridextent; // in engine.c
|
||||
extern char game_executable[BMAX_PATH];
|
||||
|
||||
//extern int32_t fillsector(int16_t sectnum, char fillcolor);
|
||||
|
||||
|
@ -288,7 +284,7 @@ static void message_common1(const char *tmpstr)
|
|||
|
||||
getmessageleng = Bstrlen(getmessage);
|
||||
getmessagetimeoff = totalclock + 120*2 + getmessageleng*(120/30);
|
||||
lastmessagetime = totalclock;
|
||||
// lastmessagetime = totalclock;
|
||||
}
|
||||
|
||||
void message(const char *fmt, ...)
|
||||
|
@ -686,6 +682,11 @@ static void MultiPskyInit(void)
|
|||
pskymultilist[0] = MOONSKY1;
|
||||
pskymultilist[1] = BIGORBIT1;
|
||||
pskymultilist[2] = LA;
|
||||
|
||||
pskymultiyscale[0] = 32768;
|
||||
pskymultiyscale[1] = 32768;
|
||||
pskymultiyscale[2] = 16384+1024;
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
{
|
||||
pskymultibits[i] = 3;
|
||||
|
@ -718,6 +719,9 @@ static void MultiPskyInit(void)
|
|||
pskymultioff[2][7]=3;
|
||||
|
||||
pskynummultis = 3;
|
||||
|
||||
// default in game:
|
||||
parallaxyscale = 32768;
|
||||
}
|
||||
|
||||
void ExtLoadMap(const char *mapname)
|
||||
|
@ -3941,6 +3945,8 @@ static int32_t OnSelectTile(int32_t iTile)
|
|||
bflushchars();
|
||||
|
||||
setpolymost2dview();
|
||||
bglEnable(GL_TEXTURE_2D);
|
||||
|
||||
clearview(0);
|
||||
|
||||
//
|
||||
|
@ -4066,6 +4072,7 @@ static void tilescreen_drawbox(int32_t iTopLeft, int32_t iSelected, int32_t nXTi
|
|||
char markedcol = editorcolors[14];
|
||||
|
||||
setpolymost2dview();
|
||||
bglEnable(GL_TEXTURE_2D);
|
||||
|
||||
y1=max(y1, 0);
|
||||
y2=min(y2, ydim-1);
|
||||
|
@ -4146,10 +4153,12 @@ static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, i
|
|||
const char *pRawPixels;
|
||||
char szT[128];
|
||||
|
||||
int32_t usehitilecnt=0, usehitile;
|
||||
int32_t runi=0, usehitile;
|
||||
static uint8_t loadedhitile[(MAXTILES+7)>>3];
|
||||
|
||||
setpolymost2dview();
|
||||
bglEnable(GL_TEXTURE_2D);
|
||||
|
||||
clearview(0);
|
||||
|
||||
begindrawing();
|
||||
|
@ -4164,15 +4173,15 @@ restart:
|
|||
if (iTile < 0 || iTile >= localartlookupnum)
|
||||
continue;
|
||||
|
||||
usehitile = usehitilecnt;
|
||||
usehitile = runi;
|
||||
|
||||
idTile = localartlookup[ iTile ];
|
||||
if (loadedhitile[idTile>>3]&(1<<(idTile&7)))
|
||||
{
|
||||
if (usehitilecnt==0)
|
||||
usehitile = 1;
|
||||
else
|
||||
if (runi==1)
|
||||
continue;
|
||||
|
||||
usehitile = 1;
|
||||
}
|
||||
|
||||
// Get pointer to tile's raw pixel data
|
||||
|
@ -4196,7 +4205,7 @@ restart:
|
|||
|
||||
tilescreen_drawbox(iTopLeft, iSelected, nXTiles, TileDim, offset, iTile, idTile);
|
||||
|
||||
if (usehitilecnt)
|
||||
if (runi==1)
|
||||
{
|
||||
int32_t k;
|
||||
|
||||
|
@ -4231,13 +4240,13 @@ restart:
|
|||
|
||||
if (rendmode>=3 && qsetmode==200)
|
||||
{
|
||||
if (usehitilecnt==0)
|
||||
if (runi==0)
|
||||
{
|
||||
enddrawing();
|
||||
showframe(1);
|
||||
begindrawing();
|
||||
|
||||
usehitilecnt = 1;
|
||||
runi = 1;
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
|
@ -7048,7 +7057,7 @@ static void Keys3d(void)
|
|||
|
||||
j = (somethingintab==SEARCH_CEILING || somethingintab==SEARCH_FLOOR);
|
||||
|
||||
for (i=headsectbunch[AIMING_AT_FLOOR][k]; i!=-1; i=nextsectbunch[AIMING_AT_FLOOR][i])
|
||||
for (SECTORS_OF_BUNCH(k,AIMING_AT_FLOOR, i))
|
||||
{
|
||||
SECTORFLD(i,picnum, AIMING_AT_FLOOR) = temppicnum;
|
||||
SECTORFLD(i,shade, AIMING_AT_FLOOR) = tempshade;
|
||||
|
@ -7073,7 +7082,7 @@ static void Keys3d(void)
|
|||
wall[searchwall].yrepeat = tempyrepeat;
|
||||
wall[searchwall].xpanning = tempxpanning;
|
||||
wall[searchwall].ypanning = tempypanning;
|
||||
wall[searchwall].cstat &= (4+8+256);
|
||||
wall[searchwall].cstat &= ~(4+8+256);
|
||||
wall[searchwall].cstat |= (tempcstat & (4+8+256));
|
||||
|
||||
SET_PROTECT_BITS(wall[searchwall].cstat, tempcstat, YAX_NEXTWALLBITS);
|
||||
|
@ -7255,7 +7264,7 @@ paste_ceiling_or_floor:
|
|||
AIMED_CEILINGFLOOR(heinum) = 0;
|
||||
#ifdef YAX_ENABLE
|
||||
if (j >= 0)
|
||||
for (i=headsectbunch[!AIMING_AT_FLOOR][j]; i != -1; i=nextsectbunch[!AIMING_AT_FLOOR][i])
|
||||
for (SECTORS_OF_BUNCH(j,!AIMING_AT_FLOOR, i))
|
||||
{
|
||||
SECTORFLD(i,stat, !AIMING_AT_FLOOR) &= ~2;
|
||||
SECTORFLD(i,heinum, !AIMING_AT_FLOOR) = 0;
|
||||
|
@ -7429,7 +7438,6 @@ NEXTSPRITE:
|
|||
printmessage16("%s Sprite search: none found", dir<0 ? "<" : ">");
|
||||
}
|
||||
|
||||
extern int32_t graphicsmode;
|
||||
|
||||
static void Keys2d(void)
|
||||
{
|
||||
|
@ -8139,23 +8147,6 @@ static void InitCustomColors(void)
|
|||
int32_t i;
|
||||
palette_t *edcol;
|
||||
|
||||
/*
|
||||
char vgapal16[4*256] =
|
||||
{
|
||||
00,00,00,00, 42,00,00,00, 00,42,00,00, 42,42,00,00, 00,00,42,00,
|
||||
42,00,42,00, 00,21,42,00, 42,42,42,00, 21,21,21,00, 63,21,21,00,
|
||||
21,63,21,00, 63,63,21,00, 21,21,63,00, 63,21,63,00, 21,63,63,00,
|
||||
63,63,63,00
|
||||
};
|
||||
*/
|
||||
/* editorcolors[0] = getclosestcol(0,0,0);
|
||||
editorcolors[1] = getclosestcol(0,0,42);
|
||||
editorcolors[2] = getclosestcol(0,42,0);
|
||||
editorcolors[3] = getclosestcol(0,42,42);
|
||||
editorcolors[4] = getclosestcol(42,0,0);
|
||||
editorcolors[5] = getclosestcol(0,0,0);
|
||||
*/
|
||||
|
||||
/* blue */
|
||||
vgapal16[9*4+0] = 63;
|
||||
vgapal16[9*4+1] = 31;
|
||||
|
@ -8591,7 +8582,6 @@ static int32_t osdcmd_quit(const osdfuncparm_t *parm)
|
|||
static int32_t osdcmd_editorgridextent(const osdfuncparm_t *parm)
|
||||
{
|
||||
int32_t i;
|
||||
extern int32_t editorgridextent;
|
||||
|
||||
if (parm->numparms == 0)
|
||||
{
|
||||
|
@ -9244,6 +9234,7 @@ void GAME_clearbackground(int32_t numcols, int32_t numrows)
|
|||
ty2 = daydim/ysiz;
|
||||
|
||||
setpolymost2dview();
|
||||
bglEnable(GL_TEXTURE_2D);
|
||||
|
||||
for (x=0; x<=tx2; x++)
|
||||
for (y=0; y<=ty2; y++)
|
||||
|
@ -10962,9 +10953,11 @@ void ExtCheckKeys(void)
|
|||
extern int32_t engine_screenshot;
|
||||
engine_screenshot = 1;
|
||||
#else
|
||||
extern int16_t capturecount;
|
||||
|
||||
Bsprintf(tempbuf, "Mapster32 %s", ExtGetVer());
|
||||
screencapture("captxxxx.tga", eitherSHIFT, tempbuf);
|
||||
message("Saved screenshot %04d", capturecount-1);
|
||||
silentmessage("Saved screenshot %04d", capturecount-1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,8 +58,6 @@ static instype *x_sortingstateptr;
|
|||
|
||||
//#include "m32structures.c"
|
||||
|
||||
extern void message(const char *fmt, ...);
|
||||
|
||||
// from sector.c vvv
|
||||
static int32_t ldist(const spritetype *s1, const spritetype *s2)
|
||||
{
|
||||
|
@ -2084,10 +2082,7 @@ badindex:
|
|||
|
||||
case CON_FIXREPEATS:
|
||||
insptr++;
|
||||
{
|
||||
extern void fixrepeats(int16_t i);
|
||||
fixrepeats(Gv_GetVarX(*insptr++));
|
||||
}
|
||||
fixrepeats(Gv_GetVarX(*insptr++));
|
||||
continue;
|
||||
|
||||
case CON_GETCLOSESTCOL:
|
||||
|
|
|
@ -28,18 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
const char *defsfilename = "duke3d.def";
|
||||
|
||||
extern char keystatus[];
|
||||
extern int32_t horiz, qsetmode;
|
||||
extern vec3_t pos;
|
||||
extern int16_t ang, cursectnum;
|
||||
extern int16_t ceilingheinum, floorheinum;
|
||||
extern char names[MAXTILES][25];
|
||||
|
||||
extern int32_t ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d;
|
||||
|
||||
extern int16_t editstatus, searchit;
|
||||
extern int32_t searchx, searchy, osearchx, osearchy; //search input
|
||||
|
||||
#define COLOR_RED 248
|
||||
#define COLOR_WHITE 31
|
||||
|
||||
|
@ -53,20 +41,15 @@ uint8_t default_buildkeys[NUMBUILDKEYS] =
|
|||
0x9c,0x1c,0xd,0xc,0xf,0x29
|
||||
};
|
||||
|
||||
// needed by build/src/defs.c
|
||||
int32_t nextvoxid = 0;
|
||||
|
||||
extern int32_t whitecol;
|
||||
extern char vgapal16[4*256];
|
||||
extern char changechar(char dachar, int32_t dadir, char smooshyalign, char boundcheck);
|
||||
extern void updatenumsprites(void);
|
||||
|
||||
extern int32_t lastpm16time, synctics;
|
||||
extern int32_t halfxdim16, midydim16, zoom;
|
||||
|
||||
static char autospritehelp=0,autosecthelp=0;
|
||||
//int16_t MinRate=24, MinD=3;
|
||||
//int32_t xoldtimerhandler;
|
||||
static int32_t lastmessagetime=-1;
|
||||
static char autospritehelp=0, autosecthelp=0;
|
||||
//static int32_t lastmessagetime=-1;
|
||||
|
||||
static char tempbuf[1024];
|
||||
static int32_t numsprite[MAXTILES], multisprite[MAXTILES];
|
||||
|
@ -89,8 +72,6 @@ static uint8_t framerateon=1,shadepreview=0;
|
|||
int32_t autosave=180;
|
||||
static int32_t autosavetimer;
|
||||
|
||||
extern int32_t vel, svel, hvel, angvel;
|
||||
|
||||
static void SearchSectors(int32_t dir);
|
||||
static inline void SpriteName(int16_t spritenum, char *lo2);
|
||||
//static void PrintStatus(const char *string,int32_t num,char x,char y,char color);
|
||||
|
@ -99,8 +80,6 @@ void SetSLIMEPalette();
|
|||
void SetWATERPalette();
|
||||
void SetGAMEPalette();
|
||||
|
||||
extern int32_t grid, autogrid;
|
||||
|
||||
static void EditSpriteData(int16_t spritenum);
|
||||
static void EditWallData(int16_t wallnum);
|
||||
static void EditSectorData(int16_t sectnum);
|
||||
|
@ -118,33 +97,14 @@ static char num_tables;
|
|||
|
||||
static int32_t updownunits=1024;
|
||||
|
||||
extern int16_t highlightsector[MAXSECTORS], highlightsectorcnt;
|
||||
extern int16_t highlight[MAXWALLS];
|
||||
extern int16_t pointhighlight, linehighlight, highlightcnt;
|
||||
extern int16_t asksave;
|
||||
|
||||
static char getmessage[162], getmessageleng;
|
||||
static int32_t getmessagetimeoff; //, charsperline;
|
||||
|
||||
extern int32_t startposx, startposy, startposz;
|
||||
extern int16_t startang, startsectnum;
|
||||
|
||||
extern int32_t numsprites;
|
||||
extern int32_t showfirstwall;
|
||||
extern char spritecol2d[MAXTILES][2];
|
||||
extern char custom2dcolors;
|
||||
|
||||
//int32_t intro=0;
|
||||
extern int32_t ydim16, halfxdim16, midydim16, zoom;
|
||||
extern intptr_t frameplace;
|
||||
//extern char pow2char[8];
|
||||
|
||||
static int32_t acurpalette=0;
|
||||
|
||||
extern int32_t checksectorpointer(int16_t i, int16_t sectnum);
|
||||
|
||||
extern double msens;
|
||||
|
||||
//void ContextHelp(int16_t spritenum);
|
||||
//void ResetKeys();
|
||||
|
||||
|
@ -213,4 +173,4 @@ static int32_t gs_spriteTagValue[3][7];
|
|||
static char gs_spriteTagInterested[3][7];
|
||||
static int16_t gs_cursprite=-1;
|
||||
|
||||
int32_t g_musicSize=0;
|
||||
//int32_t g_musicSize=0;
|
||||
|
|
|
@ -929,6 +929,11 @@ static void G_MultiPskyInit(void)
|
|||
pskymultilist[0] = MOONSKY1;
|
||||
pskymultilist[1] = BIGORBIT1;
|
||||
pskymultilist[2] = LA;
|
||||
|
||||
pskymultiyscale[0] = 32768;
|
||||
pskymultiyscale[1] = 32768;
|
||||
pskymultiyscale[2] = 16384+1024;
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
{
|
||||
pskymultibits[i] = 3;
|
||||
|
@ -965,7 +970,13 @@ static void G_MultiPskyInit(void)
|
|||
|
||||
static inline void G_SetupBackdrop(int16_t sky)
|
||||
{
|
||||
G_MultiPskyInit();
|
||||
static int32_t multiskiesinited=0;
|
||||
|
||||
if (!multiskiesinited)
|
||||
{
|
||||
multiskiesinited = 1;
|
||||
G_MultiPskyInit();
|
||||
}
|
||||
|
||||
Bmemset(pskyoff, 0, sizeof(pskyoff[0]) * MAXPSKYTILES);
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ int32_t G_LoadPlayer(int32_t spot)
|
|||
if (numyaxbunches > 0)
|
||||
{
|
||||
if (kdfread(yax_bunchnum,sizeof(yax_bunchnum[0]),numsectors,fil) != numsectors) goto corrupt;
|
||||
if (kdfread(yax_nextwall,sizeof(yax_nextwall[0]),numwalls,fil) != numsectors) goto corrupt;
|
||||
if (kdfread(yax_nextwall,sizeof(yax_nextwall[0]),numwalls,fil) != numwalls) goto corrupt;
|
||||
yax_update(2);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <string.h>
|
||||
|
||||
#include "compat.h"
|
||||
#include "baselayer.h"
|
||||
|
||||
#include "fx_man.h"
|
||||
//#include "music.h"
|
||||
|
@ -37,6 +38,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "macros.h"
|
||||
#include "mathutil.h"
|
||||
#include "build.h" // vec3_t
|
||||
#include "editor.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include "winlayer.h"
|
||||
|
@ -58,7 +60,6 @@ int32_t backflag,g_numEnvSoundsPlaying;
|
|||
void MUSIC_Update(void) {} // needed when linking
|
||||
|
||||
void S_Callback(uint32_t);
|
||||
extern void initprintf(const char *f, ...);
|
||||
|
||||
/*
|
||||
===================
|
||||
|
@ -155,9 +156,6 @@ int32_t S_LoadSound(uint32_t num)
|
|||
return 1;
|
||||
}
|
||||
|
||||
extern vec3_t pos;
|
||||
extern int16_t ang, cursectnum;
|
||||
|
||||
int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
|
||||
{
|
||||
int32_t sndist, cx, cy, cz, j/*,k*/;
|
||||
|
|
Loading…
Reference in a new issue