Changeset 517


Ignore:
Timestamp:
Sep 29, 2026, 6:55:40 PM (7 weeks ago)
Author:
alloc
Message:

31_39_53: 3.3 compatibility

Location:
binary-improvements
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements/7dtd-server-fixes/7dtd-server-fixes.csproj

    r470 r517  
    1010    <AssemblyName>7dtd-server-fixes</AssemblyName>
    1111    <RootNamespace>AllocsFixes</RootNamespace>
    12     <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
     12    <TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
    1313    <LangVersion>9</LangVersion>
    1414  </PropertyGroup>
  • binary-improvements/7dtd-server-fixes/ModInfo.xml

    r513 r517  
    55        <Description value="Common functions" />
    66        <Author value="Christian 'Alloc' Illy" />
    7         <Version value="38" />
     7        <Version value="39" />
    88        <Website value="https://7dtd.illy.bz" />
    99</xml>
  • binary-improvements/7dtd-server-fixes/src/PersistentData/Inventory.cs

    r513 r517  
    11using System;
    22using System.Collections.Generic;
     3using System.IO;
    34
    45namespace AllocsFixes.PersistentData {
    56        [Serializable]
    67        public class Inventory {
     8                public static readonly EnumDictionary<EquipmentSlots, string> CustomEquipmentSlotNames =
     9                        new() {
     10                                { EquipmentSlots.Chest, "armor" },
     11                                { EquipmentSlots.Hands, "gloves" },
     12                                { EquipmentSlots.Feet, "boots" },
     13                        };
     14               
    715                public List<InvItem> bag;
    816                public List<InvItem> belt;
    … …  
    1725                public void Update (PlayerDataFile _pdf) {
    1826                        lock (this) {
    19                                 //Log.Out ("Updating player inventory - player id: " + pdf.id);
    20                                 ProcessInv (bag, _pdf.bag.items, _pdf.id);
    21                                 ProcessInv (belt, _pdf.inventory, _pdf.id);
    22                                 ProcessEqu (_pdf.equipment, _pdf.id);
     27                                ItemStackGrid toolbeltRead = readToolbelt (_pdf.inventoryData);
     28
     29                                Bag bagRead = null;
     30                                StreamUtils.FromBlob (_pdf.bagData, pbr => bagRead = Bag.Read (pbr, XUiC_ItemStack.StackLocationTypes.Backpack, StreamModeRead.FromClient, null));
     31                               
     32                                Equipment equipRead = null;
     33                                StreamUtils.FromBlob (_pdf.equipmentData, pbr => equipRead = Equipment.Read (pbr, StreamModeRead.FromClient));
     34
     35                                ProcessInv (bag, bagRead.ItemGrid.items, _pdf.id);
     36                                ProcessInv (belt, toolbeltRead.items, _pdf.id);
     37                                ProcessEqu (equipRead, _pdf.id);
    2338                        }
    2439                }
    2540
    26                 private void ProcessInv (ICollection<InvItem> _target, IReadOnlyList<ItemStack> _sourceFields, int _id) {
     41                private ItemStackGrid readToolbelt (MemoryStream _ms) {
     42                        ItemStackGrid grid = ItemStackGrid.Create (new Vector2i (1, 1), XUiC_ItemStack.StackLocationTypes.ToolBelt, false, false, null);
     43                        StreamUtils.FromBlob (_ms, pbr => {
     44                                byte version = pbr.ReadByte ();
     45                                grid.ReadInto (pbr, StreamModeRead.FromClient);
     46                        });
     47                        return grid;
     48                }
     49
     50                private void ProcessInv (ICollection<InvItem> _target, IReadOnlyList<ItemStack> _sourceFields, int _playerId) {
    2751                        _target.Clear ();
    2852                        for (int i = 0; i < _sourceFields.Count; i++) {
    29                                 InvItem item = CreateInvItem (_sourceFields [i].itemValue, _sourceFields [i].count, _id);
    30                                 if (item != null && _sourceFields [i].itemValue.Modifications != null) {
    31                                         ProcessParts (_sourceFields [i].itemValue.Modifications, item, _id);
     53                                ItemValue curItemValue = _sourceFields [i].itemValue;
     54                                InvItem item = CreateInvItem (curItemValue, _sourceFields [i].count, _playerId);
     55                                if (item != null) {
     56                                        ProcessParts (curItemValue, item, _playerId);
    3257                                }
    3358
    … …  
    3964                        equipment = new InvItem[_sourceEquipment.GetSlotCount ()];
    4065                        for (int i = 0; i < _sourceEquipment.GetSlotCount (); i++) {
    41                                 equipment [i] = CreateInvItem (_sourceEquipment.GetSlotItem (i), 1, _playerId);
     66                                ItemValue curItemValue = _sourceEquipment.GetSlotItem (i);
     67                                equipment [i] = CreateInvItem (curItemValue, 1, _playerId);
     68                                if (equipment [i] != null) {
     69                                        ProcessParts (curItemValue, equipment [i], _playerId);
     70                                }
    4271                        }
    4372                }
    4473
    45                 private void ProcessParts (IReadOnlyList<ItemValue> _parts, InvItem _item, int _playerId) {
    46                         InvItem[] itemParts = new InvItem[_parts.Count];
    47                         for (int i = 0; i < _parts.Count; i++) {
    48                                 InvItem partItem = CreateInvItem (_parts [i], 1, _playerId);
    49                                 if (partItem != null && _parts [i].Modifications != null) {
    50                                         ProcessParts (_parts [i].Modifications, partItem, _playerId);
     74                private void ProcessParts (ItemValue _parent, InvItem _item, int _playerId) {
     75                        if (_parent.ModificationCount < 1) {
     76                                return;
     77                        }
     78                       
     79                        InvItem[] itemParts = new InvItem[_parent.ModificationCount];
     80                        for (int i = 0; i < _parent.ModificationCount; i++) {
     81                                ItemValue part = _parent.GetModification (i);
     82                                InvItem partItem = CreateInvItem (part, 1, _playerId);
     83                                if (partItem != null) {
     84                                        ProcessParts (part, partItem, _playerId);
    5185                                }
    5286
  • binary-improvements/AllocsCommands/AllocsCommands.csproj

    r470 r517  
    1010    <RootNamespace>AllocsCommands</RootNamespace>
    1111    <AssemblyName>AllocsCommands</AssemblyName>
    12     <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
     12    <TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
    1313  </PropertyGroup>
    1414  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  • binary-improvements/AllocsCommands/Commands/ShowInventory.cs

    r488 r517  
    103103
    104104                private static void PrintEquipment (IReadOnlyList<InvItem> _equipment, int _entityId, string _location, string _tag) {
    105                         AddEquipment ("head", _equipment, EquipmentSlots.Head, _entityId, _location, _tag);
    106                         // AddEquipment ("eyes", _equipment, EquipmentSlots.Eyewear, _entityId, _location, _tag);
    107                         // AddEquipment ("face", _equipment, EquipmentSlots.Face, _entityId, _location, _tag);
    108 
    109                         AddEquipment ("armor", _equipment, EquipmentSlots.Chest, _entityId, _location, _tag);
    110                         // AddEquipment ("jacket", _equipment, EquipmentSlots.Jacket, _entityId, _location, _tag);
    111                         // AddEquipment ("shirt", _equipment, EquipmentSlots.Shirt, _entityId, _location, _tag);
    112 
    113                         // AddEquipment ("legarmor", _equipment, EquipmentSlots.LegArmor, _entityId, _location, _tag);
    114                         // AddEquipment ("pants", _equipment, EquipmentSlots.Legs, _entityId, _location, _tag);
    115                         AddEquipment ("boots", _equipment, EquipmentSlots.Feet, _entityId, _location, _tag);
    116 
    117                         AddEquipment ("gloves", _equipment, EquipmentSlots.Hands, _entityId, _location, _tag);
     105                        for (EquipmentSlots slot = 0; slot < EquipmentSlots.Count; slot++) {
     106                                if (!PersistentData.Inventory.CustomEquipmentSlotNames.TryGetValue (slot, out string slotName)) {
     107                                        slotName = slot.ToStringCached ().ToLower ();
     108                                }
     109                                       
     110                                AddEquipment (slotName, _equipment, slot, _entityId, _location, _tag);
     111                        }
    118112                }
    119113
    … …  
    122116                        int slotindex = (int)_slot;
    123117
    124                         if (_items == null || _items[slotindex] == null) {
     118                        if (_items == null || slotindex >= _items.Count || _items[slotindex] == null) {
    125119                                return;
    126120                        }
    … …  
    130124                                // no Tag defined -> readable output
    131125                                if (item.quality < 0) {
    132                                         SdtdConsole.Instance.Output (string.Format ("    Slot {0:8}: {1:000}", _slotname,
     126                                        SdtdConsole.Instance.Output (string.Format ("    Slot {0}: {1}", _slotname,
    133127                                                item.itemName));
    134128                                } else {
    135                                         SdtdConsole.Instance.Output (string.Format ("    Slot {0:8}: {1:000} - quality: {2}",
     129                                        SdtdConsole.Instance.Output (string.Format ("    Slot {0}: {1} - quality: {2}",
    136130                                                _slotname, item.itemName, item.quality));
    137131                                }
  • binary-improvements/AllocsCommands/ModInfo.xml

    r513 r517  
    55        <Description value="Additional commands for server operation" />
    66        <Author value="Christian 'Alloc' Illy" />
    7         <Version value="30" />
     7        <Version value="31" />
    88        <Website value="https://7dtd.illy.bz" />
    99</xml>
  • binary-improvements/MapRendering/API/GetPlayerInventory.cs

    r488 r517  
    9191                }
    9292
    93                 private static void DoEquipment (ref JsonWriter _writer, IReadOnlyList<InvItem> _equ, bool _showIconColor, bool _showIconName) {
     93                private static void DoEquipment (ref JsonWriter _writer, IReadOnlyList<InvItem> _equipment, bool _showIconColor, bool _showIconName) {
    9494                        _writer.WriteBeginObject ();
    95                        
    96                         AddEquipment (ref _writer, "head", _equ, EquipmentSlots.Head, _showIconColor, _showIconName);
    97                         _writer.WriteValueSeparator ();
    9895
    99                         AddEquipment (ref _writer, "armor", _equ, EquipmentSlots.Chest, _showIconColor, _showIconName);
    100                         _writer.WriteValueSeparator ();
    101 
    102                         AddEquipment (ref _writer, "boots", _equ, EquipmentSlots.Feet, _showIconColor, _showIconName);
    103                         _writer.WriteValueSeparator ();
    104 
    105                         AddEquipment (ref _writer, "gloves", _equ, EquipmentSlots.Hands, _showIconColor, _showIconName);
     96                        for (EquipmentSlots slot = 0; slot < EquipmentSlots.Count; slot++) {
     97                                if (slot > 0) {
     98                                        _writer.WriteValueSeparator ();
     99                                }
     100                               
     101                                if (!PersistentData.Inventory.CustomEquipmentSlotNames.TryGetValue (slot, out string slotName)) {
     102                                        slotName = slot.ToStringCached ().ToLower ();
     103                                }
     104                                       
     105                                AddEquipment (ref _writer, slotName, _equipment, slot, _showIconColor, _showIconName);
     106                        }
    106107                       
    107108                        _writer.WriteEndObject ();
    … …  
    113114                        int slotindex = (int)_slot;
    114115
    115                         if (_items == null || _items[slotindex] == null) {
     116                        if (_items == null || slotindex >= _items.Count || _items[slotindex] == null) {
    116117                                // Slot not found / empty
    117118                                _writer.WriteNull ();
  • binary-improvements/MapRendering/ModInfo.xml

    r513 r517  
    55        <Description value="Render the game map to image map tiles as it is uncovered" />
    66        <Author value="Christian 'Alloc' Illy" />
    7         <Version value="52" />
     7        <Version value="53" />
    88        <Website value="https://7dtd.illy.bz" />
    99</xml>
  • binary-improvements/MapRendering/WebAndMapRendering.csproj

    r513 r517  
    1010    <RootNamespace>MapRendering</RootNamespace>
    1111    <AssemblyName>AllocsWeb</AssemblyName>
    12     <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
     12    <TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
    1313    <Nullable>warnings</Nullable>
    1414    <LangVersion>9</LangVersion>
  • binary-improvements/bin/Mods/Allocs_CommandExtensions/ModInfo.xml

    r513 r517  
    55        <Description value="Additional commands for server operation" />
    66        <Author value="Christian 'Alloc' Illy" />
    7         <Version value="30" />
     7        <Version value="31" />
    88        <Website value="https://7dtd.illy.bz" />
    99</xml>
  • binary-improvements/bin/Mods/Allocs_CommonFunc/ModInfo.xml

    r513 r517  
    55        <Description value="Common functions" />
    66        <Author value="Christian 'Alloc' Illy" />
    7         <Version value="38" />
     7        <Version value="39" />
    88        <Website value="https://7dtd.illy.bz" />
    99</xml>
  • binary-improvements/bin/Mods/Allocs_WebAndMapRendering/ModInfo.xml

    r513 r517  
    55        <Description value="Render the game map to image map tiles as it is uncovered" />
    66        <Author value="Christian 'Alloc' Illy" />
    7         <Version value="52" />
     7        <Version value="53" />
    88        <Website value="https://7dtd.illy.bz" />
    99</xml>
Note: See TracChangeset for help on using the changeset viewer.