From b85a55137cfef0a18b297c59e62018586323a2e9 Mon Sep 17 00:00:00 2001 From: haya_underscore Date: Sun, 9 Oct 2022 10:45:51 +0800 Subject: [PATCH] Gamer --- src/d_netcmd.c | 22 +++++++------- src/d_netcmd.h | 6 ++-- src/lua_mobjlib.c | 17 +++++------ src/m_menu.c | 74 ++++++++++++++++++++++++++++++++++++++++++----- src/r_things.c | 69 +++++++++++++++++++++++-------------------- src/r_things.h | 2 ++ 6 files changed, 127 insertions(+), 63 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index d554c344b..84ee801ff 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -289,10 +289,6 @@ consvar_t cv_skin3 = {"skin3", DEFAULTSKIN3, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Sk consvar_t cv_skin4 = {"skin4", DEFAULTSKIN4, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Skin4_OnChange, 0, NULL, NULL, 0, 0, NULL}; // haha I've beaten you now, ONLINE consvar_t cv_localskin = {"internal___localskin", "none", CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_localskin2 = {"internal___localskin2", "none", CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_localskin3 = {"internal___localskin3", "none", CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_localskin4 = {"internal___localskin4", "none", CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_localskinall = {"internal___localskinall", "none", CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_skipmapcheck = {"skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -451,6 +447,7 @@ static CV_PossibleValue_t basenumlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, " consvar_t cv_basenumlaps = {"basenumlaps", "Map default", CV_NETVAR|CV_CALL|CV_CHEAT, basenumlaps_cons_t, BaseNumLaps_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_forceskin = {"forceskin", "Off", CV_NETVAR|CV_CALL|CV_CHEAT, Forceskin_cons_t, ForceSkin_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fakelocalskin = {"fakelocalskin", "None", CV_SAVE, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_downloading = {"downloading", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowexitlevel = {"allowexitlevel", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -472,6 +469,7 @@ consvar_t cv_showping = {"showping", "Always", CV_SAVE, showping_cons_t, NULL, 0 static CV_PossibleValue_t pingmeasurement_cons_t[] = {{0, "Frames"}, {1, "Milliseconds"}, {0, NULL}}; consvar_t cv_pingmeasurement = {"pingmeasurement", "Frames", CV_SAVE, pingmeasurement_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; @@ -755,6 +753,9 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_showping); CV_RegisterVar(&cv_pingmeasurement); + CV_RegisterVar(&cv_luaimmersion); + CV_RegisterVar(&cv_fakelocalskin); + CV_RegisterVar(&cv_showtrackaddon); CV_RegisterVar(&cv_showviewpointtext); @@ -862,18 +863,14 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_playername2); CV_RegisterVar(&cv_playercolor2); CV_RegisterVar(&cv_skin2); - CV_RegisterVar(&cv_localskin2); // third player CV_RegisterVar(&cv_playername3); CV_RegisterVar(&cv_playercolor3); CV_RegisterVar(&cv_skin3); - CV_RegisterVar(&cv_localskin3); // fourth player CV_RegisterVar(&cv_playername4); CV_RegisterVar(&cv_playercolor4); CV_RegisterVar(&cv_skin4); - CV_RegisterVar(&cv_localskin4); - CV_RegisterVar(&cv_localskinall); // preferred number of players CV_RegisterVar(&cv_splitplayers); @@ -4559,15 +4556,18 @@ static void Command_GLocalSkin (void) { for (idx = 0; idx < ap_count_args(parser); idx++) { if (disply) { - SetLocalPlayerSkin(displayplayers[0], ap_arg(parser, idx), &cv_localskin); + SetLocalPlayerSkin(displayplayers[0], ap_arg(parser, idx), NULL); return; } else { for (i = 0; i < MAXPLAYERS; i++) { if (allp) { - SetLocalPlayerSkin(i, ap_arg(parser, idx), &cv_localskinall); + SetLocalPlayerSkin(i, ap_arg(parser, idx), NULL); } else { if (fasticmp(player_names[i], ap_str_value(parser, "player"))) { - SetLocalPlayerSkin(i, ap_arg(parser, idx), &cv_localskin); + if (fasticmp(player_names[i], cv_playername.string)) + SetLocalPlayerSkin(i, ap_arg(parser, idx), &cv_localskin); + else + SetLocalPlayerSkin(i, ap_arg(parser, idx), NULL); break; } } diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 7303470ef..23f5a87ee 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -26,18 +26,14 @@ extern consvar_t cv_localskin; extern consvar_t cv_playername2; extern consvar_t cv_playercolor2; extern consvar_t cv_skin2; -extern consvar_t cv_localskin2; // third splitscreen player extern consvar_t cv_playername3; extern consvar_t cv_playercolor3; extern consvar_t cv_skin3; -extern consvar_t cv_localskin3; // fourth splitscreen player extern consvar_t cv_playername4; extern consvar_t cv_playercolor4; extern consvar_t cv_skin4; -extern consvar_t cv_localskin4; -extern consvar_t cv_localskinall; // preferred number of players extern consvar_t cv_splitplayers; @@ -156,6 +152,8 @@ extern consvar_t cv_showping; extern consvar_t cv_pingmeasurement; extern consvar_t cv_showviewpointtext; +extern consvar_t cv_luaimmersion; +extern consvar_t cv_fakelocalskin; extern consvar_t cv_skipmapcheck; diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 8419fc1e6..afb918814 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -18,6 +18,7 @@ #include "g_game.h" #include "p_setup.h" #include "doomdef.h" +#include "d_netcmd.h" #include "lua_script.h" #include "lua_libs.h" @@ -245,10 +246,14 @@ static int mobj_get(lua_State *L) case mobj_skin: // skin name or nil, not struct if (!mo->skin) return 0; - if (mo->localskin) // pretty cool, but also destructive - lua_pushstring(L, ((skin_t *)mo->localskin)->name); - else + if (hud_running && cv_luaimmersion.value) { + if (mo->localskin) // HUD ONLY!!!!!!!!!! + lua_pushstring(L, ((skin_t *)mo->localskin)->name); + else + lua_pushstring(L, ((skin_t *)mo->skin)->name); + } else { lua_pushstring(L, ((skin_t *)mo->skin)->name); + } break; case mobj_color: lua_pushinteger(L, mo->color); @@ -522,12 +527,6 @@ static int mobj_set(lua_State *L) char skin[SKINNAMESIZE+1]; // all skin names are limited to this length strlcpy(skin, luaL_checkstring(L, 3), sizeof skin); strlwr(skin); // all skin names are lowercase - // nope, not this time chief. - if (fastcmp(localskins[players[consoleplayer].localskin - 1].name, skin)) - { - mo->skin = &skins[players[consoleplayer].skin]; // we dont want to use our local skin for this!!!!!!!!! - return 0; - } for (i = 0; i < numskins; i++) { if (fastcmp(skins[i].name, skin)) { diff --git a/src/m_menu.c b/src/m_menu.c index 54f4c508a..614f7f0a3 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -231,6 +231,8 @@ menu_t SR_MainDef, SR_UnlockChecklistDef; static void M_SinglePlayerMenu(INT32 choice); #endif static void M_Options(INT32 choice); +static void M_LocalSkinMenu(INT32 choice); +static void M_LocalSkinChange(INT32 choice); static void M_Manual(INT32 choice); static void M_SelectableClearMenus(INT32 choice); static void M_Retry(INT32 choice); @@ -335,6 +337,9 @@ static patch_t *addonsp[NUM_EXT+5]; // Bird menu_t OP_BirdDef; +// Stuff, yknow. +menu_t OP_ForkedBirdDef; +menu_t OP_LocalSkinDef; menu_t OP_TiltDef; menu_t OP_AdvancedBirdDef; @@ -631,10 +636,11 @@ static menuitem_t MPauseMenu[] = {IT_STRING | IT_SUBMENU, NULL, "Switch Team...", &MISC_ChangeTeamDef, 48}, {IT_STRING | IT_SUBMENU, NULL, "Enter/Spectate...", &MISC_ChangeSpectateDef,48}, {IT_CALL | IT_STRING, NULL, "Player Setup...", M_SetupMultiPlayer, 56}, // alone - {IT_CALL | IT_STRING, NULL, "Options", M_Options, 64}, + {IT_CALL | IT_STRING, NULL, "Local Skin...", M_LocalSkinMenu, 64}, // alone + {IT_CALL | IT_STRING, NULL, "Options", M_Options, 72}, - {IT_CALL | IT_STRING, NULL, "Return to Title", M_EndGame, 80}, - {IT_CALL | IT_STRING, NULL, "Quit Game", M_QuitSRB2, 88}, + {IT_CALL | IT_STRING, NULL, "Return to Title", M_EndGame, 88}, + {IT_CALL | IT_STRING, NULL, "Quit Game", M_QuitSRB2, 96}, }; typedef enum @@ -658,6 +664,7 @@ typedef enum mpause_switchteam, mpause_switchspectate, mpause_psetup, + mpause_localskin, mpause_options, mpause_title, @@ -1110,6 +1117,7 @@ static menuitem_t OP_MainMenu[] = {IT_CALL|IT_STRING, NULL, "Play Credits", M_Credits, 130}, {IT_SUBMENU|IT_STRING, NULL, "Bird", &OP_BirdDef, 150}, + {IT_CALL|IT_STRING, NULL, "Fork Options...", M_LocalSkinMenu, 160}, }; static menuitem_t OP_ControlsMenu[] = @@ -1661,6 +1669,17 @@ static menuitem_t OP_BirdMenu[] = {IT_STRING | IT_SUBMENU, NULL, "Advanced Music Options...", &OP_AdvancedBirdDef, 120}, }; +static menuitem_t OP_ForkedBirdMenu[] = +{ + {IT_HEADER, NULL, "Local Skins", NULL, 0}, + {IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "Local Skin Name", &cv_fakelocalskin, 10}, + {IT_STRING2 | IT_SPACE, NULL, "Set to None for no Local Skin", NULL, 50}, + {IT_STRING | IT_CALL, NULL, "Apply to All Players", M_LocalSkinChange, 50}, + {IT_STRING | IT_CALL, NULL, "Apply to Displaying Player", M_LocalSkinChange, 60}, + {IT_STRING | IT_CALL, NULL, "Apply to Yourself", M_LocalSkinChange, 70}, + {IT_STRING | IT_CVAR, NULL, "Lua Immersion", &cv_luaimmersion, 90}, +}; + static menuitem_t OP_TiltMenu[] = { {IT_STRING | IT_CVAR, NULL, "Camera Tilting", &cv_tilting, 0}, @@ -2212,6 +2231,9 @@ menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30); menu_t OP_TiltDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_BirdDef, 30, 60); menu_t OP_AdvancedBirdDef = DEFAULTMENUSTYLE(NULL, OP_AdvancedBirdMenu, &OP_BirdDef, 30, 60); +menu_t OP_ForkedBirdDef = DEFAULTMENUSTYLE(NULL, OP_ForkedBirdMenu, &OP_MainDef, 30, 30); +menu_t OP_LocalSkinDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_ForkedBirdDef, 30, 60); + // ========================================================================== // CVAR ONCHANGE EVENTS GO HERE // ========================================================================== @@ -3389,7 +3411,7 @@ void M_StartControlPanel(void) else // multiplayer { MPauseMenu[mpause_switchmap].status = IT_DISABLED; - //MPauseMenu[mpause_addons].status = IT_DISABLED; + MPauseMenu[mpause_addons].status = IT_DISABLED; MPauseMenu[mpause_scramble].status = IT_DISABLED; MPauseMenu[mpause_psetupsplit].status = IT_DISABLED; MPauseMenu[mpause_psetupsplit2].status = IT_DISABLED; @@ -3411,9 +3433,10 @@ void M_StartControlPanel(void) MPauseMenu[mpause_switchteam].alphaKey = 48; MPauseMenu[mpause_switchspectate].alphaKey = 48; - MPauseMenu[mpause_options].alphaKey = 64; - MPauseMenu[mpause_title].alphaKey = 80; - MPauseMenu[mpause_quit].alphaKey = 88; + MPauseMenu[mpause_localskin].alphaKey = 64; + MPauseMenu[mpause_options].alphaKey = 72; + MPauseMenu[mpause_title].alphaKey = 88; + MPauseMenu[mpause_quit].alphaKey = 96; Dummymenuplayer_OnChange(); @@ -3423,6 +3446,9 @@ void M_StartControlPanel(void) MPauseMenu[mpause_addons].status = IT_STRING | IT_CALL; if (G_GametypeHasTeams()) MPauseMenu[mpause_scramble].status = IT_STRING | IT_SUBMENU; + } else { + MPauseMenu[mpause_addons].status = IT_STRING | IT_CALL; + MPauseMenu[mpause_addons].alphaKey += 8; } if (splitscreen) @@ -3436,6 +3462,7 @@ void M_StartControlPanel(void) { MPauseMenu[mpause_switchteam].status = IT_STRING | IT_SUBMENU; MPauseMenu[mpause_switchteam].alphaKey += ((splitscreen+1) * 8); + MPauseMenu[mpause_localskin].alphaKey += 8; MPauseMenu[mpause_options].alphaKey += 8; MPauseMenu[mpause_title].alphaKey += 8; MPauseMenu[mpause_quit].alphaKey += 8; @@ -3444,6 +3471,7 @@ void M_StartControlPanel(void) { MPauseMenu[mpause_switchspectate].status = IT_STRING | IT_SUBMENU; MPauseMenu[mpause_switchspectate].alphaKey += ((splitscreen+1) * 8); + MPauseMenu[mpause_localskin].alphaKey += 8; MPauseMenu[mpause_options].alphaKey += 8; MPauseMenu[mpause_title].alphaKey += 8; MPauseMenu[mpause_quit].alphaKey += 8; @@ -3454,6 +3482,7 @@ void M_StartControlPanel(void) { MPauseMenu[mpause_psetupsplit3].status = IT_STRING | IT_CALL; + MPauseMenu[mpause_localskin].alphaKey += 8; MPauseMenu[mpause_options].alphaKey += 8; MPauseMenu[mpause_title].alphaKey += 8; MPauseMenu[mpause_quit].alphaKey += 8; @@ -3461,6 +3490,7 @@ void M_StartControlPanel(void) if (splitscreen > 2) { MPauseMenu[mpause_psetupsplit4].status = IT_STRING | IT_CALL; + MPauseMenu[mpause_localskin].alphaKey += 8; MPauseMenu[mpause_options].alphaKey += 8; MPauseMenu[mpause_title].alphaKey += 8; MPauseMenu[mpause_quit].alphaKey += 8; @@ -4140,7 +4170,7 @@ static void M_DrawGenericMenu(void) y += STRINGHEIGHT; break; case IT_STRING2: - V_DrawString(x, y, 0, currentMenu->menuitems[i].text); + V_DrawString(((BASEVIDWIDTH - V_StringWidth(currentMenu->menuitems[i].text, 0))>>1), y, 0, currentMenu->menuitems[i].text); /* FALLTHRU */ case IT_DYLITLSPACE: y += SMALLLINEHEIGHT; @@ -6543,6 +6573,34 @@ static void M_Options(INT32 choice) M_SetupNextMenu(&OP_MainDef); } +static void M_LocalSkinMenu(INT32 choice) +{ + (void)choice; + + OP_ForkedBirdDef.prevMenu = currentMenu; + M_SetupNextMenu(&OP_ForkedBirdDef); +} + +static void M_LocalSkinChange(INT32 choice) +{ + (void)choice; + + switch (itemOn) { + case 3: + COM_BufAddText(va("localskin -a %s", cv_fakelocalskin.string)); + break; + case 4: + COM_BufAddText(va("localskin -d %s", cv_fakelocalskin.string)); + break; + case 5: + COM_BufAddText(va("localskin %s", cv_fakelocalskin.string)); + break; + default: + break; + } + S_StartSound(NULL, sfx_s221); +} + static void M_Manual(INT32 choice) { (void)choice; diff --git a/src/r_things.c b/src/r_things.c index 0a22f1322..e4cd0965e 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2730,6 +2730,7 @@ void R_InitSkins(void) skin->wadnum = 0; // god what have you brought to this world skin->prefcolor = SKINCOLOR_BLUE; skin->localskin = false; + skin->localnum = 0; // SRB2kart skin->kartspeed = 8; @@ -2769,6 +2770,20 @@ INT32 R_SkinAvailable(const char *name) return -1; } +// returns true if the skin name is found (loaded from pwad) +// warning return -1 if not found +INT32 R_AnySkinAvailable(const char *name) +{ + INT32 i; + + for (i = 0; i < numallskins; i++) + { + if (stricmp(allskins[i].name,name)==0) + return i; + } + return -1; +} + INT32 R_LocalSkinAvailable(const char *name, boolean local) { INT32 i; @@ -2816,13 +2831,6 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) player_t *player = &players[playernum]; INT32 i; - // this is where we're gonna use major mod for. - if (wadfiles[skins[player->skin].wadnum]->majormod && !demo.playback) - { - CONS_Alert(CONS_ERROR, M_GetText("Cannot set localskin to %s because the player's skin is modifying the game.\n"), skinname); - return; - } - if (strcasecmp(skinname, "none")) { for (i = 0; i < numlocalskins; i++) @@ -2831,12 +2839,6 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) if (stricmp(localskins[i].name, skinname) == 0) { player->localskin = 1 + i; - if (wadfiles[localskins[player->localskin - 1].wadnum]->majormod && !demo.playback) - { - CONS_Alert(CONS_ERROR, M_GetText("Cannot set localskin to %s because the localskin is a gameplay-modifying addon.\n"), skinname); - player->localskin = 0; - return; - } player->skinlocal = true; if (player->mo) { @@ -2852,12 +2854,6 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) if (stricmp(skins[i].name, skinname) == 0) { player->localskin = 1 + i; - if (wadfiles[skins[player->localskin - 1].wadnum]->majormod && !demo.playback) - { - CONS_Alert(CONS_ERROR, M_GetText("Cannot set localskin to %s because the skin is a gameplay-modifying addon.\n"), skinname); - player->localskin = 0; - return; - } player->skinlocal = false; if (player->mo) { @@ -2879,12 +2875,16 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) } } - /* - if (player->localskin > 0) - CV_StealthSet(cvar, ( (player->skinlocal) ? localskins : skins )[player->localskin - 1].name); - else - CV_StealthSet(cvar, "none"); - */ + if (cvar != NULL) { + if (player->localskin > 0) { + CV_StealthSet(&cv_fakelocalskin, ( (player->skinlocal) ? localskins : skins )[player->localskin - 1].name); + CV_StealthSet(cvar, ( (player->skinlocal) ? localskins : skins )[player->localskin - 1].name); + } + else { + CV_StealthSet(&cv_fakelocalskin, "none"); + CV_StealthSet(cvar, "none"); + } + } } // Same as SetPlayerSkin, but uses the skin #. @@ -3342,6 +3342,11 @@ next_token: } skin->localskin = local; + // so we dont have to guess + if (local) + skin->localnum = numlocalskins; + else + skin->localnum = numskins; // add face graphics if (local) { @@ -3354,12 +3359,14 @@ next_token: if (rendermode == render_opengl) HWR_AddPlayerMD2(( (local) ? numlocalskins : numskins ), local); #endif - skinstats[skin->kartspeed-1][skin->kartweight-1][skinstatscount[skin->kartspeed-1][skin->kartweight-1]] = numskins; - CONS_Debug(DBG_SETUP, M_GetText("Added %d to %d, %d\n"), numskins, skin->kartweight, skin->kartweight); - skinstatscount[skin->kartspeed-1][skin->kartweight-1]++; - CONS_Debug(DBG_SETUP, M_GetText("Incremented %d, %d to %d\n"), skin->kartspeed, skin->kartweight, skinstatscount[skin->kartspeed - 1][skin->kartweight - 1]); - - skinsorted[numskins] = numskins; + if (!local) { + skinstats[skin->kartspeed-1][skin->kartweight-1][skinstatscount[skin->kartspeed-1][skin->kartweight-1]] = numskins; + CONS_Debug(DBG_SETUP, M_GetText("Added %d to %d, %d\n"), numskins, skin->kartweight, skin->kartweight); + skinstatscount[skin->kartspeed-1][skin->kartweight-1]++; + CONS_Debug(DBG_SETUP, M_GetText("Incremented %d, %d to %d\n"), skin->kartspeed, skin->kartweight, skinstatscount[skin->kartspeed - 1][skin->kartweight - 1]); + + skinsorted[numskins] = numskins; + } allskins[numallskins] = ( (local) ? localskins : skins )[( (local) ? numlocalskins : numskins )]; diff --git a/src/r_things.h b/src/r_things.h index 9b71464a2..26ba6faa1 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -96,6 +96,7 @@ typedef struct sfxenum_t soundsid[NUMSKINSOUNDS]; // sound # in S_sfx table boolean localskin; + INT32 localnum; } skin_t; extern CV_PossibleValue_t Forceskin_cons_t[]; @@ -205,6 +206,7 @@ boolean SetPlayerSkin(INT32 playernum,const char *skinname); void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002 void SetLocalPlayerSkin(INT32 playernum,const char *skinname, consvar_t *cvar); INT32 R_SkinAvailable(const char *name); +INT32 R_AnySkinAvailable(const char *name); INT32 R_LocalSkinAvailable(const char *name, boolean local); void R_AddSkins(UINT16 wadnum, boolean local);