mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 07:44:00 +00:00
Compare commits
8 Commits
v0.4
...
5f92f2c116
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f92f2c116 | ||
|
|
16d1413cd8 | ||
|
|
00d5f35c30 | ||
|
|
7e45bd8dcb | ||
|
|
ac5762fc42 | ||
|
|
12df57b273 | ||
|
|
c109c82a91 | ||
|
|
d214778af1 |
@@ -16,7 +16,7 @@ public class HttpServerConfig
|
||||
public string BindAddress { get; set; } = "0.0.0.0";
|
||||
public string PublicAddress { get; set; } = "127.0.0.1";
|
||||
public int Port { get; set; } = 21500;
|
||||
public bool EnableLog { get; set; } = true;
|
||||
public bool EnableLog { get; set; } = false;
|
||||
|
||||
public string GetDisplayAddress()
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ public class GameWeaponInfo : GrowableItemInfo
|
||||
}
|
||||
}public class GameSkinInfo : BaseGameItemInfo
|
||||
{
|
||||
public uint Level { get; set; }
|
||||
public uint SkinType { get; set; }
|
||||
public override Item ToProto()
|
||||
{
|
||||
var proto = new Item
|
||||
@@ -79,6 +79,7 @@ public class GameWeaponInfo : GrowableItemInfo
|
||||
Count = ItemCount,
|
||||
Flag = (uint)Flag,
|
||||
};
|
||||
proto.Slots[11] = SkinType;
|
||||
return proto;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class CharacterManager(PlayerInstance player) : BasePlayerManager(player)
|
||||
var weaponInfo = await Player.InventoryManager!.AddWeaponItem((ItemTypeEnum)CharacterExcel.DefaultWeaponGPDL[0], CharacterExcel.DefaultWeaponGPDL[1], CharacterExcel.DefaultWeaponGPDL[2], CharacterExcel.DefaultWeaponGPDL[3],sendPacket:false);
|
||||
if (weaponInfo != null) character.WeaponUniqueId = weaponInfo.UniqueId;
|
||||
|
||||
var skinInfo = Player.InventoryManager!.GetNormalItemGDPL(ItemTypeEnum.TYPE_CARD_SKIN, detail, particular, level)
|
||||
var skinInfo = Player.InventoryManager!.GetSkinItemGDPL(ItemTypeEnum.TYPE_CARD_SKIN, detail, particular, level)
|
||||
?? await Player.InventoryManager!.AddSkinItem(ItemTypeEnum.TYPE_CARD_SKIN, detail, particular, level, false);
|
||||
if (skinInfo != null) character.SkinId = skinInfo.UniqueId;
|
||||
|
||||
|
||||
@@ -51,27 +51,43 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
||||
return InventoryData.Weapons.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
||||
}
|
||||
|
||||
public async ValueTask<BaseGameItemInfo?> AddSkinItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||
public async ValueTask<GameSkinInfo?> AddSkinItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||
{
|
||||
if (genre != ItemTypeEnum.TYPE_CARD_SKIN) return null;
|
||||
var skinData = GameData.CardSkinData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
|
||||
if (skinData == null) return null;
|
||||
|
||||
var templateId = GameResourceTemplateId.FromGdpl((uint)genre,detail,particular,level);
|
||||
var skinInfo = new BaseGameItemInfo
|
||||
var skinInfo = new GameSkinInfo
|
||||
{
|
||||
TemplateId = templateId,
|
||||
UniqueId = InventoryData.NextUniqueUid++,
|
||||
ItemType = ItemTypeEnum.TYPE_CARD_SKIN,
|
||||
ItemCount = 1
|
||||
};
|
||||
InventoryData.Items[skinInfo.UniqueId] = skinInfo;
|
||||
InventoryData.Skins[skinInfo.UniqueId] = skinInfo;
|
||||
|
||||
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([skinInfo]));
|
||||
|
||||
return skinInfo;
|
||||
}
|
||||
|
||||
public GameSkinInfo? GetSkinItem(uint uniqueId)
|
||||
{
|
||||
return InventoryData.Skins.GetValueOrDefault(uniqueId);
|
||||
}
|
||||
|
||||
public GameSkinInfo? GetSkinItemByTemplateId(ulong templateId)
|
||||
{
|
||||
return InventoryData.Skins.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
||||
}
|
||||
|
||||
public GameSkinInfo? GetSkinItemGDPL(ItemTypeEnum genre, uint detail, uint particular, uint level)
|
||||
{
|
||||
var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level);
|
||||
return InventoryData.Skins.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
||||
}
|
||||
|
||||
public async ValueTask<BaseGameItemInfo?> AddArItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||
{
|
||||
if (genre != ItemTypeEnum.TYPE_AR) return null;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using MikuSB.Proto;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
@@ -15,16 +16,35 @@ public class GirlSkin_ChangeSkinType : ICallGSHandler
|
||||
["nType"] = req?.Type ?? 1,
|
||||
["nSkinId"] = req?.SkinId
|
||||
};
|
||||
// TODO change type in proto Item ??
|
||||
await CallGSRouter.SendScript(connection, "GirlSkin_ChangeSkinType", response.ToJsonString());
|
||||
if (req == null)
|
||||
{
|
||||
await CallGSRouter.SendScript(connection, "GirlSkin_ChangeSkinType", response.ToJsonString());
|
||||
return;
|
||||
}
|
||||
|
||||
var player = connection.Player!;
|
||||
var skinData = player.InventoryManager.GetSkinItem(req.SkinId);
|
||||
if (skinData == null)
|
||||
{
|
||||
await CallGSRouter.SendScript(connection, "GirlSkin_ChangeSkinType", response.ToJsonString());
|
||||
return;
|
||||
}
|
||||
|
||||
skinData.SkinType = req.Type;
|
||||
var sync = new NtfSyncPlayer
|
||||
{
|
||||
Items = { skinData.ToProto() }
|
||||
};
|
||||
|
||||
await CallGSRouter.SendScript(connection, "GirlSkin_ChangeSkinType", response.ToJsonString(), sync);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class ChangeSkinTypeParam
|
||||
{
|
||||
[JsonPropertyName("nType")]
|
||||
public int? Type { get; set; }
|
||||
public uint Type { get; set; }
|
||||
|
||||
[JsonPropertyName("nSkinId")]
|
||||
public uint? SkinId { get; set; }
|
||||
public uint SkinId { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using MikuSB.Database.Player;
|
||||
using MikuSB.GameServer.Server.CallGS.Handlers.Misc;
|
||||
using MikuSB.Proto;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.Preview;
|
||||
|
||||
[CallGSApi("RecordConfession")]
|
||||
public class RecordConfession : ICallGSHandler
|
||||
{
|
||||
private const int MainSceneGID = 132;
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var req = JsonSerializer.Deserialize<RecordConfessionParam>(param);
|
||||
if (req == null) return;
|
||||
var sid = req.Id + 10;
|
||||
var player = connection.Player!;
|
||||
var attr = player.Data.Attrs
|
||||
.FirstOrDefault(x => x.Gid == MainSceneGID && x.Sid == sid);
|
||||
if (attr == null)
|
||||
{
|
||||
attr = new PlayerAttr
|
||||
{
|
||||
Gid = MainSceneGID,
|
||||
Sid = sid,
|
||||
Val = 1
|
||||
};
|
||||
player.Data.Attrs.Add(attr);
|
||||
}
|
||||
var sync = new NtfSyncPlayer();
|
||||
sync.Custom[player.ToPackedAttrKey(MainSceneGID, sid)] = attr.Val;
|
||||
sync.Custom[player.ToShiftedAttrKey(MainSceneGID, sid)] = attr.Val;
|
||||
await CallGSRouter.SendScript(connection, "RecordConfession", "{}", sync);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class RecordConfessionParam
|
||||
{
|
||||
[JsonPropertyName("nIdx")]
|
||||
public uint Id { get; set; }
|
||||
}
|
||||
@@ -62,7 +62,8 @@ public class PacketNtfCallScript : BasePacket
|
||||
};
|
||||
|
||||
var extraSync = new NtfSyncPlayer();
|
||||
foreach (var item in inventory.Items.Values) if ((item.TemplateId & 0xFFFF) != 5) extraSync.Items.Add(item.ToProto());
|
||||
foreach (var item in inventory.Items.Values) extraSync.Items.Add(item.ToProto());
|
||||
foreach (var skin in inventory.Skins.Values) extraSync.Items.Add(skin.ToProto());
|
||||
foreach (var weapon in inventory.Weapons.Values) extraSync.Items.Add(weapon.ToProto());
|
||||
proto.ExtraSync = extraSync;
|
||||
SetData(proto);
|
||||
|
||||
@@ -11,7 +11,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<SelfContained>true</SelfContained>
|
||||
<SelfContained>false</SelfContained>
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
<PublishReadyToRun>true</PublishReadyToRun>
|
||||
<PublishTrimmed>false</PublishTrimmed>
|
||||
|
||||
@@ -13,10 +13,13 @@ public static class UpdateService
|
||||
private static readonly Logger Logger = new("Updater");
|
||||
private static readonly bool UpdateEnabled = true;
|
||||
private static readonly bool AskBeforeUpdate = true;
|
||||
private static readonly string RepositoryOwner = "DevilProMT";
|
||||
private static readonly string RepositoryOwner = "MikuLeaks";
|
||||
private static readonly string RepositoryName = "MikuSB";
|
||||
private static readonly string AssetName = "MikuSB-win-x64.zip";
|
||||
private static readonly int TimeoutSeconds = 5;
|
||||
private static readonly int ReleaseCheckTimeoutSeconds = 10;
|
||||
private static readonly int PackageDownloadTimeoutSeconds = 300;
|
||||
private static readonly int ResourceDownloadTimeoutSeconds = 300;
|
||||
private static readonly int ChecksumDownloadTimeoutSeconds = 30;
|
||||
private static readonly string ResourceArchiveUrl =
|
||||
"https://github.com/Kei-Luna/MikuSB-Resource/archive/refs/heads/main.zip";
|
||||
private static readonly string[] RequiredResourceFiles =
|
||||
@@ -50,8 +53,9 @@ public static class UpdateService
|
||||
Logger.Info($"Current build version: {BuildVersion.Current}");
|
||||
|
||||
using var client = CreateHttpClient();
|
||||
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(Math.Max(1, TimeoutSeconds)));
|
||||
var release = await GetLatestReleaseAsync(client, cts.Token);
|
||||
using var releaseCts =
|
||||
new CancellationTokenSource(TimeSpan.FromSeconds(Math.Max(1, ReleaseCheckTimeoutSeconds)));
|
||||
var release = await GetLatestReleaseAsync(client, releaseCts.Token);
|
||||
if (release == null)
|
||||
return false;
|
||||
|
||||
@@ -78,18 +82,18 @@ public static class UpdateService
|
||||
|
||||
var packagePath = Path.Combine(tempRoot, asset.Name);
|
||||
Logger.Info($"Downloading update {release.TagName}.");
|
||||
await DownloadFileAsync(client, asset.DownloadUrl, packagePath, cts.Token);
|
||||
await DownloadFileAsync(client, asset.DownloadUrl, packagePath, PackageDownloadTimeoutSeconds);
|
||||
|
||||
var resourcePackagePath = Path.Combine(tempRoot, "MikuSB-Resource-main.zip");
|
||||
Logger.Info("Downloading resource package.");
|
||||
await DownloadFileAsync(client, ResourceArchiveUrl, resourcePackagePath, cts.Token);
|
||||
await DownloadFileAsync(client, ResourceArchiveUrl, resourcePackagePath, ResourceDownloadTimeoutSeconds);
|
||||
|
||||
var checksumAsset = release.Assets.FirstOrDefault(x =>
|
||||
string.Equals(x.Name, AssetName + ".sha256", StringComparison.OrdinalIgnoreCase));
|
||||
if (checksumAsset != null)
|
||||
{
|
||||
var checksumPath = Path.Combine(tempRoot, checksumAsset.Name);
|
||||
await DownloadFileAsync(client, checksumAsset.DownloadUrl, checksumPath, cts.Token);
|
||||
await DownloadFileAsync(client, checksumAsset.DownloadUrl, checksumPath, ChecksumDownloadTimeoutSeconds);
|
||||
VerifySha256(packagePath, checksumPath);
|
||||
}
|
||||
|
||||
@@ -166,12 +170,11 @@ public static class UpdateService
|
||||
private static async Task DownloadAndInstallResourcesAsync()
|
||||
{
|
||||
using var client = CreateHttpClient();
|
||||
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(Math.Max(1, TimeoutSeconds)));
|
||||
var tempRoot = Path.Combine(Path.GetTempPath(), "MikuSB", "resources", Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(tempRoot);
|
||||
|
||||
var resourcePackagePath = Path.Combine(tempRoot, "MikuSB-Resource-main.zip");
|
||||
await DownloadFileAsync(client, ResourceArchiveUrl, resourcePackagePath, cts.Token);
|
||||
await DownloadFileAsync(client, ResourceArchiveUrl, resourcePackagePath, ResourceDownloadTimeoutSeconds);
|
||||
InstallResourcesFromArchive(resourcePackagePath,
|
||||
Path.Combine(AppContext.BaseDirectory, ConfigManager.Config.Path.ResourcePath));
|
||||
}
|
||||
@@ -214,7 +217,7 @@ public static class UpdateService
|
||||
{
|
||||
var client = new HttpClient
|
||||
{
|
||||
Timeout = TimeSpan.FromSeconds(Math.Max(1, TimeoutSeconds))
|
||||
Timeout = Timeout.InfiniteTimeSpan
|
||||
};
|
||||
|
||||
client.DefaultRequestHeaders.UserAgent.Add(
|
||||
@@ -251,14 +254,15 @@ public static class UpdateService
|
||||
HttpClient client,
|
||||
string downloadUrl,
|
||||
string destinationPath,
|
||||
CancellationToken cancellationToken)
|
||||
int timeoutSeconds)
|
||||
{
|
||||
using var response = await client.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
|
||||
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(Math.Max(1, timeoutSeconds)));
|
||||
using var response = await client.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead, cts.Token);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
await using var source = await response.Content.ReadAsStreamAsync(cancellationToken);
|
||||
await using var source = await response.Content.ReadAsStreamAsync(cts.Token);
|
||||
await using var destination = File.Create(destinationPath);
|
||||
await source.CopyToAsync(destination, cancellationToken);
|
||||
await source.CopyToAsync(destination, cts.Token);
|
||||
}
|
||||
|
||||
private static void CopyDirectory(string sourceDirectory, string targetDirectory)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# MikuSB
|
||||
|
||||
Snowbreak: Containment Zone private server reimplementation written in C#.
|
||||
<strong>MikuSB</strong> is a server emulator of a certain dungeon anime game.
|
||||
`SdkServer`, `GameServer`, and an optional local HTTP/HTTPS proxy are started from a single `net9.0` application.
|
||||
|
||||
[Discord](https://discord.gg/aMwCu9JyUR)
|
||||
@@ -86,7 +86,6 @@ It is not intended for unauthorized access to, interference with, or commercial
|
||||
|
||||
## Legal Disclaimer
|
||||
MikuSB was developed for educational and research purposes.
|
||||
- This project is not affiliated with or endorsed by SEASUN GAMES PTE. LTD.
|
||||
- All trademarks, copyrights, and other intellectual property related to the original game and its associated franchise belong to their respective owners.
|
||||
- This repository does not include any copyrighted game assets, binaries, or master data.
|
||||
- Use this software at your own risk. The authors assume no responsibility for any damages or legal consequences resulting from its use.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# MikuSB
|
||||
|
||||
Snowbreak: Containment Zone 向けの C# 製プライベートサーバー再実装です。
|
||||
<strong>MikuSB</strong>は、あるダンジョンアニメゲームのサーバーエミュレーターです。
|
||||
`SdkServer`、`GameServer`、任意のローカル HTTP/HTTPS プロキシを 1 つの `net9.0` アプリとして起動します。
|
||||
|
||||
[Discord](https://discord.gg/aMwCu9JyUR)
|
||||
@@ -87,7 +87,6 @@ dotnet build
|
||||
|
||||
## 法的免責事項
|
||||
MikuSBは教育および研究目的で開発されました。
|
||||
- このプロジェクトはSEASUN GAMES PTE. LTD. と一切関係が無く、承認も受けていません。
|
||||
- 元のゲーム及び関連フランチャイズに関するすべての商標、著作権知的財産権はそれぞれの所有者に帰属します。
|
||||
- このリポジトリには、著作権で保護されたゲームアセット、バイナリ、マスターデータは一切含まれていません。
|
||||
- 自己責任でご利用下さい。 著者は、本ソフトウェアによって生じるいかなる損害または法的結果についても一切責任を負いません。
|
||||
|
||||
@@ -1 +1 @@
|
||||
v=0.4
|
||||
v=0.9
|
||||
Reference in New Issue
Block a user