Skip to content

Commit

Permalink
Merge pull request #18 from yuwui/guild
Browse files Browse the repository at this point in the history
Guild
  • Loading branch information
Wincent01 authored Feb 19, 2020
2 parents f249c56 + f009a4c commit e89c754
Show file tree
Hide file tree
Showing 101 changed files with 5,696 additions and 600 deletions.
2 changes: 1 addition & 1 deletion InfectedRose
Submodule InfectedRose updated 60 files
+10 −9 InfectedRose.Core/Extensions/BitReaderExtensions.cs
+14 −0 InfectedRose.Core/Extensions/BitWriterExtensions.cs
+25 −0 InfectedRose.Database/Concepts/Generic/LwoObjectExtensions.cs
+2 −3 InfectedRose.Database/Concepts/LwoObject.cs
+18 −12 InfectedRose.Database/FdbRowInfo.cs
+28 −26 InfectedRose.Database/Table.cs
+45 −0 InfectedRose.Examples/AccessDatabaseCommand.cs
+142 −0 InfectedRose.Examples/AccessEditor.cs
+17 −0 InfectedRose.Nif/Controllers/NiTimeController.cs
+17 −0 InfectedRose.Nif/Data/AbstractAdditionalGeometryData.cs
+186 −0 InfectedRose.Nif/Data/NiGeometryData.cs
+15 −0 InfectedRose.Nif/Data/NiLODData.cs
+40 −0 InfectedRose.Nif/Data/NiRangeLODData.cs
+54 −0 InfectedRose.Nif/Data/NiScreenLODData.cs
+17 −0 InfectedRose.Nif/Data/NiSkinInstance.cs
+23 −0 InfectedRose.Nif/Data/NiTriBasedGeomData.cs
+53 −0 InfectedRose.Nif/Data/NiTriShapeData.cs
+7 −0 InfectedRose.Nif/Effects/NiAmbientLight.cs
+40 −0 InfectedRose.Nif/Effects/NiDynamicEffect.cs
+41 −0 InfectedRose.Nif/Effects/NiLight.cs
+1 −1 InfectedRose.Nif/Enums/NifVersion.cs
+19 −0 InfectedRose.Nif/Extensions/BitReaderExtensions.cs
+20 −0 InfectedRose.Nif/Extra/NiExtraData.cs
+24 −0 InfectedRose.Nif/Extra/NiStringExtraData.cs
+154 −0 InfectedRose.Nif/NiFile.cs
+39 −3 InfectedRose.Nif/NiHeader.cs
+14 −0 InfectedRose.Nif/NiObject.cs
+48 −0 InfectedRose.Nif/NiRef.cs
+38 −0 InfectedRose.Nif/NiStringRef.cs
+0 −22 InfectedRose.Nif/NifFile.cs
+0 −40 InfectedRose.Nif/NifString.cs
+65 −0 InfectedRose.Nif/Nodes/NiAvObject.cs
+20 −0 InfectedRose.Nif/Nodes/NiCollisionObject.cs
+66 −0 InfectedRose.Nif/Nodes/NiGeometry.cs
+24 −0 InfectedRose.Nif/Nodes/NiLODNode.cs
+50 −0 InfectedRose.Nif/Nodes/NiNode.cs
+43 −0 InfectedRose.Nif/Nodes/NiObjectNet.cs
+29 −0 InfectedRose.Nif/Nodes/NiSwitchNode.cs
+7 −0 InfectedRose.Nif/Nodes/NiTriBasedGeom.cs
+7 −0 InfectedRose.Nif/Nodes/NiTriShape.cs
+7 −0 InfectedRose.Nif/Nodes/NiTriStrips.cs
+59 −0 InfectedRose.Nif/Properties/NiMaterialProperty.cs
+7 −0 InfectedRose.Nif/Properties/NiProperty.cs
+23 −0 InfectedRose.Nif/Properties/NiShadeProperty.cs
+23 −0 InfectedRose.Nif/Properties/NiSpecularProperty.cs
+23 −0 InfectedRose.Nif/Properties/NiVertexColorProperty.cs
+23 −0 InfectedRose.Nif/Properties/NiZBufferProperty.cs
+11 −0 InfectedRose.Nif/Structs/Color3.cs
+13 −0 InfectedRose.Nif/Structs/Color4.cs
+9 −0 InfectedRose.Nif/Structs/LODRange.cs
+9 −0 InfectedRose.Nif/Structs/MatchGroup.cs
+23 −0 InfectedRose.Nif/Structs/Matrix3X3.cs
+11 −0 InfectedRose.Nif/Structs/Triangle.cs
+7 −0 InfectedRose.Terrain/HeightMap.cs
+0 −7 InfectedRose.Terrain/TerrainEditor.cs
+31 −0 InfectedRose.Terrain/TerrainFile.cs
+4 −1 InfectedRose.Triggers/Trigger.cs
+2 −1 InfectedRose.Triggers/TriggerCollection.cs
+76 −0 InfectedRose.Triggers/TriggerDictionary.cs
+2 −1 InfectedRose.Triggers/TriggerEvent.cs
13 changes: 7 additions & 6 deletions Uchu.Auth/Handlers/LoginHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
using Microsoft.EntityFrameworkCore;
using RakDotNet;
using Uchu.Core;
using static Uchu.Auth.ServerLoginInfoPacket;

namespace Uchu.Auth.Handlers
{
public class LoginHandler : HandlerGroup
{
[PacketHandler]
public async Task LoginRequestHandler(ClientLoginInfoPacket packet, IRakConnection connection)
{
{
await using var ctx = new UchuContext();

var info = new ServerLoginInfoPacket
Expand All @@ -25,7 +26,7 @@ public async Task LoginRequestHandler(ClientLoginInfoPacket packet, IRakConnecti
if (characterSpecification == default)
{
info.LoginCode = LoginCode.InsufficientPermissions;
info.Error = new ServerLoginInfoPacket.ErrorMessage
info.Error = new ErrorMessage
{
Message = "No character server instance is running. Please try again later."
};
Expand All @@ -37,7 +38,7 @@ public async Task LoginRequestHandler(ClientLoginInfoPacket packet, IRakConnecti
if (!await ctx.Users.AnyAsync(u => u.Username == packet.Username))
{
info.LoginCode = LoginCode.InsufficientPermissions;
info.Error = new ServerLoginInfoPacket.ErrorMessage
info.Error = new ErrorMessage
{
Message = "We have no records of that Username and Password combination. Please try again."
};
Expand All @@ -51,15 +52,15 @@ public async Task LoginRequestHandler(ClientLoginInfoPacket packet, IRakConnecti
if (user.Banned)
{
info.LoginCode = LoginCode.InsufficientPermissions;
info.Error = new ServerLoginInfoPacket.ErrorMessage
info.Error = new ErrorMessage
{
Message = $"This account has been banned by an admin. Reason:\n{user.BannedReason ?? "Unknown"}"
};
}
else if (!string.IsNullOrWhiteSpace(user.CustomLockout))
{
info.LoginCode = LoginCode.InsufficientPermissions;
info.Error = new ServerLoginInfoPacket.ErrorMessage
info.Error = new ErrorMessage
{
Message = user.CustomLockout
};
Expand Down Expand Up @@ -91,7 +92,7 @@ public async Task LoginRequestHandler(ClientLoginInfoPacket packet, IRakConnecti
else
{
info.LoginCode = LoginCode.InsufficientPermissions;
info.Error = new ServerLoginInfoPacket.ErrorMessage
info.Error = new ErrorMessage
{
Message = "We have no records of that Username and Password combination. Please try again."
};
Expand Down
4 changes: 4 additions & 0 deletions Uchu.Core/Config/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ public class Configuration
public class ManagedScriptSources
{
[XmlElement("Script")] public List<string> Scripts { get; set; } = new List<string>();

[XmlElement("Library")] public List<string> Paths { get; set; } = new List<string>();
}

public class ServerDllSource
{
[XmlElement] public string ServerDllSourcePath { get; set; } = "../../../../";

[XmlElement] public string DotNetPath { get; set; } = "dotnet";

[XmlElement] public string Instance { get; set; } = "Uchu.Instance.dll";

[XmlElement]
public List<string> ScriptDllSource { get; set; } = new List<string>
Expand Down
2 changes: 2 additions & 0 deletions Uchu.Core/Database/Models/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ public class Character
public bool LandingByRocket { get; set; }

public int InventorySize { get; set; }

public long GuildId { get; set; }

public ZoneId LaunchedRocketFrom { get; set; }

Expand Down
15 changes: 15 additions & 0 deletions Uchu.Core/Database/Models/Guild.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Collections.Generic;

namespace Uchu.Core
{
public class Guild
{
public long Id { get; set; }

public string Name { get; set; }

public long CreatorId { get; set; }

public List<GuildInvite> Invites { get; set; }
}
}
18 changes: 18 additions & 0 deletions Uchu.Core/Database/Models/GuildInvite.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations.Schema;

namespace Uchu.Core
{
public class GuildInvite
{
public long Id { get; set; }

public long SenderId { get; set; }

public long RecipientId { get; set; }

public long GuildId { get; set; }

[ForeignKey(nameof(GuildId))]
public Guild Guild { get; set; }
}
}
14 changes: 14 additions & 0 deletions Uchu.Core/Database/Providers/SqliteContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.EntityFrameworkCore;

namespace Uchu.Core.Providers
{
public class SqliteContext : UchuContextBase
{
public static string DatabasePath { get; set; } = "./Uchu.sqlite";

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite($"Data Source=\"{DatabasePath}\"");
}
}
}
4 changes: 4 additions & 0 deletions Uchu.Core/Database/Providers/UchuContextBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public abstract class UchuContextBase : DbContext, IAsyncDisposable

public DbSet<CharacterMail> Mails { get; set; }

public DbSet<Guild> Guilds { get; set; }

public DbSet<GuildInvite> GuildInvites { get; set; }

public virtual async Task EnsureUpdatedAsync()
{
await Database.MigrateAsync().ConfigureAwait(false);
Expand Down
9 changes: 7 additions & 2 deletions Uchu.Core/Database/UchuContext.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.IO;
using System.Threading.Tasks;
using System.Xml.Serialization;
using Microsoft.EntityFrameworkCore;
using Uchu.Core.Providers;

Expand Down Expand Up @@ -31,6 +29,10 @@ public sealed class UchuContext : IAsyncDisposable, IDisposable

public DbSet<CharacterMail> Mails => ContextBase.Mails;

public DbSet<Guild> Guilds => ContextBase.Guilds;

public DbSet<GuildInvite> GuildInvites => ContextBase.GuildInvites;

public UchuContext()
{
var config = UchuContextBase.Config;
Expand All @@ -43,6 +45,9 @@ public UchuContext()
case "mysql":
ContextBase = new MySqlContext();
break;
case "sqlite":
ContextBase = new SqliteContext();
break;
default:
Logger.Error($"{config.Database.Provider} is a invalid or unsupported database provider");
throw new Exception($"Invalid database provider: \"{config.Database.Provider}\"");
Expand Down
3 changes: 2 additions & 1 deletion Uchu.Core/Enums/ZoneId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public enum ZoneId : ushort
NexusTower = 1900,
Ninjago = 2000,
FrakjawBattle,
NimbusStationWinterRacetrack = 1261
NimbusStationWinterRacetrack = 1261,
Test = 58001
}
}
10 changes: 9 additions & 1 deletion Uchu.Core/Extensions/RakConnectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.IO;
using RakDotNet;
using RakDotNet.IO;
Expand All @@ -15,7 +16,14 @@ public static void Send(this IRakConnection @this, ISerializable serializable)

writer.Write(serializable);

@this.Send(stream.ToArray());
try
{
@this.Send(stream.ToArray());
}
catch (IOException e)
{
Logger.Error(e);
}
}

public static void SavePacket(this IRakConnection @this, ISerializable serializable)
Expand Down
2 changes: 2 additions & 0 deletions Uchu.Core/IO/IFileResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace Uchu.Core.IO
{
public interface IFileResources
{
string RootPath { get; }

Task<string> ReadTextAsync(string path);

Task<byte[]> ReadBytesAsync(string path);
Expand Down
8 changes: 4 additions & 4 deletions Uchu.Core/IO/LocalResources.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -11,6 +10,8 @@ public class LocalResources : IFileResources
{
private readonly Configuration _config;

public string RootPath => _config.ResourcesConfiguration.GameResourceFolder;

public LocalResources(Configuration config)
{
_config = config;
Expand All @@ -20,7 +21,7 @@ public async Task<string> ReadTextAsync(string path)
{
await using var stream = GetStream(path);
using var reader = new StreamReader(stream);
return await reader.ReadToEndAsync();
return await reader.ReadToEndAsync().ConfigureAwait(false);
}

public async Task<byte[]> ReadBytesAsync(string path)
Expand Down Expand Up @@ -77,8 +78,7 @@ public IEnumerable<string> GetAllFilesWithExtension(string location, string exte

return files;
}



public Stream GetStream(string path)
{
path = path.Replace('\\', '/').ToLower();
Expand Down
Loading

0 comments on commit e89c754

Please sign in to comment.