Пример #1
0
        private void TroopSetTheme(Session session, Packet packet)
        {
            uint   cityId;
            uint   troopId;
            string theme;

            try
            {
                cityId  = packet.GetUInt32();
                troopId = packet.GetUInt32();
                theme   = packet.GetString();
            }
            catch (Exception)
            {
                ReplyError(session, packet, Error.Unexpected);
                return;
            }

            ICity        city;
            ITroopObject troop;

            locker.Lock(cityId, troopId, out city, out troop).Do(() =>
            {
                if (city == null || troop == null || city.Owner != session.Player)
                {
                    ReplyError(session, packet, Error.ObjectNotFound);
                    return;
                }

                var result = themeManager.SetTroopTheme(troop, theme);

                ReplyWithResult(session, packet, result);
            });
        }