From 370f8588a09cd5b755ee29051324a44b09466757 Mon Sep 17 00:00:00 2001 From: Riley Labrecque Date: Sat, 7 Sep 2019 18:43:27 -0700 Subject: [PATCH] Automatically generate array safety code --- .../Steamworks.NET/autogen/isteamcontroller.cs | 9 +++++++++ .../autogen/isteamgameserverinventory.cs | 18 ++++++++++++++++++ Plugins/Steamworks.NET/autogen/isteaminput.cs | 9 +++++++++ .../Steamworks.NET/autogen/isteaminventory.cs | 18 ++++++++++++++++++ 4 files changed, 54 insertions(+) diff --git a/Plugins/Steamworks.NET/autogen/isteamcontroller.cs b/Plugins/Steamworks.NET/autogen/isteamcontroller.cs index ecb7b84b..73b26aac 100644 --- a/Plugins/Steamworks.NET/autogen/isteamcontroller.cs +++ b/Plugins/Steamworks.NET/autogen/isteamcontroller.cs @@ -106,6 +106,9 @@ public static void DeactivateAllActionSetLayers(ControllerHandle_t controllerHan /// public static int GetActiveActionSetLayers(ControllerHandle_t controllerHandle, ControllerActionSetHandle_t[] handlesOut) { InteropHelp.TestIfAvailableClient(); + if (handlesOut.Length != Constants.STEAM_CONTROLLER_MAX_ACTIVE_LAYERS) { + throw new System.ArgumentException("handlesOut must be the same size as Constants.STEAM_CONTROLLER_MAX_ACTIVE_LAYERS!"); + } return NativeMethods.ISteamController_GetActiveActionSetLayers(CSteamAPIContext.GetSteamController(), controllerHandle, handlesOut); } @@ -137,6 +140,9 @@ public static ControllerDigitalActionData_t GetDigitalActionData(ControllerHandl /// public static int GetDigitalActionOrigins(ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle, ControllerDigitalActionHandle_t digitalActionHandle, EControllerActionOrigin[] originsOut) { InteropHelp.TestIfAvailableClient(); + if (originsOut.Length != Constants.STEAM_CONTROLLER_MAX_ORIGINS) { + throw new System.ArgumentException("originsOut must be the same size as Constants.STEAM_CONTROLLER_MAX_ORIGINS!"); + } return NativeMethods.ISteamController_GetDigitalActionOrigins(CSteamAPIContext.GetSteamController(), controllerHandle, actionSetHandle, digitalActionHandle, originsOut); } @@ -165,6 +171,9 @@ public static ControllerAnalogActionData_t GetAnalogActionData(ControllerHandle_ /// public static int GetAnalogActionOrigins(ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle, ControllerAnalogActionHandle_t analogActionHandle, EControllerActionOrigin[] originsOut) { InteropHelp.TestIfAvailableClient(); + if (originsOut.Length != Constants.STEAM_CONTROLLER_MAX_ORIGINS) { + throw new System.ArgumentException("originsOut must be the same size as Constants.STEAM_CONTROLLER_MAX_ORIGINS!"); + } return NativeMethods.ISteamController_GetAnalogActionOrigins(CSteamAPIContext.GetSteamController(), controllerHandle, actionSetHandle, analogActionHandle, originsOut); } diff --git a/Plugins/Steamworks.NET/autogen/isteamgameserverinventory.cs b/Plugins/Steamworks.NET/autogen/isteamgameserverinventory.cs index 13ba8a06..29c42e77 100644 --- a/Plugins/Steamworks.NET/autogen/isteamgameserverinventory.cs +++ b/Plugins/Steamworks.NET/autogen/isteamgameserverinventory.cs @@ -41,6 +41,9 @@ public static EResult GetResultStatus(SteamInventoryResult_t resultHandle) { /// public static bool GetResultItems(SteamInventoryResult_t resultHandle, SteamItemDetails_t[] pOutItemsArray, ref uint punOutItemsArraySize) { InteropHelp.TestIfAvailableGameServer(); + if (pOutItemsArray.Length != punOutItemsArraySize) { + throw new System.ArgumentException("pOutItemsArray must be the same size as punOutItemsArraySize!"); + } return NativeMethods.ISteamInventory_GetResultItems(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle, pOutItemsArray, ref punOutItemsArraySize); } @@ -300,6 +303,9 @@ public static bool LoadItemDefinitions() { /// public static bool GetItemDefinitionIDs(SteamItemDef_t[] pItemDefIDs, ref uint punItemDefIDsArraySize) { InteropHelp.TestIfAvailableGameServer(); + if (pItemDefIDs.Length != punItemDefIDsArraySize) { + throw new System.ArgumentException("pItemDefIDs must be the same size as punItemDefIDsArraySize!"); + } return NativeMethods.ISteamInventory_GetItemDefinitionIDs(CSteamGameServerAPIContext.GetSteamInventory(), pItemDefIDs, ref punItemDefIDsArraySize); } @@ -342,6 +348,9 @@ public static SteamAPICall_t RequestEligiblePromoItemDefinitionsIDs(CSteamID ste /// public static bool GetEligiblePromoItemDefinitionIDs(CSteamID steamID, SteamItemDef_t[] pItemDefIDs, ref uint punItemDefIDsArraySize) { InteropHelp.TestIfAvailableGameServer(); + if (pItemDefIDs.Length != punItemDefIDsArraySize) { + throw new System.ArgumentException("pItemDefIDs must be the same size as punItemDefIDsArraySize!"); + } return NativeMethods.ISteamInventory_GetEligiblePromoItemDefinitionIDs(CSteamGameServerAPIContext.GetSteamInventory(), steamID, pItemDefIDs, ref punItemDefIDsArraySize); } @@ -378,6 +387,15 @@ public static uint GetNumItemsWithPrices() { /// public static bool GetItemsWithPrices(SteamItemDef_t[] pArrayItemDefs, ulong[] pCurrentPrices, ulong[] pBasePrices, uint unArrayLength) { InteropHelp.TestIfAvailableGameServer(); + if (pArrayItemDefs.Length != unArrayLength) { + throw new System.ArgumentException("pArrayItemDefs must be the same size as unArrayLength!"); + } + if (pCurrentPrices.Length != unArrayLength) { + throw new System.ArgumentException("pCurrentPrices must be the same size as unArrayLength!"); + } + if (pBasePrices.Length != unArrayLength) { + throw new System.ArgumentException("pBasePrices must be the same size as unArrayLength!"); + } return NativeMethods.ISteamInventory_GetItemsWithPrices(CSteamGameServerAPIContext.GetSteamInventory(), pArrayItemDefs, pCurrentPrices, pBasePrices, unArrayLength); } diff --git a/Plugins/Steamworks.NET/autogen/isteaminput.cs b/Plugins/Steamworks.NET/autogen/isteaminput.cs index 48c9c7d3..c4e02388 100644 --- a/Plugins/Steamworks.NET/autogen/isteaminput.cs +++ b/Plugins/Steamworks.NET/autogen/isteaminput.cs @@ -107,6 +107,9 @@ public static void DeactivateAllActionSetLayers(InputHandle_t inputHandle) { /// public static int GetActiveActionSetLayers(InputHandle_t inputHandle, InputActionSetHandle_t[] handlesOut) { InteropHelp.TestIfAvailableClient(); + if (handlesOut.Length != Constants.STEAM_INPUT_MAX_ACTIVE_LAYERS) { + throw new System.ArgumentException("handlesOut must be the same size as Constants.STEAM_INPUT_MAX_ACTIVE_LAYERS!"); + } return NativeMethods.ISteamInput_GetActiveActionSetLayers(CSteamAPIContext.GetSteamInput(), inputHandle, handlesOut); } @@ -138,6 +141,9 @@ public static InputDigitalActionData_t GetDigitalActionData(InputHandle_t inputH /// public static int GetDigitalActionOrigins(InputHandle_t inputHandle, InputActionSetHandle_t actionSetHandle, InputDigitalActionHandle_t digitalActionHandle, EInputActionOrigin[] originsOut) { InteropHelp.TestIfAvailableClient(); + if (originsOut.Length != Constants.STEAM_INPUT_MAX_ORIGINS) { + throw new System.ArgumentException("originsOut must be the same size as Constants.STEAM_INPUT_MAX_ORIGINS!"); + } return NativeMethods.ISteamInput_GetDigitalActionOrigins(CSteamAPIContext.GetSteamInput(), inputHandle, actionSetHandle, digitalActionHandle, originsOut); } @@ -166,6 +172,9 @@ public static InputAnalogActionData_t GetAnalogActionData(InputHandle_t inputHan /// public static int GetAnalogActionOrigins(InputHandle_t inputHandle, InputActionSetHandle_t actionSetHandle, InputAnalogActionHandle_t analogActionHandle, EInputActionOrigin[] originsOut) { InteropHelp.TestIfAvailableClient(); + if (originsOut.Length != Constants.STEAM_INPUT_MAX_ORIGINS) { + throw new System.ArgumentException("originsOut must be the same size as Constants.STEAM_INPUT_MAX_ORIGINS!"); + } return NativeMethods.ISteamInput_GetAnalogActionOrigins(CSteamAPIContext.GetSteamInput(), inputHandle, actionSetHandle, analogActionHandle, originsOut); } diff --git a/Plugins/Steamworks.NET/autogen/isteaminventory.cs b/Plugins/Steamworks.NET/autogen/isteaminventory.cs index c746a5ad..cdb192fe 100644 --- a/Plugins/Steamworks.NET/autogen/isteaminventory.cs +++ b/Plugins/Steamworks.NET/autogen/isteaminventory.cs @@ -41,6 +41,9 @@ public static EResult GetResultStatus(SteamInventoryResult_t resultHandle) { /// public static bool GetResultItems(SteamInventoryResult_t resultHandle, SteamItemDetails_t[] pOutItemsArray, ref uint punOutItemsArraySize) { InteropHelp.TestIfAvailableClient(); + if (pOutItemsArray.Length != punOutItemsArraySize) { + throw new System.ArgumentException("pOutItemsArray must be the same size as punOutItemsArraySize!"); + } return NativeMethods.ISteamInventory_GetResultItems(CSteamAPIContext.GetSteamInventory(), resultHandle, pOutItemsArray, ref punOutItemsArraySize); } @@ -300,6 +303,9 @@ public static bool LoadItemDefinitions() { /// public static bool GetItemDefinitionIDs(SteamItemDef_t[] pItemDefIDs, ref uint punItemDefIDsArraySize) { InteropHelp.TestIfAvailableClient(); + if (pItemDefIDs.Length != punItemDefIDsArraySize) { + throw new System.ArgumentException("pItemDefIDs must be the same size as punItemDefIDsArraySize!"); + } return NativeMethods.ISteamInventory_GetItemDefinitionIDs(CSteamAPIContext.GetSteamInventory(), pItemDefIDs, ref punItemDefIDsArraySize); } @@ -342,6 +348,9 @@ public static SteamAPICall_t RequestEligiblePromoItemDefinitionsIDs(CSteamID ste /// public static bool GetEligiblePromoItemDefinitionIDs(CSteamID steamID, SteamItemDef_t[] pItemDefIDs, ref uint punItemDefIDsArraySize) { InteropHelp.TestIfAvailableClient(); + if (pItemDefIDs.Length != punItemDefIDsArraySize) { + throw new System.ArgumentException("pItemDefIDs must be the same size as punItemDefIDsArraySize!"); + } return NativeMethods.ISteamInventory_GetEligiblePromoItemDefinitionIDs(CSteamAPIContext.GetSteamInventory(), steamID, pItemDefIDs, ref punItemDefIDsArraySize); } @@ -378,6 +387,15 @@ public static uint GetNumItemsWithPrices() { /// public static bool GetItemsWithPrices(SteamItemDef_t[] pArrayItemDefs, ulong[] pCurrentPrices, ulong[] pBasePrices, uint unArrayLength) { InteropHelp.TestIfAvailableClient(); + if (pArrayItemDefs.Length != unArrayLength) { + throw new System.ArgumentException("pArrayItemDefs must be the same size as unArrayLength!"); + } + if (pCurrentPrices.Length != unArrayLength) { + throw new System.ArgumentException("pCurrentPrices must be the same size as unArrayLength!"); + } + if (pBasePrices.Length != unArrayLength) { + throw new System.ArgumentException("pBasePrices must be the same size as unArrayLength!"); + } return NativeMethods.ISteamInventory_GetItemsWithPrices(CSteamAPIContext.GetSteamInventory(), pArrayItemDefs, pCurrentPrices, pBasePrices, unArrayLength); }