private void ProfileByType(Session session, Packet packet) { var reply = new Packet(packet); string type; uint id; try { type = packet.GetString().ToLowerInvariant(); id = packet.GetUInt32(); } catch (Exception) { ReplyError(session, packet, Error.Unexpected); return; } if (type == "city") { ICity city; locker.Lock(id, out city).Do(() => { if (city == null) { ReplyError(session, reply, Error.PlayerNotFound); return; } PacketHelper.AddPlayerProfileToPacket(city.Owner, reply); session.Write(reply); }); return; } if (type == "stronghold") { IStronghold stronghold; locker.Lock(id, out stronghold).Do(() => { if (stronghold == null || stronghold.StrongholdState == StrongholdState.Inactive) { ReplyError(session, reply, Error.ObjectNotFound); return; } PacketHelper.AddStrongholdProfileToPacket(session, stronghold, reply); session.Write(reply); }); return; } ReplyError(session, packet, Error.Unexpected); }
private void GetInfoByName(Session session, Packet packet) { var reply = new Packet(packet); string name; try { name = packet.GetString(); } catch (Exception) { ReplyError(session, packet, Error.Unexpected); return; } IStronghold stronghold; if (!strongholdManager.TryGetStronghold(name, out stronghold)) { ReplyError(session, packet, Error.StrongholdNotFound); return; } locker.Lock(stronghold).Do(() => { if (stronghold == null) { ReplyError(session, packet, Error.Unexpected); return; } PacketHelper.AddStrongholdProfileToPacket(session, stronghold, reply); session.Write(reply); }); }
private void GetInfo(Session session, Packet packet) { var reply = new Packet(packet); uint strongholdId; try { strongholdId = packet.GetUInt32(); } catch (Exception) { ReplyError(session, packet, Error.Unexpected); return; } if (session.Player.Tribesman == null) { ReplyError(session, packet, Error.TribeIsNull); return; } IStronghold stronghold; if (!strongholdManager.TryGetStronghold(strongholdId, out stronghold)) { ReplyError(session, packet, Error.StrongholdNotFound); return; } locker.Lock(stronghold).Do(() => { PacketHelper.AddStrongholdProfileToPacket(session, stronghold, reply); session.Write(reply); }); }