From 9e7b93cd59cdae03b0a1863ea4ee99c85321f8b9 Mon Sep 17 00:00:00 2001 From: Citrinate Date: Sun, 29 Dec 2024 16:29:39 -0500 Subject: [PATCH] Remove position property, return items in correct order instead --- .../GameData/GameObjects/Items/InventoryItem.cs | 10 ---------- CS2Interface/IPC/Api/CS2InterfaceController.cs | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/CS2Interface/GameData/GameObjects/Items/InventoryItem.cs b/CS2Interface/GameData/GameObjects/Items/InventoryItem.cs index 762aeb6..f46c59e 100644 --- a/CS2Interface/GameData/GameObjects/Items/InventoryItem.cs +++ b/CS2Interface/GameData/GameObjects/Items/InventoryItem.cs @@ -15,10 +15,6 @@ public sealed class InventoryItem : Item { [JsonConverter (typeof(AttributeConverter))] public Dictionary? Attributes { get; private set; } - [JsonInclude] - [JsonPropertyName("position")] - public uint? Position { get; private set; } - [JsonInclude] [JsonPropertyName("casket_id")] public ulong? CasketID { get; private set; } @@ -29,7 +25,6 @@ public sealed class InventoryItem : Item { public bool? Moveable { get; private set; } public bool ShouldSerializeAttributes() => Attributes != null && ShouldSerializeAdditionalProperties; - public bool ShouldSerializePosition() => Position != null && ShouldSerializeAdditionalProperties; public bool ShouldSerializeCasketID() => CasketID != null && ShouldSerializeAdditionalProperties; public bool ShouldSerializeMoveable() => Moveable != null && ShouldSerializeAdditionalProperties; @@ -53,11 +48,6 @@ internal InventoryItem(CSOEconItem item) { SetDefs(); - { - bool is_new = ((ItemInfo.inventory >>> 30) & 1) == 1; - Position = is_new ? 0 : ItemInfo.inventory & 0xFFFF; - } - { uint? casket_low = Attributes.GetValueOrDefault("casket item id low")?.ToUInt32(); uint? casket_high = Attributes.GetValueOrDefault("casket item id high")?.ToUInt32(); diff --git a/CS2Interface/IPC/Api/CS2InterfaceController.cs b/CS2Interface/IPC/Api/CS2InterfaceController.cs index cc856cb..3c869b5 100644 --- a/CS2Interface/IPC/Api/CS2InterfaceController.cs +++ b/CS2Interface/IPC/Api/CS2InterfaceController.cs @@ -173,7 +173,7 @@ public ActionResult Inventory(string botName, [FromQuery] bool return BadRequest(new GenericResponse(false, "Inventory not loaded yet")); } - List inventory = client.Inventory.Values.Where(x => x.IsVisible() && x.CasketID == null).ToList(); + List inventory = client.Inventory.Values.Where(x => x.IsVisible() && x.CasketID == null).OrderByDescending(x => x.ItemInfo.id).ToList(); GameObject.SetSerializationProperties(!minimal, showDefs); return Ok(new GenericResponse>(true, inventory)); @@ -208,7 +208,7 @@ public async Task> GetCrateContents(string botName GameObject.SetSerializationProperties(!minimal, showDefs); - return Ok(new GenericResponse>(true, contents)); + return Ok(new GenericResponse>(true, contents.OrderByDescending(x => x.ItemInfo.id).ToList())); } [HttpGet("{botName:required}/StoreItem/{crateID:required}/{itemID:required}")]