Changeset 250 for binary-improvements/7dtd-server-fixes/src
- Timestamp:
- Aug 12, 2015, 6:10:28 PM (9 years ago)
- Location:
- binary-improvements/7dtd-server-fixes/src/PersistentData
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/PersistentData/InvItem.cs
r145 r250 9 9 public string itemName; 10 10 public int count; 11 public int quality; 12 public InvItem[] parts; 11 13 12 public InvItem (string itemName, int count )14 public InvItem (string itemName, int count, int quality = -1) 13 15 { 14 16 this.itemName = itemName; 15 17 this.count = count; 18 this.quality = quality; 16 19 } 17 20 } -
binary-improvements/7dtd-server-fixes/src/PersistentData/Inventory.cs
r245 r250 23 23 ProcessInv (bag, pdf.bag, pdf.id); 24 24 ProcessInv (belt, pdf.inventory, pdf.id); 25 ProcessEqu (pdf.equipment );25 ProcessEqu (pdf.equipment, pdf.id); 26 26 } 27 27 } … … 30 30 target.Clear (); 31 31 for (int i = 0; i < sourceFields.Length; i++) { 32 if (sourceFields [i].count > 0) { 33 int count = sourceFields [i].count; 34 int maxAllowed = ItemClass.list [sourceFields [i].itemValue.type].Stacknumber.Value; 35 string name = ItemClass.list [sourceFields [i].itemValue.type].GetItemName (); 36 37 if (count > maxAllowed) { 38 Log.Out ("Player with ID " + id + " has stack for \"" + name + "\" greater than allowed (" + count + " > " + maxAllowed + ")"); 39 } 40 target.Add (new InvItem (name, count)); 41 } else { 42 target.Add (null); 32 InvItem item = CreateInvItem (sourceFields [i].itemValue, sourceFields [i].count, id); 33 if (item != null && sourceFields [i].itemValue.Parts != null) { 34 ProcessParts (sourceFields [i].itemValue.Parts, item, id); 43 35 } 36 target.Add (item); 44 37 } 45 38 } 46 39 47 private void ProcessEqu (Equipment sourceEquipment ) {40 private void ProcessEqu (Equipment sourceEquipment, int _playerId) { 48 41 equipment = new InvItem[sourceEquipment.GetSlotCount ()]; 49 42 for (int i = 0; i < sourceEquipment.GetSlotCount (); i++) { 50 if (sourceEquipment.GetSlotItem (i) != null && !sourceEquipment.GetSlotItem (i).Equals (ItemValue.None)) {51 int count = 1;52 string name = ItemClass.list [sourceEquipment.GetSlotItem (i).type].GetItemName ();43 equipment [i] = CreateInvItem (sourceEquipment.GetSlotItem (i), 1, _playerId); 44 } 45 } 53 46 54 equipment [i] = new InvItem (name, count); 47 private void ProcessParts (ItemValue[] _parts, InvItem _item, int _playerId) { 48 InvItem[] itemParts = new InvItem[_parts.Length]; 49 for (int i = 0; i < _parts.Length; i++) { 50 InvItem partItem = CreateInvItem (_parts [i], 1, _playerId); 51 if (partItem != null && _parts [i].Parts != null) { 52 ProcessParts (_parts [i].Parts, partItem, _playerId); 53 } 54 itemParts [i] = partItem; 55 } 56 _item.parts = itemParts; 57 } 58 59 private InvItem CreateInvItem (ItemValue _itemValue, int _count, int _playerId) { 60 if (_count > 0 && _itemValue != null && !_itemValue.Equals (ItemValue.None)) { 61 int maxAllowed = ItemClass.list [_itemValue.type].Stacknumber.Value; 62 string name = ItemClass.list [_itemValue.type].GetItemName (); 63 64 if (_count > maxAllowed) { 65 Log.Out ("Player with ID " + _playerId + " has stack for \"" + name + "\" greater than allowed (" + _count + " > " + maxAllowed + ")"); 66 } 67 68 InvItem item = null; 69 if (_itemValue.HasQuality) { 70 item = new InvItem (name, _count, _itemValue.Quality); 55 71 } else { 56 equipment [i] = null;72 item = new InvItem (name, _count); 57 73 } 74 return item; 75 } else { 76 return null; 58 77 } 59 78 }
Note:
See TracChangeset
for help on using the changeset viewer.