Skip to content

Commit

Permalink
Remove position property, return items in correct order instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Dec 29, 2024
1 parent 3c71c43 commit 9e7b93c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
10 changes: 0 additions & 10 deletions CS2Interface/GameData/GameObjects/Items/InventoryItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public sealed class InventoryItem : Item {
[JsonConverter (typeof(AttributeConverter))]
public Dictionary<string, IAttribute>? Attributes { get; private set; }

[JsonInclude]
[JsonPropertyName("position")]
public uint? Position { get; private set; }

[JsonInclude]
[JsonPropertyName("casket_id")]
public ulong? CasketID { get; private set; }
Expand All @@ -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;

Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions CS2Interface/IPC/Api/CS2InterfaceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public ActionResult<GenericResponse> Inventory(string botName, [FromQuery] bool
return BadRequest(new GenericResponse(false, "Inventory not loaded yet"));
}

List<InventoryItem> inventory = client.Inventory.Values.Where(x => x.IsVisible() && x.CasketID == null).ToList();
List<InventoryItem> 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<List<InventoryItem>>(true, inventory));
Expand Down Expand Up @@ -208,7 +208,7 @@ public async Task<ActionResult<GenericResponse>> GetCrateContents(string botName

GameObject.SetSerializationProperties(!minimal, showDefs);

return Ok(new GenericResponse<List<InventoryItem>>(true, contents));
return Ok(new GenericResponse<List<InventoryItem>>(true, contents.OrderByDescending(x => x.ItemInfo.id).ToList()));
}

[HttpGet("{botName:required}/StoreItem/{crateID:required}/{itemID:required}")]
Expand Down

0 comments on commit 9e7b93c

Please sign in to comment.