Skip to content

Commit

Permalink
Automatically generate array safety code
Browse files Browse the repository at this point in the history
  • Loading branch information
rlabrecque committed Sep 8, 2019
1 parent a52bae4 commit 370f858
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Plugins/Steamworks.NET/autogen/isteamcontroller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public static void DeactivateAllActionSetLayers(ControllerHandle_t controllerHan
/// </summary>
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);
}

Expand Down Expand Up @@ -137,6 +140,9 @@ public static ControllerDigitalActionData_t GetDigitalActionData(ControllerHandl
/// </summary>
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);
}

Expand Down Expand Up @@ -165,6 +171,9 @@ public static ControllerAnalogActionData_t GetAnalogActionData(ControllerHandle_
/// </summary>
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);
}

Expand Down
18 changes: 18 additions & 0 deletions Plugins/Steamworks.NET/autogen/isteamgameserverinventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public static EResult GetResultStatus(SteamInventoryResult_t resultHandle) {
/// </summary>
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);
}

Expand Down Expand Up @@ -300,6 +303,9 @@ public static bool LoadItemDefinitions() {
/// </summary>
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);
}

Expand Down Expand Up @@ -342,6 +348,9 @@ public static SteamAPICall_t RequestEligiblePromoItemDefinitionsIDs(CSteamID ste
/// </summary>
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);
}

Expand Down Expand Up @@ -378,6 +387,15 @@ public static uint GetNumItemsWithPrices() {
/// </summary>
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);
}

Expand Down
9 changes: 9 additions & 0 deletions Plugins/Steamworks.NET/autogen/isteaminput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public static void DeactivateAllActionSetLayers(InputHandle_t inputHandle) {
/// </summary>
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);
}

Expand Down Expand Up @@ -138,6 +141,9 @@ public static InputDigitalActionData_t GetDigitalActionData(InputHandle_t inputH
/// </summary>
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);
}

Expand Down Expand Up @@ -166,6 +172,9 @@ public static InputAnalogActionData_t GetAnalogActionData(InputHandle_t inputHan
/// </summary>
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);
}

Expand Down
18 changes: 18 additions & 0 deletions Plugins/Steamworks.NET/autogen/isteaminventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public static EResult GetResultStatus(SteamInventoryResult_t resultHandle) {
/// </summary>
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);
}

Expand Down Expand Up @@ -300,6 +303,9 @@ public static bool LoadItemDefinitions() {
/// </summary>
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);
}

Expand Down Expand Up @@ -342,6 +348,9 @@ public static SteamAPICall_t RequestEligiblePromoItemDefinitionsIDs(CSteamID ste
/// </summary>
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);
}

Expand Down Expand Up @@ -378,6 +387,15 @@ public static uint GetNumItemsWithPrices() {
/// </summary>
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);
}

Expand Down

0 comments on commit 370f858

Please sign in to comment.