Пример #1
0
 internal static void InitializeVanillaIDMatrix()
 {
     IsHostVanilla = true;
     MatrixReady   = false;
     foreach (Registry reg in GameRegistry.ListAllRegistries())
     {
         IDConversionMatrixToHost[reg.GetRegistryName()]  = new Dictionary <int, int>();
         IDConversionMatrixToLocal[reg.GetRegistryName()] = new Dictionary <int, int>();
     }
     MatrixReady = true;
     OnMatrixReady?.Invoke(false);
 }
Пример #2
0
 internal static void ParseIDMatrixData(string packedData)
 {
     IsHostVanilla = false;
     MatrixReady   = false;
     try
     {
         foreach (string dicEntry in packedData.Split('|'))
         {
             string[] splitDic = dicEntry.Split(new char[] { ':' }, 2);
             if (GameRegistry.IsRegistryRegistered(splitDic[0]))
             {
                 Registry reg = GameRegistry.GetRegistry(splitDic[0]);
                 IDConversionMatrixToHost[reg.GetRegistryName()]  = new Dictionary <int, int>();
                 IDConversionMatrixToLocal[reg.GetRegistryName()] = new Dictionary <int, int>();
                 foreach (string regEntry in splitDic[1].Split(','))
                 {
                     string[] splitReg = regEntry.Split('=');
                     if (reg.reservedIDs.ContainsKey(splitReg[0]))
                     {
                         int hostID = int.Parse(splitReg[1]);
                         IDConversionMatrixToHost[reg.GetRegistryName()][reg.reservedIDs[splitReg[0]]] = hostID;
                         IDConversionMatrixToLocal[reg.GetRegistryName()][hostID] = reg.reservedIDs[splitReg[0]];
                     }
                 }
             }
         }
         MatrixReady = true;
     }
     catch (Exception e)
     {
         GadgetCore.CoreLogger.LogError("Received bad host ID conversion data: " + packedData);
         GadgetCore.CoreLogger.LogError("Exception that occured while parsing host ID conversion data:" + Environment.NewLine + e.ToString());
         Network.Disconnect();
     }
     OnMatrixReady?.Invoke(true);
 }