Skip to content

Commit

Permalink
Util: add UpdateResourceDirectory() (#1797)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daztek authored Nov 12, 2024
1 parent 45d6dd1 commit 451aa94
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ https://github.com/nwnxee/unified/compare/build8193.36.12...HEAD
- Race: SuppressCreatureRaceEffects()
- Race: ReactivateCreatureRaceEffects()
- Creature: {Get|Set}MulticlassLimit()
- Util: UpdateResourceDirectory()

### Changed
- Player: added bChatWindow parameter to FloatingTextStringOnCreature()
Expand Down
13 changes: 13 additions & 0 deletions Plugins/Util/NWScript/nwnx_util.nss
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ int NWNX_Util_CleanResourceDirectory(string sAlias, int nResType = 0xFFFF);
/// @return The name
string NWNX_Util_GetModuleTlkFile();

/// @brief Update a resource directory by having ResMan reindex it.
/// @param sAlias A resource directory alias, eg: TEMP
/// @return TRUE if successful, FALSE on error.
int NWNX_Util_UpdateResourceDirectory(string sAlias);

/// @}

string NWNX_Util_GetCurrentScriptName(int depth = 0)
Expand Down Expand Up @@ -657,3 +662,11 @@ string NWNX_Util_GetModuleTlkFile()
NWNX_CallFunction(NWNX_Util, sFunc);
return NWNX_GetReturnValueString();
}

int NWNX_Util_UpdateResourceDirectory(string sAlias)
{
string sFunc = "UpdateResourceDirectory";
NWNX_PushArgumentString(sAlias);
NWNX_CallFunction(NWNX_Util, sFunc);
return NWNX_GetReturnValueInt();
}
7 changes: 7 additions & 0 deletions Plugins/Util/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,3 +798,10 @@ NWNX_EXPORT ArgumentStack GetModuleTlkFile(ArgumentStack&& args)
CNWSModule *pMod = Utils::GetModule();
return pMod->m_sModuleAltTLKFile;
}

NWNX_EXPORT ArgumentStack UpdateResourceDirectory(ArgumentStack&& args)
{
const auto alias = args.extract<std::string>();
ASSERT_OR_THROW(!alias.empty());
return Globals::ExoResMan()->UpdateResourceDirectory(alias + ":");
}

0 comments on commit 451aa94

Please sign in to comment.