mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-04-19 16:51:53 +00:00
Merge branch 'add-namechange-lua-hook' into 'next'
Add NameChange lua hook See merge request STJr/SRB2!2436
This commit is contained in:
commit
7e43c1fb45
3 changed files with 21 additions and 0 deletions
|
@ -62,6 +62,7 @@ automatically.
|
|||
X (ShieldSpecial),/* shield abilities */\
|
||||
X (PlayerCanDamage),/* P_PlayerCanDamage */\
|
||||
X (PlayerQuit),\
|
||||
X (NameChange),\
|
||||
X (IntermissionThinker),/* Y_Ticker */\
|
||||
X (TeamSwitch),/* team switching in... uh... *what* speak, spit it the fuck out */\
|
||||
X (ViewpointSwitch),/* spy mode (no trickstabs) */\
|
||||
|
@ -153,6 +154,7 @@ int LUA_HookMapThingSpawn(mobj_t *, mapthing_t *);
|
|||
int LUA_HookFollowMobj(player_t *, mobj_t *);
|
||||
int LUA_HookPlayerCanDamage(player_t *, mobj_t *);
|
||||
void LUA_HookPlayerQuit(player_t *, kickreason_t);
|
||||
int LUA_HookNameChange(player_t *plr, const char *name);
|
||||
int LUA_HookTeamSwitch(player_t *, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble);
|
||||
int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced);
|
||||
int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend);
|
||||
|
|
|
@ -1077,6 +1077,18 @@ void LUA_HookPlayerQuit(player_t *plr, kickreason_t reason)
|
|||
}
|
||||
}
|
||||
|
||||
int LUA_HookNameChange(player_t *plr, const char *name)
|
||||
{
|
||||
Hook_State hook;
|
||||
if (prepare_hook(&hook, true, HOOK(NameChange)))
|
||||
{
|
||||
LUA_PushUserdata(gL, plr, META_PLAYER); // Player that changed name
|
||||
lua_pushstring(gL, name); // New player name
|
||||
call_hooks(&hook, 1, res_false);
|
||||
}
|
||||
return hook.status;
|
||||
}
|
||||
|
||||
int LUA_HookTeamSwitch(player_t *player, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble)
|
||||
{
|
||||
Hook_State hook;
|
||||
|
|
|
@ -1170,6 +1170,13 @@ static void SetPlayerName(INT32 playernum, char *newname)
|
|||
{
|
||||
if (strcasecmp(newname, player_names[playernum]) != 0)
|
||||
{
|
||||
if (!LUA_HookNameChange(&players[playernum], newname))
|
||||
{
|
||||
// Name change rejected by Lua
|
||||
if (playernum == consoleplayer)
|
||||
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
|
||||
return;
|
||||
}
|
||||
if (netgame)
|
||||
HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false);
|
||||
|
||||
|
|
Loading…
Reference in a new issue