private void writeUserMap(BinSerializer s)
        {
            UInt32 len = (UInt32)users.Count;

            s.writeUInt32(len);
            foreach (ulong key in users.Keys)
            {
                s.writeUInt64(key);
                s.writeUTF8String(users[key]);
            }
        }
Exemple #2
0
        public void testSave()
        {
            test.Add(new List <string>());
            test.Add(new List <string>());
            test.Add(new List <string>());
            test[0].Add("Item01");
            test[1].Add("Item11");
            test[0].Add("Item02");
            test[2].Add("Item21");

            int arrLen = 0;

            int list1len = test.Count;

            arrLen += 4;            //integer for the superlist length

            arrLen += 4 * list1len; //integers for the length of each sublist

            for (int i = 0; i < list1len; i++)
            {
                arrLen += 4 * test[i].Count; //integers for the length of each string
                foreach (string s in test[i])
                {
                    int slen = Encoding.UTF8.GetByteCount(s);
                    arrLen += slen; //actual size of the string;
                }
            }
            BinSerializer serializer = new BinSerializer(arrLen);

            serializer.writeInt(list1len);
            foreach (List <string> ls in test)
            {
                serializer.writeInt(ls.Count);
                foreach (string s in ls)
                {
                    int slen = Encoding.UTF8.GetByteCount(s);
                    serializer.writeInt(slen);
                    serializer.writeUTF8String(s);
                }
            }

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            string filepath = Path.Combine(path, gamesSaveFile);

            File.WriteAllBytes(filepath, serializer.data);
        }
Exemple #3
0
        private void saveKeylist()
        {
            int arrLen = 0;

            int list1len = games.Count;

            arrLen += 8;            //integer for the superlist length and the interval time at end

            arrLen += 4 * list1len; //integers for the length of each sublist

            for (int i = 0; i < list1len; i++)
            {
                arrLen += 4 * games[i].Count; //integers for the length of each string
                foreach (string s in games[i])
                {
                    int slen = Encoding.UTF8.GetByteCount(s);
                    arrLen += slen; //actual size of the string;
                }
            }
            BinSerializer serializer = new BinSerializer(arrLen);

            serializer.writeInt(list1len);
            foreach (List <string> ls in games)
            {
                serializer.writeInt(ls.Count);
                foreach (string s in ls)
                {
                    serializer.writeUTF8String(s);
                }
            }

            serializer.writeInt(CLAIM_CD);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            string filepath = Path.Combine(path, gamesSaveFile);

            File.WriteAllBytes(filepath, serializer.data);
        }
Exemple #4
0
        private void saveClaimlist()
        {
            int arrLen = 0;

            int list1len = claimMap.Count;

            arrLen += 4; //Integer for the superlist length

            foreach (string name in claimMap.Keys)
            {
                arrLen += 8; //2 ints for name length and KeyGamePair list length
                arrLen += Encoding.UTF8.GetByteCount(name);
                foreach (KeyGamePair p in claimMap[name])
                {
                    arrLen += p.getSerializableSize();
                }
            }

            BinSerializer serializer = new BinSerializer(arrLen);

            serializer.writeInt(list1len);
            foreach (string name in claimMap.Keys)
            {
                serializer.writeUTF8String(name);
                serializer.writeInt(claimMap[name].Count);
                foreach (KeyGamePair p in claimMap[name])
                {
                    p.serialize(serializer);
                }
            }

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            string filepath = Path.Combine(path, claimantFile);

            File.WriteAllBytes(filepath, serializer.data);
        }
Exemple #5
0
 public void serialize(BinSerializer s)
 {
     s.writeUTF8String(game);
     s.writeUTF8String(key);
 }