Patch from hunter_rus

git-svn-id: https://svn.eduke32.com/eduke32@723 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2008-05-10 01:29:37 +00:00
parent a56eb92f1c
commit 67e2466b0e
28 changed files with 324 additions and 226 deletions

View file

@ -16,6 +16,7 @@
SUPERBUILD ?= 1
POLYMOST ?= 1
POLYMER ?= 1
USE_OPENGL ?= 1
NOASM ?= 0
LINKED_GTK ?= 0
@ -88,8 +89,10 @@ ENGINEOBJS+= \
$(OBJ)/mmulti.$o \
$(OBJ)/osd.$o \
$(OBJ)/pragmas.$o \
$(OBJ)/scriptfile.$o \
$(OBJ)/polymer.$o
$(OBJ)/scriptfile.$o
ifeq (1,$(POLYMER))
ENGINEOBJS+= $(OBJ)/polymer.$o
endif
EDITOROBJS=$(OBJ)/build.$o \
$(OBJ)/config.$o

View file

@ -155,3 +155,10 @@ ifneq (0,$(LINKED_GTK))
BUILDCFLAGS+= -DLINKED_GTK
endif
ifneq (0,$(POLYMER))
ifneq (0,$(POLYMOST))
ifneq (0,$(USE_OPENGL))
BUILDCFLAGS+= -DPOLYMER
endif
endif
endif

View file

@ -481,9 +481,11 @@ _equation equation(int x1, int y1, int x2, int y2);
int sameside(_equation* eq, _point2d* p1, _point2d* p2);
int wallvisible(short wallnum);
#ifdef POLYMER
// polymer stuff for the game to provide it with the animatessprites ptr
typedef void (*animatespritesptr)(int, int, int, int);
EXTERN void polymer_setanimatesprites(animatespritesptr, int, int, int, int);
#endif
#define STATUS2DSIZ 144
void qsetmode640350(void);
@ -565,7 +567,7 @@ int md_undefinemodel(int modelid);
#define MAXPALCONV 200
void clearconv();
void setpalconv(int pal,int pal1,int pal2);
void getpalmap(int stage,int *pal1,int *pal2);
void getpalmap(int *stage,int *pal1,int *pal2);
int checkpalmaps(int pal);
void applypalmap(char *pic, char *palmap, int size, int pal);

View file

@ -3162,6 +3162,7 @@ void overheadeditor(void)
drawline16(0,searchy,8,searchy,15);
col = 15-((gridlock<<1)+gridlock);
if (joinsector[0] >= 0)col = 11;
drawline16(searchx,searchy-8,searchx,searchy-1,col);
drawline16(searchx+1,searchy-8,searchx+1,searchy-1,col);
drawline16(searchx,searchy+2,searchx,searchy+9,col);
@ -5587,6 +5588,7 @@ void overheadeditor(void)
printmessage16("Arrow must be inside a sector before entering 3D mode.");
}
CANCEL:
if (keystatus[1] > 0 && joinsector[0] >= 0){keystatus[1]=0;joinsector[0]=-1;}
if (keystatus[1] > 0)
{
keystatus[1] = 0;

View file

@ -27,9 +27,11 @@
# endif
# ifdef USE_OPENGL
# include "glbuild.h"
# ifdef POLYMER
# include "polymer.h"
# endif
#endif
#endif
#include <math.h>
@ -3188,7 +3190,7 @@ static void drawsprite(int snum)
# endif
return;
}
# ifdef USE_OPENGL
# ifdef POLYMER
if (rendmode == 4)
{
bglEnable(GL_ALPHA_TEST);
@ -4124,6 +4126,7 @@ static void drawmaskwall(short damaskwallcnt)
//============================================================================= //POLYMOST BEGINS
#ifdef POLYMOST
if (rendmode == 3) { polymost_drawmaskwall(damaskwallcnt); return; }
# ifdef POLYMER
if (rendmode == 4)
{
bglEnable(GL_ALPHA_TEST);
@ -4136,6 +4139,7 @@ static void drawmaskwall(short damaskwallcnt)
return;
}
#endif
#endif
//============================================================================= //POLYMOST ENDS
@ -4626,7 +4630,9 @@ static void dorotatesprite(int sx, int sy, int z, short a, short picnum, signed
//============================================================================= //POLYMOST BEGINS
#ifdef POLYMOST
if (rendmode >= 3) { polymost_dorotatesprite(sx,sy,z,a,picnum,dashade,dapalnum,dastat,cx1,cy1,cx2,cy2,uniqid); return; }
# ifdef POLYMER
if (rendmode == 4) { polymer_rotatesprite(sx,sy,z,a,picnum,dashade,dapalnum,dastat,cx1,cy1,cx2,cy2); return; }
#endif
#endif
//============================================================================= //POLYMOST ENDS
@ -5855,6 +5861,7 @@ void drawrooms(int daposx, int daposy, int daposz,
dmost[0] = shortptr2[0]-windowy1;
#ifdef POLYMOST
# ifdef POLYMER
if (rendmode == 4)
{
polymer_glinit();
@ -5863,6 +5870,7 @@ void drawrooms(int daposx, int daposy, int daposz,
gloy1 = 0;
return;
}
# endif
//============================================================================= //POLYMOST BEGINS
polymost_drawrooms();
@ -6127,7 +6135,7 @@ void drawmasks(void)
_equation maskeq, p1eq, p2eq;
_point2d dot, dot2, middle, pos, spr;
#ifdef USE_OPENGL
#ifdef POLYMER
if ((rendmode == 4) && 0)
{
polymer_drawmasks();
@ -6834,8 +6842,10 @@ int loadboard(char *filename, char fromwhere, int *daposx, int *daposy, int *dap
memset(spriteext, 0, sizeof(spriteexttype) * MAXSPRITES);
memset(spritesmooth, 0, sizeof(spritesmooth));
# ifdef POLYMER
if (rendmode == 4)
polymer_loadboard();
#endif
#endif
guniqhudid = 0;
@ -7768,8 +7778,10 @@ int setgamemode(char davidoption, int daxdim, int daydim, int dabpp)
polymost_glreset();
polymost_glinit();
}
# ifdef POLYMER
if (rendmode == 4)
polymer_glinit();
#endif
#endif
qsetmode = 200;
return(0);
@ -11863,8 +11875,13 @@ int setrendermode(int renderer)
else if (renderer > 4) renderer = 4;
}
# ifdef POLYMER
if (renderer == 4)
polymer_init();
# else
if (renderer == 4)
renderer = 3;
# endif
rendmode = renderer;
#endif

View file

@ -392,20 +392,15 @@ void setpalconv(int pal,int pal1,int pal2)
}
void getpalmap(int stage,int *pal1,int *pal2)
void getpalmap(int *i,int *pal1,int *pal2)
{
int i;
for (i=0;i<MAXPALCONV;i++)
if (palconv[i].pal==*pal2)
for (;*i<MAXPALCONV&&palconv[*i].pal1;(*i)++)
if (palconv[*i].pal==*pal2)
{
if (!stage)
{
*pal1=palconv[i].pal1;
*pal2=palconv[i].pal2;
*pal1=palconv[*i].pal1;
*pal2=palconv[*i].pal2;
return;
}
stage--;
}
}
int checkpalmaps(int pal)
@ -415,7 +410,7 @@ int checkpalmaps(int pal)
for (stage=0;stage<MAXPALCONV;stage++)
{
int pal1=0,pal2=pal;
getpalmap(stage,&pal1,&pal2);
getpalmap(&stage,&pal1,&pal2);
if (!pal)break;
if (pal1)val|=1<<(pal1-SPECPAL);
}
@ -435,6 +430,12 @@ void applypalmap(char *pic, char *palmap, int size, int pal)
pic[r]=((pic[r]*(255-a)+hictinting[pal].r*a)*palmap[r])/255/255;
pic[g]=((pic[g]*(255-a)+hictinting[pal].g*a)*palmap[g])/255/255;
pic[b]=((pic[b]*(255-a)+hictinting[pal].b*a)*palmap[b])/255/255;
/*
pic[r]=((255*(255-a)+hictinting[pal].r*a)*palmap[r])/255/255;
pic[g]=((255*(255-a)+hictinting[pal].g*a)*palmap[g])/255/255;
pic[b]=((255*(255-a)+hictinting[pal].b*a)*palmap[b])/255/255;
*/
if (glinfo.bgra)swapchar(&pic[r], &pic[b]);
r+=4;g+=4;b+=4;
}
@ -449,7 +450,7 @@ static void applypalmapSkin(char *pic, int sizx, int sizy, int pal)
{
int pal1=0,pal2=pal;
mdskinmap_t *sk;
getpalmap(stage,&pal1,&pal2);
getpalmap(&stage,&pal1,&pal2);
if (!pal1)return;
for (sk = modelhead->skinmap; sk; sk = sk->next)

View file

@ -228,10 +228,13 @@ static int _internal_osdfunc_vars(const osdfuncparm_t *parm)
if (osdrowscur!=-1)osdrowscur = osdrows;
return OSDCMD_OK;
}
} else
if (!Bstrcasecmp(parm->name, "logcutoff")) {
}
else
if (!Bstrcasecmp(parm->name, "logcutoff"))
{
if (showval) { OSD_Printf("logcutoff is %d\n", logcutoff); return OSDCMD_OK; }
else {
else
{
logcutoff = atoi(parm->parms[0]);
return OSDCMD_OK;
}

View file

@ -20,7 +20,8 @@ _prwall *prwalls[MAXWALLS];
GLfloat skybox[16];
GLfloat vertsprite[4 * 5] = {
GLfloat vertsprite[4 * 5] =
{
-0.5f, 0.0f, 0.0f,
0.0f, 1.0f,
0.5f, 0.0f, 0.0f,
@ -31,7 +32,8 @@ GLfloat vertsprite[4 * 5] = {
0.0f, 0.0f,
};
GLfloat horizsprite[4 * 5] = {
GLfloat horizsprite[4 * 5] =
{
-0.5f, 0.0f, -0.5f,
0.0f, 1.0f,
0.5f, 0.0f, -0.5f,
@ -1849,7 +1851,8 @@ static void polymer_buffertoplane(GLfloat* buffer, GLushort* indices, in
int i;
i = 0;
do {
do
{
vec1[0] = buffer[(INDICE(1)) + 0] - buffer[(INDICE(0)) + 0];
vec1[1] = buffer[(INDICE(1)) + 1] - buffer[(INDICE(0)) + 1];
vec1[2] = buffer[(INDICE(1)) + 2] - buffer[(INDICE(0)) + 2];

View file

@ -437,12 +437,7 @@ pthtyp * gltexcache(int dapicnum, int dapalnum, int dameth)
if (pth2->flags & 8) pth->flags |= 8; //hasalpha
pth->hicr = si;
pth->next = gltexcachead[j];
if (pth->palmap)
{
//_initprintf("Realloc #%d->#%d\n",pth2->palmap, pth->palmap);
pth->palmap=malloc(pth->size*4);
memcpy(pth->palmap, pth2->palmap, pth->size*4);
}
gltexcachead[j] = pth;
return(pth);
}
@ -1449,18 +1444,23 @@ failure:
return -1;
}
// --------------------------------------------------- JONOF'S COMPRESSED TEXTURE CACHE STUFF
static void applypalmapsT(char *pic, int sizx, int sizy, int pal)
static void applypalmapsT(char *pic, int sizx, int sizy, int dapic,int dapalnum, int dameth)
{
//_initprintf("%d\n",pal);
int stage;
pthtyp *pichead1=pichead;
for (stage=0;stage<MAXPALCONV;stage++)
{
int pal1=0,pal2=pal;
int pal1=0,pal2=dapalnum;
pthtyp *pth;
getpalmap(stage,&pal1,&pal2);
getpalmap(&stage,&pal1,&pal2);
if (!pal1)return;
for (pth=pichead; pth; pth=pth->next)
//_initprintf("Pal: %d\n",pal1);
if (hicfindsubst(dapic, pal1, 0))
gltexcache(dapic, pal1, dameth);
for (pth=pichead1; pth; pth=pth->next)
if (pth->palnum ==pal1&&pth->palmap)break;
if (!pth||pth->size!=sizx*sizy)continue;
@ -1549,7 +1549,7 @@ int gloadtile_hi(int dapic,int dapalnum, int facen, hicreplctyp *hicr, int damet
pic = (coltype *)calloc(xsiz,ysiz*sizeof(coltype)); if (!pic) { free(picfil); return 1; }
if (kprender(picfil,picfillen,(int)pic,xsiz*sizeof(coltype),xsiz,ysiz,0,0)) { free(picfil); free(pic); return -2; }
applypalmapsT((char *)pic,tsizx,tsizy,dapalnum);
applypalmapsT((char *)pic,tsizx,tsizy,dapic,dapalnum,dameth);
r=(glinfo.bgra)?hictinting[dapalnum].r:hictinting[dapalnum].b;
g=hictinting[dapalnum].g;
@ -1632,7 +1632,6 @@ int gloadtile_hi(int dapic,int dapalnum, int facen, hicreplctyp *hicr, int damet
memcpy(pth->palmap,pic,pth->size*4);
}
cachefil=0;
//_initprintf("#%d\n",pth->palmap);
}
fixtransparency(pic,tsizx,tsizy,xsiz,ysiz,dameth);
uploadtexture(doalloc,xsiz,ysiz,intexfmt,texfmt,pic,-1,tsizy,dameth);
@ -1806,12 +1805,6 @@ void drawpoly(double *dpx, double *dpy, int n, int method)
{
float hackscx, hackscy;
int pal1;
if (usehightile)
for (pal1=SPECPAL;pal1<=REDPAL;pal1++)
if (hicfindsubst(globalpicnum, pal1, 0))
gltexcache(globalpicnum, pal1, method&(~3));
if (skyclamphack) method |= 4;
pth = gltexcache(globalpicnum,globalpal,method&(~3));
@ -3789,7 +3782,10 @@ static void polymost_drawalls(int bunch)
yoffs=(i-tilesizy[globalpicnum])*(255./i);
if (!(nwal->cstat&4))
{
if (ypan>256-yoffs){ypan-=yoffs;initprintf("FL\n");}
if (ypan>256-yoffs)
{
ypan-=yoffs;
}
}
else
{
@ -5911,7 +5907,6 @@ void polymost_precache(int dapicnum, int dapalnum, int datype)
// basically this just means walls are repeating
// while sprites are clamped
int mid;
int pal1;
if (rendmode < 3) return;
@ -5919,9 +5914,7 @@ void polymost_precache(int dapicnum, int dapalnum, int datype)
//OSD_Printf("precached %d %d type %d\n", dapicnum, dapalnum, datype);
hicprecaching = 1;
for (pal1=SPECPAL;pal1<=REDPAL;pal1++)
if (hicfindsubst(globalpicnum, pal1, 0))
gltexcache(globalpicnum, pal1, (datype & 1) << 2);
gltexcache(dapicnum, dapalnum, (datype & 1) << 2);
hicprecaching = 0;

View file

@ -227,7 +227,8 @@ int initsystem(void)
linked->major, linked->minor, linked->patch);
if (SDL_VERSIONNUM(linked->major,linked->minor,linked->patch) < SDL_REQUIREDVERSION)
{ /*reject running under SDL versions older than what is stated in sdl_inc.h */
{
/*reject running under SDL versions older than what is stated in sdl_inc.h */
initprintf("You need at least v%d.%d.%d of SDL to run this game\n",SDL_MIN_X,SDL_MIN_Y,SDL_MIN_Z);
return -1;
}

View file

@ -47,6 +47,7 @@ int _buildargc = 0;
const char **_buildargv = NULL;
static char *argvbuf = NULL;
extern int app_main(int argc, const char *argv[]);
extern void app_crashhandler(void);
// Windows crud
static HINSTANCE hInstance = 0;
@ -250,6 +251,7 @@ static void SignalHandler(int signum)
{
case SIGSEGV:
printOSD("Fatal Signal caught: SIGSEGV. Bailing out.\n");
app_crashhandler();
uninitsystem();
if (stdout) fclose(stdout);
break;

View file

@ -7,6 +7,7 @@ ALROOT=AL
# Engine options
SUPERBUILD = 1
POLYMOST = 1
POLYMER = 1
USE_OPENGL = 1
NOASM = 0
LINKED_GTK = 0

View file

@ -6025,6 +6025,32 @@ int ExtInit(void)
return rv;
}
#ifdef RENDERTYPEWIN
void app_crashhandler(void)
{
if (levelname[0])
{
char *f;
fixspritesectors(); //Do this before saving!
updatesector(startposx,startposy,&startsectnum);
if (pathsearchmode) f = levelname;
else
{
// virtual filesystem mode can't save to directories so drop the file into
// the current directory
f = strrchr(levelname, '/');
if (!f) f = levelname; else f++;
}
ExtPreSaveMap();
saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
ExtSaveMap(f);
message("Board saved");
asksave = 0;
keystatus[0x1f] = 0;
}
}
#endif
void ExtUnInit(void)
{
int i;
@ -6234,11 +6260,20 @@ static void Keys2d3d(void)
{
if (levelname[0])
{
char *f;
fixspritesectors(); //Do this before saving!
updatesector(startposx,startposy,&startsectnum);
if (pathsearchmode) f = levelname;
else
{
// virtual filesystem mode can't save to directories so drop the file into
// the current directory
f = strrchr(levelname, '/');
if (!f) f = levelname; else f++;
}
ExtPreSaveMap();
saveboard(levelname,&startposx,&startposy,&startposz,&startang,&startsectnum);
ExtSaveMap(levelname);
saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
ExtSaveMap(f);
message("Board saved");
asksave = 0;
keystatus[0x1f] = 0;

View file

@ -641,7 +641,6 @@ int32 CONFIG_ReadSetup(void)
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping", &r_parallaxskyclamping);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning", &r_parallaxskypanning);
dummy = usemodels;
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "UseModels",&dummy);
usemodels = dummy != 0;

View file

@ -36,6 +36,9 @@ extern "C" {
#include "a.h"
#include "build.h"
#if defined(POLYMOST) && defined(USE_OPENGL)
# include "polymost.h"
#endif
#ifdef POLYMER
# include "polymer.h"
#endif
#include "cache1d.h"

View file

@ -4042,8 +4042,10 @@ void displayrooms(int snum,int smoothratio)
#ifdef SE40
se40code(s->x,s->y,s->z,ud.cameraang,s->yvel,smoothratio);
#endif
#ifdef POLYMER
if (rendmode == 4)
polymer_setanimatesprites(animatesprites, s->x, s->y, ud.cameraang, smoothratio);
#endif
drawrooms(s->x,s->y,s->z-(4<<8),ud.cameraang,s->yvel,s->sectnum);
animatesprites(s->x,s->y,ud.cameraang,smoothratio);
drawmasks();
@ -4216,8 +4218,10 @@ void displayrooms(int snum,int smoothratio)
gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7));
}
#ifdef POLYMER
if (rendmode == 4)
polymer_setanimatesprites(animatesprites, ud.camerax,ud.cameray,ud.cameraang,smoothratio);
#endif
drawrooms(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,ud.camerasect);
animatesprites(ud.camerax,ud.cameray,ud.cameraang,smoothratio);
drawmasks();
@ -10181,6 +10185,14 @@ void backtomenu(void)
else wm_setapptitle(HEAD);
}
#ifdef RENDERTYPEWIN
void app_crashhandler(void)
{
closedemowrite();
sendquit();
}
#endif
void app_main(int argc,const char **argv)
{
int i, j;
@ -11053,7 +11065,7 @@ RECHECK:
ud.recstat = 2;
which_demo++;
if (which_demo == 10) which_demo = 1;
if (enterlevel(MODE_DEMO)) return 1;
if (enterlevel(MODE_DEMO)) ud.recstat = foundemo = 0;
}
if (foundemo == 0 || in_menu || KB_KeyWaiting() || numplayers > 1)
@ -11924,8 +11936,8 @@ static int domovethings(void)
pan3dsound();
}
#ifdef POLYMER
//polymer invalidate
#if defined(POLYMOST) && defined(USE_OPENGL)
updatesectors = 1;
#endif

View file

@ -450,6 +450,7 @@ static const char *keyw[] =
"resizearray", // 318
"writearraytofile", // 319
"readarrayfromfile", // 320
"starttrackvar", // 321
"<null>"
};
@ -3287,6 +3288,7 @@ static int parsecommand(void)
case CON_SAVEGAMEVAR:
case CON_READGAMEVAR:
case CON_USERQUOTE:
case CON_STARTTRACKVAR:
transvar();
return 0;

View file

@ -810,4 +810,5 @@ enum keywords
CON_RESIZEARRAY, // 318
CON_WRITEARRAYTOFILE, // 319
CON_READARRAYFROMFILE, // 320
CON_STARTTRACKVAR, // 321
};

View file

@ -5597,8 +5597,10 @@ static int parse(void)
gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7));
}
#ifdef POLYMER
if (rendmode == 4)
polymer_setanimatesprites(animatesprites, x,y,a,smoothratio);
#endif
drawrooms(x,y,z,a,horiz,sect);
display_mirror = 2;
animatesprites(x,y,a,smoothratio);
@ -7027,6 +7029,13 @@ static int parse(void)
playmusic(&map[(unsigned char)music_select].musicfn[0],music_select);
break;
case CON_STARTTRACKVAR:
insptr++;
music_select=(ud.volume_number*MAXLEVELS)+(GetGameVarID(*(insptr++), g_i, g_p));
if (map[(unsigned char)music_select].musicfn != NULL)
playmusic(&map[(unsigned char)music_select].musicfn[0],music_select);
break;
case CON_GETTEXTURECEILING:
insptr++;
SetGameVarID(g_iTextureID, sector[g_sp->sectnum].ceilingpicnum, g_i, g_p);

View file

@ -694,12 +694,14 @@ cvar[] =
#if defined(POLYMOST) && defined(USE_OPENGL)
{ "r_anamorphic", "r_anamorphic: enable/disable widescreen mode", (void*)&glwidescreen, CVAR_BOOL, 0, 0, 1 },
{ "r_projectionhack", "r_projectionhack: enable/disable projection hack", (void*)&glprojectionhacks, CVAR_BOOL, 0, 0, 1 },
# ifdef POLYMER
// polymer cvars
{ "pr_occlusionculling", "pr_occlusionculling: insert description that noone will ever read", (void*)&pr_occlusionculling, CVAR_INT, 0, 0, 512 },
{ "pr_fov", "pr_fov: sets the field of vision in build angle", (void*)&pr_fov, CVAR_INT, 0, 0, 1023},
{ "pr_billboardingmode", "pr_billboardingmode: face sprite display method. 0: classic mode; 1: polymost mode", (void*)&pr_billboardingmode, CVAR_INT, 0, 0, 1 },
{ "pr_verbosity", "pr_verbosity: verbosity level of the polymer renderer", (void*)&pr_verbosity, CVAR_INT, 0, 0, 3 },
{ "pr_wireframe", "pr_wireframe: toggles wireframe mode", (void*)&pr_wireframe, CVAR_INT, 0, 0, 1 },
#endif
#endif
{ "r_precache", "r_precache: enable/disable the pre-level caching routine", (void*)&ud.config.useprecache, CVAR_BOOL, 0, 0, 1 },