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

@ -50,6 +50,27 @@ typedef struct
int32_t max; // for string, is the length int32_t max; // for string, is the length
} cvar_t; } 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 enum osdflags_t
{ {
OSD_INITIALIZED = 0x00000001, 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) 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)))); f = (vis > 239) ? (float)(gvisibility*((vis-240+f)/(klabs(vis-256)))) :
else f = (float)(gvisibility*(vis+16+f)); (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)); 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); inittimer(TIMERINTSPERSECOND);
installusertimercallback(keytimerstuff); installusertimercallback(keytimerstuff);
loadpics("tiles000.art",1048576*16); loadpics("tiles000.art", 1048576*16);
loadnames(); loadnames();
Bstrcpy(kensig,"Uses BUILD technology by Ken Silverman"); Bstrcpy(kensig,"Uses BUILD technology by Ken Silverman");

View file

@ -225,7 +225,7 @@ void agecache(void)
while(mutex_lock(&cachemutex)); while(mutex_lock(&cachemutex));
for (; cnt>=0; cnt--) for (; cnt>=0; cnt--)
{ {
if ((((*cac[agecount].lock)-2)&255) < 198) if (cac[agecount].lock && (((*cac[agecount].lock)-2)&255) < 198)
(*cac[agecount].lock)--; (*cac[agecount].lock)--;
agecount--; 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, "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, "bpp", val, VL) > 0) bppgame = Batoi(val);
if (readconfig(fp, "vsync", val, VL) > 0) vsync = Batoi(val)?1:0; 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) if (readconfig(fp, "grid", val, VL) > 0)
{ {
grid = Batoi(val); grid = Batoi(val);

View file

@ -1245,7 +1245,7 @@ static int32_t owallmost(int16_t *mostbuf, int32_t w, int32_t z)
// //
// wallmost (internal) // 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 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; 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; spritenum = tspr->owner;
cstat = tspr->cstat; cstat = tspr->cstat;
if (tilenum < 0 || tilenum >= MAXSPRITES) return;
#ifdef SUPERBUILD #ifdef SUPERBUILD
if ((cstat&48)==48) vtilenum = tilenum; // if the game wants voxels, it gets voxels if ((cstat&48)==48) vtilenum = tilenum; // if the game wants voxels, it gets voxels
else if ((cstat&48)!=48 && (usevoxels) && (tiletovox[tilenum] != -1) 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]; extern palette_t palookupfog[MAXPALOOKUPS];
#endif #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 wallfront(int32_t l1, int32_t l2);
int32_t animateoffs(int16_t tilenum, int16_t fakevar); 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 while (curbits < 16) //Getbits
{ {
ch = *kfileptr++; if (ch == 255) kfileptr++; ch = *kfileptr++;
if (ch == 255) kfileptr++;
num = (num<<8)+((int32_t)ch); curbits += 8; num = (num<<8)+((int32_t)ch); curbits += 8;
} }
i = ((num>>(curbits-10))&1023); 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 (*_getcolumnwidth)(int32_t) = _internal_getcolumnwidth;
static int32_t (*_getrowheight)(int32_t) = _internal_getrowheight; static int32_t (*_getrowheight)(int32_t) = _internal_getrowheight;
static cvar_t *cvars = NULL; static osdcvar_t *cvars = NULL;
static uint32_t osdnumcvars = 0; static uint32_t osdnumcvars = 0;
static hashtable_t h_cvars = { MAXSYMBOLS<<1, NULL }; 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); 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)); Bmemcpy(&cvars[osdnumcvars++], cvar, sizeof(cvar_t));
return 0; 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: // color code format is as follows:
// ^## sets a color, where ## is the palette number // ^## sets a color, where ## is the palette number
// ^S# sets a shade, range is 0-7 equiv to shades 0-14 // ^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; in += 2;
continue; continue;
} }
*(out++) = *in; *(out++) = *(in++);
} }
while (*(++in)); while (*in);
*out = '\0'; *out = '\0';
return (ptr); return (ptr);
@ -527,7 +573,15 @@ static int32_t _internal_osdfunc_listsymbols(const osdfuncparm_t *parm)
{ {
if (i->func != OSD_UNALIASED) 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; x += maxwidth;
count++; count++;
} }
@ -634,6 +688,28 @@ static int32_t osdcmd_cvar_set_osd(const osdfuncparm_t *parm)
return r; 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 // 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("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("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("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); OSD_RegisterFunction("unalias","unalias: removes a command alias",_internal_osdfunc_unalias);
atexit(OSD_Cleanup); atexit(OSD_Cleanup);
@ -2006,7 +2083,7 @@ void OSD_WriteCvars(FILE *fp)
for (i=0; i<osdnumcvars; i++) 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)) switch (cvars[i].type&(CVAR_FLOAT|CVAR_DOUBLE|CVAR_INT|CVAR_UINT|CVAR_BOOL|CVAR_STRING))
{ {
case CVAR_FLOAT: case CVAR_FLOAT:

View file

@ -892,6 +892,7 @@ void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t da
polymersearching = FALSE; polymersearching = FALSE;
} }
if (dacursectnum > -1 && dacursectnum < numsectors)
getzsofslope(dacursectnum, daposx, daposy, &cursectceilz, &cursectflorz); getzsofslope(dacursectnum, daposx, daposy, &cursectceilz, &cursectflorz);
// external view (editor) // external view (editor)
@ -3467,7 +3468,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
color = mdspritematerial.diffusemodulation; color = mdspritematerial.diffusemodulation;
color[0] = color[1] = color[2] = 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)) if (!(hictinting[tspr->pal].f&4))
{ {
@ -3819,7 +3820,7 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
material->diffusemodulation[0] = material->diffusemodulation[0] =
material->diffusemodulation[1] = material->diffusemodulation[1] =
material->diffusemodulation[2] = 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) 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 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 #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 gyxscale, gxyaspect, gviewxrange, ghalfx, grhalfxdown10, grhalfxdown10x, ghoriz;
double gcosang, gsinang, gcosang2, gsinang2; double gcosang, gsinang, gcosang2, gsinang2;
@ -776,6 +776,7 @@ void polymost_glinit()
memcachesize = filelength(cachefilehandle); memcachesize = filelength(cachefilehandle);
if (memcachesize > 0) if (memcachesize > 0)
{
memcachedata = (uint8_t *)Brealloc(memcachedata, memcachesize); memcachedata = (uint8_t *)Brealloc(memcachedata, memcachesize);
if (!memcachedata) if (!memcachedata)
@ -784,12 +785,13 @@ void polymost_glinit()
memcachesize = -1; memcachesize = -1;
} }
if (memcachesize > 0 && Bread(cachefilehandle, memcachedata, memcachesize) != memcachesize) if (Bread(cachefilehandle, memcachedata, memcachesize) != memcachesize)
{ {
initprintf("Failed reading texcache into memcache!\n"); initprintf("Failed reading texcache into memcache!\n");
Bfree(memcachedata); Bfree(memcachedata);
memcachesize = -1; memcachesize = -1;
} }
}
i = 0; i = 0;
@ -2144,7 +2146,7 @@ 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); f = ((float)(numpalookups-min(max((globalshade * shadescale),0),numpalookups)))/((float)numpalookups);
pc[0] = pc[1] = pc[2] = f; pc[0] = pc[1] = pc[2] = f;
switch (method&3) 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; nguo = uu[0] - ox*ngux - oy*nguy;
ngvo = vv[0] - ox*ngvx - oy*ngvy; 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)); tsizxm1 = tsizx-1; xmodnice = (!(tsizxm1&tsizx));
tsizym1 = tsizy-1; ymulnice = (!(tsizym1&tsizy)); tsizym1 = tsizy-1; ymulnice = (!(tsizym1&tsizy));
@ -2434,7 +2436,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
} }
else 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 if (grhalfxdown10x < 0) //Hack for mirrors
@ -4347,6 +4349,9 @@ void polymost_drawrooms()
hitallsprites = 1; hitallsprites = 1;
hitscan((const vec3_t *)&vect,globalcursectnum, //Start position hitscan((const vec3_t *)&vect,globalcursectnum, //Start position
vx>>12,vy>>12,vz>>8,&hitinfo,0xffff0030); vx>>12,vy>>12,vz>>8,&hitinfo,0xffff0030);
if (hitinfo.hitsect != -1) // if hitsect is -1, hitscan overflowed somewhere
{
getzsofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz); getzsofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz);
hitallsprites = 0; hitallsprites = 0;
@ -4415,6 +4420,7 @@ void polymost_drawrooms()
if (bestk >= 0) if (bestk >= 0)
searchwall = sector[searchsector].wallptr + bestk; searchwall = sector[searchsector].wallptr + bestk;
} }
}
searchit = 0; searchit = 0;
} }
@ -4710,7 +4716,7 @@ void polymost_drawsprite(int32_t snum)
int32_t oldsizx, oldsizy; int32_t oldsizx, oldsizy;
int32_t tsizx, tsizy; int32_t tsizx, tsizy;
tspr = tspriteptr[snum]; 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; globalpicnum = tspr->picnum;
globalshade = tspr->shade; globalshade = tspr->shade;
@ -5681,7 +5687,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),numpalookups)))/((float)numpalookups);
switch ((globalorientation>>7)&3) switch ((globalorientation>>7)&3)
{ {
case 0: case 0:

View file

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

View file

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

View file

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

View file

@ -2840,13 +2840,10 @@ static int32_t m32gettile(int32_t idInitialTile)
idle_waitevent_timeout(500); idle_waitevent_timeout(500);
// SDL seems to miss mousewheel events when rotated slowly. // SDL seems to miss mousewheel events when rotated slowly.
// These kludgy things seem to make it better, but I'm not sure. // These kludgy things seem to make it better, but I'm not sure.
idle();
idle();
if (handleevents()) if (handleevents())
quitevent = 0; quitevent = 0;
getmousevalues(&mousedx,&mousedy,&bstatus); getmousevalues(&mousedx,&mousedy,&bstatus);
searchx += mousedx; searchx += mousedx;
searchy += mousedy; searchy += mousedy;
@ -3988,7 +3985,7 @@ static void Keys3d(void)
drawtileinfo("Clipboard",3,124,temppicnum,tempshade,temppal,tempcstat,templotag,temphitag,tempextra); drawtileinfo("Clipboard",3,124,temppicnum,tempshade,temppal,tempcstat,templotag,temphitag,tempextra);
}// end if usedcount }// end if usedcount
// if (infobox&1) if (searchsector > -1 && searchsector < numsectors)
{ {
char lines[8][64]; char lines[8][64];
int32_t dist, height1=0,height2=0,height3=0, num=0; 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.AmbienceToggle = 1;
ud.config.AutoAim = 1; ud.config.AutoAim = 1;
ud.config.FXDevice = 0; ud.config.FXDevice = 0;
ud.config.FXVolume = 220; ud.config.FXVolume = 225;
#if defined(_WIN32) #if defined(_WIN32)
ud.config.MixRate = 44100; ud.config.MixRate = 44100;
#else #else
@ -208,7 +208,7 @@ void CONFIG_SetDefaults(void)
ud.config.MouseDeadZone = 0; ud.config.MouseDeadZone = 0;
ud.config.MusicDevice = 0; ud.config.MusicDevice = 0;
ud.config.MusicToggle = 1; ud.config.MusicToggle = 1;
ud.config.MusicVolume = 200; ud.config.MusicVolume = 195;
g_myAimMode = g_player[0].ps->aim_mode = 1; g_myAimMode = g_player[0].ps->aim_mode = 1;
ud.config.NumBits = 16; ud.config.NumBits = 16;
ud.config.NumChannels = 2; ud.config.NumChannels = 2;
@ -1017,7 +1017,7 @@ int32_t CONFIG_GetMapBestTime(char *mapname)
strcpy(m, mapname); strcpy(m, mapname);
p = strrchr(m, '/'); p = strrchr(m, '/');
if (!p) 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); for (p=m; *p; p++) *p = tolower(*p);
// cheap hack because SCRIPT_GetNumber doesn't like the slashes // 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" "-l#\t\tWarp to level #, see -v\n"
"-map [file.map]\tLoads a map\n" "-map [file.map]\tLoads a map\n"
"-m\t\tDisable monsters\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" "-r\t\tRecord demo\n"
"-s#\t\tSet skill level (1-4)\n" "-s#\t\tSet skill level (1-4)\n"
"-server\t\tStart a multiplayer game for other players to join\n" "-server\t\tStart a multiplayer game for other players to join\n"
@ -9508,6 +9508,7 @@ static void G_ShowParameterHelp(void)
#endif #endif
"-u#########\tUser's favorite weapon order (default: 3425689071)\n" "-u#########\tUser's favorite weapon order (default: 3425689071)\n"
"-v#\t\tWarp to volume #, see -l\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" "-x[game.con]\tLoad custom CON script\n"
"-#\t\tLoad and run a game from slot # (0-9)\n" "-#\t\tLoad and run a game from slot # (0-9)\n"
// "\n-?/--help\tDisplay this help message and exit\n" // "\n-?/--help\tDisplay this help message and exit\n"
@ -9527,17 +9528,14 @@ static void G_ShowDebugHelp(void)
"\n" "\n"
"-a\t\tUse fake player AI (fake multiplayer only)\n" "-a\t\tUse fake player AI (fake multiplayer only)\n"
"-cachesize #\tSets cache size, in Kb\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" "-game_dir [dir]\tDuke3d_w32 compatibility option, see -j\n"
"-gamegrp \tSelects which file to use as main grp\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" "-name [name]\tPlayer name in multiplay\n"
"-nD\t\tDump default gamevars to gamevars.txt\n" "-nD\t\tDump default gamevars to gamevars.txt\n"
"-noautoload\tDisable loading content from autoload dir\n" "-noautoload\tDisable loading content from autoload dir\n"
"-nologo\t\tSkip the logo anim\n" "-nologo\t\tSkip the logo anim\n"
"-ns/-nm\t\tDisable sound or music\n" "-ns/-nm\t\tDisable sound or music\n"
"-q#\t\tFake multiplayer with # (2-8) players\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" "-z#/-condebug\tEnable line-by-line CON compile debugging at level #\n"
; ;
#if defined RENDERTYPEWIN #if defined RENDERTYPEWIN
@ -11121,9 +11119,8 @@ void app_main(int32_t argc,const char **argv)
getcwd(g_rootDir,BMAX_PATH); getcwd(g_rootDir,BMAX_PATH);
strcat(g_rootDir,"/"); strcat(g_rootDir,"/");
#endif #endif
OSD_SetLogFile("eduke32.log");
OSD_SetParameters(0,0, 0,12, 2,12); OSD_SetParameters(0,0, 0,12, 2,12);
OSD_SetLogFile("eduke32.log");
OSD_SetFunctions( OSD_SetFunctions(
GAME_drawosdchar, GAME_drawosdchar,
GAME_drawosdstr, GAME_drawosdstr,

View file

@ -3866,8 +3866,8 @@ nullquote:
if (asize > 0) if (asize > 0)
{ {
OSD_Printf(OSDTEXT_GREEN "CON_RESIZEARRAY: resizing array %s from %d to %d\n", /*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].szLabel, aGameArrays[j].size, asize / sizeof(int32_t));*/
aGameArrays[j].plValues=Brealloc(aGameArrays[j].plValues, asize); aGameArrays[j].plValues=Brealloc(aGameArrays[j].plValues, asize);
aGameArrays[j].size = asize / sizeof(int32_t); aGameArrays[j].size = asize / sizeof(int32_t);
kread(fil, aGameArrays[j].plValues, asize); kread(fil, aGameArrays[j].plValues, asize);
@ -3911,7 +3911,7 @@ nullquote:
if (asize > 0) 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].plValues=Brealloc(aGameArrays[j].plValues, sizeof(int32_t) * asize);
aGameArrays[j].size = 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); Bfree(aGameVars[i].val.plValues);
aGameVars[i].val.plValues=NULL; aGameVars[i].val.plValues=NULL;
} }
aGameVars[i].dwFlags |= GAMEVAR_RESET; aGameVars[i].dwFlags |= GAMEVAR_RESET;
if (i >= MAXGAMEARRAYS) if (i >= MAXGAMEARRAYS)
continue; continue;
if (aGameArrays[i].plValues) if (aGameArrays[i].plValues)
Bfree(aGameArrays[i].plValues); Bfree(aGameArrays[i].plValues);
aGameArrays[i].plValues=NULL; aGameArrays[i].plValues=NULL;
aGameArrays[i].bReset=1; aGameArrays[i].bReset=1;
} }
@ -680,17 +684,17 @@ void __fastcall Gv_SetVar(register int32_t id, register int32_t lValue, register
} }
badvarid: 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); g_errorLineNum,keyw[g_tw],id,vm.g_i,sprite[vm.g_i].picnum,vm.g_p);
return; return;
badplayer: 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); g_errorLineNum,keyw[g_tw],iPlayer,aGameVars[id].szLabel,vm.g_i,vm.g_p);
return; return;
badactor: 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); g_errorLineNum,keyw[g_tw],iActor,aGameVars[id].szLabel,vm.g_i,sprite[vm.g_i].picnum,vm.g_p);
return; return;
} }
@ -798,9 +802,11 @@ void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue)
aGameVars[id].val.lValue=lValue; aGameVars[id].val.lValue=lValue;
return; return;
case GAMEVAR_PERPLAYER: case GAMEVAR_PERPLAYER:
if (vm.g_p < 0 || vm.g_p > MAXPLAYERS-1) goto badplayer;
aGameVars[id].val.plValues[vm.g_p]=lValue; aGameVars[id].val.plValues[vm.g_p]=lValue;
return; return;
case GAMEVAR_PERACTOR: case GAMEVAR_PERACTOR:
if (vm.g_i < 0 || vm.g_i > MAXSPRITES-1) goto badactor;
aGameVars[id].val.plValues[vm.g_i]=lValue; aGameVars[id].val.plValues[vm.g_i]=lValue;
return; return;
case GAMEVAR_INTPTR: 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; *((uint8_t*)aGameVars[id].val.lValue)=(uint8_t)lValue;
return; 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) int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t lDefault, int32_t iActor, int32_t iPlayer)

View file

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

View file

@ -4475,9 +4475,7 @@ cheat_for_port_credits:
{ {
enabled = (ud.config.SoundToggle && ud.config.FXDevice >= 0); enabled = (ud.config.SoundToggle && ud.config.FXDevice >= 0);
l = ud.config.FXVolume; l = ud.config.FXVolume;
ud.config.FXVolume >>= 2; _bar(1,d+8,yy+7, &ud.config.FXVolume,15,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,0,255);
_bar(1,d+8,yy+7, &ud.config.FXVolume,4,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,0,64);
ud.config.FXVolume <<= 2;
if (l != ud.config.FXVolume) if (l != ud.config.FXVolume)
FX_SetVolume((int16_t) 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); enabled = (ud.config.MusicToggle && ud.config.MusicDevice >= 0);
l = ud.config.MusicVolume; l = ud.config.MusicVolume;
ud.config.MusicVolume >>= 2; _bar(1,d+8,yy+7, &ud.config.MusicVolume,15,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,0,255);
_bar(1,d+8,yy+7, &ud.config.MusicVolume,4,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,0,64);
ud.config.MusicVolume <<= 2;
if (l != ud.config.MusicVolume) if (l != ud.config.MusicVolume)
S_MusicVolume((int16_t) 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 }, { "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_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_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 }, { "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 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) switch (ud.drawweapon)
{ {
default: default:
return; return;
case 1: case 1:
G_DrawTileScaled(x,y,tilenum,shade,orientation,p); G_DrawTileScaled(x,y,tilenum,shadef,orientation,p);
return; return;
case 2: case 2:
switch (g_currentweapon) switch (g_currentweapon)
@ -5355,10 +5374,10 @@ HORIZONLY:
if (!A_CheckSoundPlaying(p->i,DUKE_ONWATER)) if (!A_CheckSoundPlaying(p->i,DUKE_ONWATER))
A_PlaySound(DUKE_ONWATER,p->i); A_PlaySound(DUKE_ONWATER,p->i);
if (p->cursectnum != s->sectnum) if (p->cursectnum >=0 && p->cursectnum != s->sectnum)
changespritesect(p->i,p->cursectnum); 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); 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; if (ud.config.FXDevice < 0) return;
j = 0; j = 0;
for (i=MAXSOUNDS; i>=0; i--) for (i=MAXSOUNDS-1; i>=0; i--)
if (g_sounds[i].ptr == 0) if (g_sounds[i].ptr == 0)
{ {
j++; j++;

View file

@ -519,7 +519,7 @@ int32_t G_ActivateWarpElevators(int32_t s,int32_t d) //Parm = sectoreffectornum
return 0; 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 j=0, l, q, startwall, endwall;
int32_t i; int32_t i;
@ -726,11 +726,6 @@ void G_OperateSectors(int32_t sn,int32_t ii)
case 29: 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 i = headspritestat[STAT_EFFECTOR]; //Effectors
while (i >= 0) while (i >= 0)
{ {
@ -745,11 +740,34 @@ void G_OperateSectors(int32_t sn,int32_t ii)
i = nextspritestat[i]; i = nextspritestat[i];
} }
A_CallSound(sn, ii);
sptr->lotag ^= 0x8000; 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; return;