The database is duplicatedSolved

All hi I have when writing to the database, for some reason its zero copy is created

 

public class DataBase : DataBaseSleepingBag
    {
        public ulong userID;
        public List<DataBaseSleepingBag>  dataBaseSleepingbag = new List<DataBaseSleepingBag>(); 
        public DataBase()
        {
                      
        }
        
    }
    public class DataBaseSleepingBag
    {
        public UnityEngine.Vector3 sethome;
        public ulong sleepingBagID;
        public int sleepingBagName;
    }
    private StoreData DataBasePlayer = new StoreData();
    class StoreData
    {
        public Dictionary<ulong, DataBase> InfoData = new Dictionary<ulong, DataBase>();
    }

// Structure

 

// Execution code

 void CreateBase(BasePlayer player,  UnityEngine.Vector3 pos, ulong sleepID, int bedName)
    {
        var data = new DataBase
        {
            userID = player.userID,
            dataBaseSleepingbag  = new List<DataBaseSleepingBag>()
            {
            new DataBaseSleepingBag
             {
                sethome = pos,
                sleepingBagID = sleepID,
                sleepingBagName =  bedName
             }
            }
        };
        DataBasePlayer.InfoData.Add(player.userID, data);
        SaveData();
    }

 

// Result

{
  "InfoData": {
    "76561############": {
      "userID": 76561############,
      "dataBaseSleepingbag": [
        {
          "sethome": {
            "x": 982.0172,
            "y": 0.304811954,
            "z": -895.9628
          },
          "sleepingBagID": 65681,
          "sleepingBagName": 1
        }
      ],
//???????????In connection with what it appears?
      "sethome": {
        "x": 0.0,
        "y": 0.0,
        "z": 0.0
      },
      "sleepingBagID": 0,
      "sleepingBagName": 0
    }
//??????In connection with what it appears?
  }
}

It's because DataBase is inheriting from DataBaseSleepingBag. So the DataBase class is inheriting the fields/properties from DataBaseSleepingBag and they are being serialised.

I pasted your whole post into chatgpt without any additional context and it spit this out.



Merged post

When asked how it would fix it.. I got this https://prnt.sc/sPGngEhnfz_f

Yes, I've already fixed it, I noticed. But thanks anyway my friend

8SecSleeper

I pasted your whole post into chatgpt without any additional context and it spit this out.



Merged post

When asked how it would fix it.. I got this https://prnt.sc/sPGngEhnfz_f

It's starting to upset me that such bots are replacing us, I hope this won't happen :с

Locked automatically