Exemplo n.º 1
0
        public void loadData(string path)
        {
            if (useAutoReloadFile)
            {
                autoFunctionTimer.Start();
            }

            currentFileHash = calcMd5OfOpenFile();

            byte[] decrypted = cr.decryptFile(path);
            rawDecrypted = decrypted.ToList();

            versionCode = ih.resolveEncodedData(decrypted[0], decrypted[1]);

            if (versionCode > 512)
            {
                throw new Exception("Invalid PLR header data");
            }

            int startpos = 25;

            int nameLen = decrypted[startpos - 1];

            StringBuilder nameBuild = new StringBuilder();

            for (int i = startpos; i < startpos + nameLen; i++)
            {
                nameBuild.Append(Encoding.ASCII.GetString(new byte[] { decrypted[i] }));
            }

            nameEndOffset = startpos + nameLen;

            playerMode = (gamemodes.gamemode)decrypted[nameEndOffset];

            playerName = nameBuild.ToString();

            tbName.Text = playerName;

            if (versionCode < 230)
            {
                inventoryOffset = 211;
                coinOffset      = 711;
            }
            else
            {
                inventoryOffset = 213;
                coinOffset      = 713;
            }

            int InvDataBeginOffset = nameEndOffset + inventoryOffset;
            int InvDataEndOffset   = InvDataBeginOffset + 500;

            int extCounter = 0;

            List <int> invTmp = new List <int> {
            };

            for (int i = InvDataBeginOffset; i < InvDataEndOffset; i++)
            {
                extCounter++;
                invTmp.Add(decrypted[i]);
                if (extCounter == 10)
                {
                    invItem iv = new invItem(invTmp, ih);
                    inventory.Add(iv);
                    debugInvData.Add(invTmp);
                    invTmp     = new List <int> {
                    };
                    extCounter = 0;
                }
            }

            int CoinDataBeginOffset = nameEndOffset + coinOffset;
            int CoinDataEndOffset   = CoinDataBeginOffset + 80;

            extCounter = 0;

            List <int> coinTmp = new List <int> {
            };

            for (int i = CoinDataBeginOffset; i < CoinDataEndOffset; i++)
            {
                extCounter++;
                coinTmp.Add(decrypted[i]);
                if (extCounter == 10)
                {
                    Console.WriteLine(string.Join(",", coinTmp));
                    invItem iv = new invItem(coinTmp, ih);
                    inventory.Add(iv);
                    debugInvData.Add(coinTmp);
                    coinTmp    = new List <int> {
                    };
                    extCounter = 0;
                }
            }

            int        ColourDataBeginOffset = nameEndOffset + 40;
            int        ColourDataEndOffset   = ColourDataBeginOffset + 21;
            List <int> colTmp = new List <int> {
            };

            for (int i = ColourDataBeginOffset; i < ColourDataEndOffset; i++)
            {
                extCounter++;
                colTmp.Add(decrypted[i]);
                if (extCounter == 3)
                {
                    Color col = Color.FromArgb(colTmp[0], colTmp[1], colTmp[2]);
                    playerColours.Add(col);
                    colTmp     = new List <int> {
                    };
                    extCounter = 0;
                }
            }

            hairPnl.BackColor       = playerColours[0];
            skinPnl.BackColor       = playerColours[1];
            eyesPnl.BackColor       = playerColours[2];
            shirtPnl.BackColor      = playerColours[3];
            undershirtPnl.BackColor = playerColours[4];
            pantsPnl.BackColor      = playerColours[5];
            shoesPnl.BackColor      = playerColours[6];

            int        HealthDataBeginOffset = nameEndOffset + 18;
            int        HealthDataEndOffset   = HealthDataBeginOffset + 8;
            List <int> helTmp = new List <int> {
            };

            for (int i = HealthDataBeginOffset; i < HealthDataEndOffset; i++)
            {
                extCounter++;
                helTmp.Add(decrypted[i]);
                if (extCounter == 4)
                {
                    int tmpHelth = ih.resolveEncodedData(helTmp[0], helTmp[1]);
                    playerHealth.Add(tmpHelth);
                    helTmp     = new List <int> {
                    };
                    extCounter = 0;
                }
            }

            nudHealthCur.Value = playerHealth[0];
            nudHealthMax.Value = playerHealth[1];

            int        ManaDataBeginOffset = nameEndOffset + 26;
            int        ManaDataEndOffset   = ManaDataBeginOffset + 8;
            List <int> manTmp = new List <int> {
            };

            for (int i = ManaDataBeginOffset; i < ManaDataEndOffset; i++)
            {
                extCounter++;
                manTmp.Add(decrypted[i]);
                if (extCounter == 4)
                {
                    int tmpMan = ih.resolveEncodedData(manTmp[0], manTmp[1]);
                    playerMana.Add(tmpMan);
                    manTmp     = new List <int> {
                    };
                    extCounter = 0;
                }
            }

            nudManaCur.Value = playerMana[0];
            nudManaMax.Value = playerMana[1];
        }
Exemplo n.º 2
0
        private void entry_kDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F1)
            {
                about ab = new about();
                ab.ShowDialog();
            }
            if (e.KeyCode == Keys.F2)
            {
                Settings st = new Settings(useOverwriteFile, useAutoReloadFile);
                if (st.ShowDialog() == DialogResult.OK)
                {
                    useOverwriteFile  = st.useOverwriteFile;
                    useAutoReloadFile = st.useAutoReloadFile;

                    if (useAutoReloadFile)
                    {
                        if (lastReadPlrPath != "")
                        {
                            autoFunctionTimer.Start();
                        }
                    }
                    else
                    {
                        autoFunctionTimer.Stop();
                    }
                }
            }
            if (e.KeyCode == Keys.F3)
            {
                hexView hx = new hexView(debugInvData, rawDecrypted.ToArray(), nameEndOffset, versionCode);
                hx.ShowDialog();
            }
            if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control)
            {
                copyBuffer = inventory[invSelectedIndex];
                copyIndex  = invSelectedIndex;
                updateInvDisplay();
            }
            if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control)
            {
                if (copyBuffer != null)
                {
                    cbItem.SelectedItem     = copyBuffer.item.name;
                    cbPrefixes.SelectedItem = copyBuffer.prefix.name;
                    nudQuant.Value          = copyBuffer.quantity;
                    updateInvDisplay();
                }
            }
            if (e.KeyCode == Keys.Escape)
            {
                copyIndex  = -1;
                copyBuffer = null;
                updateInvDisplay();
            }
            if (e.KeyCode == Keys.Delete)
            {
                cbItem.SelectedItem      = "Empty";
                cbPrefixes.SelectedIndex = 0;
                nudQuant.Value           = 0;
            }
        }
Exemplo n.º 3
0
        public void loadData(string path)
        {
            if (useAutoReloadFile)
            {
                autoFunctionTimer.Start();
            }

            currentFileHash = calcMd5OfOpenFile();

            byte[] decrypted = cr.decryptFile(path);
            rawDecrypted = decrypted.ToList();

            versionCode = ih.resolveEncodedData(decrypted[0], decrypted[1]);

            if (versionCode > 512)
            {
                throw new Exception("Invalid PLR header data");
            }

            byte[] printables = new byte[] { 0x27, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x5c, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e };
            int    startpos   = 25;

            StringBuilder nameBuild = new StringBuilder();

            for (int i = startpos; i < 51; i++)
            {
                if (printables.Contains(decrypted[i]))
                {
                    nameBuild.Append(Encoding.ASCII.GetString(new byte[] { decrypted[i] }));
                }
                else
                {
                    nameEndOffset = i;
                    break;
                }
            }

            playerMode = (gamemodes.gamemode)decrypted[nameEndOffset];


            playerName = nameBuild.ToString();

            tbName.Text = playerName;

            if (versionCode < 230)
            {
                inventoryOffset = 211;
            }
            else
            {
                inventoryOffset = 213;
            }

            int InvDataBeginOffset = nameEndOffset + inventoryOffset;
            int InvDataEndOffset   = InvDataBeginOffset + 500;

            int extCounter = 0;

            List <int> invTmp = new List <int> {
            };

            for (int i = InvDataBeginOffset; i < InvDataEndOffset; i++)
            {
                extCounter++;
                invTmp.Add(decrypted[i]);
                if (extCounter == 10)
                {
                    invItem iv = new invItem(invTmp, ih);
                    inventory.Add(iv);
                    debugInvData.Add(invTmp);
                    invTmp     = new List <int> {
                    };
                    extCounter = 0;
                }
            }

            int        ColourDataBeginOffset = nameEndOffset + 40;
            int        ColourDataEndOffset   = ColourDataBeginOffset + 21;
            List <int> colTmp = new List <int> {
            };

            for (int i = ColourDataBeginOffset; i < ColourDataEndOffset; i++)
            {
                extCounter++;
                colTmp.Add(decrypted[i]);
                if (extCounter == 3)
                {
                    Color col = Color.FromArgb(colTmp[0], colTmp[1], colTmp[2]);
                    playerColours.Add(col);
                    colTmp     = new List <int> {
                    };
                    extCounter = 0;
                }
            }

            hairPnl.BackColor       = playerColours[0];
            skinPnl.BackColor       = playerColours[1];
            eyesPnl.BackColor       = playerColours[2];
            shirtPnl.BackColor      = playerColours[3];
            undershirtPnl.BackColor = playerColours[4];
            pantsPnl.BackColor      = playerColours[5];
            shoesPnl.BackColor      = playerColours[6];

            int        HealthDataBeginOffset = nameEndOffset + 18;
            int        HealthDataEndOffset   = HealthDataBeginOffset + 8;
            List <int> helTmp = new List <int> {
            };

            for (int i = HealthDataBeginOffset; i < HealthDataEndOffset; i++)
            {
                extCounter++;
                helTmp.Add(decrypted[i]);
                if (extCounter == 4)
                {
                    int tmpHelth = ih.resolveEncodedData(helTmp[0], helTmp[1]);
                    playerHealth.Add(tmpHelth);
                    helTmp     = new List <int> {
                    };
                    extCounter = 0;
                }
            }

            nudHealthCur.Value = playerHealth[0];
            nudHealthMax.Value = playerHealth[1];

            int        ManaDataBeginOffset = nameEndOffset + 26;
            int        ManaDataEndOffset   = ManaDataBeginOffset + 8;
            List <int> manTmp = new List <int> {
            };

            for (int i = ManaDataBeginOffset; i < ManaDataEndOffset; i++)
            {
                extCounter++;
                manTmp.Add(decrypted[i]);
                if (extCounter == 4)
                {
                    int tmpMan = ih.resolveEncodedData(manTmp[0], manTmp[1]);
                    playerMana.Add(tmpMan);
                    manTmp     = new List <int> {
                    };
                    extCounter = 0;
                }
            }

            nudManaCur.Value = playerMana[0];
            nudManaMax.Value = playerMana[1];
        }