From 3b79ca4fae6fce10d9a45bbc3fa81e0d66cc9600 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 16:00:01 -0500 Subject: [PATCH 01/63] Improved text colormaps --- src/console.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/console.c b/src/console.c index 3eee67bb8..76c46538c 100644 --- a/src/console.c +++ b/src/console.c @@ -359,27 +359,31 @@ static void CON_SetupColormaps(void) for (i = 0; i < (256*15); i++, ++memorysrc) *memorysrc = (UINT8)(i & 0xFF); // remap each color to itself... -#define colset(map, a, b, c) \ +#define colset(map, a, b, c, d, e) \ map[1] = (UINT8)a;\ - map[3] = (UINT8)b;\ - map[9] = (UINT8)c + map[2] = (UINT8)b;\ + map[3] = (UINT8)c;\ + map[8] = (UINT8)d;\ + map[9] = (UINT8)e - colset(magentamap, 177, 178, 184); - colset(yellowmap, 82, 73, 66); - colset(lgreenmap, 97, 98, 106); - colset(bluemap, 146, 147, 155); - colset(redmap, 210, 32, 39); - colset(graymap, 6, 8, 14); - colset(orangemap, 51, 52, 57); - colset(skymap, 129, 130, 133); - colset(purplemap, 160, 161, 163); - colset(aquamap, 120, 121, 123); - colset(peridotmap, 88, 188, 190); - colset(azuremap, 144, 145, 170); - colset(brownmap, 219, 221, 224); - colset(rosymap, 200, 201, 203); - colset(invertmap, 27, 26, 22); + colset(magentamap, 177, 178, 180, 181, 183); + colset(yellowmap, 82, 73, 74, 75, 76); + colset(lgreenmap, 96, 112, 113, 114, 115); + colset(bluemap, 148, 149, 150, 151, 152); + colset(redmap, 33, 34, 35, 37, 39); + colset(graymap, 9, 11, 13, 15, 17); + colset(orangemap, 50, 52, 54, 56, 58); + colset(skymap, 129, 130, 132, 134, 135); + colset(purplemap, 161, 162, 163, 164, 166); + colset(aquamap, 121, 122, 123, 124, 125); + colset(peridotmap, 73, 188, 189, 190, 191); + colset(azuremap, 144, 145, 170, 171, 172); + colset(brownmap, 224, 226, 228, 230, 232); + colset(rosymap, 200, 201, 202, 203, 204); + colset(invertmap, 30, 29, 27, 25, 23); invertmap[26] = (UINT8)3; + invertmap[30] = (UINT8)1; + invertmap[31] = (UINT8)0; #undef colset From 14aec09d1317ef6cdec97352e383a7418dcba976 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 16:21:06 -0500 Subject: [PATCH 02/63] possibly fixed --- src/console.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/console.c b/src/console.c index 76c46538c..66e04c198 100644 --- a/src/console.c +++ b/src/console.c @@ -360,11 +360,11 @@ static void CON_SetupColormaps(void) *memorysrc = (UINT8)(i & 0xFF); // remap each color to itself... #define colset(map, a, b, c, d, e) \ - map[1] = (UINT8)a;\ + map[0] = (UINT8)a;\ map[2] = (UINT8)b;\ - map[3] = (UINT8)c;\ - map[8] = (UINT8)d;\ - map[9] = (UINT8)e + map[4] = (UINT8)c;\ + map[6] = (UINT8)d;\ + map[8] = (UINT8)e colset(magentamap, 177, 178, 180, 181, 183); colset(yellowmap, 82, 73, 74, 75, 76); From 94cee68d4141ae09453c55fdf4eca4623c286707 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 16:41:14 -0500 Subject: [PATCH 03/63] Calloc --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index 66e04c198..b0eb2ce0f 100644 --- a/src/console.c +++ b/src/console.c @@ -333,7 +333,7 @@ static void CONS_backcolor_Change(void) static void CON_SetupColormaps(void) { INT32 i; - UINT8 *memorysrc = (UINT8 *)Z_Malloc((256*15), PU_STATIC, NULL); + UINT8 *memorysrc = (UINT8 *)Z_Calloc((256*15), PU_STATIC, NULL); magentamap = memorysrc; yellowmap = (magentamap+256); From 2403cbd57ba725c92e028d99467ac8828f1f51c5 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 17:01:31 -0500 Subject: [PATCH 04/63] possibly final --- src/console.c | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/console.c b/src/console.c index b0eb2ce0f..8780bf5d2 100644 --- a/src/console.c +++ b/src/console.c @@ -360,30 +360,33 @@ static void CON_SetupColormaps(void) *memorysrc = (UINT8)(i & 0xFF); // remap each color to itself... #define colset(map, a, b, c, d, e) \ - map[0] = (UINT8)a;\ - map[2] = (UINT8)b;\ - map[4] = (UINT8)c;\ - map[6] = (UINT8)d;\ - map[8] = (UINT8)e + map[1] = (UINT8)a;\ + map[3] = (UINT8)b;\ + map[5] = (UINT8)c;\ + map[7] = (UINT8)d;\ + map[9] = (UINT8)e - colset(magentamap, 177, 178, 180, 181, 183); - colset(yellowmap, 82, 73, 74, 75, 76); - colset(lgreenmap, 96, 112, 113, 114, 115); - colset(bluemap, 148, 149, 150, 151, 152); - colset(redmap, 33, 34, 35, 37, 39); - colset(graymap, 9, 11, 13, 15, 17); - colset(orangemap, 50, 52, 54, 56, 58); - colset(skymap, 129, 130, 132, 134, 135); - colset(purplemap, 161, 162, 163, 164, 166); - colset(aquamap, 121, 122, 123, 124, 125); - colset(peridotmap, 73, 188, 189, 190, 191); - colset(azuremap, 144, 145, 170, 171, 172); - colset(brownmap, 224, 226, 228, 230, 232); - colset(rosymap, 200, 201, 202, 203, 204); - colset(invertmap, 30, 29, 27, 25, 23); - invertmap[26] = (UINT8)3; - invertmap[30] = (UINT8)1; - invertmap[31] = (UINT8)0; + colset(magentamap, 178, 179, 181, 182, 184); + colset(yellowmap, 83, 74, 75, 76, 77); + colset(lgreenmap, 97, 113, 114, 115, 116); + colset(bluemap, 149, 150, 151, 152, 153); + colset(redmap, 34, 35, 36, 38, 40); + colset(graymap, 10, 12, 14, 16, 18); + colset(orangemap, 51, 53, 55, 57, 59); + colset(skymap, 130, 131, 133, 135, 136); + colset(purplemap, 162, 163, 164, 165, 167); + colset(aquamap, 122, 123, 124, 125, 126); + colset(peridotmap, 74, 189, 190, 191, 192); + colset(azuremap, 145, 146, 171, 172, 173); + colset(brownmap, 225, 227, 229, 231, 233); + colset(rosymap, 201, 202, 203, 204, 205); + colset(invertmap, 31, 30, 28, 26, 24); + invertmap[27] = (UINT8)6; + invertmap[28] = (UINT8)5; + invertmap[29] = (UINT8)4; + invertmap[30] = (UINT8)3; + invertmap[31] = (UINT8)2; + invertmap[32] = (UINT8)1; #undef colset From e2d686ba42b42f4b1ab902672b5c10ad0f4a5dd2 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 17:45:46 -0500 Subject: [PATCH 05/63] update --- src/console.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/console.c b/src/console.c index 8780bf5d2..bffa6d18c 100644 --- a/src/console.c +++ b/src/console.c @@ -360,11 +360,11 @@ static void CON_SetupColormaps(void) *memorysrc = (UINT8)(i & 0xFF); // remap each color to itself... #define colset(map, a, b, c, d, e) \ - map[1] = (UINT8)a;\ - map[3] = (UINT8)b;\ - map[5] = (UINT8)c;\ - map[7] = (UINT8)d;\ - map[9] = (UINT8)e + map[1] = (UINT8)a;\ + map[3] = (UINT8)b;\ + map[5] = (UINT8)c;\ + map[9] = (UINT8)d;\ + map[15] = (UINT8)e colset(magentamap, 178, 179, 181, 182, 184); colset(yellowmap, 83, 74, 75, 76, 77); @@ -381,6 +381,7 @@ static void CON_SetupColormaps(void) colset(brownmap, 225, 227, 229, 231, 233); colset(rosymap, 201, 202, 203, 204, 205); colset(invertmap, 31, 30, 28, 26, 24); + invertmap[26] = (UINT8)7; invertmap[27] = (UINT8)6; invertmap[28] = (UINT8)5; invertmap[29] = (UINT8)4; From 5dc90289dc7ced8b21386b78d15dae012ca5d53b Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 21:59:34 -0500 Subject: [PATCH 06/63] thanks goldie --- src/console.c | 68 +++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/src/console.c b/src/console.c index bffa6d18c..7927ea925 100644 --- a/src/console.c +++ b/src/console.c @@ -333,7 +333,7 @@ static void CONS_backcolor_Change(void) static void CON_SetupColormaps(void) { INT32 i; - UINT8 *memorysrc = (UINT8 *)Z_Calloc((256*15), PU_STATIC, NULL); + UINT8 *memorysrc = (UINT8 *)Z_Malloc((256*15), PU_STATIC, NULL); magentamap = memorysrc; yellowmap = (magentamap+256); @@ -359,38 +359,48 @@ static void CON_SetupColormaps(void) for (i = 0; i < (256*15); i++, ++memorysrc) *memorysrc = (UINT8)(i & 0xFF); // remap each color to itself... -#define colset(map, a, b, c, d, e) \ - map[1] = (UINT8)a;\ - map[3] = (UINT8)b;\ - map[5] = (UINT8)c;\ - map[9] = (UINT8)d;\ - map[15] = (UINT8)e +#define colset(map, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \ + map[0x0] = (UINT8)a;\ + map[0x1] = (UINT8)b;\ + map[0x2] = (UINT8)c;\ + map[0x3] = (UINT8)d;\ + map[0x4] = (UINT8)e;\ + map[0x5] = (UINT8)f;\ + map[0x6] = (UINT8)g;\ + map[0x7] = (UINT8)h;\ + map[0x8] = (UINT8)i;\ + map[0x9] = (UINT8)j;\ + map[0xA] = (UINT8)k;\ + map[0xB] = (UINT8)l;\ + map[0xC] = (UINT8)m;\ + map[0xD] = (UINT8)n;\ + map[0xE] = (UINT8)o;\ + map[0xF] = (UINT8)p; - colset(magentamap, 178, 179, 181, 182, 184); - colset(yellowmap, 83, 74, 75, 76, 77); - colset(lgreenmap, 97, 113, 114, 115, 116); - colset(bluemap, 149, 150, 151, 152, 153); - colset(redmap, 34, 35, 36, 38, 40); - colset(graymap, 10, 12, 14, 16, 18); - colset(orangemap, 51, 53, 55, 57, 59); - colset(skymap, 130, 131, 133, 135, 136); - colset(purplemap, 162, 163, 164, 165, 167); - colset(aquamap, 122, 123, 124, 125, 126); - colset(peridotmap, 74, 189, 190, 191, 192); - colset(azuremap, 145, 146, 171, 172, 173); - colset(brownmap, 225, 227, 229, 231, 233); - colset(rosymap, 201, 202, 203, 204, 205); - colset(invertmap, 31, 30, 28, 26, 24); - invertmap[26] = (UINT8)7; - invertmap[27] = (UINT8)6; - invertmap[28] = (UINT8)5; - invertmap[29] = (UINT8)4; - invertmap[30] = (UINT8)3; - invertmap[31] = (UINT8)2; - invertmap[32] = (UINT8)1; + // I tried to make them kinda close to the originals, tell me how I did! ~Golden + + // 0x1 0x3 0x9 0xF + colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); + colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); + colset(lgreenmap, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111); + colset(bluemap, 147, 147, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151, 152, 152, 152); + colset(redmap, 210, 210, 211, 211, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 38, 38); + colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); + colset(orangemap, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58); + colset(skymap, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135, 136, 136); + colset(purplemap, 160, 160, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164, 165, 165, 165); + colset(aquamap, 128, 120, 121, 121, 122, 122, 123, 123, 123, 123, 124, 124, 124, 125, 125, 125); + colset(peridotmap, 72, 72, 188, 188, 188, 189, 189, 189, 189, 190, 190, 191, 191, 104, 105, 106); + colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 170, 170, 170, 171, 171, 171, 172, 172, 172); + colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); + colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 203, 203, 203, 204, 204, 205, 205, 206, 206); #undef colset + // Yeah just straight up invert it like a normal person + for (i = 0x00; i <= 0x1F; i++) + invertmap[0x1F - i] = i; + // Init back colormap CON_SetupBackColormap(); } From fed2fffaa1debb65e26acab4bddf91fd22d3cb22 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 22:52:40 -0500 Subject: [PATCH 07/63] better colors --- src/console.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/console.c b/src/console.c index 7927ea925..feffdd338 100644 --- a/src/console.c +++ b/src/console.c @@ -378,22 +378,23 @@ static void CON_SetupColormaps(void) map[0xF] = (UINT8)p; // I tried to make them kinda close to the originals, tell me how I did! ~Golden + // decent but i made most of the colors better thanks for th help :3 // 0x1 0x3 0x9 0xF - colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); + colset(magentamap, 176, 176, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183); colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); - colset(lgreenmap, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111); - colset(bluemap, 147, 147, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151, 152, 152, 152); - colset(redmap, 210, 210, 211, 211, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 38, 38); + colset(lgreenmap, 96, 96, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103); + colset(bluemap, 144, 144, 145, 145, 146, 146, 146, 147, 147, 147, 148, 148, 148, 149, 149, 149); + colset(redmap, 210, 210, 210, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 35); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); colset(orangemap, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58); - colset(skymap, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135, 136, 136); - colset(purplemap, 160, 160, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164, 165, 165, 165); - colset(aquamap, 128, 120, 121, 121, 122, 122, 123, 123, 123, 123, 124, 124, 124, 125, 125, 125); - colset(peridotmap, 72, 72, 188, 188, 188, 189, 189, 189, 189, 190, 190, 191, 191, 104, 105, 106); - colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 170, 170, 170, 171, 171, 171, 172, 172, 172); + colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); + colset(purplemap, 144, 144, 160, 160, 160, 161, 161, 161, 162, 162, 162, 162, 163, 163, 163, 163); + colset(aquamap, 128, 128, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 124, 125, 125, 125); + colset(peridotmap, 72, 72, 188, 188, 188, 189, 189, 189, 189, 190, 190, 191, 191, 104, 104, 104); + colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 147, 147, 147, 170, 170, 170, 171, 171, 171); colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); - colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 203, 203, 203, 204, 204, 205, 205, 206, 206); + colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 203, 203, 203, 204, 204, 204, 205, 205, 205); #undef colset From e5c891932aaff1ac8c8f285dd57648079c4d878b Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 23:47:14 -0500 Subject: [PATCH 08/63] improvement --- src/console.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/console.c b/src/console.c index feffdd338..0d32eae85 100644 --- a/src/console.c +++ b/src/console.c @@ -381,13 +381,13 @@ static void CON_SetupColormaps(void) // decent but i made most of the colors better thanks for th help :3 // 0x1 0x3 0x9 0xF - colset(magentamap, 176, 176, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183); + colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); - colset(lgreenmap, 96, 96, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103); - colset(bluemap, 144, 144, 145, 145, 146, 146, 146, 147, 147, 147, 148, 148, 148, 149, 149, 149); - colset(redmap, 210, 210, 210, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 35); + colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); + colset(bluemap, 147, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 151, 151, 151, 152, 152); + colset(redmap, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 37); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); - colset(orangemap, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58); + colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); colset(purplemap, 144, 144, 160, 160, 160, 161, 161, 161, 162, 162, 162, 162, 163, 163, 163, 163); colset(aquamap, 128, 128, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 124, 125, 125, 125); From d633f2495aeb95f40dce30a7be337621f7f79bee Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 19 Oct 2020 14:12:28 -0500 Subject: [PATCH 09/63] red abd bkyue sikbucx --- src/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/console.c b/src/console.c index 0d32eae85..7b32889ea 100644 --- a/src/console.c +++ b/src/console.c @@ -384,8 +384,8 @@ static void CON_SetupColormaps(void) colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); - colset(bluemap, 147, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 151, 151, 151, 152, 152); - colset(redmap, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 37); + colset(bluemap, 147, 147, 147, 148, 148, 148, 149, 149, 150, 150, 151, 151, 152, 152, 153, 153); + colset(redmap, 33, 33, 33, 34, 34, 34, 35, 35, 37, 37, 39, 39, 41, 41, 43, 43); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); From 81c9d2eae9576b6497e9b53749d36ae15739a3db Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 19 Oct 2020 18:41:23 -0500 Subject: [PATCH 10/63] forgot to send this like 3 hours ago --- src/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/console.c b/src/console.c index 7b32889ea..81d3abaac 100644 --- a/src/console.c +++ b/src/console.c @@ -384,8 +384,8 @@ static void CON_SetupColormaps(void) colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); - colset(bluemap, 147, 147, 147, 148, 148, 148, 149, 149, 150, 150, 151, 151, 152, 152, 153, 153); - colset(redmap, 33, 33, 33, 34, 34, 34, 35, 35, 37, 37, 39, 39, 41, 41, 43, 43); + colset(bluemap, 146, 146, 147, 147, 148, 148, 149, 149, 150, 150, 151, 151, 152, 152, 153, 153); + colset(redmap, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 39, 39, 41, 41, 43, 43); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); From 04eae86d0a4bfbe0abe762bf705f5c1bddff5579 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 19 Oct 2020 19:58:50 -0500 Subject: [PATCH 11/63] t --- src/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/console.c b/src/console.c index 81d3abaac..239706679 100644 --- a/src/console.c +++ b/src/console.c @@ -384,8 +384,8 @@ static void CON_SetupColormaps(void) colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); - colset(bluemap, 146, 146, 147, 147, 148, 148, 149, 149, 150, 150, 151, 151, 152, 152, 153, 153); - colset(redmap, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 39, 39, 41, 41, 43, 43); + colset(bluemap, 146, 146, 147, 147, 148, 148, 149, 149, 150, 150, 151, 151, 151, 152, 152, 152); + colset(redmap, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 39, 39, 39, 41, 41, 41); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); From 4e985d71457fde8f342e4069ac5a251b4ed611f6 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 19 Oct 2020 20:36:59 -0500 Subject: [PATCH 12/63] blue & red really seem like a hassle don't they --- src/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/console.c b/src/console.c index 239706679..b66c73bd4 100644 --- a/src/console.c +++ b/src/console.c @@ -384,8 +384,8 @@ static void CON_SetupColormaps(void) colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); - colset(bluemap, 146, 146, 147, 147, 148, 148, 149, 149, 150, 150, 151, 151, 151, 152, 152, 152); - colset(redmap, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 39, 39, 39, 41, 41, 41); + colset(bluemap, 146, 146, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151); + colset(redmap, 32, 32, 33, 33, 34, 34, 34, 35, 35, 35, 37, 37, 37, 39, 39, 39); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); From 0b48f1052a1941b5f2fcf7ef790aca319c5ea4bd Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 20 Oct 2020 14:03:27 -0500 Subject: [PATCH 13/63] pencilvoid aqua --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index b66c73bd4..ed15e583e 100644 --- a/src/console.c +++ b/src/console.c @@ -390,7 +390,7 @@ static void CON_SetupColormaps(void) colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); colset(purplemap, 144, 144, 160, 160, 160, 161, 161, 161, 162, 162, 162, 162, 163, 163, 163, 163); - colset(aquamap, 128, 128, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 124, 125, 125, 125); + colset(aquamap, 128, 120, 120, 121, 121, 122, 123, 123, 123, 124, 124, 124, 125, 125, 126, 126); colset(peridotmap, 72, 72, 188, 188, 188, 189, 189, 189, 189, 190, 190, 191, 191, 104, 104, 104); colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 147, 147, 147, 170, 170, 170, 171, 171, 171); colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); From b65ac1df30ad11101ff30e4199181d743478e1f3 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 20 Oct 2020 14:40:10 -0500 Subject: [PATCH 14/63] sonicx azure --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index ed15e583e..c181f670c 100644 --- a/src/console.c +++ b/src/console.c @@ -392,7 +392,7 @@ static void CON_SetupColormaps(void) colset(purplemap, 144, 144, 160, 160, 160, 161, 161, 161, 162, 162, 162, 162, 163, 163, 163, 163); colset(aquamap, 128, 120, 120, 121, 121, 122, 123, 123, 123, 124, 124, 124, 125, 125, 126, 126); colset(peridotmap, 72, 72, 188, 188, 188, 189, 189, 189, 189, 190, 190, 191, 191, 104, 104, 104); - colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 147, 147, 147, 170, 170, 170, 171, 171, 171); + colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 170, 170, 170, 171, 171, 171, 172, 172, 172); colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 203, 203, 203, 204, 204, 204, 205, 205, 205); From 45dd26476a7d20a8f3ffd041a96e4de9103471bc Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 20 Oct 2020 14:52:25 -0500 Subject: [PATCH 15/63] SonicX8000 purple, peridot, rosy --- src/console.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/console.c b/src/console.c index c181f670c..64c07f619 100644 --- a/src/console.c +++ b/src/console.c @@ -389,12 +389,12 @@ static void CON_SetupColormaps(void) colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); - colset(purplemap, 144, 144, 160, 160, 160, 161, 161, 161, 162, 162, 162, 162, 163, 163, 163, 163); + colset(purplemap, 144, 144, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164); colset(aquamap, 128, 120, 120, 121, 121, 122, 123, 123, 123, 124, 124, 124, 125, 125, 126, 126); - colset(peridotmap, 72, 72, 188, 188, 188, 189, 189, 189, 189, 190, 190, 191, 191, 104, 104, 104); + colset(peridotmap, 72, 72, 188, 188, 189, 189, 189, 190, 190, 190, 191, 191, 191, 104, 104, 104); colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 170, 170, 170, 171, 171, 171, 172, 172, 172); colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); - colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 203, 203, 203, 204, 204, 204, 205, 205, 205); + colset(rosymap, 200, 200, 201, 201, 202, 202, 202, 203, 203, 203, 204, 204, 204, 205, 205, 205); #undef colset From 03198ab31dd9a5e9eb791b1134d55677a2f0c782 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 20 Oct 2020 14:59:30 -0500 Subject: [PATCH 16/63] SonicX aqua --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index 64c07f619..daa5f7f1b 100644 --- a/src/console.c +++ b/src/console.c @@ -390,7 +390,7 @@ static void CON_SetupColormaps(void) colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); colset(purplemap, 144, 144, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164); - colset(aquamap, 128, 120, 120, 121, 121, 122, 123, 123, 123, 124, 124, 124, 125, 125, 126, 126); + colset(aquamap, 120, 120, 121, 121, 122, 122, 122, 123, 123, 123, 124, 124, 124, 125, 125, 125); colset(peridotmap, 72, 72, 188, 188, 189, 189, 189, 190, 190, 190, 191, 191, 191, 104, 104, 104); colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 170, 170, 170, 171, 171, 171, 172, 172, 172); colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); From 0f771edfd527f5c96d00d8da9d5065ac02f8b9f2 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 20 Oct 2020 15:11:00 -0500 Subject: [PATCH 17/63] SonicX orange --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index daa5f7f1b..5d85ca663 100644 --- a/src/console.c +++ b/src/console.c @@ -387,7 +387,7 @@ static void CON_SetupColormaps(void) colset(bluemap, 146, 146, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151); colset(redmap, 32, 32, 33, 33, 34, 34, 34, 35, 35, 35, 37, 37, 37, 39, 39, 39); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); - colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); + colset(orangemap, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); colset(purplemap, 144, 144, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164); colset(aquamap, 120, 120, 121, 121, 122, 122, 122, 123, 123, 123, 124, 124, 124, 125, 125, 125); From 88c882fa9cf9845a0331a7f43011c1a8befe2499 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 20 Oct 2020 19:59:33 -0500 Subject: [PATCH 18/63] 81 --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index 5d85ca663..24ec6443c 100644 --- a/src/console.c +++ b/src/console.c @@ -382,7 +382,7 @@ static void CON_SetupColormaps(void) // 0x1 0x3 0x9 0xF colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); - colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); + colset(yellowmap, 81, 81, 73, 73, 74, 74, 74, 65, 65, 65, 66, 66, 66, 67, 67, 67); colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); colset(bluemap, 146, 146, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151); colset(redmap, 32, 32, 33, 33, 34, 34, 34, 35, 35, 35, 37, 37, 37, 39, 39, 39); From 621efbfa158e49a33f6ba8a55c267cb10f85b602 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 4 Dec 2020 00:30:08 -0800 Subject: [PATCH 19/63] Lua taglib for accessing taggroups The global "tags" can be iterated upon for every unique tag which is set in the level. If a tag is set on a sector/line/thing, it will be included. Taking the length of "tags" will give you the number of these unique tags. (If a tag is set on multiple sectors/lines/things, it will only be counted once though.) For sectors, lines and mapthings, call the field "tagged". This function takes one argument, which is the tag. The return value can be iterated over for all the sectors/lines/things with that tag. The length can also be taken for the number of such objects. If no argument is given, the global tag is default. --- src/CMakeLists.txt | 1 + src/blua/Makefile.cfg | 1 + src/doomtype.h | 22 +++++++++++ src/lua_libs.h | 1 + src/lua_maplib.c | 60 +++++++++-------------------- src/lua_mobjlib.c | 31 +++++---------- src/lua_script.c | 59 ++++++++++++++++++++++++++-- src/lua_script.h | 48 ++++++++++++++++++++--- src/taglist.c | 90 +++++++++++++++++++++++-------------------- src/taglist.h | 10 +++++ 10 files changed, 208 insertions(+), 115 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d35e774e9..87a0499b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -276,6 +276,7 @@ set(SRB2_LUA_SOURCES lua_hudlib.c lua_infolib.c lua_maplib.c + lua_taglib.c lua_mathlib.c lua_mobjlib.c lua_playerlib.c diff --git a/src/blua/Makefile.cfg b/src/blua/Makefile.cfg index eae95ba3a..3a2962e65 100644 --- a/src/blua/Makefile.cfg +++ b/src/blua/Makefile.cfg @@ -47,6 +47,7 @@ OBJS:=$(OBJS) \ $(OBJDIR)/lua_skinlib.o \ $(OBJDIR)/lua_thinkerlib.o \ $(OBJDIR)/lua_maplib.o \ + $(OBJDIR)/lua_taglib.o \ $(OBJDIR)/lua_polyobjlib.o \ $(OBJDIR)/lua_blockmaplib.o \ $(OBJDIR)/lua_hudlib.o diff --git a/src/doomtype.h b/src/doomtype.h index 4e13ba96d..08317c65a 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -379,4 +379,26 @@ Needed for some lua shenanigans. #define FIELDFROM( type, field, have, want ) \ (void *)((intptr_t)(field) - offsetof (type, have) + offsetof (type, want)) +typedef UINT8 bitarray_t; + +#define BIT_ARRAY_SIZE(n) (((n) + 7) >> 3) + +static inline int +in_bit_array (const bitarray_t * const array, const int value) +{ + return (array[value >> 3] & (1<<(value & 7))); +} + +static inline void +set_bit_array (bitarray_t * const array, const int value) +{ + array[value >> 3] |= (1<<(value & 7)); +} + +static inline void +unset_bit_array (bitarray_t * const array, const int value) +{ + array[value >> 3] &= ~(1<<(value & 7)); +} + #endif //__DOOMTYPE__ diff --git a/src/lua_libs.h b/src/lua_libs.h index 062a3fe50..aa0638683 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -93,6 +93,7 @@ int LUA_PlayerLib(lua_State *L); int LUA_SkinLib(lua_State *L); int LUA_ThinkerLib(lua_State *L); int LUA_MapLib(lua_State *L); +int LUA_TagLib(lua_State *L); int LUA_PolyObjLib(lua_State *L); int LUA_BlockmapLib(lua_State *L); int LUA_HudLib(lua_State *L); diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 95cc8c101..a3df28cca 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1385,25 +1385,15 @@ static int lib_iterateSectors(lua_State *L) static int lib_getSector(lua_State *L) { - int field; INLEVEL - lua_settop(L, 2); - lua_remove(L, 1); // dummy userdata table is unused. - if (lua_isnumber(L, 1)) + if (lua_isnumber(L, 2)) { - size_t i = lua_tointeger(L, 1); + size_t i = lua_tointeger(L, 2); if (i >= numsectors) return 0; LUA_PushUserdata(L, §ors[i], META_SECTOR); return 1; } - field = luaL_checkoption(L, 1, NULL, array_opt); - switch(field) - { - case 0: // iterate - lua_pushcfunction(L, lib_iterateSectors); - return 1; - } return 0; } @@ -1489,25 +1479,15 @@ static int lib_iterateLines(lua_State *L) static int lib_getLine(lua_State *L) { - int field; INLEVEL - lua_settop(L, 2); - lua_remove(L, 1); // dummy userdata table is unused. - if (lua_isnumber(L, 1)) + if (lua_isnumber(L, 2)) { - size_t i = lua_tointeger(L, 1); + size_t i = lua_tointeger(L, 2); if (i >= numlines) return 0; LUA_PushUserdata(L, &lines[i], META_LINE); return 1; } - field = luaL_checkoption(L, 1, NULL, array_opt); - switch(field) - { - case 0: // iterate - lua_pushcfunction(L, lib_iterateLines); - return 1; - } return 0; } @@ -2358,15 +2338,13 @@ int LUA_MapLib(lua_State *L) //lua_setfield(L, -2, "__len"); lua_pop(L, 1); - lua_newuserdata(L, 0); - lua_createtable(L, 0, 2); - lua_pushcfunction(L, lib_getSector); - lua_setfield(L, -2, "__index"); - - lua_pushcfunction(L, lib_numsectors); - lua_setfield(L, -2, "__len"); - lua_setmetatable(L, -2); - lua_setglobal(L, "sectors"); + LUA_PushTaggableObjectArray(L, "sectors", + lib_iterateSectors, + lib_getSector, + lib_numsectors, + tags_sectors, + &numsectors, §ors, + sizeof (sector_t), META_SECTOR); lua_newuserdata(L, 0); lua_createtable(L, 0, 2); @@ -2378,15 +2356,13 @@ int LUA_MapLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "subsectors"); - lua_newuserdata(L, 0); - lua_createtable(L, 0, 2); - lua_pushcfunction(L, lib_getLine); - lua_setfield(L, -2, "__index"); - - lua_pushcfunction(L, lib_numlines); - lua_setfield(L, -2, "__len"); - lua_setmetatable(L, -2); - lua_setglobal(L, "lines"); + LUA_PushTaggableObjectArray(L, "lines", + lib_iterateLines, + lib_getLine, + lib_numlines, + tags_lines, + &numlines, &lines, + sizeof (line_t), META_LINE); lua_newuserdata(L, 0); lua_createtable(L, 0, 2); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 7aae18c90..134f104ee 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -22,8 +22,6 @@ #include "lua_hud.h" // hud_running errors #include "lua_hook.h" // hook_cmd_running errors -static const char *const array_opt[] ={"iterate",NULL}; - enum mobj_e { mobj_valid = 0, mobj_x, @@ -1003,25 +1001,15 @@ static int lib_iterateMapthings(lua_State *L) static int lib_getMapthing(lua_State *L) { - int field; INLEVEL - lua_settop(L, 2); - lua_remove(L, 1); // dummy userdata table is unused. - if (lua_isnumber(L, 1)) + if (lua_isnumber(L, 2)) { - size_t i = lua_tointeger(L, 1); + size_t i = lua_tointeger(L, 2); if (i >= nummapthings) return 0; LUA_PushUserdata(L, &mapthings[i], META_MAPTHING); return 1; } - field = luaL_checkoption(L, 1, NULL, array_opt); - switch(field) - { - case 0: // iterate - lua_pushcfunction(L, lib_iterateMapthings); - return 1; - } return 0; } @@ -1068,14 +1056,13 @@ int LUA_MobjLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L,1); - lua_newuserdata(L, 0); - lua_createtable(L, 0, 2); - lua_pushcfunction(L, lib_getMapthing); - lua_setfield(L, -2, "__index"); + LUA_PushTaggableObjectArray(L, "mapthings", + lib_iterateMapthings, + lib_getMapthing, + lib_nummapthings, + tags_mapthings, + &nummapthings, &mapthings, + sizeof (mapthing_t), META_MAPTHING); - lua_pushcfunction(L, lib_nummapthings); - lua_setfield(L, -2, "__len"); - lua_setmetatable(L, -2); - lua_setglobal(L, "mapthings"); return 0; } diff --git a/src/lua_script.c b/src/lua_script.c index eb4737f76..ee60a41c6 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -53,6 +53,7 @@ static lua_CFunction liblist[] = { LUA_SkinLib, // skin_t, skins[] LUA_ThinkerLib, // thinker_t LUA_MapLib, // line_t, side_t, sector_t, subsector_t + LUA_TagLib, // tags LUA_PolyObjLib, // polyobj_t LUA_BlockmapLib, // blockmap stuff LUA_HudLib, // HUD stuff @@ -739,25 +740,37 @@ void LUA_PushLightUserdata (lua_State *L, void *data, const char *meta) // Pushes it to the stack and stores it in the registry. void LUA_PushUserdata(lua_State *L, void *data, const char *meta) { + if (LUA_RawPushUserdata(L, data) == LPUSHED_NEW) + { + luaL_getmetatable(L, meta); + lua_setmetatable(L, -2); + } +} + +// Same as LUA_PushUserdata but don't set a metatable yet. +lpushed_t LUA_RawPushUserdata(lua_State *L, void *data) +{ + lpushed_t status = LPUSHED_NIL; + void **userdata; if (!data) { // push a NULL lua_pushnil(L); - return; + return status; } lua_getfield(L, LUA_REGISTRYINDEX, LREG_VALID); I_Assert(lua_istable(L, -1)); + lua_pushlightuserdata(L, data); lua_rawget(L, -2); + if (lua_isnil(L, -1)) { // no userdata? deary me, we'll have to make one. lua_pop(L, 1); // pop the nil // create the userdata userdata = lua_newuserdata(L, sizeof(void *)); *userdata = data; - luaL_getmetatable(L, meta); - lua_setmetatable(L, -2); // Set it in the registry so we can find it again lua_pushlightuserdata(L, data); // k (store the userdata via the data's pointer) @@ -765,8 +778,15 @@ void LUA_PushUserdata(lua_State *L, void *data, const char *meta) lua_rawset(L, -4); // stack is left with the userdata on top, as if getting it had originally succeeded. + + status = LPUSHED_NEW; } + else + status = LPUSHED_EXISTING; + lua_remove(L, -2); // remove LREG_VALID + + return status; } // When userdata is freed, use this function to remove it from Lua. @@ -1681,3 +1701,36 @@ int Lua_optoption(lua_State *L, int narg, return i; return -1; } + +void LUA_PushTaggableObjectArray +( lua_State *L, + const char *field, + lua_CFunction iterator, + lua_CFunction indexer, + lua_CFunction counter, + taggroup_t *garray[], + size_t * max_elements, + void * element_array, + size_t sizeof_element, + const char *meta) +{ + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, iterator); + lua_setfield(L, -2, "iterate"); + + LUA_InsertTaggroupIterator(L, garray, + max_elements, element_array, sizeof_element, meta); + + lua_createtable(L, 0, 1); + lua_pushcfunction(L, indexer); + lua_setfield(L, -2, "__index"); + lua_setmetatable(L, -2); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, counter); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, field); +} diff --git a/src/lua_script.h b/src/lua_script.h index 79ba0bb38..2dc34446a 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -10,10 +10,14 @@ /// \file lua_script.h /// \brief Lua scripting basics +#ifndef LUA_SCRIPT_H +#define LUA_SCRIPT_H + #include "m_fixed.h" #include "doomtype.h" #include "d_player.h" #include "g_state.h" +#include "taglist.h" #include "blua/lua.h" #include "blua/lualib.h" @@ -46,12 +50,6 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump, boolean noresults); void LUA_DumpFile(const char *filename); #endif fixed_t LUA_EvalMath(const char *word); -void LUA_PushLightUserdata(lua_State *L, void *data, const char *meta); -void LUA_PushUserdata(lua_State *L, void *data, const char *meta); -void LUA_InvalidateUserdata(void *data); -void LUA_InvalidateLevel(void); -void LUA_InvalidateMapthings(void); -void LUA_InvalidatePlayer(player_t *player); void LUA_Step(void); void LUA_Archive(void); void LUA_UnArchive(void); @@ -63,6 +61,42 @@ int Lua_optoption(lua_State *L, int narg, const char *def, const char *const lst[]); void LUAh_NetArchiveHook(lua_CFunction archFunc); +void LUA_PushTaggableObjectArray +( lua_State *L, + const char *field, + lua_CFunction iterator, + lua_CFunction indexer, + lua_CFunction counter, + taggroup_t *garray[], + size_t * max_elements, + void * element_array, + size_t sizeof_element, + const char *meta); + +void LUA_InsertTaggroupIterator +( lua_State *L, + taggroup_t *garray[], + size_t * max_elements, + void * element_array, + size_t sizeof_element, + const char * meta); + +typedef enum { + LPUSHED_NIL, + LPUSHED_NEW, + LPUSHED_EXISTING, +} lpushed_t; + +void LUA_PushLightUserdata(lua_State *L, void *data, const char *meta); +void LUA_PushUserdata(lua_State *L, void *data, const char *meta); +lpushed_t LUA_RawPushUserdata(lua_State *L, void *data); + +void LUA_InvalidateUserdata(void *data); + +void LUA_InvalidateLevel(void); +void LUA_InvalidateMapthings(void); +void LUA_InvalidatePlayer(player_t *player); + // Console wrapper void COM_Lua_f(void); @@ -98,3 +132,5 @@ void COM_Lua_f(void); #define INLEVEL if (! ISINLEVEL)\ return luaL_error(L, "This can only be used in a level!"); + +#endif/*LUA_SCRIPT_H*/ diff --git a/src/taglist.c b/src/taglist.c index b11216b6c..658605734 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -15,6 +15,11 @@ #include "z_zone.h" #include "r_data.h" +// Bit array of whether a tag exists for sectors/lines/things. +bitarray_t tags_available[BIT_ARRAY_SIZE (MAXTAGS)]; + +size_t num_tags; + // Taggroups are used to list elements of the same tag, for iteration. // Since elements can now have multiple tags, it means an element may appear // in several taggroups at the same time. These are built on level load. @@ -105,6 +110,33 @@ size_t Taggroup_Find (const taggroup_t *group, const size_t id) return -1; } +/// Iterate thru elements in a global taggroup. +INT32 Taggroup_Iterate +( taggroup_t *garray[], + const size_t max_elements, + const mtag_t tag, + const size_t p) +{ + const taggroup_t *group; + + if (tag == MTAG_GLOBAL) + { + if (p < max_elements) + return p; + return -1; + } + + group = garray[(UINT16)tag]; + + if (group) + { + if (p < group->count) + return group->elements[p]; + return -1; + } + return -1; +} + /// Add an element to a global taggroup. void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) { @@ -120,6 +152,11 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) if (Taggroup_Find(group, id) != (size_t)-1) return; + if (! in_bit_array(tags_available, tag)) + num_tags++; + + set_bit_array(tags_available, tag); + // Create group if empty. if (!group) { @@ -161,6 +198,11 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) if ((rempos = Taggroup_Find(group, id)) == (size_t)-1) return; + if (in_bit_array(tags_available, tag)) + num_tags--; + + unset_bit_array(tags_available, tag); + // Strip away taggroup if no elements left. if (!(newcount = --group->count)) { @@ -209,6 +251,9 @@ void Taglist_InitGlobalTables(void) { size_t i, j; + memset(tags_available, 0, sizeof tags_available); + num_tags = 0; + for (i = 0; i < MAXTAGS; i++) { tags_sectors[i] = NULL; @@ -236,56 +281,17 @@ void Taglist_InitGlobalTables(void) INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p) { - if (tag == MTAG_GLOBAL) - { - if (p < numsectors) - return p; - return -1; - } - - if (tags_sectors[(UINT16)tag]) - { - if (p < tags_sectors[(UINT16)tag]->count) - return tags_sectors[(UINT16)tag]->elements[p]; - return -1; - } - return -1; + return Taggroup_Iterate(tags_sectors, numsectors, tag, p); } INT32 Tag_Iterate_Lines (const mtag_t tag, const size_t p) { - if (tag == MTAG_GLOBAL) - { - if (p < numlines) - return p; - return -1; - } - - if (tags_lines[(UINT16)tag]) - { - if (p < tags_lines[(UINT16)tag]->count) - return tags_lines[(UINT16)tag]->elements[p]; - return -1; - } - return -1; + return Taggroup_Iterate(tags_lines, numlines, tag, p); } INT32 Tag_Iterate_Things (const mtag_t tag, const size_t p) { - if (tag == MTAG_GLOBAL) - { - if (p < nummapthings) - return p; - return -1; - } - - if (tags_mapthings[(UINT16)tag]) - { - if (p < tags_mapthings[(UINT16)tag]->count) - return tags_mapthings[(UINT16)tag]->elements[p]; - return -1; - } - return -1; + return Taggroup_Iterate(tags_mapthings, nummapthings, tag, p); } INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag) diff --git a/src/taglist.h b/src/taglist.h index 0e6d9f842..e5db08806 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -43,6 +43,10 @@ typedef struct size_t count; } taggroup_t; +extern bitarray_t tags_available[]; + +extern size_t num_tags; + extern taggroup_t* tags_sectors[]; extern taggroup_t* tags_lines[]; extern taggroup_t* tags_mapthings[]; @@ -51,6 +55,12 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id); void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id); size_t Taggroup_Find (const taggroup_t *group, const size_t id); +INT32 Taggroup_Iterate +( taggroup_t *garray[], + const size_t max_elements, + const mtag_t tag, + const size_t p); + void Taglist_InitGlobalTables(void); INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p); From 96851e52a10bb87c02fcc579a8407a003d9f7be5 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 4 Dec 2020 02:27:14 -0800 Subject: [PATCH 20/63] hehehehehe what if I forgot to git add? --- src/lua_taglib.c | 186 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 src/lua_taglib.c diff --git a/src/lua_taglib.c b/src/lua_taglib.c new file mode 100644 index 000000000..e6c82fea3 --- /dev/null +++ b/src/lua_taglib.c @@ -0,0 +1,186 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2020 by James R. +// Copyright (C) 2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file lua_taglib.c +/// \brief tag list iterator for Lua scripting + +#include "doomdef.h" +#include "taglist.h" +#include "r_state.h" + +#include "lua_script.h" +#include "lua_libs.h" + +static int tag_iterator(lua_State *L) +{ + INT32 tag = lua_isnil(L, 2) ? -1 : lua_tonumber(L, 2); + do + { + if (++tag >= MAXTAGS) + return 0; + } + while (! in_bit_array(tags_available, tag)) ; + lua_pushnumber(L, tag); + return 1; +} + +enum { +#define UPVALUE lua_upvalueindex + up_garray = UPVALUE(1), + up_max_elements = UPVALUE(2), + up_element_array = UPVALUE(3), + up_sizeof_element = UPVALUE(4), + up_meta = UPVALUE(5), +#undef UPVALUE +}; + +static INT32 next_element(lua_State *L, const mtag_t tag, const size_t p) +{ + taggroup_t ** garray = lua_touserdata(L, up_garray); + const size_t * max_elements = lua_touserdata(L, up_max_elements); + return Taggroup_Iterate(garray, *max_elements, tag, p); +} + +static void push_element(lua_State *L, void *element) +{ + if (LUA_RawPushUserdata(L, element) == LPUSHED_NEW) + { + lua_pushvalue(L, up_meta); + lua_setmetatable(L, -2); + } +} + +static void push_next_element(lua_State *L, const INT32 element) +{ + char * element_array = *(char **)lua_touserdata(L, up_element_array); + const size_t sizeof_element = lua_tonumber(L, up_sizeof_element); + push_element(L, &element_array[element * sizeof_element]); +} + +struct element_iterator_state { + mtag_t tag; + size_t p; +}; + +static int element_iterator(lua_State *L) +{ + struct element_iterator_state * state = lua_touserdata(L, 1); + const INT32 element = next_element(L, state->tag, state->p); + + if (element == -1) + return 0; + else + { + push_next_element(L, element); + state->p++; + return 1; + } +} + +static int lib_iterateTags(lua_State *L) +{ + if (lua_gettop(L) < 2) + { + lua_pushcfunction(L, tag_iterator); + return 1; + } + else + return tag_iterator(L); +} + +static int lib_numTags(lua_State *L) +{ + lua_pushnumber(L, num_tags); + return 1; +} + +static int lib_getTaggroup(lua_State *L) +{ + struct element_iterator_state *state; + + mtag_t tag; + + if (lua_gettop(L) > 1) + return luaL_error(L, "too many arguments"); + + if (lua_isnoneornil(L, 1)) + { + tag = MTAG_GLOBAL; + } + else + { + tag = lua_tonumber(L, 1); + luaL_argcheck(L, tag >= -1, 1, "tag out of range"); + } + + state = lua_newuserdata(L, sizeof *state); + state->tag = tag; + state->p = 0; + + lua_pushvalue(L, lua_upvalueindex(1)); + lua_setmetatable(L, -2); + + return 1; +} + +static int lib_numTaggroupElements(lua_State *L) +{ + const mtag_t tag = *(mtag_t *)lua_touserdata(L, 1); + if (tag == MTAG_GLOBAL) + lua_pushnumber(L, *(size_t *)lua_touserdata(L, up_max_elements)); + else + { + const taggroup_t ** garray = lua_touserdata(L, up_garray); + lua_pushnumber(L, garray[tag] ? garray[tag]->count : 0); + } + return 1; +} + +void LUA_InsertTaggroupIterator +( lua_State *L, + taggroup_t *garray[], + size_t * max_elements, + void * element_array, + size_t sizeof_element, + const char * meta) +{ + lua_createtable(L, 0, 2); + lua_pushlightuserdata(L, garray); + lua_pushlightuserdata(L, max_elements); + + lua_pushvalue(L, -2); + lua_pushvalue(L, -2); + lua_pushlightuserdata(L, element_array); + lua_pushnumber(L, sizeof_element); + luaL_getmetatable(L, meta); + lua_pushcclosure(L, element_iterator, 5); + lua_setfield(L, -4, "__call"); + + lua_pushcclosure(L, lib_numTaggroupElements, 2); + lua_setfield(L, -2, "__len"); + lua_pushcclosure(L, lib_getTaggroup, 1); + lua_setfield(L, -2, "tagged"); +} + +int LUA_TagLib(lua_State *L) +{ + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_createtable(L, 0, 1); + lua_pushcfunction(L, lib_iterateTags); + lua_setfield(L, -2, "iterate"); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_numTags); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, "tags"); + + return 0; +} From c2217bb42689502a9511a752b6e6aae3fc60aa07 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 4 Dec 2020 04:54:12 -0800 Subject: [PATCH 21/63] Mkae Lua taggroups indexable They are 1-indexed. --- src/lua_taglib.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index e6c82fea3..2e2a0d277 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -71,16 +71,9 @@ struct element_iterator_state { static int element_iterator(lua_State *L) { struct element_iterator_state * state = lua_touserdata(L, 1); - const INT32 element = next_element(L, state->tag, state->p); - - if (element == -1) - return 0; - else - { - push_next_element(L, element); - state->p++; - return 1; - } + lua_pushnumber(L, ++state->p); + lua_gettable(L, 1); + return 1; } static int lib_iterateTags(lua_State *L) @@ -129,6 +122,21 @@ static int lib_getTaggroup(lua_State *L) return 1; } +static int lib_getTaggroupElement(lua_State *L) +{ + const size_t p = luaL_checknumber(L, 2) - 1; + const mtag_t tag = *(mtag_t *)lua_touserdata(L, 1); + const INT32 element = next_element(L, tag, p); + + if (element == -1) + return 0; + else + { + push_next_element(L, element); + return 1; + } +} + static int lib_numTaggroupElements(lua_State *L) { const mtag_t tag = *(mtag_t *)lua_touserdata(L, 1); @@ -150,7 +158,7 @@ void LUA_InsertTaggroupIterator size_t sizeof_element, const char * meta) { - lua_createtable(L, 0, 2); + lua_createtable(L, 0, 3); lua_pushlightuserdata(L, garray); lua_pushlightuserdata(L, max_elements); @@ -159,11 +167,14 @@ void LUA_InsertTaggroupIterator lua_pushlightuserdata(L, element_array); lua_pushnumber(L, sizeof_element); luaL_getmetatable(L, meta); - lua_pushcclosure(L, element_iterator, 5); - lua_setfield(L, -4, "__call"); + lua_pushcclosure(L, lib_getTaggroupElement, 5); + lua_setfield(L, -4, "__index"); lua_pushcclosure(L, lib_numTaggroupElements, 2); lua_setfield(L, -2, "__len"); + + lua_pushcfunction(L, element_iterator); + lua_setfield(L, -2, "__call"); lua_pushcclosure(L, lib_getTaggroup, 1); lua_setfield(L, -2, "tagged"); } From 314fd2783a2b22c2803b9063994a2dd48ddd98a7 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 4 Dec 2020 13:47:22 -0800 Subject: [PATCH 22/63] Lua tag lists Index and take length of tag lists like a table, 1-indexed. There are three methods which may be used on tag lists: list:iterate() - returns an iterator over the tags in the list list:has(tag) - returns a boolean whether the tag is in the list list.shares(list2) - returns whether two lists share a tag "find" is also an alias to "has". Each method may be accessed from the global taglist library too, e.g. taglist.iterate(list) Tag lists may be compared with an equality operator too. This will tell you if the two lists are composed of identical tags. Accessible from sector.taglist, line.taglist and mapthing.taglist. --- src/lua_baselib.c | 3 + src/lua_libs.h | 3 + src/lua_maplib.c | 12 ++++ src/lua_mobjlib.c | 7 +++ src/lua_script.h | 2 + src/lua_taglib.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 183 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 4667fdbf4..1324322a2 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -184,12 +184,15 @@ static const struct { {META_CVAR, "consvar_t"}, {META_SECTORLINES, "sector_t.lines"}, + {META_SECTORTAGLIST, "sector_t.taglist"}, {META_SIDENUM, "line_t.sidenum"}, {META_LINEARGS, "line_t.args"}, {META_LINESTRINGARGS, "line_t.stringargs"}, + {META_LINETAGLIST, "line_t.taglist"}, {META_THINGARGS, "mapthing.args"}, {META_THINGSTRINGARGS, "mapthing.stringargs"}, + {META_THINGTAGLIST, "mapthing_t.taglist"}, #ifdef HAVE_LUA_SEGS {META_NODEBBOX, "node_t.bbox"}, {META_NODECHILDREN, "node_t.children"}, diff --git a/src/lua_libs.h b/src/lua_libs.h index aa0638683..991fae3fd 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -56,11 +56,14 @@ extern lua_State *gL; #define META_CVAR "CONSVAR_T*" #define META_SECTORLINES "SECTOR_T*LINES" +#define META_SECTORTAGLIST "SECTOR_T*TAGLIST" #define META_SIDENUM "LINE_T*SIDENUM" #define META_LINEARGS "LINE_T*ARGS" #define META_LINESTRINGARGS "LINE_T*STRINGARGS" +#define META_LINETAGLIST "LINE_T*TAGLIST" #define META_THINGARGS "MAPTHING_T*ARGS" #define META_THINGSTRINGARGS "MAPTHING_T*STRINGARGS" +#define META_THINGTAGLIST "THING_T*TAGLIST" #define META_POLYOBJVERTICES "POLYOBJ_T*VERTICES" #define META_POLYOBJLINES "POLYOBJ_T*LINES" #ifdef HAVE_LUA_SEGS diff --git a/src/lua_maplib.c b/src/lua_maplib.c index a3df28cca..25edf83d8 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -37,6 +37,7 @@ enum sector_e { sector_lightlevel, sector_special, sector_tag, + sector_taglist, sector_thinglist, sector_heightsec, sector_camsec, @@ -55,6 +56,7 @@ static const char *const sector_opt[] = { "lightlevel", "special", "tag", + "taglist", "thinglist", "heightsec", "camsec", @@ -89,6 +91,7 @@ enum line_e { line_flags, line_special, line_tag, + line_taglist, line_args, line_stringargs, line_sidenum, @@ -113,6 +116,7 @@ static const char *const line_opt[] = { "flags", "special", "tag", + "taglist", "args", "stringargs", "sidenum", @@ -581,6 +585,9 @@ static int sector_get(lua_State *L) case sector_tag: lua_pushinteger(L, Tag_FGet(§or->tags)); return 1; + case sector_taglist: + LUA_PushUserdata(L, §or->tags, META_SECTORTAGLIST); + return 1; case sector_thinglist: // thinglist lua_pushcfunction(L, lib_iterateSectorThinglist); LUA_PushUserdata(L, sector->thinglist, META_MOBJ); @@ -682,6 +689,8 @@ static int sector_set(lua_State *L) case sector_tag: Tag_SectorFSet((UINT32)(sector - sectors), (INT16)luaL_checkinteger(L, 3)); break; + case sector_taglist: + return LUA_ErrSetDirectly(L, "sector_t", "taglist"); } return 0; } @@ -821,6 +830,9 @@ static int line_get(lua_State *L) case line_tag: lua_pushinteger(L, Tag_FGet(&line->tags)); return 1; + case line_taglist: + LUA_PushUserdata(L, &line->tags, META_LINETAGLIST); + return 1; case line_args: LUA_PushUserdata(L, line->args, META_LINEARGS); return 1; diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 134f104ee..8d205780d 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -902,6 +902,11 @@ static int mapthing_get(lua_State *L) number = mt->extrainfo; else if(fastcmp(field,"tag")) number = Tag_FGet(&mt->tags); + else if(fastcmp(field,"taglist")) + { + LUA_PushUserdata(L, &mt->tags, META_THINGTAGLIST); + return 1; + } else if(fastcmp(field,"args")) { LUA_PushUserdata(L, mt->args, META_THINGARGS); @@ -964,6 +969,8 @@ static int mapthing_set(lua_State *L) } else if (fastcmp(field,"tag")) Tag_FSet(&mt->tags, (INT16)luaL_checkinteger(L, 3)); + else if (fastcmp(field,"taglist")) + return LUA_ErrSetDirectly(L, "mapthing_t", "taglist"); else if(fastcmp(field,"mobj")) mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); else diff --git a/src/lua_script.h b/src/lua_script.h index 2dc34446a..77fbb7c1d 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -102,6 +102,8 @@ void COM_Lua_f(void); #define LUA_ErrInvalid(L, type) luaL_error(L, "accessed " type " doesn't exist anymore, please check 'valid' before using " type "."); +#define LUA_ErrSetDirectly(L, type, field) luaL_error(L, type " field " LUA_QL(field) " cannot be set directly.") + // Deprecation warnings // Shows once upon use. Then doesn't show again. #define LUA_Deprecated(L,this_func,use_instead)\ diff --git a/src/lua_taglib.c b/src/lua_taglib.c index 2e2a0d277..73f033312 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -150,6 +150,137 @@ static int lib_numTaggroupElements(lua_State *L) return 1; } +static void push_taglist(lua_State *L, int idx) +{ + lua_getmetatable(L, idx); + lua_pushliteral(L, "taglist"); + lua_rawget(L, -2); + lua_remove(L, -2); +} + +static int has_valid_field(lua_State *L) +{ + int equal; + lua_pushliteral(L, "valid"); + equal = lua_rawequal(L, 2, -1); + lua_pop(L, 1); + return equal; +} + +static taglist_t * valid_taglist(lua_State *L, int idx, boolean getting) +{ + taglist_t *list = *(taglist_t **)lua_touserdata(L, idx); + + if (list == NULL) + { + if (getting && has_valid_field(L)) + lua_pushboolean(L, 0); + else + LUA_ErrInvalid(L, "taglist_t");/* doesn't actually return */ + return NULL; + } + else + return list; +} + +static taglist_t * check_taglist(lua_State *L, int idx) +{ + luaL_checktype(L, idx, LUA_TUSERDATA); + push_taglist(L, idx); + luaL_argcheck(L, lua_toboolean(L, -1), idx, "must be a tag list"); + return valid_taglist(L, idx, false); +} + +static int taglist_get(lua_State *L) +{ + const taglist_t *list = valid_taglist(L, 1, true); + + if (list == NULL)/* valid check */ + return 1; + + if (lua_isnumber(L, 2)) + { + const size_t i = lua_tonumber(L, 2); + + if (list && i <= list->count) + { + lua_pushnumber(L, list->tags[i - 1]); + return 1; + } + else + return 0; + } + else if (has_valid_field(L)) + { + lua_pushboolean(L, 1); + return 1; + } + else + { + push_taglist(L, 1); + lua_replace(L, 1); + lua_rawget(L, 1); + return 1; + } +} + +static int taglist_len(lua_State *L) +{ + const taglist_t *list = valid_taglist(L, 1, false); + lua_pushnumber(L, list->count); + return 1; +} + +static int taglist_equal(lua_State *L) +{ + const taglist_t *lhs = check_taglist(L, 1); + const taglist_t *rhs = check_taglist(L, 2); + lua_pushboolean(L, Tag_Compare(lhs, rhs)); + return 1; +} + +static int taglist_iterator(lua_State *L) +{ + const taglist_t *list = valid_taglist(L, 1, false); + const size_t i = 1 + lua_tonumber(L, lua_upvalueindex(1)); + if (i <= list->count) + { + lua_pushnumber(L, list->tags[i - 1]); + /* watch me exploit an upvalue as a control because + I want to use the control as the value */ + lua_pushnumber(L, i); + lua_replace(L, lua_upvalueindex(1)); + return 1; + } + else + return 0; +} + +static int taglist_iterate(lua_State *L) +{ + check_taglist(L, 1); + lua_pushnumber(L, 0); + lua_pushcclosure(L, taglist_iterator, 1); + lua_pushvalue(L, 1); + return 2; +} + +static int taglist_find(lua_State *L) +{ + const taglist_t *list = check_taglist(L, 1); + const mtag_t tag = luaL_checknumber(L, 2); + lua_pushboolean(L, Tag_Find(list, tag)); + return 1; +} + +static int taglist_shares(lua_State *L) +{ + const taglist_t *lhs = check_taglist(L, 1); + const taglist_t *rhs = check_taglist(L, 2); + lua_pushboolean(L, Tag_Share(lhs, rhs)); + return 1; +} + void LUA_InsertTaggroupIterator ( lua_State *L, taggroup_t *garray[], @@ -179,6 +310,13 @@ void LUA_InsertTaggroupIterator lua_setfield(L, -2, "tagged"); } +static luaL_Reg taglist_lib[] = { + {"iterate", taglist_iterate}, + {"find", taglist_find}, + {"shares", taglist_shares}, + {0} +}; + int LUA_TagLib(lua_State *L) { lua_newuserdata(L, 0); @@ -193,5 +331,23 @@ int LUA_TagLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "tags"); + luaL_newmetatable(L, META_THINGTAGLIST); + luaL_register(L, "taglist", taglist_lib); + lua_getfield(L, -1, "find"); + lua_setfield(L, -2, "has"); + lua_setfield(L, -2, "taglist"); + + lua_pushcfunction(L, taglist_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, taglist_len); + lua_setfield(L, -2, "__len"); + + lua_pushcfunction(L, taglist_equal); + lua_setfield(L, -2, "__eq"); + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, META_LINETAGLIST); + lua_setfield(L, LUA_REGISTRYINDEX, META_SECTORTAGLIST); + return 0; } From 828d7e71ce62d1dae4ddcd7fe9319229005eac75 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 5 Dec 2020 00:36:54 -0800 Subject: [PATCH 23/63] Fix uninitialized last element when using Taggroup_Remove --- src/taglist.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index 658605734..7dbad65c4 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -188,7 +188,7 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) { taggroup_t *group; size_t rempos; - size_t newcount; + size_t oldcount; if (tag == MTAG_GLOBAL) return; @@ -204,7 +204,7 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) unset_bit_array(tags_available, tag); // Strip away taggroup if no elements left. - if (!(newcount = --group->count)) + if (!(oldcount = group->count--)) { Z_Free(group->elements); Z_Free(group); @@ -212,19 +212,18 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) } else { - size_t *newelements = Z_Malloc(newcount * sizeof(size_t), PU_LEVEL, NULL); + size_t *newelements = Z_Malloc(group->count * sizeof(size_t), PU_LEVEL, NULL); size_t i; // Copy the previous entries save for the one to remove. for (i = 0; i < rempos; i++) newelements[i] = group->elements[i]; - for (i = rempos + 1; i < group->count; i++) + for (i = rempos + 1; i < oldcount; i++) newelements[i - 1] = group->elements[i]; Z_Free(group->elements); group->elements = newelements; - group->count = newcount; } } From ae663e724774007e0242fc509c87402a3ff7b7c4 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 5 Dec 2020 00:46:51 -0800 Subject: [PATCH 24/63] Don't realloc twice when adding to the taggroup --- src/taglist.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index 7dbad65c4..cfd9cbb9c 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -170,16 +170,15 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) for (i = 0; i < group->count; i++) if (group->elements[i] > id) break; - - group->elements = Z_Realloc(group->elements, (group->count + 1) * sizeof(size_t), PU_LEVEL, NULL); - - // Offset existing elements to make room for the new one. - if (i < group->count) - memmove(&group->elements[i + 1], &group->elements[i], group->count - i); } + group->elements = Z_Realloc(group->elements, (group->count + 1) * sizeof(size_t), PU_LEVEL, NULL); + + // Offset existing elements to make room for the new one. + if (i < group->count) + memmove(&group->elements[i + 1], &group->elements[i], group->count - i); + group->count++; - group->elements = Z_Realloc(group->elements, group->count * sizeof(size_t), PU_LEVEL, NULL); group->elements[i] = id; } From e5a3e6a845e105566dd6def263cd2d7326155d42 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 5 Dec 2020 01:14:52 -0800 Subject: [PATCH 25/63] Fix removing a tag unsetting the bit array even if more elements with that tag exist --- src/lua_taglib.c | 2 +- src/taglist.c | 28 +++++++++++++++++++++++----- src/taglist.h | 1 + 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index 73f033312..07646af87 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -145,7 +145,7 @@ static int lib_numTaggroupElements(lua_State *L) else { const taggroup_t ** garray = lua_touserdata(L, up_garray); - lua_pushnumber(L, garray[tag] ? garray[tag]->count : 0); + lua_pushnumber(L, Taggroup_Count(garray[tag])); } return 1; } diff --git a/src/taglist.c b/src/taglist.c index cfd9cbb9c..a759f4d02 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -110,6 +110,12 @@ size_t Taggroup_Find (const taggroup_t *group, const size_t id) return -1; } +/// group->count, but also checks for NULL +size_t Taggroup_Count (const taggroup_t *group) +{ + return group ? group->count : 0; +} + /// Iterate thru elements in a global taggroup. INT32 Taggroup_Iterate ( taggroup_t *garray[], @@ -153,9 +159,10 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) return; if (! in_bit_array(tags_available, tag)) + { num_tags++; - - set_bit_array(tags_available, tag); + set_bit_array(tags_available, tag); + } // Create group if empty. if (!group) @@ -182,6 +189,16 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) group->elements[i] = id; } +static size_t total_elements_with_tag (const mtag_t tag) +{ + return + ( + Taggroup_Count(tags_sectors[tag]) + + Taggroup_Count(tags_lines[tag]) + + Taggroup_Count(tags_mapthings[tag]) + ); +} + /// Remove an element from a global taggroup. void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) { @@ -197,10 +214,11 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) if ((rempos = Taggroup_Find(group, id)) == (size_t)-1) return; - if (in_bit_array(tags_available, tag)) + if (group->count == 1 && total_elements_with_tag(tag) == 1) + { num_tags--; - - unset_bit_array(tags_available, tag); + unset_bit_array(tags_available, tag); + } // Strip away taggroup if no elements left. if (!(oldcount = group->count--)) diff --git a/src/taglist.h b/src/taglist.h index e5db08806..a0529ab6b 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -54,6 +54,7 @@ extern taggroup_t* tags_mapthings[]; void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id); void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id); size_t Taggroup_Find (const taggroup_t *group, const size_t id); +size_t Taggroup_Count (const taggroup_t *group); INT32 Taggroup_Iterate ( taggroup_t *garray[], From 8dd964e3a726a30ad50e7cfc3a5d0356351f24bf Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 5 Dec 2020 02:02:06 -0800 Subject: [PATCH 26/63] Lua: taglist.add and taglist.remove for sector tag lists --- src/lua_baselib.c | 6 ++- src/lua_libs.h | 10 +++-- src/lua_maplib.c | 2 +- src/lua_mobjlib.c | 2 +- src/lua_taglib.c | 110 +++++++++++++++++++++++++++++++++++++++------- 5 files changed, 108 insertions(+), 22 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 1324322a2..59c1d411b 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -155,6 +155,8 @@ static const struct { {META_PIVOTLIST, "spriteframepivot_t[]"}, {META_FRAMEPIVOT, "spriteframepivot_t"}, + {META_TAGLIST, "taglist"}, + {META_MOBJ, "mobj_t"}, {META_MAPTHING, "mapthing_t"}, @@ -184,15 +186,15 @@ static const struct { {META_CVAR, "consvar_t"}, {META_SECTORLINES, "sector_t.lines"}, +#ifdef MUTABLE_TAGS {META_SECTORTAGLIST, "sector_t.taglist"}, +#endif {META_SIDENUM, "line_t.sidenum"}, {META_LINEARGS, "line_t.args"}, {META_LINESTRINGARGS, "line_t.stringargs"}, - {META_LINETAGLIST, "line_t.taglist"}, {META_THINGARGS, "mapthing.args"}, {META_THINGSTRINGARGS, "mapthing.stringargs"}, - {META_THINGTAGLIST, "mapthing_t.taglist"}, #ifdef HAVE_LUA_SEGS {META_NODEBBOX, "node_t.bbox"}, {META_NODECHILDREN, "node_t.children"}, diff --git a/src/lua_libs.h b/src/lua_libs.h index 991fae3fd..e7f4ae253 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -12,6 +12,8 @@ extern lua_State *gL; +#define MUTABLE_TAGS + #define LREG_VALID "VALID_USERDATA" #define LREG_EXTVARS "LUA_VARS" #define LREG_STATEACTION "STATE_ACTION" @@ -27,6 +29,8 @@ extern lua_State *gL; #define META_PIVOTLIST "SPRITEFRAMEPIVOT_T[]" #define META_FRAMEPIVOT "SPRITEFRAMEPIVOT_T*" +#define META_TAGLIST "TAGLIST" + #define META_MOBJ "MOBJ_T*" #define META_MAPTHING "MAPTHING_T*" @@ -56,14 +60,14 @@ extern lua_State *gL; #define META_CVAR "CONSVAR_T*" #define META_SECTORLINES "SECTOR_T*LINES" -#define META_SECTORTAGLIST "SECTOR_T*TAGLIST" +#ifdef MUTABLE_TAGS +#define META_SECTORTAGLIST "sector_t.taglist" +#endif #define META_SIDENUM "LINE_T*SIDENUM" #define META_LINEARGS "LINE_T*ARGS" #define META_LINESTRINGARGS "LINE_T*STRINGARGS" -#define META_LINETAGLIST "LINE_T*TAGLIST" #define META_THINGARGS "MAPTHING_T*ARGS" #define META_THINGSTRINGARGS "MAPTHING_T*STRINGARGS" -#define META_THINGTAGLIST "THING_T*TAGLIST" #define META_POLYOBJVERTICES "POLYOBJ_T*VERTICES" #define META_POLYOBJLINES "POLYOBJ_T*LINES" #ifdef HAVE_LUA_SEGS diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 25edf83d8..3520cdbda 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -831,7 +831,7 @@ static int line_get(lua_State *L) lua_pushinteger(L, Tag_FGet(&line->tags)); return 1; case line_taglist: - LUA_PushUserdata(L, &line->tags, META_LINETAGLIST); + LUA_PushUserdata(L, &line->tags, META_TAGLIST); return 1; case line_args: LUA_PushUserdata(L, line->args, META_LINEARGS); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 8d205780d..65adceb15 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -904,7 +904,7 @@ static int mapthing_get(lua_State *L) number = Tag_FGet(&mt->tags); else if(fastcmp(field,"taglist")) { - LUA_PushUserdata(L, &mt->tags, META_THINGTAGLIST); + LUA_PushUserdata(L, &mt->tags, META_TAGLIST); return 1; } else if(fastcmp(field,"args")) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index 07646af87..7994b6625 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -17,6 +17,10 @@ #include "lua_script.h" #include "lua_libs.h" +#ifdef MUTABLE_TAGS +#include "z_zone.h" +#endif + static int tag_iterator(lua_State *L) { INT32 tag = lua_isnil(L, 2) ? -1 : lua_tonumber(L, 2); @@ -281,6 +285,63 @@ static int taglist_shares(lua_State *L) return 1; } +/* only sector tags are mutable... */ + +#ifdef MUTABLE_TAGS +static size_t sector_of_taglist(taglist_t *list) +{ + return (sector_t *)((char *)list - offsetof (sector_t, tags)) - sectors; +} + +static int this_taglist(lua_State *L) +{ + lua_settop(L, 1); + return 1; +} + +static int taglist_add(lua_State *L) +{ + taglist_t *list = *(taglist_t **)luaL_checkudata(L, 1, META_SECTORTAGLIST); + const mtag_t tag = luaL_checknumber(L, 2); + + if (! Tag_Find(list, tag)) + { + Taggroup_Add(tags_sectors, tag, sector_of_taglist(list)); + Tag_Add(list, tag); + } + + return this_taglist(L); +} + +static int taglist_remove(lua_State *L) +{ + taglist_t *list = *(taglist_t **)luaL_checkudata(L, 1, META_SECTORTAGLIST); + const mtag_t tag = luaL_checknumber(L, 2); + + size_t i; + + for (i = 0; i < list->count; ++i) + { + if (list->tags[i] == tag) + { + if (list->count > 1) + { + memmove(&list->tags[i], &list->tags[i + 1], + (list->count - 1 - i) * sizeof (mtag_t)); + list->tags = Z_Realloc(list->tags, + (--list->count) * sizeof (mtag_t), PU_LEVEL, NULL); + Taggroup_Remove(tags_sectors, tag, sector_of_taglist(list)); + } + else/* reset to default tag */ + Tag_SectorFSet(sector_of_taglist(list), 0); + break; + } + } + + return this_taglist(L); +} +#endif/*MUTABLE_TAGS*/ + void LUA_InsertTaggroupIterator ( lua_State *L, taggroup_t *garray[], @@ -314,9 +375,38 @@ static luaL_Reg taglist_lib[] = { {"iterate", taglist_iterate}, {"find", taglist_find}, {"shares", taglist_shares}, +#ifdef MUTABLE_TAGS + {"add", taglist_add}, + {"remove", taglist_remove}, +#endif {0} }; +static void open_taglist(lua_State *L) +{ + luaL_register(L, "taglist", taglist_lib); + + lua_getfield(L, -1, "find"); + lua_setfield(L, -2, "has"); +} + +static void set_taglist_metatable(lua_State *L, const char *meta) +{ + lua_createtable(L, 0, 4); + lua_getglobal(L, "taglist"); + lua_setfield(L, -2, "taglist"); + + lua_pushcfunction(L, taglist_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, taglist_len); + lua_setfield(L, -2, "__len"); + + lua_pushcfunction(L, taglist_equal); + lua_setfield(L, -2, "__eq"); + lua_setfield(L, LUA_REGISTRYINDEX, meta); +} + int LUA_TagLib(lua_State *L) { lua_newuserdata(L, 0); @@ -331,23 +421,13 @@ int LUA_TagLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "tags"); - luaL_newmetatable(L, META_THINGTAGLIST); - luaL_register(L, "taglist", taglist_lib); - lua_getfield(L, -1, "find"); - lua_setfield(L, -2, "has"); - lua_setfield(L, -2, "taglist"); + open_taglist(L); - lua_pushcfunction(L, taglist_get); - lua_setfield(L, -2, "__index"); + set_taglist_metatable(L, META_TAGLIST); - lua_pushcfunction(L, taglist_len); - lua_setfield(L, -2, "__len"); - - lua_pushcfunction(L, taglist_equal); - lua_setfield(L, -2, "__eq"); - lua_pushvalue(L, -1); - lua_setfield(L, LUA_REGISTRYINDEX, META_LINETAGLIST); - lua_setfield(L, LUA_REGISTRYINDEX, META_SECTORTAGLIST); +#ifdef MUTABLE_TAGS + set_taglist_metatable(L, META_SECTORTAGLIST); +#endif return 0; } From 5d1040c92441a2634410caf2da673eea335e92be Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 5 Dec 2020 02:08:00 -0800 Subject: [PATCH 27/63] Reset taggroup iterator on successive calls --- src/lua_taglib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index 7994b6625..cfaf84872 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -75,6 +75,8 @@ struct element_iterator_state { static int element_iterator(lua_State *L) { struct element_iterator_state * state = lua_touserdata(L, 1); + if (lua_isnoneornil(L, 3)) + state->p = 0; lua_pushnumber(L, ++state->p); lua_gettable(L, 1); return 1; From 0b0f2e1e35aa822566986bcd6dc1526f3828f25e Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 5 Dec 2020 02:26:00 -0800 Subject: [PATCH 28/63] Invalidate taglist userdata --- src/lua_script.c | 5 +++++ src/lua_taglib.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lua_script.c b/src/lua_script.c index ee60a41c6..bc88928f3 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -846,6 +846,7 @@ void LUA_InvalidateLevel(void) { LUA_InvalidateUserdata(§ors[i]); LUA_InvalidateUserdata(§ors[i].lines); + LUA_InvalidateUserdata(§ors[i].tags); if (sectors[i].ffloors) { for (rover = sectors[i].ffloors; rover; rover = rover->next) @@ -855,6 +856,7 @@ void LUA_InvalidateLevel(void) for (i = 0; i < numlines; i++) { LUA_InvalidateUserdata(&lines[i]); + LUA_InvalidateUserdata(&lines[i].tags); LUA_InvalidateUserdata(lines[i].sidenum); } for (i = 0; i < numsides; i++) @@ -886,7 +888,10 @@ void LUA_InvalidateMapthings(void) return; for (i = 0; i < nummapthings; i++) + { LUA_InvalidateUserdata(&mapthings[i]); + LUA_InvalidateUserdata(&mapthings[i].tags); + } } void LUA_InvalidatePlayer(player_t *player) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index cfaf84872..284b171a3 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -182,7 +182,7 @@ static taglist_t * valid_taglist(lua_State *L, int idx, boolean getting) if (getting && has_valid_field(L)) lua_pushboolean(L, 0); else - LUA_ErrInvalid(L, "taglist_t");/* doesn't actually return */ + LUA_ErrInvalid(L, "taglist");/* doesn't actually return */ return NULL; } else From ffd20ee7538609d2e8dbc841ff43ab3685badabe Mon Sep 17 00:00:00 2001 From: katsy Date: Sun, 6 Dec 2020 07:44:49 +0000 Subject: [PATCH 29/63] Revert "ensure the new flag is cleared properly" This reverts commit 3dbb44e7b1afa8d42cf9b83ffcdc02525871f1af --- src/p_user.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 65397c287..c5f919c78 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1085,9 +1085,6 @@ void P_ResetPlayer(player_t *player) player->powers[pw_carry] = CR_NONE; } - if (player->powers[pw_carry] == CR_MACESPIN || player->powers[pw_carry] == CR_GENERIC) - player->mo->flags &= ~MF_NOCLIPHEIGHT; - if (!(player->powers[pw_carry] == CR_NIGHTSMODE || player->powers[pw_carry] == CR_NIGHTSFALL || player->powers[pw_carry] == CR_BRAKGOOP || player->powers[pw_carry] == CR_MINECART)) player->powers[pw_carry] = CR_NONE; @@ -4429,8 +4426,6 @@ void P_DoJump(player_t *player, boolean soundandstate) if (!(player->mo->tracer->flags & MF_MISSILE)) // Missiles remember their owner! P_SetTarget(&player->mo->tracer->target, NULL); P_SetTarget(&player->mo->tracer, NULL); - player->mo->flags &= ~MF_NOCLIPHEIGHT; - } else if (player->powers[pw_carry] == CR_ROPEHANG) { @@ -5262,7 +5257,6 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->powers[pw_carry] = CR_NONE; P_SetTarget(&player->mo->tracer, NULL); player->powers[pw_flashing] = TICRATE/4; - player->mo->flags &= ~MF_NOCLIPHEIGHT; } // can't jump while in air, can't jump while jumping else if (onground || player->climbing || player->powers[pw_carry]) From 5853a0b4d837fbb83c092c2a91ef4566ab906e64 Mon Sep 17 00:00:00 2001 From: katsy Date: Sun, 6 Dec 2020 07:44:59 +0000 Subject: [PATCH 30/63] Revert "add noclipheight on chaingrab" This reverts commit 854140932940517a5800b9c93939081f189f2b08 --- src/p_inter.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 189cbcea7..415c679e4 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1641,9 +1641,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Can't jump first frame player->pflags |= PF_JUMPSTASIS; - // Disable interaction with ground - player->mo->flags |= MF_NOCLIPHEIGHT; - return; } case MT_EGGMOBILE2_POGO: From 24ba78214421ff6fe4aafc5480a9d5e6e66c49db Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 6 Dec 2020 17:29:20 -0300 Subject: [PATCH 31/63] Fix archived mobjs having no default blend mode and sprite scales --- src/p_saveg.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index adedea049..03229e740 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1506,7 +1506,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) { const mobj_t *mobj = (const mobj_t *)th; UINT32 diff; - UINT16 diff2; + UINT32 diff2; // Ignore stationary hoops - these will be respawned from mapthings. if (mobj->type == MT_HOOP) @@ -1638,7 +1638,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_SHADOWSCALE; if (mobj->renderflags) diff2 |= MD2_RENDERFLAGS; - if (mobj->renderflags) + if (mobj->blendmode != AST_TRANSLUCENT) diff2 |= MD2_BLENDMODE; if (mobj->spritexscale != FRACUNIT) diff2 |= MD2_SPRITEXSCALE; @@ -1646,6 +1646,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_SPRITEYSCALE; if (mobj->spritexoffset) diff2 |= MD2_SPRITEXOFFSET; + if (mobj->spriteyoffset) + diff2 |= MD2_SPRITEYOFFSET; if (mobj->floorspriteslope) { pslope_t *slope = mobj->floorspriteslope; @@ -1667,7 +1669,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEUINT8(save_p, type); WRITEUINT32(save_p, diff); if (diff & MD_MORE) - WRITEUINT16(save_p, diff2); + WRITEUINT32(save_p, diff2); // save pointer, at load time we will search this pointer to reinitilize pointers WRITEUINT32(save_p, (size_t)mobj); @@ -2615,14 +2617,14 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) thinker_t *next; mobj_t *mobj; UINT32 diff; - UINT16 diff2; + UINT32 diff2; INT32 i; fixed_t z, floorz, ceilingz; ffloor_t *floorrover = NULL, *ceilingrover = NULL; diff = READUINT32(save_p); if (diff & MD_MORE) - diff2 = READUINT16(save_p); + diff2 = READUINT32(save_p); else diff2 = 0; @@ -2843,10 +2845,16 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->renderflags = READUINT32(save_p); if (diff2 & MD2_BLENDMODE) mobj->blendmode = READINT32(save_p); + else + mobj->blendmode = AST_TRANSLUCENT; if (diff2 & MD2_SPRITEXSCALE) mobj->spritexscale = READFIXED(save_p); + else + mobj->spritexscale = FRACUNIT; if (diff2 & MD2_SPRITEYSCALE) mobj->spriteyscale = READFIXED(save_p); + else + mobj->spriteyscale = FRACUNIT; if (diff2 & MD2_SPRITEXOFFSET) mobj->spritexoffset = READFIXED(save_p); if (diff2 & MD2_SPRITEYOFFSET) From 6f9c48a30560b0f2d89f7202371dfc164015b9ba Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 6 Dec 2020 17:46:35 -0300 Subject: [PATCH 32/63] Move a few mobj spawn defaults to its own function --- src/p_local.h | 1 + src/p_mobj.c | 76 ++++++++++++++++++++++++++++----------------------- src/p_saveg.c | 40 ++------------------------- 3 files changed, 46 insertions(+), 71 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 8a5084962..96401bb75 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -279,6 +279,7 @@ mobjtype_t P_GetMobjtype(UINT16 mthingtype); void P_RespawnSpecials(void); mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); +void P_SetMobjSpawnDefaults(mobj_t *mobj); void P_RecalcPrecipInSector(sector_t *sector); void P_PrecipitationEffects(void); diff --git a/src/p_mobj.c b/src/p_mobj.c index 7ba6d1fad..e664d85be 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10438,44 +10438,11 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->x = x; mobj->y = y; - mobj->radius = info->radius; - mobj->height = info->height; - mobj->flags = info->flags; - - mobj->health = (info->spawnhealth ? info->spawnhealth : 1); - - mobj->reactiontime = info->reactiontime; - - mobj->lastlook = -1; // stuff moved in P_enemy.P_LookForPlayer - - // do not set the state with P_SetMobjState, - // because action routines can not be called yet - st = &states[info->spawnstate]; - - mobj->state = st; - mobj->tics = st->tics; - mobj->sprite = st->sprite; - mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. - P_SetupStateAnimation(mobj, st); - - mobj->friction = ORIG_FRICTION; - - mobj->movefactor = FRACUNIT; - - // All mobjs are created at 100% scale. - mobj->scale = FRACUNIT; - mobj->destscale = mobj->scale; - mobj->scalespeed = FRACUNIT/12; - // TODO: Make this a special map header if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) mobj->destscale = FRACUNIT/2; - // Sprite rendering - mobj->blendmode = AST_TRANSLUCENT; - mobj->spritexscale = mobj->spriteyscale = mobj->scale; - mobj->spritexoffset = mobj->spriteyoffset = 0; - mobj->floorspriteslope = NULL; + P_SetMobjSpawnDefaults(mobj); // set subsector and/or block links P_SetThingPosition(mobj); @@ -10785,6 +10752,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->frame &= ~FF_FRAMEMASK; } + st = &states[info->spawnstate]; + // Call action functions when the state is set if (st->action.acp1 && (mobj->flags & MF_RUNSPAWNFUNC)) { @@ -10815,6 +10784,45 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) return mobj; } +void P_SetMobjSpawnDefaults(mobj_t *mobj) +{ + const mobjinfo_t *info = mobj->info; + state_t *st = &states[info->spawnstate]; + + mobj->radius = info->radius; + mobj->height = info->height; + mobj->flags = info->flags; + + mobj->health = (info->spawnhealth ? info->spawnhealth : 1); + + mobj->reactiontime = info->reactiontime; + + mobj->lastlook = -1; // stuff moved in P_enemy.P_LookForPlayer + + // do not set the state with P_SetMobjState, + // because action routines can not be called yet + mobj->state = st; + mobj->tics = st->tics; + mobj->sprite = st->sprite; + mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. + P_SetupStateAnimation(mobj, st); + + mobj->friction = ORIG_FRICTION; + + mobj->movefactor = FRACUNIT; + + // All mobjs are created at 100% scale. + mobj->scale = FRACUNIT; + mobj->destscale = mobj->scale; + mobj->scalespeed = FRACUNIT/12; + + // Sprite rendering + mobj->blendmode = AST_TRANSLUCENT; + mobj->spritexscale = mobj->spriteyscale = mobj->scale; + mobj->spritexoffset = mobj->spriteyoffset = 0; + mobj->floorspriteslope = NULL; +} + static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { state_t *st; diff --git a/src/p_saveg.c b/src/p_saveg.c index 03229e740..c1364e08f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2692,7 +2692,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) } mobj->type = i; } + mobj->info = &mobjinfo[mobj->type]; + P_SetMobjSpawnDefaults(mobj); + if (diff & MD_POS) { mobj->x = READFIXED(save_p); @@ -2718,35 +2721,21 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) if (diff & MD_RADIUS) mobj->radius = READFIXED(save_p); - else - mobj->radius = mobj->info->radius; if (diff & MD_HEIGHT) mobj->height = READFIXED(save_p); - else - mobj->height = mobj->info->height; if (diff & MD_FLAGS) mobj->flags = READUINT32(save_p); - else - mobj->flags = mobj->info->flags; if (diff & MD_FLAGS2) mobj->flags2 = READUINT32(save_p); if (diff & MD_HEALTH) mobj->health = READINT32(save_p); - else - mobj->health = mobj->info->spawnhealth; if (diff & MD_RTIME) mobj->reactiontime = READINT32(save_p); - else - mobj->reactiontime = mobj->info->reactiontime; if (diff & MD_STATE) mobj->state = &states[READUINT16(save_p)]; - else - mobj->state = &states[mobj->info->spawnstate]; if (diff & MD_TICS) mobj->tics = READINT32(save_p); - else - mobj->tics = mobj->state->tics; if (diff & MD_SPRITE) { mobj->sprite = READUINT16(save_p); if (mobj->sprite == SPR_PLAY) @@ -2762,11 +2751,6 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->frame = READUINT32(save_p); mobj->anim_duration = READUINT16(save_p); } - else - { - mobj->frame = mobj->state->frame; - mobj->anim_duration = (UINT16)mobj->state->var2; - } if (diff & MD_EFLAGS) mobj->eflags = READUINT16(save_p); if (diff & MD_PLAYER) @@ -2783,20 +2767,14 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->threshold = READINT32(save_p); if (diff & MD_LASTLOOK) mobj->lastlook = READINT32(save_p); - else - mobj->lastlook = -1; if (diff & MD_TARGET) mobj->target = (mobj_t *)(size_t)READUINT32(save_p); if (diff & MD_TRACER) mobj->tracer = (mobj_t *)(size_t)READUINT32(save_p); if (diff & MD_FRICTION) mobj->friction = READFIXED(save_p); - else - mobj->friction = ORIG_FRICTION; if (diff & MD_MOVEFACTOR) mobj->movefactor = READFIXED(save_p); - else - mobj->movefactor = FRACUNIT; if (diff & MD_FUSE) mobj->fuse = READINT32(save_p); if (diff & MD_WATERTOP) @@ -2805,16 +2783,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->waterbottom = READFIXED(save_p); if (diff & MD_SCALE) mobj->scale = READFIXED(save_p); - else - mobj->scale = FRACUNIT; if (diff & MD_DSCALE) mobj->destscale = READFIXED(save_p); - else - mobj->destscale = mobj->scale; if (diff2 & MD2_SCALESPEED) mobj->scalespeed = READFIXED(save_p); - else - mobj->scalespeed = FRACUNIT/12; if (diff2 & MD2_CUSVAL) mobj->cusval = READINT32(save_p); if (diff2 & MD2_CVMEM) @@ -2845,16 +2817,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->renderflags = READUINT32(save_p); if (diff2 & MD2_BLENDMODE) mobj->blendmode = READINT32(save_p); - else - mobj->blendmode = AST_TRANSLUCENT; if (diff2 & MD2_SPRITEXSCALE) mobj->spritexscale = READFIXED(save_p); - else - mobj->spritexscale = FRACUNIT; if (diff2 & MD2_SPRITEYSCALE) mobj->spriteyscale = READFIXED(save_p); - else - mobj->spriteyscale = FRACUNIT; if (diff2 & MD2_SPRITEXOFFSET) mobj->spritexoffset = READFIXED(save_p); if (diff2 & MD2_SPRITEYOFFSET) From 18ee97c583117e7d10e4914e473e47adbfaa13d4 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 6 Dec 2020 20:17:14 -0300 Subject: [PATCH 33/63] Fix animated skincolors in OpenGL --- src/hardware/hw_cache.c | 73 +++++++++++++++++++++++++++++++++-------- src/hardware/hw_data.h | 13 ++++++-- src/hardware/hw_main.c | 4 +-- src/hardware/hw_md2.c | 17 ++++++++-- src/m_menu.c | 11 ++----- src/z_zone.c | 12 +++---- 6 files changed, 95 insertions(+), 35 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index b4fa7ec6c..43fdc89f0 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -108,7 +108,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm //Hurdler: 25/04/2000: now support colormap in hardware mode if (mipmap->colormap) - texel = mipmap->colormap[texel]; + texel = mipmap->colormap->data[texel]; // hope compiler will get this switch out of the loops (dreams...) // gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?) @@ -218,7 +218,7 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block, //Hurdler: 25/04/2000: now support colormap in hardware mode if (mipmap->colormap) - texel = mipmap->colormap[texel]; + texel = mipmap->colormap->data[texel]; // hope compiler will get this switch out of the loops (dreams...) // gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?) @@ -659,7 +659,10 @@ void HWR_FreeTextureColormaps(patch_t *patch) // Free image data from memory. if (next->data) Z_Free(next->data); + if (next->colormap) + Z_Free(next->colormap); next->data = NULL; + next->colormap = NULL; HWD.pfnDeleteTexture(next); // Free the old colormap mipmap from memory. @@ -667,16 +670,29 @@ void HWR_FreeTextureColormaps(patch_t *patch) } } +static boolean FreeTextureCallback(void *mem) +{ + patch_t *patch = (patch_t *)mem; + HWR_FreeTexture(patch); + return false; +} + +static boolean FreeColormapsCallback(void *mem) +{ + patch_t *patch = (patch_t *)mem; + HWR_FreeTextureColormaps(patch); + return false; +} + static void HWR_FreePatchCache(boolean freeall) { - INT32 i; + boolean (*callback)(void *mem) = FreeTextureCallback; - for (i = 0; i < numwadfiles; i++) - { - INT32 j = 0; - for (; j < wadfiles[i]->numlumps; j++) - (freeall ? HWR_FreeTexture : HWR_FreeTextureColormaps)(wadfiles[i]->patchcache[j]); - } + if (!freeall) + callback = FreeColormapsCallback; + + Z_IterateTags(PU_PATCH, PU_PATCH_ROTATED, callback); + Z_IterateTags(PU_SPRITE, PU_HUDGFX, callback); } // free all textures after each level @@ -977,8 +993,28 @@ static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *grMipmap) Z_ChangeTag(grMipmap->data, PU_HWRCACHE_UNLOCKED); } +// ----------------------+ +// HWR_UpdatePatchMipmap : Updates a mipmap. +// ----------------------+ +static void HWR_UpdatePatchMipmap(patch_t *patch, GLMipmap_t *grMipmap) +{ + GLPatch_t *grPatch = patch->hardware; + HWR_MakePatch(patch, grPatch, grMipmap, true); + + // If hardware does not have the texture, then call pfnSetTexture to upload it + // If it does have the texture, then call pfnUpdateTexture to update it + if (!grMipmap->downloaded) + HWD.pfnSetTexture(grMipmap); + else + HWD.pfnUpdateTexture(grMipmap); + HWR_SetCurrentTexture(grMipmap); + + // The system-memory data can be purged now. + Z_ChangeTag(grMipmap->data, PU_HWRCACHE_UNLOCKED); +} + // -----------------+ -// HWR_GetPatch : Download a patch to the hardware cache and make it ready for use +// HWR_GetPatch : Downloads a patch to the hardware cache and make it ready for use // -----------------+ void HWR_GetPatch(patch_t *patch) { @@ -1006,14 +1042,20 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) return; } - // search for the mimmap + // search for the mipmap // skip the first (no colormap translated) for (grMipmap = grPatch->mipmap; grMipmap->nextcolormap; ) { grMipmap = grMipmap->nextcolormap; - if (grMipmap->colormap == colormap) + if (grMipmap->colormap && grMipmap->colormap->source == colormap) { - HWR_LoadPatchMipmap(patch, grMipmap); + if (memcmp(grMipmap->colormap->data, colormap, 256 * sizeof(UINT8))) + { + M_Memcpy(grMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + HWR_UpdatePatchMipmap(patch, grMipmap); + } + else + HWR_LoadPatchMipmap(patch, grMipmap); return; } } @@ -1029,7 +1071,10 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) I_Error("%s: Out of memory", "HWR_GetMappedPatch"); grMipmap->nextcolormap = newMipmap; - newMipmap->colormap = colormap; + newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); + newMipmap->colormap->source = colormap; + M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + HWR_LoadPatchMipmap(patch, newMipmap); } diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 3ae4ef8bc..11e41b18a 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -39,6 +39,15 @@ typedef enum GLTextureFormat_e GL_TEXFMT_ALPHA_INTENSITY_88 = 0x22, } GLTextureFormat_t; +// Colormap structure for mipmaps. +struct GLColormap_s +{ + const UINT8 *source; + UINT8 data[256]; +}; +typedef struct GLColormap_s GLColormap_t; + + // data holds the address of the graphics data cached in heap memory // NULL if the texture is not in Doom heap cache. struct GLMipmap_s @@ -53,7 +62,7 @@ struct GLMipmap_s UINT32 downloaded; // The GPU has this texture. struct GLMipmap_s *nextcolormap; - const UINT8 *colormap; + struct GLColormap_s *colormap; struct GLMipmap_s *nextmipmap; // Linked list of all textures }; @@ -77,7 +86,7 @@ struct GLPatch_s { float max_s,max_t; GLMipmap_t *mipmap; -} ATTRPACK; +}; typedef struct GLPatch_s GLPatch_t; #endif //_HWR_DATA_ diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5dd2727bc..902ce55bd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5295,7 +5295,7 @@ static void HWR_ProjectSprite(mobj_t *thing) vis->colormap = R_GetTranslationColormap(TC_DEFAULT, vis->mobj->color ? vis->mobj->color : SKINCOLOR_CYAN, GTC_CACHE); } else - vis->colormap = colormaps; + vis->colormap = NULL; // set top/bottom coords vis->gzt = gzt; @@ -5396,7 +5396,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) vis->flip = flip; vis->mobj = (mobj_t *)thing; - vis->colormap = colormaps; + vis->colormap = NULL; // set top/bottom coords vis->gzt = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 9c786e67e..2e944d3e6 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1106,11 +1106,19 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski for (grMipmap = grPatch->mipmap; grMipmap->nextcolormap; ) { grMipmap = grMipmap->nextcolormap; - if (grMipmap->colormap == colormap) + if (grMipmap->colormap && grMipmap->colormap->source == colormap) { if (grMipmap->downloaded && grMipmap->data) { - HWD.pfnSetTexture(grMipmap); // found the colormap, set it to the correct texture + if (memcmp(grMipmap->colormap->data, colormap, 256 * sizeof(UINT8))) + { + M_Memcpy(grMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + HWR_CreateBlendedTexture(patch, blendpatch, grMipmap, skinnum, color); + HWD.pfnUpdateTexture(grMipmap); + } + else + HWD.pfnSetTexture(grMipmap); // found the colormap, set it to the correct texture + Z_ChangeTag(grMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED); return; } @@ -1128,7 +1136,10 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski if (newMipmap == NULL) I_Error("%s: Out of memory", "HWR_GetBlendedTexture"); grMipmap->nextcolormap = newMipmap; - newMipmap->colormap = colormap; + + newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); + newMipmap->colormap->source = colormap; + M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); HWR_CreateBlendedTexture(patch, blendpatch, newMipmap, skinnum, color); diff --git a/src/m_menu.c b/src/m_menu.c index 77648f877..3a6b5ce22 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8423,7 +8423,7 @@ static void M_DrawLoadGameData(void) sprdef = &charbotskin->sprites[SPR2_SIGN]; if (!sprdef->numframes) goto skipbot; - colormap = R_GetTranslationColormap(savegameinfo[savetodraw].botskin-1, charbotskin->prefcolor, 0); + colormap = R_GetTranslationColormap(savegameinfo[savetodraw].botskin-1, charbotskin->prefcolor, GTC_CACHE); sprframe = &sprdef->spriteframes[0]; patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); @@ -8433,8 +8433,6 @@ static void M_DrawLoadGameData(void) charbotskin->highresscale, 0, patch, colormap); - Z_Free(colormap); - tempx -= (20<sprites[SPR2_SIGN]; - colormap = R_GetTranslationColormap(savegameinfo[savetodraw].skinnum, charskin->prefcolor, 0); + colormap = R_GetTranslationColormap(savegameinfo[savetodraw].skinnum, charskin->prefcolor, GTC_CACHE); if (!sprdef->numframes) goto skipsign; sprframe = &sprdef->spriteframes[0]; @@ -8483,8 +8481,6 @@ skipsign: charskin->highresscale/2, 0, patch, colormap); skiplife: - if (colormap) - Z_Free(colormap); patch = W_CachePatchName("STLIVEX", PU_PATCH); @@ -11755,7 +11751,7 @@ static void M_DrawSetupMultiPlayerMenu(void) goto faildraw; // ok, draw player sprite for sure now - colormap = R_GetTranslationColormap(setupm_fakeskin, setupm_fakecolor->color, 0); + colormap = R_GetTranslationColormap(setupm_fakeskin, setupm_fakecolor->color, GTC_CACHE); if (multi_frame >= sprdef->numframes) multi_frame = 0; @@ -11773,7 +11769,6 @@ static void M_DrawSetupMultiPlayerMenu(void) FixedDiv(skins[setupm_fakeskin].highresscale, skins[setupm_fakeskin].shieldscale), flags, patch, colormap); - Z_Free(colormap); goto colordraw; faildraw: diff --git a/src/z_zone.c b/src/z_zone.c index ad64a3a07..d7da17e51 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -813,12 +813,12 @@ static void Command_Memfree_f(void) #ifdef HWRENDER if (rendermode == render_opengl) { - CONS_Printf(M_GetText("Patch info headers: %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10)); - CONS_Printf(M_GetText("Mipmap patches : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLMIPMAP)>>10)); - CONS_Printf(M_GetText("HW Texture cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10)); - CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10)); - CONS_Printf(M_GetText("HW model textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRMODELTEXTURE)>>10)); - CONS_Printf(M_GetText("HW Texture used : %7d KB\n"), HWR_GetTextureUsed()>>10); + CONS_Printf(M_GetText("Patch info headers : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10)); + CONS_Printf(M_GetText("Cached textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10)); + CONS_Printf(M_GetText("Texture colormaps : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLMIPMAP)>>10)); + CONS_Printf(M_GetText("Model textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRMODELTEXTURE)>>10)); + CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10)); + CONS_Printf(M_GetText("All GPU textures : %7d KB\n"), HWR_GetTextureUsed()>>10); } #endif From 284205baacdd2ffb923ef222a3469178f9ddd12f Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 6 Dec 2020 22:20:06 -0500 Subject: [PATCH 34/63] Fix SPC looping on libgme versions >= 0.6.3 --- src/sdl/mixer_sound.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index c64164caa..d67536b04 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1298,6 +1298,9 @@ boolean I_PlaySong(boolean looping) if (gme) { gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; +#if GME_VERSION >= 0x000603 + gme_set_autoload_playback_limit(gme, 0); +#endif gme_set_equalizer(gme, &eq); gme_start_track(gme, 0); current_track = 0; From c3a560f51d274b039bc3441bb8f4f2994350ea86 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 6 Dec 2020 22:30:50 -0500 Subject: [PATCH 35/63] Let's check for looping first --- src/sdl/mixer_sound.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index d67536b04..490ebb5ba 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1299,7 +1299,8 @@ boolean I_PlaySong(boolean looping) { gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; #if GME_VERSION >= 0x000603 - gme_set_autoload_playback_limit(gme, 0); + if (looping) + gme_set_autoload_playback_limit(gme, 0); #endif gme_set_equalizer(gme, &eq); gme_start_track(gme, 0); From 11bbad9be8231c0403c1fb41d7c65c4a62a3fec3 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 6 Dec 2020 22:58:17 -0500 Subject: [PATCH 36/63] Tab fix --- src/sdl/mixer_sound.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 490ebb5ba..5cae48077 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1299,8 +1299,8 @@ boolean I_PlaySong(boolean looping) { gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; #if GME_VERSION >= 0x000603 - if (looping) - gme_set_autoload_playback_limit(gme, 0); + if (looping) + gme_set_autoload_playback_limit(gme, 0); #endif gme_set_equalizer(gme, &eq); gme_start_track(gme, 0); From 27217259624c287b131d92e2f762057fa791bd12 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 7 Dec 2020 16:46:05 -0600 Subject: [PATCH 37/63] Final lap text for circuit --- src/p_spec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index a1afdd00d..cdab17c97 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4823,6 +4823,8 @@ DoneSection2: if (player->laps >= (UINT8)cv_numlaps.value) CONS_Printf(M_GetText("%s has finished the race.\n"), player_names[player-players]); + else if (player->laps == (UINT8)cv_numlaps.value-1) + CONS_Printf(M_GetText("%s started the %c%s%c!\n"), player_names[player-players], 0x85, M_GetText("final lap"), 0x80); else CONS_Printf(M_GetText("%s started lap %u\n"), player_names[player-players], (UINT32)player->laps+1); From c2de684150262cca19402bcace64c14da3362767 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 7 Dec 2020 17:52:43 -0500 Subject: [PATCH 38/63] Fix double free occuring when unloading the intermission patches due to the same patch being cached twice --- src/y_inter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 061cbb5e1..bd3b557d7 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1229,7 +1229,10 @@ void Y_StartIntermission(void) data.coop.tics = players[consoleplayer].realtime; for (i = 0; i < 4; ++i) - data.coop.bonuspatches[i] = W_CachePatchName(data.coop.bonuses[i].patch, PU_PATCH); + { + if (strlen(data.coop.bonuses[i].patch)) + data.coop.bonuspatches[i] = W_CachePatchName(data.coop.bonuses[i].patch, PU_PATCH); + } data.coop.ptotal = W_CachePatchName("YB_TOTAL", PU_PATCH); // get act number @@ -1733,7 +1736,6 @@ static void Y_SetNullBonus(player_t *player, y_bonus_t *bstruct) { (void)player; memset(bstruct, 0, sizeof(y_bonus_t)); - strncpy(bstruct->patch, "MISSING", sizeof(bstruct->patch)); } // From 45a4b728b354fd867641e6c7c372c052ad827d32 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 8 Dec 2020 12:05:06 -0600 Subject: [PATCH 39/63] zwip suggestion --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index cdab17c97..06eee3b12 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4824,7 +4824,7 @@ DoneSection2: if (player->laps >= (UINT8)cv_numlaps.value) CONS_Printf(M_GetText("%s has finished the race.\n"), player_names[player-players]); else if (player->laps == (UINT8)cv_numlaps.value-1) - CONS_Printf(M_GetText("%s started the %c%s%c!\n"), player_names[player-players], 0x85, M_GetText("final lap"), 0x80); + CONS_Printf(M_GetText("%s started the \205final lap\200!\n"), player_names[player-players]); else CONS_Printf(M_GetText("%s started lap %u\n"), player_names[player-players], (UINT32)player->laps+1); From 1b888c689cb2a5a24e13f7fcf34f0b2235dad86c Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 8 Dec 2020 15:56:45 -0600 Subject: [PATCH 40/63] CTF text 1 --- src/p_spec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 06eee3b12..e79e02812 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4600,7 +4600,7 @@ DoneSection2: HU_SetCEchoFlags(V_AUTOFADEOUT|V_ALLOWLOWERCASE); HU_SetCEchoDuration(5); - HU_DoCEcho(va(M_GetText("%s%s%s\\CAPTURED THE %sBLUE FLAG%s.\\\\\\\\"), "\x85", player_names[player-players], "\x80", "\x84", "\x80")); + HU_DoCEcho(va(M_GetText("\205%s\200\\CAPTURED THE \204BLUE FLAG\200.\\\\\\\\"), player_names[player-players])); if (splitscreen || players[consoleplayer].ctfteam == 1) S_StartSound(NULL, sfx_flgcap); @@ -4633,7 +4633,7 @@ DoneSection2: HU_SetCEchoFlags(V_AUTOFADEOUT|V_ALLOWLOWERCASE); HU_SetCEchoDuration(5); - HU_DoCEcho(va(M_GetText("%s%s%s\\CAPTURED THE %sRED FLAG%s.\\\\\\\\"), "\x84", player_names[player-players], "\x80", "\x85", "\x80")); + HU_DoCEcho(va(M_GetText("\204%s\200\\CAPTURED THE \205RED FLAG\200.\\\\\\\\"), player_names[player-players])); if (splitscreen || players[consoleplayer].ctfteam == 2) S_StartSound(NULL, sfx_flgcap); From 7082db485b754bd0a007d44b3e71edcdd9e40c96 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 8 Dec 2020 16:09:51 -0600 Subject: [PATCH 41/63] CTF text 2, branch is finished --- src/p_mobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 7ba6d1fad..0e80496b5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9835,7 +9835,7 @@ static void P_FlagFuseThink(mobj_t *mobj) if (mobj->type == MT_REDFLAG) { if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x85, M_GetText("Red flag"), 0x80); + CONS_Printf(M_GetText("The \205Red flag\200 has returned to base.\n")); // Assumedly in splitscreen players will be on opposing teams if (players[consoleplayer].ctfteam == 1 || splitscreen) @@ -9848,7 +9848,7 @@ static void P_FlagFuseThink(mobj_t *mobj) else // MT_BLUEFLAG { if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x84, M_GetText("Blue flag"), 0x80); + CONS_Printf(M_GetText("The \204Blue flag\200 has returned to base.\n")); // Assumedly in splitscreen players will be on opposing teams if (players[consoleplayer].ctfteam == 2 || splitscreen) From 3472b3ece38bc6d62ff248bfdf34950ec4709105 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Thu, 10 Dec 2020 21:55:22 -0300 Subject: [PATCH 42/63] Fix ERZ3 mode --- src/p_mobj.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index e664d85be..2393013de 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10438,19 +10438,12 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->x = x; mobj->y = y; - // TODO: Make this a special map header - if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) - mobj->destscale = FRACUNIT/2; - P_SetMobjSpawnDefaults(mobj); // set subsector and/or block links P_SetThingPosition(mobj); I_Assert(mobj->subsector != NULL); - // Make sure scale matches destscale immediately when spawned - P_SetScale(mobj, mobj->destscale); - mobj->floorz = P_GetSectorFloorZAt (mobj->subsector->sector, x, y); mobj->ceilingz = P_GetSectorCeilingZAt(mobj->subsector->sector, x, y); @@ -10816,9 +10809,16 @@ void P_SetMobjSpawnDefaults(mobj_t *mobj) mobj->destscale = mobj->scale; mobj->scalespeed = FRACUNIT/12; + // TODO: Make this a special map header + if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) + mobj->destscale = FRACUNIT/2; + + // Make sure scale matches destscale immediately when spawned + P_SetScale(mobj, mobj->destscale); + // Sprite rendering mobj->blendmode = AST_TRANSLUCENT; - mobj->spritexscale = mobj->spriteyscale = mobj->scale; + mobj->spritexscale = mobj->spriteyscale = FRACUNIT; mobj->spritexoffset = mobj->spriteyoffset = 0; mobj->floorspriteslope = NULL; } From 440f46144a75d9048c24eef9fcaf34b0cad8181b Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Thu, 10 Dec 2020 22:01:53 -0300 Subject: [PATCH 43/63] Fix intro crash --- src/w_wad.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index 2429eaf92..6566800c0 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1747,6 +1747,9 @@ void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag) void W_UnlockCachedPatch(void *patch) { + if (!patch) + return; + // The hardware code does its own memory management, as its patches // have different lifetimes from software's. #ifdef HWRENDER @@ -2144,7 +2147,7 @@ int W_VerifyNMUSlumps(const char *filename, boolean exit_on_error) {"LT", 2}, // Titlecard changes {"SLID", 4}, // Continue - {"CONT", 4}, + {"CONT", 4}, {"MINICAPS", 8}, // NiGHTS graphics here and below {"BLUESTAT", 8}, // Sphere status From f2095b57fd042dfbe58a1e696308d6b8c24083c3 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Thu, 10 Dec 2020 20:37:50 -0600 Subject: [PATCH 44/63] Player-Colored Elemental Fire for competitive gametypes --- src/deh_tables.c | 7 +++++++ src/hardware/hw_light.c | 1 + src/info.c | 8 ++++++++ src/info.h | 8 ++++++++ src/p_user.c | 10 ++++++++++ 5 files changed, 34 insertions(+) diff --git a/src/deh_tables.c b/src/deh_tables.c index 7877903c5..67d876069 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -1522,6 +1522,13 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi "S_SPINFIRE5", "S_SPINFIRE6", + "S_TEAM_SPINFIRE1", + "S_TEAM_SPINFIRE2", + "S_TEAM_SPINFIRE3", + "S_TEAM_SPINFIRE4", + "S_TEAM_SPINFIRE5", + "S_TEAM_SPINFIRE6", + // Spikes "S_SPIKE1", "S_SPIKE2", diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index 987d70c69..93c61f4e7 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -253,6 +253,7 @@ light_t *t_lspr[NUMSPRITES] = &lspr[NOLIGHT], // SPR_SIGN &lspr[NOLIGHT], // SPR_SPIK &lspr[NOLIGHT], // SPR_SFLM + &lspr[NOLIGHT], // SPR_TFLM &lspr[NOLIGHT], // SPR_USPK &lspr[NOLIGHT], // SPR_WSPK &lspr[NOLIGHT], // SPR_WSPB diff --git a/src/info.c b/src/info.c index 56e764b5d..3ae9aeeb4 100644 --- a/src/info.c +++ b/src/info.c @@ -150,6 +150,7 @@ char sprnames[NUMSPRITES + 1][5] = "SIGN", // Level end sign "SPIK", // Spike Ball "SFLM", // Spin fire + "TFLM", // Spin fire (team) "USPK", // Floor spike "WSPK", // Wall spike "WSPB", // Wall spike base @@ -1894,6 +1895,13 @@ state_t states[NUMSTATES] = {SPR_SFLM, FF_FULLBRIGHT|4, 2, {NULL}, 0, 0, S_SPINFIRE6}, // S_SPINFIRE5 {SPR_SFLM, FF_FULLBRIGHT|5, 2, {NULL}, 0, 0, S_SPINFIRE1}, // S_SPINFIRE6 + {SPR_TFLM, FF_FULLBRIGHT, 2, {NULL}, 0, 0, S_TEAM_SPINFIRE2}, // S_TEAM_SPINFIRE1 + {SPR_TFLM, FF_FULLBRIGHT|1, 2, {NULL}, 0, 0, S_TEAM_SPINFIRE3}, // S_TEAM_SPINFIRE2 + {SPR_TFLM, FF_FULLBRIGHT|2, 2, {NULL}, 0, 0, S_TEAM_SPINFIRE4}, // S_TEAM_SPINFIRE3 + {SPR_TFLM, FF_FULLBRIGHT|3, 2, {NULL}, 0, 0, S_TEAM_SPINFIRE5}, // S_TEAM_SPINFIRE4 + {SPR_TFLM, FF_FULLBRIGHT|4, 2, {NULL}, 0, 0, S_TEAM_SPINFIRE6}, // S_TEAM_SPINFIRE5 + {SPR_TFLM, FF_FULLBRIGHT|5, 2, {NULL}, 0, 0, S_TEAM_SPINFIRE1}, // S_TEAM_SPINFIRE6 + // Floor Spike {SPR_USPK, 0,-1, {A_SpikeRetract}, 1, 0, S_SPIKE2}, // S_SPIKE1 -- Fully extended {SPR_USPK, 1, 2, {A_Pain}, 0, 0, S_SPIKE3}, // S_SPIKE2 diff --git a/src/info.h b/src/info.h index 604922beb..461afd180 100644 --- a/src/info.h +++ b/src/info.h @@ -684,6 +684,7 @@ typedef enum sprite SPR_SIGN, // Level end sign SPR_SPIK, // Spike Ball SPR_SFLM, // Spin fire + SPR_TFLM, // Spin fire (team) SPR_USPK, // Floor spike SPR_WSPK, // Wall spike SPR_WSPB, // Wall spike base @@ -2324,6 +2325,13 @@ typedef enum state S_SPINFIRE5, S_SPINFIRE6, + S_TEAM_SPINFIRE1, + S_TEAM_SPINFIRE2, + S_TEAM_SPINFIRE3, + S_TEAM_SPINFIRE4, + S_TEAM_SPINFIRE5, + S_TEAM_SPINFIRE6, + // Spikes S_SPIKE1, S_SPIKE2, diff --git a/src/p_user.c b/src/p_user.c index 892f4b678..09d148f41 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7756,6 +7756,11 @@ void P_ElementalFire(player_t *player, boolean cropcircle) flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); P_InstaThrust(flame, flame->angle, FixedMul(3*FRACUNIT, flame->scale)); P_SetObjectMomZ(flame, 3*FRACUNIT, false); + if (!(gametyperules & GTR_FRIENDLY)) + { + P_SetMobjState(flame, S_TEAM_SPINFIRE1); + flame->color = player->mo->color; + } } #undef limitangle #undef numangles @@ -7783,6 +7788,11 @@ void P_ElementalFire(player_t *player, boolean cropcircle) flame->destscale = player->mo->scale; P_SetScale(flame, player->mo->scale); flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); + if (!(gametyperules & GTR_FRIENDLY)) + { + P_SetMobjState(flame, S_TEAM_SPINFIRE1); + flame->color = player->mo->color; + } flame->momx = 8; // this is a hack which is used to ensure it still behaves as a missile and can damage others P_XYMovement(flame); From 68de9f4bbe132bd57fbf072bc3dc861dd9f3be81 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Fri, 11 Dec 2020 12:34:30 -0600 Subject: [PATCH 45/63] Make Ring Drain sectors play the depletion sound instead of the ring sound --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 5b9e05c61..8843824ce 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4304,7 +4304,7 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers if (leveltime % (TICRATE/2) == 0 && player->rings > 0) { player->rings--; - S_StartSound(player->mo, sfx_itemup); + S_StartSound(player->mo, sfx_antiri); } break; case 11: // Special Stage Damage From ddf743d521654cbfb7ee7d7d9f5040c68351a49b Mon Sep 17 00:00:00 2001 From: katsy Date: Fri, 11 Dec 2020 20:59:14 -0500 Subject: [PATCH 46/63] make fire spindust dust fullbright --- src/info.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/info.c b/src/info.c index 29a79b1d6..8684c68f5 100644 --- a/src/info.c +++ b/src/info.c @@ -3299,10 +3299,10 @@ state_t states[NUMSTATES] = {SPR_BUBL, 0, 6, {NULL}, 0, 0, S_SPINDUST_BUBBLE3}, // S_SPINDUST_BUBBLE2 {SPR_BUBL, FF_TRANS30|0, 4, {NULL}, 0, 0, S_SPINDUST_BUBBLE4}, // S_SPINDUST_BUBBLE3 {SPR_BUBL, FF_TRANS60|0, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST_BUBBLE4 - {SPR_FPRT, 0, 7, {NULL}, 0, 0, S_SPINDUST_FIRE2}, // S_SPINDUST_FIRE1 - {SPR_FPRT, 0, 6, {NULL}, 0, 0, S_SPINDUST_FIRE3}, // S_SPINDUST_FIRE2 - {SPR_FPRT, FF_TRANS30|0, 4, {NULL}, 0, 0, S_SPINDUST_FIRE4}, // S_SPINDUST_FIRE3 - {SPR_FPRT, FF_TRANS60|0, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST_FIRE4 + {SPR_FPRT, FF_FULLBRIGHT|0, 7, {NULL}, 0, 0, S_SPINDUST_FIRE2}, // S_SPINDUST_FIRE1 + {SPR_FPRT, FF_FULLBRIGHT|0, 6, {NULL}, 0, 0, S_SPINDUST_FIRE3}, // S_SPINDUST_FIRE2 + {SPR_FPRT, FF_FULLBRIGHT|FF_TRANS30|0, 4, {NULL}, 0, 0, S_SPINDUST_FIRE4}, // S_SPINDUST_FIRE3 + {SPR_FPRT, FF_FULLBRIGHT|FF_TRANS60|0, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST_FIRE4 {SPR_TFOG, FF_FULLBRIGHT|FF_TRANS50, 2, {NULL}, 0, 0, S_FOG2}, // S_FOG1 From 2971156ba7c4699979218a4a8470d93d8faf63aa Mon Sep 17 00:00:00 2001 From: katsy Date: Fri, 11 Dec 2020 23:39:42 -0500 Subject: [PATCH 47/63] Update info.c --- src/info.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/info.c b/src/info.c index 8684c68f5..192e592af 100644 --- a/src/info.c +++ b/src/info.c @@ -3291,16 +3291,16 @@ state_t states[NUMSTATES] = {SPR_WZAP, FF_TRANS10|FF_ANIMATE|FF_RANDOMANIM, 4, {NULL}, 3, 2, S_NULL}, // S_WATERZAP // Spindash dust - {SPR_DUST, 0, 7, {NULL}, 0, 0, S_SPINDUST2}, // S_SPINDUST1 - {SPR_DUST, 1, 6, {NULL}, 0, 0, S_SPINDUST3}, // S_SPINDUST2 - {SPR_DUST, FF_TRANS30|2, 4, {NULL}, 0, 0, S_SPINDUST4}, // S_SPINDUST3 - {SPR_DUST, FF_TRANS60|3, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST4 - {SPR_BUBL, 0, 7, {NULL}, 0, 0, S_SPINDUST_BUBBLE2}, // S_SPINDUST_BUBBLE1 - {SPR_BUBL, 0, 6, {NULL}, 0, 0, S_SPINDUST_BUBBLE3}, // S_SPINDUST_BUBBLE2 - {SPR_BUBL, FF_TRANS30|0, 4, {NULL}, 0, 0, S_SPINDUST_BUBBLE4}, // S_SPINDUST_BUBBLE3 - {SPR_BUBL, FF_TRANS60|0, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST_BUBBLE4 - {SPR_FPRT, FF_FULLBRIGHT|0, 7, {NULL}, 0, 0, S_SPINDUST_FIRE2}, // S_SPINDUST_FIRE1 - {SPR_FPRT, FF_FULLBRIGHT|0, 6, {NULL}, 0, 0, S_SPINDUST_FIRE3}, // S_SPINDUST_FIRE2 + {SPR_DUST, 0, 7, {NULL}, 0, 0, S_SPINDUST2}, // S_SPINDUST1 + {SPR_DUST, 1, 6, {NULL}, 0, 0, S_SPINDUST3}, // S_SPINDUST2 + {SPR_DUST, FF_TRANS30|2, 4, {NULL}, 0, 0, S_SPINDUST4}, // S_SPINDUST3 + {SPR_DUST, FF_TRANS60|3, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST4 + {SPR_BUBL, 0, 7, {NULL}, 0, 0, S_SPINDUST_BUBBLE2}, // S_SPINDUST_BUBBLE1 + {SPR_BUBL, 0, 6, {NULL}, 0, 0, S_SPINDUST_BUBBLE3}, // S_SPINDUST_BUBBLE2 + {SPR_BUBL, FF_TRANS30|0, 4, {NULL}, 0, 0, S_SPINDUST_BUBBLE4}, // S_SPINDUST_BUBBLE3 + {SPR_BUBL, FF_TRANS60|0, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST_BUBBLE4 + {SPR_FPRT, FF_FULLBRIGHT|0, 7, {NULL}, 0, 0, S_SPINDUST_FIRE2}, // S_SPINDUST_FIRE1 + {SPR_FPRT, FF_FULLBRIGHT|0, 6, {NULL}, 0, 0, S_SPINDUST_FIRE3}, // S_SPINDUST_FIRE2 {SPR_FPRT, FF_FULLBRIGHT|FF_TRANS30|0, 4, {NULL}, 0, 0, S_SPINDUST_FIRE4}, // S_SPINDUST_FIRE3 {SPR_FPRT, FF_FULLBRIGHT|FF_TRANS60|0, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST_FIRE4 From 7e0a1709de58ea290a6edef7d7f2b4ec28427ac8 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 14 Dec 2020 00:53:42 -0300 Subject: [PATCH 48/63] Fix a crash in Picture_GetPatchPixel with PICFMT_DOOMPATCH formats --- src/r_picformats.c | 9 +++++---- src/r_textures.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/r_picformats.c b/src/r_picformats.c index 02f1de4ab..f87362c76 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -544,21 +544,22 @@ void *Picture_GetPatchPixel( UINT16 *s16 = NULL; UINT32 *s32 = NULL; softwarepatch_t *doompatch = (softwarepatch_t *)patch; + boolean isdoompatch = Picture_IsDoomPatchFormat(informat); INT16 width; if (patch == NULL) I_Error("Picture_GetPatchPixel: patch == NULL"); - width = (Picture_IsDoomPatchFormat(informat) ? patch->width : SHORT(patch->width)); + width = (isdoompatch ? SHORT(doompatch->width) : patch->width); if (x >= 0 && x < width) { INT32 colx = (flags & PICFLAGS_XFLIP) ? (width-1)-x : x; INT32 topdelta, prevdelta = -1; - INT32 colofs = (Picture_IsDoomPatchFormat(informat) ? LONG(patch->columnofs[colx]) : patch->columnofs[colx]); + INT32 colofs = (isdoompatch ? LONG(doompatch->columnofs[colx]) : patch->columnofs[colx]); - // Column offsets are pointers so no casting required - if (Picture_IsDoomPatchFormat(informat)) + // Column offsets are pointers, so no casting is required. + if (isdoompatch) column = (column_t *)((UINT8 *)doompatch + colofs); else column = (column_t *)((UINT8 *)patch->columns + colofs); diff --git a/src/r_textures.c b/src/r_textures.c index 9de9649e2..a006d739f 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -604,7 +604,7 @@ void *R_GetLevelFlat(levelflat_t *levelflat) levelflat->height = ds_flatheight = SHORT(patch->height); levelflat->picture = Z_Malloc(levelflat->width * levelflat->height, PU_LEVEL, NULL); - converted = Picture_FlatConvert(PICFMT_DOOMPATCH, patch, PICFMT_FLAT, 0, &size, levelflat->width, levelflat->height, patch->topoffset, patch->leftoffset, 0); + converted = Picture_FlatConvert(PICFMT_DOOMPATCH, patch, PICFMT_FLAT, 0, &size, levelflat->width, levelflat->height, SHORT(patch->topoffset), SHORT(patch->leftoffset), 0); M_Memcpy(levelflat->picture, converted, size); Z_Free(converted); } From ca78fc69cad750a5a915cd5519c2cc45c5ff5848 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 14 Dec 2020 01:14:55 -0300 Subject: [PATCH 49/63] Restore the viewpoint's angle in R_DrawPlanes instead --- src/r_plane.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index c54b32382..b5ac7252f 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -607,6 +607,7 @@ void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) void R_DrawPlanes(void) { visplane_t *pl; + angle_t va = viewangle; INT32 i; R_UpdatePlaneRipple(); @@ -621,6 +622,8 @@ void R_DrawPlanes(void) R_DrawSinglePlane(pl); } } + + viewangle = va; } // R_DrawSkyPlane @@ -788,7 +791,6 @@ void R_DrawSinglePlane(visplane_t *pl) ffloor_t *rover; int type; int spanfunctype = BASEDRAWFUNC; - angle_t viewang = viewangle; if (!(pl->minx <= pl->maxx)) return; @@ -1153,8 +1155,6 @@ using the palette colors. } } #endif - - viewangle = viewang; } void R_PlaneBounds(visplane_t *plane) From 2b2346835920ca359891c1212e8210a3543a4c27 Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 02:36:00 -0500 Subject: [PATCH 50/63] remove amy --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index badf19372..b116b756c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11798,7 +11798,7 @@ static boolean P_AllowMobjSpawn(mapthing_t* mthing, mobjtype_t i) if (!(G_CoopGametype() || (mthing->options & MTF_EXTRA))) return false; // she doesn't hang out here - if (!mariomode && !(netgame || multiplayer) && players[consoleplayer].skin == 3) + if (!(netgame || multiplayer) && players[consoleplayer].skin == 3) return false; // no doubles break; From 0ce9d9127a7707aceb94c2f263508725438ef9dc Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 04:01:50 -0500 Subject: [PATCH 51/63] add SF_NOSHIELDABILITY --- src/d_player.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index eb0372832..0e0f623d3 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -51,7 +51,8 @@ typedef enum SF_NONIGHTSSUPER = 1<<15, // Disable super colors for NiGHTS (if you have SF_SUPER) SF_NOSUPERSPRITES = 1<<16, // Don't use super sprites while super SF_NOSUPERJUMPBOOST = 1<<17, // Disable the jump boost given while super (i.e. Knuckles) - SF_CANBUSTWALLS = 1<<18, // Can naturally bust walls on contact? (i.e. Knuckles) + SF_CANBUSTWALLS = 1<<18, // Can naturally bust walls on contact? (i.e. Knuckles) + SF_NOSHIELDABILITY = 1<<19, // Disable shield abilities // free up to and including 1<<31 } skinflags_t; From dfbb1825f460fcc3db33880450fea4c93bd2e648 Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 04:02:17 -0500 Subject: [PATCH 52/63] ditto --- src/deh_tables.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/deh_tables.c b/src/deh_tables.c index 5733d9b0e..2a0f179d4 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4987,6 +4987,8 @@ struct int_const_s const INT_CONST[] = { {"SF_NOSUPERSPRITES",SF_NOSUPERSPRITES}, {"SF_NOSUPERJUMPBOOST",SF_NOSUPERJUMPBOOST}, {"SF_CANBUSTWALLS",SF_CANBUSTWALLS}, + {"SF_NOSHIELDABILITY",SF_NOSHIELDABILITY}, + // Dashmode constants {"DASHMODE_THRESHOLD",DASHMODE_THRESHOLD}, From 2bebaf12d0f19e97a84577af8c75fa1e1523172a Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 04:03:14 -0500 Subject: [PATCH 53/63] add checks for new flag, make emergency jump call shieldspecial --- src/p_user.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index c5f919c78..f06ad998d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2491,6 +2491,7 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) player->mo->momx = player->mo->momy = 0; clipmomz = false; } + else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP) // Bubble shield's bounce attack. { P_DoBubbleBounce(player); @@ -5020,7 +5021,7 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock if ((player->powers[pw_shield] & SH_NOSTACK) && !player->powers[pw_super] && !(player->pflags & PF_SPINDOWN) && ((!(player->pflags & PF_THOKKED) || (((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP || (player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) && player->secondjump == UINT8_MAX) ))) // thokked is optional if you're bubblewrapped / 3dblasted { - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) + if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT && !(player->charflags & SF_NOSHIELDABILITY)) { if ((lockonshield = P_LookForEnemies(player, false, false))) { @@ -5043,7 +5044,7 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock } } } - if (cmd->buttons & BT_SPIN && !LUAh_ShieldSpecial(player)) // Spin button effects + if ((!(player->charflags & SF_NOSHIELDABILITY)) && (cmd->buttons & BT_SPIN && !LUAh_ShieldSpecial(player))) // Spin button effects { // Force stop if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE) @@ -5491,7 +5492,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) break; } } - else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super]) + else if ((!(player->charflags & SF_NOSHIELDABILITY)) && ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super] && !LUAh_ShieldSpecial(player))) P_DoJumpShield(player); } From 200e444016f61556fb080d956903364fee304abe Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 04:05:14 -0500 Subject: [PATCH 54/63] go away whitespace --- src/deh_tables.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index 2a0f179d4..e92a4f60c 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4989,7 +4989,6 @@ struct int_const_s const INT_CONST[] = { {"SF_CANBUSTWALLS",SF_CANBUSTWALLS}, {"SF_NOSHIELDABILITY",SF_NOSHIELDABILITY}, - // Dashmode constants {"DASHMODE_THRESHOLD",DASHMODE_THRESHOLD}, {"DASHMODE_MAX",DASHMODE_MAX}, From 4521827e2c2b101db0ba3c8ddd114fd8a1b18bc7 Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 04:06:28 -0500 Subject: [PATCH 55/63] you too --- src/p_user.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index f06ad998d..917c7ddf6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2491,7 +2491,6 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) player->mo->momx = player->mo->momy = 0; clipmomz = false; } - else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP) // Bubble shield's bounce attack. { P_DoBubbleBounce(player); From 00dff6d2836890bf51803530626047bf40f7b2fa Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 14 Dec 2020 05:53:57 -0800 Subject: [PATCH 56/63] Push "valid" only once --- src/lua_taglib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index 284b171a3..12d1a3c05 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -167,7 +167,7 @@ static void push_taglist(lua_State *L, int idx) static int has_valid_field(lua_State *L) { int equal; - lua_pushliteral(L, "valid"); + lua_rawgeti(L, LUA_ENVIRONINDEX, 1); equal = lua_rawequal(L, 2, -1); lua_pop(L, 1); return equal; @@ -392,6 +392,9 @@ static void open_taglist(lua_State *L) lua_setfield(L, -2, "has"); } +#define new_literal(L, s) \ + (lua_pushliteral(L, s), luaL_ref(L, -2)) + static void set_taglist_metatable(lua_State *L, const char *meta) { lua_createtable(L, 0, 4); @@ -399,6 +402,9 @@ static void set_taglist_metatable(lua_State *L, const char *meta) lua_setfield(L, -2, "taglist"); lua_pushcfunction(L, taglist_get); + lua_createtable(L, 0, 1); + new_literal(L, "valid"); + lua_setfenv(L, -2); lua_setfield(L, -2, "__index"); lua_pushcfunction(L, taglist_len); From d0f3a6d737137d2e68c4fb1506f8d7809f8801ae Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 14 Dec 2020 08:08:01 -0800 Subject: [PATCH 57/63] Better check for tag list userdata --- src/lua_taglib.c | 52 +++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index 12d1a3c05..c9f320fe8 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -156,13 +156,9 @@ static int lib_numTaggroupElements(lua_State *L) return 1; } -static void push_taglist(lua_State *L, int idx) -{ - lua_getmetatable(L, idx); - lua_pushliteral(L, "taglist"); - lua_rawget(L, -2); - lua_remove(L, -2); -} +#ifdef MUTABLE_TAGS +static int meta_ref[2]; +#endif static int has_valid_field(lua_State *L) { @@ -191,10 +187,19 @@ static taglist_t * valid_taglist(lua_State *L, int idx, boolean getting) static taglist_t * check_taglist(lua_State *L, int idx) { - luaL_checktype(L, idx, LUA_TUSERDATA); - push_taglist(L, idx); - luaL_argcheck(L, lua_toboolean(L, -1), idx, "must be a tag list"); - return valid_taglist(L, idx, false); + if (lua_isuserdata(L, idx) && lua_getmetatable(L, idx)) + { + lua_getref(L, meta_ref[0]); + lua_getref(L, meta_ref[1]); + + if (lua_rawequal(L, -3, -2) || lua_rawequal(L, -3, -1)) + { + lua_pop(L, 3); + return valid_taglist(L, idx, false); + } + } + + return luaL_argerror(L, idx, "must be a tag list"), NULL; } static int taglist_get(lua_State *L) @@ -223,7 +228,7 @@ static int taglist_get(lua_State *L) } else { - push_taglist(L, 1); + lua_getmetatable(L, 1); lua_replace(L, 1); lua_rawget(L, 1); return 1; @@ -395,12 +400,14 @@ static void open_taglist(lua_State *L) #define new_literal(L, s) \ (lua_pushliteral(L, s), luaL_ref(L, -2)) -static void set_taglist_metatable(lua_State *L, const char *meta) +#ifdef MUTABLE_TAGS +static int +#else +static void +#endif +set_taglist_metatable(lua_State *L, const char *meta) { - lua_createtable(L, 0, 4); - lua_getglobal(L, "taglist"); - lua_setfield(L, -2, "taglist"); - + luaL_newmetatable(L, meta); lua_pushcfunction(L, taglist_get); lua_createtable(L, 0, 1); new_literal(L, "valid"); @@ -412,7 +419,9 @@ static void set_taglist_metatable(lua_State *L, const char *meta) lua_pushcfunction(L, taglist_equal); lua_setfield(L, -2, "__eq"); - lua_setfield(L, LUA_REGISTRYINDEX, meta); +#ifdef MUTABLE_TAGS + return luaL_ref(L, LUA_REGISTRYINDEX); +#endif } int LUA_TagLib(lua_State *L) @@ -431,10 +440,11 @@ int LUA_TagLib(lua_State *L) open_taglist(L); - set_taglist_metatable(L, META_TAGLIST); - #ifdef MUTABLE_TAGS - set_taglist_metatable(L, META_SECTORTAGLIST); + meta_ref[0] = set_taglist_metatable(L, META_TAGLIST); + meta_ref[1] = set_taglist_metatable(L, META_SECTORTAGLIST); +#else + set_taglist_metatable(L, META_TAGLIST); #endif return 0; From 3b36005ceb1fa04f8c2875e5d614aeb8c419cef9 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 14 Dec 2020 14:13:24 -0300 Subject: [PATCH 58/63] Replace the first entry in the taglist, instead of adding into it --- src/p_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index 41d8822e2..66243fb0e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3171,7 +3171,7 @@ static void P_ConvertBinaryMap(void) switch (mapthings[i].type) { case 750: - Tag_Add(&mapthings[i].tags, mapthings[i].angle); + Tag_FSet(&mapthings[i].tags, mapthings[i].angle); break; case 760: case 761: From 9b8bacd08886375c1090d46d8d964f6c1c2b1be6 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 14 Dec 2020 12:52:24 -0600 Subject: [PATCH 59/63] Redone colormaps by SonicX8000 --- src/console.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/console.c b/src/console.c index 982b0d550..3c19c5e18 100644 --- a/src/console.c +++ b/src/console.c @@ -378,24 +378,23 @@ static void CON_SetupColormaps(void) map[0xE] = (UINT8)o;\ map[0xF] = (UINT8)p; - // I tried to make them kinda close to the originals, tell me how I did! ~Golden - // decent but i made most of the colors better thanks for th help :3 + // Tried to keep the colors vanilla while adding some shades in between them ~SonicX8000 - // 0x1 0x3 0x9 0xF - colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); - colset(yellowmap, 81, 81, 73, 73, 74, 74, 74, 65, 65, 65, 66, 66, 66, 67, 67, 67); - colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); - colset(bluemap, 146, 146, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151); - colset(redmap, 32, 32, 33, 33, 34, 34, 34, 35, 35, 35, 37, 37, 37, 39, 39, 39); - colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); - colset(orangemap, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58); - colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); - colset(purplemap, 144, 144, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164); - colset(aquamap, 120, 120, 121, 121, 122, 122, 122, 123, 123, 123, 124, 124, 124, 125, 125, 125); - colset(peridotmap, 72, 72, 188, 188, 189, 189, 189, 190, 190, 190, 191, 191, 191, 104, 104, 104); - colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 170, 170, 170, 171, 171, 171, 172, 172, 172); - colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); - colset(rosymap, 200, 200, 201, 201, 202, 202, 202, 203, 203, 203, 204, 204, 204, 205, 205, 205); + // 0x1 0x3 0x9 0xF + colset(magentamap, 177, 177, 178, 178, 178, 181, 181, 181, 183, 183, 183, 183, 185, 185, 185, 186); + colset(yellowmap, 82, 82, 73, 73, 73, 64, 64, 64, 66, 66, 66, 66, 67, 67, 67, 68); + colset(lgreenmap, 96, 96, 98, 98, 98, 101, 101, 101, 105, 105, 105, 105, 107, 107, 107, 108); + colset(bluemap, 146, 146, 147, 147, 147, 149, 149, 149, 152, 152, 152, 152, 155, 155, 155, 157); + colset(redmap, 32, 32, 33, 33, 33, 35, 35, 35, 39, 39, 39, 39, 42, 42, 42, 44); + colset(graymap, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23); + colset(orangemap, 50, 50, 52, 52, 52, 54, 54, 54, 56, 56, 56, 56, 59, 59, 59, 60); + colset(skymap, 129, 129, 130, 130, 130, 131, 131, 131, 133, 133, 133, 133, 135, 135, 135, 136); + colset(purplemap, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 163, 164, 164, 164, 165); + colset(aquamap, 120, 120, 121, 121, 121, 122, 122, 122, 123, 123, 123, 123, 124, 124, 124, 125); + colset(peridotmap, 72, 72, 188, 188, 189, 189, 189, 189, 190, 190, 190, 190, 191, 191, 191, 94); + colset(azuremap, 144, 144, 145, 145, 145, 146, 146, 146, 170, 170, 170, 170, 171, 171, 171, 172); + colset(brownmap, 219, 219, 221, 221, 221, 222, 222, 222, 224, 224, 224, 224, 227, 227, 227, 229); + colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 202, 203, 203, 203, 203, 204, 204, 204, 205); #undef colset From 07034cf44116b54bf769c80b42c39586b90338b6 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 14 Dec 2020 16:14:20 -0600 Subject: [PATCH 60/63] fixes spaces --- src/console.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/console.c b/src/console.c index 3c19c5e18..478f93fc8 100644 --- a/src/console.c +++ b/src/console.c @@ -378,23 +378,23 @@ static void CON_SetupColormaps(void) map[0xE] = (UINT8)o;\ map[0xF] = (UINT8)p; - // Tried to keep the colors vanilla while adding some shades in between them ~SonicX8000 + // Tried to keep the colors vanilla while adding some shades in between them ~SonicX8000 - // 0x1 0x3 0x9 0xF - colset(magentamap, 177, 177, 178, 178, 178, 181, 181, 181, 183, 183, 183, 183, 185, 185, 185, 186); - colset(yellowmap, 82, 82, 73, 73, 73, 64, 64, 64, 66, 66, 66, 66, 67, 67, 67, 68); - colset(lgreenmap, 96, 96, 98, 98, 98, 101, 101, 101, 105, 105, 105, 105, 107, 107, 107, 108); - colset(bluemap, 146, 146, 147, 147, 147, 149, 149, 149, 152, 152, 152, 152, 155, 155, 155, 157); - colset(redmap, 32, 32, 33, 33, 33, 35, 35, 35, 39, 39, 39, 39, 42, 42, 42, 44); - colset(graymap, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23); - colset(orangemap, 50, 50, 52, 52, 52, 54, 54, 54, 56, 56, 56, 56, 59, 59, 59, 60); - colset(skymap, 129, 129, 130, 130, 130, 131, 131, 131, 133, 133, 133, 133, 135, 135, 135, 136); - colset(purplemap, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 163, 164, 164, 164, 165); - colset(aquamap, 120, 120, 121, 121, 121, 122, 122, 122, 123, 123, 123, 123, 124, 124, 124, 125); + // 0x1 0x3 0x9 0xF + colset(magentamap, 177, 177, 178, 178, 178, 181, 181, 181, 183, 183, 183, 183, 185, 185, 185, 186); + colset(yellowmap, 82, 82, 73, 73, 73, 64, 64, 64, 66, 66, 66, 66, 67, 67, 67, 68); + colset(lgreenmap, 96, 96, 98, 98, 98, 101, 101, 101, 105, 105, 105, 105, 107, 107, 107, 108); + colset(bluemap, 146, 146, 147, 147, 147, 149, 149, 149, 152, 152, 152, 152, 155, 155, 155, 157); + colset(redmap, 32, 32, 33, 33, 33, 35, 35, 35, 39, 39, 39, 39, 42, 42, 42, 44); + colset(graymap, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23); + colset(orangemap, 50, 50, 52, 52, 52, 54, 54, 54, 56, 56, 56, 56, 59, 59, 59, 60); + colset(skymap, 129, 129, 130, 130, 130, 131, 131, 131, 133, 133, 133, 133, 135, 135, 135, 136); + colset(purplemap, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 163, 164, 164, 164, 165); + colset(aquamap, 120, 120, 121, 121, 121, 122, 122, 122, 123, 123, 123, 123, 124, 124, 124, 125); colset(peridotmap, 72, 72, 188, 188, 189, 189, 189, 189, 190, 190, 190, 190, 191, 191, 191, 94); - colset(azuremap, 144, 144, 145, 145, 145, 146, 146, 146, 170, 170, 170, 170, 171, 171, 171, 172); - colset(brownmap, 219, 219, 221, 221, 221, 222, 222, 222, 224, 224, 224, 224, 227, 227, 227, 229); - colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 202, 203, 203, 203, 203, 204, 204, 204, 205); + colset(azuremap, 144, 144, 145, 145, 145, 146, 146, 146, 170, 170, 170, 170, 171, 171, 171, 172); + colset(brownmap, 219, 219, 221, 221, 221, 222, 222, 222, 224, 224, 224, 224, 227, 227, 227, 229); + colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 202, 203, 203, 203, 203, 204, 204, 204, 205); #undef colset From d999e436f1883dead04b1b603a67e3f9efa9e547 Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 20:23:24 -0500 Subject: [PATCH 61/63] GETFLAG --- src/r_skins.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/r_skins.c b/src/r_skins.c index 522d9236a..6f150f234 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -514,6 +514,7 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) GETFLAG(NOSUPERSPRITES) GETFLAG(NOSUPERJUMPBOOST) GETFLAG(CANBUSTWALLS) + GETFLAG(NOSHIELDABILITY) #undef GETFLAG else // let's check if it's a sound, otherwise error out From fa9db2d64424bb6bfd98b350f43e44a63dfe8095 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 16 Dec 2020 00:26:08 -0300 Subject: [PATCH 62/63] Fix vibing slope planes I messed up the multiplication order for texture scaling: it multiplied a floating point number with a fixed point number, instead of multiplying two floats and then converting the result into a fixed point number. --- src/r_plane.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index c54b32382..194f85c4a 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -705,9 +705,9 @@ void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planev n.z = -xscale * cos(ang); ang = ANG2RAD(planeangle); - temp = P_GetSlopeZAt(slope, planeviewx + yscale * FLOAT_TO_FIXED(sin(ang)), planeviewy + yscale * FLOAT_TO_FIXED(cos(ang))); + temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(yscale * sin(ang)), planeviewy + FLOAT_TO_FIXED(yscale * cos(ang))); m.y = FIXED_TO_FLOAT(temp) - zeroheight; - temp = P_GetSlopeZAt(slope, planeviewx + xscale * FLOAT_TO_FIXED(cos(ang)), planeviewy - xscale * FLOAT_TO_FIXED(sin(ang))); + temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(xscale * cos(ang)), planeviewy - FLOAT_TO_FIXED(xscale * sin(ang))); n.y = FIXED_TO_FLOAT(temp) - zeroheight; if (ds_powersoftwo) From 45976d230454f37f62ca0c5cef5d1506c73dbccd Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 15 Dec 2020 22:19:57 -0600 Subject: [PATCH 63/63] magenta and green sonicx --- src/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/console.c b/src/console.c index 478f93fc8..c7bfe0fe1 100644 --- a/src/console.c +++ b/src/console.c @@ -381,9 +381,9 @@ static void CON_SetupColormaps(void) // Tried to keep the colors vanilla while adding some shades in between them ~SonicX8000 // 0x1 0x3 0x9 0xF - colset(magentamap, 177, 177, 178, 178, 178, 181, 181, 181, 183, 183, 183, 183, 185, 185, 185, 186); + colset(magentamap, 177, 177, 178, 178, 178, 180, 180, 180, 182, 182, 182, 182, 184, 184, 184, 185); colset(yellowmap, 82, 82, 73, 73, 73, 64, 64, 64, 66, 66, 66, 66, 67, 67, 67, 68); - colset(lgreenmap, 96, 96, 98, 98, 98, 101, 101, 101, 105, 105, 105, 105, 107, 107, 107, 108); + colset(lgreenmap, 96, 96, 98, 98, 98, 101, 101, 101, 104, 104, 104, 104, 106, 106, 106, 107); colset(bluemap, 146, 146, 147, 147, 147, 149, 149, 149, 152, 152, 152, 152, 155, 155, 155, 157); colset(redmap, 32, 32, 33, 33, 33, 35, 35, 35, 39, 39, 39, 39, 42, 42, 42, 44); colset(graymap, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23);