Some misc fixes, mostly win32/msvc focused.

Rename sound flags to include their valid scope.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5322 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2018-10-17 00:43:04 +00:00
parent 487201eeec
commit 4ae635bc7b
24 changed files with 188 additions and 102 deletions

View File

@ -66,7 +66,7 @@ void QDECL AAS_Error(char *fmt, ...)
va_list arglist;
va_start(arglist, fmt);
Q_vsnprintf(str, sizeof(str), fmt, arglist);
vsnprintf(str, sizeof(str), fmt, arglist);
va_end(arglist);
botimport.Print(PRT_FATAL, "%s", str);
} //end of the function AAS_Error

View File

@ -137,7 +137,7 @@ void QDECL SourceError(source_t *source, char *str, ...)
va_list ap;
va_start(ap, str);
Q_vsnprintf(text, sizeof(text), str, ap);
vsnprintf(text, sizeof(text), str, ap);
va_end(ap);
#ifdef BOTLIB
botimport.Print(PRT_ERROR, "file %s, line %d: %s\n", source->scriptstack->filename, source->scriptstack->line, text);
@ -161,7 +161,7 @@ void QDECL SourceWarning(source_t *source, char *str, ...)
va_list ap;
va_start(ap, str);
Q_vsnprintf(text, sizeof(text), str, ap);
vsnprintf(text, sizeof(text), str, ap);
va_end(ap);
#ifdef BOTLIB
botimport.Print(PRT_WARNING, "file %s, line %d: %s\n", source->scriptstack->filename, source->scriptstack->line, text);

View File

@ -242,7 +242,7 @@ void QDECL ScriptError(script_t *script, char *str, ...)
if (script->flags & SCFL_NOERRORS) return;
va_start(ap, str);
Q_vsnprintf(text, sizeof(text), str, ap);
vsnprintf(text, sizeof(text), str, ap);
va_end(ap);
#ifdef BOTLIB
botimport.Print(PRT_ERROR, "file %s, line %d: %s\n", script->filename, script->line, text);
@ -268,7 +268,7 @@ void QDECL ScriptWarning(script_t *script, char *str, ...)
if (script->flags & SCFL_NOWARNINGS) return;
va_start(ap, str);
Q_vsnprintf(text, sizeof(text), str, ap);
vsnprintf(text, sizeof(text), str, ap);
va_end(ap);
#ifdef BOTLIB
botimport.Print(PRT_WARNING, "file %s, line %d: %s\n", script->filename, script->line, text);

View File

@ -4903,7 +4903,7 @@ static void CLNQ_ParseStartSoundPacket(void)
pitchadj = (unsigned short)MSG_ReadShort() / 4000.0;
flags = field_mask>>8;
flags &= CF_FORCELOOP | CF_NOREVERB | CF_FOLLOW;
flags &= CF_NETWORKED;
if (field_mask & NQSND_LARGEENTITY)
{

View File

@ -2892,6 +2892,9 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch
struct pendingtextureinfo *mips;
int encoding = TF_INVALID;
qbyte *in;
qbyte *fileend = filedata + filesize;
unsigned int blockwidth, blockheight, blockbytes;
if (memcmp(filedata, magic, sizeof(magic)))
return NULL; //not a ktx file
@ -3082,6 +3085,8 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch
if (nummips * header->numberoffaces > countof(mips->mip))
nummips = countof(mips->mip) / header->numberoffaces;
Image_BlockSizeForEncoding(encoding, &blockbytes, &blockwidth, &blockheight);
w = header->pixelwidth;
h = header->pixelheight;
d = header->pixeldepth;
@ -3089,7 +3094,18 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch
{
datasize = *(int*)filedata;
filedata += 4;
//FIXME: validate the data size
if (datasize != blockbytes * ((w+blockwidth-1)/blockwidth) * ((h+blockheight-1)/blockheight))
{
Con_Printf("%s: mip %i does not match expected size\n", fname, mipnum);
break;
}
if (filedata + datasize*header->numberoffaces > fileend)
{
Con_Printf("%s: truncation at mip %i\n", fname, mipnum);
break;
}
for (face = 0; face < header->numberoffaces; face++)
{
@ -3106,10 +3122,16 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch
if ((datasize & 3) && mips->type == PTI_CUBEMAP)
filedata += 4-(datasize&3);
}
w = (w+1)>>1;
h = (h+1)>>1;
w = max(1, w>>1);
h = max(1, h>>1);
if (mips->type == PTI_3D)
d = (d+1)>>1;
d = max(1, d>>1);
}
if (!mips->mipcount)
{
Z_Free(mips);
return NULL;
}
return mips;
@ -5319,12 +5341,13 @@ const char *Image_FormatName(uploadfmt_t fmt)
return "Unknown";
}
static pixel32_t *Image_Block_Decode(qbyte *fte_restrict in, int w, int h, void(*decodeblock)(qbyte *fte_restrict in, pixel32_t *fte_restrict out, int w), uploadfmt_t encoding)
static pixel32_t *Image_Block_Decode(qbyte *fte_restrict in, size_t insize, int w, int h, void(*decodeblock)(qbyte *fte_restrict in, pixel32_t *fte_restrict out, int w), uploadfmt_t encoding)
{
#define TMPBLOCKSIZE 16u
pixel32_t *ret, *out;
pixel32_t tmp[TMPBLOCKSIZE*TMPBLOCKSIZE];
int x, y, i, j;
int sizediff;
unsigned int blockbytes, blockwidth, blockheight;
Image_BlockSizeForEncoding(encoding, &blockbytes, &blockwidth, &blockheight);
@ -5332,6 +5355,14 @@ static pixel32_t *Image_Block_Decode(qbyte *fte_restrict in, int w, int h, void(
if (blockwidth > TMPBLOCKSIZE || blockheight > TMPBLOCKSIZE)
Sys_Error("Image_Block_Decode only supports up to %u*%u blocks.\n", TMPBLOCKSIZE,TMPBLOCKSIZE);
sizediff = insize - blockbytes*((w+blockwidth-1)/blockwidth)*((h+blockheight-1)/blockheight);
if (sizediff)
{
Con_Printf("Image_Block_Decode: %s data size is %u, expected %u\n\n", Image_FormatName(encoding), insize, insize-sizediff);
if (sizediff < 0)
return NULL;
}
ret = out = BZ_Malloc(w*h*sizeof(*out));
for (y = 0; y < (h&~(blockheight-1)); y+=blockheight, out += w*(blockheight-1))
@ -5349,9 +5380,8 @@ static pixel32_t *Image_Block_Decode(qbyte *fte_restrict in, int w, int h, void(
in+=blockbytes;
}
}
if (h%blockheight)
{
{ //now walk along the bottom of the image
h %= blockheight;
for (x = 0; x < w; )
{
@ -5374,11 +5404,17 @@ static pixel32_t *Image_Block_Decode(qbyte *fte_restrict in, int w, int h, void(
static void Image_DecompressFormat(struct pendingtextureinfo *mips)
{
//various compressed formats might not be supported.
//various compressed formats might not be supported by various gpus/apis.
//sometimes the gpu might only partially support the format (eg: d3d requires mip 0 be a multiple of the block size)
//and sometimes we want the actual rgb data (eg: so that we can palettize it)
//so this is still useful even if every driver ever created supported the format.
//as a general rule, decompressing is fairly straight forward, but not free. yay threads.
//iiuc any basic s3tc patents have now expired, so it is legally safe to decode (though fancy compression logic may still have restrictions, but we don't compress).
static float throttle;
void *decodefunc = NULL;
int rcoding = mips->encoding;
int mip;
//its easy enough to decompress these, if needed, its not so easy to compress them as something that's actually supported...
switch(mips->encoding)
{
default:
@ -5416,7 +5452,7 @@ static void Image_DecompressFormat(struct pendingtextureinfo *mips)
decodefunc = Image_Decode_EAC_R11U_Block;
rcoding = PTI_RGBX8;
break;
/* case PTI_EAC_R11_SNORM:
/* case PTI_EAC_R11_SNORM:
decodefunc = Image_Decode_EAC_R11S_Block;
rcoding = PTI_RGBX8;
break;*/
@ -5424,36 +5460,62 @@ static void Image_DecompressFormat(struct pendingtextureinfo *mips)
decodefunc = Image_Decode_EAC_RG11U_Block;
rcoding = PTI_RGBX8;
break;
/* case PTI_EAC_RG11_SNORM:
/* case PTI_EAC_RG11_SNORM:
decodefunc = Image_Decode_EAC_RG11S_Block;
rcoding = PTI_RGBX8;
break;*/
#else
case PTI_ETC1_RGB8:
case PTI_ETC2_RGB8:
case PTI_ETC2_RGB8_SRGB:
case PTI_ETC2_RGB8A1:
case PTI_ETC2_RGB8A1_SRGB:
case PTI_ETC2_RGB8A8:
case PTI_ETC2_RGB8A8_SRGB:
case PTI_EAC_R11:
case PTI_EAC_R11_SNORM:
case PTI_EAC_RG11:
case PTI_EAC_RG11_SNORM:
Con_ThrottlePrintf(&throttle, 0, "ETC1/ETC2/EAC decompression is not supported in this build\n");
break;
#endif
#ifdef DECOMPRESS_S3TC
case PTI_BC1_RGB:
case PTI_BC1_RGB_SRGB:
#ifdef DECOMPRESS_S3TC
decodefunc = Image_Decode_BC1_Block;
rcoding = (mips->encoding==PTI_BC1_RGB_SRGB)?PTI_RGBX8_SRGB:PTI_RGBX8;
#else
Con_ThrottlePrintf(&throttle, 0, "BC1 decompression is not supported in this build\n");
#endif
break;
case PTI_BC1_RGBA:
case PTI_BC1_RGBA_SRGB:
#ifdef DECOMPRESS_S3TC
decodefunc = Image_Decode_BC1A_Block;
rcoding = (mips->encoding==PTI_BC1_RGBA_SRGB)?PTI_RGBA8_SRGB:PTI_RGBA8;
#else
Con_ThrottlePrintf(&throttle, 0, "BC1A decompression is not supported in this build\n");
#endif
break;
case PTI_BC2_RGBA:
case PTI_BC2_RGBA_SRGB:
#ifdef DECOMPRESS_S3TC
decodefunc = Image_Decode_BC2_Block;
rcoding = (mips->encoding==PTI_BC2_RGBA_SRGB)?PTI_RGBA8_SRGB:PTI_RGBA8;
break;
#else
Con_ThrottlePrintf(&throttle, 0, "BC2 decompression is not supported in this build\n");
#endif
#if defined(DECOMPRESS_RGTC) && defined(DECOMPRESS_S3TC)
break;
case PTI_BC3_RGBA:
case PTI_BC3_RGBA_SRGB:
#if defined(DECOMPRESS_RGTC) && defined(DECOMPRESS_S3TC)
decodefunc = Image_Decode_BC3_Block;
rcoding = (mips->encoding==PTI_BC3_RGBA_SRGB)?PTI_RGBA8_SRGB:PTI_RGBA8;
break;
#else
Con_ThrottlePrintf(&throttle, 0, "BC3 decompression is not supported in this build\n");
#endif
break;
#ifdef DECOMPRESS_RGTC
case PTI_BC4_R8_SNORM:
decodefunc = Image_Decode_BC4S_Block;
@ -5471,23 +5533,37 @@ static void Image_DecompressFormat(struct pendingtextureinfo *mips)
decodefunc = Image_Decode_BC5U_Block;
rcoding = PTI_RGBX8;
break;
#else
case PTI_BC4_R8_SNORM:
case PTI_BC4_R8:
case PTI_BC5_RG8_SNORM:
case PTI_BC5_RG8:
Con_ThrottlePrintf(&throttle, 0, "BC4/BC5 decompression is not supported in this build\n");
break;
#endif
#if 0//def DECOMPRESS_BPTC
case PTI_BC6_RGBFU:
case PTI_BC6_RGBFS:
case PTI_BC6_RGB_UFLOAT:
case PTI_BC6_RGB_SFLOAT:
rcoding = PTI_RGBA16F;
break;
case PTI_BC7_RGBA:
case PTI_BC7_RGBA_SRGB:
rcoding = PTI_ZOMGWTF;
break;
#else
case PTI_BC6_RGB_UFLOAT:
case PTI_BC6_RGB_SFLOAT:
case PTI_BC7_RGBA:
case PTI_BC7_RGBA_SRGB:
Con_ThrottlePrintf(&throttle, 0, "BC6/BC7 decompression is not supported\n");
break;
#endif
}
if (decodefunc)
{
for (mip = 0; mip < mips->mipcount; mip++)
{
pixel32_t *out = Image_Block_Decode(mips->mip[mip].data, mips->mip[mip].width, mips->mip[mip].height, decodefunc, mips->encoding);
pixel32_t *out = Image_Block_Decode(mips->mip[mip].data, mips->mip[mip].datasize, mips->mip[mip].width, mips->mip[mip].height, decodefunc, mips->encoding);
if (mips->mip[mip].needfree)
BZ_Free(mips->mip[mip].data);
mips->mip[mip].data = out;

View File

@ -1037,7 +1037,7 @@ void M_Menu_Demos_f (void)
#ifdef PACKAGE_DZIP
".dz",
#endif
NULL
NULL //in case none of the above are defined. compilers don't much like 0-length arrays.
};
size_t u;
demomenu_t *info;
@ -1078,7 +1078,7 @@ void M_Menu_Demos_f (void)
//and some archive formats... for the luls
for (u = 0; u < countof(archiveexts); u++)
{
if (archiveexts[u])
if (!archiveexts[u])
continue;
info->command[info->numext] = NULL;
info->ext[info->numext++] = archiveexts[u];

View File

@ -1104,7 +1104,7 @@ static skelobject_t *skel_get(world_t *world, int skelidx)
return &skelobjects[skelidx];
}
void skel_lookup(world_t *world, int skelidx, framestate_t *out)
void skel_lookup(world_t *world, int skelidx, framestate_t *fte_restrict out)
{
skelobject_t *sko = skel_get(world, skelidx);
if (sko && sko->inuse)

View File

@ -684,7 +684,7 @@ static void OpenAL_ChannelUpdate(soundcardinfo_t *sc, channel_t *chan, unsigned
}
cvolume = chan->master_vol/255.0f;
if (!(chan->flags & CF_ABSVOLUME))
if (!(chan->flags & CF_CL_ABSVOLUME))
cvolume *= volume.value*voicevolumemod;
//openal doesn't support loopstart (entire sample loops or not at all), so if we're meant to skip the first half then we need to stream it.

View File

@ -2554,7 +2554,7 @@ static void SND_AccumulateSpacialization(soundcardinfo_t *sc, channel_t *ch, vec
float volscale;
int seat;
if (ch->flags & CF_ABSVOLUME)
if (ch->flags & CF_CL_ABSVOLUME)
volscale = 1;
else
volscale = volume.value * voicevolumemod;
@ -2681,12 +2681,12 @@ static void SND_Spatialize(soundcardinfo_t *sc, channel_t *ch)
}
//sounds with absvolume ignore all volume etc cvars+settings
if (ch->flags & CF_ABSVOLUME)
if (ch->flags & CF_CL_ABSVOLUME)
volscale = 1;
else
volscale = volume.value * voicevolumemod;
if (!vid.activeapp && !snd_inactive.ival && !(ch->flags & CF_INACTIVE))
if (!vid.activeapp && !snd_inactive.ival && !(ch->flags & CF_CLI_INACTIVE))
volscale = 0;
if (sc->seat == -1)
@ -3286,9 +3286,9 @@ void S_UpdateAmbientSounds (soundcardinfo_t *sc)
}
if (chan->sfx)
{
chan->flags = /*CF_INACTIVE|*/CF_ABSVOLUME|CF_NOSPACIALISE|CF_NOREVERB; //bypasses volume cvar completely.
chan->flags = /*CF_CL_INACTIVE|*/CF_CL_ABSVOLUME|CF_NOSPACIALISE|CF_NOREVERB; //bypasses volume cvar completely.
vol = 255*bgmvolume.value*voicevolumemod;
if (!vid.activeapp && !snd_inactive.ival && !(chan->flags & CF_INACTIVE))
if (!vid.activeapp && !snd_inactive.ival && !(chan->flags & CF_CLI_INACTIVE))
vol = 0;
vol = bound(0, vol, 255);
vol = Media_CrossFade(i-MUSIC_FIRST, vol, (chan->pos>>PITCHSHIFT) / (float)snd_speed);
@ -3484,7 +3484,7 @@ static void S_Q2_AddEntitySounds(soundcardinfo_t *sc)
{
for (c = NULL, j=DYNAMIC_FIRST; j < DYNAMIC_STOP ; j++)
{
if (sc->channel[j].entnum == entnums[count] && !sc->channel[j].entchannel && (sc->channel[j].flags & CF_AUTOSOUND))
if (sc->channel[j].entnum == entnums[count] && !sc->channel[j].entchannel && (sc->channel[j].flags & CF_CLI_AUTOSOUND))
{
c = &sc->channel[j];
break;
@ -3495,7 +3495,7 @@ static void S_Q2_AddEntitySounds(soundcardinfo_t *sc)
{
for (c = NULL, j=DYNAMIC_FIRST; j < DYNAMIC_STOP ; j++)
{
if (sc->channel[j].sfx == sfx && (sc->channel[j].flags & CF_AUTOSOUND))
if (sc->channel[j].sfx == sfx && (sc->channel[j].flags & CF_CLI_AUTOSOUND))
{
c = &sc->channel[j];
break;
@ -3507,7 +3507,7 @@ static void S_Q2_AddEntitySounds(soundcardinfo_t *sc)
c = SND_PickChannel(sc, 0, 0);
if (!c)
continue;
c->flags = CF_AUTOSOUND|CF_FORCELOOP;
c->flags = CF_CLI_AUTOSOUND|CF_FORCELOOP;
c->entnum = sc->ChannelUpdate?entnums[count]:0;
c->entchannel = 0;
c->dist_mult = 3 / sound_nominal_clip_dist;
@ -3582,7 +3582,7 @@ static void S_UpdateCard(soundcardinfo_t *sc)
{
if (!ch->sfx)
continue;
if (ch->flags & CF_AUTOSOUND)
if (ch->flags & CF_CLI_AUTOSOUND)
{
if (!ch->vol[0] && !ch->vol[1] && !ch->vol[2] && !ch->vol[3] && !ch->vol[4] && !ch->vol[5])
{
@ -3959,7 +3959,7 @@ void S_LocalSound2 (const char *sound, int channel, float volume)
Con_Printf ("S_LocalSound: can't cache %s\n", sound);
return;
}
S_StartSound (0, channel, sfx, NULL, NULL, volume, 0, 0, 0, CF_INACTIVE|CF_NOSPACIALISE|CF_NOREVERB);
S_StartSound (0, channel, sfx, NULL, NULL, volume, 0, 0, 0, CF_CLI_INACTIVE|CF_NOSPACIALISE|CF_NOREVERB);
}
void S_LocalSound (const char *sound)
{
@ -4170,7 +4170,7 @@ void S_RawAudio(int sourceid, qbyte *data, int speed, int samples, int channels,
channel_t *c = SND_PickChannel(si, -1, 0);
if (c)
{
c->flags = (sourceid>=0?CF_INACTIVE:0)|CF_ABSVOLUME|CF_NOSPACIALISE;
c->flags = (sourceid>=0?CF_CLI_INACTIVE:0)|CF_CL_ABSVOLUME|CF_NOSPACIALISE;
c->entnum = 0;
c->entchannel = 0;
c->dist_mult = 0;

View File

@ -100,45 +100,21 @@ typedef struct
} dma_t;
//client and server
//#define CF_RELIABLE 1
#define CF_SV_RELIABLE 1 // send reliably
#define CF_NET_SENTVELOCITY CF_SV_RELIABLE
#define CF_FORCELOOP 2 // forces looping. set on static sounds.
#define CF_NOSPACIALISE 4 // these sounds are played at a fixed volume in both speakers, but still gets quieter with distance.
//#define CF_PAUSED 8 // rate = 0. or something.
//#define CF_ABSVOLUME 16
#define CF_CL_ABSVOLUME 16 // ignores volume cvar. this is ignored if received from the server because there's no practical way for the server to respect the client's preferences.
//#define CF_SV_RESERVED CF_CL_ABSVOLUME
#define CF_NOREVERB 32 // disables reverb on this channel, if possible.
#define CF_FOLLOW 64 // follows the owning entity (stops moving if we lose track)
//#define CF_RESERVEDN 128 // reserved for things that should be networked.
//client only
///CF_RELIABLE 1
//#define CF_FORCELOOP 2
//#define CF_NOSPACIALISE 4
///#define CF_PAUSED 8
#define CF_ABSVOLUME 16 // ignores volume cvar.
//#define CF_NOREVERB 32
//#define CF_FOLLOW 64
///#define CF_RESERVEDN 128
//client-internal
#define CF_AUTOSOUND 1024 // generated from q2 entities, which avoids breaking regular sounds, using it outside the sound system will probably break things.
#define CF_INACTIVE 2048 // try to play even when inactive
//server only
#define CF_RELIABLE 1 // serverside only. yeah, evil. screw you.
//#define CF_FORCELOOP 2
//#define CF_NOSPACIALISE 4
///#define CF_PAUSED 8
//#define CF_NOREVERB 32
//#define CF_FOLLOW 64
///#define CF_RESERVEDN 128
#define CF_UNICAST 256 // serverside only. the sound is sent to msg_entity only.
#define CF_SENDVELOCITY 512 // serverside hint that velocity is important
///#define CF_UNUSED 2048
///#define CF_UNUSED 4096
///#define CF_UNUSED 8192
///#define CF_UNUSED 16384
///#define CF_UNUSED 32768
#define CF_SV_UNICAST 256 // serverside only. the sound is sent to msg_entity only.
#define CF_SV_SENDVELOCITY 512 // serverside hint that velocity is important
#define CF_CLI_AUTOSOUND 1024 // generated from q2 entities, which avoids breaking regular sounds, using it outside the sound system will probably break things.
#define CF_CLI_INACTIVE 2048 // try to play even when inactive
#define CF_NETWORKED (CF_NOSPACIALISE|CF_NOREVERB|CF_FORCELOOP|CF_FOLLOW/*|CF_RESERVEDN*/)
typedef struct

View File

@ -92,7 +92,7 @@
#define AVAIL_JPEGLIB //.jpeg image format support (read+screenshots)
#define AVAIL_FREETYPE //for truetype font rendering
#define DECOMPRESS_ETC2 //decompress etc2(core in gles3/gl4.3) if the graphics driver doesn't support it (eg d3d or crappy gpus with vulkan).
//#define DECOMPRESS_S3TC //allows bc1-3 to work even when drivers don't support it. This is probably only an issue on mobile chips. WARNING: not entirely sure if all patents expired yet...
#define DECOMPRESS_S3TC //allows bc1-3 to work even when drivers don't support it. This is probably only an issue on mobile chips. WARNING: not entirely sure if all patents expired yet...
#define DECOMPRESS_RGTC //bc4+bc5
// Game/Gamecode Support

View File

@ -7171,7 +7171,7 @@ int TCP_OpenStream (netadr_t *remoteaddr)
#endif
#ifdef HAVE_IPX
case NA_IPX:
protocol = NSPROTO_IPX;
sysprot = NSPROTO_IPX;
break;
#endif
default:
@ -7842,7 +7842,7 @@ void QDECL SV_PortIPX_Callback(struct cvar_s *var, char *oldvalue)
}
cvar_t sv_port_ipx = CVARC("sv_port_ipx", "", SV_PortIPX_Callback);
#endif
#ifdef HAVE_IPX
#ifdef UNIXSOCKETS
void QDECL SV_PortUNIX_Callback(struct cvar_s *var, char *oldvalue)
{
FTENET_AddToCollection(svs.sockets, var->name, var->string, NA_UNIX, NP_DGRAM);

View File

@ -3976,7 +3976,7 @@ static const char *PR_buf_loadgame(pubprogfuncs_t *prinst, const char *l)
if (tt != TTP_RAWTOKEN)
break;
index = atoi(token);
l = COM_ParseTokenOut(l, NULL, token, sizeof(token), &tt);if (tt != TTP_STRING)return false;
l = COM_ParseTokenOut(l, NULL, token, sizeof(token), &tt);if (tt != TTP_STRING)return NULL;
if (index < 0 || index >= buf->allocated)
continue; //some sort of error.

View File

@ -887,14 +887,19 @@ enum {
#define NQSND_VOLUME (1<<0) // a qbyte
#define NQSND_ATTENUATION (1<<1) // a qbyte
//#define DPSND_LOOPING (1<<2) // a long, supposedly
#define FTESND_MOREFLAGS (1<<2) // actually, chan flags
#define FTESND_MOREFLAGS (1<<2) // actually, chan flags, mostly.
#define NQSND_LARGEENTITY (1<<3) //both dp+fitz
#define NQSND_LARGESOUND (1<<4) //both dp+fitz
#define DPSND_SPEEDUSHORT4000 (1<<5) // ushort speed*4000 (speed is usually 1.0, a value of 0.0 is the same as 1.0)
#define FTESND_TIMEOFS (1<<6) //signed short, in milliseconds.
#define FTESND_PITCHADJ (1<<7) //a byte (speed percent (0=100%))
//more flags are weird.
#define FTESND_VELOCITY (CF_RELIABLE<<8) //borrowed.
#define FTESND_VELOCITY (CF_NET_SENTVELOCITY<<8) //borrowed.
//FTESND_NOSPACIALISE (CF_NOSPACIALISE<<8)
//FTESND_NOREVERB (CF_NOREVERB<<8)
//FTESND_FORCELOOP (CF_FORCELOOP<<8)
//FTESND_FOLLOW (CF_FOLLOW<<8)
//FTESND_RESERVED (CF_RESERVEDN<<8)
#define DEFAULT_SOUND_PACKET_VOLUME 255
#define DEFAULT_SOUND_PACKET_ATTENUATION 1.0

View File

@ -31,6 +31,14 @@ qboolean D3D9_LoadTextureMips(image_t *tex, const struct pendingtextureinfo *mip
switch(mips->encoding)
{
case PTI_L8_SRGB:
case PTI_L8:
fmt = D3DFMT_L8;
break;
case PTI_L8A8_SRGB:
case PTI_L8A8:
fmt = D3DFMT_A8L8;
break;
case PTI_RGB565:
fmt = D3DFMT_R5G6B5;
break;

View File

@ -949,7 +949,9 @@ qboolean GL_LoadTextureMips(texid_t tex, const struct pendingtextureinfo *mips)
j = i;
}
qglGetTexLevelParameteriv(targ, j, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &csize);
qglGetTexLevelParameteriv(targface, j, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &csize);
if (!csize)
break; //some kind of error. the gpu didn't store it?
out.mip[i].datasize = csize;
out.mip[i].data = BZ_Malloc(csize);
out.mip[i].needfree = true;
@ -959,7 +961,14 @@ qboolean GL_LoadTextureMips(texid_t tex, const struct pendingtextureinfo *mips)
qglGetCompressedTexImage(targ, j, out.mip[i].data);
}
Image_WriteKTXFile(va("textures/%s.ktx", tex->ident), &out);
if (i)
{
out.mipcount = i;
Image_WriteKTXFile(va("textures/%s.ktx", tex->ident), &out);
}
while (i-- > 0)
if (out.mip[i].needfree)
BZ_Free(out.mip[i].data);
}
}
#endif

View File

@ -1066,14 +1066,15 @@ static struct charcache_s *Font_TryLoadGlyph(font_t *f, CHARIDXTYPE charidx)
if (qface->ft.activeheight != f->charheight)
{
qface->ft.activeheight = f->charheight;
if (FT_HAS_FIXED_SIZES(face))
if (FT_HAS_FIXED_SIZES(face) && !FT_IS_SCALABLE(face))
{ //freetype doesn't like scaling these for us, so we have to pick a usable size ourselves.
FT_Int best = 0, s;
int bestheight = 0, h;
for (s = 0; s < qface->ft.face->num_fixed_sizes; s++)
{
h = qface->ft.face->available_sizes[s].height;
if (h >= f->charheight && h < bestheight)
//always try to pick the smallest size that is also >= our target size
if ((h > bestheight && bestheight < f->charheight) || (h >= f->charheight && h < bestheight))
{
bestheight = h;
best = s;
@ -1106,8 +1107,10 @@ static struct charcache_s *Font_TryLoadGlyph(font_t *f, CHARIDXTYPE charidx)
nw = (bm->width*nh)/bm->rows;
}
else
nw = nh = 0;
if (bm->pixel_mode == FT_PIXEL_MODE_BGRA)
nw = f->charheight, nh = 0;
if (!nw || !nh)
c = Font_LoadGlyphData(f, charidx, FT_PIXEL_MODE_GRAY, NULL, nw, nh, 0);
else if (bm->pixel_mode == FT_PIXEL_MODE_BGRA)
{
unsigned int *out = alloca(nw*nh*sizeof(*out));
Image_ResampleTexture((void*)bm->buffer, bm->width, bm->rows, out, nw, nh);
@ -1529,7 +1532,7 @@ qboolean Font_LoadFreeTypeFont(struct font_s *f, int height, const char *fontfil
#endif
if (!error)
{
if (FT_HAS_FIXED_SIZES(face))
if (FT_HAS_FIXED_SIZES(face) && !FT_IS_SCALABLE(face))
{
height = 0; //will need to rescale manually I guess
error = pFT_Select_Size(face, 0);

View File

@ -766,7 +766,7 @@ qboolean HTTP_ServerPoll(qboolean httpserverwanted, int portnum) //loop while tr
}
cl = IWebMalloc(sizeof(HTTP_active_connections_t));
NET_SockadrToString(cl->peername, sizeof(cl->peername), &from);
NET_SockadrToString(cl->peername, sizeof(cl->peername), &from, sizeof(from));
IWebPrintf("%s: New http connection\n", cl->peername);
cl->datasock = clientsock;

View File

@ -3,6 +3,12 @@
#include "qcc.h"
#include <math.h>
#if defined(_WIN32) || defined(__DJGPP__)
#include <malloc.h>
#elif !defined(alloca) //alloca.h isn't present on bsd (stdlib.h should define it to __builtin_alloca, and we can check for that here).
#include <alloca.h>
#endif
/*
TODO:
*foo++ = 5;

View File

@ -3590,7 +3590,7 @@ static void QCBUILTIN PF_sound (pubprogfuncs_t *prinst, struct globalvars_s *pr_
else
{
//QW uses channel&8 to mean reliable.
chflags = (channel & 8)?CF_RELIABLE:0;
chflags = (channel & 8)?CF_SV_RELIABLE:0;
//demangle it so the upper bits are still useful.
channel = (channel & 7) | ((channel & ~15) >> 1);
}
@ -8385,7 +8385,7 @@ static void QCBUILTIN PF_h2StopSound(pubprogfuncs_t *prinst, struct globalvars_s
entity = G_EDICT(prinst, OFS_PARM0);
channel = G_FLOAT(OFS_PARM1);
SVQ1_StartSound (NULL, (wedict_t*)entity, channel, NULL, 1, 0, 0, 0, CF_RELIABLE);
SVQ1_StartSound (NULL, (wedict_t*)entity, channel, NULL, 1, 0, 0, 0, CF_SV_RELIABLE);
}
static void QCBUILTIN PF_h2updatesoundpos(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
@ -12096,14 +12096,14 @@ void PR_DumpPlatform_f(void)
{"CHAN_BODY", "const float", QW|NQ|CS, NULL, CHAN_BODY},
{"CHANF_RELIABLE", "const float", QW, D("Only valid if the flags argument is not specified. The sound will be sent reliably, which is important if it is intended to replace looping sounds on doors etc."), 8},
{"SOUNDFLAG_RELIABLE", "const float", QW|NQ, D("The sound will be sent reliably, and without regard to phs."), CF_RELIABLE},
{"SOUNDFLAG_ABSVOLUME", "const float", /*QW|NQ|*/CS,D("The sample's volume is not scaled by the volume cvar. Use with caution"), CF_ABSVOLUME},
{"SOUNDFLAG_RELIABLE", "const float", QW|NQ, D("The sound will be sent reliably, and without regard to phs."), CF_SV_RELIABLE},
{"SOUNDFLAG_ABSVOLUME", "const float", CS, D("The sample's volume is not scaled by the volume cvar. Use with caution"), CF_CL_ABSVOLUME},
{"SOUNDFLAG_FORCELOOP", "const float", QW|NQ|CS, D("The sound will restart once it reaches the end of the sample."), CF_FORCELOOP},
{"SOUNDFLAG_NOSPACIALISE", "const float", /*QW|NQ|*/CS,D("The different audio channels are played at the same volume regardless of which way the player is facing, without needing to use 0 attenuation."), CF_NOSPACIALISE},
{"SOUNDFLAG_NOREVERB", "const float", QW|NQ|CS, D("Disables the use of underwater/reverb effects on this sound effect."), CF_NOREVERB},
{"SOUNDFLAG_FOLLOW", "const float", QW|NQ|CS, D("The sound's origin will updated to follow the emitting entity."), CF_FOLLOW},
{"SOUNDFLAG_UNICAST", "const float", QW|NQ, D("The sound will be heard only by the player specified by msg_entity."), CF_UNICAST},
{"SOUNDFLAG_SENDVELOCITY", "const float", QW|NQ, D("The entity's current velocity will be sent to the client, only useful if doppler is enabled."), CF_SENDVELOCITY},
{"SOUNDFLAG_UNICAST", "const float", QW|NQ, D("The sound will be sent only by the player specified by msg_entity. Spectators and related splitscreen players will also hear the sound."), CF_SV_UNICAST},
{"SOUNDFLAG_SENDVELOCITY", "const float", QW|NQ, D("The entity's current velocity will be sent to the client, only useful if doppler is enabled."), CF_SV_SENDVELOCITY},
{"ATTN_NONE", "const float", QW|NQ|CS, D("Sounds with this attenuation can be heard throughout the map"), ATTN_NONE},
{"ATTN_NORM", "const float", QW|NQ|CS, D("Standard attenuation"), ATTN_NORM},

View File

@ -1410,7 +1410,7 @@ static int bi_lua_walkmove(lua_State *L)
// save program state, because World_movestep may call other progs
oldself = *world->g.self;
lua_pushboolean(L, World_movestep(world, ent, move, axis, true, false, NULL, NULL));
lua_pushboolean(L, World_movestep(world, ent, move, axis, true, false, NULL));
// restore program state
*world->g.self = oldself;
@ -2367,6 +2367,7 @@ static void my_lua_registerbuiltins(lua_State *L)
registerfuncd(loadlua); //should probably use 'require' instead.
registerfuncn(vec3);
registerfuncn(field);
#undef qtrue
registerfuncn(qtrue); //for auto-converted code that tests for truth amongst a myriad of different custom types...
registerfunc(setmodel);
@ -2898,7 +2899,7 @@ static int QDECL Lua_LoadEnts(pubprogfuncs_t *pf, const char *mapstring, void *c
return sv.world.edict_size;
}
static eval_t *QDECL Lua_GetEdictFieldValue(pubprogfuncs_t *pf, edict_t *e, char *fieldname, etype_t type, evalc_t *cache)
static eval_t *QDECL Lua_GetEdictFieldValue(pubprogfuncs_t *pf, edict_t *e, const char *fieldname, etype_t type, evalc_t *cache)
{
eval_t *val;
luafld_t *fld;
@ -3027,7 +3028,7 @@ static const char *ASMCALL QDECL Lua_StringToNative(pubprogfuncs_t *prinst, stri
return ret;
}
static void Lua_Event_Touch(world_t *w, wedict_t *s, wedict_t *o)
static void Lua_Event_Touch(world_t *w, wedict_t *s, wedict_t *o, trace_t *trace)
{
int oself = pr_global_struct->self;
int oother = pr_global_struct->other;

View File

@ -897,7 +897,7 @@ static qintptr_t QVM_Sound (void *offset, quintptr_t mask, const qintptr_t *arg)
if (channel & 8)
{ //based on quakeworld, remember
channel = (channel & 7) | ((channel&~15)>>1);
flags |= CF_RELIABLE;
flags |= CF_SV_RELIABLE;
}
SVQ1_StartSound (NULL, (wedict_t*)Q1QVMPF_EdictNum(svprogfuncs, VM_LONG(arg[0])), channel, VM_POINTER(arg[2]), VM_FLOAT(arg[3])*255, VM_FLOAT(arg[4]), 0, 0, flags);
return 0;

View File

@ -1556,7 +1556,7 @@ static void SV_SoundMulticast(client_t *client, sizebuf_t *msg, void *vctx)
void SV_StartSound (int ent, vec3_t origin, float *velocity, int seenmask, int channel, const char *sample, int volume, float attenuation, float ratemul, float timeofs, unsigned int chflags)
{
qboolean use_phs;
qboolean reliable = chflags & CF_RELIABLE;
qboolean reliable = chflags & CF_SV_RELIABLE;
struct startsoundcontext_s ctx;
if (volume < 0 || volume > 255)
@ -1635,7 +1635,7 @@ void SV_StartSound (int ent, vec3_t origin, float *velocity, int seenmask, int c
else
use_phs = attenuation!=0;
if (chflags & CF_UNICAST)
if (chflags & CF_SV_UNICAST)
{
SV_MulticastCB(origin, reliable ? MULTICAST_ONE_R_SPECS : MULTICAST_ONE_SPECS, seenmask, SV_SoundMulticast, &ctx);
}
@ -1667,7 +1667,7 @@ void QDECL SVQ1_StartSound (float *origin, wedict_t *wentity, int channel, const
//making them all reliable avoids packetloss and phs issues.
//this applies only to pushers. you won't get extra latency on player actions because of this.
//be warned that it does mean you might be able to hear people triggering stuff on the other side of the map however.
chflags |= CF_RELIABLE;
chflags |= CF_SV_RELIABLE;
}
else if (progstype == PROG_QW)
{ //quakeworld puts the sound ONLY at the entity's actual origin. this is annoying and stupid. I'm not really sure what to do here. it seems wrong.
@ -1679,7 +1679,7 @@ void QDECL SVQ1_StartSound (float *origin, wedict_t *wentity, int channel, const
origin[i] = entity->v->origin[i]+0.5*(entity->v->mins[i]+entity->v->maxs[i]);
}
if (chflags & CF_SENDVELOCITY)
if (chflags & CF_SV_SENDVELOCITY)
velocity = entity->v->velocity;
}

View File

@ -3,9 +3,11 @@
#include <ctype.h>
//ezquake sucks. I'd fix these, but that'd make diffs more messy.
#pragma GCC diagnostic ignored "-Wold-style-definition"
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wold-style-definition"
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
#endif
//ezquake types.
#define byte qbyte