Tweakery in various places.

Engine stuff:
 * Add 'r_shadescale_unbounded' cvar. When set to 0, OpenGL renderers should never
   draw completely black objects (currently only implemented for Polymost)

Mapster32:
 * Add 'r_shadescale' to config
 * In 3D mode, make SPACE behave the same as holding down a mose button: the
   currently pointed-at object is locked. Required some modification of a.m32
   to play well (i.e. not reset SPACE). This is useful by itself but more so
   in conjunction with the next point
 * make Alt behave as a modifier with PGUP/PGDN: when aiming at a 2-sided wall,
   move the other side's sector's ceiling or floor (only this is new).
 * Auto-alignment of walls can be controlled in a finer grained fashion now:
   When pressing '.', only the immediate neighbors get aligned. Use Ctrl-. for
   the old behaviour.
 * When inserting a point in 2D mode, auto-align the neighboring wall


git-svn-id: https://svn.eduke32.com/eduke32@1848 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-03-17 23:37:38 +00:00
parent 9a51ea8b95
commit 4dba12a5d3
16 changed files with 298 additions and 253 deletions

View file

@ -14,7 +14,10 @@
#define UNREFERENCED_PARAMETER(x) x=x #define UNREFERENCED_PARAMETER(x) x=x
#endif #endif
#define clamp(in, min, max) ((in) <= (min) ? (min) : (in) >= (max) ? (max) : (in)) static inline int clamp(int in, int min, int max)
{
return in <= min ? min : in >= max ? max : in;
}
#if defined __GNUC__ || defined __clang__ #if defined __GNUC__ || defined __clang__
# define ATTRIBUTE(attrlist) __attribute__(attrlist) # define ATTRIBUTE(attrlist) __attribute__(attrlist)
@ -566,8 +569,5 @@ char *Bstrupr(char *);
#define EDUKE32_TMRTIC t[ti++]=getticks() #define EDUKE32_TMRTIC t[ti++]=getticks()
#define EDUKE32_TMRPRN do { int ii=0; fprintf(stderr,"%s: ",tmrstr); for (ii=1; ii<ti; ii++) fprintf(stderr,"%d ", t[ii]-t[ii-1]); fprintf(stderr,"\n"); } while (0) #define EDUKE32_TMRPRN do { int ii=0; fprintf(stderr,"%s: ",tmrstr); for (ii=1; ii<ti; ii++) fprintf(stderr,"%d ", t[ii]-t[ii-1]); fprintf(stderr,"\n"); } while (0)
static inline int32_t ARBNDCHK(int32_t i) { return i<0 ? (*(int32_t *)123=234) : i; }
#define DOUBLEWALL(w) wall[ARBNDCHK(w)]
#endif // __compat_h__ #endif // __compat_h__

View file

@ -38,7 +38,7 @@ extern "C" {
extern int32_t qsetmode; extern int32_t qsetmode;
extern int16_t searchsector, searchwall, searchstat; extern int16_t searchsector, searchwall, searchstat;
extern int16_t searchbottomwall; extern int16_t searchbottomwall, searchisbottom;
extern int32_t zmode, kensplayerheight, zlock; extern int32_t zmode, kensplayerheight, zlock;
#define DEFAULT_SPRITE_CSTAT 0 #define DEFAULT_SPRITE_CSTAT 0
@ -89,6 +89,8 @@ extern void m32_setkeyfilter(int32_t on);
extern int32_t wallength(int16_t i); extern int32_t wallength(int16_t i);
extern void fixrepeats(int16_t i); extern void fixrepeats(int16_t i);
extern void fixxrepeat(int16_t i, uint32_t lenrepquot); extern void fixxrepeat(int16_t i, uint32_t lenrepquot);
extern void AlignWallPoint2(int32_t w0);
extern int32_t AutoAlignWalls(int32_t w0, int32_t dorecurse, int32_t nrecurs);
extern int32_t ExtInit(void); extern int32_t ExtInit(void);
extern int32_t ExtPreInit(int32_t argc,const char **argv); extern int32_t ExtPreInit(int32_t argc,const char **argv);
@ -226,6 +228,13 @@ extern int32_t scripthistend;
#define BTAG_MAX 65535 #define BTAG_MAX 65535
#define BZ_MAX 8388608 #define BZ_MAX 8388608
#define BHEINUM_MAX 32767
#define M32_MAXPALOOKUPS (MAXPALOOKUPS-RESERVEDPALS-1)
static inline int32_t atoi_safe(const char *str)
{
return (int32_t)strtol(str, NULL, 10);
}
#endif #endif

View file

@ -191,28 +191,12 @@ extern int16_t ang;
extern int32_t horiz; extern int32_t horiz;
extern int16_t cursectnum; extern int16_t cursectnum;
extern int32_t searchx, searchy; extern int32_t searchx, searchy;
/*
extern int16_t searchstat;
extern int16_t searchwall;
extern int16_t searchsector;
extern int16_t searchbottomwall;
*/
extern int16_t pointhighlight; extern int16_t pointhighlight;
extern int16_t linehighlight; extern int16_t linehighlight;
extern int16_t highlightcnt; extern int16_t highlightcnt;
extern int16_t highlightsectorcnt; extern int16_t highlightsectorcnt;
/*
extern int32_t temppicnum;
extern int32_t tempcstat;
extern int32_t templotag;
extern int32_t temphitag;
extern int32_t tempextra;
extern int32_t tempshade;
extern uint32_t temppal;
extern uint32_t tempvis;
extern uint32_t tempxrepeat;
extern uint32_t tempyrepeat;
*/
extern int32_t startposx; extern int32_t startposx;
extern int32_t startposy; extern int32_t startposy;
extern int32_t startposz; extern int32_t startposz;

View file

@ -84,6 +84,7 @@ int32_t dedxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf,
void writexcache(char *fn, int32_t len, int32_t dameth, char effect, texcacheheader *head); void writexcache(char *fn, int32_t len, int32_t dameth, char effect, texcacheheader *head);
extern float shadescale; extern float shadescale;
extern int32_t shadescale_unbounded;
extern float alphahackarray[MAXTILES]; extern float alphahackarray[MAXTILES];
typedef struct pthtyp_t typedef struct pthtyp_t

View file

@ -236,7 +236,6 @@ int32_t loadnames(const char *namesfile);
void updatenumsprites(void); void updatenumsprites(void);
static void getclosestpointonwall(int32_t x, int32_t y, int32_t dawall, int32_t *nx, int32_t *ny); static void getclosestpointonwall(int32_t x, int32_t y, int32_t dawall, int32_t *nx, int32_t *ny);
static void initcrc(void); static void initcrc(void);
void AutoAlignWalls(int32_t nWall0, int32_t ply);
int32_t gettile(int32_t tilenum); int32_t gettile(int32_t tilenum);
static int32_t menuselect(void); static int32_t menuselect(void);
@ -346,8 +345,8 @@ static void M32_drawdebug(void)
#if 0 #if 0
{ {
static char tstr[128]; static char tstr[128];
Bsprintf(tstr, "searchstat=%d, searchsector=%d, searchwall=%d (%d), asksave=%d", Bsprintf(tstr, "search... stat=%d, sector=%d, wall=%d (%d), isbottom=%d, asksave=%d",
searchstat, searchsector, searchwall, searchbottomwall, asksave); searchstat, searchsector, searchwall, searchbottomwall, searchisbottom, asksave);
printext256(x,y,whitecol,0,tstr,xdimgame>640?0:1); printext256(x,y,whitecol,0,tstr,xdimgame>640?0:1);
} }
#endif #endif
@ -1048,7 +1047,7 @@ void editinput(void)
searchit = 2; searchit = 2;
if (searchstat >= 0) if (searchstat >= 0)
{ {
if ((bstatus&(1|2|4)) > 0) if ((bstatus&(1|2|4)) || keystatus[0x39]) // SPACE
searchit = 0; searchit = 0;
if (keystatus[0x1f]) //S (insert sprite) (3D) if (keystatus[0x1f]) //S (insert sprite) (3D)
@ -2773,10 +2772,10 @@ void overheadeditor(void)
if (inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc,i) == 1) if (inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc,i) == 1)
{ {
Bsprintf(buffer, "Sector (%d) Ceilingpal: ", i); Bsprintf(buffer, "Sector (%d) Ceilingpal: ", i);
sector[i].ceilingpal = getnumber16(buffer, sector[i].ceilingpal, MAXPALOOKUPS-1, 0); sector[i].ceilingpal = getnumber16(buffer, sector[i].ceilingpal, M32_MAXPALOOKUPS, 0);
Bsprintf(buffer, "Sector (%d) Floorpal: ", i); Bsprintf(buffer, "Sector (%d) Floorpal: ", i);
sector[i].floorpal = getnumber16(buffer, sector[i].floorpal, MAXPALOOKUPS-1, 0); sector[i].floorpal = getnumber16(buffer, sector[i].floorpal, M32_MAXPALOOKUPS, 0);
break; break;
} }
} }
@ -4883,6 +4882,7 @@ end_space_handling:
{ {
getclosestpointonwall(mousxplc,mousyplc, linehighlight, &dax,&day); getclosestpointonwall(mousxplc,mousyplc, linehighlight, &dax,&day);
adjustmark(&dax,&day, newnumwalls); adjustmark(&dax,&day, newnumwalls);
i = linehighlight; i = linehighlight;
if ((wall[i].x == dax && wall[i].y == day) || (POINT2(i).x == dax && POINT2(i).y == day)) if ((wall[i].x == dax && wall[i].y == day) || (POINT2(i).x == dax && POINT2(i).y == day))
{ {
@ -5705,7 +5705,6 @@ static void insertpoint(int16_t linehighlight, int32_t dax, int32_t day)
j = linehighlight; j = linehighlight;
sucksect = sectorofwall(j); sucksect = sectorofwall(j);
templenrepquot = divscale12(wallength(j), wall[j].xrepeat); templenrepquot = divscale12(wallength(j), wall[j].xrepeat);
templenrepquot = max(1, templenrepquot);
sector[sucksect].wallnum++; sector[sucksect].wallnum++;
for (i=sucksect+1; i<numsectors; i++) for (i=sucksect+1; i<numsectors; i++)
@ -5718,11 +5717,13 @@ static void insertpoint(int16_t linehighlight, int32_t dax, int32_t day)
wall[j+1].x = dax; wall[j+1].x = dax;
wall[j+1].y = day; wall[j+1].y = day;
fixxrepeat(j, templenrepquot); fixxrepeat(j, templenrepquot);
AlignWallPoint2(j);
fixxrepeat(j+1, templenrepquot); fixxrepeat(j+1, templenrepquot);
if (wall[j].nextwall >= 0) if (wall[j].nextwall >= 0)
{ {
k = wall[j].nextwall; k = wall[j].nextwall;
templenrepquot = divscale12(wallength(k), wall[k].xrepeat);
sucksect = sectorofwall(k); sucksect = sectorofwall(k);
@ -5737,6 +5738,7 @@ static void insertpoint(int16_t linehighlight, int32_t dax, int32_t day)
wall[k+1].x = dax; wall[k+1].x = dax;
wall[k+1].y = day; wall[k+1].y = day;
fixxrepeat(k, templenrepquot); fixxrepeat(k, templenrepquot);
AlignWallPoint2(k);
fixxrepeat(k+1, templenrepquot); fixxrepeat(k+1, templenrepquot);
j = wall[k].nextwall; j = wall[k].nextwall;
@ -5903,7 +5905,10 @@ void fixrepeats(int16_t i)
void fixxrepeat(int16_t i, uint32_t lenrepquot) // lenrepquot: divscale12(wallength,xrepeat) void fixxrepeat(int16_t i, uint32_t lenrepquot) // lenrepquot: divscale12(wallength,xrepeat)
{ {
if (lenrepquot != 0) if (lenrepquot != 0)
wall[i].xrepeat = clamp(divscale12(wallength(i), lenrepquot), 1, 255); {
uint32_t res = (((wallength(i)<<12)+(1<<11))/lenrepquot);
wall[i].xrepeat = clamp(res, 1, 255);
}
} }
@ -7354,123 +7359,132 @@ static void initcrc(void)
} }
} }
static int32_t GetWallZPeg(int32_t nWall) static int32_t GetWallBaseZ(int32_t wallnum)
{ {
int32_t z=0, nSector, nNextSector; int32_t z=0, sectnum, nextsec;
nSector = sectorofwall((int16_t)nWall); sectnum = sectorofwall(wallnum);
nNextSector = wall[nWall].nextsector; nextsec = wall[wallnum].nextsector;
if (nNextSector == -1)
if (nextsec == -1) //1-sided wall
{ {
//1-sided wall if (wall[wallnum].cstat&4) // floor-aligned
if (wall[nWall].cstat&4) z = sector[nSector].floorz; z = sector[sectnum].floorz;
else z = sector[nSector].ceilingz; else
z = sector[sectnum].ceilingz;
} }
else else //2-sided wall
{ {
//2-sided wall if (wall[wallnum].cstat&4)
if (wall[nWall].cstat&4) z = sector[sectnum].ceilingz;
z = sector[nSector].ceilingz;
else else
{ {
if (sector[nNextSector].ceilingz > sector[nSector].ceilingz) if (sector[nextsec].ceilingz > sector[sectnum].ceilingz)
z = sector[nNextSector].ceilingz; //top step z = sector[nextsec].ceilingz; //top step
if (sector[nNextSector].floorz < sector[nSector].floorz) if (sector[nextsec].floorz < sector[sectnum].floorz)
z = sector[nNextSector].floorz; //bottom step z = sector[nextsec].floorz; //bottom step
} }
} }
return(z); return(z);
} }
static void AlignWalls(int32_t nWall0, int32_t z0, int32_t nWall1, int32_t z1, int32_t nTile) static void AlignWalls(int32_t w0, int32_t z0, int32_t w1, int32_t z1, int32_t tilenum)
{ {
int32_t n; int32_t n;
//do the x alignment //do the x alignment
wall[nWall1].cstat &= ~0x0108; //Set to non-flip wall[w1].cstat &= ~0x0108; //Set to non-flip
wall[nWall1].xpanning = (uint8_t)((wall[nWall0].xpanning+(wall[nWall0].xrepeat<<3))%tilesizx[nTile]); wall[w1].xpanning = (uint8_t)((wall[w0].xpanning + (wall[w0].xrepeat<<3))%tilesizx[tilenum]);
z1 = GetWallZPeg(nWall1); for (n=picsiz[tilenum]>>4; (1<<n)<tilesizy[tilenum]; n++);
for (n=picsiz[nTile]>>4; (1<<n)<tilesizy[nTile]; n++); wall[w1].yrepeat = wall[w0].yrepeat;
wall[w1].ypanning = (uint8_t)(wall[w0].ypanning + (((z1-z0)*wall[w0].yrepeat)>>(n+3)));
wall[nWall1].yrepeat = wall[nWall0].yrepeat;
wall[nWall1].ypanning = (uint8_t)(wall[nWall0].ypanning+(((z1-z0)*wall[nWall0].yrepeat)>>(n+3)));
} }
void AutoAlignWalls(int32_t nWall0, int32_t ply) void AlignWallPoint2(int32_t w0)
{ {
int32_t z0, z1, nTile, nWall1, branch, visible, nNextSector, nSector; int32_t w1 = wall[w0].point2;
AlignWalls(w0,GetWallBaseZ(w0), w1,GetWallBaseZ(w1), wall[w0].picnum);
}
nTile = wall[nWall0].picnum; // pass maxrecurs=0 for unconstrained recursion
branch = 0; int32_t AutoAlignWalls(int32_t w0, int32_t dorecurse, int32_t nrecurs)
if (ply == 0) {
int32_t z0, z1, tilenum, w1, visible, nextsec, sectnum;
static int32_t numaligned;
tilenum = wall[w0].picnum;
if (nrecurs == 0)
{ {
//clear visited bits //clear visited bits
Bmemset(visited, 0, sizeof(visited)); Bmemset(visited, 0, sizeof(visited));
visited[nWall0>>3] |= (1<<(nWall0&7)); visited[w0>>3] |= (1<<(w0&7));
numaligned = 0;
} }
z0 = GetWallZPeg(nWall0); z0 = GetWallBaseZ(w0);
nWall1 = wall[nWall0].point2; w1 = wall[w0].point2;
//loop through walls at this vertex in CCW order //loop through walls at this vertex in CCW order
while (1) while (1)
{ {
//break if this wall would connect us in a loop //break if this wall would connect us in a loop
if (visited[nWall1>>3]&(1<<(nWall1&7))) if (visited[w1>>3]&(1<<(w1&7)))
break; break;
visited[nWall1>>3] |= (1<<(nWall1&7)); visited[w1>>3] |= (1<<(w1&7));
//break if reached back of left wall //break if reached back of left wall
if (wall[nWall1].nextwall == nWall0) if (wall[w1].nextwall == w0)
break; break;
if (wall[nWall1].picnum == nTile) if (wall[w1].picnum == tilenum)
{ {
z1 = GetWallZPeg(nWall1); z1 = GetWallBaseZ(w1);
visible = 0; visible = 0;
nNextSector = wall[nWall1].nextsector; nextsec = wall[w1].nextsector;
if (nNextSector < 0) if (nextsec < 0)
visible = 1; visible = 1;
else else
{ {
//ignore two sided walls that have no visible face int32_t cz,fz, czn,fzn;
nSector = NEXTWALL(nWall1).nextsector;
if (getceilzofslope((int16_t)nSector,wall[nWall1].x,wall[nWall1].y) <
getceilzofslope((int16_t)nNextSector,wall[nWall1].x,wall[nWall1].y))
visible = 1;
if (getflorzofslope((int16_t)nSector,wall[nWall1].x,wall[nWall1].y) > //ignore two sided walls that have no visible face
getflorzofslope((int16_t)nNextSector,wall[nWall1].x,wall[nWall1].y)) sectnum = NEXTWALL(w1).nextsector;
getzsofslope(sectnum, wall[w1].x,wall[w1].y, &cz, &fz);
getzsofslope(nextsec, wall[w1].x,wall[w1].y, &czn, &fzn);
if (cz < czn || fz > fzn)
visible = 1; visible = 1;
} }
if (visible) if (visible)
{ {
branch++; numaligned++;
AlignWalls(nWall0,z0,nWall1,z1,nTile); AlignWalls(w0,z0, w1,z1, tilenum);
//if wall was 1-sided, no need to recurse //if wall was 1-sided, no need to recurse
if (wall[nWall1].nextwall < 0) if (wall[w1].nextwall < 0)
{ {
nWall0 = nWall1; w0 = w1;
z0 = GetWallZPeg(nWall0); z0 = GetWallBaseZ(w0);
nWall1 = wall[nWall0].point2; w1 = wall[w0].point2;
branch = 0;
continue; continue;
} }
else else if (dorecurse)
AutoAlignWalls(nWall1,ply+1); AutoAlignWalls(w1, 1, nrecurs+1);
} }
} }
if (wall[nWall1].nextwall < 0) break; if (wall[w1].nextwall < 0) break;
nWall1 = NEXTWALL(nWall1).point2; w1 = NEXTWALL(w1).point2;
} }
return numaligned;
} }
#define PLAYTEST_MAPNAME "autosave_playtest.map" #define PLAYTEST_MAPNAME "autosave_playtest.map"

View file

@ -16,6 +16,15 @@ static int32_t vesares[13][2] = {{320,200},{360,200},{320,240},{360,240},{320,40
{1024,768},{1280,1024},{1600,1200} {1024,768},{1280,1024},{1600,1200}
}; };
static double clampd(double d, double mind, double maxd)
{
if (d != d || d<mind)
d = mind;
else if (d>maxd)
d = maxd;
return d;
}
static int32_t readconfig(BFILE *fp, const char *key, char *value, uint32_t len) static int32_t readconfig(BFILE *fp, const char *key, char *value, uint32_t len)
{ {
char buf[1000], *k, *v, *eq; char buf[1000], *k, *v, *eq;
@ -117,70 +126,79 @@ int32_t loadsetup(const char *fn)
if ((fp = Bfopen(fn, "rt")) == NULL) return -1; if ((fp = Bfopen(fn, "rt")) == NULL) return -1;
if (readconfig(fp, "forcesetup", val, VL) > 0) { if (Batoi(val) != 0) forcesetup = 1; else forcesetup = 0; } if (readconfig(fp, "forcesetup", val, VL) > 0) { if (atoi_safe(val) != 0) forcesetup = 1; else forcesetup = 0; }
if (readconfig(fp, "fullscreen", val, VL) > 0) { if (Batoi(val) != 0) fullscreen = 1; else fullscreen = 0; } if (readconfig(fp, "fullscreen", val, VL) > 0) { if (atoi_safe(val) != 0) fullscreen = 1; else fullscreen = 0; }
if (readconfig(fp, "resolution", val, VL) > 0) if (readconfig(fp, "resolution", val, VL) > 0)
{ {
i = Batoi(val) & 0x0f; i = atoi_safe(val) & 0x0f;
if ((unsigned)i<13) { xdimgame = xdim2d = vesares[i][0]; ydimgame = ydim2d = vesares[i][1]; } if ((unsigned)i<13) { xdimgame = xdim2d = vesares[i][0]; ydimgame = ydim2d = vesares[i][1]; }
} }
if (readconfig(fp, "2dresolution", val, VL) > 0) if (readconfig(fp, "2dresolution", val, VL) > 0)
{ {
i = Batoi(val) & 0x0f; i = atoi_safe(val) & 0x0f;
if ((unsigned)i<13) { xdim2d = vesares[i][0]; ydim2d = vesares[i][1]; } if ((unsigned)i<13) { xdim2d = vesares[i][0]; ydim2d = vesares[i][1]; }
} }
if (readconfig(fp, "xdim2d", val, VL) > 0) xdim2d = Batoi(val); if (readconfig(fp, "xdim2d", val, VL) > 0) xdim2d = atoi_safe(val);
if (readconfig(fp, "ydim2d", val, VL) > 0) ydim2d = Batoi(val); if (readconfig(fp, "ydim2d", val, VL) > 0) ydim2d = atoi_safe(val);
if (readconfig(fp, "xdim3d", val, VL) > 0) xdimgame = Batoi(val); if (readconfig(fp, "xdim3d", val, VL) > 0) xdimgame = atoi_safe(val);
if (readconfig(fp, "ydim3d", val, VL) > 0) ydimgame = Batoi(val); if (readconfig(fp, "ydim3d", val, VL) > 0) ydimgame = atoi_safe(val);
// if (readconfig(fp, "samplerate", val, VL) > 0) option[7] = (Batoi(val) & 0x0f) << 4; // if (readconfig(fp, "samplerate", val, VL) > 0) option[7] = (atoi_safe(val) & 0x0f) << 4;
// if (readconfig(fp, "music", val, VL) > 0) { if (Batoi(val) != 0) option[2] = 1; else option[2] = 0; } // if (readconfig(fp, "music", val, VL) > 0) { if (atoi_safe(val) != 0) option[2] = 1; else option[2] = 0; }
// if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; } // if (readconfig(fp, "mouse", val, VL) > 0) { if (atoi_safe(val) != 0) option[3] = 1; else option[3] = 0; }
if (readconfig(fp, "bpp", val, VL) > 0) bppgame = Batoi(val); if (readconfig(fp, "bpp", val, VL) > 0) bppgame = atoi_safe(val);
if (readconfig(fp, "vsync", val, VL) > 0) vsync = Batoi(val)?1:0; if (readconfig(fp, "vsync", val, VL) > 0) vsync = !!atoi_safe(val);
if (readconfig(fp, "editorgridextent", val, VL) > 0) editorgridextent = max(min(262144,Batoi(val)),32768); if (readconfig(fp, "editorgridextent", val, VL) > 0)
{
int32_t tmp = atoi_safe(val);
editorgridextent = clamp(tmp, 65536, BXY_MAX);
}
if (readconfig(fp, "grid", val, VL) > 0) if (readconfig(fp, "grid", val, VL) > 0)
{ {
grid = Batoi(val); grid = atoi_safe(val);
default_grid = grid; default_grid = grid;
autogrid = (grid==9); autogrid = (grid==9);
grid = min(max(0, grid), 8); grid = clamp(grid, 0, 8);
} }
#ifdef POLYMER #ifdef POLYMER
if (readconfig(fp, "rendmode", val, VL) > 0) { i = Batoi(val); glrendmode = i; } if (readconfig(fp, "rendmode", val, VL) > 0) { i = atoi_safe(val); glrendmode = i; }
#endif #endif
if (readconfig(fp, "vid_gamma", val, VL) > 0) vid_gamma = Bstrtod(val, NULL); if (readconfig(fp, "vid_gamma", val, VL) > 0) vid_gamma = clampd(Bstrtod(val, NULL), 0.0, 10.0);
if (readconfig(fp, "vid_brightness", val, VL) > 0) vid_brightness = Bstrtod(val, NULL); if (readconfig(fp, "vid_brightness", val, VL) > 0) vid_brightness = clampd(Bstrtod(val, NULL), 0.0, 10.0);
if (readconfig(fp, "vid_contrast", val, VL) > 0) vid_contrast = Bstrtod(val, NULL); if (readconfig(fp, "vid_contrast", val, VL) > 0) vid_contrast = clampd(Bstrtod(val, NULL), 0.0, 10.0);
#ifdef RENDERTYPEWIN #ifdef RENDERTYPEWIN
if (readconfig(fp, "maxrefreshfreq", val, VL) > 0) maxrefreshfreq = Batoi(val); if (readconfig(fp, "maxrefreshfreq", val, VL) > 0) maxrefreshfreq = atoi_safe(val);
#endif #endif
#ifdef USE_OPENGL #ifdef USE_OPENGL
if (readconfig(fp, "usemodels", val, VL) > 0) usemodels = Batoi(val)?1:0; if (readconfig(fp, "usemodels", val, VL) > 0) usemodels = !!atoi_safe(val);
if (readconfig(fp, "usehightile", val, VL) > 0) usehightile = Batoi(val)?1:0; if (readconfig(fp, "usehightile", val, VL) > 0) usehightile = !!atoi_safe(val);
glusetexcache = -1; glusetexcache = -1;
if (readconfig(fp, "glusetexcache", val, VL) > 0) if (readconfig(fp, "glusetexcache", val, VL) > 0)
{ {
glusetexcache = clamp(Batoi(val), 0, 2); glusetexcache = clamp(atoi_safe(val), 0, 2);
} }
if (readconfig(fp, "gltexfiltermode", val, VL) > 0) if (readconfig(fp, "gltexfiltermode", val, VL) > 0)
{ {
gltexfiltermode = Batoi(val); gltexfiltermode = atoi_safe(val);
} }
if (readconfig(fp, "glanisotropy", val, VL) > 0) if (readconfig(fp, "glanisotropy", val, VL) > 0)
{ {
glanisotropy = Batoi(val); glanisotropy = atoi_safe(val);
} }
if (readconfig(fp, "r_downsize", val, VL) > 0) if (readconfig(fp, "r_downsize", val, VL) > 0)
{ {
r_downsize = Batoi(val); r_downsize = atoi_safe(val);
r_downsize = clamp(r_downsize, 0, 5); r_downsize = clamp(r_downsize, 0, 5);
r_downsizevar = r_downsize; r_downsizevar = r_downsize;
} }
if (readconfig(fp, "r_texcompr", val, VL) > 0) if (readconfig(fp, "r_texcompr", val, VL) > 0)
{ {
glusetexcompr = !!Batoi(val); glusetexcompr = !!atoi_safe(val);
}
if (readconfig(fp, "r_shadescale", val, VL) > 0)
{
shadescale = clampd(Bstrtod(val, NULL), 0.0, 10.0);
} }
#endif #endif
@ -215,49 +233,49 @@ int32_t loadsetup(const char *fn)
#endif #endif
#ifdef RENDERTYPEWIN #ifdef RENDERTYPEWIN
if (readconfig(fp, "windowpositioning", val, VL) > 0) windowpos = Batoi(val); if (readconfig(fp, "windowpositioning", val, VL) > 0) windowpos = atoi_safe(val);
windowx = -1; windowx = -1;
if (readconfig(fp, "windowposx", val, VL) > 0) windowx = Batoi(val); if (readconfig(fp, "windowposx", val, VL) > 0) windowx = atoi_safe(val);
windowy = -1; windowy = -1;
if (readconfig(fp, "windowposy", val, VL) > 0) windowy = Batoi(val); if (readconfig(fp, "windowposy", val, VL) > 0) windowy = atoi_safe(val);
#endif #endif
if (readconfig(fp, "keyconsole", val, VL) > 0) { keys[19] = Bstrtol(val, NULL, 16); OSD_CaptureKey(keys[19]); } if (readconfig(fp, "keyconsole", val, VL) > 0) { keys[19] = Bstrtol(val, NULL, 16); OSD_CaptureKey(keys[19]); }
if (readconfig(fp, "mousesensitivity", val, VL) > 0) msens = Bstrtod(val, NULL); if (readconfig(fp, "mousesensitivity", val, VL) > 0) msens = Bstrtod(val, NULL);
if (readconfig(fp, "mousenavigation", val, VL) > 0) unrealedlook = !!Batoi(val); if (readconfig(fp, "mousenavigation", val, VL) > 0) unrealedlook = !!atoi_safe(val);
if (readconfig(fp, "mousenavigationaccel", val, VL) > 0) pk_uedaccel = Batoi(val); if (readconfig(fp, "mousenavigationaccel", val, VL) > 0) pk_uedaccel = atoi_safe(val);
if (readconfig(fp, "quickmapcycling", val, VL) > 0) quickmapcycling = !!Batoi(val); if (readconfig(fp, "quickmapcycling", val, VL) > 0) quickmapcycling = !!atoi_safe(val);
if (readconfig(fp, "sideview_reversehorizrot", val, VL) > 0) sideview_reversehrot = !!Batoi(val); if (readconfig(fp, "sideview_reversehorizrot", val, VL) > 0) sideview_reversehrot = !!atoi_safe(val);
if (readconfig(fp, "revertCTRL", val, VL) > 0) revertCTRL = !!Batoi(val); if (readconfig(fp, "revertCTRL", val, VL) > 0) revertCTRL = !!atoi_safe(val);
if (readconfig(fp, "scrollamount", val, VL) > 0) scrollamount = Batoi(val); if (readconfig(fp, "scrollamount", val, VL) > 0) scrollamount = atoi_safe(val);
if (readconfig(fp, "turnaccel", val, VL) > 0) pk_turnaccel = Batoi(val); if (readconfig(fp, "turnaccel", val, VL) > 0) pk_turnaccel = atoi_safe(val);
if (readconfig(fp, "turndecel", val, VL) > 0) pk_turndecel = Batoi(val); if (readconfig(fp, "turndecel", val, VL) > 0) pk_turndecel = atoi_safe(val);
// if (readconfig(fp, "autosave", val, VL) > 0) autosave = Batoi(val)*60; // if (readconfig(fp, "autosave", val, VL) > 0) autosave = atoi_safe(val)*60;
if (readconfig(fp, "autosavesec", val, VL) > 0) autosave = max(0, Batoi(val)); if (readconfig(fp, "autosavesec", val, VL) > 0) autosave = max(0, atoi_safe(val));
if (readconfig(fp, "autocorruptchecksec", val, VL) > 0) autocorruptcheck = max(0, Batoi(val)); if (readconfig(fp, "autocorruptchecksec", val, VL) > 0) autocorruptcheck = max(0, atoi_safe(val));
if (readconfig(fp, "showheightindicators", val, VL) > 0) if (readconfig(fp, "showheightindicators", val, VL) > 0)
showheightindicators = min(max(Batoi(val),0),2); showheightindicators = clamp(atoi_safe(val), 0, 2);
if (readconfig(fp, "showambiencesounds", val, VL) > 0) if (readconfig(fp, "showambiencesounds", val, VL) > 0)
showambiencesounds = min(max(Batoi(val),0),2); showambiencesounds = clamp(atoi_safe(val), 0, 2);
if (readconfig(fp, "graphicsmode", val, VL) > 0) if (readconfig(fp, "graphicsmode", val, VL) > 0)
graphicsmode = min(max(Batoi(val),0),2); graphicsmode = clamp(atoi_safe(val), 0, 2);
if (readconfig(fp, "samplerate", val, VL) > 0) MixRate = min(max(8000, Batoi(val)), 48000); if (readconfig(fp, "samplerate", val, VL) > 0) MixRate = clamp(atoi_safe(val), 8000, 48000);
if (readconfig(fp, "ambiencetoggle", val, VL) > 0) AmbienceToggle = !!Batoi(val); if (readconfig(fp, "ambiencetoggle", val, VL) > 0) AmbienceToggle = !!atoi_safe(val);
if (readconfig(fp, "parlock", val, VL) > 0) ParentalLock = !!Batoi(val); if (readconfig(fp, "parlock", val, VL) > 0) ParentalLock = !!atoi_safe(val);
if (readconfig(fp, "osdtryscript", val, VL) > 0) m32_osd_tryscript = !!Batoi(val); if (readconfig(fp, "osdtryscript", val, VL) > 0) m32_osd_tryscript = !!atoi_safe(val);
for (i=0; i<256; i++) for (i=0; i<256; i++)
remap[i]=i; remap[i]=i;
@ -355,6 +373,7 @@ int32_t writesetup(const char *fn)
"glanisotropy = %d\n" "glanisotropy = %d\n"
"r_downsize = %d\n" "r_downsize = %d\n"
"r_texcompr = %d\n" "r_texcompr = %d\n"
"r_shadescale = %g\n"
"\n" "\n"
#endif #endif
@ -505,10 +524,11 @@ int32_t writesetup(const char *fn)
#ifdef POLYMER #ifdef POLYMER
glrendmode, glrendmode,
#endif #endif
editorgridextent, min(max(0, default_grid), 9), editorgridextent, clamp(default_grid, 0, 9),
#ifdef USE_OPENGL #ifdef USE_OPENGL
usemodels, usehightile, usemodels, usehightile,
glusetexcache, gltexfiltermode, glanisotropy,r_downsize,glusetexcompr, glusetexcache, gltexfiltermode, glanisotropy,r_downsize,glusetexcompr,
shadescale,
#endif #endif
#ifdef RENDERTYPEWIN #ifdef RENDERTYPEWIN
maxrefreshfreq, windowpos, windowx, windowy, maxrefreshfreq, windowpos, windowx, windowy,

View file

@ -1230,9 +1230,14 @@ int16_t searchit;
int32_t searchx = -1, searchy; //search input int32_t searchx = -1, searchy; //search input
int16_t searchsector, searchwall, searchstat; //search output int16_t searchsector, searchwall, searchstat; //search output
// if searchstat==0 (wall), searchbottomwall is ==.nextwall if aiming at // SEARCHBOTTOMWALL:
// bottom of a wall with swapped walls (.cstat&2), else it's ==searchwall // When aiming at a the bottom part of a 2-sided wall whose bottom part
int16_t searchbottomwall; // is swapped (.cstat&2), searchbottomwall equals that wall's .nextwall. In all
// other cases (when aiming at a wall), searchbottomwall equals searchwall.
//
// SEARCHISBOTTOM:
// When aiming at a 2-sided wall, 1 if aiming at the bottom part, 0 else
int16_t searchbottomwall, searchisbottom;
double msens = 1.0; double msens = 1.0;
@ -3230,6 +3235,7 @@ static void drawalls(int32_t bunch)
if (searchy <= dwall[searchx]) //wall if (searchy <= dwall[searchx]) //wall
{ {
searchsector = sectnum; searchbottomwall = searchwall = wallnum; searchsector = sectnum; searchbottomwall = searchwall = wallnum;
searchisbottom = 0;
searchstat = 0; searchit = 1; searchstat = 0; searchit = 1;
} }
@ -3320,6 +3326,7 @@ static void drawalls(int32_t bunch)
{ {
searchsector = sectnum; searchbottomwall = searchwall = wallnum; searchsector = sectnum; searchbottomwall = searchwall = wallnum;
if ((wal->cstat&2) > 0) searchbottomwall = wal->nextwall; if ((wal->cstat&2) > 0) searchbottomwall = wal->nextwall;
searchisbottom = 1;
searchstat = 0; searchit = 1; searchstat = 0; searchit = 1;
} }

View file

@ -36,7 +36,7 @@ extern int32_t globalorientation;
extern int16_t searchit; extern int16_t searchit;
extern int32_t searchx, searchy; extern int32_t searchx, searchy;
extern int16_t searchsector, searchwall, searchstat; extern int16_t searchsector, searchwall, searchstat;
extern int16_t searchbottomwall; extern int16_t searchbottomwall, searchisbottom;
extern char inpreparemirror; extern char inpreparemirror;

View file

@ -1097,6 +1097,7 @@ void polymer_editorpick(void)
case 4: // 1-way/masked wall case 4: // 1-way/masked wall
searchsector = sectorofwall(num); searchsector = sectorofwall(num);
searchbottomwall = searchwall = num; searchbottomwall = searchwall = num;
searchisbottom = (searchstat==5);
if (searchstat == 5) { if (searchstat == 5) {
searchstat = 0; searchstat = 0;
if (wall[num].nextwall >= 0 && (wall[num].cstat & 2)) { if (wall[num].nextwall >= 0 && (wall[num].cstat & 2)) {

View file

@ -110,6 +110,7 @@ static double dxb1[MAXWALLSB], dxb2[MAXWALLSB];
#define DEPTHDEBUG 0 //1:render distance instead of texture, for debugging only!, 0:default #define DEPTHDEBUG 0 //1:render distance instead of texture, for debugging only!, 0:default
float shadescale = 1.3f; float shadescale = 1.3f;
int32_t shadescale_unbounded = 0;
double gyxscale, gxyaspect, gviewxrange, ghalfx, grhalfxdown10, grhalfxdown10x, ghoriz; double gyxscale, gxyaspect, gviewxrange, ghalfx, grhalfxdown10, grhalfxdown10x, ghoriz;
double gcosang, gsinang, gcosang2, gsinang2; double gcosang, gsinang, gcosang2, gsinang2;
@ -2185,7 +2186,8 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
{ {
float pc[4]; float pc[4];
f = ((float)(numpalookups-min(max((globalshade * shadescale),0),numpalookups)))/((float)numpalookups); int32_t shadebound = shadescale_unbounded ? numpalookups : 31;
f = ((float)(numpalookups-min(max((globalshade * shadescale),0),shadebound)))/((float)numpalookups);
pc[0] = pc[1] = pc[2] = f; pc[0] = pc[1] = pc[2] = f;
switch (method&3) switch (method&3)
{ {
@ -4398,7 +4400,9 @@ void polymost_drawrooms()
hitallsprites = 0; hitallsprites = 0;
searchsector = hitinfo.hitsect; searchsector = hitinfo.hitsect;
if (hitinfo.pos.z<cz) searchstat = 1; else if (hitinfo.pos.z>fz) searchstat = 2; else if (hitinfo.hitwall >= 0) if (hitinfo.pos.z<cz) searchstat = 1;
else if (hitinfo.pos.z>fz) searchstat = 2;
else if (hitinfo.hitwall >= 0)
{ {
searchbottomwall = searchwall = hitinfo.hitwall; searchstat = 0; searchbottomwall = searchwall = hitinfo.hitwall; searchstat = 0;
if (wall[hitinfo.hitwall].nextwall >= 0) if (wall[hitinfo.hitwall].nextwall >= 0)
@ -4407,11 +4411,16 @@ void polymost_drawrooms()
getzsofslope(wall[hitinfo.hitwall].nextsector,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz); getzsofslope(wall[hitinfo.hitwall].nextsector,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz);
if (hitinfo.pos.z > fz) if (hitinfo.pos.z > fz)
{ {
searchisbottom = 1;
if (wall[hitinfo.hitwall].cstat&2) //'2' bottoms of walls if (wall[hitinfo.hitwall].cstat&2) //'2' bottoms of walls
searchbottomwall = wall[hitinfo.hitwall].nextwall; searchbottomwall = wall[hitinfo.hitwall].nextwall;
} }
else if ((hitinfo.pos.z > cz) && (wall[hitinfo.hitwall].cstat&(16+32))) //masking or 1-way else
searchstat = 4; {
searchisbottom = 0;
if ((hitinfo.pos.z > cz) && (wall[hitinfo.hitwall].cstat&(16+32))) //masking or 1-way
searchstat = 4;
}
} }
} }
else if (hitinfo.hitsprite >= 0) { searchwall = hitinfo.hitsprite; searchstat = 3; } else if (hitinfo.hitsprite >= 0) { searchwall = hitinfo.hitsprite; searchstat = 3; }
@ -5840,6 +5849,7 @@ void polymost_fillpolygon(int32_t npoints)
pthtyp *pth; pthtyp *pth;
float f,a=0.0; float f,a=0.0;
int32_t i; int32_t i;
int32_t shadebound = shadescale_unbounded ? numpalookups-1 : 31;
globalx1 = mulscale16(globalx1,xyaspect); globalx1 = mulscale16(globalx1,xyaspect);
globaly2 = mulscale16(globaly2,xyaspect); globaly2 = mulscale16(globaly2,xyaspect);
@ -5863,7 +5873,7 @@ void polymost_fillpolygon(int32_t npoints)
pth = gltexcache(globalpicnum,globalpal,0); pth = gltexcache(globalpicnum,globalpal,0);
bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0); bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0);
f = ((float)(numpalookups-min(max((globalshade * shadescale),0),numpalookups)))/((float)numpalookups); f = ((float)(numpalookups-min(max((globalshade * shadescale),0),shadebound)))/((float)numpalookups);
switch ((globalorientation>>7)&3) switch ((globalorientation>>7)&3)
{ {
case 0: case 0:
@ -6237,7 +6247,8 @@ void polymost_initosdfuncs(void)
}, },
{ "r_polygonmode","r_polygonmode: debugging feature",(void *) &glpolygonmode, CVAR_INT | CVAR_NOSAVE, 0, 3 }, { "r_polygonmode","r_polygonmode: debugging feature",(void *) &glpolygonmode, CVAR_INT | CVAR_NOSAVE, 0, 3 },
{ "r_redbluemode","r_redbluemode: enable/disable experimental OpenGL red-blue glasses mode",(void *) &glredbluemode, CVAR_BOOL, 0, 1 }, { "r_redbluemode","r_redbluemode: enable/disable experimental OpenGL red-blue glasses mode",(void *) &glredbluemode, CVAR_BOOL, 0, 1 },
{ "r_shadescale","r_shadescale: multiplier for lighting",(void *) &shadescale, CVAR_FLOAT, 0, 10 }, { "r_shadescale","r_shadescale: multiplier for shading",(void *) &shadescale, CVAR_FLOAT, 0, 10 },
{ "r_shadescale_unbounded","r_shadescale_unbounded: enable/disable allowance of complete blackness",(void *) &shadescale_unbounded, CVAR_BOOL, 0, 1 },
{ "r_swapinterval","r_swapinterval: sets the GL swap interval (VSync)",(void *) &vsync, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 }, { "r_swapinterval","r_swapinterval: sets the GL swap interval (VSync)",(void *) &vsync, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
{ "r_texcache","r_texcache: enable/disable OpenGL compressed texture cache",(void *) &glusetexcache, CVAR_INT, 0, 2 }, { "r_texcache","r_texcache: enable/disable OpenGL compressed texture cache",(void *) &glusetexcache, CVAR_INT, 0, 2 },
{ "r_texcompr","r_texcompr: enable/disable OpenGL texture compression",(void *) &glusetexcompr, CVAR_BOOL, 0, 1 }, { "r_texcompr","r_texcompr: enable/disable OpenGL texture compression",(void *) &glusetexcompr, CVAR_BOOL, 0, 1 },

View file

@ -122,10 +122,7 @@ ends
// KP+/-: radius // KP+/-: radius
// KP 1,2,3: RGB color (Shift inverts) // KP 1,2,3: RGB color (Shift inverts)
// //
// when aiming at wall or sector: // when aiming at wall or sector and the respective overrides are on:
// ----Alt-KP/ enable/disable parallax override /// none, toggle them manually in the OSD
// ----Alt-KP* enable/disable bias override /// none, toggle them manually in the OSD
// when the respective overrides are on:
// KP 5,8: parallaxscale // KP 5,8: parallaxscale
// KP 4,6: parallaxbias // KP 4,6: parallaxbias
// KP /,*: specularfactor // KP /,*: specularfactor
@ -134,27 +131,7 @@ ends
// Also try Shift and/or Ctrl modifiers for different increments // Also try Shift and/or Ctrl modifiers for different increments
defstate fiddlewithlights defstate fiddlewithlights
var minval maxval var minval maxval
/*
ifaimingsprite nullop else
{
ifeithershift ifhitkey KEY_gSLASH
{
xor pr_overrideparallax 1, and pr_overrideparallax 1
ife pr_overrideparallax 1
quote "OVERRIDE POLYMER PARALLAX: ON"
else
quote "OVERRIDE POLYMER PARALLAX: OFF"
}
else ifeithershift ifhitkey KEY_gSTAR
{
xor pr_overridespecular 1, and pr_overridespecular 1
ife pr_overridespecular 1
quote "OVERRIDE POLYMER SPECULAR: ON"
else
quote "OVERRIDE POLYMER SPECULAR: OFF"
}
}
*/
// if aiming at sector or wall // if aiming at sector or wall
ifaimingsprite nullop ifaimingsprite nullop
else ifn pr_overrideparallax 0 else ifn pr_overrideparallax 0
@ -818,7 +795,7 @@ onevent EVENT_KEYS3D
var l m var l m
// door sound tester // door sound tester
ifaimingwall ifeitherctrl ifeithershift ifaimingwall
ifholdkey KEY_SPACE ifholdkey KEY_SPACE
{ {
set k wall[searchwall].nextsector set k wall[searchwall].nextsector
@ -833,17 +810,21 @@ onevent EVENT_KEYS3D
{ {
getsoundflags .lotag m getsoundflags .lotag m
ifand m 1 nullop else soundonce .lotag ifand m 1 nullop else soundonce .lotag
resetkey KEY_SPACE
} }
} }
} }
// swinging doors tester -- hit space on a door wall // swinging doors tester -- hit Ctrl-Shift-SPACE on a door wall
ifaimingwall ifeitherctrl ifeithershift ifaimingwall
ifhitkey KEY_SPACE // SE11 ST23 up:ccw ifholdkey KEY_SPACE // SE11 ST23 up:ccw
{ {
set k wall[searchwall].nextsector set k wall[searchwall].nextsector
ifl k 0 return ifl k 0 return
ifn sector[k].lotag 23 return ifn sector[k].lotag 23 return
resetkey KEY_SPACE
set tmp 0 set tmp 0
for i loopofwall searchwall for i loopofwall searchwall
{ {
@ -894,8 +875,8 @@ onevent EVENT_KEYS3D
} }
// teleporter -- works on SE7 and SE17 (elevator) // teleporter -- works on SE7 and SE17 (elevator)
ifaimingsprite ifeitherctrl ifaimingsprite
ifhitkey KEY_SPACE ifholdkey KEY_SPACE
{ {
ife sprite[searchwall].picnum SECTOREFFECTOR ife sprite[searchwall].picnum SECTOREFFECTOR
{ {
@ -904,6 +885,8 @@ onevent EVENT_KEYS3D
ife sprite[searchwall].lotag 17 set tmp 1 ife sprite[searchwall].lotag 17 set tmp 1
ife tmp 0 return ife tmp 0 return
resetkey KEY_SPACE
for i allsprites for i allsprites
{ {
ifn i searchwall, ifactor SECTOREFFECTOR, ife sprite[i].lotag sprite[searchwall].lotag ifn i searchwall, ifactor SECTOREFFECTOR, ife sprite[i].lotag sprite[searchwall].lotag
@ -922,10 +905,12 @@ onevent EVENT_KEYS3D
else ife sprite[searchwall].extra DUP_ROT_MAGIC else ife sprite[searchwall].extra DUP_ROT_MAGIC
{ {
state duprot state duprot
resetkey KEY_SPACE
} }
else ife sprite[searchwall].extra DUP_LIN_MAGIC2 else ife sprite[searchwall].extra DUP_LIN_MAGIC2
{ {
state duplin state duplin
resetkey KEY_SPACE
} }
} }

View file

@ -4589,14 +4589,14 @@ static void Keys3d(void)
if (keystatus[KEYSC_QUOTE]) if (keystatus[KEYSC_QUOTE])
{ {
pal[0] = getnumber256("Ceiling palette: ", -1, MAXPALOOKUPS-1, 1); pal[0] = getnumber256("Ceiling palette: ", -1, M32_MAXPALOOKUPS, 1);
pal[1] = getnumber256("Floor palette: ", -1, MAXPALOOKUPS-1, 1); pal[1] = getnumber256("Floor palette: ", -1, M32_MAXPALOOKUPS, 1);
pal[2] = getnumber256("Wall palette: ", -1, MAXPALOOKUPS-1, 1); pal[2] = getnumber256("Wall palette: ", -1, M32_MAXPALOOKUPS, 1);
pal[3] = getnumber256("Sprite palette: ", -1, MAXPALOOKUPS-1, 1); pal[3] = getnumber256("Sprite palette: ", -1, M32_MAXPALOOKUPS, 1);
} }
else else
{ {
pal[0] = getnumber256("Global palette: ", 0, MAXPALOOKUPS-1, 0); pal[0] = getnumber256("Global palette: ", 0, M32_MAXPALOOKUPS, 0);
pal[1] = pal[2] = pal[3] = pal[0]; pal[1] = pal[2] = pal[3] = pal[0];
} }
@ -4674,8 +4674,9 @@ static void Keys3d(void)
if (AIMING_AT_WALL_OR_MASK && PRESSED_KEYSC(PERIOD)) if (AIMING_AT_WALL_OR_MASK && PRESSED_KEYSC(PERIOD))
{ {
AutoAlignWalls(searchwall, 0); int32_t naligned=AutoAlignWalls(searchwall, eitherCTRL, 0);
message("Wall %d autoalign", searchwall); message("Auto-aligned %d wall%s %s based on wall %d", naligned,
naligned==1?"":"s", eitherCTRL?"recursively":"", searchwall);
} }
@ -4709,7 +4710,7 @@ static void Keys3d(void)
sector[searchsector].ceilingheinum = 0; sector[searchsector].ceilingheinum = 0;
} }
getnumberptr256("Sector ceiling slope: ", &sector[searchsector].ceilingheinum, getnumberptr256("Sector ceiling slope: ", &sector[searchsector].ceilingheinum,
sizeof(sector[0].ceilingheinum), 32767, 1, NULL); sizeof(sector[0].ceilingheinum), BHEINUM_MAX, 1, NULL);
break; break;
case SEARCH_FLOOR: case SEARCH_FLOOR:
getnumberptr256("Sector floorz: ", &sector[searchsector].floorz, getnumberptr256("Sector floorz: ", &sector[searchsector].floorz,
@ -4720,14 +4721,15 @@ static void Keys3d(void)
sector[searchsector].floorstat |= 2; sector[searchsector].floorstat |= 2;
} }
getnumberptr256("Sector floor slope: ", &sector[searchsector].floorheinum, getnumberptr256("Sector floor slope: ", &sector[searchsector].floorheinum,
sizeof(sector[0].floorheinum), 32767, 1, NULL); sizeof(sector[0].floorheinum), BHEINUM_MAX, 1, NULL);
break; break;
case SEARCH_SPRITE: case SEARCH_SPRITE:
getnumberptr256("Sprite x: ", &sprite[searchwall].x, sizeof(sprite[0].x), editorgridextent-1, 1, NULL); getnumberptr256("Sprite x: ", &sprite[searchwall].x, sizeof(sprite[0].x), editorgridextent-1, 1, NULL);
getnumberptr256("Sprite y: ", &sprite[searchwall].y, sizeof(sprite[0].y), editorgridextent-1, 1, NULL); getnumberptr256("Sprite y: ", &sprite[searchwall].y, sizeof(sprite[0].y), editorgridextent-1, 1, NULL);
getnumberptr256("Sprite z: ", &sprite[searchwall].z, sizeof(sprite[0].z), BZ_MAX, 1, NULL); getnumberptr256("Sprite z: ", &sprite[searchwall].z, sizeof(sprite[0].z), BZ_MAX, 1, NULL);
getnumberptr256("Sprite angle: ", &sprite[searchwall].ang, sizeof(sprite[0].ang), 2047, 0, NULL); getnumberptr256("Sprite angle: ", &sprite[searchwall].ang, sizeof(sprite[0].ang), 2047, 1, NULL);
sprite[searchwall].ang &= 2047;
break; break;
} }
@ -5185,14 +5187,16 @@ static void Keys3d(void)
if (ASSERT_AIMING) if (ASSERT_AIMING)
{ {
// PK: PGUP/PGDN, rmb only & mwheel // PK: PGUP/PGDN, rmb only & mwheel
tsign -= (PRESSED_KEYSC(PGUP) || (mouseaction && mousey<0) || ((bstatus&18)==18 && !(bstatus&1))); tsign -= (PRESSED_KEYSC(PGUP) || (mouseaction && mousey<0) || ((bstatus&(16|2|1))==(16|2)));
tsign += (PRESSED_KEYSC(PGDN) || (mouseaction && mousey>0) || ((bstatus&34)==34 && !(bstatus&1))); tsign += (PRESSED_KEYSC(PGDN) || (mouseaction && mousey>0) || ((bstatus&(32|2|1))==(32|2)));
} }
if (tsign) if (tsign)
{ {
int16_t sect, havebtm=0, havetop=0;
k = 0; k = 0;
if (highlightsectorcnt >= 0) if (highlightsectorcnt > 0)
{ {
for (i=0; i<highlightsectorcnt; i++) for (i=0; i<highlightsectorcnt; i++)
if (highlightsector[i] == searchsector) if (highlightsector[i] == searchsector)
@ -5202,11 +5206,29 @@ static void Keys3d(void)
} }
} }
if (AIMING_AT_WALL || AIMING_AT_CEILING) if (k)
{
sect = highlightsector[0];
havetop = AIMING_AT_WALL;
}
else
{
if (AIMING_AT_WALL && wall[searchwall].nextsector>=0
&& eitherALT && !(bstatus&1))
{
sect = wall[searchwall].nextsector;
havebtm = searchisbottom;
havetop = !havebtm;
}
else
{
sect = searchsector;
havetop = AIMING_AT_WALL;
}
}
if (AIMING_AT_CEILING || havetop)
{ {
int16_t sect = k ? highlightsector[0] :
((AIMING_AT_WALL && wall[searchwall].nextsector>=0 && (eitherALT && !(bstatus&1))) ?
wall[searchwall].nextsector : searchsector);
int32_t tmphei; int32_t tmphei;
for (j=0; j<(k?k:1); j++, sect=highlightsector[j]) for (j=0; j<(k?k:1); j++, sect=highlightsector[j])
@ -5229,10 +5251,8 @@ static void Keys3d(void)
message("Sector %d ceilingz = %d", sect, sector[sect].ceilingz); message("Sector %d ceilingz = %d", sect, sector[sect].ceilingz);
} }
} }
else if (AIMING_AT_FLOOR) else if (AIMING_AT_FLOOR || havebtm)
{ {
int16_t sect = k ? highlightsector[0] : searchsector;
for (j=0; j<(k?k:1); j++, sect=highlightsector[j]) for (j=0; j<(k?k:1); j++, sect=highlightsector[j])
{ {
for (i=headspritesect[sect]; i!=-1; i=nextspritesect[i]) for (i=headspritesect[sect]; i!=-1; i=nextspritesect[i])
@ -5364,12 +5384,12 @@ static void Keys3d(void)
Bsprintf(tempbuf,"VIEW"); Bsprintf(tempbuf,"VIEW");
else if ((bstatus&(2|1))==2) else if ((bstatus&(2|1))==2)
Bsprintf(tempbuf,"Z%s", keystatus[KEYSC_HOME]?" 256":keystatus[KEYSC_END]?" 512":""); Bsprintf(tempbuf,"Z%s", keystatus[KEYSC_HOME]?" 256":keystatus[KEYSC_END]?" 512":"");
else if ((bstatus&(2|1))==1)
if ((bstatus&(2|1))==1 || (keystatus[KEYSC_SPACE]))
Bsprintf(tempbuf,"LOCK"); Bsprintf(tempbuf,"LOCK");
if (bstatus&1) if (bstatus&1)
{ {
Bsprintf(tempbuf,"LOCK");
switch (searchstat) switch (searchstat)
{ {
case SEARCH_WALL: case SEARCH_WALL:
@ -5464,14 +5484,6 @@ static void Keys3d(void)
} }
} }
/* if(purpleon) {
begindrawing();
// printext256(1*4,1*8,whitecol,-1,"Purple ON",0);
message("Purple ON");
enddrawing();
}
*/
if (cursectnum>=0 && sector[cursectnum].lotag==2) if (cursectnum>=0 && sector[cursectnum].lotag==2)
{ {
if (sector[cursectnum].ceilingpicnum==FLOORSLIME) if (sector[cursectnum].ceilingpicnum==FLOORSLIME)
@ -5518,25 +5530,7 @@ static void Keys3d(void)
DeletePolymerLights(); DeletePolymerLights();
#endif #endif
} }
///___unused_keys___
/* if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_G]) // ' g <Unused>
{
keystatus[KEYSC_G] = 0;
tabgraphic++;
if (tabgraphic > 2) tabgraphic = 0;
if (tabgraphic) message("Graphics ON");
else message("Graphics OFF");
}*/
/* if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_R]) // ' r <Handled already>
{
keystatus[KEYSC_R] = 0;
framerateon=!framerateon;
if (framerateon) message("Framerate ON");
else message("Framerate OFF");
}*/
if (keystatus[KEYSC_QUOTE] && PRESSED_KEYSC(W)) // ' w if (keystatus[KEYSC_QUOTE] && PRESSED_KEYSC(W)) // ' w
{ {
nosprites = (nosprites+1)%MAXNOSPRITES; nosprites = (nosprites+1)%MAXNOSPRITES;
@ -5850,7 +5844,7 @@ static void Keys3d(void)
if (!(AIMED_CEILINGFLOOR(stat)&2)) if (!(AIMED_CEILINGFLOOR(stat)&2))
AIMED_CEILINGFLOOR(heinum) = 0; AIMED_CEILINGFLOOR(heinum) = 0;
AIMED_CEILINGFLOOR(heinum) = clamp(AIMED_CEILINGFLOOR(heinum) + tsign*i, -32768, 32767); AIMED_CEILINGFLOOR(heinum) = clamp(AIMED_CEILINGFLOOR(heinum) + tsign*i, -BHEINUM_MAX, BHEINUM_MAX);
message("Sector %d ceiling slope = %d",searchsector,AIMED_CEILINGFLOOR(heinum)); message("Sector %d ceiling slope = %d",searchsector,AIMED_CEILINGFLOOR(heinum));
} }
@ -6557,7 +6551,7 @@ static void Keys3d(void)
if (ASSERT_AIMING) if (ASSERT_AIMING)
{ {
Bsprintf(tempbuf, "%s pal: ", Typestr[searchstat]); Bsprintf(tempbuf, "%s pal: ", Typestr[searchstat]);
getnumberptr256(tempbuf, &AIMED_CF_SEL(pal), sizeof(uint8_t), 255, 0, NULL); getnumberptr256(tempbuf, &AIMED_CF_SEL(pal), sizeof(uint8_t), M32_MAXPALOOKUPS, 0, NULL);
asksave = 1; asksave = 1;
} }
} }
@ -7671,11 +7665,6 @@ int32_t ExtPreInit(int32_t argc,const char **argv)
return 0; return 0;
} }
static int32_t atoi_safe(const char *str)
{
return (int32_t)strtol(str, NULL, 10);
}
static int32_t osdcmd_quit(const osdfuncparm_t *parm) static int32_t osdcmd_quit(const osdfuncparm_t *parm)
{ {
UNREFERENCED_PARAMETER(parm); UNREFERENCED_PARAMETER(parm);
@ -7963,7 +7952,7 @@ static int32_t osdcmd_tint(const osdfuncparm_t *parm)
if (parm->numparms==1) if (parm->numparms==1)
{ {
i = atoi_safe(parm->parms[0]); i = atoi_safe(parm->parms[0]);
if (i>=0 && i<MAXPALOOKUPS-RESERVEDPALS) if (i>=0 && i<=M32_MAXPALOOKUPS)
{ {
p = &hictinting[i]; p = &hictinting[i];
OSD_Printf("pal %d: r=%d g=%d b=%d f=%d\n", i, p->r, p->g, p->b, p->f); OSD_Printf("pal %d: r=%d g=%d b=%d f=%d\n", i, p->r, p->g, p->b, p->f);
@ -7972,14 +7961,14 @@ static int32_t osdcmd_tint(const osdfuncparm_t *parm)
else if (parm->numparms==0) else if (parm->numparms==0)
{ {
OSD_Printf("Hightile tintings:\n"); OSD_Printf("Hightile tintings:\n");
for (i=0,p=&hictinting[0]; i<MAXPALOOKUPS-RESERVEDPALS; i++,p++) for (i=0,p=&hictinting[0]; i<=M32_MAXPALOOKUPS; i++,p++)
if (*(int32_t *)&hictinting[i] != B_LITTLE32(0x00ffffff)) if (*(int32_t *)&hictinting[i] != B_LITTLE32(0x00ffffff))
OSD_Printf("pal %d: rgb %3d %3d %3d f %d\n", i, p->r, p->g, p->b, p->f); OSD_Printf("pal %d: rgb %3d %3d %3d f %d\n", i, p->r, p->g, p->b, p->f);
} }
else if (parm->numparms>=2) else if (parm->numparms>=2)
{ {
i = atoi_safe(parm->parms[0]); i = atoi_safe(parm->parms[0]);
if (i<0 || i>=MAXPALOOKUPS-RESERVEDPALS) if (i<0 || i>M32_MAXPALOOKUPS)
return OSDCMD_SHOWHELP; return OSDCMD_SHOWHELP;
p = &hictinting[i]; p = &hictinting[i];
@ -10610,11 +10599,11 @@ static void EditSectorData(int16_t sectnum)
break; break;
case 5: case 5:
handlemed(0, "Ceiling heinum", "Ceiling Heinum", &sector[sectnum].ceilingheinum, handlemed(0, "Ceiling heinum", "Ceiling Heinum", &sector[sectnum].ceilingheinum,
sizeof(sector[sectnum].ceilingheinum), 32767, 1); sizeof(sector[sectnum].ceilingheinum), BHEINUM_MAX, 1);
break; break;
case 6: case 6:
handlemed(0, "Palookup number", "Ceiling Palookup Number", &sector[sectnum].ceilingpal, handlemed(0, "Palookup number", "Ceiling Palookup Number", &sector[sectnum].ceilingpal,
sizeof(sector[sectnum].ceilingpal), MAXPALOOKUPS-1, 0); sizeof(sector[sectnum].ceilingpal), M32_MAXPALOOKUPS, 0);
break; break;
} }
} }
@ -10654,11 +10643,11 @@ static void EditSectorData(int16_t sectnum)
break; break;
case 5: case 5:
handlemed(0, "Floor heinum", "Floor Heinum", &sector[sectnum].floorheinum, handlemed(0, "Floor heinum", "Floor Heinum", &sector[sectnum].floorheinum,
sizeof(sector[sectnum].floorheinum), 32767, 1); sizeof(sector[sectnum].floorheinum), BHEINUM_MAX, 1);
break; break;
case 6: case 6:
handlemed(0, "Palookup number", "Floor Palookup Number", &sector[sectnum].floorpal, handlemed(0, "Palookup number", "Floor Palookup Number", &sector[sectnum].floorpal,
sizeof(sector[sectnum].floorpal), MAXPALOOKUPS-1, 0); sizeof(sector[sectnum].floorpal), M32_MAXPALOOKUPS, 0);
break; break;
} }
} }
@ -10710,7 +10699,7 @@ static void EditWallData(int16_t wallnum)
break; break;
case 2: case 2:
handlemed(0, "Pal", "Pal", &wall[wallnum].pal, handlemed(0, "Pal", "Pal", &wall[wallnum].pal,
sizeof(wall[wallnum].pal), MAXPALOOKUPS-1, 0); sizeof(wall[wallnum].pal), M32_MAXPALOOKUPS, 0);
break; break;
case 3: case 3:
for (i=Bsprintf(med_disptext,"(X,Y)repeat: %d, %d",wall[wallnum].xrepeat,wall[wallnum].yrepeat); i < med_dispwidth; i++) med_disptext[i] = ' '; for (i=Bsprintf(med_disptext,"(X,Y)repeat: %d, %d",wall[wallnum].xrepeat,wall[wallnum].yrepeat); i < med_dispwidth; i++) med_disptext[i] = ' ';
@ -10900,7 +10889,7 @@ static void EditSpriteData(int16_t spritenum)
break; break;
case 2: case 2:
handlemed(0, "Pal", "Pal", &sprite[spritenum].pal, handlemed(0, "Pal", "Pal", &sprite[spritenum].pal,
sizeof(sprite[spritenum].pal), MAXPALOOKUPS-1, 0); sizeof(sprite[spritenum].pal), M32_MAXPALOOKUPS, 0);
break; break;
case 3: case 3:
{ {
@ -11016,7 +11005,7 @@ static void GenericSpriteSearch()
{ {
{ BXY_MAX , 65535 , 2048 }, { BXY_MAX , 65535 , 2048 },
{ BXY_MAX , 128 , 65535 }, { BXY_MAX , 128 , 65535 },
{ BZ_MAX , MAXPALOOKUPS-1, 65535 }, { BZ_MAX , M32_MAXPALOOKUPS, 65535 },
{ MAXSECTORS-1, 128 , 65535 }, { MAXSECTORS-1, 128 , 65535 },
{ MAXSTATUS-1 , 128 , MAXSPRITES-1 }, { MAXSTATUS-1 , 128 , MAXSPRITES-1 },
{ BTAG_MAX , MAXTILES-1 , 256 }, { BTAG_MAX , MAXTILES-1 , 256 },

View file

@ -446,6 +446,11 @@ const memberlabel_t SectorLabels[]=
{ "lotag", SECTOR_LOTAG, 0, 0, 0 }, { "lotag", SECTOR_LOTAG, 0, 0, 0 },
{ "hitag", SECTOR_HITAG, 0, 0, 0 }, { "hitag", SECTOR_HITAG, 0, 0, 0 },
{ "extra", SECTOR_EXTRA, 0, 0, 0 }, { "extra", SECTOR_EXTRA, 0, 0, 0 },
// aliases
{ "filler", SECTOR_ALIGNTO, 0, 0, 0 },
{ "ceilingheinum", SECTOR_CEILINGSLOPE, 0, 0, 0},
{ "floorheinum", SECTOR_FLOORSLOPE, 0, 0, 0},
{ "", -1, 0, 0, 0 } // END OF LIST { "", -1, 0, 0, 0 } // END OF LIST
}; };
@ -496,6 +501,9 @@ const memberlabel_t SpriteLabels[]=
{ "lotag", SPRITE_LOTAG, 0, 0, 0 }, { "lotag", SPRITE_LOTAG, 0, 0, 0 },
{ "hitag", SPRITE_HITAG, 0, 0, 0 }, { "hitag", SPRITE_HITAG, 0, 0, 0 },
{ "extra", SPRITE_EXTRA, 0, 0, 0 }, { "extra", SPRITE_EXTRA, 0, 0, 0 },
// aliases
{ "filler", SPRITE_DETAIL, 1, 0, 0 },
{ "", -1, 0, 0, 0 } // END OF LIST { "", -1, 0, 0, 0 } // END OF LIST
}; };
@ -555,7 +563,7 @@ static void C_InitHashes()
hash_init(&h_sector); hash_init(&h_sector);
for (i=0; SectorLabels[i].lId >=0; i++) for (i=0; SectorLabels[i].lId >=0; i++)
hash_add(&h_sector,SectorLabels[i].name,i, 0); hash_add(&h_sector,SectorLabels[i].name,i, 0);
hash_add(&h_sector,"filler", SECTOR_ALIGNTO, 0); // hash_add(&h_sector,"filler", SECTOR_ALIGNTO, 0);
hash_init(&h_wall); hash_init(&h_wall);
for (i=0; WallLabels[i].lId >=0; i++) for (i=0; WallLabels[i].lId >=0; i++)
@ -564,7 +572,7 @@ static void C_InitHashes()
hash_init(&h_sprite); hash_init(&h_sprite);
for (i=0; SpriteLabels[i].lId >=0; i++) for (i=0; SpriteLabels[i].lId >=0; i++)
hash_add(&h_sprite,SpriteLabels[i].name,i, 0); hash_add(&h_sprite,SpriteLabels[i].name,i, 0);
hash_add(&h_sprite,"filler", SPRITE_DETAIL, 0); // hash_add(&h_sprite,"filler", SPRITE_DETAIL, 0);
hash_init(&h_iter); hash_init(&h_iter);
for (i=0; iter_tokens[i].val >=0; i++) for (i=0; iter_tokens[i].val >=0; i++)

View file

@ -25,15 +25,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "m32script.h" #include "m32script.h"
#include "m32def.h" #include "m32def.h"
#include "macros.h"
#include "sounds_mapster32.h" #include "sounds_mapster32.h"
#include "fx_man.h" #include "fx_man.h"
//#include "scriplib.h"
//#include "osdcmds.h"
#include "osd.h" #include "osd.h"
#include "keys.h" #include "keys.h"
// from macros.h
#define rnd(X) ((krand()>>8)>=(255-(X)))
vmstate_t vm; vmstate_t vm;
vmstate_t vm_default = vmstate_t vm_default =
{ {

View file

@ -39,8 +39,6 @@ extern int32_t ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d;
extern int16_t editstatus, searchit; extern int16_t editstatus, searchit;
extern int32_t searchx, searchy, osearchx, osearchy; //search input extern int32_t searchx, searchy, osearchx, osearchy; //search input
extern int16_t searchsector, searchwall, searchstat; //search output
extern int16_t searchbottomwall;
#define COLOR_RED 248 #define COLOR_RED 248
#define COLOR_WHITE 31 #define COLOR_WHITE 31
@ -59,7 +57,6 @@ int32_t nextvoxid = 0;
extern int32_t whitecol; extern int32_t whitecol;
extern char vgapal16[4*256]; extern char vgapal16[4*256];
extern void AutoAlignWalls(int32_t nWall0, int32_t ply);
extern char changechar(char dachar, int32_t dadir, char smooshyalign, char boundcheck); extern char changechar(char dachar, int32_t dadir, char smooshyalign, char boundcheck);
extern void updatenumsprites(void); extern void updatenumsprites(void);

View file

@ -175,3 +175,21 @@ Index: astub.c
+ } + }
+ } + }
+ */ + */
@@ -5532,1 +5532,17 @@
///__unused_keys__
+ /* if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_G]) // ' g <Unused>
+ {
+ keystatus[KEYSC_G] = 0;
+ tabgraphic++;
+ if (tabgraphic > 2) tabgraphic = 0;
+ if (tabgraphic) message("Graphics ON");
+ else message("Graphics OFF");
+ }*/
+
+ /* if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_R]) // ' r <Handled already>
+ {
+ keystatus[KEYSC_R] = 0;
+ framerateon=!framerateon;
+ if (framerateon) message("Framerate ON");
+ else message("Framerate OFF");
+ }*/