public static void HandleClientTransferZone(ZoneConnection zc, InterPacket packet) { byte admin, zoneid; int accountid; string username, charname, hostip; ushort randid; if (!packet.TryReadByte(out zoneid) || !packet.TryReadInt(out accountid) || !packet.TryReadString(out username) || !packet.TryReadString(out charname) || !packet.TryReadUShort(out randid) || !packet.TryReadByte(out admin) || !packet.TryReadString(out hostip)) { return; } if (Program.Zones.ContainsKey(zoneid)) { ZoneConnection z; if (Program.Zones.TryGetValue(zoneid, out z)) { z.SendTransferClientFromZone(accountid, username, charname, randid, admin, hostip); } } else { Log.WriteLine(LogLevel.Warn, "Uh oh, Zone {0} tried to transfer {1} to zone {1} D:", zc.ID, charname, zoneid); } }
public static void HandleServerAssignement(WorldConnection wc, InterPacket packet) { byte wid; string name, ip; ushort port; if (!packet.TryReadByte(out wid) || !packet.TryReadString(out name) || !packet.TryReadString(out ip) || !packet.TryReadUShort(out port)) { Log.WriteLine(LogLevel.Error, "Could not read World ID in inter server packet."); wc.Disconnect(); return; } if (WorldManager.Instance.Worlds.ContainsKey(wid)) { Log.WriteLine(LogLevel.Error, "Already loaded this world?"); wc.Disconnect(); return; } wc.Name = name; wc.ID = wid; wc.IP = ip; wc.Port = port; wc.IsAWorld = true; if (WorldManager.Instance.Worlds.TryAdd(wc.ID, wc)) { Log.WriteLine(LogLevel.Info, "Assigned world {0}!", wc.ID); SendAssigned(wc); } else { Log.WriteLine(LogLevel.Error, "Couldn't assign world {0}..", wc.ID); } }
public static void HandleTransfer(LoginConnector lc, InterPacket packet) { byte v; if (!packet.TryReadByte(out v)) { return; } if (v == 0) { byte admin; int accountid; string username, hash, hostip; if (!packet.TryReadInt(out accountid) || !packet.TryReadString(out username) || !packet.TryReadString(out hash) || !packet.TryReadByte(out admin) || !packet.TryReadString(out hostip)) { return; } ClientTransfer ct = new ClientTransfer(accountid, username, admin, hostip, hash); ClientManager.Instance.AddTransfer(ct); } else if (v == 1) { byte admin; int accountid; string username, charname, hostip; ushort randid; if (!packet.TryReadInt(out accountid) || !packet.TryReadString(out username) || !packet.TryReadString(out charname) || !packet.TryReadUShort(out randid) || !packet.TryReadByte(out admin) || !packet.TryReadString(out hostip)) { return; } ClientTransfer ct = new ClientTransfer(accountid, username, charname, randid, admin, hostip); ClientManager.Instance.AddTransfer(ct); } }
public static void ChangeZoneBeginn(ZoneConnection zc, InterPacket packet) { ushort mapid,randomid,port; string charname,ip; int x,y; if(!packet.TryReadUShort(out mapid)) return; if(!packet.TryReadInt(out x)) return; if(!packet.TryReadInt(out y)) return; if(!packet.TryReadString(out charname,16)) return; if(!packet.TryReadString(out ip,16)) return; if(!packet.TryReadUShort(out port)) return; if(!packet.TryReadUShort(out randomid)) return; WorldClient client = ClientManager.Instance.GetClientByCharname(charname); if(client == null) return; int oldmap = client.Character.Character.PositionInfo.Map; client.Character.Character.PositionInfo.Map = mapid; client.Character.Character.PositionInfo.XPos = x; client.Character.Character.PositionInfo.YPos = y; Managers.CharacterManager.InvokeChangeMapEvent(client.Character); client.Character.ChangeFrendMap(DataProvider.GetMapname(mapid));//setup later to event }
public static void Broadcast(WorldConnector pConnector, InterPacket pPacket) { int packetlenght; byte[] packet; string charname; if (!pPacket.TryReadString(out charname, 16)) return; if (!pPacket.TryReadInt(out packetlenght)) return; if (!pPacket.TryReadBytes(packetlenght, out packet)) return; ZoneClient pClient = ClientManager.Instance.GetClientByCharName(charname); if (pClient == null) return; using (var ipacket = new InterPacket(InterHeader.SendBroiadCastList)) { List<ZoneCharacter> Sender = pClient.Character.Map.GetCharactersBySectors(pClient.Character.MapSector.SurroundingSectors); if (Sender.Count == 0) return; ipacket.WriteInt(packetlenght); ipacket.WriteBytes(packet); ipacket.WriteInt(Sender.Count); foreach (var character in Sender) { ipacket.WriteString(character.Name,16); } pConnector.SendPacket(ipacket); } }
public static void AddPartyMember(WorldConnector lc, InterPacket packet) { long groupId = 0; string charName = ""; if (!packet.TryReadLong(out groupId) && !packet.TryReadString(out charName, 16)) { throw new InvalidPacketException(); } GroupManager.Instance.AddMemberToGroup(groupId, charName); }
public static void DisconnectFromzoneserver(ZoneConnection zc, InterPacket packet) { string charname; if (packet.TryReadString(out charname,16)) { WorldClient client = ClientManager.Instance.GetClientByCharname(charname); if (client == null) return; client.Character.Loggeout(client); ClientManager.Instance.RemoveClient(client); } }
public static void HandleAssigned(WorldConnector lc, InterPacket packet) { string entity, name; byte id; ushort port; int mapidcout; if (!packet.TryReadString(out entity) || !packet.TryReadByte(out id) || !packet.TryReadString(out name) || !packet.TryReadUShort(out port) || !packet.TryReadInt(out mapidcout)) { return; } Program.serviceInfo = new ZoneData { EntityString = entity, ID = id, Port = port, MapsToLoad = new List<FiestaLib.Data.MapInfo>() }; for (int i = 0; i < mapidcout; i++) { ushort mapid, viewrange; string shortname, fullname; int regenx, regeny; byte kingdom; if (!packet.TryReadUShort(out mapid) || !packet.TryReadString(out shortname) || !packet.TryReadString(out fullname) || !packet.TryReadInt(out regenx) || !packet.TryReadInt(out regeny) || !packet.TryReadByte(out kingdom) || !packet.TryReadUShort(out viewrange)) { break; } Program.serviceInfo.MapsToLoad.Add(new MapInfo(mapid, shortname, fullname, regenx, regeny, kingdom, viewrange)); ; } Console.Title = "Zepheus.Zone[" + id + "]"; Log.WriteLine(LogLevel.Info, "Successfully linked with worldserver. [Zone: {0} | Port: {1}]", id, port); ZoneAcceptor.Load(); }
public static void HandleAssigning(ZoneConnection lc, InterPacket packet) { string ip; if (!packet.TryReadString(out ip)) { return; } lc.IP = ip; // make idlist InterHandler.SendZoneStarted(lc.ID, lc.IP, lc.Port, lc.Maps); InterHandler.SendZoneList(lc); Log.WriteLine(LogLevel.Info, "Zone {0} listens @ {1}:{2}", lc.ID, lc.IP, lc.Port); }
public static void BanAccount(ZoneConnection zc, InterPacket packet) { string playername; if (packet.TryReadString(out playername, 16)) { WorldClient bannclient = ClientManager.Instance.GetClientByCharname(playername); if (bannclient != null) { using (var p = new InterPacket(InterHeader.BanAccount)) { p.WriteInt(bannclient.AccountID); LoginConnector.Instance.SendPacket(p); } bannclient.Disconnect(); } } }
public static void AddRewardItem(WorldConnector pConnector, InterPacket pPacket) { byte count; ushort ItemID; string Charname; if (!pPacket.TryReadUShort(out ItemID)) return; if (!pPacket.TryReadByte(out count)) return; if(!pPacket.TryReadString(out Charname,16)) return; ZoneClient pClient = ClientManager.Instance.GetClientByName(Charname); if(pClient == null) return; pClient.Character.GiveMasterRewardItem(ItemID, count); }
public static void RemovePartyMember(WorldConnector lc, InterPacket packet) { string name = ""; if (!packet.TryReadString(out name, 16)) { throw new InvalidPacketException(); } if (!ClientManager.Instance.HasClient(name)) return; var client = ClientManager.Instance.GetClientByCharName(name); var group = GroupManager.Instance.GetGroupForCharacter(client.Character.ID); group.RemoveMember(name); }
public static void HandleZoneOpened(WorldConnector lc, InterPacket packet) { byte id; string ip; ushort port; int mapcount; if (!packet.TryReadByte(out id) || !packet.TryReadString(out ip) || !packet.TryReadUShort(out port) || !packet.TryReadInt(out mapcount)) { return; } List<MapInfo> maps = new List<MapInfo>(); for (int j = 0; j < mapcount; j++) { ushort mapid, viewrange; string shortname, fullname; int regenx, regeny; byte kingdom; if (!packet.TryReadUShort(out mapid) || !packet.TryReadString(out shortname) || !packet.TryReadString(out fullname) || !packet.TryReadInt(out regenx) || !packet.TryReadInt(out regeny) || !packet.TryReadByte(out kingdom) || !packet.TryReadUShort(out viewrange)) { break; } maps.Add(new MapInfo(mapid, shortname, fullname, regenx, regeny, kingdom, viewrange)); } ZoneData zd; if (!Program.Zones.TryGetValue(id, out zd)) { zd = new ZoneData(); } zd.ID = id; zd.IP = ip; zd.Port = port; zd.MapsToLoad = maps; Program.Zones[id] = zd; Log.WriteLine(LogLevel.Info, "Added zone {0} to zonelist. {1}:{2}", zd.ID, zd.IP, zd.Port); }
public static void GetList(ZoneConnection pConnection, InterPacket pPacket) { int count, packetlenght; byte[] SendPacket; if (!pPacket.TryReadInt(out packetlenght)) return; if (!pPacket.TryReadBytes(packetlenght, out SendPacket)) return; if (!pPacket.TryReadInt(out count)) return; for (int i = 0; i < count; i++) { string charname; if(!pPacket.TryReadString(out charname,16)) return; WorldClient client= ClientManager.Instance.GetClientByCharname(charname); if(client !=null) using (var packet = new FiestaLib.Networking.Packet()) { packet.WriteBytes(SendPacket); client.SendPacket(packet); Log.WriteLine(LogLevel.Debug, "Send borcast to {0}", charname); } } }
public static void On_InterClient_GuildMessageUpdate(WorldConnector pConnector, InterPacket pPacket) { int guildID, characterID; DateTime createTime; ushort length; string message; if (!pPacket.TryReadInt(out guildID) || !pPacket.TryReadInt(out characterID) || !pPacket.TryReadDateTime(out createTime) || !pPacket.TryReadUShort(out length) || !pPacket.TryReadString(out message, length)) { return; } Guild guild; if (GetGuildByID(guildID, out guild)) { //update guild guild.Message = message; guild.MessageCreateTime = createTime; guild.MessageCreaterID = characterID; } }
public static void FunctionGetCharacterOnline(ZoneConnection pConnection, InterPacket pPacket) { long id; string charName; if(!pPacket.TryReadLong(out id) ||!pPacket.TryReadString(out charName, 16)) throw new InvalidPacketException(); bool isOnline = ClientManager.Instance.IsOnline(charName); using (InterPacket packet = new InterPacket(InterHeader.FunctionAnswer)) { packet.WriteLong(id); packet.WriteBool(isOnline); pConnection.SendPacket(packet); } }
public static void HandleWorldMessage(ZoneConnection zc, InterPacket packet) { string msg; bool wut; byte type; if (!packet.TryReadString(out msg) || !packet.TryReadByte(out type) || !packet.TryReadBool(out wut)) { return; } if (wut) { string to; if (!packet.TryReadString(out to)) { return; } WorldClient client; if ((client = ClientManager.Instance.GetClientByCharname(to)) == null) { Log.WriteLine(LogLevel.Warn, "Tried to send a WorldMessage to a character that is unknown. Charname: {0}", to); } else { using (var p = Handler25.CreateWorldMessage((WorldMessageTypes)type, msg)) { client.SendPacket(p); } } } else { using (var p = Handler25.CreateWorldMessage((WorldMessageTypes)type, msg)) { ClientManager.Instance.SendPacketToAll(p); } } }
public static void UpdateMoneyInWorld(ZoneConnection lc, InterPacket packet) { string charname = string.Empty; long NewMoney = 0; if(!packet.TryReadString(out charname,16) || !packet.TryReadLong(out NewMoney)) { return; } WorldCharacter Pchar = ClientManager.Instance.GetClientByCharname(charname).Character; Pchar.Character.Money = NewMoney; }
public static void UpdateLevel(ZoneConnection pConnection, InterPacket pPacket) { byte level; string Charname; if (!pPacket.TryReadByte(out level) || !pPacket.TryReadString(out Charname, 16)) return; WorldClient pClient = ClientManager.Instance.GetClientByCharname(Charname); if(pClient == null) return; pClient.Character.Character.CharLevel = level; Managers.CharacterManager.invokeLevelUp(pClient.Character); }
public static void ReciveCoper(ZoneConnection zc, InterPacket packet) { string charname; long coper; bool typ; if (!packet.TryReadString(out charname, 16)) return; if (!packet.TryReadLong(out coper)) return; if (!packet.TryReadBool(out typ)) return; WorldClient pClient = ClientManager.Instance.GetClientByCharname(charname); if (typ) { pClient.Character.Character.ReviveCoper += coper; } else { pClient.Character.RecviveCoperMaster += coper; pClient.Character.UpdateRecviveCoper(); } }