public AccountOBJ GetAccount(AccountOBJ entity, bool AutoCreate = false) { IDbEntity that = Get(entity); if (that != null) { return((AccountOBJ)that); } CHeck(); Users usr = session.QueryOver <Users>().Where(x => x.UserName == entity.Username).List().FirstOrDefault(); if (usr != null) { AccountOBJ account = GetAccountFromDB(usr.UserName); ENTITY.Add(account.GetId(), account); return(account); } else { if (AutoCreate) { AccountOBJ user = new AccountOBJ((Users)entity.GetEntity()); using (ITransaction transaction = session.BeginTransaction()) { user.Id = (uint)session.Save(user.GetEntity()); transaction.Commit(); } return(GetAccount(user)); } } return(null); }
private void StartNow(List <MatchPlayer> m_players, Server server) { LastStartTime = JHSTime.Time; if (DbManager == null) { DbManager = AccountManager.Instance; } for (int i = 0; i < m_players.Count; i++) { MatchPlayer parti = m_players[i]; if (parti != null) { AccountOBJ user = DbManager.GetOnlineByConnectionId(parti.ConnectionId); if (user != null && user.InQueue && user.IsOnline) { lock (user) user.InQueue = false; JHSNetworkServer.Send(user.connectionID, NetworkConstants.START_SEARCH_MATCH, new SearchMatch() { op = Enums.SearchMatchOperations.START, IP = server.IP, port = server.port }); } } } }
private IDbEntity Get(AccountOBJ entity) { if (ENTITY.TryGetValue(entity.GetId(), out IDbEntity Entity)) { return(Entity); } return(null); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } if (rankingManager == null) { rankingManager = RankingManager.Instance; } Empty packet = netMsg.ReadMessage <Empty>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ account = DbManager.GetOnlineByConnectionId(connectionId); if (account != null) { if (account.RankRequestTime > JHSTime.Time) { netMsg.conn.Send(NetworkConstants.UPDATE_RANKINGS, new RankingPacket() { PayLoadType = RankingPacketType.ERROR }); return(true); } account.RankRequestTime = JHSTime.Time + Settings.CAN_REQUEST_RANK_UPDATE_TIME; RankinngOBJ rankings = rankingManager._GetPlayer(account); if (rankings != null) { if (rankings.GameCount < Settings.MIN_GAMES_TO_DECIDE_RANKING_SKILLS) { netMsg.conn.Send(NetworkConstants.UPDATE_RANKINGS, new RankingPacket() { GameCount = rankings.GameCount < Settings.MIN_GAMES_TO_DECIDE_RANKING_SKILLS ? (byte)(Settings.MIN_GAMES_TO_DECIDE_RANKING_SKILLS - rankings.GameCount) : (byte)0, PayLoadType = RankingPacketType.GAME_COUNT, }); return(true); } LeagueData[] data = rankingManager._GetLegue(rankings.League); netMsg.conn.Send(NetworkConstants.UPDATE_RANKINGS, new RankingPacket() { CurrentLeague = rankings.League, GameCount = (byte)rankings.GameCount, LeaguePosition = (byte)(rankings.RankNo > 100 ? 255: rankings.RankNo), PayLoadType = RankingPacketType.UPDATE_DATA, rankingData = data, LeaguePoints = (uint)rankings.LeaguePoints }); } } } return(true); }
private AccountOBJ CreateAccount(GWLoginPacket packet) { AccountOBJ user = new AccountOBJ() { Username = packet.LoginName, Password = (packet.LoginName + packet.Password).GetPassword(), PlayerName = "Test", Email = "EEEE", CreateTime = DateTime.Now }; return(user); }
public void OnDisconnect(JHSNetworkMessage netMsg) { AccountOBJ user = DbManager.GetOnlineByConnectionId(netMsg.conn.connectionId); if (user != null) { lock (user) { user.OnLogout(); DbManager.RemoveOnline(netMsg.conn.connectionId); user.InQueue = false; } } queueManager.RemoveServer(netMsg.conn.connectionId); }
public RankinngOBJ _GetPlayer(AccountOBJ user) { if (KnownPlayers.TryGetValue(user.Id, out RankinngOBJ obj)) { return(obj); } else { RankinngOBJ objx = dbService.GetRankinData(new RankinngOBJ(user.Id, user.PlayerName)); if (objx != null) { KnownPlayers.Add(objx.UserId, objx); leagueManager._AddPlayer(objx.RefLeagueData); return(objx); } } return(null); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } Empty packet = netMsg.ReadMessage <Empty>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ account = DbManager.GetOnlineByConnectionId(connectionId); if (account != null) { netMsg.conn.Send(NetworkConstants.REFRESH_ACTIVES, new RefreshActives() { actives = account.SerializeActives() }); } } return(true); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } GWLoginPacket packet = netMsg.ReadMessage <GWLoginPacket>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ user = DbManager.GetAccountFromDbByUserName(packet.LoginName); if (user != null) { lock (user) { string userName = user.Username; if (userName.VerifyPassword(user.Password, packet.Password)) { //RESPONSE LOGIC lock (user) { user.connectionID = connectionId; user.LoginTime = DateTime.Now; user.LastKnownIp = user.Ip; user.Ip = netMsg.conn.IP; user.OnLogin(); DbService.SubmitUpdate2Queue(user); } // RankinData ranking = rankingManager.GetUser(user); GWLoginResponsePacket dat = new GWLoginResponsePacket { actives = user.GetActiveCompleate(), characters = user.SerializeChars(), RESPONSE = SUCCESS, League = user.League, LeaguePosition = user.LeaguePosition, LEGUE_STATUS = user.LegueStatus, PlayerNick = user.PlayerName, Gold = (uint)user.Gold, Silver = (uint)user.Silver, Priviledge = (byte)user.Priviledge, LoginTocken = user.Id, LEVEL = (uint)user.Data.Level, EXP = (uint)user.Data.Exp, IsPushLevelUp = user.LevelUpNotify, SEASON = (byte)Settings.RANKING_SEASON, GameCount = user.GameCount < Settings.MIN_GAMES_TO_DECIDE_RANKING_SKILLS ? (byte)(Settings.MIN_GAMES_TO_DECIDE_RANKING_SKILLS - user.GameCount) : (byte)0 }; DbManager.RegisterOnline(connectionId, user); JHSNetworkServer.Send(connectionId, NetworkConstants.LOGIN, dat); } else { JHSNetworkServer.Send(connectionId, NetworkConstants.LOGIN, new GWLoginResponsePacket() { RESPONSE = WRONG_PASSWORD_OR_LOGIN }); } } } else { if (Settings.AutoCreate) { user = CreateAccount(packet); lock (user) { user.connectionID = connectionId; user.LoginTime = DateTime.Now; user.LastKnownIp = user.Ip; user.Ip = netMsg.conn.IP; user.OnLogin(); DbService.UpdateEntityIntime(user); } user = DbManager.GetAccountFromDbByUserName(packet.LoginName); if (user != null) { GWLoginResponsePacket dat = new GWLoginResponsePacket { actives = user.GetActiveCompleate(), characters = user.SerializeChars(), RESPONSE = SUCCESS, League = user.League, LeaguePosition = user.LeaguePosition, LEGUE_STATUS = user.LegueStatus, PlayerNick = user.PlayerName, Gold = (uint)user.Gold, Silver = (uint)user.Silver, Priviledge = (byte)user.Priviledge, LoginTocken = user.Id, LEVEL = (uint)user.Data.Level, EXP = (uint)user.Data.Exp, IsPushLevelUp = user.LevelUpNotify, SEASON = (byte)Settings.RANKING_SEASON, GameCount = user.GameCount < 5 ? (byte)(5 - user.GameCount) : (byte)0 }; DbManager.RegisterOnline(connectionId, user); JHSNetworkServer.Send(connectionId, NetworkConstants.LOGIN, dat); } } else { JHSNetworkServer.Send(connectionId, NetworkConstants.LOGIN, new GWLoginResponsePacket() { RESPONSE = USER_NOT_FOUND }); } } } return(true); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } ConsoleCMD packet = netMsg.ReadMessage <ConsoleCMD>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ account = DbManager.GetOnlineByConnectionId(connectionId); if (account != null) { if (account.Priviledge > 1) { switch ((GMCOMMAND)packet.Command) { case GMCOMMAND.ADD_GOLD: account.Gold += (int)packet.Value; netMsg.conn.Send(NetworkConstants.EXCHANGE, new ExchangeCurResp() { STATUS = 0, SilverValue = (uint)account.Silver, GoldValue = (uint)account.Gold }); break; case GMCOMMAND.ADD_SILVER: account.Silver += (int)packet.Value; netMsg.conn.Send(NetworkConstants.EXCHANGE, new ExchangeCurResp() { STATUS = 0, SilverValue = (uint)account.Silver, GoldValue = (uint)account.Gold }); break; case GMCOMMAND.FINISH_ACTIVES: if (packet.Value == 1) { ActivesConfig[] allConfig = ConfigManager.GetActives(); for (int i = 0; i < allConfig.Length; i++) { ActivesOBJ active = account.GetActive(allConfig[i].ActiveId); if (active != null) { active.Value = (int)allConfig[i].Conditions; active.Collected = false; DbService.SubmitUpdate2Queue(active); } } netMsg.conn.Send(NetworkConstants.REFRESH_ACTIVES, new RefreshActives() { actives = account.SerializeActives() }); } else { ActivesConfig[] allConfig = ConfigManager.GetActives(); for (int i = 0; i < allConfig.Length; i++) { ActivesOBJ active = account.GetActive(allConfig[i].ActiveId); if (active != null) { active.Value = 0; active.Collected = false; DbService.SubmitUpdate2Queue(active); } } netMsg.conn.Send(NetworkConstants.REFRESH_ACTIVES, new RefreshActives() { actives = account.SerializeActives() }); } break; } } } } return(true); }
public AccountOBJ GetAccountFromDB(string username) { CHeck(); AccountOBJ account = null; Users usr = session.QueryOver <Users>().Where(x => x.UserName == username).List().FirstOrDefault(); if (usr != null) { account = new AccountOBJ(usr); IList <Characters> chars = session.QueryOver <Characters>().Where(x => x.UserId == account.Id).List(); account.Skins = new SortedList <uint, CharacterOBJ>(); for (int c = 0; c < chars.Count; c++) { Characters character = chars[c]; CharacterOBJ objchar = new CharacterOBJ(character); account.Skins.Add(objchar.PlayerId, objchar); } if (chars.Count == 0) { using (ITransaction transaction = session.BeginTransaction()) { short skinId = Settings.randomSkins[new Random().Next(Settings.randomSkins.Length)]; ConfiModel model = ConfigManager.GetModel(skinId); if (model != null) { Characters ccc = new Characters(account.Id, skinId) { SkinColorId = model.SkinColorId, EyeColorId = model.EyeColorId, HairColorId = model.HairColorId, ShirtColorId = model.ShirtColorId, PantsColorId = model.PantsColorId, BootsColorId = model.BootsColorId, GlovesColorId = model.GlovesColorId }; session.Save(ccc); transaction.Commit(); } } chars = session.QueryOver <Characters>().Where(x => x.UserId == account.Id).List(); for (int c = 0; c < chars.Count; c++) { Characters character = chars[c]; CharacterOBJ objchar = new CharacterOBJ(character); account.Skins.Add(objchar.PlayerId, objchar); } } IList <Actives> actives = session.QueryOver <Actives>().Where(x => x.UserId == account.Id).List(); ActivesConfig[] allActives = ConfigManager.GetActives(); if (allActives.Length != actives.Count) { for (int c = 0; c < actives.Count; c++) { Actives active = actives[c]; ActivesOBJ objactive = new ActivesOBJ(active); account.Actives.Add(objactive.ActiveId, objactive); } using (ITransaction transaction = session.BeginTransaction()) { for (int a = 0; a < allActives.Length; a++) { ActivesConfig ac = allActives[a]; if (!account.Actives.ContainsKey(ac.ActiveId)) { Actives active = new Actives { UserId = account.Id, value = 0, ActiveId = ac.ActiveId, collected = false }; session.Save(active); // <-- this ActivesOBJ objactive = new ActivesOBJ(active); account.Actives.Add(objactive.ActiveId, objactive); } } transaction.Commit(); } account.Actives.Clear(); actives = session.QueryOver <Actives>().Where(x => x.UserId == account.Id).List(); for (int c = 0; c < actives.Count; c++) { Actives active = actives[c]; ActivesOBJ objactive = new ActivesOBJ(active); account.Actives.Add(objactive.ActiveId, objactive); } } else { for (int c = 0; c < actives.Count; c++) { Actives active = actives[c]; ActivesOBJ objactive = new ActivesOBJ(active); account.Actives.Add(objactive.ActiveId, objactive); } } } return(account); }
static void Main(string[] args) { float StartTime = JHSTime.Time; Console.Title = "LoginServer"; AppDomain.CurrentDomain.DomainUnload += CleanupBeforeExit; AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); Properties props = new Properties(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs/Config.ini")); Settings.AutoCreate = bool.Parse(props.get("AUTO_CREATE")); Settings.BINDPASSWORD = uint.Parse(props.get("BINDPASSWORD")); Settings.GAMEVERSION = int.Parse(props.get("GAMEVERSION")); Settings.DEBUG_MODE = int.Parse(props.get("DEBUG_MODE")); Settings.MIN_PLAYERS = int.Parse(props.get("MIN_PLAYERS")); Settings.MAX_PLAYERS = int.Parse(props.get("MAX_PLAYERS")); Settings.CHECK_CAN_START = int.Parse(props.get("CHECK_CAN_START")); Settings.MAX_WAIT_TIME = int.Parse(props.get("MAX_WAIT_TIME")); Settings.RANKING_SEASON = int.Parse(props.get("RANKING_SEASON")); Settings.CAN_REQUEST_RANK_UPDATE_TIME = int.Parse(props.get("CAN_REQUEST_RANK_UPDATE_TIME")); Settings.MIN_GAMES_TO_DECIDE_RANKING_SKILLS = int.Parse(props.get("MIN_GAMES_TO_DECIDE_RANKING_SKILLS")); Settings.USE_RANKING_QUEUES = bool.Parse(props.get("USE_RANKING_QUEUES")); Settings.START_WITH_ONE_PLAYER = bool.Parse(props.get("START_WITH_ONE_PLAYER")); Settings.DEBUG_GET_PLAYER = bool.Parse(props.get("ALLOW_NOT_REGISTERED_GET_ROLE_INFO")); LOG.Error("Starting LoginServer"); LOG.Info("Starting LoginServer"); List <short> skins = new List <short>(); string[] d = props.get("DEFAULT_SKIKINS").Split(','); foreach (string str in d) { skins.Add(short.Parse(str)); } Settings.randomSkins = skins.ToArray(); DbService.Instance.Start(); ConfigManager.LoadConfigs(); RankingManager.Init(); NetworkServer.Instance.SetConfig(props); NetworkServer.Instance.InitHandlers(); NetworkServer.Instance.Start(); LOG.Info("Finished loading Server, time-consuming:" + (JHSTime.Time - StartTime) + " sec."); WATIREGION: string line = Console.ReadLine(); if (line == "exit") { goto EXITPROGRAM; } if (line == "aadd") { Console.SetCursorPosition(0, Console.CursorTop - 1); AccountOBJ obj = DbService.Instance.GetAccountFromDB(2); if (obj != null) { RankinngOBJ data = RankingManager.GetPlayer(obj); RankingManager.UpdatePlayer(obj.Id, data.LeaguePoints + 100); } } if (line == "add") { AccountOBJ obj = DbService.Instance.GetAccountFromDB(1); if (obj != null) { Console.SetCursorPosition(0, Console.CursorTop - 1); RankinngOBJ data = RankingManager.GetPlayer(obj); if (data != null) { RankingManager.UpdatePlayer(obj.Id, data.LeaguePoints + 100); } } } if (line == "gamec") { AccountOBJ obj = DbService.Instance.GetAccountFromDB(1); if (obj != null) { Console.SetCursorPosition(0, Console.CursorTop - 1); RankinngOBJ data = RankingManager.GetPlayer(obj); if (data != null) { RankingManager.UpdatePlayer(obj.Id, data.LeaguePoints + 100, data.GameCount + 1, data.Kills + 1, 0); } } } if (line == "add2") { AccountOBJ obj = DbService.Instance.GetAccountFromDB(1); if (obj != null) { Console.SetCursorPosition(0, Console.CursorTop - 1); RankinngOBJ data = RankingManager.GetPlayer(obj); RankingManager.UpdatePlayer(obj.Id, data.LeaguePoints + 1000); } } if (line == "del") { AccountOBJ obj = DbService.Instance.GetAccountFromDB(1); if (obj != null) { Console.SetCursorPosition(0, Console.CursorTop - 1); RankinngOBJ data = RankingManager.GetPlayer(obj); RankingManager.UpdatePlayer(obj.Id, data.LeaguePoints - 100); } } goto WATIREGION; EXITPROGRAM: Console.WriteLine("Saving Database."); if (DbService.Instance.SaveAll()) { Console.WriteLine("Server is now down."); Console.ReadKey(); } }
public static RankinngOBJ GetPlayer(AccountOBJ user) { return(Instance._GetPlayer(user)); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } BuySkin packet = netMsg.ReadMessage <BuySkin>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ user = DbManager.GetOnlineByConnectionId(connectionId); if (user != null) { ConfiModel model = ConfigManager.GetModel((int)packet.ModelId); if (model == null) { netMsg.conn.Send(NetworkConstants.BUYCHARACTER, new BuySkinResponse() { STATUS = ITEM_CONFIG_WRONG }); return(true); } //Silver Buy if (packet.BuyType == 0) { //TO DO CHECK IF CHARACTER ALREADY HAS THE MODEL lock (user) { if (user.Silver < model.SilverPrice) { netMsg.conn.Send(NetworkConstants.BUYCHARACTER, new BuySkinResponse() { STATUS = NOT_ENOUGH_SILVER }); return(true); } Characters ccc = new Characters(user.Id, model.ModelId) { SkinColorId = model.SkinColorId, EyeColorId = model.EyeColorId, HairColorId = model.HairColorId, ShirtColorId = model.ShirtColorId, PantsColorId = model.PantsColorId, BootsColorId = model.BootsColorId, GlovesColorId = model.GlovesColorId }; ccc.PlayerId = DbService.SaveEntity(ccc); CharacterOBJ obj = new CharacterOBJ(ccc); user.Skins.Add(obj.PlayerId, obj); user.ResetNotification(); user.Silver -= model.SilverPrice; DbService.SubmitUpdate2Queue(user); netMsg.conn.Send(NetworkConstants.BUYCHARACTER, new BuySkinResponse() { STATUS = SUCCESS, Gold = (uint)user.Gold, Silver = (uint)user.Silver, character = obj.GetServerChar() }); return(true); } } else // GOLD BUY { //TO DO CHECK IF CHARACTER ALREADY HAS THE MODEL lock (user) { if (user.Gold < model.GoldPrice) { netMsg.conn.Send(NetworkConstants.BUYCHARACTER, new BuySkinResponse() { STATUS = NOT_ENOUGH_GOLD }); return(true); } Characters ccc = new Characters(user.Id, model.ModelId) { SkinColorId = model.SkinColorId, EyeColorId = model.EyeColorId, HairColorId = model.HairColorId, ShirtColorId = model.ShirtColorId, PantsColorId = model.PantsColorId, BootsColorId = model.BootsColorId, GlovesColorId = model.GlovesColorId }; ccc.PlayerId = DbService.SaveEntity(ccc); CharacterOBJ obj = new CharacterOBJ(ccc); user.Skins.Add(obj.PlayerId, obj); user.Gold -= model.GoldPrice; DbService.SubmitUpdate2Queue(user); netMsg.conn.Send(NetworkConstants.BUYCHARACTER, new BuySkinResponse() { STATUS = SUCCESS, Gold = (uint)user.Gold, Silver = (uint)user.Silver, character = obj.GetServerChar() }); return(true); } } } } return(true); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } GWMainMenu packet = netMsg.ReadMessage <GWMainMenu>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; AccountOBJ user = DbManager.GetOnlineByConnectionId(connectionId); if (user != null) { int total = 0; if (packet.SkinColorId_changed) { total += Settings.PRICE_PER_COLOR_CHANGE; } if (packet.HairColorId_changed) { total += Settings.PRICE_PER_COLOR_CHANGE; } if (packet.EyeColorId_changed) { total += Settings.PRICE_PER_COLOR_CHANGE; } if (packet.ShirtColorId_changed) { total += Settings.PRICE_PER_COLOR_CHANGE; } if (packet.PantsColorId_changed) { total += Settings.PRICE_PER_COLOR_CHANGE; } if (packet.BootsColorId_changed) { total += Settings.PRICE_PER_COLOR_CHANGE; } if (packet.GlovesColorId_changed) { total += Settings.PRICE_PER_COLOR_CHANGE; } if (total == 0) { return(true); } lock (user) { if (user.Silver < total) { netMsg.conn.Send(NetworkConstants.BUYCOLORCHANGE, new HeroBuyColorResponse() { STATUS = NOT_ENOUGH_SILVER }); return(true); } CharacterOBJ player = user.GetPlayer(packet.PlayerId); if (packet.SkinColorId_changed) { player.SkinColorId = packet.SkinColorId; } if (packet.HairColorId_changed) { player.HairColorId = packet.HairColorId; } if (packet.EyeColorId_changed) { player.EyeColorId = packet.EyeColorId; } if (packet.ShirtColorId_changed) { player.ShirtColorId = packet.ShirtColorId; } if (packet.PantsColorId_changed) { player.PantsColorId = packet.PantsColorId; } if (packet.BootsColorId_changed) { player.BootsColorId = packet.BootsColorId; } if (packet.GlovesColorId_changed) { player.GlovesColorId = packet.GlovesColorId; } DbService.SubmitUpdate2Queue(player); user.Silver = user.Silver - total; user.ResetNotification(); DbService.SubmitUpdate2Queue(user); HeroBuyColorResponse response = new HeroBuyColorResponse() { STATUS = 255, PlayerId = packet.PlayerId, SkinColorId = packet.SkinColorId, SkinColorId_changed = packet.SkinColorId_changed, HairColorId = packet.HairColorId, HairColorId_changed = packet.HairColorId_changed, EyeColorId = packet.EyeColorId, EyeColorId_changed = packet.EyeColorId_changed, ShirtColorId = packet.ShirtColorId, ShirtColorId_changed = packet.ShirtColorId_changed, PantsColorId = packet.PantsColorId, PantsColorId_changed = packet.PantsColorId_changed, BootsColorId = packet.BootsColorId, BootsColorId_changed = packet.BootsColorId_changed, GlovesColorId = packet.GlovesColorId, GlovesColorId_changed = packet.GlovesColorId_changed, }; response.STATUS = SUCCESS; response.Silver = (uint)user.Silver; netMsg.conn.Send(NetworkConstants.BUYCOLORCHANGE, response); return(true); } } else { netMsg.conn.Send(NetworkConstants.BUYCOLORCHANGE, new HeroBuyColorResponse() { STATUS = USER_NOT_FOUND }); } } return(true); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } if (queueManager == null) { queueManager = GameServerManager.Instance; } if (dbService == null) { dbService = DbService.Instance; } UpdateMatchResult packet = netMsg.ReadMessage <UpdateMatchResult>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; var server = queueManager.GetServerByConnectionId(connectionId); if (server != null) { AccountOBJ user = DbManager.GetOnlineByUserId(packet.UserId); if (user == null) { user = dbService.GetAccountFromDB(packet.UserId); } if (user != null) { lock (user) { foreach (DBPlayerActive active in packet.Actives) { ActivesOBJ obj = user.GetActive((int)active.ActiveId); obj.Value = (int)active.Value; DbService.UpdateEntityIntime(obj); } user.Data.Exp += (int)packet.EXP; RankinngOBJ RankData = RankingManager.GetPlayer(user); if (RankData != null) { RankData.GameCount += 1; RankData.Kills += (int)packet.KillCount; if (!packet.HasWon) { RankData.Deaths += 1; } } user.OnGameResultRecieved(); DbService.UpdateEntityIntime(user); } LOG.Info(string.Format("SaveResult :: Server[{0}] userid[{1}]", connectionId, packet.UserId)); } else { LOG.Info(string.Format("SaveResult Error unknown user :: Server[{0}] userid[{1}]", connectionId, packet.UserId)); } netMsg.conn.Send(GameServerOP.PUTROLE, new Empty()); } } return(true); }
public bool Execute(JHSNetworkMessage netMsg) { if (DbManager == null) { DbManager = AccountManager.Instance; } if (queueManager == null) { queueManager = GameServerManager.Instance; } if (dbService == null) { dbService = DbService.Instance; } ReqeuestUser packet = netMsg.ReadMessage <ReqeuestUser>(); if (packet != null) { uint connectionId = netMsg.conn.connectionId; var server = queueManager.GetServerByConnectionId(connectionId); if (server != null || Settings.DEBUG_GET_PLAYER) { AccountOBJ user = DbManager.GetOnlineByUserId(packet.userId); if (Settings.DEBUG_GET_PLAYER && user == null) { user = dbService.GetAccountFromDB(packet.userId); user.SelectedCharacer = user.FirstRole().PlayerId; } if (user != null) { if (user.SelectedCharacer != 0) { DBPlayer role = user.GetRole(user.SelectedCharacer); if (role != null) { if (packet.Type == InfoType.NONE) { netMsg.conn.Send(GameServerOP.GETROLE, new LoginDataBasePlayer() { STATUS = SUCCESS, player = role, REQ = packet.Req }); } else { netMsg.conn.Send(GameServerOP.GET_ROLE2, new UpdateRole() { STATUS = SUCCESS, player = role, TYPE = packet.Type }); } LOG.Info(string.Format("GETRole :: REQ[{3}] id[{0}] userid[{1}] serverid[{2}]", role.Base.PlayerId, role.Base.UserId, connectionId, packet.Req)); return(true); } } } netMsg.conn.Send(GameServerOP.GETROLE, new LoginDataBasePlayer() { STATUS = PLAYER_NOT_FOUND }); } } return(true); }