diff --git a/CMakeLists.txt b/CMakeLists.txt index 963aae37..22e3f8e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,6 +154,7 @@ IF(CMAKE_C_COMPILER_ID MATCHES "GNU") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes") # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wold-style-definition") #k&r c is weird and can't cope with 64bit types. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wold-style-declaration") # + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith") #void* stuff SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wvla") #msvc doesn't support vla SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdeclaration-after-statement") #msvc doesn't allow defs after statements, and they're so very tempting... #SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wc++-compat") #lul diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 6cabf617..25aaa5e1 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -4405,6 +4405,11 @@ void CL_Fog_f(void) if (Cmd_FromGamecode()) cl.fog_locked = !!cl.fog[ftype].density; + +#ifdef HAVE_LEGACY + if (cl.fog[ftype].colour[0] > 1 || cl.fog[ftype].colour[1] > 1 || cl.fog[ftype].colour[2] > 1) + Con_DPrintf(CON_WARNING "Fog is oversaturated. This can result in compatibility issues.\n"); +#endif } } diff --git a/engine/client/cl_pred.c b/engine/client/cl_pred.c index 12ae57fd..9293a97d 100644 --- a/engine/client/cl_pred.c +++ b/engine/client/cl_pred.c @@ -668,7 +668,9 @@ void CL_CalcClientTime(void) else cl.servertime = 0; - if (cl.servertime > min) + if (!cl.oldgametime) + cl.servertime = max; //map start (or reload/connect or something). snap to current. + else if (cl.servertime > min) { if (cl.servertime > max) { diff --git a/engine/client/cl_screen.c b/engine/client/cl_screen.c index e9bedc94..0326bf6b 100644 --- a/engine/client/cl_screen.c +++ b/engine/client/cl_screen.c @@ -2936,7 +2936,7 @@ void SCR_ScreenShot_Cubemap_f(void) break; //zomgwtfbbq } - Image_FlipImage(facedata, mips.mip[0].data + i*mips.mip[0].datasize/6, &fbwidth, &fbheight, bb, sides[i].horizontalflip, sides[i].verticalflip, false); + Image_FlipImage(facedata, (qbyte*)mips.mip[0].data + i*mips.mip[0].datasize/6, &fbwidth, &fbheight, bb, sides[i].horizontalflip, sides[i].verticalflip, false); BZ_Free(facedata); } if (i == 6) diff --git a/engine/client/image.c b/engine/client/image.c index dfced236..c415c6b4 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -2649,6 +2649,7 @@ qbyte *ReadPCXFile(qbyte *buf, int length, int *width, int *height) || pcx->version != 5 || pcx->encoding != 1 || pcx->bits_per_pixel != 8 + || pcx->color_planes != 1 || swidth >= 1024 || sheight >= 1024) { @@ -4890,7 +4891,7 @@ qboolean Image_WriteKTXFile(const char *filename, enum fs_relative fsroot, struc case PTI_RGBA5551: header.glinternalformat = 0x8057/*GL_RGB5_A1*/; header.glbaseinternalformat = 0x1908/*GL_RGBA*/; header.glformat = 0x1908/*GL_RGBA*/; header.gltype = 0x8034/*GL_UNSIGNED_SHORT_5_5_5_1*/; header.gltypesize = 2; break; case PTI_ARGB1555: header.glinternalformat = 0x8057/*GL_RGB5_A1*/; header.glbaseinternalformat = 0x1908/*GL_RGBA*/; header.glformat = 0x80E1/*GL_BGRA*/; header.gltype = 0x8366/*GL_UNSIGNED_SHORT_1_5_5_5_REV*/; header.gltypesize = 2; break; case PTI_DEPTH16: header.glinternalformat = 0x81A5/*GL_DEPTH_COMPONENT16*/; header.glbaseinternalformat = 0x1902/*GL_DEPTH_COMPONENT*/; header.glformat = 0x1902/*GL_DEPTH_COMPONENT*/; header.gltype = 0x1403/*GL_UNSIGNED_SHORT*/; header.gltypesize = 2; break; - case PTI_DEPTH24: header.glinternalformat = 0x81A6/*GL_DEPTH_COMPONENT24*/; header.glbaseinternalformat = 0x1902/*GL_DEPTH_COMPONENT*/; header.glformat = 0x1902/*GL_DEPTH_COMPONENT*/; header.gltype = 0x1405/*GL_UNSIGNED_INT*/; header.gltypesize = 4; break; + case PTI_DEPTH24: header.glinternalformat = 0x81A6/*GL_DEPTH_COMPONENT24*/; header.glbaseinternalformat = 0x1902/*GL_DEPTH_COMPONENT*/; header.glformat = 0x1902/*GL_DEPTH_COMPONENT*/; header.gltype = 0x1405/*GL_UNSIGNED_INT*/; header.gltypesize = 3; break; case PTI_DEPTH32: header.glinternalformat = 0x81A7/*GL_DEPTH_COMPONENT32*/; header.glbaseinternalformat = 0x1902/*GL_DEPTH_COMPONENT*/; header.glformat = 0x1902/*GL_DEPTH_COMPONENT*/; header.gltype = 0x1406/*GL_FLOAT*/; header.gltypesize = 4; break; case PTI_DEPTH24_8: header.glinternalformat = 0x88F0/*GL_DEPTH24_STENCIL8*/; header.glbaseinternalformat = 0x84F9/*GL_DEPTH_STENCIL*/; header.glformat = 0x84F9/*GL_DEPTH_STENCIL*/; header.gltype = 0x84FA/*GL_UNSIGNED_INT_24_8*/; header.gltypesize = 4; break; @@ -4947,7 +4948,7 @@ qboolean Image_WriteKTXFile(const char *filename, enum fs_relative fsroot, struc unsigned int pad = 0, y; for (y = 0; y < brows; y++) { - VFS_WRITE(file, mips->mip[mipnum].data + browbytes*y, browbytes); + VFS_WRITE(file, (qbyte*)mips->mip[mipnum].data + browbytes*y, browbytes); VFS_WRITE(file, &pad, 4-(browbytes&3)); } } @@ -4959,39 +4960,50 @@ qboolean Image_WriteKTXFile(const char *filename, enum fs_relative fsroot, struc VFS_CLOSE(file); return true; } + +#define LongSwap(i) (((i&0xff000000) >> 24)|((i&0x00ff0000) >> 8)|((i&0x0000ff00) << 8)|((i&0x000000ff) << 24)) +#define ShortSwap(i) (((i&0xff00) >> 8)|((i&0x00ff) << 8)) static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const char *fname, qbyte *filedata, size_t filesize) { static const char magic[12] = {0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A}; - ktxheader_t *header; + ktxheader_t header; int nummips; int mipnum; int face; int datasize; - unsigned int w, h, d, f, l, browbytes,padbytes,y,rows; + unsigned int w, h, d, f, l, browbytes,padbytes,y,x,rows; struct pendingtextureinfo *mips; int encoding = TF_INVALID; - qbyte *fileend = filedata + filesize; + const qbyte *fileend = filedata + filesize; unsigned int blockwidth, blockheight, blockbytes; - if (filesize < sizeof(magic) || memcmp(filedata, magic, sizeof(magic))) + if (filesize < sizeof(ktxheader_t) || memcmp(filedata, magic, sizeof(magic))) return NULL; //not a ktx file - header = (ktxheader_t*)filedata; - nummips = header->numberofmipmaplevels; + header = *(const ktxheader_t*)filedata; + if (header.endianness == 0x01020304) + { //swap the rest of the header. + for (w = offsetof(ktxheader_t, endianness); w < sizeof(ktxheader_t); w+=sizeof(int)) + ((int*)&header)[w/sizeof(int)] = LongSwap(((int*)&header)[w/sizeof(int)]); + } + else if (header.endianness != 0x04030201) + return NULL; + + nummips = header.numberofmipmaplevels; if (nummips < 1) nummips = 1; // if (header->numberofarrayelements != 0) // return NULL; //don't support array textures - if (header->numberoffaces == 1) + if (header.numberoffaces == 1) ; //non-cubemap - else if (header->numberoffaces == 6) + else if (header.numberoffaces == 6) { - if (header->numberofarrayelements != 0) + if (header.numberofarrayelements != 0) return NULL; //don't support array textures - if (header->pixeldepth != 0) + if (header.pixeldepth != 0) return NULL; // if (header->numberofmipmaplevels != 1) // return false; //only allow cubemaps that have no mips @@ -5002,7 +5014,7 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch // return NULL; //we only support 3d textures where width+height+depth are the same. too lazy to change it now. /*FIXME: validate format+type for non-compressed formats*/ - switch(header->glinternalformat) + switch(header.glinternalformat) { case 0x8D64/*GL_ETC1_RGB8_OES*/: encoding = PTI_ETC1_RGB8; break; case 0x9270/*GL_COMPRESSED_R11_EAC*/: encoding = PTI_EAC_R11; break; @@ -5061,9 +5073,9 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch case 0x93DD/*GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR*/: encoding = PTI_ASTC_12X12_SRGB; break; case 0x80E1/*GL_BGRA_EXT*/: encoding = PTI_BGRA8; break; //not even an internal format case 0x1908/*GL_RGBA*/: - case 0x8058/*GL_RGBA8*/: encoding = (header->glformat==0x80E1/*GL_BGRA*/)?PTI_BGRA8:PTI_RGBA8; break; //unsized types shouldn't really be here + case 0x8058/*GL_RGBA8*/: encoding = (header.glformat==0x80E1/*GL_BGRA*/)?PTI_BGRA8:PTI_RGBA8; break; //unsized types shouldn't really be here case 0x805B/*GL_RGBA16*/: encoding = PTI_RGBA16; break; - case 0x8C43/*GL_SRGB8_ALPHA8*/: encoding = (header->glformat==0x80E1/*GL_BGRA*/)?PTI_BGRA8_SRGB:PTI_RGBA8_SRGB; break; + case 0x8C43/*GL_SRGB8_ALPHA8*/: encoding = (header.glformat==0x80E1/*GL_BGRA*/)?PTI_BGRA8_SRGB:PTI_RGBA8_SRGB; break; case 0x8040/*GL_LUMINANCE8*/: encoding = PTI_L8; break; case 0x8045/*GL_LUMINANCE8_ALPHA8*/: encoding = PTI_L8A8; break; case 0x881A/*GL_RGBA16F_ARB*/: encoding = PTI_RGBA16F; break; @@ -5083,9 +5095,9 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch case 0x8C40/*GL_SRGB*/: case 0x8C41/*GL_SRGB8*/: - if (header->glformat==0x80E1/*GL_BGRA*/) + if (header.glformat==0x80E1/*GL_BGRA*/) encoding = PTI_BGRX8_SRGB; - else if (header->glformat==0x1908/*GL_RGBA*/) + else if (header.glformat==0x1908/*GL_RGBA*/) encoding = PTI_RGBX8_SRGB; break; @@ -5094,41 +5106,41 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch case 0x8C3D/*GL_RGB9_E5*/: case 0x8D62/*GL_RGB565*/: case 0x8C3A/*GL_R11F_G11F_B10F*/: - if (header->glformat == 0x80E0/*GL_BGR*/) + if (header.glformat == 0x80E0/*GL_BGR*/) encoding = PTI_BGR8; - else if (header->glformat == 0x80E1/*GL_BGRA*/) + else if (header.glformat == 0x80E1/*GL_BGRA*/) encoding = PTI_BGRX8; - else if (header->glformat == 0x1907/*GL_RGB*/) + else if (header.glformat == 0x1907/*GL_RGB*/) { - if (header->gltype == 0x8C3B/*GL_UNSIGNED_INT_10F_11F_11F_REV*/) + if (header.gltype == 0x8C3B/*GL_UNSIGNED_INT_10F_11F_11F_REV*/) encoding = PTI_B10G11R11F; - else if (header->gltype == 0x8C3E/*GL_UNSIGNED_INT_5_9_9_9_REV*/) + else if (header.gltype == 0x8C3E/*GL_UNSIGNED_INT_5_9_9_9_REV*/) encoding = PTI_E5BGR9; - else if (header->gltype == 0x8363/*GL_UNSIGNED_SHORT_5_6_5*/) + else if (header.gltype == 0x8363/*GL_UNSIGNED_SHORT_5_6_5*/) encoding = PTI_RGB565; else encoding = PTI_RGB8; } - else if (header->glformat == 0x1908/*GL_RGBA*/) + else if (header.glformat == 0x1908/*GL_RGBA*/) encoding = PTI_RGBX8; else encoding = PTI_RGB8; break; case 0x8056/*GL_RGBA4*/: case 0x8057/*GL_RGB5_A1*/: - if (header->glformat == 0x1908/*GL_RGBA*/ && header->gltype == 0x8034/*GL_UNSIGNED_SHORT_5_5_5_1*/) + if (header.glformat == 0x1908/*GL_RGBA*/ && header.gltype == 0x8034/*GL_UNSIGNED_SHORT_5_5_5_1*/) encoding = PTI_RGBA5551; - else if (header->glformat == 0x80E1/*GL_BGRA*/ && header->gltype == 0x8366/*GL_UNSIGNED_SHORT_1_5_5_5_REV*/) + else if (header.glformat == 0x80E1/*GL_BGRA*/ && header.gltype == 0x8366/*GL_UNSIGNED_SHORT_1_5_5_5_REV*/) encoding = PTI_ARGB1555; - else if (header->glformat == 0x1908/*GL_RGBA*/ && header->gltype == 0x8033/*GL_UNSIGNED_SHORT_4_4_4_4*/) + else if (header.glformat == 0x1908/*GL_RGBA*/ && header.gltype == 0x8033/*GL_UNSIGNED_SHORT_4_4_4_4*/) encoding = PTI_RGBA4444; - else if (header->glformat == 0x80E1/*GL_BGRA*/ && header->gltype == 0x8365/*GL_UNSIGNED_SHORT_4_4_4_4_REV*/) + else if (header.glformat == 0x80E1/*GL_BGRA*/ && header.gltype == 0x8365/*GL_UNSIGNED_SHORT_4_4_4_4_REV*/) encoding = PTI_ARGB4444; break; } if (encoding == TF_INVALID) { - Con_Printf("Unsupported ktx internalformat %x in %s\n", header->glinternalformat, fname); + Con_Printf("Unsupported ktx internalformat %x in %s\n", header.glinternalformat, fname); return NULL; } @@ -5140,13 +5152,13 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch mips = Z_Malloc(sizeof(*mips)); mips->mipcount = 0; - if (header->pixeldepth) + if (header.pixeldepth) mips->type = PTI_3D; - else if (header->numberoffaces==6) + else if (header.numberoffaces==6) { - if (header->numberofarrayelements) + if (header.numberofarrayelements) { - header->pixeldepth = header->numberofarrayelements*6; + header.pixeldepth = header.numberofarrayelements*6; mips->type = PTI_CUBE_ARRAY; } else @@ -5154,39 +5166,42 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch } else { - if (header->numberofarrayelements) + if (header.numberofarrayelements) { - header->pixeldepth = header->numberofarrayelements; + header.pixeldepth = header.numberofarrayelements; mips->type = PTI_2D_ARRAY; } else { - header->pixeldepth = 1; + header.pixeldepth = 1; mips->type = PTI_2D; } } mips->extrafree = filedata; mips->encoding = encoding; - filedata += sizeof(*header); //skip the header... - filedata += header->bytesofkeyvaluedata; //skip the keyvalue stuff + filedata += sizeof(header); //skip the header... + filedata += header.bytesofkeyvaluedata; //skip the keyvalue stuff - if (nummips * header->numberoffaces > countof(mips->mip)) - nummips = countof(mips->mip) / header->numberoffaces; + if (nummips * header.numberoffaces > countof(mips->mip)) + nummips = countof(mips->mip) / header.numberoffaces; Image_BlockSizeForEncoding(encoding, &blockbytes, &blockwidth, &blockheight); - w = header->pixelwidth; - h = max(1, header->pixelheight); - d = max(1, header->pixeldepth); - f = max(1, header->numberoffaces); - l = max(1, header->numberofarrayelements); + w = header.pixelwidth; + h = max(1, header.pixelheight); + d = max(1, header.pixeldepth); + f = max(1, header.numberoffaces); + l = max(1, header.numberofarrayelements); for (mipnum = 0; mipnum < nummips; mipnum++) { datasize = *(int*)filedata; filedata += 4; + if (header.endianness == 0x01020304) + datasize = LongSwap(datasize); + browbytes = blockbytes * ((w+blockwidth-1)/blockwidth); padbytes = (browbytes & 3)?4-(browbytes&3):0; rows = ((h+blockheight-1)/blockheight)*d; @@ -5208,15 +5223,31 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch mips->mip[mips->mipcount].height = h; mips->mip[mips->mipcount].depth = d*l*f; - if (padbytes) - { - //gah + if (padbytes || header.endianness == 0x01020304) + { //gah. + //the ktx format is 4-byte aligned. our internal representation is tightly packed (consistent with everything but gl). + //in the case of byteswapping, any data types should work out okay (no misaligned stuff). rows *= l*f; mips->mip[mips->mipcount].needfree = true; mips->mip[mips->mipcount].datasize = browbytes * rows; mips->mip[mips->mipcount].data = BZ_Malloc(mips->mip[mips->mipcount].datasize); - for (y = 0; y < rows; y++) - memcpy(mips->mip[mips->mipcount].data + y*browbytes, filedata + y*browbytes+padbytes, browbytes); + if (header.gltypesize == 4 && header.endianness == 0x01020304) + { + for (y = 0; y < rows; y++) + for (x = 0; x < browbytes>>2; x++) + ((int*)((qbyte*)mips->mip[mips->mipcount].data + y*browbytes))[x] = LongSwap(((int*)filedata + y*browbytes+padbytes)[x]); + } + else if (header.gltypesize == 2 && header.endianness == 0x01020304) + { + for (y = 0; y < rows; y++) + for (x = 0; x < browbytes>>1; x++) + ((short*)((qbyte*)mips->mip[mips->mipcount].data + y*browbytes))[x] = ShortSwap(((short*)filedata + y*browbytes+padbytes)[x]); + } + else + { //erk, panic... + for (y = 0; y < rows; y++) + memcpy((qbyte*)mips->mip[mips->mipcount].data + y*browbytes, filedata + y*browbytes+padbytes, browbytes); + } } else { @@ -5241,7 +5272,7 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch #ifdef ASTC_WITH_HDRTEST if (encoding >= PTI_ASTC_4X4_LDR && encoding <= PTI_ASTC_12X12_LDR) { - for (face = 0; face < header->numberoffaces; face++) + for (face = 0; face < header.numberoffaces; face++) { if (ASTC_BlocksAreHDR(mips->mip[face].data, mips->mip[face].datasize, blockwidth, blockheight, 1)) { //convert it to one of the hdr formats if we can. @@ -6014,7 +6045,7 @@ qboolean Image_WriteDDSFile(const char *filename, enum fs_relative fsroot, struc for (mipnum = 0; mipnum < h9.dwMipMapCount; mipnum++) { size_t sz = mips->mip[mipnum].datasize / arraysize; - VFS_WRITE(file, mips->mip[mipnum].data + sz*a, sz); + VFS_WRITE(file, (qbyte*)mips->mip[mipnum].data + sz*a, sz); } } @@ -12286,7 +12317,7 @@ static struct pendingtextureinfo *Image_LoadCubemapTextureData(const char *nicen if (!(texflags&IF_NOGAMMA) && !vid_hardwaregamma.value) BoostGamma(data, width, height, format); - Image_FlipImage(data, mips->mip[0].data + i*width*height*bb, &width, &height, bb, cmscheme[j][i].flipx, cmscheme[j][i].flipy, cmscheme[j][i].flipd); + Image_FlipImage(data, (qbyte*)mips->mip[0].data + i*width*height*bb, &width, &height, bb, cmscheme[j][i].flipx, cmscheme[j][i].flipy, cmscheme[j][i].flipd); BZ_Free(data); BZ_Free(buf); diff --git a/engine/client/in_generic.c b/engine/client/in_generic.c index e6a5c554..6cd947d2 100644 --- a/engine/client/in_generic.c +++ b/engine/client/in_generic.c @@ -97,7 +97,7 @@ static cvar_t joy_anglesens[3] = { #define ANGLESENSDESC "Scaler value for the controller when it is at its most extreme value" CVARD("joypitchsensitivity", "0.5", ANGLESENSDESC), - CVARD("joyyawsensitivity", "-1.0", ANGLESENSDESC), + CVARD("joyyawsensitivity", "1.0", ANGLESENSDESC), CVARD("joyrollsensitivity", "1.0", ANGLESENSDESC) }; static cvar_t joy_movesens[3] = diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index d19489e7..983831df 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -6968,14 +6968,14 @@ static struct { {"generateentitydata", PF_generateentitydata, 0}, {"stringtokeynum_menu", PF_cl_stringtokeynum, 614}, - {"resethostcachemasks", PF_cl_resethostcachemasks, 615}, - {"sethostcachemaskstring", PF_cl_sethostcachemaskstring,616}, - {"sethostcachemasknumber", PF_cl_sethostcachemasknumber,617}, - {"resorthostcache", PF_cl_resorthostcache, 618}, - {"sethostcachesort", PF_cl_sethostcachesort, 619}, - {"refreshhostcache", PF_cl_refreshhostcache, 620}, - {"gethostcachenumber", PF_cl_gethostcachenumber, 621}, - {"gethostcacheindexforkey", PF_cl_gethostcacheindexforkey,622}, + {"resethostcachemasks", PF_cl_resethostcachemasks, 615}, + {"sethostcachemaskstring", PF_cl_sethostcachemaskstring, 616}, + {"sethostcachemasknumber", PF_cl_sethostcachemasknumber, 617}, + {"resorthostcache", PF_cl_resorthostcache, 618}, + {"sethostcachesort", PF_cl_sethostcachesort, 619}, + {"refreshhostcache", PF_cl_refreshhostcache, 620}, + {"gethostcachenumber", PF_cl_gethostcachenumber, 621}, + {"gethostcacheindexforkey", PF_cl_gethostcacheindexforkey, 622}, {"addwantedhostcachekey", PF_cl_addwantedhostcachekey, 623}, #ifdef CL_MASTER {"getextresponse", PF_cl_getextresponse, 624}, @@ -6983,16 +6983,35 @@ static struct { {"netaddress_resolve", PF_netaddress_resolve, 625}, {"getgamedirinfo", PF_cl_getgamedirinfo, 626}, {"sprintf", PF_sprintf, 627}, - {"getsurfacenumtriangles", PF_getsurfacenumtriangles,628}, + {"getsurfacenumtriangles", PF_getsurfacenumtriangles, 628}, {"getsurfacetriangle", PF_getsurfacetriangle, 629}, {"setkeybind", PF_cl_setkeybind, 630}, {"getbindmaps", PF_cl_GetBindMap, 631}, {"setbindmaps", PF_cl_SetBindMap, 632}, - +// {NULL, PF_Fixme, 643}, +// {NULL, PF_Fixme, 644}, +// {NULL, PF_Fixme, 645}, +// {NULL, PF_Fixme, 646}, +// {NULL, PF_Fixme, 647}, +// {NULL, PF_Fixme, 648}, {"digest_hex", PF_digest_hex, 639}, {"digest_ptr", PF_digest_ptr, 0}, {"V_CalcRefdef", PF_V_CalcRefdef, 640}, +// {NULL, PF_Fixme, 641}, +// {NULL, PF_Fixme, 642}, +// {NULL, PF_Fixme, 643}, +// {NULL, PF_Fixme, 644}, +// {NULL, PF_Fixme, 645}, +// {NULL, PF_Fixme, 646}, +// {NULL, PF_Fixme, 647}, +// {NULL, PF_Fixme, 648}, +// {NULL, PF_Fixme, 649}, + {"fcopy", PF_fcopy, 650}, + {"frename", PF_frename, 651}, + {"fremove", PF_fremove, 652}, + {"fexists", PF_fexists, 653}, + {"rmtree", PF_rmtree, 654}, {NULL} }; diff --git a/engine/client/pr_menu.c b/engine/client/pr_menu.c index 83741a20..b3956784 100644 --- a/engine/client/pr_menu.c +++ b/engine/client/pr_menu.c @@ -2567,6 +2567,19 @@ static struct { {"digest_ptr", PF_digest_ptr, 0}, // {NULL, PF_Fixme, 640}, {"crypto_getmyidstatus", PF_crypto_getmyidfp, 641}, +// {NULL, PF_Fixme, 642}, +// {NULL, PF_Fixme, 643}, +// {NULL, PF_Fixme, 644}, +// {NULL, PF_Fixme, 645}, +// {NULL, PF_Fixme, 646}, +// {NULL, PF_Fixme, 647}, +// {NULL, PF_Fixme, 648}, +// {NULL, PF_Fixme, 649}, + {"fcopy", PF_fcopy, 650}, + {"frename", PF_frename, 651}, + {"fremove", PF_fremove, 652}, + {"fexists", PF_fexists, 653}, + {"rmtree", PF_rmtree, 654}, {"setlocaluserinfo", PF_cl_setlocaluserinfo, 0}, @@ -2849,6 +2862,11 @@ pbool PDECL Menu_CheckHeaderCrc(pubprogfuncs_t *inst, progsnum_t idx, int crc, c if (crc == 10020) return true; //its okay Con_Printf("progs crc is invalid for %s\n", filename); + if (crc == 12776) + { //whoever wrote wrath fucked up. + Con_Printf("(please correct .src include orders)\n"); + return true; + } return false; } diff --git a/engine/client/renderer.c b/engine/client/renderer.c index b6e90b09..6370c5cc 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -2480,8 +2480,8 @@ Returns the proper texture for a given time and base texture */ texture_t *R_TextureAnimation (int frame, texture_t *base) { - int reletive; - int count; + unsigned int relative; + int count; if (frame) { @@ -2492,10 +2492,10 @@ texture_t *R_TextureAnimation (int frame, texture_t *base) if (!base->anim_total) return base; - reletive = (int)(cl.time*10) % base->anim_total; + relative = (unsigned int)(cl.time*10) % base->anim_total; count = 0; - while (base->anim_min > reletive || base->anim_max <= reletive) + while (base->anim_min > relative || base->anim_max <= relative) { base = base->anim_next; if (!base) @@ -3041,7 +3041,7 @@ void R_SetFrustum (float projmat[16], float viewmat[16]) //do far plane //fog will logically not actually reach 0, though precision issues will force it. we cut off at an exponant of -500 - if (r_refdef.globalfog.density && r_refdef.globalfog.alpha>=1 && r_fog_cullentities.ival && !r_refdef.globalfog.depthbias) + if (r_refdef.globalfog.density && r_refdef.globalfog.alpha>=1 && (r_fog_cullentities.ival&&r_skyfog.value>=1) && !r_refdef.globalfog.depthbias) { float culldist; float fog; diff --git a/engine/client/snd_al.c b/engine/client/snd_al.c index da9a71d0..7d444c08 100644 --- a/engine/client/snd_al.c +++ b/engine/client/snd_al.c @@ -9,6 +9,23 @@ This means we force distance models and use hacks to avoid bugs in browsers. We also have no doppler with WebAudio. */ +/*Bug list: + + underwater cacaphoy + openal bug with reverb. either disable reverb or disable openal. + + "build/openal-soft-1.19.1/Alc/filters/filter.c:25: BiquadFilter_setParams: Assertion `gain > 0.00001f' failed." + SIGABRT + bug started with 1.19.1. Not fte's bug. either disable reverb or disable openal. + + AL_OUT_OF_MEMORY + shitty openal implementation with too-low limits on number of sources. + + AL_INVALID_VALUE + shitty (apple) openal implementation with too-low limits on number of sources. + +*/ + + #ifdef AVAIL_OPENAL #ifdef FTE_TARGET_WEB @@ -115,6 +132,7 @@ static AL_API void (AL_APIENTRY *palListenerfv)( ALenum param, const ALfloat* va static AL_API void (AL_APIENTRY *palSourcefv)( ALuint sid, ALenum param, const ALfloat* values ); static AL_API const ALchar* (AL_APIENTRY *palGetString)( ALenum param ); static AL_API void (AL_APIENTRY *palGenSources)( ALsizei n, ALuint* sources ); +static AL_API ALboolean (AL_APIENTRY *palIsSource)( ALuint sourceName ); static AL_API void (AL_APIENTRY *palListenerf)( ALenum param, ALfloat value ); static AL_API void (AL_APIENTRY *palDeleteBuffers)( ALsizei n, const ALuint* buffers ); static AL_API void (AL_APIENTRY *palDeleteSources)( ALsizei n, const ALuint* sources ); @@ -296,9 +314,7 @@ static AL_API ALvoid (AL_APIENTRY *palEffectfv)(ALuint effect, ALenum param, con #define SOUNDVARS SDRVNAME" variables" -extern sfx_t *known_sfx; -extern int loaded_sfx; -extern int num_sfx; +extern sfx_t *known_sfx; //sfxindex = (sfx-known_sfx); #ifdef USEEFX static ALuint OpenAL_LoadEffect(const struct reverbproperties_s *reverb); @@ -337,9 +353,20 @@ enum distancemodel_e typedef struct { - ALuint *source; + struct + { + ALuint handle; + qbyte allocated; //there is no guarenteed-unused handle (and I don't want to have to keep spamming alIsSource). + } *source; size_t max_sources; + struct + { + ALuint buffer; + qbyte allocated; //again no guarentee. + } *sounds; + size_t max_sounds; + ALCdevice *OpenAL_Device; ALCcontext *OpenAL_Context; @@ -404,8 +431,8 @@ static qboolean OpenAL_LoadCache(oalinfo_t *oali, unsigned int *bufptr, sfxcache case 0: palGenBuffers(1, bufptr); emscriptenfte_al_loadaudiofile(*bufptr, sc->data, sc->length); - //not allowed to play it yet, because it (probably) doesn't exist yet. - return false; + //alIsBuffer will report false until success or failure... + return true; //but we do have a 'proper' reference to the buffer. #endif case 1: if (sc->numchannels == 2) @@ -593,14 +620,15 @@ static qboolean OpenAL_ReclaimASource(soundcardinfo_t *sc) for (i = 0; i < sc->total_chans; i++) { // channel_t *chan = &sc->channel[i]; - src = oali->source[i]; - if (src) + src = oali->source[i].handle; + if (oali->source[i].allocated) { palGetSourcei(src, AL_SOURCE_STATE, &buf); if (buf != AL_PLAYING) { palDeleteSources(1, &src); - oali->source[i] = 0; + oali->source[i].handle = 0; + oali->source[i].allocated = false; success++; } } @@ -610,11 +638,11 @@ static qboolean OpenAL_ReclaimASource(soundcardinfo_t *sc) { for (i = DYNAMIC_STOP; i < sc->total_chans; i++) { //FIXME: prioritize the furthest - src = oali->source[i]; - if (src) + if (oali->source[i].allocated) { - palDeleteSources(1, &src); - oali->source[i] = 0; + palDeleteSources(1, &oali->source[i].handle); + oali->source[i].handle = 0; + oali->source[i].allocated = false; success++; break; } @@ -631,12 +659,14 @@ static ssamplepos_t OpenAL_GetChannelPos(soundcardinfo_t *sc, channel_t *chan) oalinfo_t *oali = sc->handle; int chnum = chan - sc->channel; ALuint src; - src = oali->source[chnum]; - if (!src) + src = oali->source[chnum].handle; + if (!oali->source[chnum].allocated) return (ssamplepos_t)(~(usamplepos_t)0)>>1; //not actually playing... + //alcMakeContextCurrent + palGetSourcei(src, AL_SAMPLE_OFFSET, &spos); - return spos; + return spos; //FIXME: result is probably going to be wrong when streaming } //schanged says the sample has changed, otherwise its merely moved around a little, maybe changed in volume, but nothing that will restart it. @@ -653,9 +683,9 @@ static void OpenAL_ChannelUpdate(soundcardinfo_t *sc, channel_t *chan, chanupdat if (chnum >= oali->max_sources) { - size_t nc = chnum+1+64; - Z_ReallocElements((void**)&oali->source, &oali->max_sources, nc, sizeof(*oali->source)); - return; + size_t oc = oali->max_sources; + Z_ReallocElements((void**)&oali->source, &oali->max_sources, chnum+1+64, sizeof(*oali->source)); + memset(oali->source+oc, 0, sizeof(*oali->source)*(oali->max_sources-oc)); } //alcMakeContextCurrent @@ -665,25 +695,30 @@ static void OpenAL_ChannelUpdate(soundcardinfo_t *sc, channel_t *chan, chanupdat sfx = NULL; #endif - src = oali->source[chnum]; - if (!src) + src = oali->source[chnum].handle; + if (!oali->source[chnum].allocated) { //not currently playing. be prepared to create one if (!sfx || chan->master_vol == 0) return; + palGetError(); //gah this is so shite palGenSources(1, &src); - //unable to start a new sound source, give up. - if (!src) - { + if (palGetError() || !palIsSource(src)) + { //can't just test for invalid, and failure leaving src unchanged could refer to a different sound. + //try to kill some pther sound if (OpenAL_ReclaimASource(sc)) + { //okay, we killed one. hopefully we can start a new one now. palGenSources(1, &src); - if (!src) - { - PrintALError("alGenSources"); - return; + if (palGetError() || !palIsSource(src)) + { + PrintALError("alGenSources"); + return; + } } + else return; } - oali->source[chnum] = src; + oali->source[chnum].handle = src; + oali->source[chnum].allocated = true; schanged |= CUR_EVERYTHING; //should normally be true anyway, but hey } @@ -734,7 +769,8 @@ static void OpenAL_ChannelUpdate(soundcardinfo_t *sc, channel_t *chan, chanupdat palSourceStop(src); #else palDeleteSources(1, &src); - oali->source[chnum] = 0; + oali->source[chnum].handle = 0; + oali->source[chnum].allocated = false; #endif } return; @@ -751,16 +787,26 @@ static void OpenAL_ChannelUpdate(soundcardinfo_t *sc, channel_t *chan, chanupdat if (schanged || stream) { - if (!sfx->openal_buffer) + int sndnum = sfx-known_sfx; + int buf; + if (sndnum >= oali->max_sounds) + { + size_t oc = oali->max_sounds; + Z_ReallocElements((void**)&oali->sounds, &oali->max_sounds, sndnum+1+64, sizeof(*oali->sounds)); + memset(oali->sounds+oc, 0, sizeof(*oali->sounds)*(oali->max_sounds-oc)); + } + buf = oali->sounds[sndnum].buffer; + if (!oali->sounds[sndnum].allocated || stream) { if (!S_LoadSound(sfx, false)) return; //can't load it if (sfx->loadstate != SLS_LOADED) { if (sfx->loadstate == SLS_LOADING) - { + { //kill the source so that it gets regenerated again soonish palDeleteSources(1, &src); - oali->source[chnum] = 0; + oali->source[chnum].handle = 0; + oali->source[chnum].allocated = false; } return; //not available yet } @@ -868,23 +914,31 @@ static void OpenAL_ChannelUpdate(soundcardinfo_t *sc, channel_t *chan, chanupdat } } else - { + { //unstreamed if (!sfx->decoder.buf) return; - if (!OpenAL_LoadCache(oali, &sfx->openal_buffer, sfx->decoder.buf, 1)) + oali->sounds[sndnum].allocated = OpenAL_LoadCache(oali, &buf, sfx->decoder.buf, 1); + if (!oali->sounds[sndnum].allocated) return; - palSourcei(src, AL_BUFFER, sfx->openal_buffer); + oali->sounds[sndnum].buffer = buf; } } + if (!stream) + { #ifdef FTE_TARGET_WEB - //loading an ogg is async, so we must wait until its valid. - else if (!palIsBuffer(sfx->openal_buffer)) - return; + //loading an ogg is async, so we must wait until its valid. + //our javascript will hack the buffer so that its not valid until the browser has decoded it for us. + if (!palIsBuffer(buf)) + { //same as the SLS_LOADING case above + palDeleteSources(1, &src); + oali->source[chnum].handle = 0; + oali->source[chnum].allocated = false; + return; + } #endif - else - palSourcei(src, AL_BUFFER, sfx->openal_buffer); + palSourcei(src, AL_BUFFER, buf); + } } - palSourcef(src, AL_GAIN, min(cvolume, 1)); //openal only supports a max volume of 1. anything above is an error and will be clamped. srcrel = (chan->flags & CF_NOSPACIALISE) || (chan->entnum && chan->entnum == oali->ListenEnt) || !chan->dist_mult; if (srcrel) @@ -1054,6 +1108,7 @@ static qboolean OpenAL_InitLibrary(void) {(void*)&palSourcefv, "alSourcefv"}, {(void*)&palGetString, "alGetString"}, {(void*)&palGenSources, "alGenSources"}, + {(void*)&palIsSource, "alIsSource"}, {(void*)&palListenerf, "alListenerf"}, {(void*)&palDeleteSources, "alDeleteSources"}, {(void*)&palSpeedOfSound, "alSpeedOfSound"}, @@ -1294,15 +1349,23 @@ static void OpenAL_Shutdown (soundcardinfo_t *sc) //alcMakeContextCurrent - palDeleteSources(oali->max_sources, oali->source); + for (i=0;imax_sources;i++) + { + if (oali->source[i].allocated) + { + palDeleteSources(1, &oali->source[i].handle); + oali->source[i].handle = 0; + oali->source[i].allocated = false; + } + } /*make sure the buffers are cleared from the sound effects*/ - for (i=0;imax_sounds;i++) { - if (known_sfx[i].openal_buffer) + if (oali->sounds[i].allocated) { - palDeleteBuffers(1,&known_sfx[i].openal_buffer); - known_sfx[i].openal_buffer = 0; + palDeleteBuffers(1,&oali->sounds[i].buffer); + oali->sounds[i].allocated = false; } } @@ -1322,6 +1385,7 @@ static void OpenAL_Shutdown (soundcardinfo_t *sc) palcMakeContextCurrent(NULL); palcDestroyContext(oali->OpenAL_Context); palcCloseDevice(oali->OpenAL_Device); + Z_Free(oali->sounds); Z_Free(oali->source); Z_Free(oali); } @@ -1331,6 +1395,7 @@ static ALuint OpenAL_LoadEffect(const struct reverbproperties_s *reverb) { ALuint effect = 0; #ifdef AL_EFFECT_EAXREVERB + palGetError(); palGenEffects(1, &effect); //try eax reverb for more settings diff --git a/engine/client/sound.h b/engine/client/sound.h index 37ceb674..a7ef360a 100644 --- a/engine/client/sound.h +++ b/engine/client/sound.h @@ -61,10 +61,6 @@ typedef struct sfx_s qboolean syspath:1; //if the sound is still relevent int loopstart; //-1 or sample index to begin looping at once the sample ends - -#ifdef AVAIL_OPENAL - unsigned int openal_buffer; -#endif } sfx_t; // !!! if this is changed, it much be changed in asm_i386.h too !!! diff --git a/engine/client/zqtp.c b/engine/client/zqtp.c index 1afbc778..972be50b 100644 --- a/engine/client/zqtp.c +++ b/engine/client/zqtp.c @@ -1735,6 +1735,9 @@ static void TP_MsgTrigger_f (void) char *name; msg_trigger_t *trig; + if (Cmd_IsInsecure()) + return; + c = Cmd_Argc(); if (c > 5) { diff --git a/engine/common/com_mesh.c b/engine/common/com_mesh.c index 626eb6d0..69875b62 100644 --- a/engine/common/com_mesh.c +++ b/engine/common/com_mesh.c @@ -9281,8 +9281,8 @@ static galiasinfo_t *Obj_FinishFace(model_t *mod, galiasinfo_t *m, struct objatt static qboolean QDECL Mod_LoadObjModel(model_t *mod, void *buffer, size_t fsize) { - struct objbuf_s f = {buffer, buffer+fsize}; - struct objattrib_s attrib[3] = {{},{},{}}; + struct objbuf_s f = {buffer, (qbyte*)buffer+fsize}; + struct objattrib_s attrib[3] = {{0},{0},{0}}; char buf[512]; char *meshname = NULL, *matname = NULL; galiasinfo_t *m = NULL, **link = (galiasinfo_t**)&mod->meshinfo; @@ -9362,7 +9362,7 @@ static qboolean QDECL Mod_LoadObjModel(model_t *mod, void *buffer, size_t fsize) case 'f': { size_t i, v = 0; - struct objvert vkey={}; + struct objvert vkey={0}; index_t first=0, prev=0, cur=0; //only generate a new mesh if something actually changed. diff --git a/engine/common/pr_bgcmd.c b/engine/common/pr_bgcmd.c index cd5e0626..3e314b15 100644 --- a/engine/common/pr_bgcmd.c +++ b/engine/common/pr_bgcmd.c @@ -2512,6 +2512,87 @@ void PF_fcloseall (pubprogfuncs_t *prinst) PF_buf_shutdown(prinst); //might as well put this here } +void QCBUILTIN PF_fcopy (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + const char *srcname = PR_GetStringOfs(prinst, OFS_PARM0); + const char *dstname = PR_GetStringOfs(prinst, OFS_PARM1); + const char *fallbackread, *fallbackwrite; + vfsfile_t *src, *dst; + char buffer[65536]; + int sz; + G_FLOAT(OFS_RETURN) = -1; + if (QC_FixFileName(srcname, &srcname, &fallbackread)) + { + if (QC_FixFileName(dstname, &dstname, &fallbackwrite)) + { + src = FS_OpenVFS(srcname, "rb", FS_GAME); + if (!src) + src = FS_OpenVFS(fallbackread, "rb", FS_GAME); + if (src) + { + dst = FS_OpenVFS(srcname, "wbp", FS_GAMEONLY); //lets mark it as persistent. this is probably profile data after all. + if (dst) + { + while ((sz = VFS_READ(src, buffer, sizeof(buffer)))>0) + { + if (sz != VFS_WRITE(dst, buffer, sz)) + G_FLOAT(OFS_RETURN) = -3; //weird errors... + } + G_FLOAT(OFS_RETURN) = 0; //success... + VFS_CLOSE(dst); + } + else + G_FLOAT(OFS_RETURN) = -2; //output failure + VFS_CLOSE(src); + } + } + } +} +void QCBUILTIN PF_frename (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + const char *srcname = PR_GetStringOfs(prinst, OFS_PARM0); + const char *dstname = PR_GetStringOfs(prinst, OFS_PARM1); + const char *fallbackread, *fallbackwrite; //not actually used, but present because QC_FixFileName wants a fallback + G_FLOAT(OFS_RETURN) = -1; //some kind of dodgy path problem + if (QC_FixFileName(srcname, &srcname, &fallbackread)) + if (QC_FixFileName(dstname, &dstname, &fallbackwrite)) + { + if (FS_Rename(srcname, dstname, FS_GAMEONLY)) + G_FLOAT(OFS_RETURN) = 0; + else + G_FLOAT(OFS_RETURN) = -5; //random, but whatever + } +} +void QCBUILTIN PF_fremove (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + const char *fname = PR_GetStringOfs(prinst, OFS_PARM0); + const char *fallbackread; //not actually used, but present because QC_FixFileName wants a fallback + G_FLOAT(OFS_RETURN) = -1; //some kind of dodgy path problem + if (QC_FixFileName(fname, &fname, &fallbackread)) + { + if (FS_Remove(fname, FS_GAMEONLY)) + G_FLOAT(OFS_RETURN) = 0; + else + G_FLOAT(OFS_RETURN) = -5; //random, but whatever + } +} +void QCBUILTIN PF_fexists (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + const char *srcname = PR_GetStringOfs(prinst, OFS_PARM0); + flocation_t loc; + + int depth = FS_FLocateFile(srcname, FSLF_DEPTH_INEXPLICIT, &loc); + + if (depth == 1) + G_FLOAT(OFS_RETURN) = true; //exists and should be in the writable path. + else + G_FLOAT(OFS_RETURN) = false; //doesn't exist / not writable / etc, should match wrath. +} +void QCBUILTIN PF_rmtree (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + const char *fname = PR_GetStringOfs(prinst, OFS_PARM0); + Con_Printf("rmtree(\"%s\"): rmtree is not implemented at this\n", fname); +} //DP_QC_WHICHPACK void QCBUILTIN PF_whichpack (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) diff --git a/engine/common/pr_common.h b/engine/common/pr_common.h index 0400f18a..691974ab 100644 --- a/engine/common/pr_common.h +++ b/engine/common/pr_common.h @@ -338,6 +338,12 @@ void QCBUILTIN PF_strireplace (pubprogfuncs_t *prinst, struct globalvars_s *pr_g void QCBUILTIN PF_randomvector (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals); void QCBUILTIN PF_fopen (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals); +void QCBUILTIN PF_fcopy (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals); +void QCBUILTIN PF_frename (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals); +void QCBUILTIN PF_fremove (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals); +void QCBUILTIN PF_fexists (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals); +void QCBUILTIN PF_rmtree (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals); + void QCBUILTIN PF_FindString (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals); void QCBUILTIN PF_FindFloat (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals); void QCBUILTIN PF_FindFlags (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals); diff --git a/engine/d3d/d3d11_image.c b/engine/d3d/d3d11_image.c index 8a77ab81..1c281e60 100644 --- a/engine/d3d/d3d11_image.c +++ b/engine/d3d/d3d11_image.c @@ -336,7 +336,7 @@ qboolean D3D11_LoadTextureMips(image_t *tex, const struct pendingtextureinfo *mi { subresdesc[i+layer*mips->mipcount].SysMemPitch = ((mips->mip[i].width+blockwidth-1)/blockwidth) * blockbytes; subresdesc[i+layer*mips->mipcount].SysMemSlicePitch = subresdesc[i].SysMemPitch * ((mips->mip[i].width+blockheight-1)/blockheight); - subresdesc[i+layer*mips->mipcount].pSysMem = mips->mip[i].data + subresdesc[i+layer*mips->mipcount].SysMemSlicePitch*layer; + subresdesc[i+layer*mips->mipcount].pSysMem = (qbyte*)mips->mip[i].data + subresdesc[i+layer*mips->mipcount].SysMemSlicePitch*layer; } } tdesc.MipLevels = mips->mipcount; diff --git a/engine/gl/gl_draw.c b/engine/gl/gl_draw.c index 153bc557..92dd43b6 100644 --- a/engine/gl/gl_draw.c +++ b/engine/gl/gl_draw.c @@ -938,9 +938,9 @@ qboolean GL_LoadTextureMips(texid_t tex, const struct pendingtextureinfo *mips) for (j = 0; j < min(6, mips->mip[i].depth); j++) { if (gl_config.formatinfo[encoding].type) - qglTexSubImage2D (cubeface[j], i, 0, 0, mips->mip[i].width, mips->mip[i].height, gl_config.formatinfo[encoding].format, gl_config.formatinfo[encoding].type, mips->mip[i].data + sz*j); + qglTexSubImage2D (cubeface[j], i, 0, 0, mips->mip[i].width, mips->mip[i].height, gl_config.formatinfo[encoding].format, gl_config.formatinfo[encoding].type, (qbyte*)mips->mip[i].data + sz*j); else - qglCompressedTexSubImage2D (cubeface[j], i, 0, 0, mips->mip[i].width, mips->mip[i].height, ifmt, sz, mips->mip[i].data + sz*j); + qglCompressedTexSubImage2D (cubeface[j], i, 0, 0, mips->mip[i].width, mips->mip[i].height, ifmt, sz, (qbyte*)mips->mip[i].data + sz*j); } } } @@ -954,9 +954,9 @@ qboolean GL_LoadTextureMips(texid_t tex, const struct pendingtextureinfo *mips) for (j = 0; j < min(6, mips->mip[i].depth); j++) { if (gl_config.formatinfo[encoding].type) - qglTexImage2D (cubeface[j], i, ifmt, mips->mip[i].width, mips->mip[i].height, 0, gl_config.formatinfo[encoding].format, gl_config.formatinfo[encoding].type, mips->mip[i].data + sz*j); + qglTexImage2D (cubeface[j], i, ifmt, mips->mip[i].width, mips->mip[i].height, 0, gl_config.formatinfo[encoding].format, gl_config.formatinfo[encoding].type, (qbyte*)mips->mip[i].data + sz*j); else - qglCompressedTexImage2D (cubeface[j], i, ifmt, mips->mip[i].width, mips->mip[i].height, 0, sz, mips->mip[i].data + sz*j); + qglCompressedTexImage2D (cubeface[j], i, ifmt, mips->mip[i].width, mips->mip[i].height, 0, sz, (qbyte*)mips->mip[i].data + sz*j); } } } @@ -1118,7 +1118,7 @@ qboolean GL_LoadTextureMips(texid_t tex, const struct pendingtextureinfo *mips) out.mip[i].height = mips->mip[i].height; out.mip[i].depth = 6; for (j = 0; j < 6; j++) - qglGetCompressedTexImage(targ, j, out.mip[i].data + csize*j); + qglGetCompressedTexImage(targ, j, (qbyte*)out.mip[i].data + csize*j); } else { diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c index 579fd32b..93cc9a22 100644 --- a/engine/gl/gl_model.c +++ b/engine/gl/gl_model.c @@ -2822,8 +2822,8 @@ static void Mod_Batches_BuildModelMeshes(model_t *mod, int maxverts, int maxindi static void Mod_UpdateBatchShader_Q1 (struct batch_s *batch) { texture_t *base = batch->texture; - int reletive; - int count; + unsigned int relative; + int count; if (batch->ent->framestate.g[FS_REG].frame[0]) { @@ -2833,10 +2833,10 @@ static void Mod_UpdateBatchShader_Q1 (struct batch_s *batch) if (base->anim_total) { - reletive = (int)(cl.time*10) % base->anim_total; + relative = (unsigned int)(cl.time*10) % base->anim_total; count = 0; - while (base->anim_min > reletive || base->anim_max <= reletive) + while (base->anim_min > relative || base->anim_max <= relative) { base = base->anim_next; if (!base) diff --git a/engine/gl/gl_model.h b/engine/gl/gl_model.h index 2980582f..a7cb3eee 100644 --- a/engine/gl/gl_model.h +++ b/engine/gl/gl_model.h @@ -330,8 +330,8 @@ typedef struct texture_s struct shader_s *shader; char *partname; //parsed from the worldspawn entity - int anim_total; // total tenths in sequence ( 0 = no) - int anim_min, anim_max; // time for this frame min <=time< max + unsigned int anim_total; // total tenths in sequence ( 0 = no) + unsigned int anim_min, anim_max; // time for this frame min <=time< max struct texture_s *anim_next; // in the animation sequence struct texture_s *alternate_anims; // bmodels in frmae 1 use these diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index 7c39ff6a..c107765f 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -5336,6 +5336,8 @@ done:; pass = s->passes+i; if (!(pass->shaderbits & (SBITS_BLEND_BITS|SBITS_MASK_BITS))) { + if (pass->texgen == T_GEN_LIGHTMAP && r_forceprogramify.ival==2) + continue; //pretend its blended. break; } } diff --git a/engine/gl/r_bishaders.h b/engine/gl/r_bishaders.h index af78ea53..36e34e96 100644 --- a/engine/gl/r_bishaders.h +++ b/engine/gl/r_bishaders.h @@ -3345,6 +3345,15 @@ YOU SHOULD NOT EDIT THIS FILE BY HAND "#ifdef ALPHATEST\n" "if (!(col.a ALPHATEST))\n" "discard;\n" +"#elif defined(MASK)\n" +"#if defined(MASKLT)\n" +"if (col.a < MASK)\n" +"discard;\n" +"#else\n" +"if (col.a >= MASK)\n" +"discard;\n" +"#endif\n" +"col.a = 1.0; //alpha blending AND alpha testing usually looks stupid, plus it screws up our fog.\n" "#endif\n" "gl_FragColor = fog4(col);\n" diff --git a/engine/qclib/execloop.h b/engine/qclib/execloop.h index 7bfd3ac0..2a532ce3 100644 --- a/engine/qclib/execloop.h +++ b/engine/qclib/execloop.h @@ -37,7 +37,7 @@ -#define QCFAULT return (pr_xstatement=(st-pr_statements)-1),PR_HandleFault +#define QCFAULT return (prinst.pr_xstatement=(st-pr_statements)-1),PR_HandleFault #define EVAL_FLOATISTRUE(ev) ((ev)->_int & 0x7fffffff) //mask away sign bit. This avoids using denormalized floats. #ifdef __GNUC__ @@ -55,7 +55,7 @@ errorif (prinst.watch_ptr && prinst.watch_ptr->_int != prinst.watch_old._int) { //this will fire on the next instruction after the variable got changed. - pr_xstatement = s; + prinst.pr_xstatement = s; if (current_progstate->linenums) externs->Printf("Watch point hit in %s:%u, \"%s\" changed", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), current_progstate->linenums[s-1], prinst.watch_name); else @@ -142,7 +142,7 @@ reeval: case OP_DIV_F: /* errorif (OPB->_float == 0) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; externs->Printf ("Division by 0 in %s\n", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name)); PR_StackTrace (&progfuncs->funcs, 1); OPC->_float = 0.0; @@ -154,7 +154,7 @@ reeval: tmpf = OPB->_float; /* errorif (!tmpf) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; externs->Printf ("Division by 0 in %s\n", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name)); PR_StackTrace (&progfuncs->funcs, 1); } @@ -427,7 +427,7 @@ reeval: errorif ((unsigned)OPA->edict >= (unsigned)num_edicts) { if (PR_ExecRunWarning (&progfuncs->funcs, st-pr_statements, "OP_ADDRESS references invalid entity in %s\n", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name))) - return pr_xstatement; + return prinst.pr_xstatement; break; } ed = PROG_TO_EDICT_PB(progfuncs, OPA->edict); @@ -446,7 +446,7 @@ reeval: #endif fdef_t *f = ED_FieldAtOfs(progfuncs, OPB->_int + progfuncs->funcs.fieldadjust); if (PR_ExecRunWarning(&progfuncs->funcs, st-pr_statements, "assignment to read-only entity %i in %s (%s.%s)\n", OPA->edict, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), d?PR_StringToNative(&progfuncs->funcs, d->s_name):"??", f?f->name:"??")) - return pr_xstatement; + return prinst.pr_xstatement; OPC->_int = ~0; break; } @@ -457,7 +457,7 @@ reeval: errorif (ed->ereftype == ER_FREE) { if (PR_ExecRunWarning (&progfuncs->funcs, st-pr_statements, "assignment to free entity in %s", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name))) - return pr_xstatement; + return prinst.pr_xstatement; break; } #endif @@ -467,7 +467,7 @@ reeval: errorif ((unsigned int)i*4 >= ed->fieldsize) //FIXME:lazy size check { if (PR_ExecRunWarning (&progfuncs->funcs, st-pr_statements, "OP_ADDRESS references invalid field %i in %s\n", OPB->_int, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name))) - return pr_xstatement; + return prinst.pr_xstatement; OPC->_int = 0; break; } @@ -487,7 +487,7 @@ reeval: errorif ((unsigned)OPA->edict >= (unsigned)num_edicts) { if (PR_ExecRunWarning (&progfuncs->funcs, st-pr_statements, "OP_LOAD references invalid entity %i in %s\n", OPA->edict, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name))) - return pr_xstatement; + return prinst.pr_xstatement; OPC->_int = 0; break; } @@ -499,7 +499,7 @@ reeval: if (ed->ereftype == ER_FREE) { if (PR_ExecRunWarning (&progfuncs->funcs, st-pr_statements, "OP_LOAD references free entity %i in %s\n", OPA->edict, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name))) - return pr_xstatement; + return prinst.pr_xstatement; OPC->_int = 0; } else @@ -509,7 +509,7 @@ reeval: errorif ((unsigned int)i*4 >= ed->fieldsize) //FIXME:lazy size check { if (PR_ExecRunWarning (&progfuncs->funcs, st-pr_statements, "OP_LOAD references invalid field %i in %s\n", OPB->_int, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name))) - return pr_xstatement; + return prinst.pr_xstatement; OPC->_int = 0; break; } @@ -522,7 +522,7 @@ reeval: errorif ((unsigned)OPA->edict >= (unsigned)num_edicts) { if (PR_ExecRunWarning (&progfuncs->funcs, st-pr_statements, "OP_LOAD_V references invalid entity %i in %s\n", OPA->edict, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name))) - return pr_xstatement; + return prinst.pr_xstatement; OPC->_vector[0] = 0; OPC->_vector[1] = 0; OPC->_vector[2] = 0; @@ -536,7 +536,7 @@ reeval: if (ed->ereftype == ER_FREE) { if (PR_ExecRunWarning (&progfuncs->funcs, st-pr_statements, "OP_LOAD references free entity %i in %s\n", OPA->edict, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name))) - return pr_xstatement; + return prinst.pr_xstatement; OPC->_vector[0] = 0; OPC->_vector[1] = 0; OPC->_vector[2] = 0; @@ -548,7 +548,7 @@ reeval: errorif ((unsigned int)i*4 >= ed->fieldsize) //FIXME:lazy size check { if (PR_ExecRunWarning (&progfuncs->funcs, st-pr_statements, "OP_LOAD references invalid field %i in %s\n", OPB->_int, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name))) - return pr_xstatement; + return prinst.pr_xstatement; OPC->_int = 0; break; } @@ -633,7 +633,7 @@ reeval: int newpr; unsigned int fnum; RUNAWAYCHECK(); - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; if (op > OP_CALL8) progfuncs->funcs.callargc = op - (OP_CALL1H-1); @@ -738,7 +738,7 @@ reeval: */ s = PR_LeaveFunction (progfuncs); st = &pr_statements[s]; - if (pr_depth == prinst.exitdepth) + if (prinst.pr_depth == prinst.exitdepth) { return -1; // all done } @@ -950,7 +950,7 @@ reeval: i = OPB->_float; errorif((unsigned)i > (unsigned)((eval_t *)&glob[st->a-1])->_int) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError(&progfuncs->funcs, "array index out of bounds: %s[%d] (max %d)", PR_GlobalStringNoContents(progfuncs, st->a), i, ((eval_t *)&glob[st->a-1])->_int); } OPC->_int = ((eval_t *)&glob[st->a + i])->_int; @@ -959,7 +959,7 @@ reeval: i = OPB->_float; errorif((unsigned)i > (unsigned)((eval_t *)&glob[st->a-1])->_int) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError(&progfuncs->funcs, "array index out of bounds: %s[%d]", PR_GlobalStringNoContents(progfuncs, st->a), i); } ptr = (eval_t *)&glob[st->a + i*3]; @@ -993,7 +993,7 @@ reeval: i = OPB->_int; errorif (QCPOINTERWRITEFAIL(i, sizeof(float))) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), i, (unsigned)prinst.addressableused); } ptr = QCPOINTERM(i); @@ -1003,7 +1003,7 @@ reeval: i = OPB->_int; errorif (QCPOINTERWRITEFAIL(i, sizeof(float))) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), i, (unsigned)prinst.addressableused); } ptr = QCPOINTERM(i); @@ -1019,7 +1019,7 @@ reeval: i = OPB->_int; errorif (QCPOINTERWRITEFAIL(i, sizeof(float))) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), i, (unsigned)prinst.addressableused); } ptr = QCPOINTERM(i); @@ -1037,7 +1037,7 @@ reeval: i = OPB->_int; errorif (QCPOINTERWRITEFAIL(i, sizeof(float))) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), i, (unsigned)prinst.addressableused); } ptr = QCPOINTERM(i); @@ -1047,7 +1047,7 @@ reeval: i = OPB->_int; errorif (QCPOINTERWRITEFAIL(i, sizeof(float))) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), i, (unsigned)prinst.addressableused); } ptr = QCPOINTERM(i); @@ -1067,7 +1067,7 @@ reeval: i = OPB->_int; errorif (QCPOINTERWRITEFAIL(i, sizeof(float))) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), i, (unsigned)prinst.addressableused); } ptr = QCPOINTERM(i); @@ -1077,7 +1077,7 @@ reeval: i = OPB->_int; errorif (QCPOINTERWRITEFAIL(i, sizeof(float))) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), i, (unsigned)prinst.addressableused); } ptr = QCPOINTERM(i); @@ -1092,7 +1092,7 @@ reeval: i = OPB->_int; errorif (QCPOINTERWRITEFAIL(i, sizeof(float))) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), i, (unsigned)prinst.addressableused); } ptr = QCPOINTERM(i); @@ -1105,7 +1105,7 @@ reeval: i = OPB->_int; errorif (QCPOINTERWRITEFAIL(i, sizeof(float))) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), i, (unsigned)prinst.addressableused); } ptr = QCPOINTERM(i); @@ -1266,7 +1266,7 @@ reeval: //this instruction is not implemented due to the weirdness of it. //its theoretically a more powerful load... but untyped? //or is it meant to be an LEA instruction (that could simply be switched with OP_GLOAD_I) - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "OP_GADDRESS not implemented (found in %s)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name)); break; case OP_GLOAD_I: @@ -1277,7 +1277,7 @@ reeval: case OP_GLOAD_FNC: errorif (OPA->_int < 0 || OPA->_int*4 >= current_progstate->globals_size) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad indexed global read in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), OPA->_int, current_progstate->globals_size); } ptr = ((eval_t *)&glob[OPA->_int]); @@ -1286,7 +1286,7 @@ reeval: case OP_GLOAD_V: errorif (OPA->_int < 0 || (OPA->_int+2)*4 >= current_progstate->globals_size) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad indexed global read in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), OPA->_int, current_progstate->globals_size); } ptr = ((eval_t *)&glob[OPA->_int]); @@ -1302,7 +1302,7 @@ reeval: case OP_GSTOREP_FNC: errorif (OPB->_int < 0 || OPB->_int*4 >= current_progstate->globals_size) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad indexed global write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), OPB->_int, (unsigned)prinst.addressableused); } ptr = ((eval_t *)&glob[OPB->_int]); @@ -1311,7 +1311,7 @@ reeval: case OP_GSTOREP_V: errorif (OPB->_int < 0 || (OPB->_int+2)*4 >= current_progstate->globals_size) { - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad indexed global write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), OPB->_int, (unsigned)prinst.addressableused); } ptr = ((eval_t *)&glob[OPB->_int]); @@ -1338,7 +1338,7 @@ reeval: if (prinst.spushed + prinst.localstack_used >= LOCALSTACK_SIZE) { prinst.spushed = 0; - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError(&progfuncs->funcs, "Progs pushed too much"); } break; @@ -1347,7 +1347,7 @@ reeval: if (pr_spushed < 0) { pr_spushed = 0; - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError(progfuncs, "Progs poped more than it pushed"); } break; @@ -1357,18 +1357,18 @@ reeval: { op &= ~OP_BIT_BREAKPOINT; s = st-pr_statements; - if (pr_xstatement != s) + if (prinst.pr_xstatement != s) { - pr_xstatement = s; + prinst.pr_xstatement = s; externs->Printf("Break point hit in %s.\n", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name)); s = ShowStep(progfuncs, s, NULL, false); st = &pr_statements[s]; //let the user move execution - pr_xstatement = s = st-pr_statements; + prinst.pr_xstatement = s = st-pr_statements; op = st->op & ~OP_BIT_BREAKPOINT; } goto reeval; //reexecute } - pr_xstatement = st-pr_statements; + prinst.pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "Bad opcode %i", st->op); } } diff --git a/engine/qclib/initlib.c b/engine/qclib/initlib.c index 82e6ea2c..4289a5cb 100644 --- a/engine/qclib/initlib.c +++ b/engine/qclib/initlib.c @@ -876,7 +876,7 @@ static struct edict_s *PDECL ProgsToEdict (pubprogfuncs_t *ppf, int progs) if ((unsigned)progs >= (unsigned)prinst.maxedicts) { externs->Printf("Bad entity index %i\n", progs); - if (pr_depth) + if (prinst.pr_depth) { PR_StackTrace (ppf, false); // progfuncs->funcs.pr_trace += 1; diff --git a/engine/qclib/pr_edict.c b/engine/qclib/pr_edict.c index b11b458d..53da99f1 100644 --- a/engine/qclib/pr_edict.c +++ b/engine/qclib/pr_edict.c @@ -187,7 +187,7 @@ void PDECL ED_Free (pubprogfuncs_t *ppf, struct edict_s *ed) if (e->ereftype == ER_FREE) //this happens on start.bsp where an onlyregistered trigger killtargets itself (when all of this sort die after 1 trigger anyway). { - if (pr_depth) + if (prinst.pr_depth) externs->Printf("Tried to free free entity within %s\n", pr_xfunction->s_name+progfuncs->funcs.stringtable); else externs->Printf("Engine tried to free free entity\n"); @@ -1699,7 +1699,7 @@ char *PR_SaveCallStack (progfuncs_t *progfuncs, char *buf, size_t *bufofs, size_ progs = -1; - if (pr_depth == 0) + if (prinst.pr_depth == 0) { AddS ("\n"); return buf; @@ -1707,10 +1707,10 @@ char *PR_SaveCallStack (progfuncs_t *progfuncs, char *buf, size_t *bufofs, size_ globalbase = (int *)pr_globals + pr_xfunction->parm_start + pr_xfunction->locals; - pr_stack[pr_depth].f = pr_xfunction; - for (i=pr_depth ; i>0 ; i--) + prinst.pr_stack[prinst.pr_depth].f = pr_xfunction; + for (i=prinst.pr_depth ; i>0 ; i--) { - f = pr_stack[i].f; + f = prinst.pr_stack[i].f; if (!f) { @@ -1718,9 +1718,9 @@ char *PR_SaveCallStack (progfuncs_t *progfuncs, char *buf, size_t *bufofs, size_ } else { - if (pr_stack[i].progsnum != progs) + if (prinst.pr_stack[i].progsnum != progs) { - progs = pr_stack[i].progsnum; + progs = prinst.pr_stack[i].progsnum; sprintf(buffer, "//%i %s\n", progs, pr_progstate[progs].filename); AddS (buffer); @@ -1754,7 +1754,7 @@ char *PR_SaveCallStack (progfuncs_t *progfuncs, char *buf, size_t *bufofs, size_ } AddS ("\t}\n"); - if (i == pr_depth) + if (i == prinst.pr_depth) globalbase = prinst.localstack + prinst.localstack_used - f->locals; else globalbase -= f->locals; diff --git a/engine/qclib/pr_exec.c b/engine/qclib/pr_exec.c index 1099b587..852cac92 100644 --- a/engine/qclib/pr_exec.c +++ b/engine/qclib/pr_exec.c @@ -294,7 +294,7 @@ static void PDECL PR_PrintRelevantLocals(progfuncs_t *progfuncs) if (!current_progstate->linenums || current_progstate->structtype != PST_DEFAULT) return; - line = current_progstate->linenums[pr_xstatement]; + line = current_progstate->linenums[prinst.pr_xstatement]; for (st = pr_xfunction->first_statement; st16[st].op != OP_DONE; st++) { if (current_progstate->linenums[st] < line - 2 || current_progstate->linenums[st] > line + 2) @@ -375,7 +375,7 @@ void PDECL PR_StackTrace (pubprogfuncs_t *ppf, int showlocals) int tracing = progfuncs->funcs.debug_trace; progs = -1; - if (pr_depth == 0) + if (prinst.pr_depth == 0) { externs->Printf ("\n"); return; @@ -386,19 +386,19 @@ void PDECL PR_StackTrace (pubprogfuncs_t *ppf, int showlocals) //point this to the function's locals globalbase = (int *)pr_globals + pr_xfunction->parm_start + pr_xfunction->locals; - for (i=pr_depth ; i>0 ; i--) + for (i=prinst.pr_depth ; i>0 ; i--) { - if (i == pr_depth) + if (i == prinst.pr_depth) { f = pr_xfunction; - st = pr_xstatement; + st = prinst.pr_xstatement; prnum = prinst.pr_typecurrent; } else { - f = pr_stack[i].f; - st = pr_stack[i].s; - prnum = pr_stack[i].progsnum; + f = prinst.pr_stack[i].f; + st = prinst.pr_stack[i].s; + prnum = prinst.pr_stack[i].progsnum; } if (!f) @@ -428,7 +428,7 @@ void PDECL PR_StackTrace (pubprogfuncs_t *ppf, int showlocals) //locals:0 = no locals //locals:1 = top only //locals:2 = ALL locals. - if ((i == pr_depth && showlocals == 1) || showlocals >= 2) + if ((i == prinst.pr_depth && showlocals == 1) || showlocals >= 2) { for (ofs = 0; ofs < f->locals; ofs++) { @@ -466,12 +466,12 @@ void PDECL PR_StackTrace (pubprogfuncs_t *ppf, int showlocals) } } } - if (i == pr_depth) + if (i == prinst.pr_depth) { //scan for op_address/op_load instructions within the function PR_PrintRelevantLocals(progfuncs); } - if (i == pr_depth) + if (i == prinst.pr_depth) globalbase = prinst.localstack + prinst.localstack_used; } } @@ -498,19 +498,19 @@ int ASMCALL PR_EnterFunction (progfuncs_t *progfuncs, mfunction_t *f, int progsn int i, j, c, o; prstack_t *st; - if (pr_depth == MAX_STACK_DEPTH) + if (prinst.pr_depth == MAX_STACK_DEPTH) { PR_StackTrace (&progfuncs->funcs, false); - externs->Printf ("stack overflow on call to %s (depth %i)\n", progfuncs->funcs.stringtable+f->s_name, pr_depth); + externs->Printf ("stack overflow on call to %s (depth %i)\n", progfuncs->funcs.stringtable+f->s_name, prinst.pr_depth); //comment this out if you want the progs to try to continue anyway (could cause infinate loops) PR_AbortStack(&progfuncs->funcs); externs->Abort("Stack Overflow in %s\n", progfuncs->funcs.stringtable+f->s_name); - return pr_xstatement; + return prinst.pr_xstatement; } - st = &pr_stack[pr_depth++]; - st->s = pr_xstatement; + st = &prinst.pr_stack[prinst.pr_depth++]; + st->s = prinst.pr_xstatement; st->f = pr_xfunction; st->progsnum = progsnum; st->pushed = prinst.spushed; @@ -529,7 +529,7 @@ int ASMCALL PR_EnterFunction (progfuncs_t *progfuncs, mfunction_t *f, int progsn if (prinst.localstack_used + c > LOCALSTACK_SIZE) { prinst.localstack_used -= prinst.spushed; - pr_depth--; + prinst.pr_depth--; PR_RunError (&progfuncs->funcs, "PR_ExecuteProgram: locals stack overflow\n"); } @@ -562,11 +562,11 @@ int ASMCALL PR_LeaveFunction (progfuncs_t *progfuncs) int i, c; prstack_t *st; - if (pr_depth <= 0) + if (prinst.pr_depth <= 0) externs->Sys_Error ("prog stack underflow"); // up stack - st = &pr_stack[--pr_depth]; + st = &prinst.pr_stack[--prinst.pr_depth]; // restore locals from the stack c = pr_xfunction->locals; @@ -591,7 +591,7 @@ int ASMCALL PR_LeaveFunction (progfuncs_t *progfuncs) externs->Printf("QC call to %s took over a second\n", PR_StringToNative(&progfuncs->funcs,pr_xfunction->s_name)); pr_xfunction->profiletime += cycles; pr_xfunction = st->f; - if (pr_depth) + if (prinst.pr_depth) pr_xfunction->profilechildtime += cycles; } else @@ -1336,7 +1336,7 @@ static const char *lastfile = NULL; const mfunction_t *f = pr_xfunction; int faultline; int debugaction; - pr_xstatement = statement; + prinst.pr_xstatement = statement; if (!externs->useeditor) { @@ -1424,15 +1424,15 @@ static const char *lastfile = NULL; { //if we're resuming, don't hit any lingering step-over triggers progfuncs->funcs.debug_trace = DEBUG_TRACE_OFF; - for (i = 0; i < pr_depth; i++) - pr_stack[pr_depth-1].stepping = DEBUG_TRACE_OFF; + for (i = 0; i < prinst.pr_depth; i++) + prinst.pr_stack[prinst.pr_depth-1].stepping = DEBUG_TRACE_OFF; } else if (debugaction == DEBUG_TRACE_OUT) { //clear tracing for now, but ensure that it'll be reactivated once we reach the caller (if from qc) progfuncs->funcs.debug_trace = DEBUG_TRACE_OFF; - if (pr_depth) - pr_stack[pr_depth-1].stepping = DEBUG_TRACE_INTO; + if (prinst.pr_depth) + prinst.pr_stack[prinst.pr_depth-1].stepping = DEBUG_TRACE_INTO; } else //some other debug action. maybe resume. progfuncs->funcs.debug_trace = debugaction; @@ -1459,7 +1459,7 @@ int PR_HandleFault (pubprogfuncs_t *ppf, char *error, ...) PR_StackTrace (ppf, true); ppf->parms->Printf ("%s\n", string); - resumestatement = ShowStep(progfuncs, pr_xstatement, string, true); + resumestatement = ShowStep(progfuncs, prinst.pr_xstatement, string, true); if (resumestatement == 0) { @@ -1506,7 +1506,7 @@ pbool PR_RunWarning (pubprogfuncs_t *ppf, char *error, ...) va_end (argptr); progfuncs->funcs.parms->Printf ("%s", string); - if (pr_depth != 0) + if (prinst.pr_depth != 0) PR_StackTrace (ppf, false); if (progfuncs->funcs.debug_trace == 0) @@ -1522,19 +1522,19 @@ static pbool PR_ExecRunWarning (pubprogfuncs_t *ppf, int xstatement, char *error va_list argptr; char string[1024]; - pr_xstatement = xstatement; + prinst.pr_xstatement = xstatement; va_start (argptr,error); Q_vsnprintf (string,sizeof(string)-1, error,argptr); va_end (argptr); progfuncs->funcs.parms->Printf ("%s", string); - if (pr_depth != 0) + if (prinst.pr_depth != 0) PR_StackTrace (ppf, false); if (progfuncs->funcs.debug_trace == 0) { - pr_xstatement = ShowStep(progfuncs, xstatement, string, false); + prinst.pr_xstatement = ShowStep(progfuncs, xstatement, string, false); return true; } return false; @@ -1591,11 +1591,11 @@ static casecmprange_t casecmprange[] = #define RUNAWAYCHECK() \ if (!--*runaway) \ { \ - pr_xstatement = st-pr_statements; \ + prinst.pr_xstatement = st-pr_statements; \ PR_RunError (&progfuncs->funcs, "runaway loop error\n");\ PR_StackTrace(&progfuncs->funcs,false); \ externs->Printf ("runaway loop error\n"); \ - while(pr_depth > prinst.exitdepth) \ + while(prinst.pr_depth > prinst.exitdepth) \ PR_LeaveFunction(progfuncs); \ prinst.spushed = 0; \ return -1; \ @@ -1855,7 +1855,7 @@ void PDECL PR_ExecuteProgram (pubprogfuncs_t *ppf, func_t fnum) progfuncs->funcs.debug_trace = DEBUG_TRACE_OFF; // make a stack frame - prinst.exitdepth = pr_depth; + prinst.exitdepth = prinst.pr_depth; s = PR_EnterFunction (progfuncs, f, initial_progs); @@ -1872,7 +1872,7 @@ void PDECL PR_ExecuteProgram (pubprogfuncs_t *ppf, func_t fnum) PR_FreeTemps(progfuncs, tempdepth); prinst.numtempstringsstack = tempdepth; #else - if (!pr_depth) + if (!prinst.pr_depth) PR_RunGC(progfuncs); #endif @@ -1912,33 +1912,33 @@ struct qcthread_s *PDECL PR_ForkStack(pubprogfuncs_t *ppf) //copy out the functions stack. for (i = 0,localsoffset=0; i < ed; i++) { - if (i+1 == pr_depth) + if (i+1 == prinst.pr_depth) f = pr_xfunction; else - f = pr_stack[i+1].f; + f = prinst.pr_stack[i+1].f; localsoffset += f->locals; //this is where it crashes } baselocalsoffset = localsoffset; - for (i = ed; i < pr_depth; i++) + for (i = ed; i < prinst.pr_depth; i++) { - thread->fstack[i-ed].fnum = pr_stack[i].f - pr_progstate[pr_stack[i].progsnum].functions; - thread->fstack[i-ed].progsnum = pr_stack[i].progsnum; - thread->fstack[i-ed].statement = pr_stack[i].s; + thread->fstack[i-ed].fnum = prinst.pr_stack[i].f - pr_progstate[prinst.pr_stack[i].progsnum].functions; + thread->fstack[i-ed].progsnum = prinst.pr_stack[i].progsnum; + thread->fstack[i-ed].statement = prinst.pr_stack[i].s; - if (i+1 == pr_depth) + if (i+1 == prinst.pr_depth) f = pr_xfunction; else - f = pr_stack[i+1].f; + f = prinst.pr_stack[i+1].f; localsoffset += f->locals; } - thread->fstackdepth = pr_depth - ed; + thread->fstackdepth = prinst.pr_depth - ed; - for (i = pr_depth - 1; i >= ed ; i--) + for (i = prinst.pr_depth - 1; i >= ed ; i--) { - if (i+1 == pr_depth) + if (i+1 == prinst.pr_depth) f = pr_xfunction; else - f = pr_stack[i+1].f; + f = prinst.pr_stack[i+1].f; localsoffset -= f->locals; for (l = 0; l < f->locals; l++) { @@ -1947,12 +1947,12 @@ struct qcthread_s *PDECL PR_ForkStack(pubprogfuncs_t *ppf) } } - for (i = ed; i < pr_depth ; i++) //we need to get the locals back to how they were. + for (i = ed; i < prinst.pr_depth ; i++) //we need to get the locals back to how they were. { - if (i+1 == pr_depth) + if (i+1 == prinst.pr_depth) f = pr_xfunction; else - f = pr_stack[i+1].f; + f = prinst.pr_stack[i+1].f; for (l = 0; l < f->locals; l++) { @@ -1962,7 +1962,7 @@ struct qcthread_s *PDECL PR_ForkStack(pubprogfuncs_t *ppf) } thread->lstackused = localsoffset - baselocalsoffset; - thread->xstatement = pr_xstatement; + thread->xstatement = prinst.pr_xstatement; thread->xfunction = pr_xfunction - current_progstate->functions; thread->xprogs = prinst.pr_typecurrent; @@ -1988,7 +1988,7 @@ void PDECL PR_ResumeThread (pubprogfuncs_t *ppf, struct qcthread_s *thread) if (prinst.localstack_used + thread->lstackused > LOCALSTACK_SIZE) PR_RunError(&progfuncs->funcs, "Too many locals on resumtion of QC thread\n"); - if (pr_depth + thread->fstackdepth > MAX_STACK_DEPTH) + if (prinst.pr_depth + thread->fstackdepth > MAX_STACK_DEPTH) PR_RunError(&progfuncs->funcs, "Too large stack on resumtion of QC thread\n"); @@ -1998,23 +1998,23 @@ void PDECL PR_ResumeThread (pubprogfuncs_t *ppf, struct qcthread_s *thread) oldexitdepth = prinst.exitdepth; - prinst.exitdepth = pr_depth; + prinst.exitdepth = prinst.pr_depth; ls = 0; //add on the callstack. for (i = 0; i < thread->fstackdepth; i++) { - if (pr_depth == prinst.exitdepth) + if (prinst.pr_depth == prinst.exitdepth) { - pr_stack[pr_depth].f = pr_xfunction; - pr_stack[pr_depth].s = pr_xstatement; - pr_stack[pr_depth].progsnum = initial_progs; + prinst.pr_stack[prinst.pr_depth].f = pr_xfunction; + prinst.pr_stack[prinst.pr_depth].s = prinst.pr_xstatement; + prinst.pr_stack[prinst.pr_depth].progsnum = initial_progs; } else { - pr_stack[pr_depth].progsnum = thread->fstack[i].progsnum; - pr_stack[pr_depth].f = pr_progstate[thread->fstack[i].progsnum].functions + thread->fstack[i].fnum; - pr_stack[pr_depth].s = thread->fstack[i].statement; + prinst.pr_stack[prinst.pr_depth].progsnum = thread->fstack[i].progsnum; + prinst.pr_stack[prinst.pr_depth].f = pr_progstate[thread->fstack[i].progsnum].functions + thread->fstack[i].fnum; + prinst.pr_stack[prinst.pr_depth].s = thread->fstack[i].statement; } if (i+1 == thread->fstackdepth) @@ -2027,7 +2027,7 @@ void PDECL PR_ResumeThread (pubprogfuncs_t *ppf, struct qcthread_s *thread) ((int *)pr_globals)[f->parm_start + l] = thread->lstack[ls++]; } - pr_depth++; + prinst.pr_depth++; } if (ls != thread->lstackused) @@ -2071,7 +2071,7 @@ void PDECL PR_ResumeThread (pubprogfuncs_t *ppf, struct qcthread_s *thread) void PDECL PR_AbortStack (pubprogfuncs_t *ppf) { progfuncs_t *progfuncs = (progfuncs_t*)ppf; - while(pr_depth > prinst.exitdepth+1) + while(prinst.pr_depth > prinst.exitdepth+1) PR_LeaveFunction(progfuncs); prinst.continuestatement = 0; } @@ -2079,7 +2079,7 @@ void PDECL PR_AbortStack (pubprogfuncs_t *ppf) pbool PDECL PR_GetBuiltinCallInfo (pubprogfuncs_t *ppf, int *builtinnum, char *function, size_t sizeoffunction) { progfuncs_t *progfuncs = (progfuncs_t*)ppf; - int st = pr_xstatement; + int st = prinst.pr_xstatement; int op; int a; const char *fname; diff --git a/engine/qclib/progsint.h b/engine/qclib/progsint.h index 0c0ea5e5..48d464ba 100644 --- a/engine/qclib/progsint.h +++ b/engine/qclib/progsint.h @@ -150,9 +150,7 @@ typedef struct prinst_s //call stack #define MAX_STACK_DEPTH 1024 //insanely high value requried for xonotic. prstack_t pr_stack[MAX_STACK_DEPTH]; -#define pr_stack prinst.pr_stack int pr_depth; -#define pr_depth prinst.pr_depth int spushed; //locals @@ -170,7 +168,6 @@ typedef struct prinst_s mfunction_t *pr_xfunction; //active function #define pr_xfunction prinst.pr_xfunction int pr_xstatement; //active statement -#define pr_xstatement prinst.pr_xstatement //pr_edict.c evalc_t spawnflagscache; diff --git a/engine/qclib/qccmain.c b/engine/qclib/qccmain.c index c333cc0c..b35858aa 100644 --- a/engine/qclib/qccmain.c +++ b/engine/qclib/qccmain.c @@ -3595,7 +3595,7 @@ static unsigned short QCC_PR_WriteProgdefs (char *filename) QCC_PR_Warning(WARN_SYSTEMCRC, NULL, 0, "please update your tenebrae system defs.\n"); break; default: - QCC_PR_Warning(WARN_SYSTEMCRC, NULL, 0, "system defs not recognised from quake nor clones\n"); + QCC_PR_Warning(WARN_SYSTEMCRC, NULL, 0, "system defs not recognised from quake nor clones, probably buggy (sys)defs.qc\n"); break; } @@ -4810,7 +4810,11 @@ pbool QCC_main (int argc, const char **argv) //as part of the quake engine */ time(&long_time); - strftime(QCC_copyright, sizeof(QCC_copyright), "Compiled [%Y/%m/%d]. ", localtime( &long_time )); + strftime(QCC_copyright, sizeof(QCC_copyright), "Compiled [%Y/%m/%d]" +#ifdef SVNREVISION + ", by fteqcc "STRINGIFY(SVNREVISION) +#endif + ". ", localtime( &long_time )); (void)QC_strlcat(QCC_copyright, QCC_VersionString(), sizeof(QCC_copyright)); for (p = 0; p < 5; p++) strcpy(QCC_Packname[p], ""); diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index ef790bcd..6790f33e 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -63,7 +63,8 @@ cvar_t noexit = CVAR("noexit", "0"); extern cvar_t sv_specprint; //cvar_t sv_aim = {"sv_aim", "0.93"}; -cvar_t sv_aim = CVAR("sv_aim", "2"); +cvar_t sv_aim = CVARD("sv_aim", "2", "The value should be cos(angle), where angle is the greatest allowed angle from which to deviate from the direction the shot would have been along. Values >1 thus disable auto-aim. This can be overridden with setinfo aim 0.73."); +cvar_t sv_maxaim = CVARD("sv_maxaim", "22", "The maximum acceptable angle for autoaiming."); extern cvar_t pr_autocreatecvars; cvar_t pr_ssqc_memsize = CVARD("pr_ssqc_memsize", "-1", "The ammount of memory available to the QC vm. This has a theoretical maximum of 1gb, but that value can only really be used in 64bit builds. -1 will attempt to use some conservative default, but you may need to increase it. Consider also clearing pr_fixbrokenqccarrays if you need to change this cvar."); @@ -4859,34 +4860,29 @@ void QCBUILTIN PF_aim (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) vec3_t start, dir, end, bestdir; int i, j; trace_t tr; - float dist, bestdist = sv_aim.value; - char *noaim; + float dist, bestdist; ent = G_EDICT(prinst, OFS_PARM0); // speed = G_FLOAT(OFS_PARM1); - VectorCopy (ent->v->origin, start); - start[2] += 20; -// noaim option + //figure out the angle we're allowed to aim at i = NUM_FOR_EDICT(prinst, ent); if (i>0 && i 0) - { - VectorCopy (P_VEC(v_forward), G_VECTOR(OFS_RETURN)); - return; - } - - noaim = InfoBuf_ValueForKey (&svs.clients[i-1].userinfo, "aim"); - if (noaim) - { - dist = atof(noaim); - if (dist > 0) - bestdist = dist; - } + bestdist = svs.clients[i-1].autoaimdot; + else + bestdist = sv_aim.value; + if (bestdist >= 1) + { //autoaim disabled, early out and just aim straight + VectorCopy (P_VEC(v_forward), G_VECTOR(OFS_RETURN)); + return; } + dist = cos(sv_maxaim.value); + bestdist = max(bestdist, dist); + + + VectorCopy (ent->v->origin, start); + start[2] += ent->v->view_ofs[2]; //the view position is at 22, but the gun position is normally at 16. // try sending a trace straight VectorCopy (P_VEC(v_forward), dir); @@ -10471,7 +10467,7 @@ static BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs {"pointcontents", PF_pointcontents, 41, 41, 41, 0, D("float(vector pos)", "Checks the given point to see what is there. Returns one of the SOLID_* constants. Just because a spot is empty does not mean that the player can stand there due to the size of the player - use tracebox for such tests.")}, // {"qtest_stopsound", NULL, 42}, // defined QTest builtin that is never called {"fabs", PF_fabs, 43, 43, 43, 0, D("float(float)", "Removes the sign of the float, making it positive if it is negative.")}, - {"aim", PF_aim, 44, 44, 44, 0, D("vector(entity player, float missilespeed)", "Returns a direction vector (specifically v_forward on error). This builtin attempts to guess what pitch angle to fire projectiles at for people that don't know about mouselook. Does not affect yaw angles.")}, //44 + {"aim", PF_aim, 44, 44, 44, 0, D("vector(entity player, float missilespeed)", "Returns a tweaked copy of the v_forward vector (must be set! ie: makevectors(player.v_angle) ). This is important for keyboard users (that don't want to have to look up/down the whole time), as well as joystick users (who's aim is otherwise annoyingly imprecise). Only the upwards component of the result will differ from the value of v_forward. The builtin will select the enemy closest to the crosshair within the angle of acos(sv_aim).")}, //44 {"cvar", PF_cvar, 45, 45, 45, 0, D("float(string)", "Returns the numeric value of the named cvar")}, {"localcmd", PF_localcmd, 46, 46, 46, 0, D("void(string, ...)", "Adds the string to the console command queue. Commands will not be executed immediately, but rather at the start of the following frame.")}, {"nextent", PF_nextent, 47, 47, 47, 0, D("entity(entity)", "Returns the following entity. Skips over removed entities. Returns world when passed the last valid entity.")}, @@ -11327,6 +11323,14 @@ static BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs //end dp extras + //wrath extras... + {"fcopy", PF_fcopy, 0, 0, 0, 650, D("float(string src, string dst)", "Equivelent to fopen+fread+fwrite+fclose from QC (ie: reads from $gamedir/data/ or $gamedir, but always writes to $gamedir/data/ )")}, + {"frename", PF_frename, 0, 0, 0, 651, D("float(string src, string dst)", "Renames the file, returning 0 on success. Both paths are relative to the data/ subdir.")}, + {"fremove", PF_fremove, 0, 0, 0, 652, D("float(string fname)", "Deletes the named file - path is relative to data/ subdir, like fopen's FILE_WRITE. Returns 0 on success.")}, + {"fexists", PF_fexists, 0, 0, 0, 653, D("float(string fname)", "Use whichpack instead. Returns true if it exists inside the default writable path.")}, + {"rmtree", PF_rmtree, 0, 0, 0, 654, D("float(string path)", "Dangerous, but sandboxed to data/")}, + //end wrath extras + {"getrmqeffectsversion",PF_Ignore, 0, 0, 0, 666, "float()" STUB}, //don't exceed sizeof(pr_builtin)/sizeof(pr_builtin[0]) (currently 1024) without modifing the size of pr_builtin diff --git a/engine/server/progs.h b/engine/server/progs.h index 101fca2b..75de6b2d 100644 --- a/engine/server/progs.h +++ b/engine/server/progs.h @@ -123,7 +123,7 @@ extern func_t EndFrameQC; extern qboolean ssqc_deprecated_warned; extern cvar_t pr_maxedicts; //used in too many places... extern cvar_t noexit, temp1, saved1, saved2, saved3, saved4, savedgamecfg, scratch1, scratch2, scratch3, scratch4, gamecfg, nomonsters; //read by savegame.c -extern cvar_t pr_ssqc_memsize, pr_imitatemvdsv, sv_aim, pr_ssqc_coreonerror, dpcompat_nopreparse; +extern cvar_t pr_ssqc_memsize, pr_imitatemvdsv, sv_aim, sv_maxaim, pr_ssqc_coreonerror, dpcompat_nopreparse; extern int pr_teamfield; qboolean PR_QCChat(char *text, int say_type); diff --git a/engine/server/server.h b/engine/server/server.h index 2ee75149..2a281256 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -525,6 +525,7 @@ typedef struct client_s // extracted from userinfo char guid[64]; /*+2 for split+pad*/ int messagelevel; // for filtering printed messages + int autoaimdot; //smallest dotproduct allowed for autoaim #ifdef HAVE_LEGACY float *dp_ping; float *dp_pl; diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index fedea678..762beeb1 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -5780,6 +5780,22 @@ void SV_ExtractFromUserinfo (client_t *cl, qboolean verbose) } #endif + val = InfoBuf_ValueForKey (&cl->userinfo, "noaim"); + if (atoi(val) > 0) + cl->autoaimdot = 2; //disable, ignoring sv_aim + else + { + val = InfoBuf_ValueForKey (&cl->userinfo, "aim"); + if (*val) + { + cl->autoaimdot = atof(val); + if (cl->autoaimdot > 1) + cl->autoaimdot = cos(cl->autoaimdot * M_PI/180);//interpret it as an accepted angle in degrees + } + else + cl->autoaimdot = sv_aim.value; + } + // msg command val = InfoBuf_ValueForKey (&cl->userinfo, "msg"); if (strlen(val)) diff --git a/engine/shaders/glsl/defaultskin.glsl b/engine/shaders/glsl/defaultskin.glsl index e85288e2..86aab0e7 100644 --- a/engine/shaders/glsl/defaultskin.glsl +++ b/engine/shaders/glsl/defaultskin.glsl @@ -399,6 +399,15 @@ void main () #ifdef ALPHATEST if (!(col.a ALPHATEST)) discard; +#elif defined(MASK) + #if defined(MASKLT) + if (col.a < MASK) + discard; + #else + if (col.a >= MASK) + discard; + #endif + col.a = 1.0; //alpha blending AND alpha testing usually looks stupid, plus it screws up our fog. #endif gl_FragColor = fog4(col); diff --git a/engine/web/ftejslib.js b/engine/web/ftejslib.js index 004754f9..7c5778fe 100644 --- a/engine/web/ftejslib.js +++ b/engine/web/ftejslib.js @@ -1086,27 +1086,42 @@ console.log("onerror: " + _url); //match emscripten's openal support. if (!buf) return; - buf = buf - 1; + + var albuf = ctx.buffers[buf]; + ctx.buffers[buf] = null; //alIsBuffer will report it as invalid now var ctx = AL.currentContext || AL.currentCtx; try { //its async, so it needs its own copy of an arraybuffer var abuf = new ArrayBuffer(datasize); - new Uint8Array(abuf).set(HEAPU8.subarray(dataptr, dataptr+datasize)); - AL.currentContext.ctx.decodeAudioData(abuf, function(buffer) - { - ctx.buf[buf] = buffer; - }, function() - { - console.log("Audio Callback failed!"); - }); + Uint8Array(abuf).set(HEAPU8.subarray(dataptr, dataptr+datasize)); + AL.currentContext.ctx.decodeAudioData(abuf, + function(buffer) + { + //Warning: This depends upon emscripten's specific implementation of alBufferData + albuf.bytesPerSample = 2; + albuf.channels = 1; + albuf.length = 1; + albuf.frequency = 11025; + albuf.audioBuf = buffer; + + ctx.buffers[buf] = albuf; //and its valid again! + }, + function() + { + console.log("Audio Callback failed!"); + ctx.buffers[buf] = albuf; + } + ); } catch (e) { console.log("unable to decode audio data"); console.log(e); + ctx.buffers[buf] = albuf; } + return id; }, emscriptenfte_gl_loadtexturefile : function(texid, widthptr, heightptr, dataptr, datasize, fname) diff --git a/imgtool.c b/imgtool.c index b74d4655..f0b88453 100644 --- a/imgtool.c +++ b/imgtool.c @@ -567,7 +567,7 @@ static qboolean ImgTool_ConvertPixelFormat(struct opts_s *args, const char *inna } else if (ret->mip[0].datasize != mips->mip[m].datasize/layers) break; //erk..? - memcpy(mips->mip[m].data + l * ret->mip[0].datasize, ret->mip[0].data, ret->mip[0].datasize); + memcpy((qbyte*)mips->mip[m].data + l * ret->mip[0].datasize, ret->mip[0].data, ret->mip[0].datasize); } continue; } @@ -823,7 +823,7 @@ static struct pendingtextureinfo *ImgTool_Combine(struct opts_s *args, const cha Con_Printf("%s: mismatched mipmap sizes\n", namelist[i]); continue; } - memcpy(r->mip[j].data + t->mip[j].datasize*r->mip[j].depth, t->mip[j].data, t->mip[j].datasize); + memcpy((qbyte*)r->mip[j].data + t->mip[j].datasize*r->mip[j].depth, t->mip[j].data, t->mip[j].datasize); r->mip[j].depth++; } }