Skip to content

Commit

Permalink
Update APIs (NWNX: 72ac257, NWN: 8193.37-14).
Browse files Browse the repository at this point in the history
  • Loading branch information
jhett12321 committed Jan 18, 2025
1 parent 8701e40 commit 02a05a2
Show file tree
Hide file tree
Showing 36 changed files with 3,205 additions and 3,789 deletions.
524 changes: 463 additions & 61 deletions NWN.Core/src/NWN/NWScript.cs

Large diffs are not rendered by default.

176 changes: 63 additions & 113 deletions NWN.Core/src/NWNX/Plugins/AdminPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ namespace NWN.Core.NWNX
[NWNXPlugin(NWNX_Administration)]
public class AdminPlugin
{
/// @addtogroup admin Administration
/// Various admin related functions
/// @{
/// @file nwnx_admin.nss
public const string NWNX_Administration = "NWNX_Administration";

///< @private
Expand Down Expand Up @@ -121,56 +125,44 @@ public class AdminPlugin
/// <returns>The current player password.</returns>
public static string GetPlayerPassword()
{
const string sFunc = "GetPlayerPassword";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.Call();
return VM.NWNX.StackPopString();
NWNXCall(NWNX_Administration, "GetPlayerPassword");
return NWNXPopString();
}

/// Sets the password for players to login.
/// <param name="password">The password to use.</param>
public static void SetPlayerPassword(string password)
{
const string sFunc = "SetPlayerPassword";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(password);
VM.NWNX.Call();
NWNXPushString(password);
NWNXCall(NWNX_Administration, "SetPlayerPassword");
}

/// Clears the player password required to login.
public static void ClearPlayerPassword()
{
const string sFunc = "ClearPlayerPassword";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.Call();
NWNXCall(NWNX_Administration, "ClearPlayerPassword");
}

/// Gets the current DM password.
/// <returns>The current DM password.</returns>
public static string GetDMPassword()
{
const string sFunc = "GetDMPassword";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.Call();
return VM.NWNX.StackPopString();
NWNXCall(NWNX_Administration, "GetDMPassword");
return NWNXPopString();
}

/// Sets the password for DMs to login.
/// <param name="password">The password to use.</param>
public static void SetDMPassword(string password)
{
const string sFunc = "SetDMPassword";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(password);
VM.NWNX.Call();
NWNXPushString(password);
NWNXCall(NWNX_Administration, "SetDMPassword");
}

/// Signals the server to immediately shut down.
public static void ShutdownServer()
{
const string sFunc = "ShutdownServer";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.Call();
NWNXCall(NWNX_Administration, "ShutdownServer");
}

/// Deletes the player character from the servervault
Expand All @@ -182,136 +174,110 @@ public static void ShutdownServer()
/// <param name="sKickMessage">An optional kick message, if left blank it will default to &quot;Delete Character&quot; as reason.</param>
public static void DeletePlayerCharacter(uint oPC, int bPreserveBackup = TRUE, string sKickMessage = "")
{
const string sFunc = "DeletePlayerCharacter";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(sKickMessage);
VM.NWNX.StackPush(bPreserveBackup);
VM.NWNX.StackPush(oPC);
VM.NWNX.Call();
NWNXPushString(sKickMessage);
NWNXPushInt(bPreserveBackup);
NWNXPushObject(oPC);
NWNXCall(NWNX_Administration, "DeletePlayerCharacter");
}

/// Bans the provided IP.
/// <param name="ip">The IP Address to ban.</param>
public static void AddBannedIP(string ip)
{
const string sFunc = "AddBannedIP";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(ip);
VM.NWNX.Call();
NWNXPushString(ip);
NWNXCall(NWNX_Administration, "AddBannedIP");
}

/// Removes the ban on the provided IP.
/// <param name="ip">The IP Address to unban.</param>
public static void RemoveBannedIP(string ip)
{
const string sFunc = "RemoveBannedIP";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(ip);
VM.NWNX.Call();
NWNXPushString(ip);
NWNXCall(NWNX_Administration, "RemoveBannedIP");
}

/// Bans the provided Public CD Key.
/// <param name="key">The Public CD Key to ban.</param>
public static void AddBannedCDKey(string key)
{
const string sFunc = "AddBannedCDKey";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(key);
VM.NWNX.Call();
NWNXPushString(key);
NWNXCall(NWNX_Administration, "AddBannedCDKey");
}

/// Removes the ban on the provided Public CD Key.
/// <param name="key">The Public CD Key to unban.</param>
public static void RemoveBannedCDKey(string key)
{
const string sFunc = "RemoveBannedCDKey";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(key);
VM.NWNX.Call();
NWNXPushString(key);
NWNXCall(NWNX_Administration, "RemoveBannedCDKey");
}

/// Bans the provided playername.
/// <param name="playerName">The player name (community name) to ban.</param>
/// @warning A user can change their playername at will.
public static void AddBannedPlayerName(string playerName)
{
const string sFunc = "AddBannedPlayerName";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(playerName);
VM.NWNX.Call();
NWNXPushString(playerName);
NWNXCall(NWNX_Administration, "AddBannedPlayerName");
}

/// Removes the ban on the provided playername.
/// <param name="playerName">The player name (community name) to unban.</param>
public static void RemoveBannedPlayerName(string playerName)
{
const string sFunc = "RemoveBannedPlayerName";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(playerName);
VM.NWNX.Call();
NWNXPushString(playerName);
NWNXCall(NWNX_Administration, "RemoveBannedPlayerName");
}

/// Get a list of all banned IPs/Keys/names as a string.
/// <returns>A string with a listing of the banned IPs/Keys/names.</returns>
public static string GetBannedList()
{
const string sFunc = "GetBannedList";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.Call();
return VM.NWNX.StackPopString();
NWNXCall(NWNX_Administration, "GetBannedList");
return NWNXPopString();
}

/// Set the module&apos;s name as shown to the serverlist.
/// <param name="name">The name to give the module.</param>
public static void SetModuleName(string name)
{
const string sFunc = "SetModuleName";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(name);
VM.NWNX.Call();
NWNXPushString(name);
NWNXCall(NWNX_Administration, "SetModuleName");
}

/// Set the server&apos;s name as shown to the serverlist.
/// <param name="name">The name to give the server.</param>
public static void SetServerName(string name)
{
const string sFunc = "SetServerName";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(name);
VM.NWNX.Call();
NWNXPushString(name);
NWNXCall(NWNX_Administration, "SetServerName");
}

/// Returns the server&apos;s name as shown to the serverlist.
public static string GetServerName()
{
const string sFunc = "GetServerName";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.Call();
return VM.NWNX.StackPopString();
NWNXCall(NWNX_Administration, "GetServerName");
return NWNXPopString();
}

/// Get an @ref admin_opts &quot;Administration Option&quot; value.
/// <param name="option">An @ref admin_opts &quot;Administration Option&quot;.</param>
/// <returns>The current setting for the supplied option from @ref admin_opts &quot;Administration Options&quot;.</returns>
public static int GetPlayOption(int option)
{
const string sFunc = "GetPlayOption";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(option);
VM.NWNX.Call();
return VM.NWNX.StackPopInt();
NWNXPushInt(option);
NWNXCall(NWNX_Administration, "GetPlayOption");
return NWNXPopInt();
}

/// Set an @ref admin_opts &quot;Administration Options&quot; to a value.
/// <param name="option">The option to adjust from @ref admin_opts &quot;Administration Options&quot;.</param>
/// <param name="value">The new value for the option.</param>
public static void SetPlayOption(int option, int value)
{
const string sFunc = "SetPlayOption";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(value);
VM.NWNX.StackPush(option);
VM.NWNX.Call();
NWNXPushInt(value);
NWNXPushInt(option);
NWNXCall(NWNX_Administration, "SetPlayOption");
}

/// Delete the TURD of playerName + characterName.
Expand All @@ -326,86 +292,70 @@ public static void SetPlayOption(int option, int value)
/// <returns>Returns TRUE if successful</returns>
public static int DeleteTURD(string playerName, string characterName)
{
const string sFunc = "DeleteTURD";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(characterName);
VM.NWNX.StackPush(playerName);
VM.NWNX.Call();
return VM.NWNX.StackPopInt();
NWNXPushString(characterName);
NWNXPushString(playerName);
NWNXCall(NWNX_Administration, "DeleteTURD");
return NWNXPopInt();
}

/// Get an @ref admin_debug &quot;Administration Debug Type&quot; value.
/// <param name="type">An @ref admin_debug &quot;Administration Debug Type&quot;.</param>
/// <returns>The current value for the supplied debug type from @ref admin_debug &quot;Administration Debug Types&quot;.</returns>
public static int GetDebugValue(int type)
{
const string sFunc = "GetDebugValue";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(type);
VM.NWNX.Call();
return VM.NWNX.StackPopInt();
NWNXPushInt(type);
NWNXCall(NWNX_Administration, "GetDebugValue");
return NWNXPopInt();
}

/// Set an @ref admin_debug &quot;Administration Debug Type&quot; to a value.
/// <param name="type">The debug type to adjust from @ref admin_debug &quot;Administration Debug Types&quot;.</param>
/// <param name="state">The new state for the debug type, TRUE or FALSE</param>
public static void SetDebugValue(int type, int state)
{
const string sFunc = "SetDebugValue";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(state);
VM.NWNX.StackPush(type);
VM.NWNX.Call();
NWNXPushInt(state);
NWNXPushInt(type);
NWNXCall(NWNX_Administration, "SetDebugValue");
}

/// Reload all rules (2da stuff etc).
/// @warning DANGER, DRAGONS. Bad things may or may not happen.
public static void ReloadRules()
{
const string sFunc = "ReloadRules";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.Call();
NWNXCall(NWNX_Administration, "ReloadRules");
}

/// Get the servers minimum level.
/// <returns>The minimum level for the server.</returns>
public static int GetMinLevel()
{
const string sFunc = "GetMinLevel";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.Call();
return VM.NWNX.StackPopInt();
NWNXCall(NWNX_Administration, "GetMinLevel");
return NWNXPopInt();
}

/// Set the servers minimum level.
/// <param name="nLevel">The minimum level for the server.</param>
public static void SetMinLevel(int nLevel)
{
const string sFunc = "SetMinLevel";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(nLevel);
VM.NWNX.Call();
NWNXPushInt(nLevel);
NWNXCall(NWNX_Administration, "SetMinLevel");
}

/// Get the servers maximum level.
/// <returns>The maximum level for the server.</returns>
public static int GetMaxLevel()
{
const string sFunc = "GetMaxLevel";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.Call();
return VM.NWNX.StackPopInt();
NWNXCall(NWNX_Administration, "GetMaxLevel");
return NWNXPopInt();
}

/// Set the servers maximum level.
/// @note Attention when using this and the MaxLevel plugin. They both change the same value.
/// <param name="nLevel">The maximum level for the server.</param>
public static void SetMaxLevel(int nLevel)
{
const string sFunc = "SetMaxLevel";
VM.NWNX.SetFunction(NWNX_Administration, sFunc);
VM.NWNX.StackPush(nLevel);
VM.NWNX.Call();
NWNXPushInt(nLevel);
NWNXCall(NWNX_Administration, "SetMaxLevel");
}

// @}
Expand Down
28 changes: 14 additions & 14 deletions NWN.Core/src/NWNX/Plugins/AppearancePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ namespace NWN.Core.NWNX
[NWNXPlugin(NWNX_Appearance)]
public class AppearancePlugin
{
/// @addtogroup appearance Appearance
/// Allows the appearance and some other things of creatures to be overridden per player.
/// @{
/// @file nwnx_appearance.nss
public const string NWNX_Appearance = "NWNX_Appearance";

///&lt; @private
Expand Down Expand Up @@ -58,13 +62,11 @@ public class AppearancePlugin
/// <param name="nValue">The new value for the appearance type.</param>
public static void SetOverride(uint oPlayer, uint oCreature, int nType, int nValue)
{
const string sFunc = "SetOverride";
VM.NWNX.SetFunction(NWNX_Appearance, sFunc);
VM.NWNX.StackPush(nValue);
VM.NWNX.StackPush(nType);
VM.NWNX.StackPush(oCreature);
VM.NWNX.StackPush(oPlayer);
VM.NWNX.Call();
NWNXPushInt(nValue);
NWNXPushInt(nType);
NWNXPushObject(oCreature);
NWNXPushObject(oPlayer);
NWNXCall(NWNX_Appearance, "SetOverride");
}

/// Get a creature&apos;s appearance type for a player.
Expand All @@ -74,13 +76,11 @@ public static void SetOverride(uint oPlayer, uint oCreature, int nType, int nVal
/// <returns>The value for the appearance type or -1 when not set.</returns>
public static int GetOverride(uint oPlayer, uint oCreature, int nType)
{
const string sFunc = "GetOverride";
VM.NWNX.SetFunction(NWNX_Appearance, sFunc);
VM.NWNX.StackPush(nType);
VM.NWNX.StackPush(oCreature);
VM.NWNX.StackPush(oPlayer);
VM.NWNX.Call();
return VM.NWNX.StackPopInt();
NWNXPushInt(nType);
NWNXPushObject(oCreature);
NWNXPushObject(oPlayer);
NWNXCall(NWNX_Appearance, "GetOverride");
return NWNXPopInt();
}

// @}
Expand Down
Loading

0 comments on commit 02a05a2

Please sign in to comment.