//创建军团 public void CreateLegion(LegionInfo info, int player_id) { int legion_id = Data.CreateLegion(info); CreateLegion_Ret ret = new CreateLegion_Ret(); if (legion_id != -1) { ret.ret = 1; } ret.play_id = player_id; ret.legion_id = legion_id; info.id = (uint)legion_id; mDicInfo[info.id] = info; LegionMember member = new LegionMember(); member.money = info.money; member.members_name = info.leader_name; member.rank = GameBase.Config.Define.LEGION_PLACE_JUNTUANZHANG; member.money = info.money; //初始化的贡献度 AddLegionMembers(info.id, member); ret.money = info.money; ret.boss_id = member.id; SessionManager.Instance().SendMapServer(0, ret.GetBuffer()); }
//发送爵位数据到mapserver public void SendData(int mapid = 0) { GUANJUEINFO info = new GUANJUEINFO(); for (int i = 0; i < mListInfo.Count; i++) { info.list_item.Add(mListInfo[i]); } SessionManager.Instance().SendMapServer(mapid, info.GetBuffer()); }
private void UpdateMapServer(int mapid, PayRecInfo info) { PackPayRecInfo pack_info = new PackPayRecInfo(); pack_info.order = info.order; pack_info.account = info.account; pack_info.money = info.money; pack_info.id = info.id; SessionManager.Instance().SendMapServer(mapid, pack_info.GetBuffer()); }
private void ProcessQueryRoleName(byte[] data) { GameBase.Network.Internal.QueryRoleName info = new GameBase.Network.Internal.QueryRoleName(); info.Create(data); QueryRoleName_Ret ret = Data.QueryRoleName(info.name); ret.gameid = info.gameid; SessionManager.Instance().SendMapServer(0, ret.GetBuffer()); }
//发送军团数据给mapserver组 public void SendData(int mapserverid = 0) { LEGIONINFO info = new LEGIONINFO(); foreach (LegionInfo obj in mDicInfo.Values) { info.list_item.Add(obj); } byte[] data = info.GetBuffer(); SessionManager.Instance().SendMapServer(mapserverid, data); }
public void ProcessCreateRole(byte[] data) { GameBase.Network.Internal.CreateRole info = new GameBase.Network.Internal.CreateRole(); info.Create(data); GameBase.Network.Internal.CreateRole_Ret ret = new GameBase.Network.Internal.CreateRole_Ret(); ret.gameid = info.gameid; info.name = Coding.GB2312ToLatin1(info.name); ret.tag = Data.CreateRole(info.accountid, info.name, info.lookface, info.profession, ref ret.playerid); SessionManager.Instance().SendMapServer(0, ret.GetBuffer()); }
//角色信息返回 private void ProcessRoleInfo_Ret(byte[] data) { GameBase.Network.Internal.RoleInfo_Ret ret = new GameBase.Network.Internal.RoleInfo_Ret(); ret.Create(data); Data.SetOnlineState(ret.accountid, 0); //发给loginserver服务器 GameBase.Network.Internal.QueryRole_Ret queryrole_ret = new GameBase.Network.Internal.QueryRole_Ret(); queryrole_ret.gameid = ret.gameid; queryrole_ret.key = ret.key; queryrole_ret.key2 = ret.key2; queryrole_ret.ret = 1; SessionManager.Instance().SendLoginServer(queryrole_ret.GetBuffer()); Log.Instance().WriteLog("通知loginserver登录服务器:" + ret.accountid.ToString()); }
public void ProcessAddRoleData_Item(byte[] data) { GameBase.Network.Internal.AddRoleData_Item info = new GameBase.Network.Internal.AddRoleData_Item(); info.Create(data); uint _key = 0; if (!Data.AddRoleData_Item(info, ref _key)) { Log.Instance().WriteLog("保存角色物品信息失败,角色id:" + info.item.playerid.ToString()); } GameBase.Network.Internal.AddRoleData_Item_Ret ret = new GameBase.Network.Internal.AddRoleData_Item_Ret(); ret.id = _key; ret.gameid = info.gameid; ret.sordid = info.sortid; SessionManager.Instance().SendMapServer(0, ret.GetBuffer()); }
private static void LogicRun() { int processtime = 4; int sleeptime = 4; int nlastProcessTime = System.Environment.TickCount; while (true) { if (System.Environment.TickCount - nlastProcessTime > processtime) { SessionManager.Instance().Run(); //充值信息读取 PayManager.Instance().Run(); nlastProcessTime = System.Environment.TickCount; } System.Threading.Thread.Sleep(sleeptime); } }
public static void OnClose(Socket s) { SessionManager.Instance().RemoveSession(s); }
public static void OnReceive(Socket s, byte[] data, int nSize) { SessionManager.Instance().ReceiveData(s, data, nSize); }
public static void OnConnect(Socket s) { SessionManager.Instance().AddSession(s, mTcpServer); }
private void ProcessQueryRole(byte[] data) { GameBase.Network.Internal.QueryRole info = new GameBase.Network.Internal.QueryRole(); info.Create(data); byte ret = 0; String sAccount = info.GetAccount(); int accountid = Data.QueryAccount(sAccount); //查询数据库是否有该角色-- if (accountid != -1) { ret = 1; //-优先查询是否在线,要是在线就踢掉了-- int mapserverindex = -1; if (Data.IsOnline(sAccount, ref mapserverindex)) { ret = 2; //发送给mapserver踢掉该玩家,因为被挤下线了 GameBase.Network.Internal.KickGamePlay kickplay = new GameBase.Network.Internal.KickGamePlay(); kickplay.accountid = accountid; SessionManager.Instance().SendMapServer(mapserverindex, kickplay.GetBuffer()); //设置该玩家帐号为离线状态 Data.SetOnlineState(accountid, -1); } if (ret == 1) { Log.Instance().WriteLog("查询角色成功:" + sAccount + "id:" + accountid.ToString()); //发送给mapserver服务器 GameBase.Network.Internal.RoleInfo roleinfo = Data.QueryRoleInfo(accountid); roleinfo.gameid = info.gameid; roleinfo.mKey = info.key; roleinfo.mKey1 = info.key2; roleinfo.sAccount = sAccount; SessionManager.Instance().SendMapServer(roleinfo.mapid, roleinfo.GetBuffer()); //如果有角色,读取角色的其他信息 //物品数据 GameBase.Network.Internal.ROLEDATA_ITEM item = new GameBase.Network.Internal.ROLEDATA_ITEM(); item.key = info.key; item.key2 = info.key2; item.playerid = roleinfo.playerid; item.SetLoadTag(); Data.LoadRoleData_Item(item); if (item.mListItem.Count > 0) //没数据就不发了。。 { SessionManager.Instance().SendMapServer(0, item.GetBuffer()); } //技能数据 GameBase.Network.Internal.RoleData_Magic magic = new GameBase.Network.Internal.RoleData_Magic(); magic.SetLoadTag(); magic.ownerid = roleinfo.playerid; magic.key = roleinfo.mKey; magic.key2 = roleinfo.mKey1; Data.LoadRoleData_Magic(magic); if (magic.mListMagic.Count > 0) { SessionManager.Instance().SendMapServer(0, magic.GetBuffer()); } //幻兽数据-- List <RoleData_Item> list_eudemondata = item.GetEudemonItemList(); if (list_eudemondata != null) { GameBase.Network.Internal.ROLEDATE_EUDEMON eudemon = new GameBase.Network.Internal.ROLEDATE_EUDEMON(); eudemon.SetLoadTag(); eudemon.playerid = roleinfo.playerid; eudemon.key = roleinfo.mKey; eudemon.key2 = roleinfo.mKey1; Data.LoadRoleData_Eudemon(eudemon); SessionManager.Instance().SendMapServer(0, eudemon.GetBuffer()); } //好友数据 GameBase.Network.Internal.ROLEDATA_FRIEND friend = new GameBase.Network.Internal.ROLEDATA_FRIEND(); friend.SetLoadTag(); friend.playerid = roleinfo.playerid; friend.key = roleinfo.mKey; friend.key2 = roleinfo.mKey1; Data.LoadRoleData_Friend(friend); SessionManager.Instance().SendMapServer(0, friend.GetBuffer()); } else { Log.Instance().WriteLog("查询角色失败:" + sAccount + "id:" + accountid.ToString()); } } if (ret == 1) { return; //有该角色 } //发送给loginserver服务器-- GameBase.Network.Internal.QueryRole_Ret queryrole_ret = new GameBase.Network.Internal.QueryRole_Ret(); queryrole_ret.gameid = info.gameid; queryrole_ret.key = info.key; queryrole_ret.key2 = info.key2; queryrole_ret.ret = ret; mTcpServer.SendData(mSocket, queryrole_ret.GetBuffer()); }