public static void On_WorldClient_AcademyMemberLeft(WorldConnector pConnector, InterPacket pPacket) { int guildID, characterID; if (!pPacket.TryReadInt(out guildID) || !pPacket.TryReadInt(out characterID)) { return; } Guild guild; if (GuildManager.GetGuildByID(guildID, out guild)) { GuildAcademyMember member; if (guild.Academy.GetMember(characterID, out member)) { guild.Academy.Members.Remove(member); member.Dispose(); ZoneCharacter character; if (CharacterManager.GetLoggedInCharacter(characterID, out character)) { character.Guild = null; character.GuildAcademy = null; character.GuildAcademyMember = null; GuildManager.RemoveGuildBuff(character); } } } }
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 On_WorldClient_AcademyMemberJoined(WorldConnector pConnector, InterPacket pPacket) { int guildID, characterID; DateTime registerDate; if (!pPacket.TryReadInt(out guildID) || !pPacket.TryReadInt(out characterID) || !pPacket.TryReadDateTime(out registerDate)) { return; } Guild guild; if (GuildManager.GetGuildByID(guildID, out guild)) { var member = new GuildAcademyMember(guild.Academy, characterID, GuildAcademyRank.Member, registerDate) { IsOnline = true, }; guild.Academy.Members.Add(member); ZoneCharacter character; if (CharacterManager.GetLoggedInCharacter(characterID, out character)) { member.Character = character; character.Guild = guild; character.GuildAcademy = guild.Academy; character.GuildAcademyMember = member; GuildManager.SetGuildBuff(character); } } }
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 Banaccount(WorldConnection wc, InterPacket packet) { int acountid; if (packet.TryReadInt(out acountid)) { Program.DatabaseManager.GetClient().ExecuteQuery("UPDATE Accounts Set Blocked='1' WHERE ID="+acountid+""); } }
public static void On_WorldClient_AcademyBuffUpdate(WorldConnector pConnector, InterPacket pPacket) { int guildID; DateTime updateTime; double keepTime; if (!pPacket.TryReadInt(out guildID) || !pPacket.TryReadDateTime(out updateTime) || !pPacket.TryReadDouble(out keepTime)) { //Client.Dispose(); return; } Guild guild; if (GuildManager.GetGuildByID(guildID, out guild)) { guild.Academy.GuildBuffUpdateTime = updateTime; guild.Academy.GuildBuffKeepTime = TimeSpan.FromSeconds(keepTime); } }
public static void ChangeMoney(WorldConnector pConnector, InterPacket pPacket) { int CharID; long NewMoney; if (!pPacket.TryReadInt(out CharID)) return; if (!pPacket.TryReadLong(out NewMoney)) return; ZoneClient pClient = ClientManager.Instance.GetClientByCharID(CharID); if (pClient == null) return; pClient.Character.ChangeMoney(NewMoney); }
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 HandleTransfer(WorldConnector lc, InterPacket packet) { byte v; if (!packet.TryReadByte(out v)) { return; } if (v == 0) { byte admin; int accountid, CharID; string username, hash, hostip; if (!packet.TryReadInt(out accountid) || !packet.TryReadString(out username) || !packet.TryReadInt(out CharID)|| !packet.TryReadString(out hash) || !packet.TryReadByte(out admin) || !packet.TryReadString(out hostip)) { return; } ClientTransfer ct = new ClientTransfer(accountid, username,CharID, admin, hostip, hash); ClientManager.Instance.AddTransfer(ct); } else if (v == 1) { byte admin; int accountid,CharID; string username, charname, hostip; ushort randid; if (!packet.TryReadInt(out accountid) || !packet.TryReadString(out username) || !packet.TryReadString(out charname) || !packet.TryReadInt(out CharID) || !packet.TryReadUShort(out randid) || !packet.TryReadByte(out admin) || !packet.TryReadString(out hostip)) { return; } ClientTransfer ct = new ClientTransfer(accountid, username, charname,CharID, randid, admin, hostip); ClientManager.Instance.AddTransfer(ct); } }
public static void HandleAssigned(WorldConnector lc, InterPacket packet) { string name; byte id; ushort port; int mapidcout; if (!packet.TryReadByte(out id) || !packet.TryReadString(out name) || !packet.TryReadUShort(out port) || !packet.TryReadInt(out mapidcout)) { return; } Program.ServiceInfo = new ZoneData { 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)); } Log.WriteLine(LogLevel.Info, "Successfully linked with worldserver. [Zone: {0} | Port: {1}]", id, port); ZoneAcceptor.Load(); }
public static void HandleClientTransferZone(ZoneConnection zc, InterPacket packet) { byte admin, zoneid; int accountid,CharID; string username, charname, hostip; ushort randid, mapid; if (!packet.TryReadByte(out zoneid) || !packet.TryReadInt(out accountid) || !packet.TryReadUShort(out mapid) || !packet.TryReadString(out username) || !packet.TryReadString(out charname)||!packet.TryReadInt(out CharID) || !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,CharID, 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 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_WorldClient_AcademyMemberOnline(WorldConnector pConnector, InterPacket pPacket) { int guildID, characterID; if (!pPacket.TryReadInt(out guildID) || !pPacket.TryReadInt(out characterID)) { return; } Guild guild; if (GuildManager.GetGuildByID(guildID, out guild)) { GuildAcademyMember member; if (guild.Academy.GetMember(characterID, out member)) { member.IsOnline = true; ZoneCharacter character; if (CharacterManager.GetLoggedInCharacter(characterID, out character)) { character.Guild = guild; character.GuildAcademy = guild.Academy; character.GuildAcademyMember = member; member.Character = character; } } } }