From cc3d3a67e6d3bcf21d3c13f196786837a875c0ed Mon Sep 17 00:00:00 2001 From: Sryder13 Date: Sun, 26 Jul 2015 20:14:47 +0100 Subject: [PATCH 01/39] Colour Changing MD2s I don't know how I can move my old branch over so I've just created a new one. --- src/hardware/hw_md2.c | 314 +++++++++++++++++++++++++++++++++++++++++- src/hardware/hw_md2.h | 1 + 2 files changed, 312 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 02f50535..8953b3a8 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -41,6 +41,7 @@ #include "../r_things.h" #include "hw_main.h" +#include "../v_video.h" #ifdef HAVE_PNG #ifndef _MSC_VER @@ -881,6 +882,59 @@ static void md2_loadTexture(md2_t *model) HWR_UnlockCachedPatch(grpatch); } +// -----------------+ +// md2_loadBlendTexture : Download a pcx or png texture for blending MD2 models +// -----------------+ +static void md2_loadBlendTexture(md2_t *model) +{ + GLPatch_t *grpatch; + char *filename = Z_Malloc(strlen(model->filename)+7, PU_STATIC, NULL); + strcpy(filename, model->filename); + + FIL_ForceExtension(filename, "_blend.png"); + + if (model->blendgrpatch) + { + grpatch = model->blendgrpatch; + Z_Free(grpatch->mipmap.grInfo.data); + } + else + grpatch = Z_Calloc(sizeof *grpatch, PU_HWRPATCHINFO, + &(model->blendgrpatch)); + + if (!grpatch->mipmap.downloaded && !grpatch->mipmap.grInfo.data) + { + int w = 0, h = 0; +#ifdef HAVE_PNG + grpatch->mipmap.grInfo.format = PNG_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap.grInfo.format == 0) +#endif + grpatch->mipmap.grInfo.format = PCX_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap.grInfo.format == 0) + { + Z_Free(filename); + return; + } + + grpatch->mipmap.downloaded = 0; + grpatch->mipmap.flags = 0; + + grpatch->width = (INT16)w; + grpatch->height = (INT16)h; + grpatch->mipmap.width = (UINT16)w; + grpatch->mipmap.height = (UINT16)h; + + // not correct! + grpatch->mipmap.grInfo.smallLodLog2 = GR_LOD_LOG2_256; + grpatch->mipmap.grInfo.largeLodLog2 = GR_LOD_LOG2_256; + grpatch->mipmap.grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1; + } + HWD.pfnSetTexture(&grpatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary + HWR_UnlockCachedPatch(grpatch); + + Z_Free(filename); +} + // Don't spam the console, or the OS with fopen requests! static boolean nomd2s = false; @@ -1058,6 +1112,248 @@ void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startu fclose(f); } +static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, skincolors_t color) +{ + UINT16 w = gpatch->width, h = gpatch->height; + UINT32 size = w*h; + RGBA_t *image, *blendimage, *cur, blendcolor; + + if (grmip->width == 0) + { + + grmip->width = gpatch->width; + grmip->height = gpatch->height; + + // no wrap around, no chroma key + grmip->flags = 0; + // setup the texture info + grmip->grInfo.format = GR_RGBA; + } + + Z_Free(grmip->grInfo.data); + grmip->grInfo.data = NULL; + + cur = Z_Malloc(size*4, PU_HWRCACHE, &grmip->grInfo.data); + memset(cur, 0x00, size*4); + + image = gpatch->mipmap.grInfo.data; + blendimage = blendgpatch->mipmap.grInfo.data; + + switch (color) + { + case SKINCOLOR_WHITE: + blendcolor = V_GetColor(3); + break; + case SKINCOLOR_SILVER: + blendcolor = V_GetColor(11); + break; + case SKINCOLOR_GREY: + blendcolor = V_GetColor(23); + break; + case SKINCOLOR_BLACK: + blendcolor = V_GetColor(27); + break; + case SKINCOLOR_CYAN: + blendcolor = V_GetColor(216); + break; + case SKINCOLOR_TEAL: + blendcolor = V_GetColor(220); + break; + case SKINCOLOR_STEELBLUE: + blendcolor = V_GetColor(204); + break; + case SKINCOLOR_BLUE: + blendcolor = V_GetColor(234); + break; + case SKINCOLOR_PEACH: + blendcolor = V_GetColor(73); + break; + case SKINCOLOR_TAN: + blendcolor = V_GetColor(49); + break; + case SKINCOLOR_PINK: + blendcolor = V_GetColor(146); + break; + case SKINCOLOR_LAVENDER: + blendcolor = V_GetColor(252); + break; + case SKINCOLOR_PURPLE: + blendcolor = V_GetColor(195); + break; + case SKINCOLOR_ORANGE: + blendcolor = V_GetColor(87); + break; + case SKINCOLOR_ROSEWOOD: + blendcolor = V_GetColor(94); + break; + case SKINCOLOR_BEIGE: + blendcolor = V_GetColor(40); + break; + case SKINCOLOR_BROWN: + blendcolor = V_GetColor(57); + break; + case SKINCOLOR_RED: + blendcolor = V_GetColor(130); + break; + case SKINCOLOR_DARKRED: + blendcolor = V_GetColor(139); + break; + case SKINCOLOR_NEONGREEN: + blendcolor = V_GetColor(184); + break; + case SKINCOLOR_GREEN: + blendcolor = V_GetColor(170); + break; + case SKINCOLOR_ZIM: + blendcolor = V_GetColor(180); + break; + case SKINCOLOR_OLIVE: + blendcolor = V_GetColor(108); + break; + case SKINCOLOR_YELLOW: + blendcolor = V_GetColor(104); + break; + case SKINCOLOR_GOLD: + blendcolor = V_GetColor(115); + break; + + case SKINCOLOR_SUPER1: + blendcolor = V_GetColor(101); + break; + case SKINCOLOR_SUPER2: + blendcolor = V_GetColor(113); + break; + case SKINCOLOR_SUPER3: + blendcolor = V_GetColor(114); + break; + case SKINCOLOR_SUPER4: + blendcolor = V_GetColor(116); + break; + case SKINCOLOR_SUPER5: + blendcolor = V_GetColor(119); + break; + + case SKINCOLOR_TSUPER1: + blendcolor = V_GetColor(80); + break; + case SKINCOLOR_TSUPER2: + blendcolor = V_GetColor(82); + break; + case SKINCOLOR_TSUPER3: + blendcolor = V_GetColor(84); + break; + case SKINCOLOR_TSUPER4: + blendcolor = V_GetColor(85); + break; + case SKINCOLOR_TSUPER5: + blendcolor = V_GetColor(87); + break; + + case SKINCOLOR_KSUPER1: + blendcolor = V_GetColor(122); + break; + case SKINCOLOR_KSUPER2: + blendcolor = V_GetColor(123); + break; + case SKINCOLOR_KSUPER3: + blendcolor = V_GetColor(124); + break; + case SKINCOLOR_KSUPER4: + blendcolor = V_GetColor(125); + break; + case SKINCOLOR_KSUPER5: + blendcolor = V_GetColor(126); + break; + default: + blendcolor = V_GetColor(247); + break; + } + + while (size--) + { + if (blendimage->s.alpha == 0) + { + // Don't bother with blending the pixel if the alpha of the blend pixel is 0 + cur->rgba = image->rgba; + } + else + { + INT32 tempcolor; + INT16 tempmult, tempalpha; + tempalpha = -(abs(blendimage->s.red-127)-127)*2; + if (tempalpha > 255) + tempalpha = 255; + else if (tempalpha < 0) + tempalpha = 0; + + tempmult = (blendimage->s.red-127)*2; + if (tempmult > 255) + tempmult = 255; + else if (tempmult < 0) + tempmult = 0; + + tempcolor = (image->s.red*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.red)/255)) * blendimage->s.alpha)/255; + cur->s.red = (UINT8)tempcolor; + tempcolor = (image->s.green*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.green)/255)) * blendimage->s.alpha)/255; + cur->s.green = (UINT8)tempcolor; + tempcolor = (image->s.blue*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.blue)/255)) * blendimage->s.alpha)/255; + cur->s.blue = (UINT8)tempcolor; + cur->s.alpha = image->s.alpha; + } + + cur++; image++; blendimage++; + } + + return; +} + +static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, const UINT8 *colormap, skincolors_t color) +{ + // mostly copied from HWR_GetMappedPatch, hence the similarities and comment + GLMipmap_t *grmip, *newmip; + + if (colormap == colormaps || colormap == NULL) + { + // Don't do any blending + HWD.pfnSetTexture(&gpatch->mipmap); + return; + } + + // search for the mimmap + // skip the first (no colormap translated) + for (grmip = &gpatch->mipmap; grmip->nextcolormap; ) + { + grmip = grmip->nextcolormap; + if (grmip->colormap == colormap) + { + if (grmip->downloaded && grmip->grInfo.data) + { + HWD.pfnSetTexture(grmip); // found the colormap, set it to the correct texture + Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED); + return; + } + } + } + + // If here, the blended texture has not been created + // So we create it + + //BP: WARNING: don't free it manually without clearing the cache of harware renderer + // (it have a liste of mipmap) + // this malloc is cleared in HWR_FreeTextureCache + // (...) unfortunately z_malloc fragment alot the memory :(so malloc is better + newmip = calloc(1, sizeof (*newmip)); + if (newmip == NULL) + I_Error("%s: Out of memory", "HWR_GetMappedPatch"); + grmip->nextcolormap = newmip; + newmip->colormap = colormap; + + HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, color); + + HWD.pfnSetTexture(newmip); + Z_ChangeTag(newmip->grInfo.data, PU_HWRCACHE_UNLOCKED); +} + // -----------------+ // HWR_DrawMD2 : Draw MD2 @@ -1194,13 +1490,25 @@ void HWR_DrawMD2(gr_vissprite_t *spr) gpatch = md2->grpatch; if (!gpatch || !gpatch->mipmap.grInfo.format || !gpatch->mipmap.downloaded) md2_loadTexture(md2); - gpatch = md2->grpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture... + if ((gpatch && gpatch->mipmap.grInfo.format) // don't load the blend texture if the base texture isn't available + && (!md2->blendgrpatch || !((GLPatch_t *)md2->blendgrpatch)->mipmap.grInfo.format || !((GLPatch_t *)md2->blendgrpatch)->mipmap.downloaded)) + md2_loadBlendTexture(md2); + if (gpatch && gpatch->mipmap.grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture { - // This is safe, since we know the texture has been downloaded - HWD.pfnSetTexture(&gpatch->mipmap); + if ((skincolors_t)spr->mobj->color != SKINCOLOR_NONE && + md2->blendgrpatch && ((GLPatch_t *)md2->blendgrpatch)->mipmap.grInfo.format + && gpatch->width == ((GLPatch_t *)md2->blendgrpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendgrpatch)->height) + { + HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, spr->colormap, (skincolors_t)spr->mobj->color); + } + else + { + // This is safe, since we know the texture has been downloaded + HWD.pfnSetTexture(&gpatch->mipmap); + } } else { diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 0fb486ea..36078268 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -120,6 +120,7 @@ typedef struct float offset; md2_model_t *model; void *grpatch; + void *blendgrpatch; boolean notfound; INT32 skin; } md2_t; From d050a60f3600eea067c2476f8d8461309ec2b515 Mon Sep 17 00:00:00 2001 From: Sryder13 Date: Mon, 3 Aug 2015 02:01:56 +0100 Subject: [PATCH 02/39] Change a few colours. --- src/hardware/hw_md2.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 8953b3a8..e4b839b6 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1145,37 +1145,37 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, blendcolor = V_GetColor(3); break; case SKINCOLOR_SILVER: - blendcolor = V_GetColor(11); + blendcolor = V_GetColor(10); break; case SKINCOLOR_GREY: - blendcolor = V_GetColor(23); + blendcolor = V_GetColor(15); break; case SKINCOLOR_BLACK: blendcolor = V_GetColor(27); break; case SKINCOLOR_CYAN: - blendcolor = V_GetColor(216); + blendcolor = V_GetColor(215); break; case SKINCOLOR_TEAL: - blendcolor = V_GetColor(220); + blendcolor = V_GetColor(221); break; case SKINCOLOR_STEELBLUE: - blendcolor = V_GetColor(204); + blendcolor = V_GetColor(203); break; case SKINCOLOR_BLUE: - blendcolor = V_GetColor(234); + blendcolor = V_GetColor(232); break; case SKINCOLOR_PEACH: - blendcolor = V_GetColor(73); + blendcolor = V_GetColor(71); break; case SKINCOLOR_TAN: - blendcolor = V_GetColor(49); + blendcolor = V_GetColor(79); break; case SKINCOLOR_PINK: - blendcolor = V_GetColor(146); + blendcolor = V_GetColor(147); break; case SKINCOLOR_LAVENDER: - blendcolor = V_GetColor(252); + blendcolor = V_GetColor(251); break; case SKINCOLOR_PURPLE: blendcolor = V_GetColor(195); @@ -1202,7 +1202,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, blendcolor = V_GetColor(184); break; case SKINCOLOR_GREEN: - blendcolor = V_GetColor(170); + blendcolor = V_GetColor(166); break; case SKINCOLOR_ZIM: blendcolor = V_GetColor(180); @@ -1218,23 +1218,23 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, break; case SKINCOLOR_SUPER1: - blendcolor = V_GetColor(101); + blendcolor = V_GetColor(97); break; case SKINCOLOR_SUPER2: - blendcolor = V_GetColor(113); + blendcolor = V_GetColor(100); break; case SKINCOLOR_SUPER3: - blendcolor = V_GetColor(114); + blendcolor = V_GetColor(103); break; case SKINCOLOR_SUPER4: - blendcolor = V_GetColor(116); + blendcolor = V_GetColor(113); break; case SKINCOLOR_SUPER5: - blendcolor = V_GetColor(119); + blendcolor = V_GetColor(116); break; case SKINCOLOR_TSUPER1: - blendcolor = V_GetColor(80); + blendcolor = V_GetColor(81); break; case SKINCOLOR_TSUPER2: blendcolor = V_GetColor(82); From 7d914913dd94400ad3369b152aa02d845774bd4b Mon Sep 17 00:00:00 2001 From: Sean Ryder Date: Wed, 20 Jan 2016 15:55:32 +0000 Subject: [PATCH 03/39] Tabbing --- src/hardware/hw_md2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index e4b839b6..0745b9a0 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1115,8 +1115,8 @@ void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startu static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, skincolors_t color) { UINT16 w = gpatch->width, h = gpatch->height; - UINT32 size = w*h; - RGBA_t *image, *blendimage, *cur, blendcolor; + UINT32 size = w*h; + RGBA_t *image, *blendimage, *cur, blendcolor; if (grmip->width == 0) { From 662d40511d56fe1514524547376a86647bc2c0a5 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 18:02:36 -0500 Subject: [PATCH 04/39] travis: let start building with travis --- .travis.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..e69de29b From 69937b41d25decffa67850ec5ff82881e44d0898 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 18:39:06 -0500 Subject: [PATCH 05/39] travis: simple build config --- .travis.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.travis.yml b/.travis.yml index e69de29b..a1052d7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -0,0 +1,25 @@ +language: c + +os: + - linux + #- osx + +compiler: + - gcc + - clang + +addons: + apt: + packages: + - libsdl-mixer2-dev + - libpng-dev + - libglu1-dev + +before_install: + - $(CC) --version + - cmake --version + +before_script: + - mkdir build + - cd build + - cmake .. From 0003cea547eb9f47e81c1c236c0ab82acd05b597 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 18:43:18 -0500 Subject: [PATCH 06/39] travis-ci: we need sudo --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a1052d7d..b1cd1f40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: c +sudo: required + os: - linux #- osx From 14440675608a10518293d080deca55a2ab0e78b0 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 18:50:02 -0500 Subject: [PATCH 07/39] travis: use the correct packages --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b1cd1f40..f25a67cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,12 +13,11 @@ compiler: addons: apt: packages: - - libsdl-mixer2-dev + - libsdl2-mixer-dev - libpng-dev - - libglu1-dev + - ibgl1-mesa-dev before_install: - - $(CC) --version - cmake --version before_script: From 522d2049de962411e29d171fe29987f7ed40804b Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 19:08:02 -0500 Subject: [PATCH 08/39] travis: add cmake 3.x package --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index f25a67cc..f8052143 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,11 @@ compiler: addons: apt: + sources: + - george-edison55-precise-backports packages: + - cmake + - cmake-data - libsdl2-mixer-dev - libpng-dev - ibgl1-mesa-dev From 45b181f889fe750b3c84772e2b93368d8f79cc66 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 19:26:59 -0500 Subject: [PATCH 09/39] travis: switch to trusty for linux os --- .travis.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f8052143..4711df7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ language: c -sudo: required +matrix: + include: + - os: linux + dist: trusty + sudo: required os: - linux @@ -19,7 +23,7 @@ addons: - cmake-data - libsdl2-mixer-dev - libpng-dev - - ibgl1-mesa-dev + - libgl1-mesa-dev before_install: - cmake --version From 0bd16a5a0c6cdbfc011f098ea609f95038b09657 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 19:30:03 -0500 Subject: [PATCH 10/39] travis: drop osx --- .travis.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4711df7d..524c4472 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,5 @@ -language: c - -matrix: - include: - - os: linux - dist: trusty - sudo: required - -os: - - linux - #- osx +sudo: required +dist: trusty compiler: - gcc From 5e5c73fe18a8a30c97b9b54e0f3119dae18d3a6b Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 20:50:35 -0500 Subject: [PATCH 11/39] travis: add SRB2 2.1.14 files --- .travis.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 524c4472..6ce5cb08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,19 +7,25 @@ compiler: addons: apt: - sources: - - george-edison55-precise-backports packages: - - cmake - - cmake-data - libsdl2-mixer-dev - libpng-dev - libgl1-mesa-dev + - p7zip before_install: - cmake --version before_script: + - curl http://rosenthalcastle.org/srb2/SRB2-v2114-Installer.exe -o cache/SRB2-v2114-Installer.exe + - 7z x cache/SRB2-v2114-Installer.exe -o assets - mkdir build - cd build - cmake .. + +install: false + +cache: + - ccache + directories: + - cache From a743f155ac62663d333f8a3ddfee3af0e943885b Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 21:00:46 -0500 Subject: [PATCH 12/39] travis: addd libgme to list --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6ce5cb08..e077597e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ addons: - libsdl2-mixer-dev - libpng-dev - libgl1-mesa-dev + - libgme-dev - p7zip before_install: From b6cc13fd2e8955a248985061b11901a3b70c5edd Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 21:07:46 -0500 Subject: [PATCH 13/39] travis: drop test --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e077597e..cf3a03f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,6 @@ before_script: - cd build - cmake .. -install: false - cache: - ccache directories: From 152c106cbda0db3fa9381a643539e568ba1e882e Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 21:09:14 -0500 Subject: [PATCH 14/39] travis: restore language --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index cf3a03f7..ab5cdea9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +language: c + sudo: required dist: trusty @@ -24,6 +26,8 @@ before_script: - cd build - cmake .. +install: false + cache: - ccache directories: From 59d111b17d443b3be5cc4bc8534cf4b327b930e8 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 21:11:00 -0500 Subject: [PATCH 15/39] travis: restore missing config? --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index ab5cdea9..8feb76d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,3 @@ before_script: - cd build - cmake .. -install: false - -cache: - - ccache - directories: - - cache From e913ca0ca6ea332177a83aa4af8f14ab54e16690 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 21:15:32 -0500 Subject: [PATCH 16/39] travis: use wget and create cache folder --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8feb76d7..98756574 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,13 +14,14 @@ addons: - libpng-dev - libgl1-mesa-dev - libgme-dev - - p7zip + - p7zip-full before_install: - cmake --version before_script: - - curl http://rosenthalcastle.org/srb2/SRB2-v2114-Installer.exe -o cache/SRB2-v2114-Installer.exe + - make cache + - wget http://rosenthalcastle.org/srb2/SRB2-v2114-Installer.exe -c -O cache/SRB2-v2114-Installer.exe - 7z x cache/SRB2-v2114-Installer.exe -o assets - mkdir build - cd build From ae75e3ee61922527f778adde2b6650e64e11212e Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 21:21:28 -0500 Subject: [PATCH 17/39] travis: mkdir , not make and cache the cccahe --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 98756574..fdcb5247 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,10 +20,14 @@ before_install: - cmake --version before_script: - - make cache + - mkdir cache - wget http://rosenthalcastle.org/srb2/SRB2-v2114-Installer.exe -c -O cache/SRB2-v2114-Installer.exe - 7z x cache/SRB2-v2114-Installer.exe -o assets - mkdir build - cd build - cmake .. +cache: + directories: + - $HOME/.ccache + - cache From a979e37586e083ac987e9ecfcdfa36b525ac9340 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 21:28:19 -0500 Subject: [PATCH 18/39] travis: no space on 7z command --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fdcb5247..26442917 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ before_install: before_script: - mkdir cache - wget http://rosenthalcastle.org/srb2/SRB2-v2114-Installer.exe -c -O cache/SRB2-v2114-Installer.exe - - 7z x cache/SRB2-v2114-Installer.exe -o assets + - 7z x cache/SRB2-v2114-Installer.exe -oassets - mkdir build - cd build - cmake .. From 4d5f16330acbd98d17dbaf21a146be2ebe5f9691 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 21:33:00 -0500 Subject: [PATCH 19/39] travis: just run make --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 26442917..896b7a78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,8 @@ before_script: - cd build - cmake .. +script: make + cache: directories: - $HOME/.ccache From 864baeda050c9f8650b2e0b0fe27c831aad24529 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 21:49:24 -0500 Subject: [PATCH 20/39] cmake: fixed up to handle Clang and AppleClang --- src/CMakeLists.txt | 6 +++--- src/sdl/CMakeLists.txt | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6859e27c..3405e85d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -166,7 +166,7 @@ set(SRB2_CORE_GAME_SOURCES p_tick.h ) -if(NOT CLANG) +if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) set(SRB2_CORE_SOURCES ${SRB2_CORE_SOURCES} string.c) endif() @@ -404,7 +404,7 @@ endif() # Compatibility flag with later versions of GCC # We should really fix our code to not need this -if(NOT CLANG AND NOT MSVC) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields) endif() @@ -429,4 +429,4 @@ endif() if(NOT ${SRB2_SDL2_AVAILABLE} AND NOT ${SRB2_WIN32_AVAILABLE}) message(FATAL_ERROR "There are no targets available to build an SRB2 executable. :(") -endif() \ No newline at end of file +endif() diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index b3fa5390..eb832797 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -117,7 +117,7 @@ if(${SDL2_FOUND}) add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_SDL2_TOTAL_SOURCES}) set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME ${SRB2_SDL2_EXE_NAME}) - if(CLANG) + if((CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")) add_framework(CoreFoundation SRB2SDL2) add_framework(SDL2 SRB2SDL2) add_framework(SDL2_mixer SRB2SDL2) @@ -224,7 +224,7 @@ if(${SDL2_FOUND}) endif() #### Installation #### - if (CLANG) + if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") install(TARGETS SRB2SDL2 BUNDLE DESTINATION . ) @@ -265,7 +265,7 @@ if(${SDL2_FOUND}) # Mac bundle fixup - if(CLANG) + if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") install(CODE " include(BundleUtilities) fixup_bundle(\"${CMAKE_INSTALL_PREFIX}/Sonic Robo Blast 2.app\" @@ -279,4 +279,4 @@ if(${SDL2_FOUND}) else() message(WARNING "SDL2 was not found, so the SDL2 target will not be available.") set(SRB2_SDL2_AVAILABLE NO PARENT_SCOPE) -endif() \ No newline at end of file +endif() From f4886657c1e4cbbe29b472c4a088ec71e3ade6d7 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 22:12:12 -0500 Subject: [PATCH 21/39] clang: fixup a few clang warnings --- src/info.c | 2 +- src/m_menu.c | 2 +- src/p_enemy.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/info.c b/src/info.c index fb30258c..17384086 100644 --- a/src/info.c +++ b/src/info.c @@ -4225,7 +4225,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = MT_GOOP, // painchance sfx_dmpain, // painsound S_EGGMOBILE2_PAIN2, // meleestate - MT_EGGMOBILE2_POGO, // missilestate + (mobjtype_t)MT_EGGMOBILE2_POGO, // missilestate S_EGGMOBILE2_DIE1, // deathstate S_EGGMOBILE2_FLEE1,// xdeathstate sfx_cybdth, // deathsound diff --git a/src/m_menu.c b/src/m_menu.c index c7a9fcc1..1e774553 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6071,7 +6071,7 @@ static void M_RoomMenu(INT32 choice) for (i = 0; room_list[i].header.buffer[0]; i++) { - if(room_list[i].name != '\0') + if(*room_list[i].name != '\0') { MP_RoomMenu[i+1].text = room_list[i].name; roomIds[i] = room_list[i].id; diff --git a/src/p_enemy.c b/src/p_enemy.c index 18a4ec5f..6ac4e896 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -6352,7 +6352,7 @@ void A_Boss2PogoTarget(mobj_t *actor) if (actor->info->missilestate) // spawn the pogo stick collision box { - mobj_t *pogo = P_SpawnMobj(actor->x, actor->y, actor->z - mobjinfo[actor->info->missilestate].height, actor->info->missilestate); + mobj_t *pogo = P_SpawnMobj(actor->x, actor->y, actor->z - mobjinfo[actor->info->missilestate].height, (mobjtype_t)actor->info->missilestate); pogo->target = actor; } From 68054a49e344af2e4854da344408c8daf08f675f Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 22:32:14 -0500 Subject: [PATCH 22/39] clang: cleanup --- src/f_finale.c | 2 +- src/info.c | 2 +- src/m_misc.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index f541995d..466e208a 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -603,7 +603,7 @@ static void F_IntroDrawScene(void) if (finalecount-84 < 58) { // Pure Fat is driving up! int ftime = (finalecount-84); - x = (-189<lvlttl) + if (gamestate == GS_LEVEL && mapheaderinfo[gamemap-1]->lvlttl[0] != '\0') snprintf(lvlttltext, 48, "%s%s%s", mapheaderinfo[gamemap-1]->lvlttl, (mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " ZONE", From 07fc74eaf50ce8ce47e0b48bc522f5ab0a3c4639 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 22:38:40 -0500 Subject: [PATCH 23/39] clang: fixup a few clang warnings --- CMakeLists.txt | 3 --- src/CMakeLists.txt | 4 ++++ src/b_bot.c | 2 +- src/p_map.c | 4 ++-- src/p_user.c | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fb5cb28..8deeb37e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,10 +80,7 @@ endif() if(${CMAKE_SYSTEM} MATCHES "Darwin") add_definitions(-DMACOSX) - if(${CMAKE_C_COMPILER_ID} MATCHES "Clang") - set(CLANG ON) endif() -endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3405e85d..d9e25dbb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -408,6 +408,10 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields) endif() +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value) +endif() + add_definitions(-DCMAKECONFIG) #add_library(SRB2Core STATIC diff --git a/src/b_bot.c b/src/b_bot.c index 5e62e58e..3072b1d7 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -49,7 +49,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm if (sonic->player->pflags & (PF_MACESPIN|PF_ITEMHANG)) { cmd->forwardmove = sonic->player->cmd.forwardmove; - cmd->angleturn = abs(tails->angle - sonic->angle)>>16; + cmd->angleturn = abs((tails->angle - sonic->angle))>>16; if (sonic->angle < tails->angle) cmd->angleturn = -cmd->angleturn; } else if (dist > FixedMul(512*FRACUNIT, tails->scale)) diff --git a/src/p_map.c b/src/p_map.c index 62cbf7b7..1aa8bc39 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2507,8 +2507,8 @@ isblocking: climbangle += (ANGLE_90 * (whichside ? -1 : 1)); - if (((!slidemo->player->climbing && abs(slidemo->angle - ANGLE_90 - climbline) < ANGLE_45) - || (slidemo->player->climbing == 1 && abs(slidemo->angle - climbline) < ANGLE_135)) + if (((!slidemo->player->climbing && abs((slidemo->angle - ANGLE_90 - climbline)) < ANGLE_45) + || (slidemo->player->climbing == 1 && abs((slidemo->angle - climbline)) < ANGLE_135)) && P_IsClimbingValid(slidemo->player, climbangle)) { slidemo->angle = climbangle; diff --git a/src/p_user.c b/src/p_user.c index 6844d2cb..dacef733 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7902,9 +7902,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (player == &players[consoleplayer]) { if (focusangle >= localangle) - localangle += abs(focusangle - localangle)>>5; + localangle += abs((focusangle - localangle))>>5; else - localangle -= abs(focusangle - localangle)>>5; + localangle -= abs((focusangle - localangle))>>5; } } else if (P_AnalogMove(player)) // Analog From 7c1f1d9c8e52b80500221ec8e0cf28b55a8abb16 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 22:54:50 -0500 Subject: [PATCH 24/39] travis: compile with warnings as errors, skip absolute-value warnings --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 896b7a78..dfc1aef8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,9 @@ language: c sudo: required dist: trusty +env: +- CFLAGS=-Wno-absolute-value -Werror + compiler: - gcc - clang From 6d26a60cbefc20b53cc0daf65181ac998cd27582 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 23:19:38 -0500 Subject: [PATCH 25/39] travis: cache 7z SFX --- .travis.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index dfc1aef8..7a9c7c37 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: c - sudo: required dist: trusty @@ -10,6 +9,10 @@ compiler: - gcc - clang +cache: + directories: + - $HOME/srb2_cache + addons: apt: packages: @@ -19,20 +22,12 @@ addons: - libgme-dev - p7zip-full -before_install: - - cmake --version - before_script: - mkdir cache - - wget http://rosenthalcastle.org/srb2/SRB2-v2114-Installer.exe -c -O cache/SRB2-v2114-Installer.exe - - 7z x cache/SRB2-v2114-Installer.exe -oassets + - wget http://rosenthalcastle.org/srb2/SRB2-v2114-Installer.exe -c -O $HOME/srb2_cache/SRB2-v2114-Installer.exe + - 7z x $HOME/srb2_cache/SRB2-v2114-Installer.exe -oassets - mkdir build - cd build - cmake .. script: make - -cache: - directories: - - $HOME/.ccache - - cache From e9048aec4845c9e2d7c30cf93977c38ecf629ada Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 5 Feb 2016 23:22:06 -0500 Subject: [PATCH 26/39] travis: premake the cache folder --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7a9c7c37..c6a3ce79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ addons: - p7zip-full before_script: - - mkdir cache + - mkdir $HOME/srb2_cache - wget http://rosenthalcastle.org/srb2/SRB2-v2114-Installer.exe -c -O $HOME/srb2_cache/SRB2-v2114-Installer.exe - 7z x $HOME/srb2_cache/SRB2-v2114-Installer.exe -oassets - mkdir build From 914c6c9d9807569be1d33e48ec3c3837e3132c3b Mon Sep 17 00:00:00 2001 From: Yukita Mayako Date: Sun, 7 Feb 2016 21:45:16 -0500 Subject: [PATCH 27/39] Whitespace cleanup. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8deeb37e..59557ef4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ endif() if(${CMAKE_SYSTEM} MATCHES "Darwin") add_definitions(-DMACOSX) - endif() +endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") From 66175d87b89ee2ef919ad1ef66872f3b96683c16 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 8 Feb 2016 20:10:32 +0000 Subject: [PATCH 28/39] removed unused macros from doomdef.h --- src/doomdef.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 4a6d6e57..e4b426eb 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -206,13 +206,6 @@ extern FILE *logstream; // Note that we use this to help keep internal testing in check; this is why v2.1.0 is not version "1". #define MODVERSION 19 - - - - -// some tests, enable or disable it if it run or not -#define SPLITSCREEN - // ========================================================================= // The maximum number of players, multiplayer/networking. @@ -348,11 +341,7 @@ void CONS_Debug(INT32 debugflags, const char *fmt, ...) FUNCDEBUG; #include "m_swap.h" // Things that used to be in dstrings.h -#define DEVMAPS "devmaps" -#define DEVDATA "devdata" - #define SAVEGAMENAME "srb2sav" - char savegamename[256]; // m_misc.h From 31deecc51c0c920ee00dc98b5a1ba952622a9a98 Mon Sep 17 00:00:00 2001 From: Sryder13 Date: Sun, 26 Jul 2015 20:14:47 +0100 Subject: [PATCH 29/39] Colour Changing MD2s I don't know how I can move my old branch over so I've just created a new one. --- src/hardware/hw_md2.c | 314 +++++++++++++++++++++++++++++++++++++++++- src/hardware/hw_md2.h | 1 + 2 files changed, 312 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 77795ccc..e15af506 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -41,6 +41,7 @@ #include "../r_things.h" #include "hw_main.h" +#include "../v_video.h" #ifdef HAVE_PNG #ifndef _MSC_VER @@ -881,6 +882,59 @@ static void md2_loadTexture(md2_t *model) HWR_UnlockCachedPatch(grpatch); } +// -----------------+ +// md2_loadBlendTexture : Download a pcx or png texture for blending MD2 models +// -----------------+ +static void md2_loadBlendTexture(md2_t *model) +{ + GLPatch_t *grpatch; + char *filename = Z_Malloc(strlen(model->filename)+7, PU_STATIC, NULL); + strcpy(filename, model->filename); + + FIL_ForceExtension(filename, "_blend.png"); + + if (model->blendgrpatch) + { + grpatch = model->blendgrpatch; + Z_Free(grpatch->mipmap.grInfo.data); + } + else + grpatch = Z_Calloc(sizeof *grpatch, PU_HWRPATCHINFO, + &(model->blendgrpatch)); + + if (!grpatch->mipmap.downloaded && !grpatch->mipmap.grInfo.data) + { + int w = 0, h = 0; +#ifdef HAVE_PNG + grpatch->mipmap.grInfo.format = PNG_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap.grInfo.format == 0) +#endif + grpatch->mipmap.grInfo.format = PCX_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap.grInfo.format == 0) + { + Z_Free(filename); + return; + } + + grpatch->mipmap.downloaded = 0; + grpatch->mipmap.flags = 0; + + grpatch->width = (INT16)w; + grpatch->height = (INT16)h; + grpatch->mipmap.width = (UINT16)w; + grpatch->mipmap.height = (UINT16)h; + + // not correct! + grpatch->mipmap.grInfo.smallLodLog2 = GR_LOD_LOG2_256; + grpatch->mipmap.grInfo.largeLodLog2 = GR_LOD_LOG2_256; + grpatch->mipmap.grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1; + } + HWD.pfnSetTexture(&grpatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary + HWR_UnlockCachedPatch(grpatch); + + Z_Free(filename); +} + // Don't spam the console, or the OS with fopen requests! static boolean nomd2s = false; @@ -1050,6 +1104,248 @@ spritemd2found: fclose(f); } +static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, skincolors_t color) +{ + UINT16 w = gpatch->width, h = gpatch->height; + UINT32 size = w*h; + RGBA_t *image, *blendimage, *cur, blendcolor; + + if (grmip->width == 0) + { + + grmip->width = gpatch->width; + grmip->height = gpatch->height; + + // no wrap around, no chroma key + grmip->flags = 0; + // setup the texture info + grmip->grInfo.format = GR_RGBA; + } + + Z_Free(grmip->grInfo.data); + grmip->grInfo.data = NULL; + + cur = Z_Malloc(size*4, PU_HWRCACHE, &grmip->grInfo.data); + memset(cur, 0x00, size*4); + + image = gpatch->mipmap.grInfo.data; + blendimage = blendgpatch->mipmap.grInfo.data; + + switch (color) + { + case SKINCOLOR_WHITE: + blendcolor = V_GetColor(3); + break; + case SKINCOLOR_SILVER: + blendcolor = V_GetColor(11); + break; + case SKINCOLOR_GREY: + blendcolor = V_GetColor(23); + break; + case SKINCOLOR_BLACK: + blendcolor = V_GetColor(27); + break; + case SKINCOLOR_CYAN: + blendcolor = V_GetColor(216); + break; + case SKINCOLOR_TEAL: + blendcolor = V_GetColor(220); + break; + case SKINCOLOR_STEELBLUE: + blendcolor = V_GetColor(204); + break; + case SKINCOLOR_BLUE: + blendcolor = V_GetColor(234); + break; + case SKINCOLOR_PEACH: + blendcolor = V_GetColor(73); + break; + case SKINCOLOR_TAN: + blendcolor = V_GetColor(49); + break; + case SKINCOLOR_PINK: + blendcolor = V_GetColor(146); + break; + case SKINCOLOR_LAVENDER: + blendcolor = V_GetColor(252); + break; + case SKINCOLOR_PURPLE: + blendcolor = V_GetColor(195); + break; + case SKINCOLOR_ORANGE: + blendcolor = V_GetColor(87); + break; + case SKINCOLOR_ROSEWOOD: + blendcolor = V_GetColor(94); + break; + case SKINCOLOR_BEIGE: + blendcolor = V_GetColor(40); + break; + case SKINCOLOR_BROWN: + blendcolor = V_GetColor(57); + break; + case SKINCOLOR_RED: + blendcolor = V_GetColor(130); + break; + case SKINCOLOR_DARKRED: + blendcolor = V_GetColor(139); + break; + case SKINCOLOR_NEONGREEN: + blendcolor = V_GetColor(184); + break; + case SKINCOLOR_GREEN: + blendcolor = V_GetColor(170); + break; + case SKINCOLOR_ZIM: + blendcolor = V_GetColor(180); + break; + case SKINCOLOR_OLIVE: + blendcolor = V_GetColor(108); + break; + case SKINCOLOR_YELLOW: + blendcolor = V_GetColor(104); + break; + case SKINCOLOR_GOLD: + blendcolor = V_GetColor(115); + break; + + case SKINCOLOR_SUPER1: + blendcolor = V_GetColor(101); + break; + case SKINCOLOR_SUPER2: + blendcolor = V_GetColor(113); + break; + case SKINCOLOR_SUPER3: + blendcolor = V_GetColor(114); + break; + case SKINCOLOR_SUPER4: + blendcolor = V_GetColor(116); + break; + case SKINCOLOR_SUPER5: + blendcolor = V_GetColor(119); + break; + + case SKINCOLOR_TSUPER1: + blendcolor = V_GetColor(80); + break; + case SKINCOLOR_TSUPER2: + blendcolor = V_GetColor(82); + break; + case SKINCOLOR_TSUPER3: + blendcolor = V_GetColor(84); + break; + case SKINCOLOR_TSUPER4: + blendcolor = V_GetColor(85); + break; + case SKINCOLOR_TSUPER5: + blendcolor = V_GetColor(87); + break; + + case SKINCOLOR_KSUPER1: + blendcolor = V_GetColor(122); + break; + case SKINCOLOR_KSUPER2: + blendcolor = V_GetColor(123); + break; + case SKINCOLOR_KSUPER3: + blendcolor = V_GetColor(124); + break; + case SKINCOLOR_KSUPER4: + blendcolor = V_GetColor(125); + break; + case SKINCOLOR_KSUPER5: + blendcolor = V_GetColor(126); + break; + default: + blendcolor = V_GetColor(247); + break; + } + + while (size--) + { + if (blendimage->s.alpha == 0) + { + // Don't bother with blending the pixel if the alpha of the blend pixel is 0 + cur->rgba = image->rgba; + } + else + { + INT32 tempcolor; + INT16 tempmult, tempalpha; + tempalpha = -(abs(blendimage->s.red-127)-127)*2; + if (tempalpha > 255) + tempalpha = 255; + else if (tempalpha < 0) + tempalpha = 0; + + tempmult = (blendimage->s.red-127)*2; + if (tempmult > 255) + tempmult = 255; + else if (tempmult < 0) + tempmult = 0; + + tempcolor = (image->s.red*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.red)/255)) * blendimage->s.alpha)/255; + cur->s.red = (UINT8)tempcolor; + tempcolor = (image->s.green*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.green)/255)) * blendimage->s.alpha)/255; + cur->s.green = (UINT8)tempcolor; + tempcolor = (image->s.blue*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.blue)/255)) * blendimage->s.alpha)/255; + cur->s.blue = (UINT8)tempcolor; + cur->s.alpha = image->s.alpha; + } + + cur++; image++; blendimage++; + } + + return; +} + +static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, const UINT8 *colormap, skincolors_t color) +{ + // mostly copied from HWR_GetMappedPatch, hence the similarities and comment + GLMipmap_t *grmip, *newmip; + + if (colormap == colormaps || colormap == NULL) + { + // Don't do any blending + HWD.pfnSetTexture(&gpatch->mipmap); + return; + } + + // search for the mimmap + // skip the first (no colormap translated) + for (grmip = &gpatch->mipmap; grmip->nextcolormap; ) + { + grmip = grmip->nextcolormap; + if (grmip->colormap == colormap) + { + if (grmip->downloaded && grmip->grInfo.data) + { + HWD.pfnSetTexture(grmip); // found the colormap, set it to the correct texture + Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED); + return; + } + } + } + + // If here, the blended texture has not been created + // So we create it + + //BP: WARNING: don't free it manually without clearing the cache of harware renderer + // (it have a liste of mipmap) + // this malloc is cleared in HWR_FreeTextureCache + // (...) unfortunately z_malloc fragment alot the memory :(so malloc is better + newmip = calloc(1, sizeof (*newmip)); + if (newmip == NULL) + I_Error("%s: Out of memory", "HWR_GetMappedPatch"); + grmip->nextcolormap = newmip; + newmip->colormap = colormap; + + HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, color); + + HWD.pfnSetTexture(newmip); + Z_ChangeTag(newmip->grInfo.data, PU_HWRCACHE_UNLOCKED); +} + // -----------------+ // HWR_DrawMD2 : Draw MD2 @@ -1180,13 +1476,25 @@ void HWR_DrawMD2(gr_vissprite_t *spr) gpatch = md2->grpatch; if (!gpatch || !gpatch->mipmap.grInfo.format || !gpatch->mipmap.downloaded) md2_loadTexture(md2); - gpatch = md2->grpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture... + if ((gpatch && gpatch->mipmap.grInfo.format) // don't load the blend texture if the base texture isn't available + && (!md2->blendgrpatch || !((GLPatch_t *)md2->blendgrpatch)->mipmap.grInfo.format || !((GLPatch_t *)md2->blendgrpatch)->mipmap.downloaded)) + md2_loadBlendTexture(md2); + if (gpatch && gpatch->mipmap.grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture { - // This is safe, since we know the texture has been downloaded - HWD.pfnSetTexture(&gpatch->mipmap); + if ((skincolors_t)spr->mobj->color != SKINCOLOR_NONE && + md2->blendgrpatch && ((GLPatch_t *)md2->blendgrpatch)->mipmap.grInfo.format + && gpatch->width == ((GLPatch_t *)md2->blendgrpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendgrpatch)->height) + { + HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, spr->colormap, (skincolors_t)spr->mobj->color); + } + else + { + // This is safe, since we know the texture has been downloaded + HWD.pfnSetTexture(&gpatch->mipmap); + } } else { diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 0fb486ea..36078268 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -120,6 +120,7 @@ typedef struct float offset; md2_model_t *model; void *grpatch; + void *blendgrpatch; boolean notfound; INT32 skin; } md2_t; From 6b8c438e583ac5d895e0b4004dec4abca1d0ab40 Mon Sep 17 00:00:00 2001 From: Sryder13 Date: Mon, 3 Aug 2015 02:01:56 +0100 Subject: [PATCH 30/39] Change a few colours. --- src/hardware/hw_md2.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index e15af506..c336e7bb 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1137,37 +1137,37 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, blendcolor = V_GetColor(3); break; case SKINCOLOR_SILVER: - blendcolor = V_GetColor(11); + blendcolor = V_GetColor(10); break; case SKINCOLOR_GREY: - blendcolor = V_GetColor(23); + blendcolor = V_GetColor(15); break; case SKINCOLOR_BLACK: blendcolor = V_GetColor(27); break; case SKINCOLOR_CYAN: - blendcolor = V_GetColor(216); + blendcolor = V_GetColor(215); break; case SKINCOLOR_TEAL: - blendcolor = V_GetColor(220); + blendcolor = V_GetColor(221); break; case SKINCOLOR_STEELBLUE: - blendcolor = V_GetColor(204); + blendcolor = V_GetColor(203); break; case SKINCOLOR_BLUE: - blendcolor = V_GetColor(234); + blendcolor = V_GetColor(232); break; case SKINCOLOR_PEACH: - blendcolor = V_GetColor(73); + blendcolor = V_GetColor(71); break; case SKINCOLOR_TAN: - blendcolor = V_GetColor(49); + blendcolor = V_GetColor(79); break; case SKINCOLOR_PINK: - blendcolor = V_GetColor(146); + blendcolor = V_GetColor(147); break; case SKINCOLOR_LAVENDER: - blendcolor = V_GetColor(252); + blendcolor = V_GetColor(251); break; case SKINCOLOR_PURPLE: blendcolor = V_GetColor(195); @@ -1194,7 +1194,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, blendcolor = V_GetColor(184); break; case SKINCOLOR_GREEN: - blendcolor = V_GetColor(170); + blendcolor = V_GetColor(166); break; case SKINCOLOR_ZIM: blendcolor = V_GetColor(180); @@ -1210,23 +1210,23 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, break; case SKINCOLOR_SUPER1: - blendcolor = V_GetColor(101); + blendcolor = V_GetColor(97); break; case SKINCOLOR_SUPER2: - blendcolor = V_GetColor(113); + blendcolor = V_GetColor(100); break; case SKINCOLOR_SUPER3: - blendcolor = V_GetColor(114); + blendcolor = V_GetColor(103); break; case SKINCOLOR_SUPER4: - blendcolor = V_GetColor(116); + blendcolor = V_GetColor(113); break; case SKINCOLOR_SUPER5: - blendcolor = V_GetColor(119); + blendcolor = V_GetColor(116); break; case SKINCOLOR_TSUPER1: - blendcolor = V_GetColor(80); + blendcolor = V_GetColor(81); break; case SKINCOLOR_TSUPER2: blendcolor = V_GetColor(82); From ddb5652ab63c7d8720e1544af364b3252e0c1a9f Mon Sep 17 00:00:00 2001 From: Sean Ryder Date: Wed, 20 Jan 2016 15:55:32 +0000 Subject: [PATCH 31/39] Tabbing --- src/hardware/hw_md2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index c336e7bb..6a315d88 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1107,8 +1107,8 @@ spritemd2found: static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, skincolors_t color) { UINT16 w = gpatch->width, h = gpatch->height; - UINT32 size = w*h; - RGBA_t *image, *blendimage, *cur, blendcolor; + UINT32 size = w*h; + RGBA_t *image, *blendimage, *cur, blendcolor; if (grmip->width == 0) { From 5d1c8d29685831ac9693f9654a4f135715c1c7fe Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 9 Feb 2016 19:35:04 +0000 Subject: [PATCH 32/39] My cherry picking somehow lead to these functions being doubled ...whoops --- src/hardware/hw_md2.c | 242 ------------------------------------------ 1 file changed, 242 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index b71cfb66..6a315d88 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1346,248 +1346,6 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, con Z_ChangeTag(newmip->grInfo.data, PU_HWRCACHE_UNLOCKED); } -static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, skincolors_t color) -{ - UINT16 w = gpatch->width, h = gpatch->height; - UINT32 size = w*h; - RGBA_t *image, *blendimage, *cur, blendcolor; - - if (grmip->width == 0) - { - - grmip->width = gpatch->width; - grmip->height = gpatch->height; - - // no wrap around, no chroma key - grmip->flags = 0; - // setup the texture info - grmip->grInfo.format = GR_RGBA; - } - - Z_Free(grmip->grInfo.data); - grmip->grInfo.data = NULL; - - cur = Z_Malloc(size*4, PU_HWRCACHE, &grmip->grInfo.data); - memset(cur, 0x00, size*4); - - image = gpatch->mipmap.grInfo.data; - blendimage = blendgpatch->mipmap.grInfo.data; - - switch (color) - { - case SKINCOLOR_WHITE: - blendcolor = V_GetColor(3); - break; - case SKINCOLOR_SILVER: - blendcolor = V_GetColor(10); - break; - case SKINCOLOR_GREY: - blendcolor = V_GetColor(15); - break; - case SKINCOLOR_BLACK: - blendcolor = V_GetColor(27); - break; - case SKINCOLOR_CYAN: - blendcolor = V_GetColor(215); - break; - case SKINCOLOR_TEAL: - blendcolor = V_GetColor(221); - break; - case SKINCOLOR_STEELBLUE: - blendcolor = V_GetColor(203); - break; - case SKINCOLOR_BLUE: - blendcolor = V_GetColor(232); - break; - case SKINCOLOR_PEACH: - blendcolor = V_GetColor(71); - break; - case SKINCOLOR_TAN: - blendcolor = V_GetColor(79); - break; - case SKINCOLOR_PINK: - blendcolor = V_GetColor(147); - break; - case SKINCOLOR_LAVENDER: - blendcolor = V_GetColor(251); - break; - case SKINCOLOR_PURPLE: - blendcolor = V_GetColor(195); - break; - case SKINCOLOR_ORANGE: - blendcolor = V_GetColor(87); - break; - case SKINCOLOR_ROSEWOOD: - blendcolor = V_GetColor(94); - break; - case SKINCOLOR_BEIGE: - blendcolor = V_GetColor(40); - break; - case SKINCOLOR_BROWN: - blendcolor = V_GetColor(57); - break; - case SKINCOLOR_RED: - blendcolor = V_GetColor(130); - break; - case SKINCOLOR_DARKRED: - blendcolor = V_GetColor(139); - break; - case SKINCOLOR_NEONGREEN: - blendcolor = V_GetColor(184); - break; - case SKINCOLOR_GREEN: - blendcolor = V_GetColor(166); - break; - case SKINCOLOR_ZIM: - blendcolor = V_GetColor(180); - break; - case SKINCOLOR_OLIVE: - blendcolor = V_GetColor(108); - break; - case SKINCOLOR_YELLOW: - blendcolor = V_GetColor(104); - break; - case SKINCOLOR_GOLD: - blendcolor = V_GetColor(115); - break; - - case SKINCOLOR_SUPER1: - blendcolor = V_GetColor(97); - break; - case SKINCOLOR_SUPER2: - blendcolor = V_GetColor(100); - break; - case SKINCOLOR_SUPER3: - blendcolor = V_GetColor(103); - break; - case SKINCOLOR_SUPER4: - blendcolor = V_GetColor(113); - break; - case SKINCOLOR_SUPER5: - blendcolor = V_GetColor(116); - break; - - case SKINCOLOR_TSUPER1: - blendcolor = V_GetColor(81); - break; - case SKINCOLOR_TSUPER2: - blendcolor = V_GetColor(82); - break; - case SKINCOLOR_TSUPER3: - blendcolor = V_GetColor(84); - break; - case SKINCOLOR_TSUPER4: - blendcolor = V_GetColor(85); - break; - case SKINCOLOR_TSUPER5: - blendcolor = V_GetColor(87); - break; - - case SKINCOLOR_KSUPER1: - blendcolor = V_GetColor(122); - break; - case SKINCOLOR_KSUPER2: - blendcolor = V_GetColor(123); - break; - case SKINCOLOR_KSUPER3: - blendcolor = V_GetColor(124); - break; - case SKINCOLOR_KSUPER4: - blendcolor = V_GetColor(125); - break; - case SKINCOLOR_KSUPER5: - blendcolor = V_GetColor(126); - break; - default: - blendcolor = V_GetColor(247); - break; - } - - while (size--) - { - if (blendimage->s.alpha == 0) - { - // Don't bother with blending the pixel if the alpha of the blend pixel is 0 - cur->rgba = image->rgba; - } - else - { - INT32 tempcolor; - INT16 tempmult, tempalpha; - tempalpha = -(abs(blendimage->s.red-127)-127)*2; - if (tempalpha > 255) - tempalpha = 255; - else if (tempalpha < 0) - tempalpha = 0; - - tempmult = (blendimage->s.red-127)*2; - if (tempmult > 255) - tempmult = 255; - else if (tempmult < 0) - tempmult = 0; - - tempcolor = (image->s.red*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.red)/255)) * blendimage->s.alpha)/255; - cur->s.red = (UINT8)tempcolor; - tempcolor = (image->s.green*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.green)/255)) * blendimage->s.alpha)/255; - cur->s.green = (UINT8)tempcolor; - tempcolor = (image->s.blue*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.blue)/255)) * blendimage->s.alpha)/255; - cur->s.blue = (UINT8)tempcolor; - cur->s.alpha = image->s.alpha; - } - - cur++; image++; blendimage++; - } - - return; -} - -static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, const UINT8 *colormap, skincolors_t color) -{ - // mostly copied from HWR_GetMappedPatch, hence the similarities and comment - GLMipmap_t *grmip, *newmip; - - if (colormap == colormaps || colormap == NULL) - { - // Don't do any blending - HWD.pfnSetTexture(&gpatch->mipmap); - return; - } - - // search for the mimmap - // skip the first (no colormap translated) - for (grmip = &gpatch->mipmap; grmip->nextcolormap; ) - { - grmip = grmip->nextcolormap; - if (grmip->colormap == colormap) - { - if (grmip->downloaded && grmip->grInfo.data) - { - HWD.pfnSetTexture(grmip); // found the colormap, set it to the correct texture - Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED); - return; - } - } - } - - // If here, the blended texture has not been created - // So we create it - - //BP: WARNING: don't free it manually without clearing the cache of harware renderer - // (it have a liste of mipmap) - // this malloc is cleared in HWR_FreeTextureCache - // (...) unfortunately z_malloc fragment alot the memory :(so malloc is better - newmip = calloc(1, sizeof (*newmip)); - if (newmip == NULL) - I_Error("%s: Out of memory", "HWR_GetMappedPatch"); - grmip->nextcolormap = newmip; - newmip->colormap = colormap; - - HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, color); - - HWD.pfnSetTexture(newmip); - Z_ChangeTag(newmip->grInfo.data, PU_HWRCACHE_UNLOCKED); -} - // -----------------+ // HWR_DrawMD2 : Draw MD2 From e43f21cdda4a75dd5ab089316680cdba32c27c33 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Sat, 13 Feb 2016 17:30:07 -0600 Subject: [PATCH 33/39] Fix dead MF_PAIN objects hurting the player Fixes #12 --- src/p_map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 7ff913a8..61d57dcd 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -503,7 +503,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; // overhead if (thing->z + thing->height < tmthing->z) return true; // underneath - if (tmthing->player && tmthing->flags & MF_SHOOTABLE) + if (tmthing->player && tmthing->flags & MF_SHOOTABLE && thing->health > 0) P_DamageMobj(tmthing, thing, thing, 1); return true; } @@ -514,7 +514,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; // overhead if (tmthing->z + tmthing->height < thing->z) return true; // underneath - if (thing->player && thing->flags & MF_SHOOTABLE) + if (thing->player && thing->flags & MF_SHOOTABLE && tmthing->health > 0) P_DamageMobj(thing, tmthing, tmthing, 1); return true; } From 7c5adacc6f25b19474e56764553f3e6b4523e27d Mon Sep 17 00:00:00 2001 From: Inuyasha Date: Sun, 14 Feb 2016 12:28:03 -0800 Subject: [PATCH 34/39] Fixed chain launching In the process, the stasis flags work like you'd expect them to. You can now set them in Lua or code and they'll actually do something. --- src/p_inter.c | 3 +++ src/p_user.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 709e0e2b..55d36a1d 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1339,6 +1339,9 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } else player->pflags |= PF_ITEMHANG; + + // Can't jump first frame + player->pflags |= PF_JUMPSTASIS; return; case MT_BIGMINE: case MT_BIGAIRMINE: diff --git a/src/p_user.c b/src/p_user.c index 96841d7e..da65b7cb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6340,8 +6340,7 @@ static void P_MovePlayer(player_t *player) if (!(player->powers[pw_nocontrol] & (1<<15))) player->pflags |= PF_JUMPSTASIS; } - else - player->pflags &= ~PF_FULLSTASIS; + // note: don't unset stasis here if (!player->spectator && G_TagGametype()) { @@ -8928,6 +8927,11 @@ void P_PlayerThink(player_t *player) if (!player->mo) return; // P_MovePlayer removed player->mo. + // Unset statis flags after moving. + // In other words, if you manually set stasis via code, + // it lasts for one tic. + player->pflags &= ~PF_FULLSTASIS; + #ifdef POLYOBJECTS if (player->onconveyor == 1) player->cmomy = player->cmomx = 0; From b258b9b5035252dfbef8f2b7b79ddfdbdf9885cd Mon Sep 17 00:00:00 2001 From: Inuyasha Date: Mon, 22 Feb 2016 01:33:10 -0800 Subject: [PATCH 35/39] remove cpuaffinity code from SDL still exists in DD (while it exists) but no longer saves. No reason whatsoever for affinity to be settable by the game itself. --- src/sdl/i_system.c | 53 ++------------------------------------------- src/win32/win_sys.c | 2 +- 2 files changed, 3 insertions(+), 52 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index da411153..f239dd03 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -45,9 +45,6 @@ typedef DWORD (WINAPI *p_timeGetTime) (void); typedef UINT (WINAPI *p_timeEndPeriod) (UINT); typedef HANDLE (WINAPI *p_OpenFileMappingA) (DWORD, BOOL, LPCSTR); typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); -typedef HANDLE (WINAPI *p_GetCurrentProcess) (VOID); -typedef BOOL (WINAPI *p_GetProcessAffinityMask) (HANDLE, PDWORD_PTR, PDWORD_PTR); -typedef BOOL (WINAPI *p_SetProcessAffinityMask) (HANDLE, DWORD_PTR); #endif #endif #include @@ -3070,52 +3067,6 @@ const CPUInfoFlags *I_CPUInfo(void) #endif } -#if (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) -static void CPUAffinity_OnChange(void); -static consvar_t cv_cpuaffinity = {"cpuaffinity", "-1", CV_SAVE | CV_CALL, NULL, CPUAffinity_OnChange, 0, NULL, NULL, 0, 0, NULL}; - -static p_GetCurrentProcess pfnGetCurrentProcess = NULL; -static p_GetProcessAffinityMask pfnGetProcessAffinityMask = NULL; -static p_SetProcessAffinityMask pfnSetProcessAffinityMask = NULL; - -static inline VOID GetAffinityFuncs(VOID) -{ - HMODULE h = GetModuleHandleA("kernel32.dll"); - pfnGetCurrentProcess = (p_GetCurrentProcess)GetProcAddress(h, "GetCurrentProcess"); - pfnGetProcessAffinityMask = (p_GetProcessAffinityMask)GetProcAddress(h, "GetProcessAffinityMask"); - pfnSetProcessAffinityMask = (p_SetProcessAffinityMask)GetProcAddress(h, "SetProcessAffinityMask"); -} - -static void CPUAffinity_OnChange(void) -{ - DWORD_PTR dwProcMask, dwSysMask; - HANDLE selfpid; - - if (!pfnGetCurrentProcess || !pfnGetProcessAffinityMask || !pfnSetProcessAffinityMask) - return; - else - selfpid = pfnGetCurrentProcess(); - - pfnGetProcessAffinityMask(selfpid, &dwProcMask, &dwSysMask); - - /* If resulting mask is zero, don't change anything and fall back to - * actual mask. - */ - if(dwSysMask & cv_cpuaffinity.value) - { - pfnSetProcessAffinityMask(selfpid, dwSysMask & cv_cpuaffinity.value); - CV_StealthSetValue(&cv_cpuaffinity, (INT32)(dwSysMask & cv_cpuaffinity.value)); - } - else - CV_StealthSetValue(&cv_cpuaffinity, (INT32)dwProcMask); -} -#endif - -void I_RegisterSysCommands(void) -{ -#if (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) - GetAffinityFuncs(); - CV_RegisterVar(&cv_cpuaffinity); -#endif -} +// note CPUAFFINITY code used to reside here +void I_RegisterSysCommands(void) {} #endif diff --git a/src/win32/win_sys.c b/src/win32/win_sys.c index efb0be46..2babb57b 100644 --- a/src/win32/win_sys.c +++ b/src/win32/win_sys.c @@ -3656,7 +3656,7 @@ const CPUInfoFlags *I_CPUInfo(void) } static void CPUAffinity_OnChange(void); -static consvar_t cv_cpuaffinity = {"cpuaffinity", "1", CV_SAVE | CV_CALL, NULL, CPUAffinity_OnChange, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cv_cpuaffinity = {"cpuaffinity", "-1", CV_CALL, NULL, CPUAffinity_OnChange, 0, NULL, NULL, 0, 0, NULL}; typedef HANDLE (WINAPI *p_GetCurrentProcess) (VOID); static p_GetCurrentProcess pfnGetCurrentProcess = NULL; From 6dda71bef7d99c9a5fe6184b739c9f79788733a4 Mon Sep 17 00:00:00 2001 From: Inuyasha Date: Mon, 22 Feb 2016 23:05:36 -0800 Subject: [PATCH 36/39] I guess this is becoming the "try to make SDL_mixer work" branch Move InitSubSystem calls into proper places, don't use AUDIO_S16LSB (bad according to SDL_mixer docs) Add error checking --- src/sdl/i_video.c | 16 +++------------- src/sdl/mixer_sound.c | 27 ++++++++++++++++++++++++--- src/sdl/sdl_sound.c | 10 ++++++++++ 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index dbb97f09..963310a2 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1701,21 +1701,11 @@ void I_StartupGraphics(void) keyboard_started = true; #if !defined(HAVE_TTF) -#ifdef _WIN32 // Initialize Audio as well, otherwise Win32's DirectX can not use audio - if (SDL_InitSubSystem(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0) -#else //SDL_OpenAudio will do SDL_InitSubSystem(SDL_INIT_AUDIO) + // Previously audio was init here for questionable reasons? if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) -#endif { -#ifdef _WIN32 - if (SDL_WasInit(SDL_INIT_AUDIO)==0) - CONS_Printf(M_GetText("Couldn't initialize SDL's Audio System with Video System: %s\n"), SDL_GetError()); - if (SDL_WasInit(SDL_INIT_VIDEO)==0) -#endif - { - CONS_Printf(M_GetText("Couldn't initialize SDL's Video System: %s\n"), SDL_GetError()); - return; - } + CONS_Printf(M_GetText("Couldn't initialize SDL's Video System: %s\n"), SDL_GetError()); + return; } #endif { diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 71969209..50e50139 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -77,7 +77,16 @@ static INT32 current_track; void I_StartupSound(void) { I_Assert(!sound_started); - sound_started = true; + + // EE inits audio first so we're following along. + if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO) + CONS_Printf("SDL Audio already started\n"); + else if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) + { + CONS_Alert(CONS_ERROR, "Error initializing SDL Audio: %s\n", SDL_GetError()); + // call to start audio failed -- we do not have it + return; + } midimode = false; music = NULL; @@ -86,19 +95,31 @@ void I_StartupSound(void) #if SDL_MIXER_VERSION_ATLEAST(1,2,11) Mix_Init(MIX_INIT_FLAC|MIX_INIT_MOD|MIX_INIT_MP3|MIX_INIT_OGG); #endif - Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 2048); + + if (Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 2048) < 0) + { + CONS_Alert(CONS_ERROR, "Error starting SDL_Mixer: %s\n", Mix_GetError()); + // call to start audio failed -- we do not have it + return; + } + + sound_started = true; Mix_AllocateChannels(256); } void I_ShutdownSound(void) { - I_Assert(sound_started); + if (!sound_started) + return; // not an error condition sound_started = false; Mix_CloseAudio(); #if SDL_MIXER_VERSION_ATLEAST(1,2,11) Mix_Quit(); #endif + + SDL_QuitSubSystem(SDL_INIT_AUDIO); + #ifdef HAVE_LIBGME if (gme) gme_delete(gme); diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 5d6c007b..0face92e 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1213,6 +1213,16 @@ void I_StartupSound(void) // Configure sound device CONS_Printf("I_StartupSound:\n"); + // EE inits audio first so we're following along. + if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO) + CONS_Printf("SDL Audio already started\n"); + else if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) + { + CONS_Alert(CONS_ERROR, "Error initializing SDL Audio: %s\n", SDL_GetError()); + // call to start audio failed -- we do not have it + return; + } + // Open the audio device if (M_CheckParm ("-freq") && M_IsNextParm()) { From 8a369d969bc90e4d81adfeb27742f757050f786a Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Thu, 25 Feb 2016 18:28:48 -0500 Subject: [PATCH 37/39] whitespace clean --- CMakeLists.txt | 14 +++++++------- cmake/Modules/FindSDL2.cmake | 2 +- cmake/Modules/FindSDL2_main.cmake | 2 +- cmake/Modules/FindSDL2_mixer.cmake | 2 +- cmake/Modules/LibFindMacros.cmake | 8 ++++---- src/sdl/CMakeLists.txt | 2 +- src/sdl/i_system.c | 7 +++---- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59557ef4..a735be00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,13 +23,13 @@ endfunction() # Macro to add OSX framework macro(add_framework fwname appname) find_library(FRAMEWORK_${fwname} - NAMES ${fwname} - PATHS ${CMAKE_OSX_SYSROOT}/System/Library - ${CMAKE_OSX_SYSROOT}/Library - /System/Library - /Library - PATH_SUFFIXES Frameworks - NO_DEFAULT_PATH) + NAMES ${fwname} + PATHS ${CMAKE_OSX_SYSROOT}/System/Library + ${CMAKE_OSX_SYSROOT}/Library + /System/Library + /Library + ATH_SUFFIXES Frameworks + NO_DEFAULT_PATH) if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND) MESSAGE(ERROR ": Framework ${fwname} not found") else() diff --git a/cmake/Modules/FindSDL2.cmake b/cmake/Modules/FindSDL2.cmake index faa556a8..ec9f3835 100644 --- a/cmake/Modules/FindSDL2.cmake +++ b/cmake/Modules/FindSDL2.cmake @@ -1,6 +1,6 @@ # Find SDL2 # Once done, this will define -# +# # SDL2_FOUND - system has SDL2 # SDL2_INCLUDE_DIRS - SDL2 include directories # SDL2_LIBRARIES - link libraries diff --git a/cmake/Modules/FindSDL2_main.cmake b/cmake/Modules/FindSDL2_main.cmake index 280e51e2..d4cbdeb1 100644 --- a/cmake/Modules/FindSDL2_main.cmake +++ b/cmake/Modules/FindSDL2_main.cmake @@ -1,6 +1,6 @@ # Find SDL2 # Once done, this will define -# +# # SDL2_MAIN_FOUND - system has SDL2 # SDL2_MAIN_INCLUDE_DIRS - SDL2 include directories # SDL2_MAIN_LIBRARIES - link libraries diff --git a/cmake/Modules/FindSDL2_mixer.cmake b/cmake/Modules/FindSDL2_mixer.cmake index 59b4823e..9af3e26d 100644 --- a/cmake/Modules/FindSDL2_mixer.cmake +++ b/cmake/Modules/FindSDL2_mixer.cmake @@ -1,6 +1,6 @@ # Find SDL2 # Once done, this will define -# +# # SDL2_MIXER_FOUND - system has SDL2 # SDL2_MIXER_INCLUDE_DIRS - SDL2 include directories # SDL2_MIXER_LIBRARIES - link libraries diff --git a/cmake/Modules/LibFindMacros.cmake b/cmake/Modules/LibFindMacros.cmake index f6800aa7..81fef7d8 100644 --- a/cmake/Modules/LibFindMacros.cmake +++ b/cmake/Modules/LibFindMacros.cmake @@ -123,7 +123,7 @@ function (libfind_process PREFIX) set(includeopts ${${PREFIX}_PROCESS_INCLUDES}) set(libraryopts ${${PREFIX}_PROCESS_LIBS}) - # Process deps to add to + # Process deps to add to foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES}) if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS) # The package seems to export option lists that we can use, woohoo! @@ -146,11 +146,11 @@ function (libfind_process PREFIX) endif() endif() endforeach() - + if (includeopts) list(REMOVE_DUPLICATES includeopts) endif() - + if (libraryopts) list(REMOVE_DUPLICATES libraryopts) endif() @@ -215,7 +215,7 @@ function (libfind_process PREFIX) set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE) set (${PREFIX}_FOUND TRUE PARENT_SCOPE) endif() - return() + return() endif() # Format messages for debug info and the type of error diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index eb832797..b3d73452 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -57,7 +57,7 @@ if(${SDL2_FOUND}) ${SRB2_SDL2_SOURCES} ${SRB2_SDL2_HEADERS} ) - + source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS}) source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES}) source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES}) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index f239dd03..2e9ebbed 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2756,8 +2756,8 @@ static const char *locateWad(void) if (isWadPathOk(returnWadPath)) return NULL; #endif - - + + #ifdef CMAKECONFIG #ifndef NDEBUG I_OutputMsg(","CMAKE_ASSETS_DIR); @@ -2768,7 +2768,7 @@ static const char *locateWad(void) } #endif #endif - + #ifdef __APPLE__ OSX_GetResourcesPath(returnWadPath); I_OutputMsg(",%s", returnWadPath); @@ -2776,7 +2776,6 @@ static const char *locateWad(void) { return returnWadPath; } - #endif // examine default dirs From 9b55244dc32400a38d2fbbf33aaf7f8ac9446436 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 26 Feb 2016 01:39:08 -0500 Subject: [PATCH 38/39] travis: use SRB2-v2114-assets.7z --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c6a3ce79..de308582 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,8 @@ addons: before_script: - mkdir $HOME/srb2_cache - - wget http://rosenthalcastle.org/srb2/SRB2-v2114-Installer.exe -c -O $HOME/srb2_cache/SRB2-v2114-Installer.exe - - 7z x $HOME/srb2_cache/SRB2-v2114-Installer.exe -oassets + - wget http://rosenthalcastle.org/srb2/SRB2-v2114-assets.7z -c -O $HOME/srb2_cache/SRB2-v2114-assets.7z + - 7z x $HOME/srb2_cache/SRB2-v2114-assets.7z -oassets - mkdir build - cd build - cmake .. From 41f8b25c36037270229343316d1ed26edd19c3c6 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 26 Feb 2016 01:48:11 -0500 Subject: [PATCH 39/39] travis: add verbose and server-response to wget --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index de308582..db44edb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ compiler: cache: directories: - - $HOME/srb2_cache + - $HOME/srb2_cache addons: apt: @@ -24,7 +24,7 @@ addons: before_script: - mkdir $HOME/srb2_cache - - wget http://rosenthalcastle.org/srb2/SRB2-v2114-assets.7z -c -O $HOME/srb2_cache/SRB2-v2114-assets.7z + - wget --verbose --server-response -c http://rosenthalcastle.org/srb2/SRB2-v2114-assets.7z -O $HOME/srb2_cache/SRB2-v2114-assets.7z - 7z x $HOME/srb2_cache/SRB2-v2114-assets.7z -oassets - mkdir build - cd build