* Comment out some practically dead code (rendmode 1 and 2, pcx screenshots), cutting some 8k from the release binary.

* Refactor two nearly identical chunks in polymost.c into one function in the hope of getting some more, but interestingly that did nothing at all. At least it's more readable this way...
* Commit, but don't enable, code for writing PNG screenshots (I'm tired of converting them every time). Requires libpng which in turn requires zlib.

git-svn-id: https://svn.eduke32.com/eduke32@1852 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-03-19 18:07:12 +00:00
parent cfd4661b0b
commit 06afc4dcc5
9 changed files with 388 additions and 275 deletions

View file

@ -23,6 +23,7 @@ LINKED_GTK = 0
BUILD32_ON_64 = 0
# DO NOT SET THIS TO 1 AND COMMIT IT.
NEDMALLOC = 0
USE_LIBPNG = 0
ifeq (0,$(USE_OPENGL))
POLYMER = 0
@ -43,6 +44,7 @@ EFENCE?=0
OPTLEVEL?=2
PROFILER?=0
MUDFLAP?=0
MUDFLAP=0
ifneq (0,$(KRANDDEBUG))
RELEASE=0
@ -63,6 +65,10 @@ STRIP=strip
# compiler flags etc.
LIBS=-lm
ifneq (0,$(USE_LIBPNG))
LIBS+= -lpng
endif
ifneq (0,$(RELEASE))
# Debugging disabled
debug=-fomit-frame-pointer -funswitch-loops -O$(OPTLEVEL)
@ -83,6 +89,9 @@ else
ifneq (0,$(KRANDDEBUG))
debug+=-DKRANDDEBUG=1
endif
ifneq (0,$(MUDFLAP))
debug+=-fmudflap -fmudflapth -funwind-tables
endif
endif
ifneq (0,$(DEBUGANYWAY))
debug+=-ggdb
@ -93,7 +102,11 @@ W_NO_UNUSED_RESULT := $(findstring -Wno-unused-result,$(W_NO_UNUSED_RESULT))
BASECFLAGS=$(debug) -W -Wall -Wimplicit -Werror-implicit-function-declaration \
-funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -D_FORTIFY_SOURCE=2 \
$(F_JUMP_TABLES) $(W_NO_UNUSED_RESULT)
$(F_JUMP_TABLES) $(W_NO_UNUSED_RESULT) \
-Wextra -Wstrict-overflow=1 #-Wwrite-strings -Waddress -Wlogical-op
ifneq (0,$(USE_LIBPNG))
BASECFLAGS+= -DUSE_LIBPNG
endif
BASECXXFLAGS= -fno-exceptions -fno-rtti
BASEASFLAGS=-s #-g

View file

@ -591,7 +591,7 @@ int32_t setsprite(int16_t spritenum, const vec3_t *new) ATTRIBUTE((nonnull(2))
int32_t spriteheight(int16_t i, int32_t *basez);
int32_t screencapture(const char *filename, char inverseit) ATTRIBUTE((nonnull(1)));
int32_t screencapture(const char *filename, char inverseit, const char *versionstr) ATTRIBUTE((nonnull(1)));
int32_t getclosestcol(int32_t r, int32_t g, int32_t b);

View file

@ -14,11 +14,6 @@
#define UNREFERENCED_PARAMETER(x) x=x
#endif
static inline int clamp(int in, int min, int max)
{
return in <= min ? min : in >= max ? max : in;
}
#if defined __GNUC__ || defined __clang__
# define ATTRIBUTE(attrlist) __attribute__(attrlist)
#else
@ -372,6 +367,10 @@ static inline void dtol(double d, int32_t *a)
# define max(a,b) ( ((a) > (b)) ? (a) : (b) )
#endif
static inline int clamp(int in, int min, int max)
{
return in <= min ? min : in >= max ? max : in;
}
#define BMAX_PATH 256

View file

@ -2532,7 +2532,9 @@ void overheadeditor(void)
{
keystatus[88] = 0;
//__clearscreen_beforecapture__
screencapture("captxxxx.tga", eitherSHIFT);
Bsprintf(tempbuf, "Mapster32 %s", ExtGetVer());
screencapture("captxxxx.tga", eitherSHIFT, tempbuf);
showframe(1);
}

View file

@ -36,6 +36,14 @@
# endif
#endif
#ifdef USE_LIBPNG
//# include <setjmp.h>
# ifdef NEDMALLOC
# define PNG_USER_MEM_SUPPORTED
# endif
# include <png.h>
#endif
#include <math.h>
#include "engine_priv.h"
@ -13322,13 +13330,10 @@ void printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, const
//
// screencapture
//
int32_t screencapture_tga(const char *filename, char inverseit)
static int32_t screencapture_common1(char *fn, const char *ext, BFILE** filptr)
{
int32_t i,j;
char *ptr, head[18] = { 0,1,1,0,0,0,1,24,0,0,0,0,0/*wlo*/,0/*whi*/,0/*hlo*/,0/*hhi*/,8,0 };
//char palette[4*256];
char *fn = Bstrdup(filename), *inversebuf;
BFILE *fil;
int32_t i;
do // JBF 2004022: So we don't overwrite existing screenshots
{
@ -13340,22 +13345,182 @@ int32_t screencapture_tga(const char *filename, char inverseit)
fn[i++] = ((capturecount/10)%10)+48;
fn[i++] = (capturecount%10)+48;
i++;
fn[i++] = 't';
fn[i++] = 'g';
fn[i++] = 'a';
Bstrcpy(&fn[i], ext);
if ((fil = Bfopen(fn,"rb")) == NULL) break;
Bfclose(fil);
if ((*filptr = Bfopen(fn,"rb")) == NULL) break;
Bfclose(*filptr);
capturecount++;
}
while (1);
fil = Bfopen(fn,"wb");
if (fil == NULL)
*filptr = Bfopen(fn,"wb");
if (*filptr == NULL)
{
Bfree(fn);
return -1;
}
return 0;
}
#ifdef USE_LIBPNG
// PNG screenshots -- adapted from libpng example.c
int32_t screencapture_png(const char *filename, char inverseit, const char *versionstr)
{
int32_t i;
BFILE *fp;
#ifdef USE_OPENGL
# define HICOLOR (rendmode>=3 && qsetmode==200)
#else
# define HICOLOR 0
#endif
png_structp png_ptr;
png_infop info_ptr;
png_colorp palette = NULL;
png_textp text = NULL;
png_bytep buf = NULL;
png_bytepp rowptrs = NULL;
char fn[32]; // careful...
UNREFERENCED_PARAMETER(inverseit);
Bstrcpy(fn, filename);
i = screencapture_common1(fn, "png", &fp);
if (i)
return i;
/* Create and initialize the png_struct with default error handling. */
#ifndef NEDMALLOC
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
#else
png_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL, Bmalloc, Bfree);
#endif
if (png_ptr == NULL)
{
Bfclose(fp);
return -1;
}
/* Allocate/initialize the image information data. */
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
{
Bfclose(fp);
png_destroy_write_struct(&png_ptr, NULL);
return -1;
}
/* Set error handling. */
if (setjmp(png_jmpbuf(png_ptr)))
{
/* If we get here, we had a problem writing the file */
Bfclose(fp);
if (palette) png_free(png_ptr, palette);
if (text) png_free(png_ptr, text);
if (buf) png_free(png_ptr, buf);
if (rowptrs) png_free(png_ptr, rowptrs);
png_destroy_write_struct(&png_ptr, &info_ptr);
return -1;
}
png_init_io(png_ptr, fp);
// initialize various info fields from here on
png_set_IHDR(png_ptr, info_ptr, xdim, ydim, 8,
HICOLOR ? PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_PALETTE,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
if (HICOLOR && editstatus==0)
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_FILTER_VALUE_NONE);
if (!HICOLOR)
palette = (png_colorp)png_malloc(png_ptr, 256*png_sizeof(png_color));
if (palette)
{
for (i=0; i<256; i++)
{
palette[i].red = curpalettefaded[i].r;
palette[i].green = curpalettefaded[i].g;
palette[i].blue = curpalettefaded[i].b;
}
png_set_PLTE(png_ptr, info_ptr, palette, 256);
}
png_set_gAMA(png_ptr, info_ptr, vid_gamma); // 1.0/vid_gamma ?
png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_SATURATION); // hm...
text = (png_textp)png_malloc(png_ptr, 2*png_sizeof(png_text));
text[0].compression = PNG_TEXT_COMPRESSION_NONE;
text[0].key = "Title";
text[0].text = editstatus ? "Mapster32 screenshot" : "EDuke32 screenshot";
text[1].compression = PNG_TEXT_COMPRESSION_NONE;
text[1].key = "Software";
text[1].text = (char *)versionstr;
png_set_text(png_ptr, info_ptr, text, 2);
// get/set the pixel data
begindrawing(); //{{{
if (palette)
{
buf = (png_bytep)png_malloc(png_ptr, xdim*ydim);
Bmemcpy(buf, (char *)frameplace, xdim*ydim);
}
else
{
buf = (png_bytep)png_malloc(png_ptr, xdim*ydim*3);
bglReadPixels(0,0,xdim,ydim,GL_RGB,GL_UNSIGNED_BYTE,buf);
}
enddrawing(); //}}}
rowptrs = (png_bytepp)png_malloc(png_ptr, ydim*sizeof(png_bytep));
if (!palette)
{
int32_t k = xdim*(1+2*!palette);
for (i=0; i<ydim; i++)
rowptrs[i] = &buf[k*(ydim-i-1)];
}
else
{
for (i=0; i<ydim; i++)
rowptrs[i] = &buf[xdim*i];
}
png_set_rows(png_ptr, info_ptr, rowptrs);
// write the png file!
png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
Bfclose(fp);
if (palette) png_free(png_ptr, palette);
if (text) png_free(png_ptr, text);
if (buf) png_free(png_ptr, buf);
if (rowptrs) png_free(png_ptr, rowptrs);
png_destroy_write_struct(&png_ptr, &info_ptr);
OSD_Printf("Saved screenshot to %s\n", fn);
capturecount++;
return 0;
}
#undef HICOLOR
#endif // defined USE_LIBPNG
int32_t screencapture_tga(const char *filename, char inverseit)
{
int32_t i,j;
char *ptr, head[18] = { 0,1,1,0,0,0,1,24,0,0,0,0,0/*wlo*/,0/*whi*/,0/*hlo*/,0/*hhi*/,8,0 };
//char palette[4*256];
char *fn = Bstrdup(filename), *inversebuf;
BFILE *fil;
i = screencapture_common1(fn, "tga", &fil);
if (i)
return i;
#ifdef USE_OPENGL
if (rendmode >= 3 && qsetmode == 200)
{
@ -13452,6 +13617,7 @@ int32_t screencapture_tga(const char *filename, char inverseit)
return(0);
}
#if 0
// PCX is nasty, which is why I've lifted these functions from the PCX spec by ZSoft
static int32_t writepcxbyte(char colour, char count, BFILE *fp)
{
@ -13512,31 +13678,9 @@ int32_t screencapture_pcx(const char *filename, char inverseit)
char *fn = Bstrdup(filename), *inversebuf;
BFILE *fil;
do // JBF 2004022: So we don't overwrite existing screenshots
{
if (capturecount > 9999) return -1;
i = Bstrrchr(fn,'.')-fn-4;
fn[i++] = ((capturecount/1000)%10)+48;
fn[i++] = ((capturecount/100)%10)+48;
fn[i++] = ((capturecount/10)%10)+48;
fn[i++] = (capturecount%10)+48;
i++;
fn[i++] = 'p';
fn[i++] = 'c';
fn[i++] = 'x';
if ((fil = Bfopen(fn,"rb")) == NULL) break;
Bfclose(fil);
capturecount++;
}
while (1);
fil = Bfopen(fn,"wb");
if (fil == NULL)
{
Bfree(fn);
return -1;
}
i = screencapture_common1(fn, "pcx", &fil);
if (i)
return i;
memset(head,0,128);
head[0] = 10;
@ -13639,11 +13783,20 @@ int32_t screencapture_pcx(const char *filename, char inverseit)
capturecount++;
return(0);
}
#endif
int32_t screencapture(const char *filename, char inverseit)
int32_t screencapture(const char *filename, char inverseit, const char *versionstr)
{
if (captureformat == 0) return screencapture_tga(filename,inverseit);
else return screencapture_pcx(filename,inverseit);
#ifndef USE_LIBPNG
UNREFERENCED_PARAMETER(versionstr);
#else
if (!inverseit)
return screencapture_png(filename,inverseit,versionstr);
else
#endif
// if (captureformat == 0)
return screencapture_tga(filename,inverseit);
// else return screencapture_pcx(filename,inverseit);
}

View file

@ -2415,6 +2415,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
}
#endif
#if 0
if (rendmode == 2)
{
#if (USEZBUFFER != 0)
@ -2476,6 +2477,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
ltsizy = (picsiz[globalpicnum]>>4);
}
else
#endif
{
dacol = palookup[0][(int32_t)(*(char *)(waloff[globalpicnum]))+(min(max((int32_t)(globalshade * shadescale),0),numpalookups-1)<<8)];
}
@ -2531,9 +2533,11 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
ix1 = (x>>14); if (ix1 > xdimen) ix1 = xdimen;
if (ix0 < ix1)
{
#if 0
if (rendmode == 1)
memset((void *)(ylookup[y]+ix0+frameoffset),dacol,ix1-ix0);
else
#endif
{
vidp = (char *)(ylookup[y]+frameoffset+ix0);
dp = ngdx*(double)ix0 + ngdy*(double)y + ngdo;
@ -2717,7 +2721,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
i = j;
}
while (i != maxi);
#if 0
if (rendmode == 1)
{
if (method&3) //Only draw border around sprites/maskwalls
@ -2730,6 +2734,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
//ox /= (double)n; oy /= (double)n;
//for(i=0,j=n-1;i<n;j=i,i++) drawline2d(px[i]+(ox-px[i])*.125,py[i]+(oy-py[i])*.125,px[j]+(ox-px[j])*.125,py[j]+(oy-py[j])*.125,31);
}
#endif
}
/*Init viewport boundary (must be 4 point convex loop):
@ -3063,11 +3068,151 @@ void domost(float x0, float y0, float x1, float y1)
static void polymost_scansector(int32_t sectnum);
// variables that are set to ceiling- or floor-members, depending
// on which one is processed right now
static int32_t global_cf_z;
static float global_cf_xpanning, global_cf_ypanning, global_cf_heinum;
static int32_t global_cf_shade, global_cf_pal;
static int32_t (*global_getzofslope_func)(int16_t, int32_t, int32_t);
static void polymost_internal_nonparallaxed(double nx0, double ny0, double nx1, double ny1, double ryp0, double ryp1,
double x0, double x1, double cf_y0, double cf_y1, int32_t have_floor,
int32_t sectnum)
{
double ft[4], fx, fy, ox, oy, oz, ox2, oy2;
double px[3], py[3], dd[3], uu[3], vv[3], r;
int32_t i;
const sectortype *sec = &sector[sectnum];
// comments from floor code:
//(singlobalang/-16384*(sx-ghalfx) + 0*(sy-ghoriz) + (cosviewingrangeglobalang/16384)*ghalfx)*d + globalposx = u*16
//(cosglobalang/ 16384*(sx-ghalfx) + 0*(sy-ghoriz) + (sinviewingrangeglobalang/16384)*ghalfx)*d + globalposy = v*16
//( 0*(sx-ghalfx) + 1*(sy-ghoriz) + ( 0)*ghalfx)*d + globalposz/16 = (sec->floorz/16)
if (!(globalorientation&64))
{ ft[0] = globalposx; ft[1] = globalposy; ft[2] = cosglobalang; ft[3] = singlobalang; }
else
{
//relative alignment
fx = (double)(wall[wall[sec->wallptr].point2].x-wall[sec->wallptr].x);
fy = (double)(wall[wall[sec->wallptr].point2].y-wall[sec->wallptr].y);
r = 1.0/sqrt(fx*fx+fy*fy); fx *= r; fy *= r;
ft[2] = cosglobalang*fx + singlobalang*fy;
ft[3] = singlobalang*fx - cosglobalang*fy;
ft[0] = ((double)(globalposx-wall[sec->wallptr].x))*fx + ((double)(globalposy-wall[sec->wallptr].y))*fy;
ft[1] = ((double)(globalposy-wall[sec->wallptr].y))*fx - ((double)(globalposx-wall[sec->wallptr].x))*fy;
if (!(globalorientation&4)) globalorientation ^= 32; else globalorientation ^= 16;
}
gdx = 0;
gdy = gxyaspect;
if (!(globalorientation&2)) gdy /= (double)(global_cf_z-globalposz);
gdo = -ghoriz*gdy;
if (globalorientation&8) { ft[0] /= 8; ft[1] /= -8; ft[2] /= 2097152; ft[3] /= 2097152; }
else { ft[0] /= 16; ft[1] /= -16; ft[2] /= 4194304; ft[3] /= 4194304; }
gux = (double)ft[3]*((double)viewingrange)/-65536.0;
gvx = (double)ft[2]*((double)viewingrange)/-65536.0;
guy = (double)ft[0]*gdy; gvy = (double)ft[1]*gdy;
guo = (double)ft[0]*gdo; gvo = (double)ft[1]*gdo;
guo += (double)(ft[2]-gux)*ghalfx;
gvo -= (double)(ft[3]+gvx)*ghalfx;
//Texture flipping
if (globalorientation&4)
{
r = gux; gux = gvx; gvx = r;
r = guy; guy = gvy; gvy = r;
r = guo; guo = gvo; gvo = r;
}
if (globalorientation&16) { gux = -gux; guy = -guy; guo = -guo; }
if (globalorientation&32) { gvx = -gvx; gvy = -gvy; gvo = -gvo; }
//Texture panning
fx = global_cf_xpanning*((float)(1<<(picsiz[globalpicnum]&15)))/256.0;
fy = global_cf_ypanning*((float)(1<<(picsiz[globalpicnum]>>4)))/256.0;
if ((globalorientation&(2+64)) == (2+64)) //Hack for panning for slopes w/ relative alignment
{
r = global_cf_heinum / 4096.0; r = 1.0/sqrt(r*r+1);
if (!(globalorientation&4)) fy *= r; else fx *= r;
}
guy += gdy*fx; guo += gdo*fx;
gvy += gdy*fy; gvo += gdo*fy;
if (globalorientation&2) //slopes
{
px[0] = x0; py[0] = ryp0 + ghoriz;
px[1] = x1; py[1] = ryp1 + ghoriz;
//Pick some point guaranteed to be not collinear to the 1st two points
ox = nx0 + (ny1-ny0);
oy = ny0 + (nx0-nx1);
ox2 = (double)(oy-globalposy)*gcosang - (double)(ox-globalposx)*gsinang ;
oy2 = (double)(ox-globalposx)*gcosang2 + (double)(oy-globalposy)*gsinang2;
oy2 = 1.0/oy2;
px[2] = ghalfx*ox2*oy2 + ghalfx; oy2 *= gyxscale;
py[2] = oy2 + ghoriz;
for (i=0; i<3; i++)
{
dd[i] = px[i]*gdx + py[i]*gdy + gdo;
uu[i] = px[i]*gux + py[i]*guy + guo;
vv[i] = px[i]*gvx + py[i]*gvy + gvo;
}
py[0] = cf_y0;
py[1] = cf_y1;
py[2] = (global_getzofslope_func(sectnum,(int32_t)ox,(int32_t)oy)-globalposz)*oy2 + ghoriz;
ox = py[1]-py[2]; oy = py[2]-py[0]; oz = py[0]-py[1];
r = 1.0 / (ox*px[0] + oy*px[1] + oz*px[2]);
gdx = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r;
gux = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r;
gvx = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r;
ox = px[2]-px[1]; oy = px[0]-px[2]; oz = px[1]-px[0];
gdy = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r;
guy = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r;
gvy = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r;
gdo = dd[0] - px[0]*gdx - py[0]*gdy;
guo = uu[0] - px[0]*gux - py[0]*guy;
gvo = vv[0] - px[0]*gvx - py[0]*gvy;
if (globalorientation&64) //Hack for relative alignment on slopes
{
r = global_cf_heinum / 4096.0;
r = sqrt(r*r+1);
if (!(globalorientation&4)) { gvx *= r; gvy *= r; gvo *= r; }
else { gux *= r; guy *= r; guo *= r; }
}
}
domostpolymethod = (globalorientation>>7)&3;
if (have_floor)
{
if (globalposz >= getflorzofslope(sectnum,globalposx,globalposy)) domostpolymethod = -1; //Back-face culling
}
else
{
if (globalposz <= getceilzofslope(sectnum,globalposx,globalposy)) domostpolymethod = -1; //Back-face culling
}
#ifdef USE_OPENGL
if (!nofog)
{
fogcalc(global_cf_shade,sec->visibility,global_cf_pal);
bglFogf(GL_FOG_DENSITY,fogresult);
bglFogfv(GL_FOG_COLOR,fogcol);
}
#endif
pow2xsplit = 0;
if (have_floor)
domost(x0,cf_y0,x1,cf_y1); //flor
else
domost(x1,cf_y1,x0,cf_y0); //ceil
domostpolymethod = 0;
}
static void polymost_drawalls(int32_t bunch)
{
sectortype *sec, *nextsec;
walltype *wal, *wal2, *nwal;
double ox, oy, oz, ox2, oy2, px[3], py[3], dd[3], uu[3], vv[3];
double ox, oy, oz, dd[3], vv[3];
double fx, fy, x0, x1, cy0, cy1, fy0, fy1, xp0, yp0, xp1, yp1, ryp0, ryp1, nx0, ny0, nx1, ny1;
double t, r, t0, t1, ocy0, ocy1, ofy0, ofy1, oxp0, oyp0, ft[4];
double oguo, ogux, oguy;
@ -3148,117 +3293,13 @@ static void polymost_drawalls(int32_t bunch)
globalpicnum = sec->floorpicnum; globalshade = sec->floorshade; globalpal = (int32_t)((uint8_t)sec->floorpal);
globalorientation = sec->floorstat;
if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,sectnum);
global_cf_shade = sec->floorshade, global_cf_pal = sec->floorpal; global_cf_z = sec->floorz; // REFACT
global_cf_xpanning = sec->floorxpanning; global_cf_ypanning = sec->floorypanning, global_cf_heinum = sec->floorheinum;
global_getzofslope_func = &getflorzofslope;
if (!(globalorientation&1))
{
//(singlobalang/-16384*(sx-ghalfx) + 0*(sy-ghoriz) + (cosviewingrangeglobalang/16384)*ghalfx)*d + globalposx = u*16
//(cosglobalang/ 16384*(sx-ghalfx) + 0*(sy-ghoriz) + (sinviewingrangeglobalang/16384)*ghalfx)*d + globalposy = v*16
//( 0*(sx-ghalfx) + 1*(sy-ghoriz) + ( 0)*ghalfx)*d + globalposz/16 = (sec->floorz/16)
if (!(globalorientation&64))
{ ft[0] = globalposx; ft[1] = globalposy; ft[2] = cosglobalang; ft[3] = singlobalang; }
else
{
//relative alignment
fx = (double)(wall[wall[sec->wallptr].point2].x-wall[sec->wallptr].x);
fy = (double)(wall[wall[sec->wallptr].point2].y-wall[sec->wallptr].y);
r = 1.0/sqrt(fx*fx+fy*fy); fx *= r; fy *= r;
ft[2] = cosglobalang*fx + singlobalang*fy;
ft[3] = singlobalang*fx - cosglobalang*fy;
ft[0] = ((double)(globalposx-wall[sec->wallptr].x))*fx + ((double)(globalposy-wall[sec->wallptr].y))*fy;
ft[1] = ((double)(globalposy-wall[sec->wallptr].y))*fx - ((double)(globalposx-wall[sec->wallptr].x))*fy;
if (!(globalorientation&4)) globalorientation ^= 32; else globalorientation ^= 16;
}
gdx = 0;
gdy = gxyaspect; if (!(globalorientation&2)) gdy /= (double)(sec->floorz-globalposz);
gdo = -ghoriz*gdy;
if (globalorientation&8) { ft[0] /= 8; ft[1] /= -8; ft[2] /= 2097152; ft[3] /= 2097152; }
else { ft[0] /= 16; ft[1] /= -16; ft[2] /= 4194304; ft[3] /= 4194304; }
gux = (double)ft[3]*((double)viewingrange)/-65536.0;
gvx = (double)ft[2]*((double)viewingrange)/-65536.0;
guy = (double)ft[0]*gdy; gvy = (double)ft[1]*gdy;
guo = (double)ft[0]*gdo; gvo = (double)ft[1]*gdo;
guo += (double)(ft[2]-gux)*ghalfx;
gvo -= (double)(ft[3]+gvx)*ghalfx;
//Texture flipping
if (globalorientation&4)
{
r = gux; gux = gvx; gvx = r;
r = guy; guy = gvy; gvy = r;
r = guo; guo = gvo; gvo = r;
}
if (globalorientation&16) { gux = -gux; guy = -guy; guo = -guo; }
if (globalorientation&32) { gvx = -gvx; gvy = -gvy; gvo = -gvo; }
//Texture panning
fx = (float)sec->floorxpanning*((float)(1<<(picsiz[globalpicnum]&15)))/256.0;
fy = (float)sec->floorypanning*((float)(1<<(picsiz[globalpicnum]>>4)))/256.0;
if ((globalorientation&(2+64)) == (2+64)) //Hack for panning for slopes w/ relative alignment
{
r = (float)sec->floorheinum / 4096.0; r = 1.0/sqrt(r*r+1);
if (!(globalorientation&4)) fy *= r; else fx *= r;
}
guy += gdy*fx; guo += gdo*fx;
gvy += gdy*fy; gvo += gdo*fy;
if (globalorientation&2) //slopes
{
px[0] = x0; py[0] = ryp0 + ghoriz;
px[1] = x1; py[1] = ryp1 + ghoriz;
//Pick some point guaranteed to be not collinear to the 1st two points
ox = nx0 + (ny1-ny0);
oy = ny0 + (nx0-nx1);
ox2 = (double)(oy-globalposy)*gcosang - (double)(ox-globalposx)*gsinang;
oy2 = (double)(ox-globalposx)*gcosang2 + (double)(oy-globalposy)*gsinang2;
oy2 = 1.0/oy2;
px[2] = ghalfx*ox2*oy2 + ghalfx; oy2 *= gyxscale;
py[2] = oy2 + ghoriz;
for (i=0; i<3; i++)
{
dd[i] = px[i]*gdx + py[i]*gdy + gdo;
uu[i] = px[i]*gux + py[i]*guy + guo;
vv[i] = px[i]*gvx + py[i]*gvy + gvo;
}
py[0] = fy0;
py[1] = fy1;
py[2] = (getflorzofslope(sectnum,(int32_t)ox,(int32_t)oy)-globalposz)*oy2 + ghoriz;
ox = py[1]-py[2]; oy = py[2]-py[0]; oz = py[0]-py[1];
r = 1.0 / (ox*px[0] + oy*px[1] + oz*px[2]);
gdx = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r;
gux = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r;
gvx = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r;
ox = px[2]-px[1]; oy = px[0]-px[2]; oz = px[1]-px[0];
gdy = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r;
guy = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r;
gvy = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r;
gdo = dd[0] - px[0]*gdx - py[0]*gdy;
guo = uu[0] - px[0]*gux - py[0]*guy;
gvo = vv[0] - px[0]*gvx - py[0]*gvy;
if (globalorientation&64) //Hack for relative alignment on slopes
{
r = (float)sec->floorheinum / 4096.0;
r = sqrt(r*r+1);
if (!(globalorientation&4)) { gvx *= r; gvy *= r; gvo *= r; }
else { gux *= r; guy *= r; guo *= r; }
}
}
domostpolymethod = (globalorientation>>7)&3;
if (globalposz >= getflorzofslope(sectnum,globalposx,globalposy)) domostpolymethod = -1; //Back-face culling
#ifdef USE_OPENGL
if (!nofog)
{
fogcalc(sec->floorshade,sec->visibility,sec->floorpal);
bglFogf(GL_FOG_DENSITY,fogresult);
bglFogfv(GL_FOG_COLOR,fogcol);
}
#endif
pow2xsplit = 0; domost(x0,fy0,x1,fy1); //flor
domostpolymethod = 0;
}
polymost_internal_nonparallaxed(nx0, ny0, nx1, ny1, ryp0, ryp1, x0, x1, fy0, fy1, 1, sectnum);
else if ((nextsectnum < 0) || (!(sector[nextsectnum].floorstat&1)))
{
//Parallaxing sky... hacked for Ken's mountain texture; paper-sky only :/
@ -3525,115 +3566,13 @@ static void polymost_drawalls(int32_t bunch)
globalpicnum = sec->ceilingpicnum; globalshade = sec->ceilingshade; globalpal = (int32_t)((uint8_t)sec->ceilingpal);
globalorientation = sec->ceilingstat;
if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,sectnum);
global_cf_shade = sec->ceilingshade, global_cf_pal = sec->ceilingpal; global_cf_z = sec->ceilingz; // REFACT
global_cf_xpanning = sec->ceilingxpanning; global_cf_ypanning = sec->ceilingypanning, global_cf_heinum = sec->ceilingheinum;
global_getzofslope_func = &getceilzofslope;
if (!(globalorientation&1))
{
if (!(globalorientation&64))
{ ft[0] = globalposx; ft[1] = globalposy; ft[2] = cosglobalang; ft[3] = singlobalang; }
else
{
//relative alignment
fx = (double)(wall[wall[sec->wallptr].point2].x-wall[sec->wallptr].x);
fy = (double)(wall[wall[sec->wallptr].point2].y-wall[sec->wallptr].y);
r = 1.0/sqrt(fx*fx+fy*fy); fx *= r; fy *= r;
ft[2] = cosglobalang*fx + singlobalang*fy;
ft[3] = singlobalang*fx - cosglobalang*fy;
ft[0] = ((double)(globalposx-wall[sec->wallptr].x))*fx + ((double)(globalposy-wall[sec->wallptr].y))*fy;
ft[1] = ((double)(globalposy-wall[sec->wallptr].y))*fx - ((double)(globalposx-wall[sec->wallptr].x))*fy;
if (!(globalorientation&4)) globalorientation ^= 32; else globalorientation ^= 16;
}
gdx = 0;
gdy = gxyaspect;
if (!(globalorientation&2)) gdy /= (double)(sec->ceilingz-globalposz);
gdo = -ghoriz*gdy;
if (globalorientation&8) { ft[0] /= 8; ft[1] /= -8; ft[2] /= 2097152; ft[3] /= 2097152; }
else { ft[0] /= 16; ft[1] /= -16; ft[2] /= 4194304; ft[3] /= 4194304; }
gux = (double)ft[3]*((double)viewingrange)/-65536.0;
gvx = (double)ft[2]*((double)viewingrange)/-65536.0;
guy = (double)ft[0]*gdy; gvy = (double)ft[1]*gdy;
guo = (double)ft[0]*gdo; gvo = (double)ft[1]*gdo;
guo += (double)(ft[2]-gux)*ghalfx;
gvo -= (double)(ft[3]+gvx)*ghalfx;
//Texture flipping
if (globalorientation&4)
{
r = gux; gux = gvx; gvx = r;
r = guy; guy = gvy; gvy = r;
r = guo; guo = gvo; gvo = r;
}
if (globalorientation&16) { gux = -gux; guy = -guy; guo = -guo; }
if (globalorientation&32) { gvx = -gvx; gvy = -gvy; gvo = -gvo; }
//Texture panning
fx = (float)sec->ceilingxpanning*((float)(1<<(picsiz[globalpicnum]&15)))/256.0;
fy = (float)sec->ceilingypanning*((float)(1<<(picsiz[globalpicnum]>>4)))/256.0;
if ((globalorientation&(2+64)) == (2+64)) //Hack for panning for slopes w/ relative alignment
{
r = (float)sec->ceilingheinum / 4096.0; r = 1.0/sqrt(r*r+1);
if (!(globalorientation&4)) fy *= r; else fx *= r;
}
guy += gdy*fx; guo += gdo*fx;
gvy += gdy*fy; gvo += gdo*fy;
if (globalorientation&2) //slopes
{
px[0] = x0; py[0] = ryp0 + ghoriz;
px[1] = x1; py[1] = ryp1 + ghoriz;
//Pick some point guaranteed to be not collinear to the 1st two points
ox = nx0 + (ny1-ny0);
oy = ny0 + (nx0-nx1);
ox2 = (double)(oy-globalposy)*gcosang - (double)(ox-globalposx)*gsinang ;
oy2 = (double)(ox-globalposx)*gcosang2 + (double)(oy-globalposy)*gsinang2;
oy2 = 1.0/oy2;
px[2] = ghalfx*ox2*oy2 + ghalfx; oy2 *= gyxscale;
py[2] = oy2 + ghoriz;
for (i=0; i<3; i++)
{
dd[i] = px[i]*gdx + py[i]*gdy + gdo;
uu[i] = px[i]*gux + py[i]*guy + guo;
vv[i] = px[i]*gvx + py[i]*gvy + gvo;
}
py[0] = cy0;
py[1] = cy1;
py[2] = (getceilzofslope(sectnum,(int32_t)ox,(int32_t)oy)-globalposz)*oy2 + ghoriz;
ox = py[1]-py[2]; oy = py[2]-py[0]; oz = py[0]-py[1];
r = 1.0 / (ox*px[0] + oy*px[1] + oz*px[2]);
gdx = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r;
gux = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r;
gvx = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r;
ox = px[2]-px[1]; oy = px[0]-px[2]; oz = px[1]-px[0];
gdy = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r;
guy = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r;
gvy = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r;
gdo = dd[0] - px[0]*gdx - py[0]*gdy;
guo = uu[0] - px[0]*gux - py[0]*guy;
gvo = vv[0] - px[0]*gvx - py[0]*gvy;
if (globalorientation&64) //Hack for relative alignment on slopes
{
r = (float)sec->ceilingheinum / 4096.0;
r = sqrt(r*r+1);
if (!(globalorientation&4)) { gvx *= r; gvy *= r; gvo *= r; }
else { gux *= r; guy *= r; guo *= r; }
}
}
domostpolymethod = (globalorientation>>7)&3;
if (globalposz <= getceilzofslope(sectnum,globalposx,globalposy)) domostpolymethod = -1; //Back-face culling
#ifdef USE_OPENGL
if (!nofog)
{
fogcalc(sec->ceilingshade,sec->visibility,sec->ceilingpal);
bglFogf(GL_FOG_DENSITY,fogresult);
bglFogfv(GL_FOG_COLOR,fogcol);
}
#endif
pow2xsplit = 0; domost(x1,cy1,x0,cy0); //ceil
domostpolymethod = 0;
}
polymost_internal_nonparallaxed(nx0, ny0, nx1, ny1, ryp0, ryp1, x0, x1, cy0, cy1, 0, sectnum);
else if ((nextsectnum < 0) || (!(sector[nextsectnum].ceilingstat&1)))
{
#ifdef USE_OPENGL

View file

@ -10091,7 +10091,8 @@ void ExtCheckKeys(void)
if (PRESSED_KEYSC(F12)) //F12
{
screencapture("captxxxx.tga", keystatus[KEYSC_LSHIFT]|keystatus[KEYSC_RSHIFT]);
Bsprintf(tempbuf, "Mapster32 %s", ExtGetVer());
screencapture("captxxxx.tga", keystatus[KEYSC_LSHIFT]|keystatus[KEYSC_RSHIFT], tempbuf);
message("Saved screenshot %04d", capturecount-1);
}
}

View file

@ -545,8 +545,11 @@ void G_HandleSpecialKeys(void)
if (KB_UnBoundKeyPressed(sc_F12))
{
char titlebuf[256];
Bsprintf(titlebuf,HEAD2 " %s",s_buildRev);
KB_ClearKeyDown(sc_F12);
screencapture("duke0000.tga",0);
screencapture("duke0000.tga",0,titlebuf);
P_DoQuote(QUOTE_SCREEN_SAVED,g_player[myconnectindex].ps);
}

View file

@ -1084,7 +1084,7 @@ static int32_t osdcmd_screenshot(const osdfuncparm_t *parm)
{
UNREFERENCED_PARAMETER(parm);
// KB_ClearKeysDown();
screencapture("duke0000.tga",0);
screencapture("duke0000.tga",0,"EDuke32");
return OSDCMD_OK;
}
@ -1105,7 +1105,9 @@ static int32_t osdcmd_restorestate(const osdfuncparm_t *parm)
G_RestoreMapState(MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate);
return OSDCMD_OK;
}
*/
#ifdef DEBUGGINGAIDS
static int32_t osdcmd_inittimer(const osdfuncparm_t *parm)
{
int32_t j;
@ -1126,7 +1128,7 @@ static int32_t osdcmd_inittimer(const osdfuncparm_t *parm)
OSD_Printf("%s\n",parm->raw);
return OSDCMD_OK;
}
*/
#endif
static int32_t osdcmd_disconnect(const osdfuncparm_t *parm)
{
@ -1522,8 +1524,9 @@ int32_t registerosdcommands(void)
OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);
OSD_RegisterFunction("initgroupfile","initgroupfile <path>: adds a grp file into the game filesystem", osdcmd_initgroupfile);
// OSD_RegisterFunction("inittimer","debug", osdcmd_inittimer);
#ifdef DEBUGGINGAIDS
OSD_RegisterFunction("inittimer","debug", osdcmd_inittimer);
#endif
OSD_RegisterFunction("kick","kick <id>: kicks a multiplayer client. See listplayers.", osdcmd_kick);
OSD_RegisterFunction("kickban","kickban <id>: kicks a multiplayer client and prevents them from reconnecting. See listplayers.", osdcmd_kickban);