Exemple #1
0
        public static bool WriteCapsule(int Index, STRUCT_CAPSULE Seal)
        {
            try
            {
                string CorrectPatch = "./DataBase/Selo_da_Alma/" + Index + ".json";
                if (File.Exists(CorrectPatch))
                {
                    return(false);
                }


                using (StreamWriter file = File.CreateText(CorrectPatch))
                {
                    string indented = JsonConvert.SerializeObject(Seal, Formatting.Indented);
                    file.Write(indented);
                }

                W2Log.Write(String.Format("read seal sucess: {0}", Index), ELogType.GAME_EVENT);
            }
            catch (Exception e)
            {
                W2Log.Write(String.Format("read seal fail {0}", e.Message), ELogType.GAME_EVENT);
                return(false);
            }
            return(true);
        }
Exemple #2
0
        //Process Capsule (Envia o Selo da Alma para a TMSRV)
        public static DBResult Exec_MSG_DBCapsuleInfo(DBController gs, pServer GameServer)
        {
            _MSG_SIGNALPARM sm = W2Marshal.GetStructure <_MSG_SIGNALPARM>(GameServer.RecvPacket.RawBuffer);

            ConfigServer.ReadConfigFile(gs.Config);

            int Index = sm.parm;


            STRUCT_CAPSULE file = new STRUCT_CAPSULE();

            if (!Functions.ReadCapsule(Index, out file))
            {
                W2Log.Write($"Exec_MSG_DBCapsuleInfo error read capsule index: {Index}");
                return(DBResult.NO_ERROR);
            }

            MSG_CNFDBCapsuleInfo p = W2Marshal.CreatePacket <MSG_CNFDBCapsuleInfo>(BaseDef._MSG_CNFDBCapsuleInfo, sm.Header.ClientId);


            p.Index = Index;

            p.Capsule.Read        = 1;
            p.Capsule.MortalClass = file.Mob.Class;
            p.Capsule.ClassCele   = file.Extra.SaveCelestial.Class;
            p.Capsule.SubClass    = file.Mob.Class;
            p.Capsule.LevelCele   = file.Extra.SaveCelestial.BaseScore.Level;
            p.Capsule.LevelSub    = file.Mob.BaseScore.Level;

            p.Capsule.For = file.Mob.BaseScore.Str;
            p.Capsule.Int = file.Mob.BaseScore.Int;
            p.Capsule.Dex = file.Mob.BaseScore.Dex;
            p.Capsule.Con = file.Mob.BaseScore.Con;

            p.Capsule.ScoreBonus = file.Mob.ScoreBonus;
            p.Capsule.SkillPoint = file.Mob.SkillBonus;

            p.Capsule.ArchQuest      = file.Extra.Arch.Cristal;
            p.Capsule.CelestialQuest = file.Extra.Celestial.Reset;
            p.Capsule.ArcanaQuest    = file.Extra.Circle;


            gs.Server.SendPacket(p);

            W2Log.Write($"error read capsule index: {Index}");
            return(DBResult.NO_ERROR);
        }
Exemple #3
0
 public static bool ReadCapsule(int Index, out STRUCT_CAPSULE Seal)
 {
     Seal = STRUCT_CAPSULE.Empty();
     try
     {
         string CorrectPatch = "./DataBase/Selo_da_Alma/" + Index + ".json";
         if (!File.Exists(CorrectPatch))
         {
             return(false);
         }
         using (StreamReader r = new StreamReader(CorrectPatch))
         {
             string json = r.ReadToEnd();
             Seal = JsonConvert.DeserializeObject <STRUCT_CAPSULE>(json);
         }
         W2Log.Write(String.Format("read seal sucess: {0}", Index), ELogType.GAME_EVENT);
     }
     catch (Exception e)
     {
         W2Log.Write(String.Format("read seal fail {0}", e.Message), ELogType.GAME_EVENT);
         return(false);
     }
     return(true);
 }
Exemple #4
0
        //Process PutCapsule (Cria o Selo da Alma e Apaga o Char)
        public static DBResult Exec_MSG_DBPutInCapsule(DBController gs, pServer GameServer)
        {
            _MSG_SIGNALPARM sm = W2Marshal.GetStructure <_MSG_SIGNALPARM>(GameServer.RecvPacket.RawBuffer);

            ConfigServer.ReadConfigFile(gs.Config);

            int Slot = sm.parm;

            int Idx = gs.GetIndex(sm.Header.ClientId);

            if (Slot < 0 || Slot >= 4)
            {
                W2Log.Write($"err,putincapsule slot out of range - {gs.AccountList[Idx].Account.Info.AccountName}");

                return(DBResult.NO_ERROR);
            }



            gs.Config.LastCapsule++;

            MItem Cap = MItem.Empty();


            Cap.Index            = 3443;
            Cap.Effects[0].Code  = 59;
            Cap.Effects[0].Value = (byte)(gs.Config.LastCapsule / 256);
            Cap.Effects[1].Code  = 59;
            Cap.Effects[1].Value = (byte)gs.Config.LastCapsule;
            Cap.Effects[2].Code  = 59;
            Cap.Effects[2].Value = 0;
            short Face = gs.AccountList[Idx].Account.Mob[Slot].Equip.Items[0].Index;

            if ((Face % 10) >= 6 && (gs.AccountList[Idx].Account.Mob[Slot].LearnedSkill & 0x40000000) != 0)
            {
                Cap.Effects[3].Value = 1;
            }



            STRUCT_CAPSULE File = STRUCT_CAPSULE.Empty();

            //Sava a capsule
            File.Mob   = gs.AccountList[Idx].Account.Mob[Slot];
            File.Extra = gs.AccountList[Idx].Account.MobExtra[Slot];
            File.Extra.Arch.MortalSlot = -1;

            if (!Functions.WriteCapsule(gs.Config.LastCapsule, File))
            {
                W2Log.Write($"fail putchar in capsule [{gs.AccountList[Idx].Account.Info.AccountName}]");
                return(DBResult.NO_ERROR);
            }
            W2Log.Write($"putchar in capsule [{gs.AccountList[Idx].Account.Info.AccountName}]");
            ConfigServer.saveConfig(gs.Config);


            //Apaga o char do q fez a capsule

            gs.AccountList[Idx].Account.Mob[Slot]      = STRUCT_MOB.ClearProperty();
            gs.AccountList[Idx].Account.MobExtra[Slot] = new STRUCT_MOBEXTRA();
            gs.AccountList[Idx].Account.Skillbar[Slot] = STRUCT_SKILLBAR.Clear();
            for (int i = 0; i < 32; i++)
            {
                gs.AccountList[Idx].Account.Affects[Slot].Affects[i] = STRUCT_AFFECT.Clear();
            }
            bool ret = gs.SaveAccount(sm.Header.ClientId);

            if (ret == false)
            {
                W2Log.Write(string.Format("err,putchar in capsule fail - save account - {0}", Idx), ELogType.GAME_EVENT);
                gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBNewCharacterFail);
                return(DBResult.NO_ERROR);
            }

            gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBCNFCapsuleSucess);



            MSG_CNFNewCharacter answer = W2Marshal.CreatePacket <MSG_CNFNewCharacter>(BaseDef._MSG_DBCNFDeleteCharacter, sm.Header.ClientId);

            for (int i = 0; i < GameBasics.MAXL_ACC_MOB; i++)
            {
                unsafe
                {
                    answer.SelChar.Coin[i] = gs.AccountList[Idx].Account.Mob[i].Coin;
                    for (int x = 0; x < GameBasics.MAXL_EQUIP; x++)
                    {
                        if (x == 0)
                        {
                            int Faces = answer.SelChar.Equip[i].Items[x].Index;
                            if (Faces == 22 || Faces == 23 || Faces == 24 || Faces == 25 || Faces == 32)
                            {
                                Faces = gs.AccountList[Idx].Account.MobExtra[i].ClassMaster == 0 ? 21 : (ushort)gs.AccountList[Idx].Account.MobExtra[i].MortalFace + 7;
                            }

                            answer.SelChar.Equip[i].Items[x].Index            = (short)Faces;
                            answer.SelChar.Equip[i].Items[x].Effects[0].Code  = 43;
                            answer.SelChar.Equip[i].Items[x].Effects[0].Value = 0;
                            answer.SelChar.Equip[i].Items[x].Effects[1].Code  = 86;
                            answer.SelChar.Equip[i].Items[x].Effects[1].Value = Functions.GetClassType(gs.AccountList[Idx].Account.Mob[i]);
                            answer.SelChar.Equip[i].Items[x].Effects[2].Code  = 28;
                            answer.SelChar.Equip[i].Items[x].Effects[2].Value = (byte)gs.AccountList[Idx].Account.MobExtra[i].Citizen;
                        }



                        answer.SelChar.Equip[i].Items[x] = gs.AccountList[Idx].Account.Mob[i].Equip.Items[x];
                    }

                    answer.SelChar.Exp[i]        = (int)gs.AccountList[Idx].Account.Mob[i].Exp;
                    answer.SelChar.Guild[i]      = gs.AccountList[Idx].Account.Mob[i].Guild;
                    answer.SelChar.Name[i].Value = gs.AccountList[Idx].Account.Mob[i].Name;
                    answer.SelChar.Score[i]      = gs.AccountList[Idx].Account.Mob[i].BaseScore;
                    answer.SelChar.SPosX[i]      = gs.AccountList[Idx].Account.Mob[i].SPX;
                    answer.SelChar.SPosY[i]      = gs.AccountList[Idx].Account.Mob[i].SPY;
                }
            }
            gs.Server.SendPacket(answer);


            Functions.CreateImportItem(gs.AccountList[Idx].Account.Info.AccountName, Cap, 0, true);


            W2Log.Write($"sucess putchar in capsule [{gs.AccountList[Idx].Account.Info.AccountName}]");
            return(DBResult.NO_ERROR);
        }
Exemple #5
0
        //Process OutCapsule (Apaga o Selo da Alma e Cria o Char)
        public static DBResult Exec_MSG_DBOutCapsule(DBController gs, pServer GameServer)
        {
            MSG_DBOutCapsule sm = W2Marshal.GetStructure <MSG_DBOutCapsule>(GameServer.RecvPacket.RawBuffer);

            int Slot     = sm.Slot;
            int NovoSlot = -1;
            int Idx      = gs.GetIndex(sm.Header.ClientId);

            if (Slot < 0 || Slot >= 4)
            {
                W2Log.Write($"err,outcapsule  slot out of range: {gs.AccountList[Idx].Account.Info.AccountName}");
                return(DBResult.NO_ERROR);
            }

            for (int i = 0; i < 4; i++)
            {
                if (String.IsNullOrEmpty(gs.AccountList[Idx].Account.Mob[i].Name))
                {
                    NovoSlot = i;
                    break;
                }
            }

            if (NovoSlot < 0 || NovoSlot >= 4)
            {
                W2Log.Write($"err,newcharcapsule  slot out of range: {NovoSlot} - {gs.AccountList[Idx].Account.Info.AccountName}");
                gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBCNFCapsuleCharacterFail);
                return(DBResult.NO_ERROR);;
            }

            bool ret = gs.CreateChar(sm.Name, gs.AccountList[Idx].Account.Info.AccountName);

            if (ret == false)
            {
                gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBCNFCapsuleCharacterFail2);
                return(DBResult.NO_ERROR);
            }

            MItem item = gs.AccountList[Idx].GetItemPointer(sm.SourType, sm.SourPos);

            int index = item.Effects[0].Value * 256 + item.Effects[1].Value;

            STRUCT_CAPSULE file = new STRUCT_CAPSULE();

            if (!Functions.ReadCapsule(index, out file))
            {
                W2Log.Write($"Exec_MSG_DBOutCapsule error read capsule index: {index}");
                return(DBResult.NO_ERROR);
            }

            STRUCT_MOB mob = gs.AccountList[Idx].Account.Mob[NovoSlot];

            if (!String.IsNullOrEmpty(mob.Name))
            {
                gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBNewCharacterFail);

                W2Log.Write($"err,newchar already charged: { gs.AccountList[Idx].Account.Info.AccountName} / {mob.Name}");

                return(DBResult.NO_ERROR);
            }

            gs.AccountList[Idx].Account.Mob[NovoSlot]      = file.Mob;
            gs.AccountList[Idx].Account.MobExtra[NovoSlot] = file.Extra;

            for (int i = 0; i < 32; i++)
            {
                gs.AccountList[Idx].Account.Affects[NovoSlot].Affects[i] = STRUCT_AFFECT.Clear();
            }

            ret = gs.SaveAccount(sm.Header.ClientId);
            if (ret == false)
            {
                gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBNewCharacterFail);

                W2Log.Write($"err,newchar fail - create file: {sm.Name}");

                return(DBResult.NO_ERROR);
            }


            MSG_CNFNewCharacter answer = W2Marshal.CreatePacket <MSG_CNFNewCharacter>(BaseDef._MSG_DBCNFNewCharacter, sm.Header.ClientId);

            for (int i = 0; i < GameBasics.MAXL_ACC_MOB; i++)
            {
                unsafe
                {
                    answer.SelChar.Coin[i] = gs.AccountList[Idx].Account.Mob[i].Coin;
                    for (int x = 0; x < GameBasics.MAXL_EQUIP; x++)
                    {
                        if (x == 0)
                        {
                            int Face = answer.SelChar.Equip[i].Items[x].Index;
                            if (Face == 22 || Face == 23 || Face == 24 || Face == 25 || Face == 32)
                            {
                                Face = gs.AccountList[Idx].Account.MobExtra[i].ClassMaster == 0 ? 21 : (ushort)gs.AccountList[Idx].Account.MobExtra[i].MortalFace + 7;
                            }

                            answer.SelChar.Equip[i].Items[x].Index            = (short)Face;
                            answer.SelChar.Equip[i].Items[x].Effects[0].Code  = 43;
                            answer.SelChar.Equip[i].Items[x].Effects[0].Value = 0;
                            answer.SelChar.Equip[i].Items[x].Effects[1].Code  = 86;
                            answer.SelChar.Equip[i].Items[x].Effects[1].Value = Functions.GetClassType(gs.AccountList[Idx].Account.Mob[i]);
                            answer.SelChar.Equip[i].Items[x].Effects[2].Code  = 28;
                            answer.SelChar.Equip[i].Items[x].Effects[2].Value = (byte)gs.AccountList[Idx].Account.MobExtra[i].Citizen;
                        }



                        answer.SelChar.Equip[i].Items[x] = gs.AccountList[Idx].Account.Mob[i].Equip.Items[x];
                    }

                    answer.SelChar.Exp[i]        = (int)gs.AccountList[Idx].Account.Mob[i].Exp;
                    answer.SelChar.Guild[i]      = gs.AccountList[Idx].Account.Mob[i].Guild;
                    answer.SelChar.Name[i].Value = gs.AccountList[Idx].Account.Mob[i].Name;
                    answer.SelChar.Score[i]      = gs.AccountList[Idx].Account.Mob[i].BaseScore;
                    answer.SelChar.SPosX[i]      = gs.AccountList[Idx].Account.Mob[i].SPX;
                    answer.SelChar.SPosY[i]      = gs.AccountList[Idx].Account.Mob[i].SPY;
                }
            }

            gs.Server.SendPacket(answer);
            return(DBResult.NO_ERROR);
        }