From 56b67a3b4ffa12b0508272619bf252babe647ca6 Mon Sep 17 00:00:00 2001 From: James Hale Date: Sat, 15 Feb 2020 03:18:41 -0500 Subject: [PATCH 01/42] Custom skincolors --- src/d_netcmd.c | 102 +++++++----- src/dehacked.c | 177 +++++++++++++++++--- src/djgppdos/i_system.c | 4 + src/doomdata.h | 4 - src/doomdef.h | 34 +++- src/f_finale.c | 2 +- src/g_game.c | 10 +- src/hardware/hw_md2.c | 16 +- src/hu_stuff.c | 133 ++++----------- src/info.c | 160 +++++++++++++++++- src/lua_baselib.c | 58 +++++-- src/lua_hudlib.c | 2 +- src/lua_infolib.c | 262 +++++++++++++++++++++++++++++ src/lua_libs.h | 2 + src/lua_mathlib.c | 9 +- src/lua_mobjlib.c | 4 +- src/lua_playerlib.c | 4 +- src/lua_script.c | 13 ++ src/m_cond.c | 8 +- src/m_cond.h | 4 +- src/m_menu.c | 300 +++++++++++++++++++++++++++------ src/m_menu.h | 17 ++ src/p_enemy.c | 10 +- src/p_mobj.c | 8 +- src/p_user.c | 2 +- src/r_draw.c | 361 +++------------------------------------- src/r_draw.h | 2 +- src/sdl/i_system.c | 4 + src/st_stuff.c | 14 +- src/win32/win_sys.c | 5 + 30 files changed, 1112 insertions(+), 619 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 623a83c47..1503c6f10 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -227,6 +227,7 @@ consvar_t cv_allowseenames = {"allowseenames", "Yes", CV_NETVAR, CV_YesNo, NULL, consvar_t cv_playername = {"name", "Sonic", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_playername2 = {"name2", "Tails", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name2_OnChange, 0, NULL, NULL, 0, 0, NULL}; // player colors +UINT8 lastgoodcolor = SKINCOLOR_BLUE, lastgoodcolor2 = SKINCOLOR_BLUE; consvar_t cv_playercolor = {"color", "Blue", CV_CALL|CV_NOINIT, Color_cons_t, Color_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_playercolor2 = {"color2", "Orange", CV_CALL|CV_NOINIT, Color_cons_t, Color2_OnChange, 0, NULL, NULL, 0, 0, NULL}; // player's skin, saved for commodity, when using a favorite skins wad.. @@ -624,7 +625,7 @@ void D_RegisterClientCommands(void) for (i = 0; i < MAXSKINCOLORS; i++) { Color_cons_t[i].value = i; - Color_cons_t[i].strvalue = Color_Names[i]; + Color_cons_t[i].strvalue = skincolors[i].name; } Color_cons_t[MAXSKINCOLORS].value = 0; Color_cons_t[MAXSKINCOLORS].strvalue = NULL; @@ -1226,15 +1227,20 @@ static void SendNameAndColor(void) CV_StealthSetValue(&cv_playercolor, skincolor_blueteam); } - // never allow the color "none" - if (!cv_playercolor.value) + // don't allow inaccessible colors + if (!skincolors[cv_playercolor.value].accessible) { - if (players[consoleplayer].skincolor) + if (players[consoleplayer].skincolor && skincolors[players[consoleplayer].skincolor].accessible) CV_StealthSetValue(&cv_playercolor, players[consoleplayer].skincolor); - else if (skins[players[consoleplayer].skin].prefcolor) - CV_StealthSetValue(&cv_playercolor, skins[players[consoleplayer].skin].prefcolor); - else + else if (skincolors[atoi(cv_playercolor.defaultvalue)].accessible) CV_StealthSet(&cv_playercolor, cv_playercolor.defaultvalue); + else if (skins[players[consoleplayer].skin].prefcolor && skincolors[skins[players[consoleplayer].skin].prefcolor].accessible) + CV_StealthSetValue(&cv_playercolor, skins[players[consoleplayer].skin].prefcolor); + else { + UINT16 i = 0; + while (icolor = (UINT8)players[consoleplayer].skincolor; @@ -1349,15 +1355,20 @@ static void SendNameAndColor2(void) CV_StealthSetValue(&cv_playercolor2, skincolor_blueteam); } - // never allow the color "none" - if (!cv_playercolor2.value) + // don't allow inaccessible colors + if (!skincolors[cv_playercolor2.value].accessible) { - if (players[secondplaya].skincolor) + if (players[secondplaya].skincolor && skincolors[players[secondplaya].skincolor].accessible) CV_StealthSetValue(&cv_playercolor2, players[secondplaya].skincolor); - else if (skins[players[secondplaya].skin].prefcolor) + else if (skincolors[atoi(cv_playercolor2.defaultvalue)].accessible) + CV_StealthSet(&cv_playercolor, cv_playercolor2.defaultvalue); + else if (skins[players[secondplaya].skin].prefcolor && skincolors[skins[players[secondplaya].skin].prefcolor].accessible) CV_StealthSetValue(&cv_playercolor2, skins[players[secondplaya].skin].prefcolor); - else - CV_StealthSet(&cv_playercolor2, cv_playercolor2.defaultvalue); + else { + UINT16 i = 0; + while (icolor = players[secondplaya].skincolor; @@ -1459,7 +1470,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) SetPlayerName(playernum, name); // set color - p->skincolor = color % MAXSKINCOLORS; + p->skincolor = color % numskincolors; if (p->mo) p->mo->color = (UINT8)p->skincolor; @@ -1478,8 +1489,8 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) kick = true; } - // don't allow color "none" - if (!p->skincolor) + // don't allow inaccessible colors + if (skincolors[p->skincolor].accessible == false) kick = true; // availabilities @@ -4491,25 +4502,30 @@ static void Skin2_OnChange(void) */ static void Color_OnChange(void) { - if (!Playing()) - return; // do whatever you want - - if (!(cv_debug || devparm) && !(multiplayer || netgame)) // In single player. - { - CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); - return; - } - - if (!P_PlayerMoving(consoleplayer)) - { - // Color change menu scrolling fix is no longer necessary - SendNameAndColor(); + if (!Playing()) { + if (!cv_playercolor.value || !skincolors[cv_playercolor.value].accessible) + CV_StealthSetValue(&cv_playercolor, lastgoodcolor); } else { - CV_StealthSetValue(&cv_playercolor, - players[consoleplayer].skincolor); + if (!(cv_debug || devparm) && !(multiplayer || netgame)) // In single player. + { + CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); + return; + } + + if (!P_PlayerMoving(consoleplayer) && skincolors[players[consoleplayer].skincolor].accessible == true) + { + // Color change menu scrolling fix is no longer necessary + SendNameAndColor(); + } + else + { + CV_StealthSetValue(&cv_playercolor, + players[consoleplayer].skincolor); + } } + lastgoodcolor = cv_playercolor.value; } /** Sends a color change for the secondary splitscreen player, unless that @@ -4520,18 +4536,24 @@ static void Color_OnChange(void) static void Color2_OnChange(void) { if (!Playing() || !splitscreen) - return; // do whatever you want - - if (!P_PlayerMoving(secondarydisplayplayer)) { - // Color change menu scrolling fix is no longer necessary - SendNameAndColor2(); + if (!cv_playercolor2.value || !skincolors[cv_playercolor2.value].accessible) + CV_StealthSetValue(&cv_playercolor2, lastgoodcolor2); } else { - CV_StealthSetValue(&cv_playercolor2, - players[secondarydisplayplayer].skincolor); + if (!P_PlayerMoving(secondarydisplayplayer) && skincolors[players[secondarydisplayplayer].skincolor].accessible == true) + { + // Color change menu scrolling fix is no longer necessary + SendNameAndColor2(); + } + else + { + CV_StealthSetValue(&cv_playercolor2, + players[secondarydisplayplayer].skincolor); + } } + lastgoodcolor2 = cv_playercolor2.value; } /** Displays the result of the chat being muted or unmuted. diff --git a/src/dehacked.c b/src/dehacked.c index 2d3fe40ed..3f08fcf35 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -57,10 +57,12 @@ int vsnprintf(char *str, size_t n, const char *fmt, va_list ap); // The crazy word-reading stuff uses these. static char *FREE_STATES[NUMSTATEFREESLOTS]; static char *FREE_MOBJS[NUMMOBJFREESLOTS]; +static char *FREE_SKINCOLORS[NUMCOLORFREESLOTS]; static UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway. #define initfreeslots() {\ memset(FREE_STATES,0,sizeof(char *) * NUMSTATEFREESLOTS);\ memset(FREE_MOBJS,0,sizeof(char *) * NUMMOBJFREESLOTS);\ +memset(FREE_SKINCOLORS,0,sizeof(char *) * NUMCOLORFREESLOTS);\ memset(used_spr,0,sizeof(UINT8) * ((NUMSPRITEFREESLOTS / 8) + 1));\ } @@ -80,6 +82,7 @@ static menutype_t get_menutype(const char *word); static INT16 get_gametype(const char *word); static powertype_t get_power(const char *word); #endif +skincolornum_t get_skincolor(const char *word); boolean deh_loaded = false; static int dbg_line; @@ -574,6 +577,16 @@ static void readfreeslots(MYFILE *f) break; } } + else if (fastcmp(type, "SKINCOLOR")) + { + for (i = 0; i < NUMCOLORFREESLOTS; i++) + if (!FREE_SKINCOLORS[i]) { + FREE_SKINCOLORS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); + strcpy(FREE_SKINCOLORS[i],word); + M_AddMenuColor(numskincolors++); + break; + } + } else if (fastcmp(type, "SPR2")) { // Search if we already have an SPR2 by that name... @@ -756,6 +769,84 @@ static void readthing(MYFILE *f, INT32 num) Z_Free(s); } +static void readskincolor(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word, *word2, *word3; + char *tmp; + + Color_cons_t[num].value = num; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + word = strtok(s, " "); + if (word) + strupr(word); + else + break; + + word2 = strtok(NULL, " = "); + if (word2) { + word3 = Z_StrDup(word2); + strupr(word2); + } else + break; + if (word2[strlen(word2)-1] == '\n') + word2[strlen(word2)-1] = '\0'; + if (word3[strlen(word3)-1] == '\n') + word3[strlen(word3)-1] = '\0'; + + if (fastcmp(word, "NAME")) + { + deh_strlcpy(skincolors[num].name, word3, + sizeof (skincolors[num].name), va("Skincolor %d: name", num)); + } + else if (fastcmp(word, "RAMP")) + { + UINT8 i; + tmp = strtok(word2,","); + for (i = 0; i < COLORRAMPSIZE; i++) { + skincolors[num].ramp[i] = (UINT8)get_number(tmp); + if ((tmp = strtok(NULL,",")) == NULL) + break; + } + } + else if (fastcmp(word, "INVCOLOR")) + { + skincolors[num].invcolor = (UINT8)get_number(word2); + } + else if (fastcmp(word, "INVSHADE")) + { + skincolors[num].invshade = get_number(word2); + } + else if (fastcmp(word, "CHATCOLOR")) + { + skincolors[num].chatcolor = get_number(word2); + } + else if (fastcmp(word, "ACCESSIBLE")) + { + if (num > FIRSTSUPERCOLOR) + skincolors[num].accessible = (boolean)(atoi(word2) || word2[0] == 'T' || word2[0] == 'Y'); + } + else + deh_warning("Skincolor %d: unknown word '%s'", num, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + #ifdef HWRENDER static void readlight(MYFILE *f, INT32 num) { @@ -4534,6 +4625,18 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) ignorelines(f); } } + else if (fastcmp(word, "SKINCOLOR") || fastcmp(word, "COLOR")) + { + if (i == 0 && word2[0] != '0') // If word2 isn't a number + i = get_skincolor(word2); // find a skincolor by name + if (i < numskincolors && i > 0) + readskincolor(f, i); + else + { + deh_warning("Skincolor %d out of range (1 - %d)", i, numskincolors-1); + ignorelines(f); + } + } else if (fastcmp(word, "SPRITE2")) { if (i == 0 && word2[0] != '0') // If word2 isn't a number @@ -8974,8 +9077,6 @@ static const char *const ML_LIST[16] = { }; #endif -// This DOES differ from r_draw's Color_Names, unfortunately. -// Also includes Super colors static const char *COLOR_ENUMS[] = { "NONE", // SKINCOLOR_NONE, @@ -9406,7 +9507,8 @@ struct { // SKINCOLOR_ doesn't include these..! {"MAXSKINCOLORS",MAXSKINCOLORS}, - {"MAXTRANSLATIONS",MAXTRANSLATIONS}, + {"FIRSTSUPERCOLOR",FIRSTSUPERCOLOR}, + {"NUMSUPERCOLORS",NUMSUPERCOLORS}, // Precipitation {"PRECIP_NONE",PRECIP_NONE}, @@ -9909,6 +10011,26 @@ static statenum_t get_state(const char *word) return S_NULL; } +skincolornum_t get_skincolor(const char *word) +{ // Returns the value of SKINCOLOR_ enumerations + skincolornum_t i; + if (*word >= '0' && *word <= '9') + return atoi(word); + if (fastncmp("SKINCOLOR_",word,10)) + word += 10; // take off the SKINCOLOR_ + for (i = 0; i < NUMCOLORFREESLOTS; i++) { + if (!FREE_SKINCOLORS[i]) + break; + if (fastcmp(word, FREE_SKINCOLORS[i])) + return SKINCOLOR_FIRSTFREESLOT+i; + } + for (i = 0; i < SKINCOLOR_FIRSTFREESLOT; i++) + if (fastcmp(word, COLOR_ENUMS[i])) + return i; + deh_warning("Couldn't find skincolor named 'SKINCOLOR_%s'",word); + return SKINCOLOR_GREEN; +} + static spritenum_t get_sprite(const char *word) { // Returns the value of SPR_ enumerations spritenum_t i; @@ -10204,6 +10326,11 @@ static fixed_t find_const(const char **rword) free(word); return r; } + else if (fastncmp("SKINCOLOR_",word,10)) { + r = get_skincolor(word); + free(word); + return r; + } else if (fastncmp("MT_",word,3)) { r = get_mobjtype(word); free(word); @@ -10272,17 +10399,6 @@ static fixed_t find_const(const char **rword) free(word); return r; } - else if (fastncmp("SKINCOLOR_",word,10)) { - char *p = word+10; - for (i = 0; i < MAXTRANSLATIONS; i++) - if (fastcmp(p, COLOR_ENUMS[i])) { - free(word); - return i; - } - const_warning("color",word); - free(word); - return 0; - } else if (fastncmp("GRADE_",word,6)) { char *p = word+6; @@ -10346,8 +10462,8 @@ void DEH_Check(void) if (dehpowers != NUMPOWERS) I_Error("You forgot to update the Dehacked powers list, you dolt!\n(%d powers defined, versus %s in the Dehacked list)\n", NUMPOWERS, sizeu1(dehpowers)); - if (dehcolors != MAXTRANSLATIONS) - I_Error("You forgot to update the Dehacked colors list, you dolt!\n(%d colors defined, versus %s in the Dehacked list)\n", MAXTRANSLATIONS, sizeu1(dehcolors)); + if (dehcolors != SKINCOLOR_FIRSTFREESLOT) + I_Error("You forgot to update the Dehacked colors list, you dolt!\n(%d colors defined, versus %s in the Dehacked list)\n", SKINCOLOR_FIRSTFREESLOT, sizeu1(dehcolors)); #endif } @@ -10456,6 +10572,22 @@ static inline int lib_freeslot(lua_State *L) if (i == NUMMOBJFREESLOTS) CONS_Alert(CONS_WARNING, "Ran out of free MobjType slots!\n"); } + else if (fastcmp(type, "SKINCOLOR")) + { + skincolornum_t i; + for (i = 0; i < NUMCOLORFREESLOTS; i++) + if (!FREE_SKINCOLORS[i]) { + CONS_Printf("Skincolor SKINCOLOR_%s allocated.\n",word); + FREE_SKINCOLORS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); + strcpy(FREE_SKINCOLORS[i],word); + M_AddMenuColor(numskincolors++); + lua_pushinteger(L, i); + r++; + break; + } + if (i == NUMCOLORFREESLOTS) + CONS_Alert(CONS_WARNING, "Ran out of free skincolor slots!\n"); + } else if (fastcmp(type, "SPR2")) { // Search if we already have an SPR2 by that name... @@ -10787,13 +10919,20 @@ static inline int lib_getenum(lua_State *L) } else if (fastncmp("SKINCOLOR_",word,10)) { p = word+10; - for (i = 0; i < MAXTRANSLATIONS; i++) + for (i = 0; i < NUMCOLORFREESLOTS; i++) { + if (!FREE_SKINCOLORS[i]) + break; + if (fastcmp(p, FREE_SKINCOLORS[i])) { + lua_pushinteger(L, SKINCOLOR_FIRSTFREESLOT+i); + return 1; + } + } + for (i = 0; i < SKINCOLOR_FIRSTFREESLOT; i++) if (fastcmp(p, COLOR_ENUMS[i])) { lua_pushinteger(L, i); return 1; } - if (mathlib) return luaL_error(L, "skincolor '%s' could not be found.\n", word); - return 0; + return luaL_error(L, "skincolor '%s' could not be found.\n", word); } else if (fastncmp("GRADE_",word,6)) { diff --git a/src/djgppdos/i_system.c b/src/djgppdos/i_system.c index dae9ed16e..9f6972fa6 100644 --- a/src/djgppdos/i_system.c +++ b/src/djgppdos/i_system.c @@ -61,6 +61,8 @@ #include "../console.h" +#include "../m_menu.h" + #ifdef __GNUG__ #pragma implementation "../i_system.h" #endif @@ -555,6 +557,7 @@ void I_Error (const char *error, ...) if (demorecording) G_CheckDemoStatus(); D_QuitNetGame (); + M_FreePlayerSetupColors(); if (shutdowning) { @@ -622,6 +625,7 @@ void I_Quit (void) if (demorecording) G_CheckDemoStatus(); D_QuitNetGame (); + M_FreePlayerSetupColors(); I_ShutdownMusic(); I_ShutdownSound(); I_ShutdownCD(); diff --git a/src/doomdata.h b/src/doomdata.h index f6e7cb584..e45bb1b5e 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -208,10 +208,6 @@ typedef struct #define ZSHIFT 4 -extern const UINT8 Color_Index[MAXTRANSLATIONS-1][16]; -extern const char *Color_Names[MAXSKINCOLORS + NUMSUPERCOLORS]; -extern const UINT8 Color_Opposite[MAXSKINCOLORS - 1][2]; - #define NUMMAPS 1035 #endif // __DOOMDATA__ diff --git a/src/doomdef.h b/src/doomdef.h index a21f878ae..bee822358 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -236,6 +236,19 @@ extern char logfilename[1024]; #define PLAYERSMASK (MAXPLAYERS-1) #define MAXPLAYERNAME 21 +#define COLORRAMPSIZE 16 +#define MAXCOLORNAME 32 + +typedef struct skincolor_s +{ + char name[MAXCOLORNAME+1]; // Skincolor name + UINT8 ramp[COLORRAMPSIZE]; // Colormap ramp + UINT8 invcolor; // Signpost color + UINT8 invshade; // Signpost color shade + UINT16 chatcolor; // Chat color + boolean accessible; // Accessible by the color command + setup menu +} skincolor_t; + typedef enum { SKINCOLOR_NONE = 0, @@ -314,12 +327,10 @@ typedef enum SKINCOLOR_RASPBERRY, SKINCOLOR_ROSY, - // SKINCOLOR_? - one left before we bump up against 0x39, which isn't a HARD limit anymore but would be excessive - - MAXSKINCOLORS, + FIRSTSUPERCOLOR, // Super special awesome Super flashing colors! - SKINCOLOR_SUPERSILVER1 = MAXSKINCOLORS, + SKINCOLOR_SUPERSILVER1 = FIRSTSUPERCOLOR, SKINCOLOR_SUPERSILVER2, SKINCOLOR_SUPERSILVER3, SKINCOLOR_SUPERSILVER4, @@ -373,9 +384,18 @@ typedef enum SKINCOLOR_SUPERTAN4, SKINCOLOR_SUPERTAN5, - MAXTRANSLATIONS, - NUMSUPERCOLORS = ((MAXTRANSLATIONS - MAXSKINCOLORS)/5) -} skincolors_t; + SKINCOLOR_FIRSTFREESLOT, + SKINCOLOR_LASTFREESLOT = 255, + + MAXSKINCOLORS, + + NUMSUPERCOLORS = ((SKINCOLOR_FIRSTFREESLOT - FIRSTSUPERCOLOR)/5) +} skincolornum_t; + +UINT16 numskincolors; + +#define NUMCOLORFREESLOTS (SKINCOLOR_LASTFREESLOT-SKINCOLOR_FIRSTFREESLOT)+1 +extern skincolor_t skincolors[MAXSKINCOLORS]; // State updates, number of tics / second. // NOTE: used to setup the timer rate, see I_StartupTimer(). diff --git a/src/f_finale.c b/src/f_finale.c index 66f963bbb..9c866538f 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2187,7 +2187,7 @@ void F_EndingDrawer(void) for (i = 0; i < 7; ++i) { UINT8* colormap; - skincolors_t col = SKINCOLOR_GREEN; + skincolornum_t col = SKINCOLOR_GREEN; switch (i) { case 1: diff --git a/src/g_game.c b/src/g_game.c index 634d80768..99eeb2160 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -5727,7 +5727,7 @@ void G_GhostTicker(void) g->mo->color += abs( ( (signed)( (unsigned)leveltime >> 1 ) % 9) - 4); break; case GHC_INVINCIBLE: // Mario invincibility (P_CheckInvincibilityTimer) - g->mo->color = (UINT8)(SKINCOLOR_RUBY + (leveltime % (MAXSKINCOLORS - SKINCOLOR_RUBY))); // Passes through all saturated colours + g->mo->color = (UINT8)(SKINCOLOR_RUBY + (leveltime % (FIRSTSUPERCOLOR - SKINCOLOR_RUBY))); // Passes through all saturated colours break; default: break; @@ -6814,8 +6814,8 @@ void G_DoPlayDemo(char *defdemoname) G_InitNew(false, G_BuildMapName(gamemap), true, true, false); // Set color - for (i = 0; i < MAXSKINCOLORS; i++) - if (!stricmp(Color_Names[i],color)) + for (i = 0; i < numskincolors; i++) + if (!stricmp(skincolors[i].name,color)) { players[0].skincolor = i; break; @@ -7063,8 +7063,8 @@ void G_AddGhost(char *defdemoname) // Set color gh->mo->color = ((skin_t*)gh->mo->skin)->prefcolor; - for (i = 0; i < MAXSKINCOLORS; i++) - if (!stricmp(Color_Names[i],color)) + for (i = 0; i < numskincolors; i++) + if (!stricmp(skincolors[i].name,color)) { gh->mo->color = (UINT8)i; break; diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 5c3cd40a6..255322240 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -677,7 +677,7 @@ spritemodelfound: #define SETBRIGHTNESS(brightness,r,g,b) \ brightness = (UINT8)(((1063*(UINT16)(r))/5000) + ((3576*(UINT16)(g))/5000) + ((361*(UINT16)(b))/5000)) -static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, INT32 skinnum, skincolors_t color) +static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, INT32 skinnum, skincolornum_t color) { UINT16 w = gpatch->width, h = gpatch->height; UINT32 size = w*h; @@ -718,16 +718,16 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, if (skinnum == TC_METALSONIC) color = SKINCOLOR_COBALT; - if (color != SKINCOLOR_NONE) + if (color != SKINCOLOR_NONE && color < numskincolors) { UINT8 numdupes = 1; - translation[translen] = Color_Index[color-1][0]; + translation[translen] = skincolors[color].ramp[0]; cutoff[translen] = 255; for (i = 1; i < 16; i++) { - if (translation[translen] == Color_Index[color-1][i]) + if (translation[translen] == skincolors[color].ramp[i]) { numdupes++; continue; @@ -741,7 +741,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, numdupes = 1; translen++; - translation[translen] = (UINT8)Color_Index[color-1][i]; + translation[translen] = (UINT8)skincolors[color].ramp[i]; } translen++; @@ -1043,7 +1043,7 @@ skippixel: #undef SETBRIGHTNESS -static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT32 skinnum, const UINT8 *colormap, skincolors_t color) +static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT32 skinnum, const UINT8 *colormap, skincolornum_t color) { // mostly copied from HWR_GetMappedPatch, hence the similarities and comment GLMipmap_t *grmip, *newmip; @@ -1336,7 +1336,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) else skinnum = TC_BOSS; } - else if ((skincolors_t)spr->mobj->color != SKINCOLOR_NONE) + else if ((skincolornum_t)spr->mobj->color != SKINCOLOR_NONE) { if (spr->mobj->colorized) skinnum = TC_RAINBOW; @@ -1356,7 +1356,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) } // Translation or skin number found - HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolors_t)spr->mobj->color); + HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolornum_t)spr->mobj->color); } else { diff --git a/src/hu_stuff.c b/src/hu_stuff.c index bf2432f5d..ce87dd375 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -759,107 +759,40 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) } else { - const UINT8 color = players[playernum].skincolor; + UINT16 chatcolor = skincolors[players[playernum].skincolor].chatcolor; - cstart = "\x83"; - - // Follow palette order at r_draw.c Color_Names - switch (color) - { - default: - case SKINCOLOR_WHITE: - case SKINCOLOR_BONE: - case SKINCOLOR_CLOUDY: - case SKINCOLOR_GREY: - case SKINCOLOR_SILVER: - case SKINCOLOR_AETHER: - case SKINCOLOR_SLATE: - cstart = "\x80"; // white - break; - case SKINCOLOR_CARBON: - case SKINCOLOR_JET: - case SKINCOLOR_BLACK: - cstart = "\x86"; // V_GRAYMAP - break; - case SKINCOLOR_PINK: - case SKINCOLOR_RUBY: - case SKINCOLOR_SALMON: - case SKINCOLOR_RED: - case SKINCOLOR_CRIMSON: - case SKINCOLOR_FLAME: - cstart = "\x85"; // V_REDMAP - break; - case SKINCOLOR_YOGURT: - case SKINCOLOR_BROWN: - case SKINCOLOR_TAN: - case SKINCOLOR_BEIGE: - case SKINCOLOR_QUAIL: - cstart = "\x8d"; // V_BROWNMAP - break; - case SKINCOLOR_MOSS: - case SKINCOLOR_GREEN: - case SKINCOLOR_FOREST: - case SKINCOLOR_EMERALD: - case SKINCOLOR_MINT: - cstart = "\x83"; // V_GREENMAP - break; - case SKINCOLOR_AZURE: - cstart = "\x8c"; // V_AZUREMAP - break; - case SKINCOLOR_LAVENDER: - case SKINCOLOR_PASTEL: - case SKINCOLOR_PURPLE: - cstart = "\x89"; // V_PURPLEMAP - break; - case SKINCOLOR_PEACHY: - case SKINCOLOR_LILAC: - case SKINCOLOR_PLUM: - case SKINCOLOR_ROSY: - cstart = "\x8e"; // V_ROSYMAP - break; - case SKINCOLOR_SUNSET: - case SKINCOLOR_APRICOT: - case SKINCOLOR_ORANGE: - case SKINCOLOR_RUST: - cstart = "\x87"; // V_ORANGEMAP - break; - case SKINCOLOR_GOLD: - case SKINCOLOR_SANDY: - case SKINCOLOR_YELLOW: - case SKINCOLOR_OLIVE: - cstart = "\x82"; // V_YELLOWMAP - break; - case SKINCOLOR_LIME: - case SKINCOLOR_PERIDOT: - cstart = "\x8b"; // V_PERIDOTMAP - break; - case SKINCOLOR_SEAFOAM: - case SKINCOLOR_AQUA: - cstart = "\x8a"; // V_AQUAMAP - break; - case SKINCOLOR_TEAL: - case SKINCOLOR_WAVE: - case SKINCOLOR_CYAN: - case SKINCOLOR_SKY: - case SKINCOLOR_CERULEAN: - case SKINCOLOR_ICY: - case SKINCOLOR_SAPPHIRE: - case SKINCOLOR_VAPOR: - cstart = "\x88"; // V_SKYMAP - break; - case SKINCOLOR_CORNFLOWER: - case SKINCOLOR_BLUE: - case SKINCOLOR_COBALT: - case SKINCOLOR_DUSK: - cstart = "\x84"; // V_BLUEMAP - break; - case SKINCOLOR_BUBBLEGUM: - case SKINCOLOR_MAGENTA: - case SKINCOLOR_NEON: - case SKINCOLOR_VIOLET: - cstart = "\x81"; // V_MAGENTAMAP - break; - } + if (!chatcolor || chatcolor%0x1000 || chatcolor>V_INVERTMAP) + cstart = "\x80"; + else if (chatcolor == V_MAGENTAMAP) + cstart = "\x81"; + else if (chatcolor == V_YELLOWMAP) + cstart = "\x82"; + else if (chatcolor == V_GREENMAP) + cstart = "\x83"; + else if (chatcolor == V_BLUEMAP) + cstart = "\x84"; + else if (chatcolor == V_REDMAP) + cstart = "\x85"; + else if (chatcolor == V_GRAYMAP) + cstart = "\x86"; + else if (chatcolor == V_ORANGEMAP) + cstart = "\x87"; + else if (chatcolor == V_SKYMAP) + cstart = "\x88"; + else if (chatcolor == V_PURPLEMAP) + cstart = "\x89"; + else if (chatcolor == V_AQUAMAP) + cstart = "\x8a"; + else if (chatcolor == V_PERIDOTMAP) + cstart = "\x8b"; + else if (chatcolor == V_AZUREMAP) + cstart = "\x8c"; + else if (chatcolor == V_BROWNMAP) + cstart = "\x8d"; + else if (chatcolor == V_ROSYMAP) + cstart = "\x8e"; + else if (chatcolor == V_INVERTMAP) + cstart = "\x8f"; } prefix = cstart; diff --git a/src/info.c b/src/info.c index cf4d7df4f..2993040d1 100644 --- a/src/info.c +++ b/src/info.c @@ -20,6 +20,7 @@ #include "m_misc.h" #include "z_zone.h" #include "d_player.h" +#include "v_video.h" // V_*MAP constants #include "lzf.h" #ifdef HWRENDER #include "hardware/hw_light.h" @@ -21606,8 +21607,140 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = #endif }; +skincolor_t skincolors[MAXSKINCOLORS] = { + {"None", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, SKINCOLOR_NONE, 0, 0, false}, // SKINCOLOR_NONE -/** Patches the mobjinfo table and state table. + // Greyscale ranges + {"White", {0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x11}, SKINCOLOR_BLACK, 5, 0, true}, // SKINCOLOR_WHITE + {"Bone", {0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x11, 0x12}, SKINCOLOR_JET, 7, 0, true}, // SKINCOLOR_BONE + {"Cloudy", {0x02, 0x03, 0x04, 0x05, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14}, SKINCOLOR_CARBON, 7, 0, true}, // SKINCOLOR_CLOUDY + {"Grey", {0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18}, SKINCOLOR_AETHER, 12, 0, true}, // SKINCOLOR_GREY + {"Silver", {0x02, 0x03, 0x05, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11, 0x13, 0x15, 0x17, 0x19, 0x1b, 0x1d, 0x1f}, SKINCOLOR_SLATE, 12, 0, true}, // SKINCOLOR_SILVER + {"Carbon", {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x16, 0x17, 0x17, 0x19, 0x19, 0x1a, 0x1a, 0x1b, 0x1c, 0x1d}, SKINCOLOR_CLOUDY, 7, V_GRAYMAP, true}, // SKINCOLOR_CARBON + {"Jet", {0x00, 0x05, 0x0a, 0x0f, 0x14, 0x19, 0x1a, 0x1b, 0x1c, 0x1e, 0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x1f}, SKINCOLOR_BONE, 7, V_GRAYMAP, true}, // SKINCOLOR_JET + {"Black", {0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1b, 0x1b, 0x1c, 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f}, SKINCOLOR_WHITE, 7, V_GRAYMAP, true}, // SKINCOLOR_BLACK + + // Desaturated + {"Aether", {0x00, 0x00, 0x01, 0x02, 0x02, 0x03, 0x91, 0x91, 0x91, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xaf}, SKINCOLOR_GREY, 15, 0, true}, // SKINCOLOR_AETHER + {"Slate", {0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0xaa, 0xaa, 0xaa, 0xab, 0xac, 0xac, 0xad, 0xad, 0xae, 0xaf}, SKINCOLOR_SILVER, 12, 0, true}, // SKINCOLOR_SLATE + {"Bluebell", {0x90, 0x91, 0x92, 0x93, 0x94, 0x94, 0x95, 0xac, 0xac, 0xad, 0xad, 0xa8, 0xa8, 0xa9, 0xfd, 0xfe}, SKINCOLOR_COPPER, 4, V_BLUEMAP, true}, // SKINCOLOR_BLUEBELL + {"Pink", {0xd0, 0xd0, 0xd1, 0xd1, 0xd2, 0xd2, 0xd3, 0xd3, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0x2b, 0x2c, 0x2e}, SKINCOLOR_AZURE, 9, V_REDMAP, true}, // SKINCOLOR_PINK + {"Yogurt", {0xd0, 0x30, 0xd8, 0xd9, 0xda, 0xdb, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe3, 0xe6, 0xe8, 0xe9}, SKINCOLOR_RUST, 7, V_BROWNMAP, true}, // SKINCOLOR_YOGURT + {"Brown", {0xdf, 0xe0, 0xe1, 0xe2, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef}, SKINCOLOR_TAN, 2, V_BROWNMAP, true}, // SKINCOLOR_BROWN + {"Bronze", {0xde, 0xe0, 0xe1, 0xe4, 0xe7, 0xe9, 0xeb, 0xec, 0xed, 0xed, 0xed, 0x19, 0x19, 0x1b, 0x1d, 0x1e}, SKINCOLOR_KETCHUP, 0, V_BROWNMAP, true}, // SKINCOLOR_BRONZE + {"Tan", {0x51, 0x51, 0x54, 0x54, 0x55, 0x55, 0x56, 0x56, 0x56, 0x57, 0xf5, 0xf5, 0xf9, 0xf9, 0xed, 0xed}, SKINCOLOR_BROWN, 12, V_BROWNMAP, true}, // SKINCOLOR_TAN + {"Beige", {0x54, 0x55, 0x56, 0x56, 0xf2, 0xf3, 0xf3, 0xf4, 0xf5, 0xf6, 0xf8, 0xf9, 0xfa, 0xfb, 0xed, 0xed}, SKINCOLOR_MOSS, 5, V_BROWNMAP, true}, // SKINCOLOR_BEIGE + {"Moss", {0x58, 0x58, 0x59, 0x59, 0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5d, 0x5d, 0x5e, 0x5e, 0x5f, 0x5f}, SKINCOLOR_BEIGE, 13, V_GREENMAP, true}, // SKINCOLOR_MOSS + {"Azure", {0x90, 0x90, 0x91, 0x91, 0xaa, 0xaa, 0xab, 0xab, 0xab, 0xac, 0xad, 0xad, 0xae, 0xae, 0xaf, 0xaf}, SKINCOLOR_PINK, 5, V_AZUREMAP, true}, // SKINCOLOR_AZURE + {"Lavender", {0xc0, 0xc0, 0xc1, 0xc1, 0xc2, 0xc2, 0xc3, 0xc3, 0xc3, 0xc4, 0xc5, 0xc5, 0xc6, 0xc6, 0xc7, 0xc7}, SKINCOLOR_GOLD, 4, V_PURPLEMAP, true}, // SKINCOLOR_LAVENDER + + // Viv's vivid colours (toast 21/07/17) + {"Ruby", {0xb0, 0xb0, 0xc9, 0xca, 0xcc, 0x26, 0x27, 0x28, 0x29, 0x2a, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfd}, SKINCOLOR_EMERALD, 10, V_REDMAP, true}, // SKINCOLOR_RUBY + {"Salmon", {0xd0, 0xd0, 0xd1, 0xd2, 0x20, 0x21, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e}, SKINCOLOR_FOREST, 6, V_REDMAP, true}, // SKINCOLOR_SALMON + {"Red", {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x47, 0x2e, 0x2f}, SKINCOLOR_GREEN, 10, V_REDMAP, true}, // SKINCOLOR_RED + {"Crimson", {0x27, 0x27, 0x28, 0x28, 0x29, 0x2a, 0x2b, 0x2b, 0x2c, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f, 0x1f}, SKINCOLOR_ICY, 10, V_REDMAP, true}, // SKINCOLOR_CRIMSON + {"Flame", {0x31, 0x32, 0x33, 0x36, 0x22, 0x22, 0x25, 0x25, 0x25, 0xcd, 0xcf, 0xcf, 0xc5, 0xc5, 0xc7, 0xc7}, SKINCOLOR_PURPLE, 8, V_REDMAP, true}, // SKINCOLOR_FLAME + {"Ketchup", {0x48, 0x49, 0x40, 0x33, 0x34, 0x36, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2b, 0x2c, 0x47, 0x2e, 0x2f}, SKINCOLOR_BRONZE, 8, V_REDMAP, true}, // SKINCOLOR_KETCHUP + {"Peachy", {0xd0, 0x30, 0x31, 0x31, 0x32, 0x32, 0xdc, 0xdc, 0xdc, 0xd3, 0xd4, 0xd4, 0xcc, 0xcd, 0xce, 0xcf}, SKINCOLOR_TEAL, 7, V_ROSYMAP, true}, // SKINCOLOR_PEACHY + {"Quail", {0xd8, 0xd9, 0xdb, 0xdc, 0xde, 0xdf, 0xd5, 0xd5, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0x1d, 0x1f}, SKINCOLOR_WAVE, 5, V_BROWNMAP, true}, // SKINCOLOR_QUAIL + {"Sunset", {0x51, 0x52, 0x40, 0x40, 0x34, 0x36, 0xd5, 0xd5, 0xd6, 0xd7, 0xcf, 0xcf, 0xc6, 0xc6, 0xc7, 0xfe}, SKINCOLOR_SAPPHIRE, 5, V_ORANGEMAP, true}, // SKINCOLOR_SUNSET + {"Copper", {0x58, 0x54, 0x40, 0x34, 0x35, 0x38, 0x3a, 0x3c, 0x3d, 0x2a, 0x2b, 0x2c, 0x2c, 0xba, 0xba, 0xbb}, SKINCOLOR_BLUEBELL, 5, V_ORANGEMAP, true}, // SKINCOLOR_COPPER + {"Apricot", {0x00, 0xd8, 0xd9, 0xda, 0xdb, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e}, SKINCOLOR_CYAN, 4, V_ORANGEMAP, true}, // SKINCOLOR_APRICOT + {"Orange", {0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x2c}, SKINCOLOR_BLUE, 4, V_ORANGEMAP, true}, // SKINCOLOR_ORANGE + {"Rust", {0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3f, 0x2c, 0x2d, 0x47, 0x2e, 0x2f, 0x2f}, SKINCOLOR_YOGURT, 8, V_ORANGEMAP, true}, // SKINCOLOR_RUST + {"Gold", {0x51, 0x51, 0x54, 0x54, 0x41, 0x42, 0x43, 0x43, 0x44, 0x45, 0x46, 0x3f, 0x2d, 0x2e, 0x2f, 0x2f}, SKINCOLOR_LAVENDER, 10, V_YELLOWMAP, true}, // SKINCOLOR_GOLD + {"Sandy", {0x53, 0x40, 0x41, 0x42, 0x43, 0xe6, 0xe9, 0xe9, 0xea, 0xec, 0xec, 0xc6, 0xc6, 0xc7, 0xc7, 0xfe}, SKINCOLOR_SKY, 8, V_YELLOWMAP, true}, // SKINCOLOR_SANDY + {"Yellow", {0x52, 0x53, 0x49, 0x49, 0x4a, 0x4a, 0x4b, 0x4b, 0x4b, 0x4c, 0x4d, 0x4d, 0x4e, 0x4e, 0x4f, 0xed}, SKINCOLOR_CORNFLOWER, 8, V_YELLOWMAP, true}, // SKINCOLOR_YELLOW + {"Olive", {0x4b, 0x4b, 0x4c, 0x4c, 0x4d, 0x4e, 0xe7, 0xe7, 0xe9, 0xc5, 0xc5, 0xc6, 0xc6, 0xc7, 0xc7, 0xfd}, SKINCOLOR_DUSK, 3, V_YELLOWMAP, true}, // SKINCOLOR_OLIVE + {"Lime", {0x50, 0x51, 0x52, 0x53, 0x48, 0xbc, 0xbd, 0xbe, 0xbe, 0xbf, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f}, SKINCOLOR_MAGENTA, 9, V_PERIDOTMAP, true}, // SKINCOLOR_LIME + {"Peridot", {0x58, 0x58, 0xbc, 0xbc, 0xbd, 0xbd, 0xbe, 0xbe, 0xbe, 0xbf, 0x5e, 0x5e, 0x5f, 0x5f, 0x77, 0x77}, SKINCOLOR_COBALT, 2, V_PERIDOTMAP, true}, // SKINCOLOR_PERIDOT + {"Apple", {0x49, 0x49, 0xbc, 0xbd, 0xbe, 0xbe, 0xbe, 0x67, 0x69, 0x6a, 0x6b, 0x6b, 0x6c, 0x6d, 0x6d, 0x6d}, SKINCOLOR_RASPBERRY, 13, V_PERIDOTMAP, true}, // SKINCOLOR_APPLE + {"Green", {0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f}, SKINCOLOR_RED, 6, V_GREENMAP, true}, // SKINCOLOR_GREEN + {"Forest", {0x65, 0x66, 0x67, 0x68, 0x69, 0x69, 0x6a, 0x6b, 0x6b, 0x6c, 0x6d, 0x6d, 0x6e, 0x6e, 0x6e, 0x6f}, SKINCOLOR_SALMON, 9, V_GREENMAP, true}, // SKINCOLOR_FOREST + {"Emerald", {0x70, 0x70, 0x71, 0x71, 0x72, 0x72, 0x73, 0x73, 0x73, 0x74, 0x75, 0x75, 0x76, 0x76, 0x77, 0x77}, SKINCOLOR_RUBY, 4, V_GREENMAP, true}, // SKINCOLOR_EMERALD + {"Mint", {0x00, 0x00, 0x58, 0x58, 0x59, 0x62, 0x62, 0x62, 0x64, 0x67, 0x7e, 0x7e, 0x8f, 0x8f, 0x8a, 0x8a}, SKINCOLOR_VIOLET, 5, V_GREENMAP, true}, // SKINCOLOR_MINT + {"Seafoam", {0x01, 0x58, 0x59, 0x5a, 0x7d, 0x7d, 0x7e, 0x7e, 0x7e, 0x8f, 0x8f, 0x8a, 0x8a, 0x8a, 0xfd, 0xfd}, SKINCOLOR_PLUM, 6, V_AQUAMAP, true}, // SKINCOLOR_SEAFOAM + {"Aqua", {0x78, 0x79, 0x7a, 0x7a, 0x7b, 0x7b, 0x7c, 0x7c, 0x7c, 0x7d, 0x7e, 0x7e, 0x7f, 0x7f, 0x76, 0x77}, SKINCOLOR_ROSY, 7, V_AQUAMAP, true}, // SKINCOLOR_AQUA + {"Teal", {0x78, 0x78, 0x8c, 0x8c, 0x8d, 0x8d, 0x8d, 0x8e, 0x8e, 0x8f, 0x8f, 0x8f, 0x8a, 0x8a, 0x8a, 0x8a}, SKINCOLOR_PEACHY, 7, V_SKYMAP, true}, // SKINCOLOR_TEAL + {"Wave", {0x00, 0x78, 0x78, 0x79, 0x8d, 0x87, 0x88, 0x89, 0x89, 0xae, 0xa8, 0xa8, 0xa9, 0xa9, 0xfd, 0xfd}, SKINCOLOR_QUAIL, 5, V_SKYMAP, true}, // SKINCOLOR_WAVE + {"Cyan", {0x80, 0x81, 0xff, 0xff, 0x83, 0x83, 0x8d, 0x8d, 0x8d, 0x8e, 0x7e, 0x7f, 0x76, 0x76, 0x77, 0x6e}, SKINCOLOR_APRICOT, 6, V_SKYMAP, true}, // SKINCOLOR_CYAN + {"Sky", {0x80, 0x80, 0x81, 0x82, 0x83, 0x83, 0x84, 0x85, 0x85, 0x86, 0x87, 0x88, 0x89, 0x89, 0x8a, 0x8b}, SKINCOLOR_SANDY, 1, V_SKYMAP, true}, // SKINCOLOR_SKY + {"Cerulean", {0x85, 0x86, 0x87, 0x88, 0x88, 0x89, 0x89, 0x89, 0x8a, 0x8a, 0xfd, 0xfd, 0xfd, 0x1f, 0x1f, 0x1f}, SKINCOLOR_NEON, 4, V_SKYMAP, true}, // SKINCOLOR_CERULEAN + {"Icy", {0x00, 0x00, 0x00, 0x00, 0x80, 0x81, 0x83, 0x83, 0x86, 0x87, 0x95, 0x95, 0xad, 0xad, 0xae, 0xaf}, SKINCOLOR_CRIMSON, 0, V_SKYMAP, true}, // SKINCOLOR_ICY + {"Sapphire", {0x80, 0x83, 0x86, 0x87, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xfd, 0xfe}, SKINCOLOR_SUNSET, 5, V_SKYMAP, true}, // SKINCOLOR_SAPPHIRE + {"Cornflower", {0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x9a, 0x9c, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e}, SKINCOLOR_YELLOW, 4, V_BLUEMAP, true}, // SKINCOLOR_CORNFLOWER + {"Blue", {0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xfd, 0xfe}, SKINCOLOR_ORANGE, 5, V_BLUEMAP, true}, // SKINCOLOR_BLUE + {"Cobalt", {0x93, 0x94, 0x95, 0x96, 0x98, 0x9a, 0x9b, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xfd, 0xfd, 0xfe, 0xfe}, SKINCOLOR_PERIDOT, 5, V_BLUEMAP, true}, // SKINCOLOR_COBALT + {"Vapor", {0x80, 0x81, 0x83, 0x86, 0x94, 0x94, 0xa3, 0xa3, 0xa4, 0xa6, 0xa6, 0xa6, 0xa8, 0xa8, 0xa9, 0xa9}, SKINCOLOR_LILAC, 4, V_SKYMAP, true}, // SKINCOLOR_VAPOR + {"Dusk", {0x92, 0x93, 0x94, 0x94, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xaf, 0xaf, 0xa9, 0xa9, 0xfd, 0xfd}, SKINCOLOR_OLIVE, 0, V_BLUEMAP, true}, // SKINCOLOR_DUSK + {"Pastel", {0x90, 0x90, 0xa0, 0xa0, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2, 0xa3, 0xa4, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8}, SKINCOLOR_BUBBLEGUM, 9, V_PURPLEMAP, true}, // SKINCOLOR_PASTEL + {"Purple", {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa5, 0xa6, 0xa7, 0xa7, 0xa8, 0xa8, 0xa9, 0xa9}, SKINCOLOR_FLAME, 7, V_PURPLEMAP, true}, // SKINCOLOR_PURPLE + {"Bubblegum", {0x00, 0xd0, 0xd0, 0xc8, 0xc8, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8}, SKINCOLOR_PASTEL, 8, V_MAGENTAMAP, true}, // SKINCOLOR_BUBBLEGUM + {"Magenta", {0xb3, 0xb3, 0xb4, 0xb5, 0xb6, 0xb6, 0xb7, 0xb7, 0xb7, 0xb8, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xbb}, SKINCOLOR_LIME, 6, V_MAGENTAMAP, true}, // SKINCOLOR_MAGENTA + {"Neon", {0xb3, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xbb, 0xc7, 0xc7, 0x1d, 0x1d, 0x1e}, SKINCOLOR_CERULEAN, 2, V_MAGENTAMAP, true}, // SKINCOLOR_NEON + {"Violet", {0xd0, 0xd1, 0xd2, 0xca, 0xcc, 0xb8, 0xb9, 0xb9, 0xba, 0xa8, 0xa8, 0xa9, 0xa9, 0xfd, 0xfe, 0xfe}, SKINCOLOR_MINT, 6, V_MAGENTAMAP, true}, // SKINCOLOR_VIOLET + {"Lilac", {0x00, 0xd0, 0xd1, 0xd2, 0xd3, 0xc1, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc5, 0xc6, 0xc6, 0xfe, 0x1f}, SKINCOLOR_VAPOR, 4, V_ROSYMAP, true}, // SKINCOLOR_LILAC + {"Plum", {0xc8, 0xd3, 0xd5, 0xd6, 0xd7, 0xce, 0xcf, 0xb9, 0xb9, 0xba, 0xba, 0xa9, 0xa9, 0xa9, 0xfd, 0xfe}, SKINCOLOR_MINT, 7, V_ROSYMAP, true}, // SKINCOLOR_PLUM + {"Raspberry", {0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xcd, 0xce, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfe, 0xfe}, SKINCOLOR_APPLE, 15, V_MAGENTAMAP, true}, // SKINCOLOR_RASPBERRY + {"Rosy", {0xfc, 0xc8, 0xc8, 0xc9, 0xc9, 0xca, 0xca, 0xcb, 0xcb, 0xcc, 0xcc, 0xcd, 0xcd, 0xce, 0xce, 0xcf}, SKINCOLOR_AQUA, 1, V_ROSYMAP, true}, // SKINCOLOR_ROSY + + // super + {"Super Silver 1", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03}, SKINCOLOR_BLACK, 15, 0, false}, // SKINCOLOR_SUPERSILVER1 + {"Super Silver 2", {0x00, 0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07}, SKINCOLOR_BLACK, 6, 0, false}, // SKINCOLOR_SUPERSILVER2 + {"Super Silver 3", {0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x09, 0x0b}, SKINCOLOR_BLACK, 5, 0, false}, // SKINCOLOR_SUPERSILVER3 + {"Super Silver 4", {0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11}, SKINCOLOR_BLACK, 5, V_GRAYMAP, false}, // SKINCOLOR_SUPERSILVER4 + {"Super Silver 5", {0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11, 0x13}, SKINCOLOR_BLACK, 5, V_GRAYMAP, false}, // SKINCOLOR_SUPERSILVER5 + + {"Super Red 1", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0xd0, 0xd1, 0xd1, 0xd2, 0xd2}, SKINCOLOR_CYAN, 15, 0, false}, // SKINCOLOR_SUPERRED1 + {"Super Red 2", {0x00, 0x00, 0x00, 0xd0, 0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2, 0x20, 0x20, 0x21, 0x21}, SKINCOLOR_CYAN, 14, V_ROSYMAP, false}, // SKINCOLOR_SUPERRED2 + {"Super Red 3", {0x00, 0x00, 0xd0, 0xd0, 0xd1, 0xd1, 0xd2, 0xd2, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23}, SKINCOLOR_CYAN, 13, V_REDMAP, false}, // SKINCOLOR_SUPERRED3 + {"Super Red 4", {0x00, 0xd0, 0xd1, 0xd1, 0xd2, 0xd2, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x24, 0x24}, SKINCOLOR_CYAN, 11, V_REDMAP, false}, // SKINCOLOR_SUPERRED4 + {"Super Red 5", {0xd0, 0xd1, 0xd2, 0xd2, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x24, 0x24, 0x25, 0x25}, SKINCOLOR_CYAN, 10, V_REDMAP, false}, // SKINCOLOR_SUPERRED5 + + {"Super Orange 1", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x30, 0x31, 0x32, 0x33, 0x34}, SKINCOLOR_SAPPHIRE, 15, 0, false}, // SKINCOLOR_SUPERORANGE1 + {"Super Orange 2", {0x00, 0x00, 0x00, 0x00, 0xd0, 0xd0, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x34, 0x34}, SKINCOLOR_SAPPHIRE, 12, V_ORANGEMAP, false}, // SKINCOLOR_SUPERORANGE2 + {"Super Orange 3", {0x00, 0x00, 0xd0, 0xd0, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x34, 0x34, 0x35, 0x35}, SKINCOLOR_SAPPHIRE, 9, V_ORANGEMAP, false}, // SKINCOLOR_SUPERORANGE3 + {"Super Orange 4", {0x00, 0xd0, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x44, 0x45, 0x46}, SKINCOLOR_SAPPHIRE, 4, V_ORANGEMAP, false}, // SKINCOLOR_SUPERORANGE4 + {"Super Orange 5", {0xd0, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x44, 0x45, 0x46, 0x47}, SKINCOLOR_SAPPHIRE, 3, V_ORANGEMAP, false}, // SKINCOLOR_SUPERORANGE5 + + {"Super Gold 1", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50, 0x51, 0x52, 0x53, 0x48}, SKINCOLOR_CORNFLOWER, 15, 0, false}, // SKINCOLOR_SUPERGOLD1 + {"Super Gold 2", {0x00, 0x50, 0x51, 0x52, 0x53, 0x53, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x40, 0x41}, SKINCOLOR_CORNFLOWER, 9, V_YELLOWMAP, false}, // SKINCOLOR_SUPERGOLD2 + {"Super Gold 3", {0x51, 0x52, 0x53, 0x53, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x40, 0x41, 0x42, 0x43}, SKINCOLOR_CORNFLOWER, 8, V_YELLOWMAP, false}, // SKINCOLOR_SUPERGOLD3 + {"Super Gold 4", {0x53, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46}, SKINCOLOR_CORNFLOWER, 8, V_YELLOWMAP, false}, // SKINCOLOR_SUPERGOLD4 + {"Super Gold 5", {0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47}, SKINCOLOR_CORNFLOWER, 8, V_YELLOWMAP, false}, // SKINCOLOR_SUPERGOLD5 + + {"Super Peridot 1", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x58, 0x58, 0xbc, 0xbc, 0xbc}, SKINCOLOR_COBALT, 15, 0, false}, // SKINCOLOR_SUPERPERIDOT1 + {"Super Peridot 2", {0x00, 0x58, 0x58, 0x58, 0xbc, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe}, SKINCOLOR_COBALT, 4, V_PERIDOTMAP, false}, // SKINCOLOR_SUPERPERIDOT2 + {"Super Peridot 3", {0x58, 0x58, 0xbc, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf}, SKINCOLOR_COBALT, 3, V_PERIDOTMAP, false}, // SKINCOLOR_SUPERPERIDOT3 + {"Super Peridot 4", {0x58, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf, 0x5e, 0x5e, 0x5f}, SKINCOLOR_COBALT, 3, V_PERIDOTMAP, false}, // SKINCOLOR_SUPERPERIDOT4 + {"Super Peridot 5", {0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf, 0x5e, 0x5e, 0x5f, 0x77}, SKINCOLOR_COBALT, 3, V_PERIDOTMAP, false}, // SKINCOLOR_SUPERPERIDOT5 + + {"Super Sky 1", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x81, 0x82, 0x83, 0x84}, SKINCOLOR_RUST, 15, 0, false}, // SKINCOLOR_SUPERSKY1 + {"Super Sky 2", {0x00, 0x80, 0x81, 0x82, 0x83, 0x83, 0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86}, SKINCOLOR_RUST, 4, V_SKYMAP, false}, // SKINCOLOR_SUPERSKY2 + {"Super Sky 3", {0x81, 0x82, 0x83, 0x83, 0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87}, SKINCOLOR_RUST, 3, V_SKYMAP, false}, // SKINCOLOR_SUPERSKY3 + {"Super Sky 4", {0x83, 0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87, 0x88, 0x89, 0x8a}, SKINCOLOR_RUST, 3, V_SKYMAP, false}, // SKINCOLOR_SUPERSKY4 + {"Super Sky 5", {0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87, 0x88, 0x89, 0x8a, 0x8b}, SKINCOLOR_RUST, 3, V_SKYMAP, false}, // SKINCOLOR_SUPERSKY5 + + {"Super Purple 1", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90, 0xa0, 0xa0, 0xa1, 0xa2}, SKINCOLOR_EMERALD, 15, 0, false}, // SKINCOLOR_SUPERPURPLE1 + {"Super Purple 2", {0x00, 0x90, 0xa0, 0xa0, 0xa1, 0xa1, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5}, SKINCOLOR_EMERALD, 4, V_PURPLEMAP, false}, // SKINCOLOR_SUPERPURPLE2 + {"Super Purple 3", {0xa0, 0xa0, 0xa1, 0xa1, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa6, 0xa6}, SKINCOLOR_EMERALD, 0, V_PURPLEMAP, false}, // SKINCOLOR_SUPERPURPLE3 + {"Super Purple 4", {0xa1, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa6, 0xa6, 0xa7, 0xa8, 0xa9}, SKINCOLOR_EMERALD, 0, V_PURPLEMAP, false}, // SKINCOLOR_SUPERPURPLE4 + {"Super Purple 5", {0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa6, 0xa6, 0xa7, 0xa8, 0xa9, 0xfd}, SKINCOLOR_EMERALD, 0, V_PURPLEMAP, false}, // SKINCOLOR_SUPERPURPLE5 + + {"Super Rust 1", {0x00, 0xd0, 0xd0, 0xd0, 0x30, 0x30, 0x31, 0x32, 0x33, 0x37, 0x3a, 0x44, 0x45, 0x46, 0x47, 0x2e}, SKINCOLOR_CYAN, 14, V_ORANGEMAP, false}, // SKINCOLOR_SUPERRUST1 + {"Super Rust 2", {0x30, 0x31, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x38, 0x3a, 0x44, 0x45, 0x46, 0x47, 0x47, 0x2e}, SKINCOLOR_CYAN, 10, V_ORANGEMAP, false}, // SKINCOLOR_SUPERRUST2 + {"Super Rust 3", {0x31, 0x32, 0x33, 0x34, 0x36, 0x37, 0x38, 0x3a, 0x44, 0x45, 0x45, 0x46, 0x46, 0x47, 0x2e, 0x2e}, SKINCOLOR_CYAN, 9, V_ORANGEMAP, false}, // SKINCOLOR_SUPERRUST3 + {"Super Rust 4", {0x48, 0x40, 0x41, 0x42, 0x43, 0x44, 0x44, 0x45, 0x45, 0x46, 0x46, 0x47, 0x47, 0x2e, 0x2e, 0x2e}, SKINCOLOR_CYAN, 8, V_ORANGEMAP, false}, // SKINCOLOR_SUPERRUST4 + {"Super Rust 5", {0x41, 0x42, 0x43, 0x43, 0x44, 0x44, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xed, 0xee, 0xee, 0xef, 0xef}, SKINCOLOR_CYAN, 8, V_ORANGEMAP, false}, // SKINCOLOR_SUPERRUST5 + + {"Super Tan 1", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50, 0x51, 0x51, 0x52, 0x52}, SKINCOLOR_BROWN, 14, 0, false}, // SKINCOLOR_SUPERTAN1 + {"Super Tan 2", {0x00, 0x50, 0x50, 0x51, 0x51, 0x52, 0x52, 0x52, 0x54, 0x54, 0x54, 0x54, 0x55, 0x56, 0x57, 0xf5}, SKINCOLOR_BROWN, 13, V_BROWNMAP, false}, // SKINCOLOR_SUPERTAN2 + {"Super Tan 3", {0x50, 0x51, 0x51, 0x52, 0x52, 0x52, 0x54, 0x54, 0x54, 0x54, 0x55, 0x56, 0x57, 0xf5, 0xf7, 0xf9}, SKINCOLOR_BROWN, 12, V_BROWNMAP, false}, // SKINCOLOR_SUPERTAN3 + {"Super Tan 4", {0x51, 0x52, 0x52, 0x52, 0x52, 0x54, 0x54, 0x54, 0x55, 0x56, 0x57, 0xf5, 0xf7, 0xf9, 0xfb, 0xed}, SKINCOLOR_BROWN, 11, V_BROWNMAP, false}, // SKINCOLOR_SUPERTAN4 + {"Super Tan 5", {0x52, 0x52, 0x54, 0x54, 0x54, 0x55, 0x56, 0x57, 0xf5, 0xf7, 0xf9, 0xfb, 0xed, 0xee, 0xef, 0xef}, SKINCOLOR_BROWN, 10, V_BROWNMAP, false} // SKINCOLOR_SUPERTAN5 +}; + +/** Patches the mobjinfo, state, and skincolor tables. * Free slots are emptied out and set to initial values. */ void P_PatchInfoTables(void) @@ -21635,6 +21768,12 @@ void P_PatchInfoTables(void) sprnames[i][0] = '\0'; // i == NUMSPRITES memset(&states[S_FIRSTFREESLOT], 0, sizeof (state_t) * NUMSTATEFREESLOTS); memset(&mobjinfo[MT_FIRSTFREESLOT], 0, sizeof (mobjinfo_t) * NUMMOBJFREESLOTS); + memset(&skincolors[SKINCOLOR_FIRSTFREESLOT], 0, sizeof (skincolor_t) * NUMCOLORFREESLOTS); + for (i = SKINCOLOR_FIRSTFREESLOT; i <= SKINCOLOR_LASTFREESLOT; i++) { + skincolors[i].accessible = false; + skincolors[i].name[0] = '\0'; + } + numskincolors = SKINCOLOR_FIRSTFREESLOT; for (i = MT_FIRSTFREESLOT; i <= MT_LASTFREESLOT; i++) mobjinfo[i].doomednum = -1; } @@ -21643,7 +21782,8 @@ void P_PatchInfoTables(void) static char *sprnamesbackup; static state_t *statesbackup; static mobjinfo_t *mobjinfobackup; -static size_t sprnamesbackupsize, statesbackupsize, mobjinfobackupsize; +static skincolor_t *skincolorsbackup; +static size_t sprnamesbackupsize, statesbackupsize, mobjinfobackupsize, skincolorsbackupsize; #endif void P_BackupTables(void) @@ -21653,6 +21793,7 @@ void P_BackupTables(void) sprnamesbackup = Z_Malloc(sizeof(sprnames), PU_STATIC, NULL); statesbackup = Z_Malloc(sizeof(states), PU_STATIC, NULL); mobjinfobackup = Z_Malloc(sizeof(mobjinfo), PU_STATIC, NULL); + skincolorsbackup = Z_Malloc(sizeof(skincolors), PU_STATIC, NULL); // Sprite names sprnamesbackupsize = lzf_compress(sprnames, sizeof(sprnames), sprnamesbackup, sizeof(sprnames)); @@ -21674,6 +21815,13 @@ void P_BackupTables(void) mobjinfobackup = Z_Realloc(mobjinfobackup, mobjinfobackupsize, PU_STATIC, NULL); else M_Memcpy(mobjinfobackup, mobjinfo, sizeof(mobjinfo)); + + //Skincolor info + skincolorsbackupsize = lzf_compress(skincolors, sizeof(skincolors), skincolorsbackup, sizeof(skincolors)); + if (skincolorsbackupsize > 0) + skincolorsbackup = Z_Realloc(skincolorsbackup, skincolorsbackupsize, PU_STATIC, NULL); + else + M_Memcpy(skincolorsbackup, skincolors, sizeof(skincolors)); #endif } @@ -21706,5 +21854,13 @@ void P_ResetData(INT32 flags) else M_Memcpy(mobjinfo, mobjinfobackup, sizeof(mobjinfobackup)); } + + if (flags & 8) + { + if (skincolorsbackupsize > 0) + lzf_decompress(skincolorsbackup, skincolorsbackupsize, skincolors, sizeof(skincolors)); + else + M_Memcpy(skincolors, skincolorsbackup, sizeof(skincolorsbackup)); + } #endif } diff --git a/src/lua_baselib.c b/src/lua_baselib.c index b16ac6a60..a68ab5619 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -30,6 +30,7 @@ #include "hu_stuff.h" // HU_AddChatText #include "console.h" #include "d_netcmd.h" // IsPlayerAdmin +#include "m_menu.h" // Player Setup menu color stuff #include "lua_script.h" #include "lua_libs.h" @@ -147,6 +148,8 @@ static const struct { {META_STATE, "state_t"}, {META_MOBJINFO, "mobjinfo_t"}, {META_SFXINFO, "sfxinfo_t"}, + {META_SKINCOLOR, "sfxinfo_t"}, + {META_COLORRAMP, "skincolor_t.ramp"}, {META_SPRITEINFO, "spriteinfo_t"}, {META_PIVOTLIST, "spriteframepivot_t[]"}, {META_FRAMEPIVOT, "spriteframepivot_t"}, @@ -249,6 +252,43 @@ static int lib_reserveLuabanks(lua_State *L) return 1; } +// M_MENU +////////////// + +static int lib_pMoveColorBefore(lua_State *L) +{ + UINT16 color = (UINT16)luaL_checkinteger(L, 1); + UINT16 targ = (UINT16)luaL_checkinteger(L, 2); + + NOHUD + M_MoveColorBefore(color, targ); + return 0; +} + +static int lib_pMoveColorAfter(lua_State *L) +{ + UINT16 color = (UINT16)luaL_checkinteger(L, 1); + UINT16 targ = (UINT16)luaL_checkinteger(L, 2); + + NOHUD + M_MoveColorAfter(color, targ); + return 0; +} + +static int lib_pGetColorBefore(lua_State *L) +{ + UINT16 color = (UINT16)luaL_checkinteger(L, 1); + lua_pushinteger(L, M_GetColorBefore(color)); + return 1; +} + +static int lib_pGetColorAfter(lua_State *L) +{ + UINT16 color = (UINT16)luaL_checkinteger(L, 1); + lua_pushinteger(L, M_GetColorAfter(color)); + return 1; +} + // M_RANDOM ////////////// @@ -2324,17 +2364,6 @@ static int lib_rGetColorByName(lua_State *L) return 1; } -// Lua exclusive function, returns the name of a color from the SKINCOLOR_ constant. -// SKINCOLOR_GREEN > "Green" for example -static int lib_rGetNameByColor(lua_State *L) -{ - UINT8 colornum = (UINT8)luaL_checkinteger(L, 1); - if (!colornum || colornum >= MAXSKINCOLORS) - return luaL_error(L, "skincolor %d out of range (1 - %d).", colornum, MAXSKINCOLORS-1); - lua_pushstring(L, Color_Names[colornum]); - return 1; -} - // S_SOUND //////////// static int lib_sStartSound(lua_State *L) @@ -3002,6 +3031,12 @@ static luaL_Reg lib[] = { {"IsPlayerAdmin", lib_isPlayerAdmin}, {"reserveLuabanks", lib_reserveLuabanks}, + // m_menu + {"M_MoveColorAfter",lib_pMoveColorAfter}, + {"M_MoveColorBefore",lib_pMoveColorBefore}, + {"M_GetColorAfter",lib_pGetColorAfter}, + {"M_GetColorBefore",lib_pGetColorBefore}, + // m_random {"P_RandomFixed",lib_pRandomFixed}, {"P_RandomByte",lib_pRandomByte}, @@ -3176,7 +3211,6 @@ static luaL_Reg lib[] = { // r_draw {"R_GetColorByName", lib_rGetColorByName}, - {"R_GetNameByColor", lib_rGetNameByColor}, // s_sound {"S_StartSound",lib_sStartSound}, diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index bf8fe017b..8fa1be8f4 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -967,7 +967,7 @@ static int libd_nameTagWidth(lua_State *L) static int libd_getColormap(lua_State *L) { INT32 skinnum = TC_DEFAULT; - skincolors_t color = luaL_optinteger(L, 2, 0); + skincolornum_t color = luaL_optinteger(L, 2, 0); UINT8* colormap = NULL; HUDONLY if (lua_isnoneornil(L, 1)) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 7a2465ef7..fdd4aba77 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -26,6 +26,9 @@ #include "lua_libs.h" #include "lua_hud.h" // hud_running errors +extern CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; +extern void R_FlushTranslationColormapCache(void); + boolean LUA_CallAction(const char *action, mobj_t *actor); state_t *astate; @@ -1469,6 +1472,230 @@ static int lib_luabankslen(lua_State *L) return 1; } +//////////////////// +// SKINCOLOR INFO // +//////////////////// + +// Arbitrary skincolors[] table index -> skincolor_t * +static int lib_getSkinColor(lua_State *L) +{ + UINT32 i; + lua_remove(L, 1); + + i = luaL_checkinteger(L, 1); + if (!i || i >= numskincolors) + return luaL_error(L, "skincolors[] index %d out of range (1 - %d)", i, numskincolors-1); + LUA_PushUserdata(L, &skincolors[i], META_SKINCOLOR); + return 1; +} + +//Set the entire c->ramp array +static void setRamp(lua_State *L, skincolor_t* c) { + UINT32 i; + lua_pushnil(L); + for (i=0; iramp[i] = lua_isnumber(L,-1) ? (UINT8)luaL_checkinteger(L,-1) : 120; + lua_pop(L, 1); + } else + c->ramp[i] = 120; + } + lua_pop(L,1); +} + +// Lua table full of data -> skincolors[] +static int lib_setSkinColor(lua_State *L) +{ + UINT32 j; + skincolor_t *info; + UINT8 cnum; //skincolor num + lua_remove(L, 1); // don't care about skincolors[] userdata. + { + cnum = (UINT8)luaL_checkinteger(L, 1); + if (!cnum || cnum >= numskincolors) + return luaL_error(L, "skincolors[] index %d out of range (1 - %d)", cnum, numskincolors-1); + info = &skincolors[cnum]; // get the skincolor to assign to. + } + luaL_checktype(L, 2, LUA_TTABLE); // check that we've been passed a table. + lua_remove(L, 1); // pop skincolor num, don't need it any more. + lua_settop(L, 1); // cut the stack here. the only thing left now is the table of data we're assigning to the skincolor. + + if (hud_running) + return luaL_error(L, "Do not alter skincolors in HUD rendering code!"); + + // clear the skincolor to start with, in case of missing table elements + memset(info,0,sizeof(skincolor_t)); + + Color_cons_t[cnum].value = cnum; + lua_pushnil(L); + while (lua_next(L, 1)) { + lua_Integer i = 0; + const char *str = NULL; + if (lua_isnumber(L, 2)) + i = lua_tointeger(L, 2); + else + str = luaL_checkstring(L, 2); + + if (i == 1 || (str && fastcmp(str,"name"))) { + const char* n = luaL_checkstring(L, 3); + strlcpy(info->name, n, MAXCOLORNAME+1); + if (strlen(n) > MAXCOLORNAME) + CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') longer than %d chars; shortened to %s.\n", n, MAXCOLORNAME, info->name); + } else if (i == 2 || (str && fastcmp(str,"ramp"))) { + if (!lua_istable(L, 3) && luaL_checkudata(L, 3, META_COLORRAMP) == NULL) + return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' must be a table or array."); + else if (lua_istable(L, 3)) + setRamp(L, info); + else + for (j=0; jramp[j] = (*((UINT8 **)luaL_checkudata(L, 3, META_COLORRAMP)))[j]; + R_FlushTranslationColormapCache(); + } else if (i == 3 || (str && fastcmp(str,"invcolor"))) + info->invcolor = (UINT8)luaL_checkinteger(L, 3); + else if (i == 4 || (str && fastcmp(str,"invshade"))) + info->invshade = (UINT8)luaL_checkinteger(L, 3); + else if (i == 5 || (str && fastcmp(str,"chatcolor"))) + info->chatcolor = (UINT16)luaL_checkinteger(L, 3); + else if (i == 6 || (str && fastcmp(str,"accessible"))) { + boolean v = lua_isboolean(L,3) ? lua_toboolean(L, 3) : true; + if (cnum < FIRSTSUPERCOLOR && v != skincolors[cnum].accessible) + return luaL_error(L, "skincolors[] index %d is a standard color; accessibility changes are prohibited.", i); + else + info->accessible = v; + } + lua_pop(L, 1); + } + return 0; +} + +// #skincolors -> numskincolors +static int lib_skincolorslen(lua_State *L) +{ + lua_pushinteger(L, numskincolors); + return 1; +} + +// skincolor_t *, field -> number +static int skincolor_get(lua_State *L) +{ + skincolor_t *info = *((skincolor_t **)luaL_checkudata(L, 1, META_SKINCOLOR)); + const char *field = luaL_checkstring(L, 2); + + I_Assert(info != NULL); + I_Assert(info >= skincolors); + + if (fastcmp(field,"name")) + lua_pushstring(L, info->name); + else if (fastcmp(field,"ramp")) + LUA_PushUserdata(L, info->ramp, META_COLORRAMP); + else if (fastcmp(field,"invcolor")) + lua_pushinteger(L, info->invcolor); + else if (fastcmp(field,"invshade")) + lua_pushinteger(L, info->invshade); + else if (fastcmp(field,"chatcolor")) + lua_pushinteger(L, info->chatcolor); + else if (fastcmp(field,"accessible")) + lua_pushboolean(L, info->accessible); + else + CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "skincolor_t", field); + return 1; +} + +// skincolor_t *, field, number -> skincolors[] +static int skincolor_set(lua_State *L) +{ + UINT32 i; + skincolor_t *info = *((skincolor_t **)luaL_checkudata(L, 1, META_SKINCOLOR)); + const char *field = luaL_checkstring(L, 2); + + I_Assert(info != NULL); + I_Assert(info >= skincolors); + + if (info-skincolors >= numskincolors) + return luaL_error(L, "skincolors[] index %d does not exist", info-skincolors); + + if (fastcmp(field,"name")) { + const char* n = luaL_checkstring(L, 3); + if (strchr(n, ' ') != NULL) + CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", n); + strlcpy(info->name, n, MAXCOLORNAME+1); + if (strlen(n) > MAXCOLORNAME) + CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') longer than %d chars; clipped to %s.\n", n, MAXCOLORNAME, info->name); + } else if (fastcmp(field,"ramp")) { + if (!lua_istable(L, 3) && luaL_checkudata(L, 3, META_COLORRAMP) == NULL) + return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' must be a table or array."); + else if (lua_istable(L, 3)) + setRamp(L, info); + else + for (i=0; iramp[i] = (*((UINT8 **)luaL_checkudata(L, 3, META_COLORRAMP)))[i]; + R_FlushTranslationColormapCache(); + } else if (fastcmp(field,"invcolor")) + info->invcolor = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"invshade")) + info->invshade = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"chatcolor")) + info->chatcolor = (UINT16)luaL_checkinteger(L, 3); + else if (fastcmp(field,"accessible")) { + boolean v = lua_isboolean(L,3) ? lua_toboolean(L, 3) : true; + if (info-skincolors < FIRSTSUPERCOLOR && v != info->accessible) + return luaL_error(L, "skincolors[] index %d is a standard color; accessibility changes are prohibited.", info-skincolors); + else + info->accessible = v; + } else + CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "skincolor_t", field); + return 1; +} + +// skincolor_t * -> SKINCOLOR_* +static int skincolor_num(lua_State *L) +{ + skincolor_t *info = *((skincolor_t **)luaL_checkudata(L, 1, META_SKINCOLOR)); + + I_Assert(info != NULL); + I_Assert(info >= skincolors); + + lua_pushinteger(L, info-skincolors); + return 1; +} + +// ramp, n -> ramp[n] +static int colorramp_get(lua_State *L) +{ + UINT8 *colorramp = *((UINT8 **)luaL_checkudata(L, 1, META_COLORRAMP)); + UINT32 n = luaL_checkinteger(L, 2); + if (n >= COLORRAMPSIZE) + return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' index %d out of range (0 - %d)", n, COLORRAMPSIZE-1); + lua_pushinteger(L, colorramp[n]); + return 1; +} + +// ramp, n, value -> ramp[n] = value +static int colorramp_set(lua_State *L) +{ + UINT8 *colorramp = *((UINT8 **)luaL_checkudata(L, 1, META_COLORRAMP)); + UINT32 n = luaL_checkinteger(L, 2); + UINT8 i = (UINT8)luaL_checkinteger(L, 3); + if (n >= COLORRAMPSIZE) + return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' index %d out of range (0 - %d)", n, COLORRAMPSIZE-1); + if (hud_running) + return luaL_error(L, "Do not alter skincolor_t in HUD rendering code!"); + colorramp[n] = i; + R_FlushTranslationColormapCache(); + return 0; +} + +// #ramp -> COLORRAMPSIZE +static int colorramp_len(lua_State *L) +{ + lua_pushinteger(L, COLORRAMPSIZE); + return 1; +} + ////////////////////////////// // // Now push all these functions into the Lua state! @@ -1506,6 +1733,28 @@ int LUA_InfoLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); + luaL_newmetatable(L, META_SKINCOLOR); + lua_pushcfunction(L, skincolor_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, skincolor_set); + lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, skincolor_num); + lua_setfield(L, -2, "__len"); + lua_pop(L, 1); + + luaL_newmetatable(L, META_COLORRAMP); + lua_pushcfunction(L, colorramp_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, colorramp_set); + lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, colorramp_len); + lua_setfield(L, -2, "__len"); + lua_pop(L,1); + luaL_newmetatable(L, META_SFXINFO); lua_pushcfunction(L, sfxinfo_get); lua_setfield(L, -2, "__index"); @@ -1609,6 +1858,19 @@ int LUA_InfoLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "mobjinfo"); + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, lib_getSkinColor); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_setSkinColor); + lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, lib_skincolorslen); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, "skincolors"); + lua_newuserdata(L, 0); lua_createtable(L, 0, 2); lua_pushcfunction(L, lib_getSfxInfo); diff --git a/src/lua_libs.h b/src/lua_libs.h index 6a908d03d..1e04c98d3 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -22,6 +22,8 @@ extern lua_State *gL; #define META_STATE "STATE_T*" #define META_MOBJINFO "MOBJINFO_T*" #define META_SFXINFO "SFXINFO_T*" +#define META_SKINCOLOR "SKINCOLOR_T*" +#define META_COLORRAMP "SKINCOLOT_T*RAMP" #define META_SPRITEINFO "SPRITEINFO_T*" #define META_PIVOTLIST "SPRITEFRAMEPIVOT_T[]" #define META_FRAMEPIVOT "SPRITEFRAMEPIVOT_T*" diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index 9115c7321..0624d3fae 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -173,15 +173,14 @@ static int lib_all7emeralds(lua_State *L) return 1; } -// Whee, special Lua-exclusive function for making use of Color_Opposite[] // Returns both color and signpost shade numbers! static int lib_coloropposite(lua_State *L) { UINT8 colornum = (UINT8)luaL_checkinteger(L, 1); - if (!colornum || colornum >= MAXSKINCOLORS) - return luaL_error(L, "skincolor %d out of range (1 - %d).", colornum, MAXSKINCOLORS-1); - lua_pushinteger(L, Color_Opposite[colornum-1][0]); // push color - lua_pushinteger(L, Color_Opposite[colornum-1][1]); // push sign shade index, 0-15 + if (!colornum || colornum >= numskincolors) + return luaL_error(L, "skincolor %d out of range (1 - %d).", colornum, numskincolors-1); + lua_pushinteger(L, skincolors[colornum].invcolor); // push color + lua_pushinteger(L, skincolors[colornum].invshade); // push sign shade index, 0-15 return 2; } diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 90733b2c6..5e574f977 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -582,8 +582,8 @@ static int mobj_set(lua_State *L) case mobj_color: { UINT8 newcolor = (UINT8)luaL_checkinteger(L,3); - if (newcolor >= MAXTRANSLATIONS) - return luaL_error(L, "mobj.color %d out of range (0 - %d).", newcolor, MAXTRANSLATIONS-1); + if (newcolor >= numskincolors) + return luaL_error(L, "mobj.color %d out of range (0 - %d).", newcolor, numskincolors-1); mo->color = newcolor; break; } diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index d1da97d70..5e7b194b0 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -459,8 +459,8 @@ static int player_set(lua_State *L) else if (fastcmp(field,"skincolor")) { UINT8 newcolor = (UINT8)luaL_checkinteger(L,3); - if (newcolor >= MAXSKINCOLORS) - return luaL_error(L, "player.skincolor %d out of range (0 - %d).", newcolor, MAXSKINCOLORS-1); + if (newcolor >= numskincolors) + return luaL_error(L, "player.skincolor %d out of range (0 - %d).", newcolor, numskincolors-1); plr->skincolor = newcolor; } else if (fastcmp(field,"score")) diff --git a/src/lua_script.c b/src/lua_script.c index eb6c54ae0..c8409058a 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -736,6 +736,7 @@ enum ARCH_SLOPE, #endif ARCH_MAPHEADER, + ARCH_SKINCOLOR, ARCH_TEND=0xFF, }; @@ -763,6 +764,7 @@ static const struct { {META_SLOPE, ARCH_SLOPE}, #endif {META_MAPHEADER, ARCH_MAPHEADER}, + {META_SKINCOLOR, ARCH_SKINCOLOR}, {NULL, ARCH_NULL} }; @@ -1040,6 +1042,14 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) } break; } + + case ARCH_SKINCOLOR: + { + skincolor_t *info = *((skincolor_t **)lua_touserdata(gL, myindex)); + WRITEUINT8(save_p, ARCH_SKINCOLOR); + WRITEUINT16(save_p, info - skincolors); + break; + } default: WRITEUINT8(save_p, ARCH_NULL); return 2; @@ -1258,6 +1268,9 @@ static UINT8 UnArchiveValue(int TABLESINDEX) case ARCH_MAPHEADER: LUA_PushUserdata(gL, mapheaderinfo[READUINT16(save_p)], META_MAPHEADER); break; + case ARCH_SKINCOLOR: + LUA_PushUserdata(gL, &skincolors[READUINT16(save_p)], META_SKINCOLOR); + break; case ARCH_TEND: return 1; } diff --git a/src/m_cond.c b/src/m_cond.c index 08f3fe038..0e150f01b 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -523,9 +523,9 @@ emblem_t *M_GetLevelEmblems(INT32 mapnum) return NULL; } -skincolors_t M_GetEmblemColor(emblem_t *em) +skincolornum_t M_GetEmblemColor(emblem_t *em) { - if (!em || em->color >= MAXSKINCOLORS) + if (!em || em->color >= numskincolors) return SKINCOLOR_NONE; return em->color; } @@ -549,9 +549,9 @@ const char *M_GetEmblemPatch(emblem_t *em, boolean big) return pnamebuf; } -skincolors_t M_GetExtraEmblemColor(extraemblem_t *em) +skincolornum_t M_GetExtraEmblemColor(extraemblem_t *em) { - if (!em || em->color >= MAXSKINCOLORS) + if (!em || em->color >= numskincolors) return SKINCOLOR_NONE; return em->color; } diff --git a/src/m_cond.h b/src/m_cond.h index 7fe3105fb..21f88cb88 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -172,9 +172,9 @@ INT32 M_CountEmblems(void); // Emblem shit emblem_t *M_GetLevelEmblems(INT32 mapnum); -skincolors_t M_GetEmblemColor(emblem_t *em); +skincolornum_t M_GetEmblemColor(emblem_t *em); const char *M_GetEmblemPatch(emblem_t *em, boolean big); -skincolors_t M_GetExtraEmblemColor(extraemblem_t *em); +skincolornum_t M_GetExtraEmblemColor(extraemblem_t *em); const char *M_GetExtraEmblemPatch(extraemblem_t *em, boolean big); // If you're looking to compare stats for unlocks or what not, use these diff --git a/src/m_menu.c b/src/m_menu.c index 8b564e068..9b946adc2 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3860,6 +3860,8 @@ void M_Init(void) #ifndef NONET CV_RegisterVar(&cv_serversort); #endif + + M_InitPlayerSetupColors(); } void M_InitCharacterTables(void) @@ -7489,7 +7491,7 @@ static void M_DrawSoundTest(void) { frame[1] = (2-st_time); frame[2] = ((cv_soundtest.value - 1) % 9); - frame[3] += (((cv_soundtest.value - 1) / 9) % (MAXSKINCOLORS - frame[3])); + frame[3] += (((cv_soundtest.value - 1) / 9) % (FIRSTSUPERCOLOR - frame[3])); if (st_time < 2) st_time++; } @@ -8149,13 +8151,13 @@ static void M_DrawLoadGameData(void) { if (charskin->prefoppositecolor) { - col = charskin->prefoppositecolor - 1; - col = Color_Index[col][Color_Opposite[Color_Opposite[col][0] - 1][1]]; + col = charskin->prefoppositecolor; + col = skincolors[col].ramp[skincolors[skincolors[col].invcolor].invshade]; } else { - col = charskin->prefcolor - 1; - col = Color_Index[Color_Opposite[col][0]-1][Color_Opposite[col][1]]; + col = charskin->prefcolor; + col = skincolors[skincolors[col].invcolor].ramp[skincolors[col].invshade]; } } @@ -8996,7 +8998,7 @@ static void M_DrawSetupChoosePlayerMenu(void) // Use the opposite of the character's skincolor col = description[char_on].oppositecolor; if (!col) - col = Color_Opposite[charskin->prefcolor - 1][0]; + col = skincolors[charskin->prefcolor].invcolor; // Make the translation colormap colormap = R_GetTranslationColormap(TC_DEFAULT, col, 0); @@ -9059,7 +9061,7 @@ static void M_DrawSetupChoosePlayerMenu(void) if (!curtextcolor) curtextcolor = charskin->prefcolor; if (!curoutlinecolor) - curoutlinecolor = Color_Opposite[charskin->prefcolor - 1][0]; + curoutlinecolor = col = skincolors[charskin->prefcolor].invcolor; txsh = oxsh; ox = 8 + SHORT((description[char_on].charpic)->width)/2; @@ -9098,7 +9100,7 @@ static void M_DrawSetupChoosePlayerMenu(void) if (!prevtextcolor) prevtextcolor = charskin->prefcolor; if (!prevoutlinecolor) - prevoutlinecolor = Color_Opposite[charskin->prefcolor - 1][0]; + prevoutlinecolor = col = skincolors[charskin->prefcolor].invcolor; x = (ox - txsh) - w; if (prevpatch) @@ -9128,7 +9130,7 @@ static void M_DrawSetupChoosePlayerMenu(void) if (!nexttextcolor) nexttextcolor = charskin->prefcolor; if (!nextoutlinecolor) - nextoutlinecolor = Color_Opposite[charskin->prefcolor - 1][0]; + nextoutlinecolor = col = skincolors[charskin->prefcolor].invcolor; x = (ox - txsh) + w; if (nextpatch) @@ -10979,15 +10981,15 @@ static UINT8 multi_spr2; // this is set before entering the MultiPlayer setup menu, // for either player 1 or 2 -static char setupm_name[MAXPLAYERNAME+1]; -static player_t *setupm_player; -static consvar_t *setupm_cvskin; -static consvar_t *setupm_cvcolor; -static consvar_t *setupm_cvname; -static consvar_t *setupm_cvdefaultskin; -static consvar_t *setupm_cvdefaultcolor; -static INT32 setupm_fakeskin; -static INT32 setupm_fakecolor; +static char setupm_name[MAXPLAYERNAME+1]; +static player_t *setupm_player; +static consvar_t *setupm_cvskin; +static consvar_t *setupm_cvcolor; +static consvar_t *setupm_cvname; +static consvar_t *setupm_cvdefaultskin; +static consvar_t *setupm_cvdefaultcolor; +static INT32 setupm_fakeskin; +static menucolor_t *setupm_fakecolor; static void M_DrawSetupMultiPlayerMenu(void) { @@ -11054,11 +11056,11 @@ static void M_DrawSetupMultiPlayerMenu(void) sprdef = &skins[setupm_fakeskin].sprites[multi_spr2]; - if (!setupm_fakecolor || !sprdef->numframes) // should never happen but hey, who knows + if (!setupm_fakecolor->color || !sprdef->numframes) // should never happen but hey, who knows goto faildraw; // ok, draw player sprite for sure now - colormap = R_GetTranslationColormap(setupm_fakeskin, setupm_fakecolor, 0); + colormap = R_GetTranslationColormap(setupm_fakeskin, setupm_fakecolor->color, 0); if (multi_frame >= sprdef->numframes) multi_frame = 0; @@ -11104,11 +11106,11 @@ colordraw: // draw color string V_DrawRightAlignedString(BASEVIDWIDTH - x, y, ((MP_PlayerSetupMenu[2].status & IT_TYPE) == IT_SPACE ? V_TRANSLUCENT : 0)|(itemOn == 2 ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE, - Color_Names[setupm_fakecolor]); + skincolors[setupm_fakecolor->color].name); if (itemOn == 2 && (MP_PlayerSetupMenu[2].status & IT_TYPE) != IT_SPACE) { - V_DrawCharacter(BASEVIDWIDTH - x - 10 - V_StringWidth(Color_Names[setupm_fakecolor], V_ALLOWLOWERCASE) - (skullAnimCounter/5), y, + V_DrawCharacter(BASEVIDWIDTH - x - 10 - V_StringWidth(skincolors[setupm_fakecolor->color].name, V_ALLOWLOWERCASE) - (skullAnimCounter/5), y, '\x1C' | V_YELLOWMAP, false); V_DrawCharacter(BASEVIDWIDTH - x + 2 + (skullAnimCounter/5), y, '\x1D' | V_YELLOWMAP, false); @@ -11118,25 +11120,39 @@ colordraw: #define indexwidth 8 { - const INT32 colwidth = (282-charw)/(2*indexwidth); - INT32 i = -colwidth; - INT16 col = setupm_fakecolor - colwidth; - INT32 w = indexwidth; + const INT32 numcolors = (282-charw)/(2*indexwidth); // Number of colors per side + INT32 w = indexwidth; // Width of a singular color block + menucolor_t *mc = setupm_fakecolor->prev; // Last accessed color UINT8 h; + INT16 i; - while (col < 1) - col += MAXSKINCOLORS-1; - while (i <= colwidth) - { - if (!(i++)) - w = charw; - else - w = indexwidth; + // Draw color in the middle + x += numcolors*w; + for (h = 0; h < 16; h++) + V_DrawFill(x, y+h, charw, 1, skincolors[setupm_fakecolor->color].ramp[h]); + + //Draw colors from middle to left + for (i=0; icolor].accessible) + mc = mc->prev; for (h = 0; h < 16; h++) - V_DrawFill(x, y+h, w, 1, Color_Index[col-1][h]); - if (++col >= MAXSKINCOLORS) - col -= MAXSKINCOLORS-1; + V_DrawFill(x, y+h, w, 1, skincolors[mc->color].ramp[h]); + mc = mc->prev; + } + + // Draw colors from middle to right + mc = setupm_fakecolor->next; + x += numcolors*w + charw; + for (i=0; icolor].accessible) + mc = mc->next; + for (h = 0; h < 16; h++) + V_DrawFill(x, y+h, w, 1, skincolors[mc->color].ramp[h]); x += w; + mc = mc->next; } } #undef charw @@ -11147,7 +11163,7 @@ colordraw: V_DrawString(x, y, ((R_SkinAvailable(setupm_cvdefaultskin->string) != setupm_fakeskin - || setupm_cvdefaultcolor->value != setupm_fakecolor) + || setupm_cvdefaultcolor->value != setupm_fakecolor->color) ? 0 : V_TRANSLUCENT) | ((itemOn == 3) ? V_YELLOWMAP : 0), @@ -11195,19 +11211,19 @@ static void M_HandleSetupMultiPlayer(INT32 choice) else if (itemOn == 2) // player color { S_StartSound(NULL,sfx_menu1); // Tails - setupm_fakecolor--; + setupm_fakecolor = setupm_fakecolor->prev; } break; case KEY_ENTER: if (itemOn == 3 && (R_SkinAvailable(setupm_cvdefaultskin->string) != setupm_fakeskin - || setupm_cvdefaultcolor->value != setupm_fakecolor)) + || setupm_cvdefaultcolor->value != setupm_fakecolor->color)) { S_StartSound(NULL,sfx_strpst); // you know what? always putting these in the buffer won't hurt anything. COM_BufAddText (va("%s \"%s\"\n",setupm_cvdefaultskin->name,skins[setupm_fakeskin].name)); - COM_BufAddText (va("%s %d\n",setupm_cvdefaultcolor->name,setupm_fakecolor)); + COM_BufAddText (va("%s %d\n",setupm_cvdefaultcolor->name,setupm_fakecolor->color)); break; } /* FALLTHRU */ @@ -11228,7 +11244,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) else if (itemOn == 2) // player color { S_StartSound(NULL,sfx_menu1); // Tails - setupm_fakecolor++; + setupm_fakecolor = setupm_fakecolor->next; } break; @@ -11245,10 +11261,12 @@ static void M_HandleSetupMultiPlayer(INT32 choice) else if (itemOn == 2) { UINT8 col = skins[setupm_fakeskin].prefcolor; - if (setupm_fakecolor != col) + if ((setupm_fakecolor->color != col) && skincolors[col].accessible) { S_StartSound(NULL,sfx_menu1); // Tails - setupm_fakecolor = col; + for (setupm_fakecolor=menucolorhead;;setupm_fakecolor=setupm_fakecolor->next) + if (setupm_fakecolor->color == col || setupm_fakecolor == menucolortail) + break; } } break; @@ -11276,10 +11294,14 @@ static void M_HandleSetupMultiPlayer(INT32 choice) } // check color - if (setupm_fakecolor < 1) - setupm_fakecolor = MAXSKINCOLORS-1; - if (setupm_fakecolor > MAXSKINCOLORS-1) - setupm_fakecolor = 1; + if (itemOn == 2 && !skincolors[setupm_fakecolor->color].accessible) { + if (choice == KEY_LEFTARROW) + while (!skincolors[setupm_fakecolor->color].accessible) + setupm_fakecolor = setupm_fakecolor->prev; + else if (choice == KEY_RIGHTARROW || choice == KEY_ENTER) + while (!skincolors[setupm_fakecolor->color].accessible) + setupm_fakecolor = setupm_fakecolor->next; + } if (exitmenu) { @@ -11311,7 +11333,10 @@ static void M_SetupMultiPlayer(INT32 choice) setupm_fakeskin = R_SkinAvailable(setupm_cvskin->string); if (setupm_fakeskin == -1) setupm_fakeskin = 0; - setupm_fakecolor = setupm_cvcolor->value; + + for (setupm_fakecolor=menucolorhead;;setupm_fakecolor=setupm_fakecolor->next) + if (setupm_fakecolor->color == setupm_cvcolor->value || setupm_fakecolor == menucolortail) + break; // disable skin changes if we can't actually change skins if (!CanChangeSkin(consoleplayer)) @@ -11352,7 +11377,10 @@ static void M_SetupMultiPlayer2(INT32 choice) setupm_fakeskin = R_SkinAvailable(setupm_cvskin->string); if (setupm_fakeskin == -1) setupm_fakeskin = 0; - setupm_fakecolor = setupm_cvcolor->value; + + for (setupm_fakecolor=menucolorhead;;setupm_fakecolor=setupm_fakecolor->next) + if (setupm_fakecolor->color == setupm_cvcolor->value || setupm_fakecolor == menucolortail) + break; // disable skin changes if we can't actually change skins if (splitscreen && !CanChangeSkin(secondarydisplayplayer)) @@ -11384,12 +11412,180 @@ static boolean M_QuitMultiPlayerMenu(void) setupm_name[l] =0; COM_BufAddText (va("%s \"%s\"\n",setupm_cvname->name,setupm_name)); } - // you know what? always putting these in the buffer won't hurt anything. COM_BufAddText (va("%s \"%s\"\n",setupm_cvskin->name,skins[setupm_fakeskin].name)); - COM_BufAddText (va("%s %d\n",setupm_cvcolor->name,setupm_fakecolor)); + // send color if changed + if (setupm_fakecolor->color != setupm_cvcolor->value) + COM_BufAddText (va("%s %d\n",setupm_cvcolor->name,setupm_fakecolor->color)); return true; } +void M_AddMenuColor(UINT8 color) { + menucolor_t *c; + + if (color >= numskincolors) { + CONS_Printf("M_AddMenuColor: color %d does not exist.",color); + return; + } + + c = (menucolor_t *)Z_Malloc(sizeof(menucolor_t), PU_STATIC, NULL); + c->color = color; + if (menucolorhead == NULL) { + c->next = c; + c->prev = c; + menucolorhead = c; + menucolortail = c; + } else { + c->next = menucolorhead; + c->prev = menucolortail; + menucolortail->next = c; + menucolorhead->prev = c; + menucolortail = c; + } +} + +void M_MoveColorBefore(UINT8 color, UINT8 targ) { + menucolor_t *look, *c = NULL, *t = NULL; + + if (color == targ) + return; + if (color >= numskincolors) { + CONS_Printf("M_MoveColorBefore: color %d does not exist.",color); + return; + } + if (targ >= numskincolors) { + CONS_Printf("M_MoveColorBefore: target color %d does not exist.",targ); + return; + } + + for (look=menucolorhead;;look=look->next) { + if (look->color == color) + c = look; + else if (look->color == targ) + t = look; + if (c != NULL && t != NULL) + break; + if (look==menucolortail) + return; + } + + if (c == t->prev) + return; + + if (t==menucolorhead) + menucolorhead = c; + if (c==menucolortail) + menucolortail = c->prev; + + c->prev->next = c->next; + c->next->prev = c->prev; + + c->prev = t->prev; + c->next = t; + t->prev->next = c; + t->prev = c; +} + +void M_MoveColorAfter(UINT8 color, UINT8 targ) { + menucolor_t *look, *c = NULL, *t = NULL; + + if (color == targ) + return; + if (color >= numskincolors) { + CONS_Printf("M_MoveColorAfter: color %d does not exist.\n",color); + return; + } + if (targ >= numskincolors) { + CONS_Printf("M_MoveColorAfter: target color %d does not exist.\n",targ); + return; + } + + for (look=menucolorhead;;look=look->next) { + if (look->color == color) + c = look; + else if (look->color == targ) + t = look; + if (c != NULL && t != NULL) + break; + if (look==menucolortail) + return; + } + + if (t == c->prev) + return; + + if (t==menucolortail) + menucolortail = c; + else if (c==menucolortail) + menucolortail = c->prev; + + c->prev->next = c->next; + c->next->prev = c->prev; + + c->next = t->next; + c->prev = t; + t->next->prev = c; + t->next = c; +} + +UINT8 M_GetColorBefore(UINT8 color) { + menucolor_t *look; + + if (color >= numskincolors) { + CONS_Printf("M_GetColorBefore: color %d does not exist.\n",color); + return 0; + } + + for (look=menucolorhead;;look=look->next) { + if (look->color == color) + return look->prev->color; + if (look==menucolortail) + return 0; + } +} + +UINT8 M_GetColorAfter(UINT8 color) { + menucolor_t *look; + + if (color >= numskincolors) { + CONS_Printf("M_GetColorAfter: color %d does not exist.\n",color); + return 0; + } + + for (look=menucolorhead;;look=look->next) { + if (look->color == color) + return look->next->color; + if (look==menucolortail) + return 0; + } +} + +void M_InitPlayerSetupColors(void) { + UINT8 i; + menucolorhead = menucolortail = NULL; + for (i=0; inext; + Z_Free(tmp); + } else { + Z_Free(look); + return; + } + } + + menucolorhead = menucolortail = NULL; +} + // ================= // DATA OPTIONS MENU // ================= diff --git a/src/m_menu.h b/src/m_menu.h index 862303426..a780df0c5 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -436,6 +436,23 @@ void Addons_option_Onchange(void); // Moviemode menu updating void Moviemode_option_Onchange(void); +// Player Setup menu colors linked list +typedef struct menucolor_s { + struct menucolor_s *next; + struct menucolor_s *prev; + UINT8 color; +} menucolor_t; + +menucolor_t *menucolorhead, *menucolortail; + +void M_AddMenuColor(UINT8 color); +void M_MoveColorBefore(UINT8 color, UINT8 targ); +void M_MoveColorAfter(UINT8 color, UINT8 targ); +UINT8 M_GetColorBefore(UINT8 color); +UINT8 M_GetColorAfter(UINT8 color); +void M_InitPlayerSetupColors(void); +void M_FreePlayerSetupColors(void); + // These defines make it a little easier to make menus #define DEFAULTMENUSTYLE(id, header, source, prev, x, y)\ {\ diff --git a/src/p_enemy.c b/src/p_enemy.c index 2ddbd8d29..f22920dc6 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -5154,7 +5154,7 @@ void A_SignPlayer(mobj_t *actor) return; #endif - if (actor->tracer == NULL || locvar1 < -3 || locvar1 >= numskins || signcolor >= MAXTRANSLATIONS) + if (actor->tracer == NULL || locvar1 < -3 || locvar1 >= numskins || signcolor >= numskincolors) return; // if no face overlay, spawn one @@ -5185,7 +5185,7 @@ void A_SignPlayer(mobj_t *actor) else if ((actor->target->player->skincolor == skin->prefcolor) && (skin->prefoppositecolor)) // Set it as the skin's preferred oppositecolor? signcolor = skin->prefoppositecolor; else if (actor->target->player->skincolor) // Set the sign to be an appropriate background color for this player's skincolor. - signcolor = Color_Opposite[actor->target->player->skincolor - 1][0]; + signcolor = skincolors[actor->target->player->skincolor].invcolor; else signcolor = SKINCOLOR_NONE; } @@ -5223,7 +5223,7 @@ void A_SignPlayer(mobj_t *actor) else if (skin->prefoppositecolor) signcolor = skin->prefoppositecolor; else if (facecolor) - signcolor = Color_Opposite[facecolor - 1][0]; + signcolor = skincolors[facecolor].invcolor; } if (skin) @@ -5265,8 +5265,8 @@ void A_SignPlayer(mobj_t *actor) of in the name. If you have a better idea, feel free to let me know. ~toast 2016/07/20 */ - if (signcolor && signcolor < MAXSKINCOLORS) - signframe += (15 - Color_Opposite[Color_Opposite[signcolor - 1][0] - 1][1]); + if (signcolor && signcolor < numskincolors) + signframe += (15 - skincolors[skincolors[signcolor].invcolor].invshade); actor->tracer->frame = signframe; } diff --git a/src/p_mobj.c b/src/p_mobj.c index f3f0b9ab0..6d295b52b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -440,7 +440,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) mobj->sprite2 = spr2; mobj->frame = frame|(st->frame&~FF_FRAMEMASK); - if (mobj->color >= MAXSKINCOLORS && mobj->color < MAXTRANSLATIONS) // Super colours? Super bright! + if (mobj->color >= FIRSTSUPERCOLOR && mobj->color < numskincolors) // Super colours? Super bright! mobj->frame |= FF_FULLBRIGHT; } // Regular sprites @@ -10792,7 +10792,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) break; case MT_EGGROBO1: mobj->movecount = P_RandomKey(13); - mobj->color = SKINCOLOR_RUBY + P_RandomKey(MAXSKINCOLORS - SKINCOLOR_RUBY); + mobj->color = SKINCOLOR_RUBY + P_RandomKey(numskincolors - SKINCOLOR_RUBY); break; case MT_HIVEELEMENTAL: mobj->extravalue1 = 5; @@ -12109,7 +12109,7 @@ static boolean P_SetupEmblem(mapthing_t *mthing, mobj_t *mobj) { INT32 j; emblem_t* emblem = M_GetLevelEmblems(gamemap); - skincolors_t emcolor; + skincolornum_t emcolor; while (emblem) { @@ -12773,7 +12773,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean break; case MT_BALLOON: if (mthing->angle > 0) - mobj->color = ((mthing->angle - 1) % (MAXSKINCOLORS - 1)) + 1; + mobj->color = ((mthing->angle - 1) % (numskincolors - 1)) + 1; break; #define makesoftwarecorona(mo, h) \ corona = P_SpawnMobjFromMobj(mo, 0, 0, h<powers[pw_super]) - player->mo->color = (UINT8)(SKINCOLOR_RUBY + (leveltime % (MAXSKINCOLORS - SKINCOLOR_RUBY))); // Passes through all saturated colours + player->mo->color = (UINT8)(SKINCOLOR_RUBY + (leveltime % (numskincolors - SKINCOLOR_RUBY))); // Passes through all saturated colours else if (leveltime % (TICRATE/7) == 0) { mobj_t *sparkle = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_IVSP); diff --git a/src/r_draw.c b/src/r_draw.c index 918c5f206..9aa414150 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -137,318 +137,6 @@ UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask; static UINT8** translationtablecache[MAXSKINS + 7] = {NULL}; -const UINT8 Color_Index[MAXTRANSLATIONS-1][16] = { - // {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // SKINCOLOR_NONE - - // Greyscale ranges - {0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x11}, // SKINCOLOR_WHITE - {0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x11, 0x12}, // SKINCOLOR_BONE - {0x02, 0x03, 0x04, 0x05, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14}, // SKINCOLOR_CLOUDY - {0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18}, // SKINCOLOR_GREY - {0x02, 0x03, 0x05, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11, 0x13, 0x15, 0x17, 0x19, 0x1b, 0x1d, 0x1f}, // SKINCOLOR_SILVER - {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x16, 0x17, 0x17, 0x19, 0x19, 0x1a, 0x1a, 0x1b, 0x1c, 0x1d}, // SKINCOLOR_CARBON - {0x00, 0x05, 0x0a, 0x0f, 0x14, 0x19, 0x1a, 0x1b, 0x1c, 0x1e, 0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x1f}, // SKINCOLOR_JET - {0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1b, 0x1b, 0x1c, 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f}, // SKINCOLOR_BLACK - - // Desaturated - {0x00, 0x00, 0x01, 0x02, 0x02, 0x03, 0x91, 0x91, 0x91, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xaf}, // SKINCOLOR_AETHER - {0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0xaa, 0xaa, 0xaa, 0xab, 0xac, 0xac, 0xad, 0xad, 0xae, 0xaf}, // SKINCOLOR_SLATE - {0x90, 0x91, 0x92, 0x93, 0x94, 0x94, 0x95, 0xac, 0xac, 0xad, 0xad, 0xa8, 0xa8, 0xa9, 0xfd, 0xfe}, // SKINCOLOR_BLUEBELL - {0xd0, 0xd0, 0xd1, 0xd1, 0xd2, 0xd2, 0xd3, 0xd3, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0x2b, 0x2c, 0x2e}, // SKINCOLOR_PINK - {0xd0, 0x30, 0xd8, 0xd9, 0xda, 0xdb, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe3, 0xe6, 0xe8, 0xe9}, // SKINCOLOR_YOGURT - {0xdf, 0xe0, 0xe1, 0xe2, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef}, // SKINCOLOR_BROWN - {0xde, 0xe0, 0xe1, 0xe4, 0xe7, 0xe9, 0xeb, 0xec, 0xed, 0xed, 0xed, 0x19, 0x19, 0x1b, 0x1d, 0x1e}, // SKINCOLOR_BRONZE - {0x51, 0x51, 0x54, 0x54, 0x55, 0x55, 0x56, 0x56, 0x56, 0x57, 0xf5, 0xf5, 0xf9, 0xf9, 0xed, 0xed}, // SKINCOLOR_TAN - {0x54, 0x55, 0x56, 0x56, 0xf2, 0xf3, 0xf3, 0xf4, 0xf5, 0xf6, 0xf8, 0xf9, 0xfa, 0xfb, 0xed, 0xed}, // SKINCOLOR_BEIGE - {0x58, 0x58, 0x59, 0x59, 0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5d, 0x5d, 0x5e, 0x5e, 0x5f, 0x5f}, // SKINCOLOR_MOSS - {0x90, 0x90, 0x91, 0x91, 0xaa, 0xaa, 0xab, 0xab, 0xab, 0xac, 0xad, 0xad, 0xae, 0xae, 0xaf, 0xaf}, // SKINCOLOR_AZURE - {0xc0, 0xc0, 0xc1, 0xc1, 0xc2, 0xc2, 0xc3, 0xc3, 0xc3, 0xc4, 0xc5, 0xc5, 0xc6, 0xc6, 0xc7, 0xc7}, // SKINCOLOR_LAVENDER - - // Viv's vivid colours (toast 21/07/17) - {0xb0, 0xb0, 0xc9, 0xca, 0xcc, 0x26, 0x27, 0x28, 0x29, 0x2a, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfd}, // SKINCOLOR_RUBY - {0xd0, 0xd0, 0xd1, 0xd2, 0x20, 0x21, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e}, // SKINCOLOR_SALMON - {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x47, 0x2e, 0x2f}, // SKINCOLOR_RED - {0x27, 0x27, 0x28, 0x28, 0x29, 0x2a, 0x2b, 0x2b, 0x2c, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f, 0x1f}, // SKINCOLOR_CRIMSON - {0x31, 0x32, 0x33, 0x36, 0x22, 0x22, 0x25, 0x25, 0x25, 0xcd, 0xcf, 0xcf, 0xc5, 0xc5, 0xc7, 0xc7}, // SKINCOLOR_FLAME - {0x48, 0x49, 0x40, 0x33, 0x34, 0x36, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2b, 0x2c, 0x47, 0x2e, 0x2f}, // SKINCOLOR_KETCHUP - {0xd0, 0x30, 0x31, 0x31, 0x32, 0x32, 0xdc, 0xdc, 0xdc, 0xd3, 0xd4, 0xd4, 0xcc, 0xcd, 0xce, 0xcf}, // SKINCOLOR_PEACHY - {0xd8, 0xd9, 0xdb, 0xdc, 0xde, 0xdf, 0xd5, 0xd5, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0x1d, 0x1f}, // SKINCOLOR_QUAIL - {0x51, 0x52, 0x40, 0x40, 0x34, 0x36, 0xd5, 0xd5, 0xd6, 0xd7, 0xcf, 0xcf, 0xc6, 0xc6, 0xc7, 0xfe}, // SKINCOLOR_SUNSET - {0x58, 0x54, 0x40, 0x34, 0x35, 0x38, 0x3a, 0x3c, 0x3d, 0x2a, 0x2b, 0x2c, 0x2c, 0xba, 0xba, 0xbb}, // SKINCOLOR_COPPER - {0x00, 0xd8, 0xd9, 0xda, 0xdb, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e}, // SKINCOLOR_APRICOT - {0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x2c}, // SKINCOLOR_ORANGE - {0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3f, 0x2c, 0x2d, 0x47, 0x2e, 0x2f, 0x2f}, // SKINCOLOR_RUST - {0x51, 0x51, 0x54, 0x54, 0x41, 0x42, 0x43, 0x43, 0x44, 0x45, 0x46, 0x3f, 0x2d, 0x2e, 0x2f, 0x2f}, // SKINCOLOR_GOLD - {0x53, 0x40, 0x41, 0x42, 0x43, 0xe6, 0xe9, 0xe9, 0xea, 0xec, 0xec, 0xc6, 0xc6, 0xc7, 0xc7, 0xfe}, // SKINCOLOR_SANDY - {0x52, 0x53, 0x49, 0x49, 0x4a, 0x4a, 0x4b, 0x4b, 0x4b, 0x4c, 0x4d, 0x4d, 0x4e, 0x4e, 0x4f, 0xed}, // SKINCOLOR_YELLOW - {0x4b, 0x4b, 0x4c, 0x4c, 0x4d, 0x4e, 0xe7, 0xe7, 0xe9, 0xc5, 0xc5, 0xc6, 0xc6, 0xc7, 0xc7, 0xfd}, // SKINCOLOR_OLIVE - {0x50, 0x51, 0x52, 0x53, 0x48, 0xbc, 0xbd, 0xbe, 0xbe, 0xbf, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f}, // SKINCOLOR_LIME - {0x58, 0x58, 0xbc, 0xbc, 0xbd, 0xbd, 0xbe, 0xbe, 0xbe, 0xbf, 0x5e, 0x5e, 0x5f, 0x5f, 0x77, 0x77}, // SKINCOLOR_PERIDOT - {0x49, 0x49, 0xbc, 0xbd, 0xbe, 0xbe, 0xbe, 0x67, 0x69, 0x6a, 0x6b, 0x6b, 0x6c, 0x6d, 0x6d, 0x6d}, // SKINCOLOR_APPLE - {0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f}, // SKINCOLOR_GREEN - {0x65, 0x66, 0x67, 0x68, 0x69, 0x69, 0x6a, 0x6b, 0x6b, 0x6c, 0x6d, 0x6d, 0x6e, 0x6e, 0x6e, 0x6f}, // SKINCOLOR_FOREST - {0x70, 0x70, 0x71, 0x71, 0x72, 0x72, 0x73, 0x73, 0x73, 0x74, 0x75, 0x75, 0x76, 0x76, 0x77, 0x77}, // SKINCOLOR_EMERALD - {0x00, 0x00, 0x58, 0x58, 0x59, 0x62, 0x62, 0x62, 0x64, 0x67, 0x7e, 0x7e, 0x8f, 0x8f, 0x8a, 0x8a}, // SKINCOLOR_MINT - {0x01, 0x58, 0x59, 0x5a, 0x7d, 0x7d, 0x7e, 0x7e, 0x7e, 0x8f, 0x8f, 0x8a, 0x8a, 0x8a, 0xfd, 0xfd}, // SKINCOLOR_SEAFOAM - {0x78, 0x79, 0x7a, 0x7a, 0x7b, 0x7b, 0x7c, 0x7c, 0x7c, 0x7d, 0x7e, 0x7e, 0x7f, 0x7f, 0x76, 0x77}, // SKINCOLOR_AQUA - {0x78, 0x78, 0x8c, 0x8c, 0x8d, 0x8d, 0x8d, 0x8e, 0x8e, 0x8f, 0x8f, 0x8f, 0x8a, 0x8a, 0x8a, 0x8a}, // SKINCOLOR_TEAL - {0x00, 0x78, 0x78, 0x79, 0x8d, 0x87, 0x88, 0x89, 0x89, 0xae, 0xa8, 0xa8, 0xa9, 0xa9, 0xfd, 0xfd}, // SKINCOLOR_WAVE - {0x80, 0x81, 0xff, 0xff, 0x83, 0x83, 0x8d, 0x8d, 0x8d, 0x8e, 0x7e, 0x7f, 0x76, 0x76, 0x77, 0x6e}, // SKINCOLOR_CYAN - {0x80, 0x80, 0x81, 0x82, 0x83, 0x83, 0x84, 0x85, 0x85, 0x86, 0x87, 0x88, 0x89, 0x89, 0x8a, 0x8b}, // SKINCOLOR_SKY - {0x85, 0x86, 0x87, 0x88, 0x88, 0x89, 0x89, 0x89, 0x8a, 0x8a, 0xfd, 0xfd, 0xfd, 0x1f, 0x1f, 0x1f}, // SKINCOLOR_CERULEAN - {0x00, 0x00, 0x00, 0x00, 0x80, 0x81, 0x83, 0x83, 0x86, 0x87, 0x95, 0x95, 0xad, 0xad, 0xae, 0xaf}, // SKINCOLOR_ICY - {0x80, 0x83, 0x86, 0x87, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xfd, 0xfe}, // SKINCOLOR_SAPPHIRE - {0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x9a, 0x9c, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e}, // SKINCOLOR_CORNFLOWER - {0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xfd, 0xfe}, // SKINCOLOR_BLUE - {0x93, 0x94, 0x95, 0x96, 0x98, 0x9a, 0x9b, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xfd, 0xfd, 0xfe, 0xfe}, // SKINCOLOR_COBALT - {0x80, 0x81, 0x83, 0x86, 0x94, 0x94, 0xa3, 0xa3, 0xa4, 0xa6, 0xa6, 0xa6, 0xa8, 0xa8, 0xa9, 0xa9}, // SKINCOLOR_VAPOR - {0x92, 0x93, 0x94, 0x94, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xaf, 0xaf, 0xa9, 0xa9, 0xfd, 0xfd}, // SKINCOLOR_DUSK - {0x90, 0x90, 0xa0, 0xa0, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2, 0xa3, 0xa4, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8}, // SKINCOLOR_PASTEL - {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa5, 0xa6, 0xa7, 0xa7, 0xa8, 0xa8, 0xa9, 0xa9}, // SKINCOLOR_PURPLE - {0x00, 0xd0, 0xd0, 0xc8, 0xc8, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8}, // SKINCOLOR_BUBBLEGUM - {0xb3, 0xb3, 0xb4, 0xb5, 0xb6, 0xb6, 0xb7, 0xb7, 0xb7, 0xb8, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xbb}, // SKINCOLOR_MAGENTA - {0xb3, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xbb, 0xc7, 0xc7, 0x1d, 0x1d, 0x1e}, // SKINCOLOR_NEON - {0xd0, 0xd1, 0xd2, 0xca, 0xcc, 0xb8, 0xb9, 0xb9, 0xba, 0xa8, 0xa8, 0xa9, 0xa9, 0xfd, 0xfe, 0xfe}, // SKINCOLOR_VIOLET - {0x00, 0xd0, 0xd1, 0xd2, 0xd3, 0xc1, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc5, 0xc6, 0xc6, 0xfe, 0x1f}, // SKINCOLOR_LILAC - {0xc8, 0xd3, 0xd5, 0xd6, 0xd7, 0xce, 0xcf, 0xb9, 0xb9, 0xba, 0xba, 0xa9, 0xa9, 0xa9, 0xfd, 0xfe}, // SKINCOLOR_PLUM - {0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xcd, 0xce, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfe, 0xfe}, // SKINCOLOR_RASPBERRY - {0xfc, 0xc8, 0xc8, 0xc9, 0xc9, 0xca, 0xca, 0xcb, 0xcb, 0xcc, 0xcc, 0xcd, 0xcd, 0xce, 0xce, 0xcf}, // SKINCOLOR_ROSY - - // {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // SKINCOLOR_? - - // super - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03}, // SKINCOLOR_SUPERSILVER1 - {0x00, 0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07}, // SKINCOLOR_SUPERSILVER2 - {0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x09, 0x0b}, // SKINCOLOR_SUPERSILVER3 - {0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11}, // SKINCOLOR_SUPERSILVER4 - {0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11, 0x13}, // SKINCOLOR_SUPERSILVER5 - - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0xd0, 0xd1, 0xd1, 0xd2, 0xd2}, // SKINCOLOR_SUPERRED1 - {0x00, 0x00, 0x00, 0xd0, 0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2, 0x20, 0x20, 0x21, 0x21}, // SKINCOLOR_SUPERRED2 - {0x00, 0x00, 0xd0, 0xd0, 0xd1, 0xd1, 0xd2, 0xd2, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23}, // SKINCOLOR_SUPERRED3 - {0x00, 0xd0, 0xd1, 0xd1, 0xd2, 0xd2, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x24, 0x24}, // SKINCOLOR_SUPERRED4 - {0xd0, 0xd1, 0xd2, 0xd2, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x24, 0x24, 0x25, 0x25}, // SKINCOLOR_SUPERRED5 - - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x30, 0x31, 0x32, 0x33, 0x34}, // SKINCOLOR_SUPERORANGE1 - {0x00, 0x00, 0x00, 0x00, 0xd0, 0xd0, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x34, 0x34}, // SKINCOLOR_SUPERORANGE2 - {0x00, 0x00, 0xd0, 0xd0, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x34, 0x34, 0x35, 0x35}, // SKINCOLOR_SUPERORANGE3 - {0x00, 0xd0, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x44, 0x45, 0x46}, // SKINCOLOR_SUPERORANGE4 - {0xd0, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x44, 0x45, 0x46, 0x47}, // SKINCOLOR_SUPERORANGE5 - - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50, 0x51, 0x52, 0x53, 0x48}, // SKINCOLOR_SUPERGOLD1 - {0x00, 0x50, 0x51, 0x52, 0x53, 0x53, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x40, 0x41}, // SKINCOLOR_SUPERGOLD2 - {0x51, 0x52, 0x53, 0x53, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x40, 0x41, 0x42, 0x43}, // SKINCOLOR_SUPERGOLD3 - {0x53, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46}, // SKINCOLOR_SUPERGOLD4 - {0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47}, // SKINCOLOR_SUPERGOLD5 - - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x58, 0x58, 0xbc, 0xbc, 0xbc}, // SKINCOLOR_SUPERPERIDOT1 - {0x00, 0x58, 0x58, 0x58, 0xbc, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe}, // SKINCOLOR_SUPERPERIDOT2 - {0x58, 0x58, 0xbc, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf}, // SKINCOLOR_SUPERPERIDOT3 - {0x58, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf, 0x5e, 0x5e, 0x5f}, // SKINCOLOR_SUPERPERIDOT4 - {0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf, 0x5e, 0x5e, 0x5f, 0x77}, // SKINCOLOR_SUPERPERIDOT5 - - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x81, 0x82, 0x83, 0x84}, // SKINCOLOR_SUPERSKY1 - {0x00, 0x80, 0x81, 0x82, 0x83, 0x83, 0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86}, // SKINCOLOR_SUPERSKY2 - {0x81, 0x82, 0x83, 0x83, 0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87}, // SKINCOLOR_SUPERSKY3 - {0x83, 0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87, 0x88, 0x89, 0x8a}, // SKINCOLOR_SUPERSKY4 - {0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87, 0x88, 0x89, 0x8a, 0x8b}, // SKINCOLOR_SUPERSKY5 - - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90, 0xa0, 0xa0, 0xa1, 0xa2}, // SKINCOLOR_SUPERPURPLE1 - {0x00, 0x90, 0xa0, 0xa0, 0xa1, 0xa1, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5}, // SKINCOLOR_SUPERPURPLE2 - {0xa0, 0xa0, 0xa1, 0xa1, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa6, 0xa6}, // SKINCOLOR_SUPERPURPLE3 - {0xa1, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa6, 0xa6, 0xa7, 0xa8, 0xa9}, // SKINCOLOR_SUPERPURPLE4 - {0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa6, 0xa6, 0xa7, 0xa8, 0xa9, 0xfd}, // SKINCOLOR_SUPERPURPLE5 - - {0x00, 0xd0, 0xd0, 0xd0, 0x30, 0x30, 0x31, 0x32, 0x33, 0x37, 0x3a, 0x44, 0x45, 0x46, 0x47, 0x2e}, // SKINCOLOR_SUPERRUST1 - {0x30, 0x31, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x38, 0x3a, 0x44, 0x45, 0x46, 0x47, 0x47, 0x2e}, // SKINCOLOR_SUPERRUST2 - {0x31, 0x32, 0x33, 0x34, 0x36, 0x37, 0x38, 0x3a, 0x44, 0x45, 0x45, 0x46, 0x46, 0x47, 0x2e, 0x2e}, // SKINCOLOR_SUPERRUST3 - {0x48, 0x40, 0x41, 0x42, 0x43, 0x44, 0x44, 0x45, 0x45, 0x46, 0x46, 0x47, 0x47, 0x2e, 0x2e, 0x2e}, // SKINCOLOR_SUPERRUST4 - {0x41, 0x42, 0x43, 0x43, 0x44, 0x44, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xed, 0xee, 0xee, 0xef, 0xef}, // SKINCOLOR_SUPERRUST5 - - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50, 0x51, 0x51, 0x52, 0x52}, // SKINCOLOR_SUPERTAN1 - {0x00, 0x50, 0x50, 0x51, 0x51, 0x52, 0x52, 0x52, 0x54, 0x54, 0x54, 0x54, 0x55, 0x56, 0x57, 0xf5}, // SKINCOLOR_SUPERTAN2 - {0x50, 0x51, 0x51, 0x52, 0x52, 0x52, 0x54, 0x54, 0x54, 0x54, 0x55, 0x56, 0x57, 0xf5, 0xf7, 0xf9}, // SKINCOLOR_SUPERTAN3 - {0x51, 0x52, 0x52, 0x52, 0x52, 0x54, 0x54, 0x54, 0x55, 0x56, 0x57, 0xf5, 0xf7, 0xf9, 0xfb, 0xed}, // SKINCOLOR_SUPERTAN4 - {0x52, 0x52, 0x54, 0x54, 0x54, 0x55, 0x56, 0x57, 0xf5, 0xf7, 0xf9, 0xfb, 0xed, 0xee, 0xef, 0xef} // SKINCOLOR_SUPERTAN5 -}; - -// See also the enum skincolors_t -// TODO Callum: Can this be translated? -const char *Color_Names[MAXSKINCOLORS + NUMSUPERCOLORS] = -{ - "None", // SKINCOLOR_NONE, - - // Greyscale ranges - "White", // SKINCOLOR_WHITE, - "Bone", // SKINCOLOR_BONE, - "Cloudy", // SKINCOLOR_CLOUDY, - "Grey", // SKINCOLOR_GREY, - "Silver", // SKINCOLOR_SILVER, - "Carbon", // SKINCOLOR_CARBON, - "Jet", // SKINCOLOR_JET, - "Black", // SKINCOLOR_BLACK, - - // Desaturated - "Aether", // SKINCOLOR_AETHER, - "Slate", // SKINCOLOR_SLATE, - "Bluebell", // SKINCOLOR_BLUEBELL, - "Pink", // SKINCOLOR_PINK, - "Yogurt", // SKINCOLOR_YOGURT, - "Brown", // SKINCOLOR_BROWN, - "Bronze", // SKINCOLOR_BRONZE, - "Tan", // SKINCOLOR_TAN, - "Beige", // SKINCOLOR_BEIGE, - "Moss", // SKINCOLOR_MOSS, - "Azure", // SKINCOLOR_AZURE, - "Lavender", // SKINCOLOR_LAVENDER, - - // Viv's vivid colours (toast 21/07/17) - "Ruby", // SKINCOLOR_RUBY, - "Salmon", // SKINCOLOR_SALMON, - "Red", // SKINCOLOR_RED, - "Crimson", // SKINCOLOR_CRIMSON, - "Flame", // SKINCOLOR_FLAME, - "Ketchup", // SKINCOLOR_KETCHUP, - "Peachy", // SKINCOLOR_PEACHY, - "Quail", // SKINCOLOR_QUAIL, - "Sunset", // SKINCOLOR_SUNSET, - "Copper", // SKINCOLOR_COPPER, - "Apricot", // SKINCOLOR_APRICOT, - "Orange", // SKINCOLOR_ORANGE, - "Rust", // SKINCOLOR_RUST, - "Gold", // SKINCOLOR_GOLD, - "Sandy", // SKINCOLOR_SANDY, - "Yellow", // SKINCOLOR_YELLOW, - "Olive", // SKINCOLOR_OLIVE, - "Lime", // SKINCOLOR_LIME, - "Peridot", // SKINCOLOR_PERIDOT, - "Apple", // SKINCOLOR_APPLE, - "Green", // SKINCOLOR_GREEN, - "Forest", // SKINCOLOR_FOREST, - "Emerald", // SKINCOLOR_EMERALD, - "Mint", // SKINCOLOR_MINT, - "Seafoam", // SKINCOLOR_SEAFOAM, - "Aqua", // SKINCOLOR_AQUA, - "Teal", // SKINCOLOR_TEAL, - "Wave", // SKINCOLOR_WAVE, - "Cyan", // SKINCOLOR_CYAN, - "Sky", // SKINCOLOR_SKY, - "Cerulean", // SKINCOLOR_CERULEAN, - "Icy", // SKINCOLOR_ICY, - "Sapphire", // SKINCOLOR_SAPPHIRE, - "Cornflower", // SKINCOLOR_CORNFLOWER, - "Blue", // SKINCOLOR_BLUE, - "Cobalt", // SKINCOLOR_COBALT, - "Vapor", // SKINCOLOR_VAPOR, - "Dusk", // SKINCOLOR_DUSK, - "Pastel", // SKINCOLOR_PASTEL, - "Purple", // SKINCOLOR_PURPLE, - "Bubblegum", // SKINCOLOR_BUBBLEGUM, - "Magenta", // SKINCOLOR_MAGENTA, - "Neon", // SKINCOLOR_NEON, - "Violet", // SKINCOLOR_VIOLET, - "Lilac", // SKINCOLOR_LILAC, - "Plum", // SKINCOLOR_PLUM, - "Raspberry", // SKINCOLOR_RASPBERRY, - "Rosy", // SKINCOLOR_ROSY, - - // Super behaves by different rules (one name per 5 colours), and will be accessed exclusively via R_GetSuperColorByName instead of R_GetColorByName. - "Silver", // SKINCOLOR_SUPERSILVER1, - "Red", // SKINCOLOR_SUPERRED1, - "Orange", // SKINCOLOR_SUPERORANGE1, - "Gold", // SKINCOLOR_SUPERGOLD1, - "Peridot", // SKINCOLOR_SUPERPERIDOT1, - "Sky", // SKINCOLOR_SUPERSKY1, - "Purple", // SKINCOLOR_SUPERPURPLE1, - "Rust", // SKINCOLOR_SUPERRUST1, - "Tan" // SKINCOLOR_SUPERTAN1, -}; - -/* -A word of warning: If the following array is non-symmetrical, -A_SignPlayer's prefoppositecolor behaviour will break. -*/ -// [0] = opposite skin color, -// [1] = shade index used by signpost, 0-15 (actual sprite frame is 15 minus this value) -const UINT8 Color_Opposite[MAXSKINCOLORS - 1][2] = -{ - // {SKINCOLOR_NONE, 8}, // SKINCOLOR_NONE - - // Greyscale ranges - {SKINCOLOR_BLACK, 5}, // SKINCOLOR_WHITE, - {SKINCOLOR_JET, 7}, // SKINCOLOR_BONE, - {SKINCOLOR_CARBON, 7}, // SKINCOLOR_CLOUDY, - {SKINCOLOR_AETHER, 12}, // SKINCOLOR_GREY, - {SKINCOLOR_SLATE, 12}, // SKINCOLOR_SILVER, - {SKINCOLOR_CLOUDY, 7}, // SKINCOLOR_CARBON, - {SKINCOLOR_BONE, 7}, // SKINCOLOR_JET, - {SKINCOLOR_WHITE, 7}, // SKINCOLOR_BLACK, - - // Desaturated - {SKINCOLOR_GREY, 15}, // SKINCOLOR_AETHER, - {SKINCOLOR_SILVER, 12}, // SKINCOLOR_SLATE, - {SKINCOLOR_COPPER, 4}, // SKINCOLOR_BLUEBELL, - {SKINCOLOR_AZURE, 9}, // SKINCOLOR_PINK, - {SKINCOLOR_RUST, 7}, // SKINCOLOR_YOGURT, - {SKINCOLOR_TAN, 2}, // SKINCOLOR_BROWN, - {SKINCOLOR_KETCHUP, 0}, // SKINCOLOR_BRONZE, - {SKINCOLOR_BROWN, 12}, // SKINCOLOR_TAN, - {SKINCOLOR_MOSS, 5}, // SKINCOLOR_BEIGE, - {SKINCOLOR_BEIGE, 13}, // SKINCOLOR_MOSS, - {SKINCOLOR_PINK, 5}, // SKINCOLOR_AZURE, - {SKINCOLOR_GOLD, 4}, // SKINCOLOR_LAVENDER, - - // Viv's vivid colours (toast 21/07/17) - {SKINCOLOR_EMERALD, 10}, // SKINCOLOR_RUBY, - {SKINCOLOR_FOREST, 6}, // SKINCOLOR_SALMON, - {SKINCOLOR_GREEN, 10}, // SKINCOLOR_RED, - {SKINCOLOR_ICY, 10}, // SKINCOLOR_CRIMSON, - {SKINCOLOR_PURPLE, 8}, // SKINCOLOR_FLAME, - {SKINCOLOR_BRONZE, 8}, // SKINCOLOR_KETCHUP, - {SKINCOLOR_TEAL, 7}, // SKINCOLOR_PEACHY, - {SKINCOLOR_WAVE, 5}, // SKINCOLOR_QUAIL, - {SKINCOLOR_SAPPHIRE, 5}, // SKINCOLOR_SUNSET, - {SKINCOLOR_BLUEBELL, 5}, // SKINCOLOR_COPPER - {SKINCOLOR_CYAN, 4}, // SKINCOLOR_APRICOT, - {SKINCOLOR_BLUE, 4}, // SKINCOLOR_ORANGE, - {SKINCOLOR_YOGURT, 8}, // SKINCOLOR_RUST, - {SKINCOLOR_LAVENDER, 10}, // SKINCOLOR_GOLD, - {SKINCOLOR_SKY, 8}, // SKINCOLOR_SANDY, - {SKINCOLOR_CORNFLOWER, 8}, // SKINCOLOR_YELLOW, - {SKINCOLOR_DUSK, 3}, // SKINCOLOR_OLIVE, - {SKINCOLOR_MAGENTA, 9}, // SKINCOLOR_LIME, - {SKINCOLOR_COBALT, 2}, // SKINCOLOR_PERIDOT, - {SKINCOLOR_RASPBERRY, 13}, // SKINCOLOR_APPLE, - {SKINCOLOR_RED, 6}, // SKINCOLOR_GREEN, - {SKINCOLOR_SALMON, 9}, // SKINCOLOR_FOREST, - {SKINCOLOR_RUBY, 4}, // SKINCOLOR_EMERALD, - {SKINCOLOR_VIOLET, 5}, // SKINCOLOR_MINT, - {SKINCOLOR_PLUM, 6}, // SKINCOLOR_SEAFOAM, - {SKINCOLOR_ROSY, 7}, // SKINCOLOR_AQUA, - {SKINCOLOR_PEACHY, 7}, // SKINCOLOR_TEAL, - {SKINCOLOR_QUAIL, 5}, // SKINCOLOR_WAVE, - {SKINCOLOR_APRICOT, 6}, // SKINCOLOR_CYAN, - {SKINCOLOR_SANDY, 1}, // SKINCOLOR_SKY, - {SKINCOLOR_NEON, 4}, // SKINCOLOR_CERULEAN, - {SKINCOLOR_CRIMSON, 0}, // SKINCOLOR_ICY, - {SKINCOLOR_SUNSET, 5}, // SKINCOLOR_SAPPHIRE, - {SKINCOLOR_YELLOW, 4}, // SKINCOLOR_CORNFLOWER, - {SKINCOLOR_ORANGE, 5}, // SKINCOLOR_BLUE, - {SKINCOLOR_PERIDOT, 5}, // SKINCOLOR_COBALT, - {SKINCOLOR_LILAC, 4}, // SKINCOLOR_VAPOR, - {SKINCOLOR_OLIVE, 0}, // SKINCOLOR_DUSK, - {SKINCOLOR_BUBBLEGUM, 9}, // SKINCOLOR_PASTEL, - {SKINCOLOR_FLAME, 7}, // SKINCOLOR_PURPLE, - {SKINCOLOR_PASTEL, 8}, // SKINCOLOR_BUBBLEGUM, - {SKINCOLOR_LIME, 6}, // SKINCOLOR_MAGENTA, - {SKINCOLOR_CERULEAN, 2}, // SKINCOLOR_NEON, - {SKINCOLOR_MINT, 6}, // SKINCOLOR_VIOLET, - {SKINCOLOR_VAPOR, 4}, // SKINCOLOR_LILAC, - {SKINCOLOR_MINT, 7}, // SKINCOLOR_PLUM, - {SKINCOLOR_APPLE, 13}, // SKINCOLOR_RASPBERRY - {SKINCOLOR_AQUA, 1} // SKINCOLOR_ROSY, -}; - CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; /** \brief The R_InitTranslationTables @@ -511,7 +199,7 @@ static void R_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor) // first generate the brightness of all the colours of that skincolour for (i = 0; i < 16; i++) { - color = V_GetColor(Color_Index[skincolor-1][i]); + color = V_GetColor(skincolors[skincolor].ramp[i]); SETBRIGHTNESS(colorbrightnesses[i], color.s.red, color.s.green, color.s.blue); } @@ -532,7 +220,7 @@ static void R_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor) if (temp < brightdif) { brightdif = (UINT16)temp; - dest_colormap[i] = Color_Index[skincolor-1][j]; + dest_colormap[i] = skincolors[skincolor].ramp[j]; } } } @@ -553,7 +241,7 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U memset(dest_colormap, 0, NUM_PALETTE_ENTRIES * sizeof(UINT8)); return; case TC_RAINBOW: - if (color >= MAXTRANSLATIONS) + if (color >= numskincolors) I_Error("Invalid skin color #%hu.", (UINT16)color); if (color != SKINCOLOR_NONE) { @@ -562,11 +250,11 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U } break; case TC_BLINK: - if (color >= MAXTRANSLATIONS) + if (color >= numskincolors) I_Error("Invalid skin color #%hu.", (UINT16)color); if (color != SKINCOLOR_NONE) { - memset(dest_colormap, Color_Index[color-1][3], NUM_PALETTE_ENTRIES * sizeof(UINT8)); + memset(dest_colormap, skincolors[color].ramp[3], NUM_PALETTE_ENTRIES * sizeof(UINT8)); return; } break; @@ -587,11 +275,11 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U { for (i = 0; i < 6; i++) { - dest_colormap[Color_Index[SKINCOLOR_BLUE-1][12-i]] = Color_Index[SKINCOLOR_BLUE-1][i]; + dest_colormap[skincolors[SKINCOLOR_BLUE].ramp[12-i]] = skincolors[SKINCOLOR_BLUE].ramp[i]; } dest_colormap[159] = dest_colormap[253] = dest_colormap[254] = 0; for (i = 0; i < 16; i++) - dest_colormap[96+i] = dest_colormap[Color_Index[SKINCOLOR_COBALT-1][i]]; + dest_colormap[96+i] = dest_colormap[skincolors[SKINCOLOR_COBALT].ramp[i]]; } else if (skinnum == TC_DASHMODE) // This is a long one, because MotorRoach basically hand-picked the indices { @@ -636,7 +324,7 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U return; } - if (color >= MAXTRANSLATIONS) + if (color >= numskincolors) I_Error("Invalid skin color #%hu.", (UINT16)color); starttranscolor = (skinnum != TC_DEFAULT) ? skins[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR; @@ -660,7 +348,7 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U // Build the translated ramp for (i = 0; i < skinramplength; i++) - dest_colormap[starttranscolor + i] = (UINT8)Color_Index[color-1][i]; + dest_colormap[starttranscolor + i] = (UINT8)skincolors[color].ramp[i]; } @@ -672,7 +360,7 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U \return Colormap. If not cached, caller should Z_Free. */ -UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags) +UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags) { UINT8* ret; INT32 skintableindex; @@ -695,7 +383,7 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags) // Allocate table for skin if necessary if (!translationtablecache[skintableindex]) - translationtablecache[skintableindex] = Z_Calloc(MAXTRANSLATIONS * sizeof(UINT8**), PU_STATIC, NULL); + translationtablecache[skintableindex] = Z_Calloc(MAXSKINCOLORS * sizeof(UINT8**), PU_STATIC, NULL); // Get colormap ret = translationtablecache[skintableindex][color]; @@ -730,29 +418,32 @@ void R_FlushTranslationColormapCache(void) for (i = 0; i < (INT32)(sizeof(translationtablecache) / sizeof(translationtablecache[0])); i++) if (translationtablecache[i]) - memset(translationtablecache[i], 0, MAXTRANSLATIONS * sizeof(UINT8**)); + memset(translationtablecache[i], 0, MAXSKINCOLORS * sizeof(UINT8**)); } UINT8 R_GetColorByName(const char *name) { - UINT8 color = (UINT8)atoi(name); - if (color > 0 && color < MAXSKINCOLORS) + UINT16 color = (UINT8)atoi(name); + if (color > 0 && color < numskincolors) return color; - for (color = 1; color < MAXSKINCOLORS; color++) - if (!stricmp(Color_Names[color], name)) + for (color = 1; color < numskincolors; color++) + if (!stricmp(skincolors[color].name, name)) return color; return SKINCOLOR_GREEN; } UINT8 R_GetSuperColorByName(const char *name) { - UINT8 color; /* = (UINT8)atoi(name); -- This isn't relevant to S_SKIN, which is the only way it's accessible right now. Let's simplify things. - if (color > MAXSKINCOLORS && color < MAXTRANSLATIONS && !((color - MAXSKINCOLORS) % 5)) - return color;*/ - for (color = 0; color < NUMSUPERCOLORS; color++) - if (!stricmp(Color_Names[color + MAXSKINCOLORS], name)) - return ((color*5) + MAXSKINCOLORS); - return SKINCOLOR_SUPERGOLD1; + UINT16 i, color = SKINCOLOR_SUPERGOLD1; + char *realname = Z_Malloc(MAXCOLORNAME+1, PU_STATIC, NULL); + snprintf(realname, MAXCOLORNAME+1, "Super %s 1", name); + for (i = 1; i < numskincolors; i++) + if (!stricmp(skincolors[i].name, realname)) { + color = i; + break; + } + Z_Free(realname); + return color; } // ========================================================================== diff --git a/src/r_draw.h b/src/r_draw.h index da38c40e0..d6eef8fea 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -114,7 +114,7 @@ extern lumpnum_t viewborderlump[8]; // Initialize color translation tables, for player rendering etc. void R_InitTranslationTables(void); -UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags); +UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags); void R_FlushTranslationColormapCache(void); UINT8 R_GetColorByName(const char *name); UINT8 R_GetSuperColorByName(const char *name); diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 81420e757..e388aa573 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -178,6 +178,8 @@ static char returnWadPath[256]; #include "../m_argv.h" +#include "../m_menu.h" + #ifdef MAC_ALERT #include "macosx/mac_alert.h" #endif @@ -2293,6 +2295,7 @@ void I_Quit(void) G_StopMetalRecording(false); D_QuitNetGame(); + M_FreePlayerSetupColors(); I_ShutdownMusic(); I_ShutdownSound(); I_ShutdownCD(); @@ -2409,6 +2412,7 @@ void I_Error(const char *error, ...) G_StopMetalRecording(false); D_QuitNetGame(); + M_FreePlayerSetupColors(); I_ShutdownMusic(); I_ShutdownSound(); I_ShutdownCD(); diff --git a/src/st_stuff.c b/src/st_stuff.c index c1b1ff6e6..910f4c6b0 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -458,7 +458,7 @@ boolean st_overlay; // // Supports different colors! woo! static void ST_DrawNightsOverlayNum(fixed_t x /* right border */, fixed_t y, fixed_t s, INT32 a, - UINT32 num, patch_t **numpat, skincolors_t colornum) + UINT32 num, patch_t **numpat, skincolornum_t colornum) { fixed_t w = SHORT(numpat[0]->width)*s; const UINT8 *colormap; @@ -998,7 +998,7 @@ static void ST_drawLivesArea(void) static void ST_drawInput(void) { - const INT32 accent = V_SNAPTOLEFT|V_SNAPTOBOTTOM|(stplyr->skincolor ? Color_Index[stplyr->skincolor-1][4] : 0); + const INT32 accent = V_SNAPTOLEFT|V_SNAPTOBOTTOM|(stplyr->skincolor ? skincolors[stplyr->skincolor].ramp[4] : 0); INT32 col; UINT8 offs; @@ -1700,14 +1700,14 @@ static void ST_drawNightsRecords(void) // 2.0-1: [21:42] <+Rob> Beige - Lavender - Steel Blue - Peach - Orange - Purple - Silver - Yellow - Pink - Red - Blue - Green - Cyan - Gold /*#define NUMLINKCOLORS 14 -static skincolors_t linkColor[NUMLINKCOLORS] = +static skincolornum_t linkColor[NUMLINKCOLORS] = {SKINCOLOR_BEIGE, SKINCOLOR_LAVENDER, SKINCOLOR_AZURE, SKINCOLOR_PEACH, SKINCOLOR_ORANGE, SKINCOLOR_MAGENTA, SKINCOLOR_SILVER, SKINCOLOR_SUPERGOLD4, SKINCOLOR_PINK, SKINCOLOR_RED, SKINCOLOR_BLUE, SKINCOLOR_GREEN, SKINCOLOR_CYAN, SKINCOLOR_GOLD};*/ // 2.2 indev list: (unix time 1470866042) Emerald, Aqua, Cyan, Blue, Pastel, Purple, Magenta, Rosy, Red, Orange, Gold, Yellow, Peridot /*#define NUMLINKCOLORS 13 -static skincolors_t linkColor[NUMLINKCOLORS] = +static skincolornum_t linkColor[NUMLINKCOLORS] = {SKINCOLOR_EMERALD, SKINCOLOR_AQUA, SKINCOLOR_CYAN, SKINCOLOR_BLUE, SKINCOLOR_PASTEL, SKINCOLOR_PURPLE, SKINCOLOR_MAGENTA, SKINCOLOR_ROSY, SKINCOLOR_RED, SKINCOLOR_ORANGE, SKINCOLOR_GOLD, SKINCOLOR_YELLOW, SKINCOLOR_PERIDOT};*/ @@ -1716,7 +1716,7 @@ static skincolors_t linkColor[NUMLINKCOLORS] = // [20:00:25] Also Icy for the link freeze text color // [20:04:03] I would start it on lime /*#define NUMLINKCOLORS 18 -static skincolors_t linkColor[NUMLINKCOLORS] = +static skincolornum_t linkColor[NUMLINKCOLORS] = {SKINCOLOR_LIME, SKINCOLOR_EMERALD, SKINCOLOR_AQUA, SKINCOLOR_CYAN, SKINCOLOR_SKY, SKINCOLOR_SAPPHIRE, SKINCOLOR_PASTEL, SKINCOLOR_PURPLE, SKINCOLOR_BUBBLEGUM, SKINCOLOR_MAGENTA, SKINCOLOR_ROSY, SKINCOLOR_RUBY, SKINCOLOR_RED, SKINCOLOR_FLAME, SKINCOLOR_SUNSET, @@ -1724,7 +1724,7 @@ static skincolors_t linkColor[NUMLINKCOLORS] = // 2.2+ list for real this time: https://wiki.srb2.org/wiki/User:Rob/Sandbox (check history around 31/10/17, spoopy) #define NUMLINKCOLORS 12 -static skincolors_t linkColor[2][NUMLINKCOLORS] = { +static skincolornum_t linkColor[2][NUMLINKCOLORS] = { {SKINCOLOR_EMERALD, SKINCOLOR_AQUA, SKINCOLOR_SKY, SKINCOLOR_BLUE, SKINCOLOR_PURPLE, SKINCOLOR_MAGENTA, SKINCOLOR_ROSY, SKINCOLOR_RED, SKINCOLOR_ORANGE, SKINCOLOR_GOLD, SKINCOLOR_YELLOW, SKINCOLOR_PERIDOT}, {SKINCOLOR_SEAFOAM, SKINCOLOR_CYAN, SKINCOLOR_WAVE, SKINCOLOR_SAPPHIRE, SKINCOLOR_VAPOR, SKINCOLOR_BUBBLEGUM, @@ -1735,7 +1735,7 @@ static void ST_drawNiGHTSLink(void) static INT32 prevsel[2] = {0, 0}, prevtime[2] = {0, 0}; const UINT8 q = ((splitscreen && stplyr == &players[secondarydisplayplayer]) ? 1 : 0); INT32 sel = ((stplyr->linkcount-1) / 5) % NUMLINKCOLORS, aflag = V_PERPLAYER, mag = ((stplyr->linkcount-1 >= 300) ? 1 : 0); - skincolors_t colornum; + skincolornum_t colornum; fixed_t x, y, scale; if (sel != prevsel[q]) diff --git a/src/win32/win_sys.c b/src/win32/win_sys.c index 42733c309..0aa93fb2b 100644 --- a/src/win32/win_sys.c +++ b/src/win32/win_sys.c @@ -54,6 +54,8 @@ #include "../screen.h" +#include "../m_menu.h" + // Wheel support for Win95/WinNT3.51 #include @@ -650,6 +652,7 @@ void I_Error(const char *error, ...) G_StopMetalRecording(false); D_QuitNetGame(); + M_FreePlayerSetupColors(); // shutdown everything that was started I_ShutdownSystem(); @@ -746,6 +749,8 @@ void I_Quit(void) // so do it before. D_QuitNetGame(); + M_FreePlayerSetupColors(); + // shutdown everything that was started I_ShutdownSystem(); From 58d435484c4a35d594c209ab344dada90cf1dd20 Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Sun, 23 Feb 2020 12:17:52 -0500 Subject: [PATCH 02/42] Fix userdataType typo --- src/lua_baselib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 99f1a9463..7e7f0a1ca 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -148,7 +148,7 @@ static const struct { {META_STATE, "state_t"}, {META_MOBJINFO, "mobjinfo_t"}, {META_SFXINFO, "sfxinfo_t"}, - {META_SKINCOLOR, "sfxinfo_t"}, + {META_SKINCOLOR, "skincolor_t"}, {META_COLORRAMP, "skincolor_t.ramp"}, {META_SPRITEINFO, "spriteinfo_t"}, {META_PIVOTLIST, "spriteframepivot_t[]"}, From 3106a92e8b7ffdcec15b1bea3f167ce466da19f0 Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Sat, 29 Feb 2020 23:14:49 -0500 Subject: [PATCH 03/42] Prohibit modification of built-in colors In addition, fixes a bug where loading a custom color using command line params exhibits strange behavior. --- src/d_main.c | 4 ++++ src/dehacked.c | 4 ++-- src/info.c | 1 - src/lua_infolib.c | 21 ++++++++++----------- src/m_menu.c | 9 ++++----- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 904ab3bf1..9fcf349db 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1151,6 +1151,10 @@ void D_SRB2Main(void) if (M_CheckParm("-password") && M_IsNextParm()) D_SetPassword(M_GetNextParm()); + + // player setup menu colors must be initialized before + // any wad file is added, as they may contain colors themselves + M_InitPlayerSetupColors(); // add any files specified on the command line with -file wadfile // to the wad list diff --git a/src/dehacked.c b/src/dehacked.c index 4d12587dd..e2627d241 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -4629,11 +4629,11 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) { if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_skincolor(word2); // find a skincolor by name - if (i < numskincolors && i > 0) + if (i < numskincolors && i >= (INT32)SKINCOLOR_FIRSTFREESLOT) readskincolor(f, i); else { - deh_warning("Skincolor %d out of range (1 - %d)", i, numskincolors-1); + deh_warning("Skincolor %d out of range (%d - %d)", i, SKINCOLOR_FIRSTFREESLOT, numskincolors-1); ignorelines(f); } } diff --git a/src/info.c b/src/info.c index d592da8b8..e8e5bc89b 100644 --- a/src/info.c +++ b/src/info.c @@ -21773,7 +21773,6 @@ void P_PatchInfoTables(void) skincolors[i].accessible = false; skincolors[i].name[0] = '\0'; } - numskincolors = SKINCOLOR_FIRSTFREESLOT; for (i = MT_FIRSTFREESLOT; i <= MT_LASTFREESLOT; i++) mobjinfo[i].doomednum = -1; } diff --git a/src/lua_infolib.c b/src/lua_infolib.c index fd9cd319f..372b746d4 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -1516,8 +1516,8 @@ static int lib_setSkinColor(lua_State *L) lua_remove(L, 1); // don't care about skincolors[] userdata. { cnum = (UINT8)luaL_checkinteger(L, 1); - if (!cnum || cnum >= numskincolors) - return luaL_error(L, "skincolors[] index %d out of range (1 - %d)", cnum, numskincolors-1); + if (cnum < SKINCOLOR_FIRSTFREESLOT || cnum >= numskincolors) + return luaL_error(L, "skincolors[] index %d out of range (%d - %d)", cnum, SKINCOLOR_FIRSTFREESLOT, numskincolors-1); info = &skincolors[cnum]; // get the skincolor to assign to. } luaL_checktype(L, 2, LUA_TTABLE); // check that we've been passed a table. @@ -1615,8 +1615,8 @@ static int skincolor_set(lua_State *L) I_Assert(info != NULL); I_Assert(info >= skincolors); - if (info-skincolors >= numskincolors) - return luaL_error(L, "skincolors[] index %d does not exist", info-skincolors); + if (info-skincolors < SKINCOLOR_FIRSTFREESLOT || info-skincolors >= numskincolors) + return luaL_error(L, "skincolors[] index %d out of range (%d - %d)", info-skincolors, SKINCOLOR_FIRSTFREESLOT, numskincolors-1); if (fastcmp(field,"name")) { const char* n = luaL_checkstring(L, 3); @@ -1640,13 +1640,9 @@ static int skincolor_set(lua_State *L) info->invshade = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"chatcolor")) info->chatcolor = (UINT16)luaL_checkinteger(L, 3); - else if (fastcmp(field,"accessible")) { - boolean v = lua_isboolean(L,3) ? lua_toboolean(L, 3) : true; - if (info-skincolors < FIRSTSUPERCOLOR && v != info->accessible) - return luaL_error(L, "skincolors[] index %d is a standard color; accessibility changes are prohibited.", info-skincolors); - else - info->accessible = v; - } else + else if (fastcmp(field,"accessible")) + info->accessible = lua_isboolean(L,3); + else CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "skincolor_t", field); return 1; } @@ -1678,8 +1674,11 @@ static int colorramp_get(lua_State *L) static int colorramp_set(lua_State *L) { UINT8 *colorramp = *((UINT8 **)luaL_checkudata(L, 1, META_COLORRAMP)); + UINT16 cnum = (UINT16)(((uint8_t*)colorramp - (uint8_t*)(skincolors[0].ramp))/sizeof(skincolor_t)); UINT32 n = luaL_checkinteger(L, 2); UINT8 i = (UINT8)luaL_checkinteger(L, 3); + if (cnum < SKINCOLOR_FIRSTFREESLOT || cnum >= numskincolors) + return luaL_error(L, "skincolors[] index %d out of range (%d - %d)", cnum, SKINCOLOR_FIRSTFREESLOT, numskincolors-1); if (n >= COLORRAMPSIZE) return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' index %d out of range (0 - %d)", n, COLORRAMPSIZE-1); if (hud_running) diff --git a/src/m_menu.c b/src/m_menu.c index 76ac7e086..ec3f59b41 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3860,8 +3860,6 @@ void M_Init(void) #ifndef NONET CV_RegisterVar(&cv_serversort); #endif - - M_InitPlayerSetupColors(); } void M_InitCharacterTables(void) @@ -11427,7 +11425,7 @@ void M_AddMenuColor(UINT8 color) { return; } - c = (menucolor_t *)Z_Malloc(sizeof(menucolor_t), PU_STATIC, NULL); + c = (menucolor_t *)malloc(sizeof(menucolor_t)); c->color = color; if (menucolorhead == NULL) { c->next = c; @@ -11561,6 +11559,7 @@ UINT8 M_GetColorAfter(UINT8 color) { void M_InitPlayerSetupColors(void) { UINT8 i; + numskincolors = SKINCOLOR_FIRSTFREESLOT; menucolorhead = menucolortail = NULL; for (i=0; inext; - Z_Free(tmp); + free(tmp); } else { - Z_Free(look); + free(look); return; } } From fd4666b481235360f6fa697c030ef56665ec398e Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Sat, 29 Feb 2020 23:44:56 -0500 Subject: [PATCH 04/42] Bruh. --- src/hu_stuff.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 9bca60208..e3034c09c 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -759,7 +759,6 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) } else { -<<<<<<< HEAD UINT16 chatcolor = skincolors[players[playernum].skincolor].chatcolor; if (!chatcolor || chatcolor%0x1000 || chatcolor>V_INVERTMAP) From 19d77bfc531794c77d78831e982e36ec74574c4b Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 2 May 2020 12:50:09 +0200 Subject: [PATCH 05/42] P_PlayerMobjThinker: Move crumbling platforms check into its own function --- src/p_mobj.c | 61 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 29fe1a57c..17734096f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3780,9 +3780,41 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled return false; } -// -// P_PlayerMobjThinker -// +static void P_CheckCrumblingPlatforms(mobj_t *mobj) +{ + msecnode_t *node; + + if (netgame && mobj->player->spectator) + return; + + for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) + { + ffloor_t *rover; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + + if (!(rover->flags & FF_CRUMBLE)) + continue; + + if (mobj->eflags & MFE_VERTICALFLIP) + { + if (P_GetSpecialBottomZ(mobj, sectors + rover->secnum, node->m_sector) != mobj->z + mobj->height) + continue; + } + else + { + if (P_GetSpecialTopZ(mobj, sectors + rover->secnum, node->m_sector) != mobj->z) + continue; + } + + EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), mobj->player, rover->alpha, !(rover->flags & FF_NORETURN)); + } + } +} + static void P_PlayerMobjThinker(mobj_t *mobj) { msecnode_t *node; @@ -3839,28 +3871,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) else P_TryMove(mobj, mobj->x, mobj->y, true); - if (!(netgame && mobj->player->spectator)) - { - // Crumbling platforms - for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) - { - fixed_t topheight, bottomheight; - ffloor_t *rover; - - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_CRUMBLE)) - continue; - - topheight = P_GetSpecialTopZ(mobj, sectors + rover->secnum, node->m_sector); - bottomheight = P_GetSpecialBottomZ(mobj, sectors + rover->secnum, node->m_sector); - - if ((topheight == mobj->z && !(mobj->eflags & MFE_VERTICALFLIP)) - || (bottomheight == mobj->z + mobj->height && mobj->eflags & MFE_VERTICALFLIP)) // You nut. - EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), mobj->player, rover->alpha, !(rover->flags & FF_NORETURN)); - } - } - } + P_CheckCrumblingPlatforms(mobj); // Check for floating water platforms and bounce them if (CheckForFloatBob && P_MobjFlip(mobj)*mobj->momz < 0) From 2605f29bd45e53a7e070fd9ddac3275721048a16 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 2 May 2020 13:08:13 +0200 Subject: [PATCH 06/42] P_PlayerMobjThinker: Move check for floatbob platforms into its own function --- src/p_mobj.c | 121 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 72 insertions(+), 49 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 17734096f..eb6a1a125 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3815,10 +3815,79 @@ static void P_CheckCrumblingPlatforms(mobj_t *mobj) } } -static void P_PlayerMobjThinker(mobj_t *mobj) +static boolean P_MobjTouchesSectorWithWater(mobj_t *mobj) { msecnode_t *node; + for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) + { + ffloor_t *rover; + + if (!node->m_sector->ffloors) + continue; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + + if (!(rover->flags & FF_SWIMMABLE)) + continue; + + return true; + } + } + + return false; +} + +// Check for floating water platforms and bounce them +static void P_CheckFloatbobPlatforms(mobj_t *mobj) +{ + msecnode_t *node; + + // Can't land on anything if you're not moving downwards + if (P_MobjFlip(mobj)*mobj->momz >= 0) + return; + + if (!P_MobjTouchesSectorWithWater(mobj)) + return; + + for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) + { + ffloor_t *rover; + + if (!node->m_sector->ffloors) + continue; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + + if (!(rover->flags & FF_FLOATBOB)) + continue; + + + if (mobj->eflags & MFE_VERTICALFLIP) + { + if (abs(*rover->bottomheight - (mobj->z + mobj->height)) > abs(mobj->momz)) + continue; + } + else + { + if (abs(*rover->topheight - mobj->z) > abs(mobj->momz)) + continue; + } + + // Initiate a 'bouncy' elevator function which slowly diminishes. + EV_BounceSector(rover->master->frontsector, -mobj->momz, rover->master); + } + } +} + +static void P_PlayerMobjThinker(mobj_t *mobj) +{ I_Assert(mobj != NULL); I_Assert(mobj->player != NULL); I_Assert(!P_MobjWasRemoved(mobj)); @@ -3873,54 +3942,8 @@ static void P_PlayerMobjThinker(mobj_t *mobj) P_CheckCrumblingPlatforms(mobj); - // Check for floating water platforms and bounce them - if (CheckForFloatBob && P_MobjFlip(mobj)*mobj->momz < 0) - { - boolean thereiswater = false; - - for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) - { - if (node->m_sector->ffloors) - { - ffloor_t *rover; - // Get water boundaries first - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) - continue; - - if (rover->flags & FF_SWIMMABLE) // Is there water? - { - thereiswater = true; - break; - } - } - } - } - if (thereiswater) - { - for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) - { - if (node->m_sector->ffloors) - { - ffloor_t *rover; - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_FLOATBOB)) - continue; - - if ((!(mobj->eflags & MFE_VERTICALFLIP) && abs(*rover->topheight-mobj->z) <= abs(mobj->momz)) // The player is landing on the cheese! - || (mobj->eflags & MFE_VERTICALFLIP && abs(*rover->bottomheight-(mobj->z+mobj->height)) <= abs(mobj->momz))) - { - // Initiate a 'bouncy' elevator function - // which slowly diminishes. - EV_BounceSector(rover->master->frontsector, -mobj->momz, rover->master); - } - } - } - } - } // Ugly ugly billions of braces! Argh! - } + if (CheckForFloatBob) + P_CheckFloatbobPlatforms(mobj); // always do the gravity bit now, that's simpler // BUT CheckPosition only if wasn't done before. From afc63788680bd75654504e0b0f0a1c7a0f04187b Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 2 May 2020 13:34:24 +0200 Subject: [PATCH 07/42] P_PlayerZMovement: Move checks for Mario blocks into their own function --- src/p_mobj.c | 70 +++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index eb6a1a125..91cb3dc9e 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2798,6 +2798,43 @@ static boolean P_ZMovement(mobj_t *mo) return true; } +// Check for "Mario" blocks to hit and bounce them +static void P_CheckMarioBlocks(mobj_t *mo) +{ + msecnode_t *node; + + if (netgame && mo->player->spectator) + return; + + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) + { + ffloor_t *rover; + + if (!node->m_sector->ffloors) + continue; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + + if (!(rover->flags & FF_MARIO)) + continue; + + if (mo->eflags & MFE_VERTICALFLIP) + continue; // if you were flipped, your head isn't actually hitting your ceilingz is it? + + if (*rover->bottomheight != mo->ceilingz) + continue; + + if (rover->flags & FF_SHATTERBOTTOM) // Brick block! + EV_CrumbleChain(node->m_sector, rover); + else // Question block! + EV_MarioBlock(rover, node->m_sector, mo); + } + } +} + static void P_PlayerZMovement(mobj_t *mo) { boolean onground; @@ -3022,39 +3059,10 @@ nightsdone: } } - // Check for "Mario" blocks to hit and bounce them if (P_MobjFlip(mo)*mo->momz > 0) { - msecnode_t *node; - - if (CheckForMarioBlocks && !(netgame && mo->player->spectator)) // Only let the player punch - { - // Search the touching sectors, from side-to-side... - for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) - { - ffloor_t *rover; - if (!node->m_sector->ffloors) - continue; - - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) - continue; - - // Come on, it's time to go... - if (rover->flags & FF_MARIO - && !(mo->eflags & MFE_VERTICALFLIP) // if you were flipped, your head isn't actually hitting your ceilingz is it? - && *rover->bottomheight == mo->ceilingz) // The player's head hit the bottom! - { - // DO THE MARIO! - if (rover->flags & FF_SHATTERBOTTOM) // Brick block! - EV_CrumbleChain(node->m_sector, rover); - else // Question block! - EV_MarioBlock(rover, node->m_sector, mo); - } - } - } // Ugly ugly billions of braces! Argh! - } + if (CheckForMarioBlocks) + P_CheckMarioBlocks(mo); // hit the ceiling if (mariomode) From a67c8786aedbab4b9dca8301b62249e0e6f620cd Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 2 May 2020 13:49:16 +0200 Subject: [PATCH 08/42] P_PlayerZMovement: Move PolyObject handling code into its own function --- src/p_mobj.c | 111 ++++++++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 59 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 4a9f4ec95..fab6c193f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2835,6 +2835,57 @@ static void P_CheckMarioBlocks(mobj_t *mo) } } +// Check if we're on a polyobject that triggers a linedef executor. +static boolean P_PlayerPolyObjectZMovement(mobj_t *mo) +{ + msecnode_t *node; + boolean stopmovecut = false; + + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) + { + sector_t *sec = node->m_sector; + subsector_t *newsubsec; + size_t i; + + for (i = 0; i < numsubsectors; i++) + { + polyobj_t *po; + sector_t *polysec; + newsubsec = &subsectors[i]; + + if (newsubsec->sector != sec) + continue; + + for (po = newsubsec->polyList; po; po = (polyobj_t *)(po->link.next)) + { + if (!(po->flags & POF_SOLID)) + continue; + + if (!P_MobjInsidePolyobj(po, mo)) + continue; + + polysec = po->lines[0]->backsector; + + // Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red + if ((mo->z == polysec->ceilingheight || mo->z + mo->height == polysec->floorheight) && po->thinker) + stopmovecut = true; + + if (!(po->flags & POF_LDEXEC)) + continue; + + if (mo->z != polysec->ceilingheight) + continue; + + // We're landing on a PO, so check for a linedef executor. + // Trigger tags are 32000 + the PO's ID number. + P_LinedefExecute((INT16)(32000 + po->id), mo, NULL); + } + } + } + + return stopmovecut; +} + static void P_PlayerZMovement(mobj_t *mo) { boolean onground; @@ -2931,66 +2982,8 @@ static void P_PlayerZMovement(mobj_t *mo) mo->eflags |= MFE_JUSTHITFLOOR; // Spin Attack + if (!P_PlayerPolyObjectZMovement(mo)) { - // Check if we're on a polyobject - // that triggers a linedef executor. - msecnode_t *node; - boolean stopmovecut = false; - - for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) - { - sector_t *sec = node->m_sector; - subsector_t *newsubsec; - size_t i; - - for (i = 0; i < numsubsectors; i++) - { - newsubsec = &subsectors[i]; - - if (newsubsec->sector != sec) - continue; - - if (newsubsec->polyList) - { - polyobj_t *po = newsubsec->polyList; - sector_t *polysec; - - while(po) - { - if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) - { - po = (polyobj_t *)(po->link.next); - continue; - } - - // We're inside it! Yess... - polysec = po->lines[0]->backsector; - - // Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red - if ((mo->z == polysec->ceilingheight || mo->z+mo->height == polysec->floorheight) && po->thinker) - stopmovecut = true; - - if (!(po->flags & POF_LDEXEC)) - { - po = (polyobj_t *)(po->link.next); - continue; - } - - if (mo->z == polysec->ceilingheight) - { - // We're landing on a PO, so check for - // a linedef executor. - // Trigger tags are 32000 + the PO's ID number. - P_LinedefExecute((INT16)(32000 + po->id), mo, NULL); - } - - po = (polyobj_t *)(po->link.next); - } - } - } - } - - if (!stopmovecut) // Cut momentum in half when you hit the ground and // aren't pressing any controls. if (!(mo->player->cmd.forwardmove || mo->player->cmd.sidemove) && !mo->player->cmomx && !mo->player->cmomy && !(mo->player->pflags & PF_SPINNING)) From 929064b998b908fe444693251baa773c2d2ab9f7 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 2 May 2020 15:21:53 +0200 Subject: [PATCH 09/42] Refactor PTR_SlideTraverse --- src/p_map.c | 279 ++++++++++++++++++++++++++-------------------------- 1 file changed, 139 insertions(+), 140 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 0fade4847..3f1f6caf5 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3310,9 +3310,139 @@ static boolean P_IsClimbingValid(player_t *player, angle_t angle) return false; } -// -// PTR_SlideTraverse -// +static boolean PTR_LineIsBlocking(line_t *li) +{ + // one-sided linedefs are always solid to sliding movement. + if (!li->backsector) + return !P_PointOnLineSide(slidemo->x, slidemo->y, li); + + if (!(slidemo->flags & MF_MISSILE)) + { + if (li->flags & ML_IMPASSIBLE) + return true; + + if ((slidemo->flags & (MF_ENEMY|MF_BOSS)) && li->flags & ML_BLOCKMONSTERS) + return true; + } + + // set openrange, opentop, openbottom + P_LineOpening(li, slidemo); + + if (openrange < slidemo->height) + return true; // doesn't fit + + if (opentop - slidemo->z < slidemo->height) + return true; // mobj is too high + + if (openbottom - slidemo->z > FixedMul(MAXSTEPMOVE, slidemo->scale)) + return true; // too big a step up + + return false; +} + +static void PTR_GlideClimbTraverse(line_t *li) +{ + line_t *checkline = li; + sector_t *checksector; + ffloor_t *rover; + fixed_t topheight, bottomheight; + boolean fofline = false; + INT32 side = P_PointOnLineSide(slidemo->x, slidemo->y, li); + + if (!side && li->backsector) + checksector = li->backsector; + else + checksector = li->frontsector; + + if (checksector->ffloors) + { + for (rover = checksector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) + continue; + + topheight = *rover->topheight; + bottomheight = *rover->bottomheight; + + if (*rover->t_slope) + topheight = P_GetZAt(*rover->t_slope, slidemo->x, slidemo->y); + if (*rover->b_slope) + bottomheight = P_GetZAt(*rover->b_slope, slidemo->x, slidemo->y); + + if (topheight < slidemo->z) + continue; + + if (bottomheight > slidemo->z + slidemo->height) + continue; + + // Got this far, so I guess it's climbable. // TODO: Climbing check, also, better method to do this? + if (rover->master->flags & ML_TFERLINE) + { + size_t linenum = li-checksector->lines[0]; + checkline = rover->master->frontsector->lines[0] + linenum; + fofline = true; + } + + break; + } + } + + // see about climbing on the wall + if (!(checkline->flags & ML_NOCLIMB) && checkline->special != HORIZONSPECIAL) + { + boolean canclimb; + angle_t climbangle, climbline; + INT32 whichside = P_PointOnLineSide(slidemo->x, slidemo->y, li); + + climbangle = climbline = R_PointToAngle2(li->v1->x, li->v1->y, li->v2->x, li->v2->y); + + if (whichside) // on second side? + climbline += ANGLE_180; + + climbangle += (ANGLE_90 * (whichside ? -1 : 1)); + + canclimb = (li->backsector ? P_IsClimbingValid(slidemo->player, climbangle) : true); + + if (((!slidemo->player->climbing && abs((signed)(slidemo->angle - ANGLE_90 - climbline)) < ANGLE_45) + || (slidemo->player->climbing == 1 && abs((signed)(slidemo->angle - climbline)) < ANGLE_135)) + && canclimb) + { + slidemo->angle = climbangle; + /*if (!demoplayback || P_ControlStyle(slidemo->player) == CS_LMAOGALOG) + { + if (slidemo->player == &players[consoleplayer]) + localangle = slidemo->angle; + else if (slidemo->player == &players[secondarydisplayplayer]) + localangle2 = slidemo->angle; + }*/ + + if (!slidemo->player->climbing) + { + S_StartSound(slidemo->player->mo, sfx_s3k4a); + slidemo->player->climbing = 5; + } + + slidemo->player->pflags &= ~(PF_GLIDING|PF_SPINNING|PF_JUMPED|PF_NOJUMPDAMAGE|PF_THOKKED); + slidemo->player->glidetime = 0; + slidemo->player->secondjump = 0; + + if (slidemo->player->climbing > 1) + slidemo->momz = slidemo->momx = slidemo->momy = 0; + + if (fofline) + whichside = 0; + + if (!whichside) + { + slidemo->player->lastsidehit = checkline->sidenum[whichside]; + slidemo->player->lastlinehit = (INT16)(checkline - lines); + } + + P_Thrust(slidemo, slidemo->angle, FixedMul(5*FRACUNIT, slidemo->scale)); + } + } +} + static boolean PTR_SlideTraverse(intercept_t *in) { line_t *li; @@ -3321,151 +3451,20 @@ static boolean PTR_SlideTraverse(intercept_t *in) li = in->d.line; - // one-sided linedefs are always solid to sliding movement. - // one-sided linedef - if (!li->backsector) - { - if (P_PointOnLineSide(slidemo->x, slidemo->y, li)) - return true; // don't hit the back side - goto isblocking; - } + if (!PTR_LineIsBlocking(li)) + return true; - if (!(slidemo->flags & MF_MISSILE)) - { - if (li->flags & ML_IMPASSIBLE) - goto isblocking; - - if ((slidemo->flags & (MF_ENEMY|MF_BOSS)) && li->flags & ML_BLOCKMONSTERS) - goto isblocking; - } - - // set openrange, opentop, openbottom - P_LineOpening(li, slidemo); - - if (openrange < slidemo->height) - goto isblocking; // doesn't fit - - if (opentop - slidemo->z < slidemo->height) - goto isblocking; // mobj is too high - - if (openbottom - slidemo->z > FixedMul(MAXSTEPMOVE, slidemo->scale)) - goto isblocking; // too big a step up - - // this line doesn't block movement - return true; - - // the line does block movement, + // the line blocks movement, // see if it is closer than best so far -isblocking: if (li->polyobj && slidemo->player) { if ((li->polyobj->lines[0]->backsector->flags & SF_TRIGGERSPECIAL_TOUCH) && !(li->polyobj->flags & POF_NOSPECIALS)) P_ProcessSpecialSector(slidemo->player, slidemo->subsector->sector, li->polyobj->lines[0]->backsector); } - if (slidemo->player && (slidemo->player->pflags & PF_GLIDING || slidemo->player->climbing) - && slidemo->player->charability == CA_GLIDEANDCLIMB) - { - line_t *checkline = li; - sector_t *checksector; - ffloor_t *rover; - fixed_t topheight, bottomheight; - boolean fofline = false; - INT32 side = P_PointOnLineSide(slidemo->x, slidemo->y, li); - - if (!side && li->backsector) - checksector = li->backsector; - else - checksector = li->frontsector; - - if (checksector->ffloors) - { - for (rover = checksector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) - continue; - - topheight = *rover->topheight; - bottomheight = *rover->bottomheight; - - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, slidemo->x, slidemo->y); - if (*rover->b_slope) - bottomheight = P_GetZAt(*rover->b_slope, slidemo->x, slidemo->y); - - if (topheight < slidemo->z) - continue; - - if (bottomheight > slidemo->z + slidemo->height) - continue; - - // Got this far, so I guess it's climbable. // TODO: Climbing check, also, better method to do this? - if (rover->master->flags & ML_TFERLINE) - { - size_t linenum = li-checksector->lines[0]; - checkline = rover->master->frontsector->lines[0] + linenum; - fofline = true; - } - - break; - } - } - - // see about climbing on the wall - if (!(checkline->flags & ML_NOCLIMB) && checkline->special != HORIZONSPECIAL) - { - boolean canclimb; - angle_t climbangle, climbline; - INT32 whichside = P_PointOnLineSide(slidemo->x, slidemo->y, li); - - climbangle = climbline = R_PointToAngle2(li->v1->x, li->v1->y, li->v2->x, li->v2->y); - - if (whichside) // on second side? - climbline += ANGLE_180; - - climbangle += (ANGLE_90 * (whichside ? -1 : 1)); - - canclimb = (li->backsector ? P_IsClimbingValid(slidemo->player, climbangle) : true); - - if (((!slidemo->player->climbing && abs((signed)(slidemo->angle - ANGLE_90 - climbline)) < ANGLE_45) - || (slidemo->player->climbing == 1 && abs((signed)(slidemo->angle - climbline)) < ANGLE_135)) - && canclimb) - { - slidemo->angle = climbangle; - /*if (!demoplayback || P_ControlStyle(slidemo->player) == CS_LMAOGALOG) - { - if (slidemo->player == &players[consoleplayer]) - localangle = slidemo->angle; - else if (slidemo->player == &players[secondarydisplayplayer]) - localangle2 = slidemo->angle; - }*/ - - if (!slidemo->player->climbing) - { - S_StartSound(slidemo->player->mo, sfx_s3k4a); - slidemo->player->climbing = 5; - } - - slidemo->player->pflags &= ~(PF_GLIDING|PF_SPINNING|PF_JUMPED|PF_NOJUMPDAMAGE|PF_THOKKED); - slidemo->player->glidetime = 0; - slidemo->player->secondjump = 0; - - if (slidemo->player->climbing > 1) - slidemo->momz = slidemo->momx = slidemo->momy = 0; - - if (fofline) - whichside = 0; - - if (!whichside) - { - slidemo->player->lastsidehit = checkline->sidenum[whichside]; - slidemo->player->lastlinehit = (INT16)(checkline - lines); - } - - P_Thrust(slidemo, slidemo->angle, FixedMul(5*FRACUNIT, slidemo->scale)); - } - } - } + if (slidemo->player && slidemo->player->charability == CA_GLIDEANDCLIMB + && (slidemo->player->pflags & PF_GLIDING || slidemo->player->climbing)) + PTR_GlideClimbTraverse(li); if (in->frac < bestslidefrac && (!slidemo->player || !slidemo->player->climbing)) { From bc2d0dcea6690458b3f7973fbd4f5cd0b82609f6 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 2 May 2020 15:25:19 +0200 Subject: [PATCH 10/42] Some minor PTR_GlideClimbTraverse cleanup --- src/p_map.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 3f1f6caf5..db6df59dc 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3343,16 +3343,10 @@ static boolean PTR_LineIsBlocking(line_t *li) static void PTR_GlideClimbTraverse(line_t *li) { line_t *checkline = li; - sector_t *checksector; ffloor_t *rover; fixed_t topheight, bottomheight; boolean fofline = false; - INT32 side = P_PointOnLineSide(slidemo->x, slidemo->y, li); - - if (!side && li->backsector) - checksector = li->backsector; - else - checksector = li->frontsector; + sector_t *checksector = (li->backsector && !P_PointOnLineSide(slidemo->x, slidemo->y, li)) ? li->backsector : li->frontsector; if (checksector->ffloors) { From ddb4c2c97f3f5bfdad660f4ee3e8bc6b95998d8b Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 2 May 2020 15:30:56 +0200 Subject: [PATCH 11/42] Refactor P_PushableCheckBustables --- src/p_mobj.c | 125 ++++++++++++++++++++++++++------------------------- 1 file changed, 64 insertions(+), 61 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index fab6c193f..1d3fe8b46 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1674,77 +1674,80 @@ static void P_PushableCheckBustables(mobj_t *mo) for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) { + ffloor_t *rover; + fixed_t topheight, bottomheight; + if (!node->m_sector) break; - if (node->m_sector->ffloors) + if (!node->m_sector->ffloors) + continue; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) { - ffloor_t *rover; - fixed_t topheight, bottomheight; + if (!(rover->flags & FF_EXISTS)) + continue; - for (rover = node->m_sector->ffloors; rover; rover = rover->next) + if (!(rover->flags & FF_BUSTUP)) + continue; + + // Needs ML_EFFECT4 flag for pushables to break it + if (!(rover->master->flags & ML_EFFECT4)) + continue; + + if (rover->master->frontsector->crumblestate != CRUMBLE_NONE) + continue; + + topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); + bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); + + // Height checks + if (rover->flags & FF_SHATTERBOTTOM) { - if (!(rover->flags & FF_EXISTS)) continue; + if (mo->z + mo->momz + mo->height < bottomheight) + continue; - if (!(rover->flags & FF_BUSTUP)) continue; - - // Needs ML_EFFECT4 flag for pushables to break it - if (!(rover->master->flags & ML_EFFECT4)) continue; - - if (rover->master->frontsector->crumblestate == CRUMBLE_NONE) - { - topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); - bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); - // Height checks - if (rover->flags & FF_SHATTERBOTTOM) - { - if (mo->z+mo->momz + mo->height < bottomheight) - continue; - - if (mo->z+mo->height > bottomheight) - continue; - } - else if (rover->flags & FF_SPINBUST) - { - if (mo->z+mo->momz > topheight) - continue; - - if (mo->z+mo->height < bottomheight) - continue; - } - else if (rover->flags & FF_SHATTER) - { - if (mo->z+mo->momz > topheight) - continue; - - if (mo->z+mo->momz + mo->height < bottomheight) - continue; - } - else - { - if (mo->z >= topheight) - continue; - - if (mo->z+mo->height < bottomheight) - continue; - } - - EV_CrumbleChain(NULL, rover); // node->m_sector - - // Run a linedef executor?? - if (rover->master->flags & ML_EFFECT5) - P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), mo, node->m_sector); - - goto bustupdone; - } + if (mo->z + mo->height > bottomheight) + continue; } + else if (rover->flags & FF_SPINBUST) + { + if (mo->z + mo->momz > topheight) + continue; + + if (mo->z + mo->height < bottomheight) + continue; + } + else if (rover->flags & FF_SHATTER) + { + if (mo->z + mo->momz > topheight) + continue; + + if (mo->z + mo->momz + mo->height < bottomheight) + continue; + } + else + { + if (mo->z >= topheight) + continue; + + if (mo->z + mo->height < bottomheight) + continue; + } + + EV_CrumbleChain(NULL, rover); // node->m_sector + + // Run a linedef executor?? + if (rover->master->flags & ML_EFFECT5) + P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), mo, node->m_sector); + + P_UnsetThingPosition(mo); + mo->x = oldx; + mo->y = oldy; + P_SetThingPosition(mo); + return; } } -bustupdone: - P_UnsetThingPosition(mo); - mo->x = oldx; - mo->y = oldy; - P_SetThingPosition(mo); } // From 122104815a33f20c7dbad8298e629d5fb647aff9 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 2 May 2020 15:33:15 +0200 Subject: [PATCH 12/42] Revert some very incorrect refactoring --- src/p_mobj.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 1d3fe8b46..301f3a8d6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1741,13 +1741,14 @@ static void P_PushableCheckBustables(mobj_t *mo) if (rover->master->flags & ML_EFFECT5) P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), mo, node->m_sector); - P_UnsetThingPosition(mo); - mo->x = oldx; - mo->y = oldy; - P_SetThingPosition(mo); - return; + goto bustupdone; } } +bustupdone: + P_UnsetThingPosition(mo); + mo->x = oldx; + mo->y = oldy; + P_SetThingPosition(mo); } // From 452fd100b8c3e15c67fafb3dfe65b718ff9920d7 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 2 May 2020 15:50:18 +0200 Subject: [PATCH 13/42] Refactor P_CheckBustableBlocks --- src/p_user.c | 244 ++++++++++++++++++++++++++++----------------------- 1 file changed, 136 insertions(+), 108 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 36a1054c6..e7dc69c1f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2532,6 +2532,72 @@ boolean P_InQuicksand(mobj_t *mo) // Returns true if you are in quicksand return false; // No sand here, Captain! } +static boolean P_PlayerCanBust(player_t *player, ffloor_t *rover) +{ + if (!(rover->flags & FF_EXISTS)) + return false; + + if (!(rover->flags & FF_BUSTUP)) + return false; + + /*if (rover->master->frontsector->crumblestate != CRUMBLE_NONE) + return false;*/ + + // If it's an FF_SHATTER, you can break it just by touching it. + if (rover->flags & FF_SHATTER) + return true; + + // If it's an FF_SPINBUST, you can break it if you are in your spinning frames + // (either from jumping or spindashing). + if (rover->flags & FF_SPINBUST) + { + if ((player->pflags & PF_SPINNING) && !(player->pflags & PF_STARTDASH)) + return true; + + if ((player->pflags & PF_JUMPED) && !(player->pflags & PF_NOJUMPDAMAGE)) + return true; + } + + // Strong abilities can break even FF_STRONGBUST. + if (player->charability == CA_GLIDEANDCLIMB) + return true; + + if (player->pflags & PF_BOUNCING) + return true; + + if (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY) + return true; + + if (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2) + return true; + + // Everyone else is out of luck. + if (rover->flags & FF_STRONGBUST) + return false; + + // Spinning (and not jumping) + if ((player->pflags & PF_SPINNING) && !(player->pflags & PF_JUMPED)) + return true; + + // Super + if (player->powers[pw_super]) + return true; + + // Dashmode + if ((player->charflags & (SF_DASHMODE|SF_MACHINE)) == (SF_DASHMODE|SF_MACHINE) && player->dashmode >= DASHMODE_THRESHOLD) + return true; + + // NiGHTS drill + if (player->pflags & PF_DRILLING) + return true; + + // Recording for Metal Sonic + if (metalrecording) + return true; + + return false; +} + static void P_CheckBustableBlocks(player_t *player) { msecnode_t *node; @@ -2554,121 +2620,83 @@ static void P_CheckBustableBlocks(player_t *player) for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { + ffloor_t *rover; + fixed_t topheight, bottomheight; + if (!node->m_sector) break; - if (node->m_sector->ffloors) + if (!node->m_sector->ffloors) + continue; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) { - ffloor_t *rover; - fixed_t topheight, bottomheight; + if (!P_PlayerCanBust(player, rover)) + continue; - for (rover = node->m_sector->ffloors; rover; rover = rover->next) + topheight = P_GetFOFTopZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); + bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); + + if (((player->charability == CA_TWINSPIN) && (player->panim == PA_ABILITY)) + || ((P_MobjFlip(player->mo)*player->mo->momz < 0) && (player->pflags & PF_BOUNCING || ((player->charability2 == CA2_MELEE) && (player->panim == PA_ABILITY2))))) { - if (!(rover->flags & FF_EXISTS)) continue; - - if ((rover->flags & FF_BUSTUP)/* && rover->master->frontsector->crumblestate == CRUMBLE_NONE*/) - { - // If it's an FF_SHATTER, you can break it just by touching it. - if (rover->flags & FF_SHATTER) - goto bust; - - // If it's an FF_SPINBUST, you can break it if you are in your spinning frames - // (either from jumping or spindashing). - if (rover->flags & FF_SPINBUST - && (((player->pflags & PF_SPINNING) && !(player->pflags & PF_STARTDASH)) - || (player->pflags & PF_JUMPED && !(player->pflags & PF_NOJUMPDAMAGE)))) - goto bust; - - // You can always break it if you have CA_GLIDEANDCLIMB - // or if you are bouncing on it - // or you are using CA_TWINSPIN/CA2_MELEE. - if (player->charability == CA_GLIDEANDCLIMB - || (player->pflags & PF_BOUNCING) - || ((player->charability == CA_TWINSPIN) && (player->panim == PA_ABILITY)) - || (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2)) - goto bust; - - if (rover->flags & FF_STRONGBUST) - continue; - - // If it's not an FF_STRONGBUST, you can break if you are spinning (and not jumping) - // or you are super - // or you are in dashmode with SF_DASHMODE - // or you are drilling in NiGHTS - // or you are recording for Metal Sonic - if (!((player->pflags & PF_SPINNING) && !(player->pflags & PF_JUMPED)) - && !(player->powers[pw_super]) - && !(((player->charflags & (SF_DASHMODE|SF_MACHINE)) == (SF_DASHMODE|SF_MACHINE)) && (player->dashmode >= DASHMODE_THRESHOLD)) - && !(player->pflags & PF_DRILLING) - && !metalrecording) - continue; - - bust: - topheight = P_GetFOFTopZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); - bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); - - if (((player->charability == CA_TWINSPIN) && (player->panim == PA_ABILITY)) - || ((P_MobjFlip(player->mo)*player->mo->momz < 0) && (player->pflags & PF_BOUNCING || ((player->charability2 == CA2_MELEE) && (player->panim == PA_ABILITY2))))) - { - topheight -= player->mo->momz; - bottomheight -= player->mo->momz; - } - - // Height checks - if (rover->flags & FF_SHATTERBOTTOM) - { - if (player->mo->z+player->mo->momz + player->mo->height < bottomheight) - continue; - - if (player->mo->z+player->mo->height > bottomheight) - continue; - } - else if (rover->flags & FF_SPINBUST) - { - if (player->mo->z+player->mo->momz > topheight) - continue; - - if (player->mo->z + player->mo->height < bottomheight) - continue; - } - else if (rover->flags & FF_SHATTER) - { - if (player->mo->z + player->mo->momz > topheight) - continue; - - if (player->mo->z+player->mo->momz + player->mo->height < bottomheight) - continue; - } - else - { - if (player->mo->z >= topheight) - continue; - - if (player->mo->z + player->mo->height < bottomheight) - continue; - } - - // Impede the player's fall a bit - if (((rover->flags & FF_SPINBUST) || (rover->flags & FF_SHATTER)) && player->mo->z >= topheight) - player->mo->momz >>= 1; - else if (rover->flags & FF_SHATTER) - { - player->mo->momx >>= 1; - player->mo->momy >>= 1; - } - - //if (metalrecording) - // G_RecordBustup(rover); - - EV_CrumbleChain(NULL, rover); // node->m_sector - - // Run a linedef executor?? - if (rover->master->flags & ML_EFFECT5) - P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), player->mo, node->m_sector); - - goto bustupdone; - } + topheight -= player->mo->momz; + bottomheight -= player->mo->momz; } + + // Height checks + if (rover->flags & FF_SHATTERBOTTOM) + { + if (player->mo->z + player->mo->momz + player->mo->height < bottomheight) + continue; + + if (player->mo->z + player->mo->height > bottomheight) + continue; + } + else if (rover->flags & FF_SPINBUST) + { + if (player->mo->z + player->mo->momz > topheight) + continue; + + if (player->mo->z + player->mo->height < bottomheight) + continue; + } + else if (rover->flags & FF_SHATTER) + { + if (player->mo->z + player->mo->momz > topheight) + continue; + + if (player->mo->z + player->mo->momz + player->mo->height < bottomheight) + continue; + } + else + { + if (player->mo->z >= topheight) + continue; + + if (player->mo->z + player->mo->height < bottomheight) + continue; + } + + // Impede the player's fall a bit + if (((rover->flags & FF_SPINBUST) || (rover->flags & FF_SHATTER)) && player->mo->z >= topheight) + player->mo->momz >>= 1; + else if (rover->flags & FF_SHATTER) + { + player->mo->momx >>= 1; + player->mo->momy >>= 1; + } + + //if (metalrecording) + // G_RecordBustup(rover); + + EV_CrumbleChain(NULL, rover); // node->m_sector + + // Run a linedef executor?? + if (rover->master->flags & ML_EFFECT5) + P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), player->mo, node->m_sector); + + goto bustupdone; } } bustupdone: From d0d25025e122abbeb5eaea121aebc8962910500e Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sun, 3 May 2020 10:01:58 +0200 Subject: [PATCH 14/42] Refactor P_CheckBouncySectors --- src/p_user.c | 197 ++++++++++++++++++++++++--------------------------- 1 file changed, 92 insertions(+), 105 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index e7dc69c1f..3296269cb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2729,122 +2729,109 @@ static void P_CheckBouncySectors(player_t *player) for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { + ffloor_t *rover; + if (!node->m_sector) break; - if (node->m_sector->ffloors) + if (!node->m_sector->ffloors) + continue; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) { - ffloor_t *rover; - boolean top = true; + fixed_t bouncestrength; fixed_t topheight, bottomheight; - for (rover = node->m_sector->ffloors; rover; rover = rover->next) + if (!(rover->flags & FF_EXISTS)) + continue; // FOFs should not be bouncy if they don't even "exist" + + if (GETSECSPECIAL(rover->master->frontsector->special, 1) != 15) + continue; // this sector type is required for FOFs to be bouncy + + topheight = P_GetFOFTopZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); + bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); + + if (player->mo->z > topheight) + continue; + + if (player->mo->z + player->mo->height < bottomheight) + continue; + + bouncestrength = P_AproxDistance(rover->master->dx, rover->master->dy)/100; + + if (oldz < P_GetFOFTopZ(player->mo, node->m_sector, rover, oldx, oldy, NULL) + && oldz + player->mo->height > P_GetFOFBottomZ(player->mo, node->m_sector, rover, oldx, oldy, NULL)) { - if (!(rover->flags & FF_EXISTS)) - continue; // FOFs should not be bouncy if they don't even "exist" - - if (GETSECSPECIAL(rover->master->frontsector->special, 1) != 15) - continue; // this sector type is required for FOFs to be bouncy - - topheight = P_GetFOFTopZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); - bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); - - if (player->mo->z > topheight) - continue; - - if (player->mo->z + player->mo->height < bottomheight) - continue; - - if (oldz < P_GetFOFTopZ(player->mo, node->m_sector, rover, oldx, oldy, NULL) - && oldz + player->mo->height > P_GetFOFBottomZ(player->mo, node->m_sector, rover, oldx, oldy, NULL)) - top = false; + player->mo->momx = -FixedMul(player->mo->momx,bouncestrength); + player->mo->momy = -FixedMul(player->mo->momy,bouncestrength); + if (player->pflags & PF_SPINNING) { - fixed_t linedist; - - linedist = P_AproxDistance(rover->master->v1->x-rover->master->v2->x, rover->master->v1->y-rover->master->v2->y); - - linedist = FixedDiv(linedist,100*FRACUNIT); - - if (top) - { - fixed_t newmom; - - pslope_t *slope; - if (abs(oldz - topheight) < abs(oldz + player->mo->height - bottomheight)) { // Hit top - slope = *rover->t_slope; - } else { // Hit bottom - slope = *rover->b_slope; - } - - momentum.x = player->mo->momx; - momentum.y = player->mo->momy; - momentum.z = player->mo->momz*2; - - if (slope) - P_ReverseQuantizeMomentumToSlope(&momentum, slope); - - newmom = momentum.z = -FixedMul(momentum.z,linedist)/2; - - if (abs(newmom) < (linedist*2)) - { - goto bouncydone; - } - - if (!(rover->master->flags & ML_BOUNCY)) - { - if (newmom > 0) - { - if (newmom < 8*FRACUNIT) - newmom = 8*FRACUNIT; - } - else if (newmom > -8*FRACUNIT && newmom != 0) - newmom = -8*FRACUNIT; - } - - if (newmom > P_GetPlayerHeight(player)/2) - newmom = P_GetPlayerHeight(player)/2; - else if (newmom < -P_GetPlayerHeight(player)/2) - newmom = -P_GetPlayerHeight(player)/2; - - momentum.z = newmom*2; - - if (slope) - P_QuantizeMomentumToSlope(&momentum, slope); - - player->mo->momx = momentum.x; - player->mo->momy = momentum.y; - player->mo->momz = momentum.z/2; - - if (player->pflags & PF_SPINNING) - { - player->pflags &= ~PF_SPINNING; - player->pflags |= P_GetJumpFlags(player); - player->pflags |= PF_THOKKED; - } - } - else - { - player->mo->momx = -FixedMul(player->mo->momx,linedist); - player->mo->momy = -FixedMul(player->mo->momy,linedist); - - if (player->pflags & PF_SPINNING) - { - player->pflags &= ~PF_SPINNING; - player->pflags |= P_GetJumpFlags(player); - player->pflags |= PF_THOKKED; - } - } - - if ((player->pflags & PF_SPINNING) && player->speed < FixedMul(1<mo->scale) && player->mo->momz) - { - player->pflags &= ~PF_SPINNING; - player->pflags |= P_GetJumpFlags(player); - } - - goto bouncydone; + player->pflags &= ~PF_SPINNING; + player->pflags |= P_GetJumpFlags(player); + player->pflags |= PF_THOKKED; } } + else + { + fixed_t newmom; + pslope_t *slope = (abs(oldz - topheight) < abs(oldz + player->mo->height - bottomheight)) ? *rover->t_slope : *rover->b_slope; + + momentum.x = player->mo->momx; + momentum.y = player->mo->momy; + momentum.z = player->mo->momz*2; + + if (slope) + P_ReverseQuantizeMomentumToSlope(&momentum, slope); + + newmom = momentum.z = -FixedMul(momentum.z,bouncestrength)/2; + + if (abs(newmom) < (bouncestrength*2)) + goto bouncydone; + + if (!(rover->master->flags & ML_BOUNCY)) + { + if (newmom > 0) + { + if (newmom < 8*FRACUNIT) + newmom = 8*FRACUNIT; + } + else if (newmom < 0) + { + if (newmom > -8*FRACUNIT) + newmom = -8*FRACUNIT; + } + } + + if (newmom > P_GetPlayerHeight(player)/2) + newmom = P_GetPlayerHeight(player)/2; + else if (newmom < -P_GetPlayerHeight(player)/2) + newmom = -P_GetPlayerHeight(player)/2; + + momentum.z = newmom*2; + + if (slope) + P_QuantizeMomentumToSlope(&momentum, slope); + + player->mo->momx = momentum.x; + player->mo->momy = momentum.y; + player->mo->momz = momentum.z/2; + + if (player->pflags & PF_SPINNING) + { + player->pflags &= ~PF_SPINNING; + player->pflags |= P_GetJumpFlags(player); + player->pflags |= PF_THOKKED; + } + } + + if ((player->pflags & PF_SPINNING) && player->speed < FixedMul(1<mo->scale) && player->mo->momz) + { + player->pflags &= ~PF_SPINNING; + player->pflags |= P_GetJumpFlags(player); + } + + goto bouncydone; } } bouncydone: From fc07db26c0697a5c12eaae3fcede5c733efbc77f Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 17 May 2020 20:09:11 +0200 Subject: [PATCH 15/42] Store starttic as a raw value in PT_SERVERTICS packets This avoids some desynch issues and is simpler to handle. Those packets are always big anyway, so the difference is irrelevant. --- src/d_clisrv.c | 4 ++-- src/d_clisrv.h | 2 +- src/d_net.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ed0b8e528..d6af642df 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4252,7 +4252,7 @@ static void HandlePacketFromPlayer(SINT8 node) break; } - realstart = ExpandTics(netbuffer->u.serverpak.starttic); + realstart = netbuffer->u.serverpak.starttic; realend = realstart + netbuffer->u.serverpak.numtics; if (!txtpak) @@ -4659,7 +4659,7 @@ static void SV_SendTics(void) // Send the tics netbuffer->packettype = PT_SERVERTICS; - netbuffer->u.serverpak.starttic = (UINT8)realfirsttic; + netbuffer->u.serverpak.starttic = realfirsttic; netbuffer->u.serverpak.numtics = (UINT8)(lasttictosend - realfirsttic); netbuffer->u.serverpak.numslots = (UINT8)SHORT(doomcom->numslots); bufpos = (UINT8 *)&netbuffer->u.serverpak.cmds; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 463240a2a..63597f832 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -128,7 +128,7 @@ typedef struct // this packet is too large typedef struct { - UINT8 starttic; + tic_t starttic; UINT8 numtics; UINT8 numslots; // "Slots filled": Highest player number in use plus one. ticcmd_t cmds[45]; // Normally [BACKUPTIC][MAXPLAYERS] but too large diff --git a/src/d_net.c b/src/d_net.c index a6768d75d..6d137fc62 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -838,7 +838,7 @@ static void DebugPrintpacket(const char *header) size_t ntxtcmd = &((UINT8 *)netbuffer)[doomcom->datalength] - cmd; fprintf(debugfile, " firsttic %u ply %d tics %d ntxtcmd %s\n ", - (UINT32)ExpandTics(serverpak->starttic), serverpak->numslots, serverpak->numtics, sizeu1(ntxtcmd)); + (UINT32)serverpak->starttic, serverpak->numslots, serverpak->numtics, sizeu1(ntxtcmd)); /// \todo Display more readable information about net commands fprintfstringnewline((char *)cmd, ntxtcmd); /*fprintfstring((char *)cmd, 3); From e49d3d0bb9e27710f123120ccc6afcb578849855 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 17 May 2020 20:23:07 +0200 Subject: [PATCH 16/42] Use per-node reference tics in ExpandTics --- src/d_clisrv.c | 17 +++++++++-------- src/d_clisrv.h | 2 +- src/d_net.c | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d6af642df..9c9e55026 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -195,24 +195,25 @@ static inline void *G_ScpyTiccmd(ticcmd_t* dest, void* src, const size_t n) // of 512 bytes is like 0.1) UINT16 software_MAXPACKETLENGTH; -/** Guesses the value of a tic from its lowest byte and from maketic +/** Guesses the full value of a tic from its lowest byte, for a specific node * * \param low The lowest byte of the tic value + * \param node The node to deduce the tic for * \return The full tic value * */ -tic_t ExpandTics(INT32 low) +tic_t ExpandTics(INT32 low, INT32 node) { INT32 delta; - delta = low - (maketic & UINT8_MAX); + delta = low - (nettics[node] & UINT8_MAX); if (delta >= -64 && delta <= 64) - return (maketic & ~UINT8_MAX) + low; + return (nettics[node] & ~UINT8_MAX) + low; else if (delta > 64) - return (maketic & ~UINT8_MAX) - 256 + low; + return (nettics[node] & ~UINT8_MAX) - 256 + low; else //if (delta < -64) - return (maketic & ~UINT8_MAX) + 256 + low; + return (nettics[node] & ~UINT8_MAX) + 256 + low; } // ----------------------------------------------------------------- @@ -3999,8 +4000,8 @@ static void HandlePacketFromPlayer(SINT8 node) // To save bytes, only the low byte of tic numbers are sent // Use ExpandTics to figure out what the rest of the bytes are - realstart = ExpandTics(netbuffer->u.clientpak.client_tic); - realend = ExpandTics(netbuffer->u.clientpak.resendfrom); + realstart = ExpandTics(netbuffer->u.clientpak.client_tic, node); + realend = ExpandTics(netbuffer->u.clientpak.resendfrom, node); if (netbuffer->packettype == PT_CLIENTMIS || netbuffer->packettype == PT_CLIENT2MIS || netbuffer->packettype == PT_NODEKEEPALIVEMIS diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 63597f832..e284522e7 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -520,7 +520,7 @@ extern consvar_t cv_resynchattempts, cv_blamecfail; extern consvar_t cv_maxsend, cv_noticedownload, cv_downloadspeed; // Used in d_net, the only dependence -tic_t ExpandTics(INT32 low); +tic_t ExpandTics(INT32 low, INT32 node); void D_ClientServerInit(void); // Initialise the other field diff --git a/src/d_net.c b/src/d_net.c index 6d137fc62..8e62b8d25 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -857,8 +857,8 @@ static void DebugPrintpacket(const char *header) case PT_NODEKEEPALIVE: case PT_NODEKEEPALIVEMIS: fprintf(debugfile, " tic %4u resendfrom %u\n", - (UINT32)ExpandTics(netbuffer->u.clientpak.client_tic), - (UINT32)ExpandTics (netbuffer->u.clientpak.resendfrom)); + (UINT32)ExpandTics(netbuffer->u.clientpak.client_tic, doomcom->remotenode), + (UINT32)ExpandTics (netbuffer->u.clientpak.resendfrom, doomcom->remotenode)); break; case PT_TEXTCMD: case PT_TEXTCMD2: From 56cc5190e5831cf0474268b16de29f0b873eb5d1 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Mon, 18 May 2020 11:34:09 +0200 Subject: [PATCH 17/42] Allow input buffer to hold more than 64 tics --- src/d_clisrv.c | 12 ++++++------ src/d_clisrv.h | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 9c9e55026..5424718dd 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4260,8 +4260,8 @@ static void HandlePacketFromPlayer(SINT8 node) txtpak = (UINT8 *)&netbuffer->u.serverpak.cmds[netbuffer->u.serverpak.numslots * netbuffer->u.serverpak.numtics]; - if (realend > gametic + BACKUPTICS) - realend = gametic + BACKUPTICS; + if (realend > gametic + CLIENTBACKUPTICS) + realend = gametic + CLIENTBACKUPTICS; cl_packetmissed = realstart > neededtic; if (realstart <= neededtic && realend > neededtic) @@ -4604,11 +4604,11 @@ static void SV_SendTics(void) for (n = 1; n < MAXNETNODES; n++) if (nodeingame[n]) { - lasttictosend = maketic; - // assert supposedtics[n]>=nettics[n] realfirsttic = supposedtics[n]; - if (realfirsttic >= maketic) + lasttictosend = min(maketic, realfirsttic + CLIENTBACKUPTICS); + + if (realfirsttic >= lasttictosend) { // well we have sent all tics we will so use extrabandwidth // to resent packet that are supposed lost (this is necessary since lost @@ -4617,7 +4617,7 @@ static void SV_SendTics(void) DEBFILE(va("Nothing to send node %u mak=%u sup=%u net=%u \n", n, maketic, supposedtics[n], nettics[n])); realfirsttic = nettics[n]; - if (realfirsttic >= maketic || (I_GetTime() + n)&3) + if (realfirsttic >= lasttictosend || (I_GetTime() + n)&3) // all tic are ok continue; DEBFILE(va("Sent %d anyway\n", realfirsttic)); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index e284522e7..583c3c8db 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -34,6 +34,7 @@ applications may follow different packet versions. // Networking and tick handling related. #define BACKUPTICS 96 +#define CLIENTBACKUPTICS 32 #define MAXTEXTCMD 256 // // Packet structure From dd42682791ce98d4c8b418ecc065130ae9faed55 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 19 May 2020 16:48:50 +0100 Subject: [PATCH 18/42] remove gxt and gyt, as they are unnecessary also add a few comments to explain what tx/tz are --- src/r_things.c | 40 +++++++++------------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 8a3c2e35f..febb5b6dc 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1346,7 +1346,6 @@ static void R_ProjectSprite(mobj_t *thing) { mobj_t *oldthing = thing; fixed_t tr_x, tr_y; - fixed_t gxt, gyt; fixed_t tx, tz; fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! @@ -1399,18 +1398,13 @@ static void R_ProjectSprite(mobj_t *thing) tr_x = thing->x - viewx; tr_y = thing->y - viewy; - gxt = FixedMul(tr_x, viewcos); - gyt = -FixedMul(tr_y, viewsin); - - tz = gxt-gyt; + tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance // thing is behind view plane? if (!papersprite && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later return; - gxt = -FixedMul(tr_x, viewsin); - gyt = FixedMul(tr_y, viewcos); - basetx = tx = -(gyt + gxt); + basetx = tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance // too far off the side? if (!papersprite && abs(tx) > tz<<2) // papersprite clipping is handled later @@ -1561,15 +1555,11 @@ static void R_ProjectSprite(mobj_t *thing) tr_x += FixedMul(offset, cosmul); tr_y += FixedMul(offset, sinmul); - gxt = FixedMul(tr_x, viewcos); - gyt = -FixedMul(tr_y, viewsin); - tz = gxt-gyt; + tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); yscale = FixedDiv(projectiony, tz); //if (yscale < 64) return; // Fix some funky visuals - gxt = -FixedMul(tr_x, viewsin); - gyt = FixedMul(tr_y, viewcos); - tx = -(gyt + gxt); + tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); xscale = FixedDiv(projection, tz); x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; @@ -1585,15 +1575,11 @@ static void R_ProjectSprite(mobj_t *thing) tr_x += FixedMul(offset2, cosmul); tr_y += FixedMul(offset2, sinmul); - gxt = FixedMul(tr_x, viewcos); - gyt = -FixedMul(tr_y, viewsin); - tz2 = gxt-gyt; + tz2 = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); yscale2 = FixedDiv(projectiony, tz2); //if (yscale2 < 64) return; // ditto - gxt = -FixedMul(tr_x, viewsin); - gyt = FixedMul(tr_y, viewcos); - tx2 = -(gyt + gxt); + tx2 = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); xscale2 = FixedDiv(projection, tz2); x2 = ((centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS); @@ -1670,9 +1656,7 @@ static void R_ProjectSprite(mobj_t *thing) tr_x = thing->x - viewx; tr_y = thing->y - viewy; - gxt = FixedMul(tr_x, viewcos); - gyt = -FixedMul(tr_y, viewsin); - tz = gxt-gyt; + tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); linkscale = FixedDiv(projectiony, tz); if (tz < FixedMul(MINZ, this_scale)) @@ -1872,7 +1856,6 @@ static void R_ProjectSprite(mobj_t *thing) static void R_ProjectPrecipitationSprite(precipmobj_t *thing) { fixed_t tr_x, tr_y; - fixed_t gxt, gyt; fixed_t tx, tz; fixed_t xscale, yscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! @@ -1893,18 +1876,13 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) tr_x = thing->x - viewx; tr_y = thing->y - viewy; - gxt = FixedMul(tr_x, viewcos); - gyt = -FixedMul(tr_y, viewsin); - - tz = gxt - gyt; + tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance // thing is behind view plane? if (tz < MINZ) return; - gxt = -FixedMul(tr_x, viewsin); - gyt = FixedMul(tr_y, viewcos); - tx = -(gyt + gxt); + tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance // too far off the side? if (abs(tx) > tz<<2) From c8320b6c9dad1996a96557858c00e1f5f9f9a4c9 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 19 May 2020 16:58:53 +0100 Subject: [PATCH 19/42] split "rot" into two variables: frame and rot, for frame number and rotation angle it always bothered me that "rot" was used for both of the above, since it confused me as to what it was for every time I look at this function --- src/r_things.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index febb5b6dc..cd19dfa90 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1358,7 +1358,7 @@ static void R_ProjectSprite(mobj_t *thing) #endif size_t lump; - size_t rot; + size_t frame, rot; UINT16 flip; boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP)); @@ -1420,7 +1420,7 @@ static void R_ProjectSprite(mobj_t *thing) I_Error("R_ProjectSprite: invalid sprite number %d ", thing->sprite); #endif - rot = thing->frame&FF_FRAMEMASK; + frame = thing->frame&FF_FRAMEMASK; //Fab : 02-08-98: 'skin' override spritedef currently used for skin if (thing->skin && thing->sprite == SPR_PLAY) @@ -1429,15 +1429,15 @@ static void R_ProjectSprite(mobj_t *thing) #ifdef ROTSPRITE sprinfo = &((skin_t *)thing->skin)->sprinfo[thing->sprite2]; #endif - if (rot >= sprdef->numframes) { - CONS_Alert(CONS_ERROR, M_GetText("R_ProjectSprite: invalid skins[\"%s\"].sprites[%sSPR2_%s] frame %s\n"), ((skin_t *)thing->skin)->name, ((thing->sprite2 & FF_SPR2SUPER) ? "FF_SPR2SUPER|": ""), spr2names[(thing->sprite2 & ~FF_SPR2SUPER)], sizeu5(rot)); + if (frame >= sprdef->numframes) { + CONS_Alert(CONS_ERROR, M_GetText("R_ProjectSprite: invalid skins[\"%s\"].sprites[%sSPR2_%s] frame %s\n"), ((skin_t *)thing->skin)->name, ((thing->sprite2 & FF_SPR2SUPER) ? "FF_SPR2SUPER|": ""), spr2names[(thing->sprite2 & ~FF_SPR2SUPER)], sizeu5(frame)); thing->sprite = states[S_UNKNOWN].sprite; thing->frame = states[S_UNKNOWN].frame; sprdef = &sprites[thing->sprite]; #ifdef ROTSPRITE sprinfo = NULL; #endif - rot = thing->frame&FF_FRAMEMASK; + frame = thing->frame&FF_FRAMEMASK; } } else @@ -1447,10 +1447,10 @@ static void R_ProjectSprite(mobj_t *thing) sprinfo = NULL; #endif - if (rot >= sprdef->numframes) + if (frame >= sprdef->numframes) { CONS_Alert(CONS_ERROR, M_GetText("R_ProjectSprite: invalid sprite frame %s/%s for %s\n"), - sizeu1(rot), sizeu2(sprdef->numframes), sprnames[thing->sprite]); + sizeu1(frame), sizeu2(sprdef->numframes), sprnames[thing->sprite]); if (thing->sprite == thing->state->sprite && thing->frame == thing->state->frame) { thing->state->sprite = states[S_UNKNOWN].sprite; @@ -1459,11 +1459,11 @@ static void R_ProjectSprite(mobj_t *thing) thing->sprite = states[S_UNKNOWN].sprite; thing->frame = states[S_UNKNOWN].frame; sprdef = &sprites[thing->sprite]; - rot = thing->frame&FF_FRAMEMASK; + frame = thing->frame&FF_FRAMEMASK; } } - sprframe = &sprdef->spriteframes[rot]; + sprframe = &sprdef->spriteframes[frame]; #ifdef PARANOIA if (!sprframe) @@ -1517,7 +1517,7 @@ static void R_ProjectSprite(mobj_t *thing) { rollangle = R_GetRollAngle(thing->rollangle); if (!(sprframe->rotsprite.cached & (1<sprite, (thing->frame & FF_FRAMEMASK), sprinfo, sprframe, rot, flip); + R_CacheRotSprite(thing->sprite, frame, sprinfo, sprframe, rot, flip); rotsprite = sprframe->rotsprite.patch[rot][rollangle]; if (rotsprite != NULL) { From 1a790235c69833f31e915586b6358c501ef87c20 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 19 May 2020 17:19:44 +0100 Subject: [PATCH 20/42] added basic culling of papersprites if tx for either is too large, proper clamping to be added later also removed some commented out old code --- src/r_things.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index cd19dfa90..27a7c0bb6 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1557,7 +1557,6 @@ static void R_ProjectSprite(mobj_t *thing) tr_y += FixedMul(offset, sinmul); tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); yscale = FixedDiv(projectiony, tz); - //if (yscale < 64) return; // Fix some funky visuals tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); xscale = FixedDiv(projection, tz); @@ -1577,7 +1576,6 @@ static void R_ProjectSprite(mobj_t *thing) tr_y += FixedMul(offset2, sinmul); tz2 = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); yscale2 = FixedDiv(projectiony, tz2); - //if (yscale2 < 64) return; // ditto tx2 = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); xscale2 = FixedDiv(projection, tz2); @@ -1586,6 +1584,9 @@ static void R_ProjectSprite(mobj_t *thing) if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier return; + if (tx2 < -(tz2<<2) || tx > tz<<2) // too far off the side? + return; + // Needs partially clipped if (tz < FixedMul(MINZ, this_scale)) { @@ -1606,6 +1607,8 @@ static void R_ProjectSprite(mobj_t *thing) x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS; } + // TODO: tx clamping + // off the right side? if (x1 > viewwidth) return; From 12e109414384ab80c702382a7fa2549c6eec26a1 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 19 May 2020 17:23:22 +0100 Subject: [PATCH 21/42] We don't actually need x1 or x2 until these points in the function, at least for papersprites --- src/r_things.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 27a7c0bb6..a4bd19627 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1560,7 +1560,6 @@ static void R_ProjectSprite(mobj_t *thing) tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); xscale = FixedDiv(projection, tz); - x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; // Get paperoffset (offset) and paperoffset (distance) paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul); @@ -1579,7 +1578,6 @@ static void R_ProjectSprite(mobj_t *thing) tx2 = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); xscale2 = FixedDiv(projection, tz2); - x2 = ((centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS); if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier return; @@ -1595,7 +1593,6 @@ static void R_ProjectSprite(mobj_t *thing) tz = FixedMul(MINZ, this_scale); yscale = FixedDiv(projectiony, tz); xscale = FixedDiv(projection, tz); - x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; } else if (tz2 < FixedMul(MINZ, this_scale)) { @@ -1604,15 +1601,18 @@ static void R_ProjectSprite(mobj_t *thing) tz2 = FixedMul(MINZ, this_scale); yscale2 = FixedDiv(projectiony, tz2); xscale2 = FixedDiv(projection, tz2); - x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS; } // TODO: tx clamping + x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + // off the right side? if (x1 > viewwidth) return; + x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS; + // off the left side if (x2 < 0) return; From 35e5d673e08485e685a0f7660397348f81e2982d Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 19 May 2020 18:43:33 +0100 Subject: [PATCH 22/42] do tx checking after tz clamping, not before --- src/r_things.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index a4bd19627..6bdb7cae8 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1582,9 +1582,6 @@ static void R_ProjectSprite(mobj_t *thing) if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier return; - if (tx2 < -(tz2<<2) || tx > tz<<2) // too far off the side? - return; - // Needs partially clipped if (tz < FixedMul(MINZ, this_scale)) { @@ -1603,6 +1600,9 @@ static void R_ProjectSprite(mobj_t *thing) xscale2 = FixedDiv(projection, tz2); } + if (tx2 < -(tz2<<2) || tx > tz<<2) // too far off the side? + return; + // TODO: tx clamping x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; From 65d6b04fd283a76bc505b1aab81abe3583038ea3 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 19 May 2020 18:54:39 +0100 Subject: [PATCH 23/42] change limits for tx based on fov, by multiplying by fovtan this makes it so that higher fov values can actually let you see all the sprites that should be in the view --- src/r_things.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 6bdb7cae8..a29fb6cb7 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1407,7 +1407,7 @@ static void R_ProjectSprite(mobj_t *thing) basetx = tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance // too far off the side? - if (!papersprite && abs(tx) > tz<<2) // papersprite clipping is handled later + if (!papersprite && abs(tx) > FixedMul(tz, fovtan)<<2) // papersprite clipping is handled later return; // aspect ratio stuff @@ -1600,7 +1600,7 @@ static void R_ProjectSprite(mobj_t *thing) xscale2 = FixedDiv(projection, tz2); } - if (tx2 < -(tz2<<2) || tx > tz<<2) // too far off the side? + if (tx2 < -(FixedMul(tz2, fovtan)<<2) || tx > FixedMul(tz, fovtan)<<2) // too far off the side? return; // TODO: tx clamping From c3d576058a2f59833026a3ef6fd1a9c35524c5ab Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 19 May 2020 22:00:34 +0100 Subject: [PATCH 24/42] on second thought maybe we don't need extra tx clamping, it turns out to be more effort than it's worth (at least for now) meanwhile, let's move x/yscale calculations down since we don't actually need them until later on --- src/r_things.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index a29fb6cb7..a40c61058 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1556,10 +1556,8 @@ static void R_ProjectSprite(mobj_t *thing) tr_x += FixedMul(offset, cosmul); tr_y += FixedMul(offset, sinmul); tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); - yscale = FixedDiv(projectiony, tz); tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); - xscale = FixedDiv(projection, tz); // Get paperoffset (offset) and paperoffset (distance) paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul); @@ -1574,10 +1572,8 @@ static void R_ProjectSprite(mobj_t *thing) tr_x += FixedMul(offset2, cosmul); tr_y += FixedMul(offset2, sinmul); tz2 = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); - yscale2 = FixedDiv(projectiony, tz2); tx2 = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); - xscale2 = FixedDiv(projection, tz2); if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier return; @@ -1588,22 +1584,19 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t div = FixedDiv(tz2-tz, FixedMul(MINZ, this_scale)-tz); tx += FixedDiv(tx2-tx, div); tz = FixedMul(MINZ, this_scale); - yscale = FixedDiv(projectiony, tz); - xscale = FixedDiv(projection, tz); } else if (tz2 < FixedMul(MINZ, this_scale)) { fixed_t div = FixedDiv(tz-tz2, FixedMul(MINZ, this_scale)-tz2); tx2 += FixedDiv(tx-tx2, div); tz2 = FixedMul(MINZ, this_scale); - yscale2 = FixedDiv(projectiony, tz2); - xscale2 = FixedDiv(projection, tz2); } if (tx2 < -(FixedMul(tz2, fovtan)<<2) || tx > FixedMul(tz, fovtan)<<2) // too far off the side? return; - // TODO: tx clamping + yscale = FixedDiv(projectiony, tz); + xscale = FixedDiv(projection, tz); x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; @@ -1611,6 +1604,9 @@ static void R_ProjectSprite(mobj_t *thing) if (x1 > viewwidth) return; + yscale2 = FixedDiv(projectiony, tz2); + xscale2 = FixedDiv(projection, tz2); + x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS; // off the left side From 934b28989f4b58d5ed2a24567af76251d9bc6db8 Mon Sep 17 00:00:00 2001 From: sphere Date: Tue, 19 May 2020 23:39:35 +0200 Subject: [PATCH 25/42] Add linedef actions 507 & 508, allow using offsets for actions 502-504. --- extras/conf/SRB2-22.cfg | 22 ++++++++++++++++++++-- src/p_spec.c | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index 7b1b678f2..f4a4baead 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -2611,31 +2611,49 @@ linedeftypes { title = "Scroll Wall According to Linedef"; prefix = "(502)"; + flags128text = "[7] Use texture offsets"; + flags256text = "[8] Scroll back side"; } 503 { title = "Scroll Wall According to Linedef (Accelerative)"; prefix = "(503)"; + flags128text = "[7] Use texture offsets"; + flags256text = "[8] Scroll back side"; } 504 { title = "Scroll Wall According to Linedef (Displacement)"; prefix = "(504)"; + flags128text = "[7] Use texture offsets"; + flags256text = "[8] Scroll back side"; } 505 { - title = "Scroll Texture by Front Side Offsets"; + title = "Scroll Front Wall by Front Side Offsets"; prefix = "(505)"; } 506 { - title = "Scroll Texture by Back Side Offsets"; + title = "Scroll Front Wall by Back Side Offsets"; prefix = "(506)"; } + + 507 + { + title = "Scroll Back Wall by Front Side Offsets"; + prefix = "(507)"; + } + + 508 + { + title = "Scroll Back Wall by Back Side Offsets"; + prefix = "(508)"; + } } planescroll diff --git a/src/p_spec.c b/src/p_spec.c index d45a33c47..6bf5b59bc 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7065,6 +7065,9 @@ void P_SpawnSpecials(boolean fromnetsave) // 503 is used for a scroller // 504 is used for a scroller // 505 is used for a scroller + // 506 is used for a scroller + // 507 is used for a scroller + // 508 is used for a scroller // 510 is used for a scroller // 511 is used for a scroller // 512 is used for a scroller @@ -7581,7 +7584,20 @@ static void P_SpawnScrollers(void) case 502: for (s = -1; (s = P_FindLineFromTag(l->tag, s)) >= 0 ;) if (s != (INT32)i) - Add_Scroller(sc_side, dx, dy, control, lines[s].sidenum[0], accel, 0); + { + if (l->flags & ML_EFFECT2) // use texture offsets instead + { + dx = sides[l->sidenum[0]].textureoffset; + dy = sides[l->sidenum[0]].rowoffset; + } + if (l->flags & ML_EFFECT3) + { + if (lines[s].sidenum[1] != 0xffff) + Add_Scroller(sc_side, dx, dy, control, lines[s].sidenum[1], accel, 0); + } + else + Add_Scroller(sc_side, dx, dy, control, lines[s].sidenum[0], accel, 0); + } break; case 505: @@ -7595,7 +7611,25 @@ static void P_SpawnScrollers(void) if (s != 0xffff) Add_Scroller(sc_side, -sides[s].textureoffset, sides[s].rowoffset, -1, lines[i].sidenum[0], accel, 0); else - CONS_Debug(DBG_GAMELOGIC, "Line special 506 (line #%s) missing 2nd side!\n", sizeu1(i)); + CONS_Debug(DBG_GAMELOGIC, "Line special 506 (line #%s) missing back side!\n", sizeu1(i)); + break; + + case 507: + s = lines[i].sidenum[0]; + + if (lines[i].sidenum[1] != 0xffff) + Add_Scroller(sc_side, -sides[s].textureoffset, sides[s].rowoffset, -1, lines[i].sidenum[1], accel, 0); + else + CONS_Debug(DBG_GAMELOGIC, "Line special 507 (line #%s) missing back side!\n", sizeu1(i)); + break; + + case 508: + s = lines[i].sidenum[1]; + + if (s != 0xffff) + Add_Scroller(sc_side, -sides[s].textureoffset, sides[s].rowoffset, -1, s, accel, 0); + else + CONS_Debug(DBG_GAMELOGIC, "Line special 508 (line #%s) missing back side!\n", sizeu1(i)); break; case 500: // scroll first side From 702a7041d4e7f3274e6c05347e72c8bc0952cf1d Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 20 May 2020 19:34:18 +0100 Subject: [PATCH 26/42] also do the fovtan multiplication thing with precip sprites --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index a40c61058..14782d0c2 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1884,7 +1884,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance // too far off the side? - if (abs(tx) > tz<<2) + if (abs(tx) > FixedMul(tz, fovtan)<<2) return; // aspect ratio stuff : From c9c7327011487ec9925e81c9d322af72c93e9487 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 21 May 2020 19:42:48 +0100 Subject: [PATCH 27/42] A_SplitShot fix: don't even attempt to A_FaceTarget (or anything beyond) if there is no target to face to begin with --- src/p_enemy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_enemy.c b/src/p_enemy.c index 061d4d366..bd8a2b054 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -9707,6 +9707,9 @@ void A_SplitShot(mobj_t *actor) if (LUA_CallAction("A_SplitShot", actor)) return; + if (!actor->target) + return; + A_FaceTarget(actor); { const angle_t an = (actor->angle + ANGLE_90) >> ANGLETOFINESHIFT; From 4b7f0f49f18e709fcb7d223940a0f0afd489fc2e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 22 May 2020 18:32:34 +0100 Subject: [PATCH 28/42] added the ability to get the # of a mapthing_t in Lua --- src/lua_mobjlib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 81729b788..ac1432b4c 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -829,6 +829,15 @@ static int mapthing_set(lua_State *L) return 0; } +static int mapthing_num(lua_State *L) +{ + mapthing_t *mt = *((mapthing_t **)luaL_checkudata(L, 1, META_MAPTHING)); + if (!mt) + return luaL_error(L, "accessed mapthing_t doesn't exist anymore."); + lua_pushinteger(L, mt-mapthings); + return 1; +} + static int lib_iterateMapthings(lua_State *L) { size_t i = 0; @@ -893,6 +902,9 @@ int LUA_MobjLib(lua_State *L) lua_pushcfunction(L, mapthing_set); lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, mapthing_num); + lua_setfield(L, -2, "__len"); lua_pop(L,1); lua_newuserdata(L, 0); From d6ea89de6fb7fabd13f7aa7bbc19c92e3511aa46 Mon Sep 17 00:00:00 2001 From: sphere Date: Sat, 23 May 2020 16:41:38 +0200 Subject: [PATCH 29/42] Rename the rest of the wall scrollers in the ZB config. --- extras/conf/SRB2-22.cfg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index f4a4baead..5ed05d4d6 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -2597,19 +2597,19 @@ linedeftypes 500 { - title = "Scroll Wall Front Side Left"; + title = "Scroll Front Wall Left"; prefix = "(500)"; } 501 { - title = "Scroll Wall Front Side Right"; + title = "Scroll Front Wall Right"; prefix = "(501)"; } 502 { - title = "Scroll Wall According to Linedef"; + title = "Scroll Tagged Wall"; prefix = "(502)"; flags128text = "[7] Use texture offsets"; flags256text = "[8] Scroll back side"; @@ -2617,7 +2617,7 @@ linedeftypes 503 { - title = "Scroll Wall According to Linedef (Accelerative)"; + title = "Scroll Tagged Wall (Accelerative)"; prefix = "(503)"; flags128text = "[7] Use texture offsets"; flags256text = "[8] Scroll back side"; @@ -2625,7 +2625,7 @@ linedeftypes 504 { - title = "Scroll Wall According to Linedef (Displacement)"; + title = "Scroll Tagged Wall (Displacement)"; prefix = "(504)"; flags128text = "[7] Use texture offsets"; flags256text = "[8] Scroll back side"; From b37c73b0081684d7bfba58fe691430b0fba803fb Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Sat, 23 May 2020 19:29:07 -0500 Subject: [PATCH 30/42] Make colors UINT16, increase color freeslots to 1024 --- src/d_clisrv.c | 4 +-- src/d_clisrv.h | 6 ++-- src/d_netcmd.c | 13 +++---- src/d_player.h | 2 +- src/dehacked.c | 18 +++++----- src/doomdef.h | 6 ++-- src/doomstat.h | 2 +- src/g_demo.c | 83 ++++++++++++++++++++++++++----------------- src/g_game.c | 14 ++++---- src/g_state.h | 3 +- src/hardware/hw_md2.c | 4 +-- src/lua_baselib.c | 12 +++++++ src/lua_hudlib.c | 8 ++--- src/lua_infolib.c | 12 +++---- src/lua_mathlib.c | 2 +- src/lua_mobjlib.c | 2 +- src/lua_playerlib.c | 2 +- src/m_cheat.c | 2 +- src/m_cond.h | 4 +-- src/m_menu.c | 18 +++++----- src/m_menu.h | 18 +++++----- src/p_enemy.c | 23 ++++-------- src/p_mobj.c | 4 +-- src/p_mobj.h | 2 +- src/p_saveg.c | 4 +-- src/p_spec.c | 2 +- src/p_user.c | 4 +-- src/r_draw.c | 10 +++--- src/r_draw.h | 4 +-- src/r_skins.c | 2 +- src/r_skins.h | 6 ++-- src/v_video.c | 2 +- src/v_video.h | 2 +- src/y_inter.c | 6 ++-- 34 files changed, 163 insertions(+), 143 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ed0b8e528..25b156153 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1495,7 +1495,7 @@ static boolean SV_SendServerConfig(INT32 node) if (!playeringame[i]) continue; netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; - netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; + netbuffer->u.servercfg.playercolor[i] = (UINT16)players[i].skincolor; netbuffer->u.servercfg.playeravailabilities[i] = (UINT32)LONG(players[i].availabilities); } @@ -3877,7 +3877,7 @@ static void HandlePacketFromAwayNode(SINT8 node) for (j = 0; j < MAXPLAYERS; j++) { if (netbuffer->u.servercfg.playerskins[j] == 0xFF - && netbuffer->u.servercfg.playercolor[j] == 0xFF + && netbuffer->u.servercfg.playercolor[j] == 0xFFFF && netbuffer->u.servercfg.playeravailabilities[j] == 0xFFFFFFFF) continue; // not in game diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 463240a2a..f15b5ff91 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -188,7 +188,7 @@ typedef struct SINT8 xtralife; SINT8 pity; - UINT8 skincolor; + UINT16 skincolor; INT32 skin; UINT32 availabilities; // Just in case Lua does something like @@ -308,7 +308,7 @@ typedef struct // 0xFF == not in game; else player skin num UINT8 playerskins[MAXPLAYERS]; - UINT8 playercolor[MAXPLAYERS]; + UINT16 playercolor[MAXPLAYERS]; UINT32 playeravailabilities[MAXPLAYERS]; UINT8 gametype; @@ -414,7 +414,7 @@ typedef struct { char name[MAXPLAYERNAME+1]; UINT8 skin; - UINT8 color; + UINT16 color; UINT32 pflags; UINT32 score; UINT8 ctfteam; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 01c14e937..84070135a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -225,7 +225,7 @@ consvar_t cv_allowseenames = {"allowseenames", "Yes", CV_NETVAR, CV_YesNo, NULL, consvar_t cv_playername = {"name", "Sonic", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_playername2 = {"name2", "Tails", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name2_OnChange, 0, NULL, NULL, 0, 0, NULL}; // player colors -UINT8 lastgoodcolor = SKINCOLOR_BLUE, lastgoodcolor2 = SKINCOLOR_BLUE; +UINT16 lastgoodcolor = SKINCOLOR_BLUE, lastgoodcolor2 = SKINCOLOR_BLUE; consvar_t cv_playercolor = {"color", "Blue", CV_CALL|CV_NOINIT, Color_cons_t, Color_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_playercolor2 = {"color2", "Orange", CV_CALL|CV_NOINIT, Color_cons_t, Color2_OnChange, 0, NULL, NULL, 0, 0, NULL}; // player's skin, saved for commodity, when using a favorite skins wad.. @@ -1285,7 +1285,7 @@ static void SendNameAndColor(void) players[consoleplayer].skincolor = cv_playercolor.value % numskincolors; if (players[consoleplayer].mo) - players[consoleplayer].mo->color = (UINT8)players[consoleplayer].skincolor; + players[consoleplayer].mo->color = (UINT16)players[consoleplayer].skincolor; }*/ } else @@ -1323,7 +1323,7 @@ static void SendNameAndColor(void) // Finally write out the complete packet and send it off. WRITESTRINGN(p, cv_playername.zstring, MAXPLAYERNAME); WRITEUINT32(p, (UINT32)players[consoleplayer].availabilities); - WRITEUINT8(p, (UINT8)cv_playercolor.value); + WRITEUINT16(p, (UINT16)cv_playercolor.value); WRITEUINT8(p, (UINT8)cv_skin.value); SendNetXCmd(XD_NAMEANDCOLOR, buf, p - buf); } @@ -1439,7 +1439,8 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) { player_t *p = &players[playernum]; char name[MAXPLAYERNAME+1]; - UINT8 color, skin; + UINT16 color; + UINT8 skin; #ifdef PARANOIA if (playernum < 0 || playernum > MAXPLAYERS) @@ -1458,7 +1459,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) READSTRINGN(*cp, name, MAXPLAYERNAME); p->availabilities = READUINT32(*cp); - color = READUINT8(*cp); + color = READUINT16(*cp); skin = READUINT8(*cp); // set name @@ -1468,7 +1469,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) // set color p->skincolor = color % numskincolors; if (p->mo) - p->mo->color = (UINT8)p->skincolor; + p->mo->color = (UINT16)p->skincolor; // normal player colors if (server && (p != &players[consoleplayer] && p != &players[secondarydisplayplayer])) diff --git a/src/d_player.h b/src/d_player.h index e5c7e7298..0f1031708 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -366,7 +366,7 @@ typedef struct player_s UINT16 flashpal; // Player skin colorshift, 0-15 for which color to draw player. - UINT8 skincolor; + UINT16 skincolor; INT32 skin; UINT32 availabilities; diff --git a/src/dehacked.c b/src/dehacked.c index 13e4eb6fe..627a3a119 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -452,7 +452,7 @@ static void readPlayer(MYFILE *f, INT32 num) else if (fastcmp(word, "OPPOSITECOLOR") || fastcmp(word, "OPPOSITECOLOUR")) { SLOTFOUND - description[num].oppositecolor = (UINT8)get_number(word2); + description[num].oppositecolor = (UINT16)get_number(word2); } else if (fastcmp(word, "NAMETAG") || fastcmp(word, "TAGNAME")) { @@ -462,12 +462,12 @@ static void readPlayer(MYFILE *f, INT32 num) else if (fastcmp(word, "TAGTEXTCOLOR") || fastcmp(word, "TAGTEXTCOLOUR")) { SLOTFOUND - description[num].tagtextcolor = (UINT8)get_number(word2); + description[num].tagtextcolor = (UINT16)get_number(word2); } else if (fastcmp(word, "TAGOUTLINECOLOR") || fastcmp(word, "TAGOUTLINECOLOUR")) { SLOTFOUND - description[num].tagoutlinecolor = (UINT8)get_number(word2); + description[num].tagoutlinecolor = (UINT16)get_number(word2); } else if (fastcmp(word, "STATUS")) { @@ -821,11 +821,11 @@ static void readskincolor(MYFILE *f, INT32 num) } else if (fastcmp(word, "INVCOLOR")) { - skincolors[num].invcolor = (UINT8)get_number(word2); + skincolors[num].invcolor = (UINT16)get_number(word2); } else if (fastcmp(word, "INVSHADE")) { - skincolors[num].invshade = get_number(word2); + skincolors[num].invshade = get_number(word2)%COLORRAMPSIZE; } else if (fastcmp(word, "CHATCOLOR")) { @@ -4043,19 +4043,19 @@ static void readmaincfg(MYFILE *f) } else if (fastcmp(word, "REDTEAM")) { - skincolor_redteam = (UINT8)get_number(word2); + skincolor_redteam = (UINT16)get_number(word2); } else if (fastcmp(word, "BLUETEAM")) { - skincolor_blueteam = (UINT8)get_number(word2); + skincolor_blueteam = (UINT16)get_number(word2); } else if (fastcmp(word, "REDRING")) { - skincolor_redring = (UINT8)get_number(word2); + skincolor_redring = (UINT16)get_number(word2); } else if (fastcmp(word, "BLUERING")) { - skincolor_bluering = (UINT8)get_number(word2); + skincolor_bluering = (UINT16)get_number(word2); } else if (fastcmp(word, "INVULNTICS")) { diff --git a/src/doomdef.h b/src/doomdef.h index 7f401f23a..120df8526 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -241,12 +241,13 @@ extern char logfilename[1024]; #define COLORRAMPSIZE 16 #define MAXCOLORNAME 32 +#define NUMCOLORFREESLOTS 1024 typedef struct skincolor_s { char name[MAXCOLORNAME+1]; // Skincolor name UINT8 ramp[COLORRAMPSIZE]; // Colormap ramp - UINT8 invcolor; // Signpost color + UINT16 invcolor; // Signpost color UINT8 invshade; // Signpost color shade UINT16 chatcolor; // Chat color boolean accessible; // Accessible by the color command + setup menu @@ -388,7 +389,7 @@ typedef enum SKINCOLOR_SUPERTAN5, SKINCOLOR_FIRSTFREESLOT, - SKINCOLOR_LASTFREESLOT = 255, + SKINCOLOR_LASTFREESLOT = SKINCOLOR_FIRSTFREESLOT + NUMCOLORFREESLOTS - 1, MAXSKINCOLORS, @@ -397,7 +398,6 @@ typedef enum UINT16 numskincolors; -#define NUMCOLORFREESLOTS (SKINCOLOR_LASTFREESLOT-SKINCOLOR_FIRSTFREESLOT)+1 extern skincolor_t skincolors[MAXSKINCOLORS]; // State updates, number of tics / second. diff --git a/src/doomstat.h b/src/doomstat.h index 57ea3e049..fa346540c 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -145,7 +145,7 @@ extern INT32 tutorialanalog; // store cv_analog[0] user value extern boolean looptitle; // CTF colors. -extern UINT8 skincolor_redteam, skincolor_blueteam, skincolor_redring, skincolor_bluering; +extern UINT16 skincolor_redteam, skincolor_blueteam, skincolor_redring, skincolor_bluering; extern tic_t countdowntimer; extern boolean countdowntimeup; diff --git a/src/g_demo.c b/src/g_demo.c index a901e8dea..7c949a4c8 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -68,7 +68,7 @@ static struct { UINT8 flags; // EZT flags // EZT_COLOR - UINT8 color, lastcolor; + UINT16 color, lastcolor; // EZT_SCALE fixed_t scale, lastscale; @@ -82,7 +82,8 @@ static struct { // There is no conflict here. typedef struct demoghost { UINT8 checksum[16]; - UINT8 *buffer, *p, color, fadein; + UINT8 *buffer, *p, fadein; + UINT16 color; UINT16 version; mobj_t oldmo, *mo; struct demoghost *next; @@ -93,7 +94,7 @@ demoghost *ghosts = NULL; // DEMO RECORDING // -#define DEMOVERSION 0x000c +#define DEMOVERSION 0x000d #define DEMOHEADER "\xF0" "SRB2Replay" "\x0F" #define DF_GHOST 0x01 // This demo contains ghost data too! @@ -280,13 +281,13 @@ void G_GhostAddColor(ghostcolor_t color) { if (!demorecording || !(demoflags & DF_GHOST)) return; - if (ghostext.lastcolor == (UINT8)color) + if (ghostext.lastcolor == (UINT16)color) { ghostext.flags &= ~EZT_COLOR; return; } ghostext.flags |= EZT_COLOR; - ghostext.color = (UINT8)color; + ghostext.color = (UINT16)color; } void G_GhostAddScale(fixed_t scale) @@ -425,7 +426,7 @@ void G_WriteGhostTic(mobj_t *ghost) WRITEUINT8(demo_p,ghostext.flags); if (ghostext.flags & EZT_COLOR) { - WRITEUINT8(demo_p,ghostext.color); + WRITEUINT16(demo_p,ghostext.color); ghostext.lastcolor = ghostext.color; } if (ghostext.flags & EZT_SCALE) @@ -501,7 +502,7 @@ void G_WriteGhostTic(mobj_t *ghost) WRITEUINT8(demo_p,ghost->player->followmobj->sprite2); WRITEUINT16(demo_p,ghost->player->followmobj->sprite); WRITEUINT8(demo_p,(ghost->player->followmobj->frame & FF_FRAMEMASK)); - WRITEUINT8(demo_p,ghost->player->followmobj->color); + WRITEUINT16(demo_p,ghost->player->followmobj->color); *followtic_p = followtic; } @@ -566,7 +567,7 @@ void G_ConsGhostTic(void) { // But wait, there's more! UINT8 xziptic = READUINT8(demo_p); if (xziptic & EZT_COLOR) - demo_p++; + demo_p += (demoversion==0x000c) ? 1 : sizeof(UINT16); if (xziptic & EZT_SCALE) demo_p += sizeof(fixed_t); if (xziptic & EZT_HIT) @@ -633,7 +634,7 @@ void G_ConsGhostTic(void) demo_p++; demo_p += sizeof(UINT16); demo_p++; - demo_p++; + demo_p += (demoversion==0x000c) ? 1 : sizeof(UINT16); } // Re-synchronise @@ -731,7 +732,7 @@ void G_GhostTicker(void) xziptic = READUINT8(g->p); if (xziptic & EZT_COLOR) { - g->color = READUINT8(g->p); + g->color = (g->version==0x000c) ? READUINT8(g->p) : READUINT16(g->p); switch(g->color) { default: @@ -864,7 +865,7 @@ void G_GhostTicker(void) g->mo->color += abs( ( (signed)( (unsigned)leveltime >> 1 ) % 9) - 4); break; case GHC_INVINCIBLE: // Mario invincibility (P_CheckInvincibilityTimer) - g->mo->color = (UINT8)(SKINCOLOR_RUBY + (leveltime % (MAXSKINCOLORS - SKINCOLOR_RUBY))); // Passes through all saturated colours + g->mo->color = (UINT16)(SKINCOLOR_RUBY + (leveltime % (FIRSTSUPERCOLOR - SKINCOLOR_RUBY))); // Passes through all saturated colours break; default: break; @@ -918,7 +919,7 @@ void G_GhostTicker(void) follow->sprite = READUINT16(g->p); follow->frame = (READUINT8(g->p)) | (g->mo->frame & FF_TRANSMASK); follow->angle = g->mo->angle; - follow->color = READUINT8(g->p); + follow->color = (g->version==0x000c) ? READUINT8(g->p) : READUINT16(g->p); if (!(followtic & FZT_SPAWNED)) { @@ -1158,7 +1159,7 @@ void G_ReadMetalTic(mobj_t *metal) follow->sprite = READUINT16(metal_p); follow->frame = READUINT32(metal_p); // NOT & FF_FRAMEMASK here, so 32 bits follow->angle = metal->angle; - follow->color = READUINT8(metal_p); + follow->color = (metalversion==0x000c) ? READUINT8(metal_p) : READUINT16(metal_p); if (!(followtic & FZT_SPAWNED)) { @@ -1340,7 +1341,7 @@ void G_WriteMetalTic(mobj_t *metal) WRITEUINT8(demo_p,metal->player->followmobj->sprite2); WRITEUINT16(demo_p,metal->player->followmobj->sprite); WRITEUINT32(demo_p,metal->player->followmobj->frame); // NOT & FF_FRAMEMASK here, so 32 bits - WRITEUINT8(demo_p,metal->player->followmobj->color); + WRITEUINT16(demo_p,metal->player->followmobj->color); *followtic_p = followtic; } @@ -1394,7 +1395,7 @@ void G_RecordMetal(void) void G_BeginRecording(void) { UINT8 i; - char name[16]; + char name[MAXCOLORNAME+1]; player_t *player = &players[consoleplayer]; if (demo_p) @@ -1457,12 +1458,12 @@ void G_BeginRecording(void) demo_p += 16; // Color - for (i = 0; i < 16 && cv_playercolor.string[i]; i++) + for (i = 0; i < MAXCOLORNAME && cv_playercolor.string[i]; i++) name[i] = cv_playercolor.string[i]; - for (; i < 16; i++) + for (; i < MAXCOLORNAME; i++) name[i] = '\0'; - M_Memcpy(demo_p,name,16); - demo_p += 16; + M_Memcpy(demo_p,name,MAXCOLORNAME); + demo_p += MAXCOLORNAME; // Stats WRITEUINT8(demo_p,player->charability); @@ -1622,7 +1623,7 @@ UINT8 G_CmpDemoTime(char *oldname, char *newname) c = READUINT8(p); // SUBVERSION I_Assert(c == SUBVERSION); s = READUINT16(p); - I_Assert(s == DEMOVERSION); + I_Assert(s >= 0x000c); p += 16; // demo checksum I_Assert(!memcmp(p, "PLAY", 4)); p += 4; // PLAY @@ -1671,6 +1672,7 @@ UINT8 G_CmpDemoTime(char *oldname, char *newname) switch(oldversion) // demoversion { case DEMOVERSION: // latest always supported + case 0x000c: // all that changed between then and now was longer color name break; // too old, cannot support. default: @@ -1744,15 +1746,15 @@ void G_DoPlayDemo(char *defdemoname) { UINT8 i; lumpnum_t l; - char skin[17],color[17],*n,*pdemoname; - UINT8 version,subversion,charability,charability2,thrustfactor,accelstart,acceleration; + char skin[17],color[MAXCOLORNAME+1],*n,*pdemoname; + UINT8 version,subversion,charability,charability2,thrustfactor,accelstart,acceleration,cnamelen; pflags_t pflags; UINT32 randseed, followitem; fixed_t camerascale,shieldscale,actionspd,mindash,maxdash,normalspeed,runspeed,jumpfactor,height,spinheight; char msg[1024]; skin[16] = '\0'; - color[16] = '\0'; + color[MAXCOLORNAME] = '\0'; n = defdemoname+strlen(defdemoname); while (*n != '/' && *n != '\\' && n != defdemoname) @@ -1810,6 +1812,11 @@ void G_DoPlayDemo(char *defdemoname) switch(demoversion) { case DEMOVERSION: // latest always supported + cnamelen = MAXCOLORNAME; + break; + // all that changed between then and now was longer color name + case 0x000c: + cnamelen = 16; break; // too old, cannot support. default: @@ -1876,8 +1883,8 @@ void G_DoPlayDemo(char *defdemoname) demo_p += 16; // Color - M_Memcpy(color,demo_p,16); - demo_p += 16; + M_Memcpy(color,demo_p,cnamelen); + demo_p += cnamelen; charability = READUINT8(demo_p); charability2 = READUINT8(demo_p); @@ -1941,7 +1948,9 @@ void G_DoPlayDemo(char *defdemoname) // Set skin SetPlayerSkin(0, skin); +#ifdef HAVE_BLUA LUAh_MapChange(gamemap); +#endif displayplayer = consoleplayer = 0; memset(playeringame,0,sizeof(playeringame)); playeringame[0] = true; @@ -1949,8 +1958,9 @@ void G_DoPlayDemo(char *defdemoname) G_InitNew(false, G_BuildMapName(gamemap), true, true, false); // Set color - for (i = 0; i < MAXSKINCOLORS; i++) - if (!stricmp(Color_Names[i],color)) + players[0].skincolor = skins[players[0].skin].prefcolor; + for (i = 0; i < numskincolors; i++) + if (!stricmp(skincolors[i].name,color)) { players[0].skincolor = i; break; @@ -1992,7 +2002,8 @@ void G_AddGhost(char *defdemoname) { INT32 i; lumpnum_t l; - char name[17],skin[17],color[17],*n,*pdemoname,md5[16]; + char name[17],skin[17],color[MAXCOLORNAME+1],*n,*pdemoname,md5[16]; + UINT8 cnamelen; demoghost *gh; UINT8 flags; UINT8 *buffer,*p; @@ -2047,6 +2058,11 @@ void G_AddGhost(char *defdemoname) switch(ghostversion) { case DEMOVERSION: // latest always supported + cnamelen = MAXCOLORNAME; + break; + // all that changed between then and now was longer color name + case 0x000c: + cnamelen = 16; break; // too old, cannot support. default: @@ -2109,8 +2125,8 @@ void G_AddGhost(char *defdemoname) p += 16; // Color - M_Memcpy(color, p,16); - p += 16; + M_Memcpy(color, p,cnamelen); + p += cnamelen; // Ghosts do not have a player structure to put this in. p++; // charability @@ -2198,10 +2214,10 @@ void G_AddGhost(char *defdemoname) // Set color gh->mo->color = ((skin_t*)gh->mo->skin)->prefcolor; - for (i = 0; i < MAXSKINCOLORS; i++) - if (!stricmp(Color_Names[i],color)) + for (i = 0; i < numskincolors; i++) + if (!stricmp(skincolors[i].name,color)) { - gh->mo->color = (UINT8)i; + gh->mo->color = (UINT16)i; break; } gh->oldmo.color = gh->mo->color; @@ -2292,6 +2308,7 @@ void G_DoPlayMetal(void) switch(metalversion) { case DEMOVERSION: // latest always supported + case 0x000c: // all that changed between then and now was longer color name break; // too old, cannot support. default: diff --git a/src/g_game.c b/src/g_game.c index 5bcf9f580..6b434cb3b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -54,7 +54,7 @@ UINT8 ultimatemode = false; boolean botingame; UINT8 botskin; -UINT8 botcolor; +UINT16 botcolor; JoyType_t Joystick; JoyType_t Joystick2; @@ -135,10 +135,10 @@ INT32 tutorialanalog = 0; // store cv_analog[0] user value boolean looptitle = false; -UINT8 skincolor_redteam = SKINCOLOR_RED; -UINT8 skincolor_blueteam = SKINCOLOR_BLUE; -UINT8 skincolor_redring = SKINCOLOR_SALMON; -UINT8 skincolor_bluering = SKINCOLOR_CORNFLOWER; +UINT16 skincolor_redteam = SKINCOLOR_RED; +UINT16 skincolor_blueteam = SKINCOLOR_BLUE; +UINT16 skincolor_redring = SKINCOLOR_SALMON; +UINT16 skincolor_bluering = SKINCOLOR_CORNFLOWER; tic_t countdowntimer = 0; boolean countdowntimeup = false; @@ -2381,7 +2381,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) INT16 totalring; UINT8 laps; UINT8 mare; - UINT8 skincolor; + UINT16 skincolor; INT32 skin; UINT32 availabilities; tic_t jointime; @@ -4475,7 +4475,7 @@ cleanup: // void G_DeferedInitNew(boolean pultmode, const char *mapname, INT32 pickedchar, boolean SSSG, boolean FLS) { - UINT8 color = skins[pickedchar].prefcolor; + UINT16 color = skins[pickedchar].prefcolor; paused = false; if (demoplayback) diff --git a/src/g_state.h b/src/g_state.h index 3320ebc47..e364c5a35 100644 --- a/src/g_state.h +++ b/src/g_state.h @@ -57,6 +57,7 @@ extern UINT8 ultimatemode; // was sk_insane extern gameaction_t gameaction; extern boolean botingame; -extern UINT8 botskin, botcolor; +extern UINT8 botskin; +extern UINT16 botcolor; #endif //__G_STATE__ diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 9bf2eb392..e4ea26d86 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -682,7 +682,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, UINT16 w = gpatch->width, h = gpatch->height; UINT32 size = w*h; RGBA_t *image, *blendimage, *cur, blendcolor; - UINT8 translation[16]; // First the color index + UINT16 translation[16]; // First the color index UINT8 cutoff[16]; // Brightness cutoff before using the next color UINT8 translen = 0; UINT8 i; @@ -741,7 +741,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, numdupes = 1; translen++; - translation[translen] = (UINT8)skincolors[color].ramp[i]; + translation[translen] = (UINT16)skincolors[color].ramp[i]; } translen++; diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 0f7d20893..d460f8cf7 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2424,6 +2424,17 @@ static int lib_rGetColorByName(lua_State *L) return 1; } +// Lua exclusive function, returns the name of a color from the SKINCOLOR_ constant. +// SKINCOLOR_GREEN > "Green" for example +static int lib_rGetNameByColor(lua_State *L) +{ + UINT16 colornum = (UINT16)luaL_checkinteger(L, 1); + if (!colornum || colornum >= numskincolors) + return luaL_error(L, "skincolor %d out of range (1 - %d).", colornum, numskincolors-1); + lua_pushstring(L, skincolors[colornum].name); + return 1; +} + // S_SOUND //////////// static int lib_sStartSound(lua_State *L) @@ -3337,6 +3348,7 @@ static luaL_Reg lib[] = { // r_draw {"R_GetColorByName", lib_rGetColorByName}, + {"R_GetNameByColor", lib_rGetNameByColor}, // s_sound {"S_StartSound",lib_sStartSound}, diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 772265ebe..4aa70574b 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -878,8 +878,8 @@ static int libd_drawNameTag(lua_State *L) INT32 y; const char *str; INT32 flags; - UINT8 basecolor; - UINT8 outlinecolor; + UINT16 basecolor; + UINT16 outlinecolor; UINT8 *basecolormap = NULL; UINT8 *outlinecolormap = NULL; @@ -908,8 +908,8 @@ static int libd_drawScaledNameTag(lua_State *L) const char *str; INT32 flags; fixed_t scale; - UINT8 basecolor; - UINT8 outlinecolor; + UINT16 basecolor; + UINT16 outlinecolor; UINT8 *basecolormap = NULL; UINT8 *outlinecolormap = NULL; diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 06b8643d1..81a215c53 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -1508,10 +1508,10 @@ static int lib_setSkinColor(lua_State *L) { UINT32 j; skincolor_t *info; - UINT8 cnum; //skincolor num + UINT16 cnum; //skincolor num lua_remove(L, 1); // don't care about skincolors[] userdata. { - cnum = (UINT8)luaL_checkinteger(L, 1); + cnum = (UINT16)luaL_checkinteger(L, 1); if (cnum < SKINCOLOR_FIRSTFREESLOT || cnum >= numskincolors) return luaL_error(L, "skincolors[] index %d out of range (%d - %d)", cnum, SKINCOLOR_FIRSTFREESLOT, numskincolors-1); info = &skincolors[cnum]; // get the skincolor to assign to. @@ -1551,9 +1551,9 @@ static int lib_setSkinColor(lua_State *L) info->ramp[j] = (*((UINT8 **)luaL_checkudata(L, 3, META_COLORRAMP)))[j]; R_FlushTranslationColormapCache(); } else if (i == 3 || (str && fastcmp(str,"invcolor"))) - info->invcolor = (UINT8)luaL_checkinteger(L, 3); + info->invcolor = (UINT16)luaL_checkinteger(L, 3); else if (i == 4 || (str && fastcmp(str,"invshade"))) - info->invshade = (UINT8)luaL_checkinteger(L, 3); + info->invshade = (UINT8)luaL_checkinteger(L, 3)%COLORRAMPSIZE; else if (i == 5 || (str && fastcmp(str,"chatcolor"))) info->chatcolor = (UINT16)luaL_checkinteger(L, 3); else if (i == 6 || (str && fastcmp(str,"accessible"))) { @@ -1631,9 +1631,9 @@ static int skincolor_set(lua_State *L) info->ramp[i] = (*((UINT8 **)luaL_checkudata(L, 3, META_COLORRAMP)))[i]; R_FlushTranslationColormapCache(); } else if (fastcmp(field,"invcolor")) - info->invcolor = (UINT8)luaL_checkinteger(L, 3); + info->invcolor = (UINT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"invshade")) - info->invshade = (UINT8)luaL_checkinteger(L, 3); + info->invshade = (UINT8)luaL_checkinteger(L, 3)%COLORRAMPSIZE; else if (fastcmp(field,"chatcolor")) info->chatcolor = (UINT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"accessible")) diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index 6efec9a5f..76c80c541 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -175,7 +175,7 @@ static int lib_all7emeralds(lua_State *L) // Returns both color and signpost shade numbers! static int lib_coloropposite(lua_State *L) { - UINT8 colornum = (UINT8)luaL_checkinteger(L, 1); + UINT16 colornum = (UINT16)luaL_checkinteger(L, 1); if (!colornum || colornum >= numskincolors) return luaL_error(L, "skincolor %d out of range (1 - %d).", colornum, numskincolors-1); lua_pushinteger(L, skincolors[colornum].invcolor); // push color diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index dbd3f4aeb..6f2496f24 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -574,7 +574,7 @@ static int mobj_set(lua_State *L) } case mobj_color: { - UINT8 newcolor = (UINT8)luaL_checkinteger(L,3); + UINT16 newcolor = (UINT16)luaL_checkinteger(L,3); if (newcolor >= numskincolors) return luaL_error(L, "mobj.color %d out of range (0 - %d).", newcolor, numskincolors-1); mo->color = newcolor; diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 6afe5009f..1ce9be525 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -461,7 +461,7 @@ static int player_set(lua_State *L) plr->flashpal = (UINT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"skincolor")) { - UINT8 newcolor = (UINT8)luaL_checkinteger(L,3); + UINT16 newcolor = (UINT16)luaL_checkinteger(L,3); if (newcolor >= numskincolors) return luaL_error(L, "player.skincolor %d out of range (0 - %d).", newcolor, numskincolors-1); plr->skincolor = newcolor; diff --git a/src/m_cheat.c b/src/m_cheat.c index 156c5db16..3d188644b 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -978,7 +978,7 @@ static mobjflag2_t op_oldflags2 = 0; static UINT32 op_oldeflags = 0; static fixed_t op_oldmomx = 0, op_oldmomy = 0, op_oldmomz = 0, op_oldheight = 0; static statenum_t op_oldstate = 0; -static UINT8 op_oldcolor = 0; +static UINT16 op_oldcolor = 0; // // Static calculation / common output help diff --git a/src/m_cond.h b/src/m_cond.h index 0c56f7f98..9bb162ff3 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -90,7 +90,7 @@ typedef struct INT16 tag; ///< Tag of emblem mapthing INT16 level; ///< Level on which this emblem can be found. UINT8 sprite; ///< emblem sprite to use, 0 - 25 - UINT8 color; ///< skincolor to use + UINT16 color; ///< skincolor to use INT32 var; ///< If needed, specifies information on the target amount to achieve (or target skin) char hint[110]; ///< Hint for emblem hints menu UINT8 collected; ///< Do you have this emblem? @@ -102,7 +102,7 @@ typedef struct UINT8 conditionset; ///< Condition set that awards this emblem. UINT8 showconditionset; ///< Condition set that shows this emblem. UINT8 sprite; ///< emblem sprite to use, 0 - 25 - UINT8 color; ///< skincolor to use + UINT16 color; ///< skincolor to use UINT8 collected; ///< Do you have this emblem? } extraemblem_t; diff --git a/src/m_menu.c b/src/m_menu.c index 8b7959768..f9061b251 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9055,7 +9055,7 @@ static void M_DrawSetupChoosePlayerMenu(void) skin_t *charskin = &skins[0]; INT32 skinnum = 0; - UINT8 col; + UINT16 col; UINT8 *colormap = NULL; INT32 prev = -1, next = -1; @@ -9145,8 +9145,8 @@ static void M_DrawSetupChoosePlayerMenu(void) INT32 ox, oxsh = FixedInt(FixedMul(BASEVIDWIDTH*FRACUNIT, FixedDiv(char_scroll, 128*FRACUNIT))), txsh; patch_t *curpatch = NULL, *prevpatch = NULL, *nextpatch = NULL; const char *curtext = NULL, *prevtext = NULL, *nexttext = NULL; - UINT8 curtextcolor = 0, prevtextcolor = 0, nexttextcolor = 0; - UINT8 curoutlinecolor = 0, prevoutlinecolor = 0, nextoutlinecolor = 0; + UINT16 curtextcolor = 0, prevtextcolor = 0, nexttextcolor = 0; + UINT16 curoutlinecolor = 0, prevoutlinecolor = 0, nextoutlinecolor = 0; // Name tag curtext = description[char_on].displayname; @@ -11355,7 +11355,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) } else if (itemOn == 2) { - UINT8 col = skins[setupm_fakeskin].prefcolor; + UINT16 col = skins[setupm_fakeskin].prefcolor; if ((setupm_fakecolor->color != col) && skincolors[col].accessible) { S_StartSound(NULL,sfx_menu1); // Tails @@ -11514,7 +11514,7 @@ static boolean M_QuitMultiPlayerMenu(void) return true; } -void M_AddMenuColor(UINT8 color) { +void M_AddMenuColor(UINT16 color) { menucolor_t *c; if (color >= numskincolors) { @@ -11538,7 +11538,7 @@ void M_AddMenuColor(UINT8 color) { } } -void M_MoveColorBefore(UINT8 color, UINT8 targ) { +void M_MoveColorBefore(UINT16 color, UINT16 targ) { menucolor_t *look, *c = NULL, *t = NULL; if (color == targ) @@ -11580,7 +11580,7 @@ void M_MoveColorBefore(UINT8 color, UINT8 targ) { t->prev = c; } -void M_MoveColorAfter(UINT8 color, UINT8 targ) { +void M_MoveColorAfter(UINT16 color, UINT16 targ) { menucolor_t *look, *c = NULL, *t = NULL; if (color == targ) @@ -11622,7 +11622,7 @@ void M_MoveColorAfter(UINT8 color, UINT8 targ) { t->next = c; } -UINT8 M_GetColorBefore(UINT8 color) { +UINT16 M_GetColorBefore(UINT16 color) { menucolor_t *look; if (color >= numskincolors) { @@ -11638,7 +11638,7 @@ UINT8 M_GetColorBefore(UINT8 color) { } } -UINT8 M_GetColorAfter(UINT8 color) { +UINT16 M_GetColorAfter(UINT16 color) { menucolor_t *look; if (color >= numskincolors) { diff --git a/src/m_menu.h b/src/m_menu.h index 3f9f15c33..240c4b235 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -355,11 +355,11 @@ typedef struct // new character select char displayname[SKINNAMESIZE+1]; SINT8 skinnum[2]; - UINT8 oppositecolor; + UINT16 oppositecolor; char nametag[8]; patch_t *namepic; - UINT8 tagtextcolor; - UINT8 tagoutlinecolor; + UINT16 tagtextcolor; + UINT16 tagoutlinecolor; } description_t; // level select platter @@ -447,16 +447,16 @@ void Moviemode_option_Onchange(void); typedef struct menucolor_s { struct menucolor_s *next; struct menucolor_s *prev; - UINT8 color; + UINT16 color; } menucolor_t; menucolor_t *menucolorhead, *menucolortail; -void M_AddMenuColor(UINT8 color); -void M_MoveColorBefore(UINT8 color, UINT8 targ); -void M_MoveColorAfter(UINT8 color, UINT8 targ); -UINT8 M_GetColorBefore(UINT8 color); -UINT8 M_GetColorAfter(UINT8 color); +void M_AddMenuColor(UINT16 color); +void M_MoveColorBefore(UINT16 color, UINT16 targ); +void M_MoveColorAfter(UINT16 color, UINT16 targ); +UINT16 M_GetColorBefore(UINT16 color); +UINT16 M_GetColorAfter(UINT16 color); void M_InitPlayerSetupColors(void); void M_FreePlayerSetupColors(void); diff --git a/src/p_enemy.c b/src/p_enemy.c index 113999d84..18de57b54 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -5106,7 +5106,7 @@ void A_SignPlayer(mobj_t *actor) INT32 locvar2 = var2; skin_t *skin = NULL; mobj_t *ov; - UINT8 facecolor, signcolor = (UINT8)locvar2; + UINT16 facecolor, signcolor = (UINT16)locvar2; UINT32 signframe = states[actor->info->raisestate].frame; if (LUA_CallAction("A_SignPlayer", actor)) @@ -5212,19 +5212,8 @@ void A_SignPlayer(mobj_t *actor) } actor->tracer->color = signcolor; - /* - If you're here from the comment above Color_Opposite, - the following line is the one which is dependent on the - array being symmetrical. It gets the opposite of the - opposite of your desired colour just so it can get the - brightness frame for the End Sign. It's not a great - design choice, but it's constant time array access and - the idea that the colours should be OPPOSITES is kind - of in the name. If you have a better idea, feel free - to let me know. ~toast 2016/07/20 - */ if (signcolor && signcolor < numskincolors) - signframe += (15 - skincolors[skincolors[signcolor].invcolor].invshade); + signframe += (15 - skincolors[signcolor].invshade); actor->tracer->frame = signframe; } @@ -8804,10 +8793,10 @@ void A_ChangeColorRelative(mobj_t *actor) { // Have you ever seen anything so hideous? if (actor->target) - actor->color = (UINT8)(actor->color + actor->target->color); + actor->color = (UINT16)(actor->color + actor->target->color); } else - actor->color = (UINT8)(actor->color + locvar2); + actor->color = (UINT16)(actor->color + locvar2); } // Function: A_ChangeColorAbsolute @@ -8831,7 +8820,7 @@ void A_ChangeColorAbsolute(mobj_t *actor) actor->color = actor->target->color; } else - actor->color = (UINT8)locvar2; + actor->color = (UINT16)locvar2; } // Function: A_Dye @@ -8850,7 +8839,7 @@ void A_Dye(mobj_t *actor) UINT8 color = (UINT8)locvar2; if (LUA_CallAction("A_Dye", actor)) return; - if (color >= MAXTRANSLATIONS) + if (color >= numskincolors) return; if (!color) diff --git a/src/p_mobj.c b/src/p_mobj.c index 78d3f49c8..fd13c8f05 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9429,7 +9429,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) case MT_BOSSFLYPOINT: return false; case MT_NIGHTSCORE: - mobj->color = (UINT8)(leveltime % SKINCOLOR_WHITE); + mobj->color = (UINT16)(leveltime % SKINCOLOR_WHITE); break; case MT_JETFUME1: if (!P_JetFume1Think(mobj)) @@ -11939,7 +11939,7 @@ static boolean P_SetupEmblem(mapthing_t *mthing, mobj_t *mobj) mobj->health = j + 1; emcolor = M_GetEmblemColor(&emblemlocations[j]); // workaround for compiler complaint about bad function casting - mobj->color = (UINT8)emcolor; + mobj->color = (UINT16)emcolor; if (emblemlocations[j].collected || (emblemlocations[j].type == ET_SKIN && emblemlocations[j].var != players[0].skin)) diff --git a/src/p_mobj.h b/src/p_mobj.h index eda7383df..dae8c8a86 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -312,7 +312,7 @@ typedef struct mobj_s void *skin; // overrides 'sprite' when non-NULL (for player bodies to 'remember' the skin) // Player and mobj sprites in multiplayer modes are modified // using an internal color lookup table for re-indexing. - UINT8 color; // This replaces MF_TRANSLATION. Use 0 for default (no translation). + UINT16 color; // This replaces MF_TRANSLATION. Use 0 for default (no translation). // Interaction info, by BLOCKMAP. // Links in blocks (if needed). diff --git a/src/p_saveg.c b/src/p_saveg.c index bec64ed35..d6abf4232 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1593,7 +1593,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) if (diff2 & MD2_SKIN) WRITEUINT8(save_p, (UINT8)((skin_t *)mobj->skin - skins)); if (diff2 & MD2_COLOR) - WRITEUINT8(save_p, mobj->color); + WRITEUINT16(save_p, mobj->color); if (diff2 & MD2_EXTVAL1) WRITEINT32(save_p, mobj->extravalue1); if (diff2 & MD2_EXTVAL2) @@ -2600,7 +2600,7 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) if (diff2 & MD2_SKIN) mobj->skin = &skins[READUINT8(save_p)]; if (diff2 & MD2_COLOR) - mobj->color = READUINT8(save_p); + mobj->color = READUINT16(save_p); if (diff2 & MD2_EXTVAL1) mobj->extravalue1 = READINT32(save_p); if (diff2 & MD2_EXTVAL2) diff --git a/src/p_spec.c b/src/p_spec.c index d45a33c47..cee21036a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3971,7 +3971,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (mo) { - if (color < 0 || color >= MAXTRANSLATIONS) + if (color < 0 || color >= numskincolors) return; var1 = 0; diff --git a/src/p_user.c b/src/p_user.c index c6e49ef69..4b2849b1c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1916,7 +1916,7 @@ void P_SpawnShieldOrb(player_t *player) shieldobj->colorized = true; } else - shieldobj->color = (UINT8)shieldobj->info->painchance; + shieldobj->color = (UINT16)shieldobj->info->painchance; shieldobj->threshold = (player->powers[pw_shield] & SH_FORCE) ? SH_FORCE : (player->powers[pw_shield] & SH_NOSTACK); if (shieldobj->info->seestate) @@ -2986,7 +2986,7 @@ static void P_CheckInvincibilityTimer(player_t *player) return; if (mariomode && !player->powers[pw_super]) - player->mo->color = (UINT8)(SKINCOLOR_RUBY + (leveltime % (numskincolors - SKINCOLOR_RUBY))); // Passes through all saturated colours + player->mo->color = (UINT16)(SKINCOLOR_RUBY + (leveltime % (numskincolors - SKINCOLOR_RUBY))); // Passes through all saturated colours else if (leveltime % (TICRATE/7) == 0) { mobj_t *sparkle = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_IVSP); diff --git a/src/r_draw.c b/src/r_draw.c index 8f5d48315..5351ef37f 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -184,7 +184,7 @@ void R_InitTranslationTables(void) \param dest_colormap colormap to populate \param skincolor translation color */ -static void R_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor) +static void R_RainbowColormap(UINT8 *dest_colormap, UINT16 skincolor) { INT32 i; RGBA_t color; @@ -226,7 +226,7 @@ static void R_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor) #undef SETBRIGHTNESS -static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color) +static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, UINT16 color) { INT32 i, starttranscolor, skinramplength; @@ -419,9 +419,9 @@ void R_FlushTranslationColormapCache(void) memset(translationtablecache[i], 0, MAXSKINCOLORS * sizeof(UINT8**)); } -UINT8 R_GetColorByName(const char *name) +UINT16 R_GetColorByName(const char *name) { - UINT16 color = (UINT8)atoi(name); + UINT16 color = (UINT16)atoi(name); if (color > 0 && color < numskincolors) return color; for (color = 1; color < numskincolors; color++) @@ -430,7 +430,7 @@ UINT8 R_GetColorByName(const char *name) return SKINCOLOR_GREEN; } -UINT8 R_GetSuperColorByName(const char *name) +UINT16 R_GetSuperColorByName(const char *name) { UINT16 i, color = SKINCOLOR_SUPERGOLD1; char *realname = Z_Malloc(MAXCOLORNAME+1, PU_STATIC, NULL); diff --git a/src/r_draw.h b/src/r_draw.h index 6a021fe39..329c4974a 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -114,8 +114,8 @@ extern lumpnum_t viewborderlump[8]; void R_InitTranslationTables(void); UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags); void R_FlushTranslationColormapCache(void); -UINT8 R_GetColorByName(const char *name); -UINT8 R_GetSuperColorByName(const char *name); +UINT16 R_GetColorByName(const char *name); +UINT16 R_GetSuperColorByName(const char *name); // Custom player skin translation void R_InitViewBuffer(INT32 width, INT32 height); diff --git a/src/r_skins.c b/src/r_skins.c index caf1fb172..57ce382c4 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -248,7 +248,7 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) { player_t *player = &players[playernum]; skin_t *skin = &skins[skinnum]; - UINT8 newcolor = 0; + UINT16 newcolor = 0; if (skinnum >= 0 && skinnum < numskins && R_SkinUsable(playernum, skinnum)) // Make sure it exists! { diff --git a/src/r_skins.h b/src/r_skins.h index 96697b422..45c90bdb4 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -65,9 +65,9 @@ typedef struct // Definable color translation table UINT8 starttranscolor; - UINT8 prefcolor; - UINT8 supercolor; - UINT8 prefoppositecolor; // if 0 use tables instead + UINT16 prefcolor; + UINT16 supercolor; + UINT16 prefoppositecolor; // if 0 use tables instead fixed_t highresscale; // scale of highres, default is 0.5 UINT8 contspeed; // continue screen animation speed diff --git a/src/v_video.c b/src/v_video.c index 1e550fe9d..5a985555f 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1040,7 +1040,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ // V_DrawContinueIcon // Draw a mini player! If we can, that is. Otherwise we draw a star. // -void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT8 skincolor) +void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT16 skincolor) { if (skinnum >= 0 && skinnum < numskins && skins[skinnum].sprites[SPR2_XTRA].numframes > XTRA_CONTINUE) { diff --git a/src/v_video.h b/src/v_video.h index 664fa8995..9f7a9a9e9 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -160,7 +160,7 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue); void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap); void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t *patch, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); -void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT8 skincolor); +void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT16 skincolor); // Draw a linear block of pixels into the view buffer. void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const UINT8 *src); diff --git a/src/y_inter.c b/src/y_inter.c index a2628832f..2fe0de605 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -99,7 +99,7 @@ typedef union UINT8 continues; patch_t *pcontinues; INT32 *playerchar; // Continue HUD - UINT8 *playercolor; + UINT16 *playercolor; UINT8 gotlife; // Number of extra lives obtained } spec; @@ -107,7 +107,7 @@ typedef union struct { UINT32 scores[MAXPLAYERS]; // Winner's score - UINT8 *color[MAXPLAYERS]; // Winner's color # + UINT16 *color[MAXPLAYERS]; // Winner's color # boolean spectator[MAXPLAYERS]; // Spectator list INT32 *character[MAXPLAYERS]; // Winner's character # INT32 num[MAXPLAYERS]; // Winner's player # @@ -121,7 +121,7 @@ typedef union struct { - UINT8 *color[MAXPLAYERS]; // Winner's color # + UINT16 *color[MAXPLAYERS]; // Winner's color # INT32 *character[MAXPLAYERS]; // Winner's character # INT32 num[MAXPLAYERS]; // Winner's player # char name[MAXPLAYERS][9]; // Winner's name From f508f5b88122e96f7c853dcf5acb1f762ca40f51 Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Sun, 24 May 2020 12:36:20 -0500 Subject: [PATCH 31/42] Fix typo SKINCOLOT --- src/lua_libs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_libs.h b/src/lua_libs.h index c9b1a6854..a78128e9f 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -21,7 +21,7 @@ extern lua_State *gL; #define META_MOBJINFO "MOBJINFO_T*" #define META_SFXINFO "SFXINFO_T*" #define META_SKINCOLOR "SKINCOLOR_T*" -#define META_COLORRAMP "SKINCOLOT_T*RAMP" +#define META_COLORRAMP "SKINCOLOR_T*RAMP" #define META_SPRITEINFO "SPRITEINFO_T*" #define META_PIVOTLIST "SPRITEFRAMEPIVOT_T[]" #define META_FRAMEPIVOT "SPRITEFRAMEPIVOT_T*" From ed25fefcaeed165008a56965a0931c2bf637966f Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 24 May 2020 21:15:31 +0100 Subject: [PATCH 32/42] T_BounceCheese: Fix FOF height desync occurring if the FOF fell down too fast (resulting in a bizarre bouncing back up effect in MP SS5 due to P_FloorzAtPos messing up as a result) --- src/p_floor.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index ee673cb04..a0f7edd9c 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -696,10 +696,20 @@ void T_BounceCheese(bouncecheese_t *bouncer) return; } - T_MovePlane(bouncer->sector, bouncer->speed/2, bouncer->sector->ceilingheight - - 70*FRACUNIT, false, true, -1); // move ceiling - T_MovePlane(bouncer->sector, bouncer->speed/2, bouncer->sector->floorheight - 70*FRACUNIT, - false, false, -1); // move floor + if (bouncer->speed >= 0) // move floor first to fix height desync and any bizarre bugs following that + { + T_MovePlane(bouncer->sector, bouncer->speed/2, bouncer->sector->floorheight - 70*FRACUNIT, + false, false, -1); // move floor + T_MovePlane(bouncer->sector, bouncer->speed/2, bouncer->sector->ceilingheight - + 70*FRACUNIT, false, true, -1); // move ceiling + } + else + { + T_MovePlane(bouncer->sector, bouncer->speed/2, bouncer->sector->ceilingheight - + 70*FRACUNIT, false, true, -1); // move ceiling + T_MovePlane(bouncer->sector, bouncer->speed/2, bouncer->sector->floorheight - 70*FRACUNIT, + false, false, -1); // move floor + } bouncer->sector->floorspeed = -bouncer->speed/2; bouncer->sector->ceilspeed = 42; From 8fee9a51ce546e414f619ad06639e85af4a5f543 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 23 May 2020 21:23:45 -0400 Subject: [PATCH 33/42] Add NOWIPE behavaior for colormap fades --- src/f_finale.h | 2 ++ src/f_wipe.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/f_finale.h b/src/f_finale.h index 63319d7d6..b3abf1778 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -162,7 +162,9 @@ extern wipestyleflags_t wipestyleflags; // Even my function names are borderline boolean F_ShouldColormapFade(void); boolean F_TryColormapFade(UINT8 wipecolor); +#ifndef NOWIPE void F_DecideWipeStyle(void); +#endif #define FADECOLORMAPDIV 8 #define FADECOLORMAPROWS (256/FADECOLORMAPDIV) diff --git a/src/f_wipe.c b/src/f_wipe.c index 08d7ed991..940b61c44 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -464,6 +464,7 @@ void F_WipeEndScreen(void) */ boolean F_ShouldColormapFade(void) { +#ifndef NOWIPE if ((wipestyleflags & (WSF_FADEIN|WSF_FADEOUT)) // only if one of those wipestyleflags are actually set && !(wipestyleflags & WSF_CROSSFADE)) // and if not crossfading { @@ -479,11 +480,13 @@ boolean F_ShouldColormapFade(void) // Menus || gamestate == GS_TIMEATTACK); } +#endif return false; } /** Decides what wipe style to use. */ +#ifndef NOWIPE void F_DecideWipeStyle(void) { // Set default wipe style @@ -493,6 +496,7 @@ void F_DecideWipeStyle(void) if (F_ShouldColormapFade()) wipestyle = WIPESTYLE_COLORMAP; } +#endif /** Attempt to run a colormap fade, provided all the conditionals were properly met. @@ -501,6 +505,7 @@ void F_DecideWipeStyle(void) */ boolean F_TryColormapFade(UINT8 wipecolor) { +#ifndef NOWIPE if (F_ShouldColormapFade()) { #ifdef HWRENDER @@ -510,6 +515,7 @@ boolean F_TryColormapFade(UINT8 wipecolor) return true; } else +#endif { F_WipeColorFill(wipecolor); return false; From 272362a86f38ee85a7f86c3615cba4ccd13d1546 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 23 May 2020 22:47:30 -0400 Subject: [PATCH 34/42] Fix NOWIPE bugs with colormap fade and title card --- src/f_wipe.c | 2 ++ src/g_game.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/f_wipe.c b/src/f_wipe.c index 940b61c44..01b45b0c2 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -614,6 +614,7 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu) tic_t F_GetWipeLength(UINT8 wipetype) { #ifdef NOWIPE + (void)wipetype; return 0; #else static char lumpname[10] = "FADEmmss"; @@ -640,6 +641,7 @@ tic_t F_GetWipeLength(UINT8 wipetype) boolean F_WipeExists(UINT8 wipetype) { #ifdef NOWIPE + (void)wipetype; return false; #else static char lumpname[10] = "FADEmm00"; diff --git a/src/g_game.c b/src/g_game.c index 92d71fbae..2f3ba9867 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1866,6 +1866,7 @@ void G_StartTitleCard(void) // void G_PreLevelTitleCard(void) { +#ifndef NOWIPE tic_t starttime = I_GetTime(); tic_t endtime = starttime + (PRELEVELTIME*NEWTICRATERATIO); tic_t nowtime = starttime; @@ -1888,6 +1889,7 @@ void G_PreLevelTitleCard(void) } if (!cv_showhud.value) wipestyleflags = WSF_CROSSFADE; +#endif } static boolean titlecardforreload = false; From 40566e69263ffec3ba641979286829dd721c9cf7 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 25 May 2020 21:27:48 +0100 Subject: [PATCH 35/42] Got_AddPlayer: check that I_GetNodeAddress(node) is non-NULL before using strcpy to copy it to the playeraddress array --- src/d_clisrv.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ed0b8e528..0892607b6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3291,7 +3291,6 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) boolean splitscreenplayer; boolean rejoined; player_t *newplayer; - char *port; if (playernum != serverplayer && !IsPlayerAdmin(playernum)) { @@ -3322,10 +3321,15 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) if (server && I_GetNodeAddress) { - strcpy(playeraddress[newplayernum], I_GetNodeAddress(node)); - port = strchr(playeraddress[newplayernum], ':'); - if (port) - *port = '\0'; + const char *address = I_GetNodeAddress(node); + char *port = NULL; + if (address) // MI: fix msvcrt.dll!_mbscat crash? + { + strcpy(playeraddress[newplayernum], address); + port = strchr(playeraddress[newplayernum], ':'); + if (port) + *port = '\0'; + } } } From 71cf31fcaf723e3710b6c9c69f8128d44a8b61ec Mon Sep 17 00:00:00 2001 From: sphere Date: Thu, 28 May 2020 18:43:04 +0200 Subject: [PATCH 36/42] Fix the "Custom skincolors" branch not compiling with GCC 10. --- src/d_main.c | 5 ++++- src/doomdef.h | 2 +- src/m_menu.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 96760c794..2e5519c83 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -125,6 +125,9 @@ boolean advancedemo; INT32 debugload = 0; #endif +UINT16 numskincolors; +menucolor_t *menucolorhead, *menucolortail; + char savegamename[256]; char srb2home[256] = "."; @@ -1190,7 +1193,7 @@ void D_SRB2Main(void) if (M_CheckParm("-password") && M_IsNextParm()) D_SetPassword(M_GetNextParm()); - + // player setup menu colors must be initialized before // any wad file is added, as they may contain colors themselves M_InitPlayerSetupColors(); diff --git a/src/doomdef.h b/src/doomdef.h index 120df8526..1cb491a10 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -396,7 +396,7 @@ typedef enum NUMSUPERCOLORS = ((SKINCOLOR_FIRSTFREESLOT - FIRSTSUPERCOLOR)/5) } skincolornum_t; -UINT16 numskincolors; +extern UINT16 numskincolors; extern skincolor_t skincolors[MAXSKINCOLORS]; diff --git a/src/m_menu.h b/src/m_menu.h index 240c4b235..cce5a6a6c 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -450,7 +450,7 @@ typedef struct menucolor_s { UINT16 color; } menucolor_t; -menucolor_t *menucolorhead, *menucolortail; +extern menucolor_t *menucolorhead, *menucolortail; void M_AddMenuColor(UINT16 color); void M_MoveColorBefore(UINT16 color, UINT16 targ); From a7f73bfa85cc7d5690cab2e6dae2290bc27b21e9 Mon Sep 17 00:00:00 2001 From: lachwright Date: Sun, 31 May 2020 01:21:26 +0800 Subject: [PATCH 37/42] Move drop shadows to the ceiling for objects in reverse gravity --- src/hardware/hw_main.c | 21 ++++++------ src/r_things.c | 73 ++++++++++++++++++++++-------------------- 2 files changed, 50 insertions(+), 44 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index bcb0afa6e..df5119814 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3862,20 +3862,21 @@ static void HWR_DrawDropShadow(mobj_t *thing, gr_vissprite_t *spr, fixed_t scale UINT8 lightlevel = 255; extracolormap_t *colormap = NULL; UINT8 i; + SINT8 flip = P_MobjFlip(thing); INT32 light; fixed_t scalemul; UINT16 alpha; fixed_t floordiff; - fixed_t floorz; + fixed_t groundz; fixed_t slopez; - pslope_t *floorslope; + pslope_t *groundslope; - floorz = R_GetShadowZ(thing, &floorslope); + groundz = R_GetShadowZ(thing, &groundslope); - //if (abs(floorz - gr_viewz) / tz > 4) return; // Prevent stretchy shadows and possible crashes + //if (abs(groundz - gr_viewz) / tz > 4) return; // Prevent stretchy shadows and possible crashes - floordiff = abs(thing->z - floorz); + floordiff = abs((flip < 0 ? thing->height : 0) + thing->z - groundz); alpha = floordiff / (4*FRACUNIT) + 75; if (alpha >= 255) return; @@ -3907,18 +3908,18 @@ static void HWR_DrawDropShadow(mobj_t *thing, gr_vissprite_t *spr, fixed_t scale shadowVerts[0].z = shadowVerts[1].z = fy - offset; shadowVerts[3].z = shadowVerts[2].z = fy + offset; - if (floorslope) + if (groundslope) { for (i = 0; i < 4; i++) { - slopez = P_GetSlopeZAt(floorslope, FLOAT_TO_FIXED(shadowVerts[i].x), FLOAT_TO_FIXED(shadowVerts[i].z)); - shadowVerts[i].y = FIXED_TO_FLOAT(slopez) + 0.05f; + slopez = P_GetSlopeZAt(groundslope, FLOAT_TO_FIXED(shadowVerts[i].x), FLOAT_TO_FIXED(shadowVerts[i].z)); + shadowVerts[i].y = FIXED_TO_FLOAT(slopez) + flip * 0.05f; } } else { for (i = 0; i < 4; i++) - shadowVerts[i].y = FIXED_TO_FLOAT(floorz) + 0.05f; + shadowVerts[i].y = FIXED_TO_FLOAT(groundz) + flip * 0.05f; } if (spr->flip) @@ -3946,7 +3947,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, gr_vissprite_t *spr, fixed_t scale if (thing->subsector->sector->numlights) { - light = R_GetPlaneLight(thing->subsector->sector, floorz, false); // Always use the light at the top instead of whatever I was doing before + light = R_GetPlaneLight(thing->subsector->sector, groundz, false); // Always use the light at the top instead of whatever I was doing before if (*thing->subsector->sector->lightlist[light].lightlevel > 255) lightlevel = 255; diff --git a/src/r_things.c b/src/r_things.c index 14782d0c2..561399859 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1096,27 +1096,29 @@ static void R_SplitSprite(vissprite_t *sprite) // fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) { - fixed_t z, floorz = INT32_MIN; - pslope_t *slope, *floorslope = NULL; + boolean isflipped = thing->eflags & MFE_VERTICALFLIP; + fixed_t z, groundz = isflipped ? INT32_MAX : INT32_MIN; + pslope_t *slope, *groundslope = NULL; msecnode_t *node; sector_t *sector; ffloor_t *rover; +#define CHECKZ (isflipped ? z > thing->z+thing->height/2 && z < groundz : z < thing->z+thing->height/2 && z > groundz) for (node = thing->touching_sectorlist; node; node = node->m_sectorlist_next) { sector = node->m_sector; - slope = sector->heightsec != -1 ? NULL : sector->f_slope; + slope = sector->heightsec != -1 ? NULL : (isflipped ? sector->c_slope : sector->f_slope); if (sector->heightsec != -1) - z = sectors[sector->heightsec].floorheight; + z = isflipped ? sectors[sector->heightsec].ceilingheight : sectors[sector->heightsec].floorheight; else - z = P_GetSectorFloorZAt(sector, thing->x, thing->y); + z = isflipped ? P_GetSectorCeilingZAt(sector, thing->x, thing->y) : P_GetSectorFloorZAt(sector, thing->x, thing->y); - if (z < thing->z+thing->height/2 && z > floorz) + if CHECKZ { - floorz = z; - floorslope = slope; + groundz = z; + groundslope = slope; } if (sector->ffloors) @@ -1125,23 +1127,25 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || (rover->alpha < 90 && !(rover->flags & FF_SWIMMABLE))) continue; - z = P_GetFFloorTopZAt(rover, thing->x, thing->y); - if (z < thing->z+thing->height/2 && z > floorz) + z = isflipped ? P_GetFFloorBottomZAt(rover, thing->x, thing->y) : P_GetFFloorTopZAt(rover, thing->x, thing->y); + if CHECKZ { - floorz = z; - floorslope = *rover->t_slope; + groundz = z; + groundslope = isflipped ? *rover->b_slope : *rover->t_slope; } } } - if (thing->floorz > floorz + (!floorslope ? 0 : FixedMul(abs(floorslope->zdelta), thing->radius*3/2))) + if (isflipped ? (thing->ceilingz < groundz - (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), thing->radius*3/2))) + : (thing->floorz > groundz + (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), thing->radius*3/2)))) { - floorz = thing->floorz; - floorslope = NULL; + groundz = isflipped ? thing->ceilingz : thing->floorz; + groundslope = NULL; } #if 0 // Unfortunately, this drops CEZ2 down to sub-17 FPS on my i7. - // Check polyobjects and see if floorz needs to be altered, for rings only because they don't update floorz + // NOTE: this section was not updated to reflect reverse gravity support + // Check polyobjects and see if groundz needs to be altered, for rings only because they don't update floorz if (thing->type == MT_RING) { INT32 xl, xh, yl, yh, bx, by; @@ -1186,10 +1190,10 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) // We're inside it! Yess... z = po->lines[0]->backsector->ceilingheight; - if (z < thing->z+thing->height/2 && z > floorz) + if (z < thing->z+thing->height/2 && z > groundz) { - floorz = z; - floorslope = NULL; + groundz = z; + groundslope = NULL; } } plink = (polymaplink_t *)(plink->link.next); @@ -1199,9 +1203,9 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) #endif if (shadowslope != NULL) - *shadowslope = floorslope; + *shadowslope = groundslope; - return floorz; + return groundz; } static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, fixed_t tx, fixed_t tz) @@ -1212,14 +1216,15 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, INT32 light = 0; fixed_t scalemul; UINT8 trans; fixed_t floordiff; - fixed_t floorz; - pslope_t *floorslope; + fixed_t groundz; + pslope_t *groundslope; + boolean isflipped = thing->eflags & MFE_VERTICALFLIP; - floorz = R_GetShadowZ(thing, &floorslope); + groundz = R_GetShadowZ(thing, &groundslope); - if (abs(floorz-viewz)/tz > 4) return; // Prevent stretchy shadows and possible crashes + if (abs(groundz-viewz)/tz > 4) return; // Prevent stretchy shadows and possible crashes - floordiff = abs(thing->z - floorz); + floordiff = abs((isflipped ? thing->height : 0) + thing->z - groundz); trans = floordiff / (100*FRACUNIT) + 3; if (trans >= 9) return; @@ -1230,23 +1235,23 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, xscale = FixedDiv(projection, tz); yscale = FixedDiv(projectiony, tz); shadowxscale = FixedMul(thing->radius*2, scalemul); - shadowyscale = FixedMul(FixedMul(thing->radius*2, scalemul), FixedDiv(abs(floorz - viewz), tz)); + shadowyscale = FixedMul(FixedMul(thing->radius*2, scalemul), FixedDiv(abs(groundz - viewz), tz)); shadowyscale = min(shadowyscale, shadowxscale) / SHORT(patch->height); shadowxscale /= SHORT(patch->width); shadowskew = 0; - if (floorslope) + if (groundslope) { // haha let's try some dumb stuff fixed_t xslope, zslope; - angle_t sloperelang = (R_PointToAngle(thing->x, thing->y) - floorslope->xydirection) >> ANGLETOFINESHIFT; + angle_t sloperelang = (R_PointToAngle(thing->x, thing->y) - groundslope->xydirection) >> ANGLETOFINESHIFT; - xslope = FixedMul(FINESINE(sloperelang), floorslope->zdelta); - zslope = FixedMul(FINECOSINE(sloperelang), floorslope->zdelta); + xslope = FixedMul(FINESINE(sloperelang), groundslope->zdelta); + zslope = FixedMul(FINECOSINE(sloperelang), groundslope->zdelta); //CONS_Printf("Shadow is sloped by %d %d\n", xslope, zslope); - if (viewz < floorz) + if (viewz < groundz) shadowyscale += FixedMul(FixedMul(thing->radius*2 / SHORT(patch->height), scalemul), zslope); else shadowyscale -= FixedMul(FixedMul(thing->radius*2 / SHORT(patch->height), scalemul), zslope); @@ -1271,7 +1276,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, shadow->heightsec = vis->heightsec; shadow->thingheight = FRACUNIT; - shadow->pz = floorz; + shadow->pz = groundz + (isflipped ? -shadow->thingheight : 0); shadow->pzt = shadow->pz + shadow->thingheight; shadow->mobjflags = 0; @@ -1279,7 +1284,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, shadow->dispoffset = vis->dispoffset - 5; shadow->gx = thing->x; shadow->gy = thing->y; - shadow->gzt = shadow->pz + SHORT(patch->height) * shadowyscale / 2; + shadow->gzt = (isflipped ? shadow->pzt : shadow->pz) + SHORT(patch->height) * shadowyscale / 2; shadow->gz = shadow->gzt - SHORT(patch->height) * shadowyscale; shadow->texturemid = FixedMul(thing->scale, FixedDiv(shadow->gzt - viewz, shadowyscale)); if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES) From f32d29f700bc5235613d3c2dd639b6e01988b3bb Mon Sep 17 00:00:00 2001 From: lachwright Date: Sun, 31 May 2020 01:26:23 +0800 Subject: [PATCH 38/42] Oops, forgot to #undef --- src/r_things.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/r_things.c b/src/r_things.c index 561399859..228c86a64 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1206,6 +1206,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) *shadowslope = groundslope; return groundz; +#undef CHECKZ } static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, fixed_t tx, fixed_t tz) From 1bacaedde23b2da9d579c4aad3017e1c3cd7c06e Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sat, 30 May 2020 20:24:33 +0200 Subject: [PATCH 39/42] Show the traceback when a Lua script error happens --- src/lua_hooklib.c | 224 ++++++++++++++++++++++++++++++---------------- src/lua_script.c | 56 +++++++++++- src/lua_script.h | 1 + 3 files changed, 202 insertions(+), 79 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index d4fe72682..9f5501a67 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -253,6 +253,7 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which) I_Assert(mo->type < NUMMOBJTYPES); lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); // Look for all generic mobj hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) @@ -260,12 +261,12 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which) if (hookp->type != which) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, mo, META_MOBJ); lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 0)) { + if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -282,12 +283,12 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which) if (hookp->type != which) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, mo, META_MOBJ); lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 0)) { + if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -311,18 +312,19 @@ boolean LUAh_PlayerHook(player_t *plr, enum hook which) return false; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = playerhooks; hookp; hookp = hookp->next) { if (hookp->type != which) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, plr, META_PLAYER); lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 0)) { + if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -346,6 +348,7 @@ void LUAh_MapChange(INT16 mapnumber) return; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); lua_pushinteger(gL, mapnumber); for (hookp = roothook; hookp; hookp = hookp->next) @@ -356,7 +359,10 @@ void LUAh_MapChange(INT16 mapnumber) lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -2); - LUA_Call(gL, 1); + if (lua_pcall(gL, 1, 0, 1)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + } } lua_settop(gL, 0); @@ -370,6 +376,7 @@ void LUAh_MapLoad(void) return; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); lua_pushinteger(gL, gamemap); for (hookp = roothook; hookp; hookp = hookp->next) @@ -380,7 +387,10 @@ void LUAh_MapLoad(void) lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -2); - LUA_Call(gL, 1); + if (lua_pcall(gL, 1, 0, 1)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + } } lua_settop(gL, 0); @@ -394,6 +404,7 @@ void LUAh_PlayerJoin(int playernum) return; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); lua_pushinteger(gL, playernum); for (hookp = roothook; hookp; hookp = hookp->next) @@ -404,7 +415,10 @@ void LUAh_PlayerJoin(int playernum) lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -2); - LUA_Call(gL, 1); + if (lua_pcall(gL, 1, 0, 1)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + } } lua_settop(gL, 0); @@ -417,6 +431,8 @@ void LUAh_PreThinkFrame(void) if (!gL || !(hooksAvailable[hook_PreThinkFrame/8] & (1<<(hook_PreThinkFrame%8)))) return; + lua_pushcfunction(gL, LUA_GetErrorMessage); + for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type != hook_PreThinkFrame) @@ -424,13 +440,15 @@ void LUAh_PreThinkFrame(void) lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); - if (lua_pcall(gL, 0, 0, 0)) { + if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); hookp->error = true; } } + + lua_pop(gL, 1); // Pop error handler } // Hook for frame (after mobj and player thinkers) @@ -440,6 +458,8 @@ void LUAh_ThinkFrame(void) if (!gL || !(hooksAvailable[hook_ThinkFrame/8] & (1<<(hook_ThinkFrame%8)))) return; + lua_pushcfunction(gL, LUA_GetErrorMessage); + for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type != hook_ThinkFrame) @@ -447,15 +467,16 @@ void LUAh_ThinkFrame(void) lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); - if (lua_pcall(gL, 0, 0, 0)) { + if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); hookp->error = true; } } -} + lua_pop(gL, 1); // Pop error handler +} // Hook for frame (at end of tick, ie after overlays, precipitation, specials) void LUAh_PostThinkFrame(void) @@ -464,6 +485,8 @@ void LUAh_PostThinkFrame(void) if (!gL || !(hooksAvailable[hook_PostThinkFrame/8] & (1<<(hook_PostThinkFrame%8)))) return; + lua_pushcfunction(gL, LUA_GetErrorMessage); + for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type != hook_PostThinkFrame) @@ -471,13 +494,15 @@ void LUAh_PostThinkFrame(void) lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); - if (lua_pcall(gL, 0, 0, 0)) { + if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); hookp->error = true; } } + + lua_pop(gL, 1); // Pop error handler } // Hook for mobj collisions @@ -491,6 +516,7 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) I_Assert(thing1->type < NUMMOBJTYPES); lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); // Look for all generic mobj collision hooks for (hookp = mobjcollidehooks[MT_NULL]; hookp; hookp = hookp->next) @@ -498,7 +524,7 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) if (hookp->type != which) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, thing1, META_MOBJ); LUA_PushUserdata(gL, thing2, META_MOBJ); @@ -507,7 +533,7 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -529,7 +555,7 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) if (hookp->type != which) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, thing1, META_MOBJ); LUA_PushUserdata(gL, thing2, META_MOBJ); @@ -538,7 +564,7 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -569,6 +595,7 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which) I_Assert(thing->type < NUMMOBJTYPES); lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); // Look for all generic mobj collision hooks for (hookp = mobjcollidehooks[MT_NULL]; hookp; hookp = hookp->next) @@ -576,7 +603,7 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which) if (hookp->type != which) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, thing, META_MOBJ); LUA_PushUserdata(gL, line, META_LINE); @@ -585,7 +612,7 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -607,7 +634,7 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which) if (hookp->type != which) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, thing, META_MOBJ); LUA_PushUserdata(gL, line, META_LINE); @@ -616,7 +643,7 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -648,16 +675,17 @@ boolean LUAh_MobjThinker(mobj_t *mo) I_Assert(mo->type < NUMMOBJTYPES); lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); // Look for all generic mobj thinker hooks for (hookp = mobjthinkerhooks[MT_NULL]; hookp; hookp = hookp->next) { - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, mo, META_MOBJ); lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 0)) { + if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -671,12 +699,12 @@ boolean LUAh_MobjThinker(mobj_t *mo) for (hookp = mobjthinkerhooks[mo->type]; hookp; hookp = hookp->next) { - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, mo, META_MOBJ); lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 0)) { + if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -703,6 +731,7 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) I_Assert(special->type < NUMMOBJTYPES); lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); // Look for all generic touch special hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) @@ -710,7 +739,7 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) if (hookp->type != hook_TouchSpecial) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, special, META_MOBJ); LUA_PushUserdata(gL, toucher, META_MOBJ); @@ -719,7 +748,7 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -736,7 +765,7 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) if (hookp->type != hook_TouchSpecial) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, special, META_MOBJ); LUA_PushUserdata(gL, toucher, META_MOBJ); @@ -745,7 +774,7 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -772,6 +801,7 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 I_Assert(target->type < NUMMOBJTYPES); lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); // Look for all generic should damage hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) @@ -779,7 +809,7 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 if (hookp->type != hook_ShouldDamage) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, inflictor, META_MOBJ); @@ -794,7 +824,7 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); - if (lua_pcall(gL, 5, 1, 0)) { + if (lua_pcall(gL, 5, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -815,7 +845,7 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 { if (hookp->type != hook_ShouldDamage) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, inflictor, META_MOBJ); @@ -830,7 +860,7 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); - if (lua_pcall(gL, 5, 1, 0)) { + if (lua_pcall(gL, 5, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -862,6 +892,7 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 I_Assert(target->type < NUMMOBJTYPES); lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); // Look for all generic mobj damage hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) @@ -869,7 +900,7 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 if (hookp->type != hook_MobjDamage) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, inflictor, META_MOBJ); @@ -884,7 +915,7 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); - if (lua_pcall(gL, 5, 1, 0)) { + if (lua_pcall(gL, 5, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -901,7 +932,7 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 if (hookp->type != hook_MobjDamage) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, inflictor, META_MOBJ); @@ -916,7 +947,7 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); - if (lua_pcall(gL, 5, 1, 0)) { + if (lua_pcall(gL, 5, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -943,6 +974,7 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 I_Assert(target->type < NUMMOBJTYPES); lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); // Look for all generic mobj death hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) @@ -950,7 +982,7 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 if (hookp->type != hook_MobjDeath) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, inflictor, META_MOBJ); @@ -963,7 +995,7 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 0)) { + if (lua_pcall(gL, 4, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -980,7 +1012,7 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 if (hookp->type != hook_MobjDeath) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, inflictor, META_MOBJ); @@ -993,7 +1025,7 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 0)) { + if (lua_pcall(gL, 4, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1018,13 +1050,14 @@ boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd) return false; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type != hook_BotTiccmd) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, bot, META_PLAYER); LUA_PushUserdata(gL, cmd, META_TICCMD); @@ -1033,7 +1066,7 @@ boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1058,6 +1091,7 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) return false; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) { @@ -1065,7 +1099,7 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) || (hookp->s.str && strcmp(hookp->s.str, ((skin_t*)tails->skin)->name))) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, sonic, META_MOBJ); LUA_PushUserdata(gL, tails, META_MOBJ); @@ -1074,7 +1108,7 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 8, 0)) { + if (lua_pcall(gL, 2, 8, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1121,13 +1155,14 @@ boolean LUAh_BotRespawn(mobj_t *sonic, mobj_t *tails) return false; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type != hook_BotRespawn) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, sonic, META_MOBJ); LUA_PushUserdata(gL, tails, META_MOBJ); @@ -1136,7 +1171,7 @@ boolean LUAh_BotRespawn(mobj_t *sonic, mobj_t *tails) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1166,13 +1201,14 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) return 0; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = linedefexecutorhooks; hookp; hookp = hookp->next) { if (strcmp(hookp->s.str, line->text)) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, line, META_LINE); LUA_PushUserdata(gL, mo, META_MOBJ); @@ -1183,7 +1219,10 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); - LUA_Call(gL, 3); + if (lua_pcall(gL, 3, 0, 1)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + } hooked = true; } @@ -1200,13 +1239,14 @@ boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg) return false; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type != hook_PlayerMsg) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player if (flags & 2 /*HU_CSAY*/) { // csay TODO: make HU_CSAY accessible outside hu_stuff.c @@ -1230,7 +1270,7 @@ boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg) lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 0)) { + if (lua_pcall(gL, 4, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1256,6 +1296,7 @@ boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 return false; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) { @@ -1263,7 +1304,7 @@ boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 || (hookp->s.mt && !(inflictor && hookp->s.mt == inflictor->type))) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, inflictor, META_MOBJ); @@ -1276,7 +1317,7 @@ boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 0)) { + if (lua_pcall(gL, 4, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1295,7 +1336,7 @@ boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 void LUAh_NetArchiveHook(lua_CFunction archFunc) { hook_p hookp; - + int errorhandlerindex; if (!gL || !(hooksAvailable[hook_NetVars/8] & (1<<(hook_NetVars%8)))) return; @@ -1303,8 +1344,11 @@ void LUAh_NetArchiveHook(lua_CFunction archFunc) I_Assert(lua_gettop(gL) > 0); I_Assert(lua_istable(gL, -1)); + lua_pushcfunction(gL, LUA_GetErrorMessage); + errorhandlerindex = lua_gettop(gL); + // tables becomes an upvalue of archFunc - lua_pushvalue(gL, -1); + lua_pushvalue(gL, -2); lua_pushcclosure(gL, archFunc, 1); // stack: tables, archFunc @@ -1316,10 +1360,13 @@ void LUAh_NetArchiveHook(lua_CFunction archFunc) lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -2); // archFunc - LUA_Call(gL, 1); + if (lua_pcall(gL, 1, 0, errorhandlerindex)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + } } - lua_pop(gL, 1); // pop archFunc + lua_pop(gL, 2); // Pop archFunc and error handler // stack: tables } @@ -1331,6 +1378,7 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing) return false; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); // Look for all generic mobj map thing spawn hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) @@ -1338,7 +1386,7 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing) if (hookp->type != hook_MapThingSpawn) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, mo, META_MOBJ); LUA_PushUserdata(gL, mthing, META_MAPTHING); @@ -1347,7 +1395,7 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1364,7 +1412,7 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing) if (hookp->type != hook_MapThingSpawn) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, mo, META_MOBJ); LUA_PushUserdata(gL, mthing, META_MAPTHING); @@ -1373,7 +1421,7 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1398,6 +1446,7 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj) return 0; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); // Look for all generic mobj follow item hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) @@ -1405,7 +1454,7 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj) if (hookp->type != hook_FollowMobj) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, mobj, META_MOBJ); @@ -1414,7 +1463,7 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1431,7 +1480,7 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj) if (hookp->type != hook_FollowMobj) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, mobj, META_MOBJ); @@ -1440,7 +1489,7 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1465,13 +1514,14 @@ UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj) return 0; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = playerhooks; hookp; hookp = hookp->next) { if (hookp->type != hook_PlayerCanDamage) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, mobj, META_MOBJ); @@ -1480,7 +1530,7 @@ UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1508,13 +1558,14 @@ void LUAh_PlayerQuit(player_t *plr, kickreason_t reason) return; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type != hook_PlayerQuit) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit lua_pushinteger(gL, reason); // Reason for quitting @@ -1523,7 +1574,10 @@ void LUAh_PlayerQuit(player_t *plr, kickreason_t reason) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - LUA_Call(gL, 2); + if (lua_pcall(gL, 2, 0, 1)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + } } lua_settop(gL, 0); @@ -1536,6 +1590,8 @@ void LUAh_IntermissionThinker(void) if (!gL || !(hooksAvailable[hook_IntermissionThinker/8] & (1<<(hook_IntermissionThinker%8)))) return; + lua_pushcfunction(gL, LUA_GetErrorMessage); + for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type != hook_IntermissionThinker) @@ -1543,13 +1599,15 @@ void LUAh_IntermissionThinker(void) lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); - if (lua_pcall(gL, 0, 0, 0)) { + if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); hookp->error = true; } } + + lua_pop(gL, 1); // Pop error handler } // Hook for team switching @@ -1562,13 +1620,14 @@ boolean LUAh_TeamSwitch(player_t *player, int newteam, boolean fromspectators, b return true; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = playerhooks; hookp; hookp = hookp->next) { if (hookp->type != hook_TeamSwitch) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, player, META_PLAYER); lua_pushinteger(gL, newteam); @@ -1583,7 +1642,7 @@ boolean LUAh_TeamSwitch(player_t *player, int newteam, boolean fromspectators, b lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); - if (lua_pcall(gL, 5, 1, 0)) { + if (lua_pcall(gL, 5, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1608,6 +1667,8 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean return 0; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + hud_running = true; // local hook for (hookp = playerhooks; hookp; hookp = hookp->next) @@ -1615,7 +1676,7 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean if (hookp->type != hook_ViewpointSwitch) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, newdisplayplayer, META_PLAYER); @@ -1626,7 +1687,7 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 0)) { + if (lua_pcall(gL, 3, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1644,6 +1705,7 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean } lua_settop(gL, 0); + hud_running = false; return canSwitchView; @@ -1659,6 +1721,8 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) return true; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + hud_running = true; // local hook for (hookp = playerhooks; hookp; hookp = hookp->next) @@ -1666,7 +1730,7 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) if (hookp->type != hook_SeenPlayer) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, seenfriend, META_PLAYER); @@ -1675,7 +1739,7 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1688,6 +1752,7 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) } lua_settop(gL, 0); + hud_running = false; return hasSeenPlayer; @@ -1702,6 +1767,8 @@ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) return true; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + hud_running = true; // local hook for (hookp = roothook; hookp; hookp = hookp->next) @@ -1710,7 +1777,7 @@ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) || (hookp->s.str && strcmp(hookp->s.str, musname))) continue; - if (lua_gettop(gL) == 0) + if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, player, META_PLAYER); lua_pushstring(gL, musname); @@ -1719,7 +1786,7 @@ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { + if (lua_pcall(gL, 2, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); @@ -1732,6 +1799,7 @@ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) } lua_settop(gL, 0); + hud_running = false; return keepplaying; diff --git a/src/lua_script.c b/src/lua_script.c index 4f94b007e..06ea18b0e 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -78,6 +78,58 @@ FUNCNORETURN static int LUA_Panic(lua_State *L) #endif } +#define LEVELS1 12 // size of the first part of the stack +#define LEVELS2 10 // size of the second part of the stack + +// Error handler used with pcall() when loading scripts or calling hooks +// Takes a string with the original error message, +// appends the traceback to it, and return the result +int LUA_GetErrorMessage(lua_State *L) +{ + int level = 1; + int firstpart = 1; // still before eventual `...' + lua_Debug ar; + + lua_pushliteral(L, "\nstack traceback:"); + while (lua_getstack(L, level++, &ar)) + { + if (level > LEVELS1 && firstpart) + { + // no more than `LEVELS2' more levels? + if (!lua_getstack(L, level + LEVELS2, &ar)) + level--; // keep going + else + { + lua_pushliteral(L, "\n ..."); // too many levels + while (lua_getstack(L, level + LEVELS2, &ar)) // find last levels + level++; + } + firstpart = 0; + continue; + } + lua_pushliteral(L, "\n "); + lua_getinfo(L, "Snl", &ar); + lua_pushfstring(L, "%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + if (*ar.namewhat != '\0') // is there a name? + lua_pushfstring(L, " in function " LUA_QS, ar.name); + else + { + if (*ar.what == 'm') // main? + lua_pushfstring(L, " in main chunk"); + else if (*ar.what == 'C' || *ar.what == 't') + lua_pushliteral(L, " ?"); // C function or tail call + else + lua_pushfstring(L, " in function <%s:%d>", + ar.short_src, ar.linedefined); + } + lua_concat(L, lua_gettop(L)); + } + lua_concat(L, lua_gettop(L)); + return 1; +} + // Moved here from lib_getenum. int LUA_PushGlobals(lua_State *L, const char *word) { @@ -410,11 +462,13 @@ static inline void LUA_LoadFile(MYFILE *f, char *name) lua_lumploading = true; // turn on loading flag - if (luaL_loadbuffer(gL, f->data, f->size, va("@%s",name)) || lua_pcall(gL, 0, 0, 0)) { + lua_pushcfunction(gL, LUA_GetErrorMessage); + if (luaL_loadbuffer(gL, f->data, f->size, va("@%s",name)) || lua_pcall(gL, 0, 0, lua_gettop(gL) - 1)) { CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1)); lua_pop(gL,1); } lua_gc(gL, LUA_GCCOLLECT, 0); + lua_pop(gL, 1); // Pop error handler lua_lumploading = false; // turn off again } diff --git a/src/lua_script.h b/src/lua_script.h index 8d5bed7c7..9568503e1 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -39,6 +39,7 @@ void LUA_ClearExtVars(void); extern boolean lua_lumploading; // is LUA_LoadLump being called? +int LUA_GetErrorMessage(lua_State *L); void LUA_LoadLump(UINT16 wad, UINT16 lump); #ifdef LUA_ALLOW_BYTECODE void LUA_DumpFile(const char *filename); From d31346822d3755ce48b6f8c671cfe2172c55bbf3 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sat, 30 May 2020 20:28:45 +0200 Subject: [PATCH 40/42] Refactor hook library a little --- src/lua_hooklib.c | 129 +++++++++++++++++----------------------------- 1 file changed, 47 insertions(+), 82 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 9f5501a67..b3390eb95 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -108,6 +108,12 @@ static hook_p linedefexecutorhooks; // For other hooks, a unique linked list hook_p roothook; +static void PushHook(lua_State *L, hook_p hookp) +{ + lua_pushfstring(L, FMT_HOOKID, hookp->id); + lua_gettable(L, LUA_REGISTRYINDEX); +} + // Takes hook, function, and additional arguments (mobj type to act on, etc.) static int lib_addHook(lua_State *L) { @@ -263,8 +269,7 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which) if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, mo, META_MOBJ); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) @@ -285,8 +290,7 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which) if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, mo, META_MOBJ); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) @@ -321,8 +325,7 @@ boolean LUAh_PlayerHook(player_t *plr, enum hook which) if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, plr, META_PLAYER); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) @@ -356,8 +359,7 @@ void LUAh_MapChange(INT16 mapnumber) if (hookp->type != hook_MapChange) continue; - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 0, 1)) { CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); @@ -384,8 +386,7 @@ void LUAh_MapLoad(void) if (hookp->type != hook_MapLoad) continue; - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 0, 1)) { CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); @@ -412,8 +413,7 @@ void LUAh_PlayerJoin(int playernum) if (hookp->type != hook_PlayerJoin) continue; - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 0, 1)) { CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); @@ -438,8 +438,7 @@ void LUAh_PreThinkFrame(void) if (hookp->type != hook_PreThinkFrame) continue; - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); @@ -465,8 +464,7 @@ void LUAh_ThinkFrame(void) if (hookp->type != hook_ThinkFrame) continue; - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); @@ -492,8 +490,7 @@ void LUAh_PostThinkFrame(void) if (hookp->type != hook_PostThinkFrame) continue; - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); @@ -529,8 +526,7 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) LUA_PushUserdata(gL, thing1, META_MOBJ); LUA_PushUserdata(gL, thing2, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -560,8 +556,7 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) LUA_PushUserdata(gL, thing1, META_MOBJ); LUA_PushUserdata(gL, thing2, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -608,8 +603,7 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which) LUA_PushUserdata(gL, thing, META_MOBJ); LUA_PushUserdata(gL, line, META_LINE); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -639,8 +633,7 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which) LUA_PushUserdata(gL, thing, META_MOBJ); LUA_PushUserdata(gL, line, META_LINE); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -682,8 +675,7 @@ boolean LUAh_MobjThinker(mobj_t *mo) { if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, mo, META_MOBJ); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) @@ -701,8 +693,7 @@ boolean LUAh_MobjThinker(mobj_t *mo) { if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, mo, META_MOBJ); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) @@ -744,8 +735,7 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) LUA_PushUserdata(gL, special, META_MOBJ); LUA_PushUserdata(gL, toucher, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -770,8 +760,7 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) LUA_PushUserdata(gL, special, META_MOBJ); LUA_PushUserdata(gL, toucher, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -817,8 +806,7 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 lua_pushinteger(gL, damage); lua_pushinteger(gL, damagetype); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); @@ -853,8 +841,7 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 lua_pushinteger(gL, damage); lua_pushinteger(gL, damagetype); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); @@ -908,8 +895,7 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 lua_pushinteger(gL, damage); lua_pushinteger(gL, damagetype); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); @@ -940,8 +926,7 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 lua_pushinteger(gL, damage); lua_pushinteger(gL, damagetype); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); @@ -989,8 +974,7 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 LUA_PushUserdata(gL, source, META_MOBJ); lua_pushinteger(gL, damagetype); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); @@ -1019,8 +1003,7 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 LUA_PushUserdata(gL, source, META_MOBJ); lua_pushinteger(gL, damagetype); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); @@ -1062,8 +1045,7 @@ boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd) LUA_PushUserdata(gL, bot, META_PLAYER); LUA_PushUserdata(gL, cmd, META_TICCMD); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -1104,8 +1086,7 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) LUA_PushUserdata(gL, sonic, META_MOBJ); LUA_PushUserdata(gL, tails, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 8, 1)) { @@ -1167,8 +1148,7 @@ boolean LUAh_BotRespawn(mobj_t *sonic, mobj_t *tails) LUA_PushUserdata(gL, sonic, META_MOBJ); LUA_PushUserdata(gL, tails, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -1214,8 +1194,7 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) LUA_PushUserdata(gL, mo, META_MOBJ); LUA_PushUserdata(gL, sector, META_SECTOR); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); @@ -1264,8 +1243,7 @@ boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg) } lua_pushstring(gL, msg); // msg } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); @@ -1311,8 +1289,7 @@ boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 LUA_PushUserdata(gL, source, META_MOBJ); lua_pushinteger(gL, damagetype); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); @@ -1357,8 +1334,7 @@ void LUAh_NetArchiveHook(lua_CFunction archFunc) if (hookp->type != hook_NetVars) continue; - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -2); // archFunc if (lua_pcall(gL, 1, 0, errorhandlerindex)) { CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); @@ -1391,8 +1367,7 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing) LUA_PushUserdata(gL, mo, META_MOBJ); LUA_PushUserdata(gL, mthing, META_MAPTHING); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -1417,8 +1392,7 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing) LUA_PushUserdata(gL, mo, META_MOBJ); LUA_PushUserdata(gL, mthing, META_MAPTHING); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -1459,8 +1433,7 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj) LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, mobj, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -1485,8 +1458,7 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj) LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, mobj, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -1526,8 +1498,7 @@ UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj) LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, mobj, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -1570,8 +1541,7 @@ void LUAh_PlayerQuit(player_t *plr, kickreason_t reason) LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit lua_pushinteger(gL, reason); // Reason for quitting } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 0, 1)) { @@ -1597,8 +1567,7 @@ void LUAh_IntermissionThinker(void) if (hookp->type != hook_IntermissionThinker) continue; - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); @@ -1635,8 +1604,7 @@ boolean LUAh_TeamSwitch(player_t *player, int newteam, boolean fromspectators, b lua_pushboolean(gL, tryingautobalance); lua_pushboolean(gL, tryingscramble); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); @@ -1682,8 +1650,7 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean LUA_PushUserdata(gL, newdisplayplayer, META_PLAYER); lua_pushboolean(gL, forced); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); @@ -1735,8 +1702,7 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, seenfriend, META_PLAYER); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -1782,8 +1748,7 @@ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) LUA_PushUserdata(gL, player, META_PLAYER); lua_pushstring(gL, musname); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { From 3a4502fa877a2d483b2d058d94f9f10170c97263 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sun, 31 May 2020 22:44:25 +0200 Subject: [PATCH 41/42] Netsync waypoint sequences --- src/p_saveg.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index d6abf4232..8f6e3bd36 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -717,6 +717,34 @@ static void P_NetUnArchiveColormaps(void) net_colormaps = NULL; } +static void P_NetArchiveWaypoints(void) +{ + INT32 i, j; + + for (i = 0; i < NUMWAYPOINTSEQUENCES; i++) + { + WRITEUINT16(save_p, numwaypoints[i]); + for (j = 0; j < numwaypoints[i]; j++) + WRITEUINT32(save_p, waypoints[i][j] ? waypoints[i][j]->mobjnum : 0xffff); + } +} + +static void P_NetUnArchiveWaypoints(void) +{ + INT32 i, j; + UINT32 mobjnum; + + for (i = 0; i < NUMWAYPOINTSEQUENCES; i++) + { + numwaypoints[i] = READUINT16(save_p); + for (j = 0; j < numwaypoints[i]; j++) + { + mobjnum = READUINT32(save_p); + waypoints[i][j] = (mobjnum == 0xffff) ? NULL : P_FindNewPosition(mobjnum); + } + } +} + /// /// World Archiving /// @@ -4042,6 +4070,7 @@ void P_SaveNetGame(void) P_NetArchiveThinkers(); P_NetArchiveSpecials(); P_NetArchiveColormaps(); + P_NetArchiveWaypoints(); } LUA_Archive(); @@ -4080,6 +4109,7 @@ boolean P_LoadNetGame(void) P_NetUnArchiveThinkers(); P_NetUnArchiveSpecials(); P_NetUnArchiveColormaps(); + P_NetUnArchiveWaypoints(); P_RelinkPointers(); P_FinishMobjs(); } From 508160ed425d012563cacab14041338f94debbca Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sun, 31 May 2020 22:58:14 +0200 Subject: [PATCH 42/42] Use 0 instead of 0xffff as dummy mobjnum --- src/p_saveg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 8f6e3bd36..6f80949ea 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -725,7 +725,7 @@ static void P_NetArchiveWaypoints(void) { WRITEUINT16(save_p, numwaypoints[i]); for (j = 0; j < numwaypoints[i]; j++) - WRITEUINT32(save_p, waypoints[i][j] ? waypoints[i][j]->mobjnum : 0xffff); + WRITEUINT32(save_p, waypoints[i][j] ? waypoints[i][j]->mobjnum : 0); } } @@ -740,7 +740,7 @@ static void P_NetUnArchiveWaypoints(void) for (j = 0; j < numwaypoints[i]; j++) { mobjnum = READUINT32(save_p); - waypoints[i][j] = (mobjnum == 0xffff) ? NULL : P_FindNewPosition(mobjnum); + waypoints[i][j] = (mobjnum == 0) ? NULL : P_FindNewPosition(mobjnum); } } }