Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Hanicef/SRB2Classic
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Jisk/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
118 results
Show changes
Commits on Source (9)
...@@ -1159,20 +1159,58 @@ static void SetPlayerName(INT32 playernum, char *newname) ...@@ -1159,20 +1159,58 @@ static void SetPlayerName(INT32 playernum, char *newname)
} }
} }
UINT8 CanChangeSkin(INT32 playernum)
/** Checks if a player can change skin under any circumstance.
* If this function gets called by the Player Setup Menu, the skinnum will be -2.
*
* \param playernum Player number who is checking the skin change conditions.
* \param skinnum Index of the requested skin.
*/
UINT8 CanChangeSkin(INT32 playernum, INT32 skinnum)
{ {
// if the function wasn't called from the Player Setup Menu
if (skinnum != -2)
{
// needed checks that can't be ignored by the lua hook
if (!R_SkinUsable(consoleplayer, skinnum))
{
CONS_Alert(CONS_NOTICE, M_GetText("You can't use that skin at the moment.\n"));
return false;
}
}
//Call the lua hook for CanChangeSkin
int canchangeskin = LUAh_HookPlayerCanChangeSkin(&players[playernum], &skins[players[playernum].skin], (skinnum < 0 ? NULL : &skins[skinnum]));
if (canchangeskin == 1)
return true; // force yes
else if (canchangeskin == 2)
{
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
return false; // force no
}
// Of course we can change if we're not playing // Of course we can change if we're not playing
if (!Playing() || !addedtogame) if (!Playing() || !addedtogame)
return true; return true;
// Force skin in effect. // Force skin in effect.
if ((cv_forceskin.value != -1) || (mapheaderinfo[gamemap-1] && mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0')) if ((cv_forceskin.value != -1) || (mapheaderinfo[gamemap-1] && mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0'))
{
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
return false; return false;
}
// Can change skin in intermission and whatnot. // Can change skin in intermission and whatnot.
if (gamestate != GS_LEVEL) if (gamestate != GS_LEVEL)
return true; return true;
// Can't change when moving
if (P_PlayerMoving(playernum))
{
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin when moving.\n"));
return false;
}
// Server has skin change restrictions. // Server has skin change restrictions.
if (cv_restrictskinchange.value) if (cv_restrictskinchange.value)
{ {
...@@ -1196,10 +1234,10 @@ UINT8 CanChangeSkin(INT32 playernum) ...@@ -1196,10 +1234,10 @@ UINT8 CanChangeSkin(INT32 playernum)
if (players[playernum].spectator || players[playernum].playerstate == PST_DEAD || players[playernum].playerstate == PST_REBORN) if (players[playernum].spectator || players[playernum].playerstate == PST_DEAD || players[playernum].playerstate == PST_REBORN)
return true; return true;
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
return false; return false;
} }
return true; return true;
} }
...@@ -1271,11 +1309,11 @@ static void SendNameAndColor(void) ...@@ -1271,11 +1309,11 @@ static void SendNameAndColor(void)
if (!Playing()) if (!Playing())
return; return;
INT32 foundskin = R_SkinAvailable(cv_skin.string);
// If you're not in a netgame, merely update the skin, color, and name. // If you're not in a netgame, merely update the skin, color, and name.
if (!netgame) if (!netgame)
{ {
INT32 foundskin;
CleanupPlayerName(consoleplayer, cv_playername.zstring); CleanupPlayerName(consoleplayer, cv_playername.zstring);
strcpy(player_names[consoleplayer], cv_playername.zstring); strcpy(player_names[consoleplayer], cv_playername.zstring);
...@@ -1289,7 +1327,7 @@ static void SendNameAndColor(void) ...@@ -1289,7 +1327,7 @@ static void SendNameAndColor(void)
SetPlayerSkinByNum(consoleplayer, 5); SetPlayerSkinByNum(consoleplayer, 5);
CV_StealthSet(&cv_skin, skins[5].name); CV_StealthSet(&cv_skin, skins[5].name);
} }
else if ((foundskin = R_SkinAvailable(cv_skin.string)) != -1 && R_SkinUsable(consoleplayer, foundskin)) else if (CanChangeSkin(consoleplayer, foundskin))
{ {
//boolean notsame; //boolean notsame;
...@@ -1335,7 +1373,7 @@ static void SendNameAndColor(void) ...@@ -1335,7 +1373,7 @@ static void SendNameAndColor(void)
CleanupPlayerName(consoleplayer, cv_playername.zstring); CleanupPlayerName(consoleplayer, cv_playername.zstring);
// Don't change skin if the server doesn't want you to. // Don't change skin if the server doesn't want you to.
if (!CanChangeSkin(consoleplayer)) if (!CanChangeSkin(consoleplayer, foundskin))
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name);
// check if player has the skin loaded (cv_skin may have // check if player has the skin loaded (cv_skin may have
...@@ -1412,7 +1450,7 @@ static void SendNameAndColor2(void) ...@@ -1412,7 +1450,7 @@ static void SendNameAndColor2(void)
} }
else if (!netgame) else if (!netgame)
{ {
INT32 foundskin; INT32 foundskin = R_SkinAvailable(cv_skin2.string);
CleanupPlayerName(secondplaya, cv_playername2.zstring); CleanupPlayerName(secondplaya, cv_playername2.zstring);
strcpy(player_names[secondplaya], cv_playername2.zstring); strcpy(player_names[secondplaya], cv_playername2.zstring);
...@@ -1429,7 +1467,7 @@ static void SendNameAndColor2(void) ...@@ -1429,7 +1467,7 @@ static void SendNameAndColor2(void)
SetPlayerSkinByNum(secondplaya, forcedskin); SetPlayerSkinByNum(secondplaya, forcedskin);
CV_StealthSet(&cv_skin2, skins[forcedskin].name); CV_StealthSet(&cv_skin2, skins[forcedskin].name);
} }
else if ((foundskin = R_SkinAvailable(cv_skin2.string)) != -1 && R_SkinUsable(secondplaya, foundskin)) else if (CanChangeSkin(secondplaya, foundskin))
{ {
//boolean notsame; //boolean notsame;
...@@ -4868,13 +4906,8 @@ static void Skin_OnChange(void) ...@@ -4868,13 +4906,8 @@ static void Skin_OnChange(void)
return; return;
} }
if (CanChangeSkin(consoleplayer) && !P_PlayerMoving(consoleplayer)) // checks are now done internally
SendNameAndColor(); SendNameAndColor();
else
{
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name);
}
} }
/** Sends a skin change for the secondary splitscreen player, unless that /** Sends a skin change for the secondary splitscreen player, unless that
...@@ -4887,13 +4920,8 @@ static void Skin2_OnChange(void) ...@@ -4887,13 +4920,8 @@ static void Skin2_OnChange(void)
if (!Playing() || !splitscreen) if (!Playing() || !splitscreen)
return; // do whatever you want return; // do whatever you want
if (CanChangeSkin(secondarydisplayplayer) && !P_PlayerMoving(secondarydisplayplayer)) // checks are now done internally
SendNameAndColor2(); SendNameAndColor2();
else
{
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
CV_StealthSet(&cv_skin2, skins[players[secondarydisplayplayer].skin].name);
}
} }
/** Sends a color change for the console player, unless that player is moving. /** Sends a color change for the console player, unless that player is moving.
......
...@@ -211,6 +211,6 @@ void ItemFinder_OnChange(void); ...@@ -211,6 +211,6 @@ void ItemFinder_OnChange(void);
void D_SetPassword(const char *pw); void D_SetPassword(const char *pw);
// used for the player setup menu // used for the player setup menu
UINT8 CanChangeSkin(INT32 playernum); UINT8 CanChangeSkin(INT32 playernum, INT32 skinnum);
#endif #endif
...@@ -2796,8 +2796,9 @@ static int lib_rSetPlayerSkin(lua_State *L) ...@@ -2796,8 +2796,9 @@ static int lib_rSetPlayerSkin(lua_State *L)
return luaL_error(L, "skin %s (argument 2) is not loaded", skinname); return luaL_error(L, "skin %s (argument 2) is not loaded", skinname);
} }
if (!R_SkinUsable(j, i)) if (!CanChangeSkin(j, i))
return luaL_error(L, "skin %d (argument 2) not usable - check with R_SkinUsable(player_t, skin) first.", i); return luaL_error(L, "Skin cannot be changed at the moment.");
SetPlayerSkinByNum(j, i); SetPlayerSkinByNum(j, i);
return 0; return 0;
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "d_player.h" #include "d_player.h"
#include "s_sound.h" #include "s_sound.h"
#include "d_event.h" #include "d_event.h"
#include "r_skins.h"
#include "lua_hudlib_drawlist.h" #include "lua_hudlib_drawlist.h"
/* /*
...@@ -72,6 +73,7 @@ automatically. ...@@ -72,6 +73,7 @@ automatically.
X (MusicChange),\ X (MusicChange),\
X (PlayerHeight),/* override player height */\ X (PlayerHeight),/* override player height */\
X (PlayerCanEnterSpinGaps),\ X (PlayerCanEnterSpinGaps),\
X (PlayerCanChangeSkin),\
X (KeyDown),\ X (KeyDown),\
X (KeyUp),\ X (KeyUp),\
...@@ -149,3 +151,4 @@ int LUA_HookPlayerCmd(player_t *, ticcmd_t *); ...@@ -149,3 +151,4 @@ int LUA_HookPlayerCmd(player_t *, ticcmd_t *);
int LUA_HookMusicChange(const char *oldname, struct MusicChange *); int LUA_HookMusicChange(const char *oldname, struct MusicChange *);
fixed_t LUA_HookPlayerHeight(player_t *player); fixed_t LUA_HookPlayerHeight(player_t *player);
int LUA_HookPlayerCanEnterSpinGaps(player_t *player); int LUA_HookPlayerCanEnterSpinGaps(player_t *player);
int LUAh_HookPlayerCanChangeSkin(player_t *player, skin_t *current_skin, skin_t *next_skin);
...@@ -1182,3 +1182,18 @@ int LUA_HookPlayerCanEnterSpinGaps(player_t *player) ...@@ -1182,3 +1182,18 @@ int LUA_HookPlayerCanEnterSpinGaps(player_t *player)
} }
return hook.status; return hook.status;
} }
int LUAh_HookPlayerCanChangeSkin(player_t *player, skin_t *current_skin, skin_t *next_skin)
{
Hook_State hook;
if (prepare_hook(&hook, 0, HOOK(PlayerCanChangeSkin))) {
LUA_PushUserdata(gL, player, META_PLAYER);
LUA_PushUserdata(gL, current_skin, META_SKIN);
LUA_PushUserdata(gL, next_skin, META_SKIN);
call_hooks(&hook, 1, res_force);
}
return hook.status;
}
...@@ -12685,7 +12685,7 @@ static void M_SetupMultiPlayer(INT32 choice) ...@@ -12685,7 +12685,7 @@ static void M_SetupMultiPlayer(INT32 choice)
break; break;
// disable skin changes if we can't actually change skins // disable skin changes if we can't actually change skins
if (!CanChangeSkin(consoleplayer)) if (!CanChangeSkin(consoleplayer, -2))
MP_PlayerSetupMenu[1].status = (IT_GRAYEDOUT); MP_PlayerSetupMenu[1].status = (IT_GRAYEDOUT);
else else
MP_PlayerSetupMenu[1].status = (IT_KEYHANDLER|IT_STRING); MP_PlayerSetupMenu[1].status = (IT_KEYHANDLER|IT_STRING);
...@@ -12730,7 +12730,7 @@ static void M_SetupMultiPlayer2(INT32 choice) ...@@ -12730,7 +12730,7 @@ static void M_SetupMultiPlayer2(INT32 choice)
break; break;
// disable skin changes if we can't actually change skins // disable skin changes if we can't actually change skins
if (splitscreen && !CanChangeSkin(secondarydisplayplayer)) if (splitscreen && !CanChangeSkin(secondarydisplayplayer, -2))
MP_PlayerSetupMenu[1].status = (IT_GRAYEDOUT); MP_PlayerSetupMenu[1].status = (IT_GRAYEDOUT);
else else
MP_PlayerSetupMenu[1].status = (IT_KEYHANDLER | IT_STRING); MP_PlayerSetupMenu[1].status = (IT_KEYHANDLER | IT_STRING);
......