shading changes and fixes for a few crashes

git-svn-id: https://svn.eduke32.com/eduke32@1657 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2010-06-07 09:03:16 +00:00
parent d76817a361
commit 4c3c64286a
25 changed files with 302 additions and 140 deletions

View file

@ -45,11 +45,32 @@ typedef struct
char *name;
char *helpstr;
void *var;
int32_t type; // see cvartype_t
int32_t type; // see cvartype_t
int32_t min;
int32_t max; // for string, is the length
int32_t max; // for string, is the length
} cvar_t;
typedef struct
{
char *name;
char *helpstr;
void *var;
int32_t type; // see cvartype_t
int32_t min;
int32_t max; // for string, is the length
// everything before this point needs to match cvar_t
// default value for cvar, assigned when var is registered
union
{
int32_t i;
uint32_t uint;
float f;
double d;
} dval;
} osdcvar_t;
enum osdflags_t
{
OSD_INITIALIZED = 0x00000001,

View file

@ -124,12 +124,13 @@ extern float fogresult, fogcol[4], fogtable[4*MAXPALOOKUPS];
static inline void fogcalc(const int32_t shade, const int32_t vis, const int32_t pal)
{
float f = shade * 1.75f;
float f = (shade < 0) ? shade * 3.5f :
shade * .66f;
if (vis > 239) f = (float)(gvisibility*((vis-240+f)/(klabs(vis-256))));
else f = (float)(gvisibility*(vis+16+f));
f = (vis > 239) ? (float)(gvisibility*((vis-240+f)/(klabs(vis-256)))) :
(float)(gvisibility*(vis+16+f));
fogresult = clamp(f, 0.01f, 100.f);
fogresult = clamp(f, 0.0f, 100.f);
Bmemcpy(fogcol, &fogtable[pal<<2], sizeof(fogcol));
}

View file

@ -429,7 +429,7 @@ int32_t app_main(int32_t argc, const char **argv)
inittimer(TIMERINTSPERSECOND);
installusertimercallback(keytimerstuff);
loadpics("tiles000.art",1048576*16);
loadpics("tiles000.art", 1048576*16);
loadnames();
Bstrcpy(kensig,"Uses BUILD technology by Ken Silverman");

View file

@ -225,7 +225,7 @@ void agecache(void)
while(mutex_lock(&cachemutex));
for (; cnt>=0; cnt--)
{
if ((((*cac[agecount].lock)-2)&255) < 198)
if (cac[agecount].lock && (((*cac[agecount].lock)-2)&255) < 198)
(*cac[agecount].lock)--;
agecount--;

View file

@ -139,7 +139,7 @@ int32_t loadsetup(const char *fn)
if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; }
if (readconfig(fp, "bpp", val, VL) > 0) bppgame = Batoi(val);
if (readconfig(fp, "vsync", val, VL) > 0) vsync = Batoi(val)?1:0;
if (readconfig(fp, "editorgridextent", val, VL) > 0) editorgridextent = max(min(524288,Batoi(val)),65536);
if (readconfig(fp, "editorgridextent", val, VL) > 0) editorgridextent = max(min(262144,Batoi(val)),32768);
if (readconfig(fp, "grid", val, VL) > 0)
{
grid = Batoi(val);

View file

@ -1245,7 +1245,7 @@ static int32_t owallmost(int16_t *mostbuf, int32_t w, int32_t z)
//
// wallmost (internal)
//
int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dastat)
static int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dastat)
{
int32_t bad, i, j, t, y, z, inty, intz, xcross, yinc, fw;
int32_t x1, y1, z1, x2, y2, z2, xv, yv, dx, dy, dasqr, oz1, oz2;
@ -3074,6 +3074,8 @@ static void drawsprite(int32_t snum)
spritenum = tspr->owner;
cstat = tspr->cstat;
if (tilenum < 0 || tilenum >= MAXSPRITES) return;
#ifdef SUPERBUILD
if ((cstat&48)==48) vtilenum = tilenum; // if the game wants voxels, it gets voxels
else if ((cstat&48)!=48 && (usevoxels) && (tiletovox[tilenum] != -1)

View file

@ -54,7 +54,7 @@ extern int16_t numscans, numhits, numbunches;
extern palette_t palookupfog[MAXPALOOKUPS];
#endif
int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dastat);
// int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dastat);
int32_t wallfront(int32_t l1, int32_t l2);
int32_t animateoffs(int16_t tilenum, int16_t fakevar);

View file

@ -1649,7 +1649,8 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
{
while (curbits < 16) //Getbits
{
ch = *kfileptr++; if (ch == 255) kfileptr++;
ch = *kfileptr++;
if (ch == 255) kfileptr++;
num = (num<<8)+((int32_t)ch); curbits += 8;
}
i = ((num>>(curbits-10))&1023);

View file

@ -120,7 +120,7 @@ static void (*_drawosdcursor)(int32_t, int32_t, int32_t, int32_t) = _internal_dr
static int32_t (*_getcolumnwidth)(int32_t) = _internal_getcolumnwidth;
static int32_t (*_getrowheight)(int32_t) = _internal_getrowheight;
static cvar_t *cvars = NULL;
static osdcvar_t *cvars = NULL;
static uint32_t osdnumcvars = 0;
static hashtable_t h_cvars = { MAXSYMBOLS<<1, NULL };
@ -164,13 +164,59 @@ int32_t OSD_RegisterCvar(const cvar_t *cvar)
}
}
cvars = Brealloc(cvars, (osdnumcvars + 1) * sizeof(cvar_t));
cvars = (osdcvar_t *)Brealloc(cvars, (osdnumcvars + 1) * sizeof(osdcvar_t));
hash_add(&h_cvars, cvar->name, osdnumcvars);
switch (cvar->type & (CVAR_BOOL|CVAR_INT|CVAR_UINT|CVAR_FLOAT|CVAR_DOUBLE))
{
case CVAR_BOOL:
case CVAR_INT:
cvars[osdnumcvars].dval.i = *(int32_t *)cvar->var;
break;
case CVAR_UINT:
cvars[osdnumcvars].dval.uint = *(uint32_t *)cvar->var;
break;
case CVAR_FLOAT:
cvars[osdnumcvars].dval.f = *(float *)cvar->var;
break;
case CVAR_DOUBLE:
cvars[osdnumcvars].dval.d = *(double *)cvar->var;
break;
}
Bmemcpy(&cvars[osdnumcvars++], cvar, sizeof(cvar_t));
return 0;
}
static int32_t OSD_CvarModified(const osdcvar_t *cvar)
{
if ((osdflags & OSD_INITIALIZED) == 0)
return 0;
if (!cvar->var)
{
OSD_Printf("OSD_CvarModified(): null cvar?!\n");
return 0;
}
switch (cvar->type & (CVAR_BOOL|CVAR_INT|CVAR_UINT|CVAR_FLOAT|CVAR_DOUBLE))
{
case CVAR_BOOL:
case CVAR_INT:
return (cvar->dval.i != *(int32_t *)cvar->var);
case CVAR_UINT:
return (cvar->dval.uint != *(uint32_t *)cvar->var);
case CVAR_FLOAT:
return (cvar->dval.f != *(float *)cvar->var);
case CVAR_DOUBLE:
return (cvar->dval.d != *(double *)cvar->var);
default:
return 0;
}
}
// color code format is as follows:
// ^## sets a color, where ## is the palette number
// ^S# sets a shade, range is 0-7 equiv to shades 0-14
@ -199,9 +245,9 @@ const char * OSD_StripColors(char *out, const char *in)
in += 2;
continue;
}
*(out++) = *in;
*(out++) = *(in++);
}
while (*(++in));
while (*in);
*out = '\0';
return (ptr);
@ -527,7 +573,15 @@ static int32_t _internal_osdfunc_listsymbols(const osdfuncparm_t *parm)
{
if (i->func != OSD_UNALIASED)
{
OSD_Printf("%-*s",maxwidth,i->name);
int32_t j = hash_find(&h_cvars, i->name);
if (j != -1 && OSD_CvarModified(&cvars[j]))
{
OSD_Printf(OSDTEXT_RED "*");
OSD_Printf("%-*s",maxwidth-1,i->name);
}
else OSD_Printf("%-*s",maxwidth,i->name);
x += maxwidth;
count++;
}
@ -634,6 +688,28 @@ static int32_t osdcmd_cvar_set_osd(const osdfuncparm_t *parm)
return r;
}
static int32_t _internal_osdfunc_toggle(const osdfuncparm_t *parm)
{
int32_t i;
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
i = hash_find(&h_cvars, parm->parms[0]);
if (i == -1)
for (i = osdnumcvars-1; i >= 0; i--)
if (!Bstrcasecmp(parm->parms[0], cvars[i].name)) break;
if (i == -1 || (cvars[i].type & CVAR_BOOL) != CVAR_BOOL)
{
OSD_Printf("Bad cvar name or cvar not boolean\n");
return OSDCMD_OK;
}
*(int32_t *)cvars[i].var = 1 - *(int32_t *)cvars[i].var;
return OSDCMD_OK;
}
//
// OSD_Init() -- Initializes the on-screen display
//
@ -681,6 +757,7 @@ void OSD_Init(void)
OSD_RegisterFunction("help","help: displays help for the specified cvar or command; \"listsymbols\" to show all commands",_internal_osdfunc_help);
OSD_RegisterFunction("history","history: displays the console command history",_internal_osdfunc_history);
OSD_RegisterFunction("listsymbols","listsymbols: lists all registered functions, cvars and aliases",_internal_osdfunc_listsymbols);
OSD_RegisterFunction("toggle","toggle: toggles the value of a boolean cvar",_internal_osdfunc_toggle);
OSD_RegisterFunction("unalias","unalias: removes a command alias",_internal_osdfunc_unalias);
atexit(OSD_Cleanup);
@ -2006,7 +2083,7 @@ void OSD_WriteCvars(FILE *fp)
for (i=0; i<osdnumcvars; i++)
{
if (!(cvars[i].type & CVAR_NOSAVE))
if (!(cvars[i].type & CVAR_NOSAVE) && OSD_CvarModified(&cvars[i]))
switch (cvars[i].type&(CVAR_FLOAT|CVAR_DOUBLE|CVAR_INT|CVAR_UINT|CVAR_BOOL|CVAR_STRING))
{
case CVAR_FLOAT:

View file

@ -892,7 +892,8 @@ void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t da
polymersearching = FALSE;
}
getzsofslope(dacursectnum, daposx, daposy, &cursectceilz, &cursectflorz);
if (dacursectnum > -1 && dacursectnum < numsectors)
getzsofslope(dacursectnum, daposx, daposy, &cursectceilz, &cursectflorz);
// external view (editor)
if ((dacursectnum < 0) || (dacursectnum >= numsectors) ||
@ -3467,7 +3468,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
color = mdspritematerial.diffusemodulation;
color[0] = color[1] = color[2] =
((float)(numpalookups-min(max((tspr->shade*shadescale)+m->shadeoff,0),numpalookups)))/((float)numpalookups) * 0xFF;
((float)(numpalookups-min(max((tspr->shade * shadescale)+m->shadeoff,0),numpalookups)))/((float)numpalookups) * 0xFF;
if (!(hictinting[tspr->pal].f&4))
{
@ -3819,7 +3820,7 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
material->diffusemodulation[0] =
material->diffusemodulation[1] =
material->diffusemodulation[2] =
((float)(numpalookups-min(max(shade*shadescale,0),numpalookups)))/((float)numpalookups) * 0xFF;
((float)(numpalookups-min(max((shade * shadescale),0),numpalookups)))/((float)numpalookups) * 0xFF;
if (pth->flags & 2)
{

View file

@ -109,7 +109,7 @@ static double dxb1[MAXWALLSB], dxb2[MAXWALLSB];
#define LINTERPSIZ 4 //log2 of interpolation size. 4:pretty fast&acceptable quality, 0:best quality/slow!
#define DEPTHDEBUG 0 //1:render distance instead of texture, for debugging only!, 0:default
float shadescale = 1.0f;
float shadescale = 1.3f;
double gyxscale, gxyaspect, gviewxrange, ghalfx, grhalfxdown10, grhalfxdown10x, ghoriz;
double gcosang, gsinang, gcosang2, gsinang2;
@ -776,19 +776,21 @@ void polymost_glinit()
memcachesize = filelength(cachefilehandle);
if (memcachesize > 0)
{
memcachedata = (uint8_t *)Brealloc(memcachedata, memcachesize);
if (!memcachedata)
{
initprintf("Failed allocating %d bytes for memcache\n", memcachesize);
memcachesize = -1;
}
if (!memcachedata)
{
initprintf("Failed allocating %d bytes for memcache\n", memcachesize);
memcachesize = -1;
}
if (memcachesize > 0 && Bread(cachefilehandle, memcachedata, memcachesize) != memcachesize)
{
initprintf("Failed reading texcache into memcache!\n");
Bfree(memcachedata);
memcachesize = -1;
if (Bread(cachefilehandle, memcachedata, memcachesize) != memcachesize)
{
initprintf("Failed reading texcache into memcache!\n");
Bfree(memcachedata);
memcachesize = -1;
}
}
i = 0;
@ -2144,7 +2146,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
{
float pc[4];
f = ((float)(numpalookups-min(max(globalshade * shadescale,0),numpalookups)))/((float)numpalookups);
f = ((float)(numpalookups-min(max((globalshade * shadescale),0),numpalookups)))/((float)numpalookups);
pc[0] = pc[1] = pc[2] = f;
switch (method&3)
{
@ -2423,7 +2425,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
nguo = uu[0] - ox*ngux - oy*nguy;
ngvo = vv[0] - ox*ngvx - oy*ngvy;
}
palptr = &palookup[globalpal][min(max(globalshade,0),numpalookups-1)<<8]; //<-need to make shade not static!
palptr = &palookup[globalpal][min(max((int32_t)(globalshade * shadescale),0),numpalookups-1)<<8]; //<-need to make shade not static!
tsizxm1 = tsizx-1; xmodnice = (!(tsizxm1&tsizx));
tsizym1 = tsizy-1; ymulnice = (!(tsizym1&tsizy));
@ -2434,7 +2436,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
}
else
{
dacol = palookup[0][(int32_t)(*(char *)(waloff[globalpicnum]))+(min(max(globalshade,0),numpalookups-1)<<8)];
dacol = palookup[0][(int32_t)(*(char *)(waloff[globalpicnum]))+(min(max((int32_t)(globalshade * shadescale),0),numpalookups-1)<<8)];
}
if (grhalfxdown10x < 0) //Hack for mirrors
@ -4346,74 +4348,78 @@ void polymost_drawrooms()
hitallsprites = 1;
hitscan((const vec3_t *)&vect,globalcursectnum, //Start position
vx>>12,vy>>12,vz>>8,&hitinfo,0xffff0030);
getzsofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz);
hitallsprites = 0;
vx>>12,vy>>12,vz>>8,&hitinfo,0xffff0030);
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.hitsect != -1) // if hitsect is -1, hitscan overflowed somewhere
{
searchbottomwall = searchwall = hitinfo.hitwall; searchstat = 0;
if (wall[hitinfo.hitwall].nextwall >= 0)
getzsofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz);
hitallsprites = 0;
searchsector = hitinfo.hitsect;
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;
if (wall[hitinfo.hitwall].nextwall >= 0)
{
int32_t cz, fz;
getzsofslope(wall[hitinfo.hitwall].nextsector,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz);
if (hitinfo.pos.z > fz)
{
if (wall[hitinfo.hitwall].cstat&2) //'2' bottoms of walls
searchbottomwall = wall[hitinfo.hitwall].nextwall;
}
else 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
{
int32_t cz, fz;
getzsofslope(wall[hitinfo.hitwall].nextsector,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz);
if (hitinfo.pos.z > fz)
{
if (wall[hitinfo.hitwall].cstat&2) //'2' bottoms of walls
searchbottomwall = wall[hitinfo.hitwall].nextwall;
}
else if ((hitinfo.pos.z > cz) && (wall[hitinfo.hitwall].cstat&(16+32))) //masking or 1-way
searchstat = 4;
getzsofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz);
if ((hitinfo.pos.z<<1) < cz+fz) searchstat = 1; else searchstat = 2;
//if (vz < 0) searchstat = 1; else searchstat = 2; //Won't work for slopes :/
}
}
else if (hitinfo.hitsprite >= 0) { searchwall = hitinfo.hitsprite; searchstat = 3; }
else
{
int32_t cz, fz;
getzsofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz);
if ((hitinfo.pos.z<<1) < cz+fz) searchstat = 1; else searchstat = 2;
//if (vz < 0) searchstat = 1; else searchstat = 2; //Won't work for slopes :/
}
if ((searchstat==1 || searchstat==2) && searchsector>=0)
{
int32_t scrv[2] = {(vx>>12), (vy>>12)};
int32_t scrv_r[2] = {scrv[1], -scrv[0]};
walltype *wal = &wall[sector[searchsector].wallptr];
int32_t wdistsq, bestwdistsq=0x7fffffff;
int16_t k, bestk=-1;
for (k=0; k<sector[searchsector].wallnum; k++)
if ((searchstat==1 || searchstat==2) && searchsector>=0)
{
int32_t w1[2] = {wal[k].x, wal[k].y};
int32_t w2[2] = {wall[wal[k].point2].x, wall[wal[k].point2].y};
int32_t w21[2] = {w1[0]-w2[0], w1[1]-w2[1]};
int32_t pw1[2] = {w1[0]-hitinfo.pos.x, w1[1]-hitinfo.pos.y};
int32_t pw2[2] = {w2[0]-hitinfo.pos.x, w2[1]-hitinfo.pos.y};
float w1d = (float)(scrv_r[0]*pw1[0] + scrv_r[1]*pw1[1]);
float w2d = (float)(scrv_r[0]*pw2[0] + scrv_r[1]*pw2[1]);
int32_t ptonline[2], scrp[2];
int32_t scrv[2] = {(vx>>12), (vy>>12)};
int32_t scrv_r[2] = {scrv[1], -scrv[0]};
walltype *wal = &wall[sector[searchsector].wallptr];
int32_t wdistsq, bestwdistsq=0x7fffffff;
int16_t k, bestk=-1;
w2d = -w2d;
if ((w1d==0 && w2d==0) || (w1d<0 || w2d<0))
continue;
ptonline[0] = (int32_t)(w2[0]+(w2d/(w1d+w2d))*w21[0]);
ptonline[1] = (int32_t)(w2[1]+(w2d/(w1d+w2d))*w21[1]);
scrp[0] = ptonline[0]-vect.x;
scrp[1] = ptonline[1]-vect.y;
if (scrv[0]*scrp[0] + scrv[1]*scrp[1] <= 0)
continue;
wdistsq = scrp[0]*scrp[0] + scrp[1]*scrp[1];
if (wdistsq < bestwdistsq)
for (k=0; k<sector[searchsector].wallnum; k++)
{
bestk = k;
bestwdistsq = wdistsq;
}
}
int32_t w1[2] = {wal[k].x, wal[k].y};
int32_t w2[2] = {wall[wal[k].point2].x, wall[wal[k].point2].y};
int32_t w21[2] = {w1[0]-w2[0], w1[1]-w2[1]};
int32_t pw1[2] = {w1[0]-hitinfo.pos.x, w1[1]-hitinfo.pos.y};
int32_t pw2[2] = {w2[0]-hitinfo.pos.x, w2[1]-hitinfo.pos.y};
float w1d = (float)(scrv_r[0]*pw1[0] + scrv_r[1]*pw1[1]);
float w2d = (float)(scrv_r[0]*pw2[0] + scrv_r[1]*pw2[1]);
int32_t ptonline[2], scrp[2];
if (bestk >= 0)
searchwall = sector[searchsector].wallptr + bestk;
w2d = -w2d;
if ((w1d==0 && w2d==0) || (w1d<0 || w2d<0))
continue;
ptonline[0] = (int32_t)(w2[0]+(w2d/(w1d+w2d))*w21[0]);
ptonline[1] = (int32_t)(w2[1]+(w2d/(w1d+w2d))*w21[1]);
scrp[0] = ptonline[0]-vect.x;
scrp[1] = ptonline[1]-vect.y;
if (scrv[0]*scrp[0] + scrv[1]*scrp[1] <= 0)
continue;
wdistsq = scrp[0]*scrp[0] + scrp[1]*scrp[1];
if (wdistsq < bestwdistsq)
{
bestk = k;
bestwdistsq = wdistsq;
}
}
if (bestk >= 0)
searchwall = sector[searchsector].wallptr + bestk;
}
}
searchit = 0;
}
@ -4710,7 +4716,7 @@ void polymost_drawsprite(int32_t snum)
int32_t oldsizx, oldsizy;
int32_t tsizx, tsizy;
tspr = tspriteptr[snum];
if (tspr->owner < 0 || tspr->picnum < 0) return;
if (tspr->owner < 0 || tspr->picnum < 0 || tspr->picnum >= MAXTILES) return;
globalpicnum = tspr->picnum;
globalshade = tspr->shade;
@ -5681,7 +5687,7 @@ void polymost_fillpolygon(int32_t npoints)
pth = gltexcache(globalpicnum,globalpal,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),numpalookups)))/((float)numpalookups);
switch ((globalorientation>>7)&3)
{
case 0:

View file

@ -176,7 +176,7 @@ BOOL RI_CaptureInput(BOOL grab, HWND target)
raw[1].usUsagePage = 0x01;
raw[1].usUsage = 0x06;
raw[1].dwFlags = RIDEV_NOLEGACY;
raw[1].dwFlags = 0;
raw[1].hwndTarget = target;
mousegrab = grab;

View file

@ -13,6 +13,10 @@
#endif
#include <math.h>
#ifdef _MSC_VER
#include <crtdbg.h>
#endif
#include "dxdidf.h" // comment this out if c_dfDI* is being reported as multiply defined
#include <stdlib.h>
#include <signal.h>
@ -306,6 +310,10 @@ int32_t WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, in
hInstance = hInst;
#ifdef _MSC_VER
_CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF);
#endif
if (!CheckWinVersion() || hPrevInst)
{
MessageBox(0, "This application requires Windows XP or better to run.",

View file

@ -150,9 +150,6 @@
<ClInclude Include="build\include\msvc\stdint.h">
<Filter>build\headers\MSVC</Filter>
</ClInclude>
<ClInclude Include="build\src\engine_priv.h">
<Filter>build\source</Filter>
</ClInclude>
<ClInclude Include="source\_functio.h">
<Filter>eduke32\headers</Filter>
</ClInclude>
@ -318,6 +315,9 @@
<ClInclude Include="build\include\rawinput.h">
<Filter>build\headers</Filter>
</ClInclude>
<ClInclude Include="build\src\engine_priv.h">
<Filter>build\headers</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="build\src\a-c.c">

View file

@ -2840,13 +2840,10 @@ static int32_t m32gettile(int32_t idInitialTile)
idle_waitevent_timeout(500);
// SDL seems to miss mousewheel events when rotated slowly.
// These kludgy things seem to make it better, but I'm not sure.
idle();
idle();
if (handleevents())
quitevent = 0;
getmousevalues(&mousedx,&mousedy,&bstatus);
searchx += mousedx;
searchy += mousedy;
@ -3988,7 +3985,7 @@ static void Keys3d(void)
drawtileinfo("Clipboard",3,124,temppicnum,tempshade,temppal,tempcstat,templotag,temphitag,tempextra);
}// end if usedcount
// if (infobox&1)
if (searchsector > -1 && searchsector < numsectors)
{
char lines[8][64];
int32_t dist, height1=0,height2=0,height3=0, num=0;

View file

@ -198,7 +198,7 @@ void CONFIG_SetDefaults(void)
ud.config.AmbienceToggle = 1;
ud.config.AutoAim = 1;
ud.config.FXDevice = 0;
ud.config.FXVolume = 220;
ud.config.FXVolume = 225;
#if defined(_WIN32)
ud.config.MixRate = 44100;
#else
@ -208,7 +208,7 @@ void CONFIG_SetDefaults(void)
ud.config.MouseDeadZone = 0;
ud.config.MusicDevice = 0;
ud.config.MusicToggle = 1;
ud.config.MusicVolume = 200;
ud.config.MusicVolume = 195;
g_myAimMode = g_player[0].ps->aim_mode = 1;
ud.config.NumBits = 16;
ud.config.NumChannels = 2;
@ -1017,7 +1017,7 @@ int32_t CONFIG_GetMapBestTime(char *mapname)
strcpy(m, mapname);
p = strrchr(m, '/');
if (!p) p = strrchr(m, '\\');
if (p) strcpy(m, p);
if (p) Bmemmove(m, p, Bstrlen(p)+1);//strcpy(m, p);
for (p=m; *p; p++) *p = tolower(*p);
// cheap hack because SCRIPT_GetNumber doesn't like the slashes

View file

@ -9495,7 +9495,7 @@ static void G_ShowParameterHelp(void)
"-l#\t\tWarp to level #, see -v\n"
"-map [file.map]\tLoads a map\n"
"-m\t\tDisable monsters\n"
"-nam/-ww2gi\tRun in NAM or WW2GI-compatible mode\n"
"-nam\t\tRun in NAM/NAPALM compatibility mode\n"
"-r\t\tRecord demo\n"
"-s#\t\tSet skill level (1-4)\n"
"-server\t\tStart a multiplayer game for other players to join\n"
@ -9508,6 +9508,7 @@ static void G_ShowParameterHelp(void)
#endif
"-u#########\tUser's favorite weapon order (default: 3425689071)\n"
"-v#\t\tWarp to volume #, see -l\n"
"-ww2gi\t\tRun in WW2GI compatibility mode\n"
"-x[game.con]\tLoad custom CON script\n"
"-#\t\tLoad and run a game from slot # (0-9)\n"
// "\n-?/--help\tDisplay this help message and exit\n"
@ -9527,17 +9528,14 @@ static void G_ShowDebugHelp(void)
"\n"
"-a\t\tUse fake player AI (fake multiplayer only)\n"
"-cachesize #\tSets cache size, in Kb\n"
"-fNUM\t\tSend fewer packets in multiplayer (1, 2, 4) (deprecated)\n"
"-game_dir [dir]\tDuke3d_w32 compatibility option, see -j\n"
"-gamegrp \tSelects which file to use as main grp\n"
"-i#\t\tUse networking mode (1/0)\n"
"-name [name]\tPlayer name in multiplay\n"
"-nD\t\tDump default gamevars to gamevars.txt\n"
"-noautoload\tDisable loading content from autoload dir\n"
"-nologo\t\tSkip the logo anim\n"
"-ns/-nm\t\tDisable sound or music\n"
"-q#\t\tFake multiplayer with # (2-8) players\n"
"-w\t\tShow coordinates\n"
"-z#/-condebug\tEnable line-by-line CON compile debugging at level #\n"
;
#if defined RENDERTYPEWIN
@ -11121,9 +11119,8 @@ void app_main(int32_t argc,const char **argv)
getcwd(g_rootDir,BMAX_PATH);
strcat(g_rootDir,"/");
#endif
OSD_SetLogFile("eduke32.log");
OSD_SetParameters(0,0, 0,12, 2,12);
OSD_SetLogFile("eduke32.log");
OSD_SetFunctions(
GAME_drawosdchar,
GAME_drawosdstr,

View file

@ -3866,8 +3866,8 @@ nullquote:
if (asize > 0)
{
OSD_Printf(OSDTEXT_GREEN "CON_RESIZEARRAY: resizing array %s from %d to %d\n",
aGameArrays[j].szLabel, aGameArrays[j].size, asize / sizeof(int32_t));
/*OSD_Printf(OSDTEXT_GREEN "CON_RESIZEARRAY: resizing array %s from %d to %d\n",
aGameArrays[j].szLabel, aGameArrays[j].size, asize / sizeof(int32_t));*/
aGameArrays[j].plValues=Brealloc(aGameArrays[j].plValues, asize);
aGameArrays[j].size = asize / sizeof(int32_t);
kread(fil, aGameArrays[j].plValues, asize);
@ -3911,7 +3911,7 @@ nullquote:
if (asize > 0)
{
OSD_Printf(OSDTEXT_GREEN "CON_RESIZEARRAY: resizing array %s from %d to %d\n", aGameArrays[j].szLabel, aGameArrays[j].size, asize);
/*OSD_Printf(OSDTEXT_GREEN "CON_RESIZEARRAY: resizing array %s from %d to %d\n", aGameArrays[j].szLabel, aGameArrays[j].size, asize);*/
aGameArrays[j].plValues=Brealloc(aGameArrays[j].plValues, sizeof(int32_t) * asize);
aGameArrays[j].size = asize;
}

View file

@ -43,11 +43,15 @@ static void Gv_Free(void) /* called from Gv_ReadSave() and Gv_ResetVars() */
Bfree(aGameVars[i].val.plValues);
aGameVars[i].val.plValues=NULL;
}
aGameVars[i].dwFlags |= GAMEVAR_RESET;
if (i >= MAXGAMEARRAYS)
continue;
if (aGameArrays[i].plValues)
Bfree(aGameArrays[i].plValues);
aGameArrays[i].plValues=NULL;
aGameArrays[i].bReset=1;
}
@ -680,17 +684,17 @@ void __fastcall Gv_SetVar(register int32_t id, register int32_t lValue, register
}
badvarid:
OSD_Printf(CON_ERROR "Gv_SetVar(): tried to set invalid gamevar ID (%d) from sprite %d (%d), player %d\n",
OSD_Printf(CON_ERROR "Gv_SetVar(): invalid gamevar (%d) from sprite %d (%d), player %d\n",
g_errorLineNum,keyw[g_tw],id,vm.g_i,sprite[vm.g_i].picnum,vm.g_p);
return;
badplayer:
OSD_Printf(CON_ERROR "Gv_SetVar(): invalid player (%d) for per-player gamevar %s from sprite %d, player %d\n",
OSD_Printf(CON_ERROR "Gv_SetVar(): invalid player (%d) for gamevar %s from sprite %d, player %d\n",
g_errorLineNum,keyw[g_tw],iPlayer,aGameVars[id].szLabel,vm.g_i,vm.g_p);
return;
badactor:
OSD_Printf(CON_ERROR "Gv_SetVar(): invalid sprite (%d) for per-actor gamevar %s from sprite %d (%d), player %d\n",
OSD_Printf(CON_ERROR "Gv_SetVar(): invalid actor (%d) for gamevar %s from sprite %d (%d), player %d\n",
g_errorLineNum,keyw[g_tw],iActor,aGameVars[id].szLabel,vm.g_i,sprite[vm.g_i].picnum,vm.g_p);
return;
}
@ -798,9 +802,11 @@ void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue)
aGameVars[id].val.lValue=lValue;
return;
case GAMEVAR_PERPLAYER:
if (vm.g_p < 0 || vm.g_p > MAXPLAYERS-1) goto badplayer;
aGameVars[id].val.plValues[vm.g_p]=lValue;
return;
case GAMEVAR_PERACTOR:
if (vm.g_i < 0 || vm.g_i > MAXSPRITES-1) goto badactor;
aGameVars[id].val.plValues[vm.g_i]=lValue;
return;
case GAMEVAR_INTPTR:
@ -813,6 +819,16 @@ void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue)
*((uint8_t*)aGameVars[id].val.lValue)=(uint8_t)lValue;
return;
}
badplayer:
OSD_Printf(CON_ERROR "Gv_SetVar(): invalid player (%d) for gamevar %s\n",
g_errorLineNum,keyw[g_tw],vm.g_p,aGameVars[id].szLabel);
return;
badactor:
OSD_Printf(CON_ERROR "Gv_SetVar(): invalid actor (%d) for gamevar %s\n",
g_errorLineNum,keyw[g_tw],vm.g_i,aGameVars[id].szLabel);
return;
}
int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t lDefault, int32_t iActor, int32_t iPlayer)

View file

@ -2755,7 +2755,8 @@ int32_t MV_Init
{
status = MV_ErrorCode;
free(MV_Voices);
if (MV_Voices)
free(MV_Voices);
MV_Voices = NULL;
MV_HarshClipTable = NULL;
MV_TotalMemory = 0;
@ -2834,7 +2835,8 @@ int32_t MV_Shutdown
SoundDriver_Shutdown();
// Free any voices we allocated
free(MV_Voices);
if (MV_Voices)
free(MV_Voices);
MV_Voices = NULL;
MV_TotalMemory = 0;

View file

@ -4475,9 +4475,7 @@ cheat_for_port_credits:
{
enabled = (ud.config.SoundToggle && ud.config.FXDevice >= 0);
l = ud.config.FXVolume;
ud.config.FXVolume >>= 2;
_bar(1,d+8,yy+7, &ud.config.FXVolume,4,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,0,64);
ud.config.FXVolume <<= 2;
_bar(1,d+8,yy+7, &ud.config.FXVolume,15,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,0,255);
if (l != ud.config.FXVolume)
FX_SetVolume((int16_t) ud.config.FXVolume);
}
@ -4511,9 +4509,7 @@ cheat_for_port_credits:
{
enabled = (ud.config.MusicToggle && ud.config.MusicDevice >= 0);
l = ud.config.MusicVolume;
ud.config.MusicVolume >>= 2;
_bar(1,d+8,yy+7, &ud.config.MusicVolume,4,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,0,64);
ud.config.MusicVolume <<= 2;
_bar(1,d+8,yy+7, &ud.config.MusicVolume,15,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,0,255);
if (l != ud.config.MusicVolume)
S_MusicVolume((int16_t) ud.config.MusicVolume);
}

View file

@ -1433,7 +1433,7 @@ int32_t registerosdcommands(void)
{ "osdhightile", "osdhightile: enable/disable hires art replacements for console text", (void*)&osdhightile, CVAR_BOOL, 0, 1 },
{ "r_drawweapon", "r_drawweapon: enable/disable weapon drawing", (void*)&ud.drawweapon, CVAR_INT, 0, 2 },
{ "r_showfps", "r_showfps: show the frame rate counter", (void*)&ud.tickrate, CVAR_INT, 0, 2 },
{ "r_showfps", "r_showfps: show the frame rate counter", (void*)&ud.tickrate, CVAR_BOOL, 0, 1 },
{ "r_shadows", "r_shadows: enable/disable sprite and model shadows", (void*)&ud.shadows, CVAR_BOOL, 0, 1 },
{ "r_precache", "r_precache: enable/disable the pre-level caching routine", (void*)&ud.config.useprecache, CVAR_BOOL, 0, 1 },

View file

@ -2027,12 +2027,31 @@ static void G_DrawTileScaled(int32_t x, int32_t y, int32_t tilenum, int32_t shad
static void G_DrawWeaponTile(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p)
{
static int32_t shadef = 0, palf = 0;
// basic fading between player weapon shades
if (shadef != shade && (!p || palf == p))
{
shadef += (shade-shadef)>>2;
if (!((shade-shadef)>>2))
{
shadef += (shade-shadef)>>1;
if (!((shade-shadef)>>1))
shadef = shade;
}
}
else
shadef = shade;
palf = p;
switch (ud.drawweapon)
{
default:
return;
case 1:
G_DrawTileScaled(x,y,tilenum,shade,orientation,p);
G_DrawTileScaled(x,y,tilenum,shadef,orientation,p);
return;
case 2:
switch (g_currentweapon)
@ -5355,10 +5374,10 @@ HORIZONLY:
if (!A_CheckSoundPlaying(p->i,DUKE_ONWATER))
A_PlaySound(DUKE_ONWATER,p->i);
if (p->cursectnum != s->sectnum)
changespritesect(p->i,p->cursectnum);
if (p->cursectnum >=0 && p->cursectnum != s->sectnum)
changespritesect(p->i, p->cursectnum);
if (ud.clipping == 0)
if (p->cursectnum >= 0 && ud.clipping == 0)
{
j = (pushmove((vec3_t *)p,&p->cursectnum,164L,(4L<<8),(4L<<8),CLIPMASK0) < 0 && A_GetFurthestAngle(p->i,8) < 512);

View file

@ -316,7 +316,7 @@ static void G_PrecacheSounds(void)
if (ud.config.FXDevice < 0) return;
j = 0;
for (i=MAXSOUNDS; i>=0; i--)
for (i=MAXSOUNDS-1; i>=0; i--)
if (g_sounds[i].ptr == 0)
{
j++;

View file

@ -519,7 +519,7 @@ int32_t G_ActivateWarpElevators(int32_t s,int32_t d) //Parm = sectoreffectornum
return 0;
}
void G_OperateSectors(int32_t sn,int32_t ii)
void G_OperateSectors(int32_t sn, int32_t ii)
{
int32_t j=0, l, q, startwall, endwall;
int32_t i;
@ -726,11 +726,6 @@ void G_OperateSectors(int32_t sn,int32_t ii)
case 29:
if (sptr->lotag&0x8000)
j = sector[nextsectorneighborz(sn,sptr->ceilingz,1,1)].floorz;
else
j = sector[nextsectorneighborz(sn,sptr->ceilingz,-1,-1)].ceilingz;
i = headspritestat[STAT_EFFECTOR]; //Effectors
while (i >= 0)
{
@ -745,11 +740,34 @@ void G_OperateSectors(int32_t sn,int32_t ii)
i = nextspritestat[i];
}
A_CallSound(sn, ii);
sptr->lotag ^= 0x8000;
SetAnimation(sn,&sptr->ceilingz,j,sptr->extra);
if (sptr->lotag&0x8000)
{
j = nextsectorneighborz(sn,sptr->ceilingz,-1,-1);
if (j == -1) j = nextsectorneighborz(sn,sptr->ceilingz,1,1);
if (j == -1)
{
OSD_Printf("WARNING: ST29: null sector!\n");
return;
}
j = sector[j].ceilingz;
}
else
{
j = nextsectorneighborz(sn,sptr->ceilingz,1,1);
if (j == -1) j = nextsectorneighborz(sn,sptr->ceilingz,-1,-1);
if (j == -1)
{
OSD_Printf("WARNING: ST29: null sector!\n");
return;
}
j = sector[j].floorz;
}
A_CallSound(sn,ii);
SetAnimation(sn,&sptr->ceilingz,j,sptr->extra);
return;