Skip to content

Commit

Permalink
NWNX_Player: ReloadColorPalettes (#1750)
Browse files Browse the repository at this point in the history

Adds void NWNX_Player_ReloadColorPalettes(object oPlayer) as a function.

This will allow the use of overwritten color palettes that are included in NWSync which are currently not noticed by the basegame unless the palette (i.e. pal_skin01.tga) is moved into the development or override folders.
  • Loading branch information
Aschent89 committed Mar 25, 2024
1 parent 67fd75a commit be21aa5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ https://github.com/nwnxee/unified/compare/build8193.36.12...HEAD
- Store: {Get|Set}MarkDown()
- Store: {Get|Set}MarkUp()
- Player: ReloadTlk()
- Player: ReloadColorPalettes()

### Changed
- N/A
Expand Down
12 changes: 12 additions & 0 deletions Plugins/Player/NWScript/nwnx_player.nss
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ void NWNX_Player_SendPartyInvite(object oPlayer, object oInviter, int bForceInvi
/// @return the TURD object of oPlayer, or OBJECT_INVALID if no TURD exists
object NWNX_Player_GetTURD(object oPlayer);

/// @brief Reloads the color palettes for oPlayer
/// @param oPlayer The player to reload the color palette for
void NWNX_Player_ReloadColorPalettes(object oPlayer);

/// @}

void NWNX_Player_ForcePlaceableExamineWindow(object player, object placeable)
Expand Down Expand Up @@ -1146,3 +1150,11 @@ object NWNX_Player_GetTURD(object oPlayer)

return NWNX_GetReturnValueObject();
}

void NWNX_Player_ReloadColorPalettes(object oPlayer)
{
string sFunc = "ReloadColorPalettes";

NWNX_PushArgumentObject(oPlayer);
NWNX_CallFunction(NWNX_Player, sFunc);
}
23 changes: 23 additions & 0 deletions Plugins/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1993,3 +1993,26 @@ NWNX_EXPORT ArgumentStack GetTURD(ArgumentStack&& args)

return Constants::OBJECT_INVALID;
}

NWNX_EXPORT ArgumentStack ReloadColorPalettes(ArgumentStack&& args)
{
if (auto* pPlayer = Utils::PopPlayer(args))
{
if (auto* pMessage = Globals::AppManager()->m_pServerExoApp->GetNWSMessage())
{
pMessage->CreateWriteMessage(4, pPlayer->m_nPlayerID, 1);
pMessage->WriteDWORD(0x20);
uint8_t* buffer;
uint32_t size;
if (pMessage->GetWriteMessage(&buffer, &size))
{
pMessage->SendServerToPlayerMessage(pPlayer->m_nPlayerID,
Constants::MessageMajor::Resman,
0x4,
buffer, size);
}
}
}

return {};
}

0 comments on commit be21aa5

Please sign in to comment.