Skip to content
Merged

Cleanup #2055

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion src/NosCore.Core/NosCore.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.3.0" />
<PackageReference Include="NosCore.Dao" Version="4.0.3" />
<PackageReference Include="NosCore.Networking" Version="7.0.0" />
<PackageReference Include="NosCore.PathFinder" Version="2.0.1" />
<PackageReference Include="NosCore.PathFinder" Version="2.1.0" />
<PackageReference Include="NosCore.Shared" Version="6.0.0" />
<PackageReference Include="Serilog" Version="4.3.0" />
<PackageReference Include="Polly" Version="8.6.5" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace NosCore.Data.CommandPackets
{
public class CommandPacketHeaderAttribute(string identification, AuthorityType authority) : PacketHeaderAttribute(identification, Scope.InGame | Scope.InGame)
public class CommandPacketHeaderAttribute(string identification, AuthorityType authority) : PacketHeaderAttribute(identification, Scope.InGame)
{
public AuthorityType Authority { get; } = authority;
}
Expand Down
4 changes: 0 additions & 4 deletions src/NosCore.Data/SkillPacket.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using NosCore.Packets.Attributes;
using NosCore.Packets;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NosCore.Packets.Enumerations;

//todo move to NosCore.Packets
Expand Down
2 changes: 2 additions & 0 deletions src/NosCore.Data/WebApi/WarehouseLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class WarehouseLink
{
public WarehouseDto? Warehouse { get; set; }

public short Slot { get; set; }

//todo move this to a generic ItemInstance with a converter
public ItemInstanceDto? ItemInstance { get; set; }
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
using NosCore.Packets.ServerPackets.Map;
using NosCore.Packets.ServerPackets.Miniland;

namespace NosCore.GameObject.Services.MapInstanceGenerationService
namespace NosCore.GameObject.ComponentEntities.Entities
{
public class MapDesignObject : MinilandObjectDto
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
using System.Reactive.Subjects;
using System.Threading.Tasks;
using NodaTime;
using NosCore.GameObject.Services.MapItemGenerationService;

namespace NosCore.GameObject.Services.MapItemGenerationService
namespace NosCore.GameObject.ComponentEntities.Entities
{
public class MapItem(long visualId) : ICountableEntity, IRequestableEntity<Tuple<MapItem, GetPacket>>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// __ _ __ __ ___ __ ___ ___
// __ _ __ __ ___ __ ___ ___
// | \| |/__\ /' _/ / _//__\| _ \ __|
// | | ' | \/ |`._`.| \_| \/ | v / _|
// |_|\__|\__/ |___/ \__/\__/|_|_\___|
Expand All @@ -22,6 +22,7 @@
using NosCore.GameObject.ComponentEntities.Extensions;
using NosCore.GameObject.ComponentEntities.Interfaces;
using NosCore.GameObject.Services.MapInstanceGenerationService;
using NosCore.GameObject.Services.ShopService;
using NosCore.PathFinder.Interfaces;
using NosCore.Shared.Enumerations;
using Serilog;
Expand All @@ -33,7 +34,7 @@
using System.Threading;
using System.Collections.Concurrent;

namespace NosCore.GameObject
namespace NosCore.GameObject.ComponentEntities.Entities
{
public class MapMonster(ILogger logger, IHeuristic distanceCalculator, IClock clock,
ISpeedCalculationService speedCalculationService)
Expand Down Expand Up @@ -99,20 +100,21 @@ internal void StopLife()

public Task StartLifeAsync()
{
Life?.Dispose();

async Task LifeAsync()
{
try
{
if (!MapInstance.IsSleeping)
{
await MonsterLifeAsync().ConfigureAwait(false);
await MonsterLifeAsync();
}
}
catch (Exception e)
{
logger.Error(e.Message, e);
}

}
Life = Observable.Interval(TimeSpan.FromMilliseconds(400)).Select(_ => LifeAsync()).Subscribe();
return Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// __ _ __ __ ___ __ ___ ___
// __ _ __ __ ___ __ ___ ___
// | \| |/__\ /' _/ / _//__\| _ \ __|
// | | ' | \/ |`._`.| \_| \/ | v / _|
// |_|\__|\__/ |___/ \__/\__/|_|_\___|
Expand Down Expand Up @@ -26,6 +26,7 @@
using NosCore.GameObject.Services.ItemGenerationService;
using NosCore.GameObject.Services.MapInstanceGenerationService;
using NosCore.GameObject.Services.NRunService;
using NosCore.GameObject.Services.ShopService;
using NosCore.PathFinder.Interfaces;
using NosCore.Shared.Enumerations;
using Serilog;
Expand All @@ -38,7 +39,7 @@
using NodaTime;
using System.Threading;

namespace NosCore.GameObject
namespace NosCore.GameObject.ComponentEntities.Entities
{
public class MapNpc(IItemGenerationService? itemProvider, ILogger logger, IHeuristic distanceCalculator,
IClock clock)
Expand Down Expand Up @@ -133,13 +134,15 @@ internal void StopLife()

public Task StartLifeAsync()
{
Life?.Dispose();

async Task LifeAsync()
{
try
{
if (!MapInstance.IsSleeping)
{
await MonsterLifeAsync().ConfigureAwait(false);
await MonsterLifeAsync();
}
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
using NosCore.Data.Dto;
using NosCore.Data.StaticEntities;
using NosCore.GameObject.ComponentEntities.Interfaces;
using NosCore.GameObject.Services.GroupService;
using NosCore.GameObject.Services.MapInstanceGenerationService;
using NosCore.GameObject.Services.ShopService;
using NosCore.Shared.Enumerations;
using System;
using System.Collections.Concurrent;
using NodaTime;
using System.Threading;

namespace NosCore.GameObject
namespace NosCore.GameObject.ComponentEntities.Entities
{
public class Pet : MapMonsterDto, INamedEntity //TODO replace MapMonsterDTO by the correct PetDTO
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using NosCore.Packets.ServerPackets.Portals;
using System;

namespace NosCore.GameObject
namespace NosCore.GameObject.ComponentEntities.Entities
{
public class Portal : PortalDto
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@
using System.Threading.Tasks;
using NodaTime;
using NosCore.Networking;
using NosCore.GameObject.Networking.ClientSession;
using NosCore.Packets.ClientPackets.Battle;
using NosCore.Packets.ServerPackets.Battle;
using Microsoft.AspNetCore.Http;
using NosCore.Data.Enumerations.Battle;
using NosCore.Data.Enumerations.Map;
using static NosCore.Data.Enumerations.Buff.AdditionalTypes;
using System.Collections.Concurrent;
using System.Threading;


namespace NosCore.GameObject.ComponentEntities.Extensions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// __ _ __ __ ___ __ ___ ___
// __ _ __ __ ___ __ ___ ___
// | \| |/__\ /' _/ / _//__\| _ \ __|
// | | ' | \/ |`._`.| \_| \/ | v / _|
// |_|\__|\__/ |___/ \__/\__/|_|_\___|
Expand Down Expand Up @@ -363,7 +363,7 @@
IBlacklistHub blacklistHttpClient)
{
var subpackets = new List<BlinitSubPacket?>();
var blackList = await blacklistHttpClient.GetBlacklistedAsync(visualEntity.VisualId).ConfigureAwait(false);
var blackList = await blacklistHttpClient.GetBlacklistedAsync(visualEntity.VisualId);
foreach (var relation in blackList)
{
if (relation.CharacterId == visualEntity.VisualId)
Expand All @@ -385,12 +385,12 @@
IChannelHub channelHttpClient, IPubSubHub pubSubHub)
{
//same canal
var servers = (await channelHttpClient.GetCommunicationChannels().ConfigureAwait(false))
var servers = (await channelHttpClient.GetCommunicationChannels())
?.Where(c => c.Type == ServerType.WorldServer).ToList();

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This assignment to
servers
is useless, since its value is never read.
var accounts = await pubSubHub.GetSubscribersAsync();

var subpackets = new List<FinitSubPacket?>();
var friendlist = await friendHttpClient.GetFriendsAsync(visualEntity.VisualId).ConfigureAwait(false);
var friendlist = await friendHttpClient.GetFriendsAsync(visualEntity.VisualId);
//TODO add spouselist
//var spouseList = _webApiAccess.Get<List<CharacterRelationDto>>(WebApiRoute.Spouse, friendServer.WebApi, visualEntity.VisualId) ?? new List<CharacterRelationDto>();
foreach (var relation in friendlist)
Expand All @@ -412,7 +412,7 @@
public static async Task SendFinfoAsync(this ICharacterEntity visualEntity, IFriendHub friendHttpClient,
IPubSubHub pubSubHub, ISerializer packetSerializer, bool isConnected)
{
var friendlist = await friendHttpClient.GetFriendsAsync(visualEntity.VisualId).ConfigureAwait(false);
var friendlist = await friendHttpClient.GetFriendsAsync(visualEntity.VisualId);
await Task.WhenAll(friendlist.Select(friend =>
pubSubHub.SendMessageAsync(new PostedPacket
{
Expand All @@ -437,7 +437,7 @@
Id = friend.CharacterId,
Name = friend.CharacterName!
}
}))).ConfigureAwait(false);
})));
}

public static ServerGetPacket GenerateGet(this ICharacterEntity visualEntity, long itemId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

using NosCore.GameObject.ComponentEntities.Interfaces;
using NosCore.GameObject.Services.GroupService;
using NosCore.Packets.ServerPackets.Shop;
using System.Collections.Generic;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

using NosCore.GameObject.ComponentEntities.Entities;
using NosCore.GameObject.ComponentEntities.Interfaces;
using NosCore.Packets.Enumerations;
using NosCore.Packets.ServerPackets.Chats;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using NosCore.GameObject.Services.BattleService;
using NosCore.GameObject.Services.ShopService;

namespace NosCore.GameObject.ComponentEntities.Interfaces
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using NosCore.GameObject.Services.BattleService;
using NosCore.GameObject.Services.GroupService;
using NosCore.GameObject.Services.MapChangeService;
using NosCore.Networking;
using MailData = NosCore.GameObject.InterChannelCommunication.Messages.MailData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

using NosCore.GameObject.Services.GroupService;

namespace NosCore.GameObject.ComponentEntities.Interfaces
{
public interface INamedEntity : IAliveEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using NosCore.GameObject.Networking.ClientSession;
using System.Threading.Tasks;

namespace NosCore.GameObject
namespace NosCore.GameObject.Infastructure
{
public interface IEventHandler<in T, T2> : IEventHandler
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using NosCore.Packets.Interfaces;
using System.Threading.Tasks;

namespace NosCore.GameObject
namespace NosCore.GameObject.Infastructure
{
public interface IPacketHandler
{
Expand Down
Loading
Loading