Ignore:
Timestamp:
Dec 12, 2015, 4:08:53 PM (9 years ago)
Author:
alloc
Message:

Fixes 6_8_10

File:
1 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements/MapRendering/Web/API/GetPlayerInventory.cs

    r251 r253  
    88{
    99        public class GetPlayerInventory : WebAPI {
     10
    1011                public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) {
    1112                        if (req.QueryString ["steamid"] == null) {
     
    3839                        DoInventory (bag, inv.bag);
    3940
    40                         AddEquipment (equipment, "head", inv.equipment, XMLData.Item.EnumEquipmentSlot.Head, NGuiInvGridEquipment.EnumClothingLayer.Middle);
    41                         AddEquipment (equipment, "eyes", inv.equipment, XMLData.Item.EnumEquipmentSlot.Eyes, NGuiInvGridEquipment.EnumClothingLayer.Middle);
    42                         AddEquipment (equipment, "face", inv.equipment, XMLData.Item.EnumEquipmentSlot.Face, NGuiInvGridEquipment.EnumClothingLayer.Middle);
     41                        AddEquipment (equipment, "head", inv.equipment, EquipmentSlots.Headgear);
     42                        AddEquipment (equipment, "eyes", inv.equipment, EquipmentSlots.Eyewear);
     43                        AddEquipment (equipment, "face", inv.equipment, EquipmentSlots.Face);
    4344
    44                         AddEquipment (equipment, "armor", inv.equipment, XMLData.Item.EnumEquipmentSlot.Chest, NGuiInvGridEquipment.EnumClothingLayer.Outer);
    45                         AddEquipment (equipment, "jacket", inv.equipment, XMLData.Item.EnumEquipmentSlot.Chest, NGuiInvGridEquipment.EnumClothingLayer.Middle);
    46                         AddEquipment (equipment, "shirt", inv.equipment, XMLData.Item.EnumEquipmentSlot.Chest, NGuiInvGridEquipment.EnumClothingLayer.Inner);
     45                        AddEquipment (equipment, "armor", inv.equipment, EquipmentSlots.ChestArmor);
     46                        AddEquipment (equipment, "jacket", inv.equipment, EquipmentSlots.Jacket);
     47                        AddEquipment (equipment, "shirt", inv.equipment, EquipmentSlots.Shirt);
    4748
    48                         AddEquipment (equipment, "legarmor", inv.equipment, XMLData.Item.EnumEquipmentSlot.Legs, NGuiInvGridEquipment.EnumClothingLayer.Outer);
    49                         AddEquipment (equipment, "pants", inv.equipment, XMLData.Item.EnumEquipmentSlot.Legs, NGuiInvGridEquipment.EnumClothingLayer.Inner);
    50                         AddEquipment (equipment, "boots", inv.equipment, XMLData.Item.EnumEquipmentSlot.Feet, NGuiInvGridEquipment.EnumClothingLayer.Inner);
     49                        AddEquipment (equipment, "legarmor", inv.equipment, EquipmentSlots.LegArmor);
     50                        AddEquipment (equipment, "pants", inv.equipment, EquipmentSlots.Legs);
     51                        AddEquipment (equipment, "boots", inv.equipment, EquipmentSlots.Feet);
    5152
    52                         AddEquipment (equipment, "gloves", inv.equipment, XMLData.Item.EnumEquipmentSlot.Hands, NGuiInvGridEquipment.EnumClothingLayer.Inner);
    53                         AddEquipment (equipment, "backpack", inv.equipment, XMLData.Item.EnumEquipmentSlot.Back, NGuiInvGridEquipment.EnumClothingLayer.Outer);
     53                        AddEquipment (equipment, "gloves", inv.equipment, EquipmentSlots.Hands);
    5454
    5555                        WriteJSON (resp, result);
     
    6262                }
    6363
    64                 private void AddEquipment (JSONObject _eq, string _slotname, InvItem[] _items, XMLData.Item.EnumEquipmentSlot _slot, NGuiInvGridEquipment.EnumClothingLayer _layer) {
    65                         int index = (int)_slot + (int)_layer * (int)XMLData.Item.EnumEquipmentSlot.Count;
    66                         if (_items != null) {
    67                                 _eq.Add (_slotname, GetJsonForItem (_items [index]));
    68                         } else {
    69                                 _eq.Add (_slotname, new JSONNull ());
     64                private void AddEquipment (JSONObject _eq, string _slotname, InvItem[] _items, EquipmentSlots _slot) {
     65                        int[] slotindices = XUiM_PlayerEquipment.GetSlotIndicesByEquipmentSlot (_slot);
     66
     67                        for (int i = 0; i < slotindices.Length; i++) {
     68                                if (_items != null && _items [slotindices [i]] != null) {
     69                                        InvItem item = _items [slotindices [i]];
     70                                        _eq.Add (_slotname, GetJsonForItem (item));
     71                                        return;
     72                                }
    7073                        }
     74
     75                        _eq.Add (_slotname, new JSONNull ());
    7176                }
    7277
     
    7580                                JSONObject jsonItem = new JSONObject ();
    7681                                jsonItem.Add ("count", new JSONNumber (_item.count));
    77                 jsonItem.Add ("name", new JSONString (_item.itemName));
    78                 jsonItem.Add ("icon", new JSONString (_item.icon));
    79                 jsonItem.Add ("iconcolor", new JSONString ((string.IsNullOrEmpty (_item.iconcolor) || _item.iconcolor == "FFFFFF" ? "" : _item.iconcolor)));
    80                 jsonItem.Add ("quality", new JSONNumber(_item.quality));
     82                                jsonItem.Add ("name", new JSONString (_item.itemName));
     83                                jsonItem.Add ("icon", new JSONString (_item.icon));
     84                                jsonItem.Add ("iconcolor", new JSONString (_item.iconcolor));
     85                                jsonItem.Add ("quality", new JSONNumber (_item.quality));
    8186                                if (_item.quality >= 0) {
    8287                                        jsonItem.Add ("qualitycolor", new JSONString (QualityInfo.GetQualityColorHex (_item.quality)));
Note: See TracChangeset for help on using the changeset viewer.