mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-12 15:04:36 +01:00
Match behavior of official server better
This commit is contained in:
@@ -131,6 +131,13 @@ namespace EpinelPS.Database
|
||||
{
|
||||
public bool ButtonAnimationPlayed = false;
|
||||
public bool PopupAnimationPlayed = false;
|
||||
|
||||
public UnlockData() {}
|
||||
public UnlockData(bool button, bool popup)
|
||||
{
|
||||
ButtonAnimationPlayed = button;
|
||||
PopupAnimationPlayed = popup;
|
||||
}
|
||||
}
|
||||
|
||||
public class MogMinigameInfo
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.Utils;
|
||||
|
||||
namespace EpinelPS.LobbyServer.ContentsOpen
|
||||
@@ -10,9 +11,33 @@ namespace EpinelPS.LobbyServer.ContentsOpen
|
||||
var req = await ReadData<ReqGetContentsOpenUnlockInfo>();
|
||||
var user = GetUser();
|
||||
|
||||
// This request is used for showing the "Collection Item Unlocked" Popup and button unlock animation
|
||||
|
||||
var response = new ResGetContentsOpenUnlockInfo();
|
||||
|
||||
// This request is used for showing the "Collection Item Unlocked" Popup and button unlock animation
|
||||
if (user.ContentsOpenUnlocked.Count == 0)
|
||||
{
|
||||
// These Always returned as true by official server
|
||||
// Fixes "Recruitment unlocked" during chapter 0
|
||||
// TODO: Don't hardcode this, maybe its in GameData
|
||||
|
||||
user.ContentsOpenUnlocked.Add(3, new(true, true));
|
||||
user.ContentsOpenUnlocked.Add(4, new(true, true));
|
||||
user.ContentsOpenUnlocked.Add(6, new(true, true));
|
||||
user.ContentsOpenUnlocked.Add(15, new(true, true));
|
||||
user.ContentsOpenUnlocked.Add(16, new(true, true));
|
||||
user.ContentsOpenUnlocked.Add(18, new(true, true));
|
||||
user.ContentsOpenUnlocked.Add(19, new(true, true));
|
||||
JsonDb.Save();
|
||||
}
|
||||
response.ContentsOpenUnlockInfoList.Add(new NetContentsOpenUnlockInfo()
|
||||
{
|
||||
ContentsOpenTableId = 3,
|
||||
IsUnlockButtonPlayed = true,
|
||||
IsUnlockPopupPlayed = true,
|
||||
});
|
||||
|
||||
|
||||
foreach (var item in user.ContentsOpenUnlocked)
|
||||
{
|
||||
response.ContentsOpenUnlockInfoList.Add(new NetContentsOpenUnlockInfo()
|
||||
|
||||
@@ -56,8 +56,18 @@ namespace EpinelPS.LobbyServer
|
||||
|
||||
protected abstract Task HandleAsync();
|
||||
|
||||
|
||||
private void PrintMessage<T>(T data) where T : IMessage, new()
|
||||
{
|
||||
var str = (string)data.GetType().InvokeMember("ToString", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod, null, data, null);
|
||||
Console.WriteLine(str);
|
||||
}
|
||||
protected async Task WriteDataAsync<T>(T data) where T : IMessage, new()
|
||||
{
|
||||
Console.WriteLine("Writing " + data.GetType().Name);
|
||||
PrintMessage(data);
|
||||
Console.WriteLine();
|
||||
|
||||
if (ctx == null)
|
||||
{
|
||||
var ms = new MemoryStream();
|
||||
@@ -71,7 +81,8 @@ namespace EpinelPS.LobbyServer
|
||||
{
|
||||
ctx.Response.ContentType = "application/octet-stream+protobuf";
|
||||
ctx.Response.ContentLength = data.CalculateSize();
|
||||
bool encrypted = false;
|
||||
bool encrypted = ctx.Request.Headers.ContentEncoding.Contains("enc");
|
||||
encrypted = false; //TODO implement, although client does not complain
|
||||
var responseBytes = encrypted ? new MemoryStream() : ctx.Response.Body;
|
||||
var x = new CodedOutputStream(responseBytes);
|
||||
data.WriteTo(x);
|
||||
@@ -102,6 +113,10 @@ namespace EpinelPS.LobbyServer
|
||||
T msg = new();
|
||||
msg.MergeFrom(bin.Contents);
|
||||
|
||||
Console.WriteLine("Reading " + msg.GetType().Name);
|
||||
PrintMessage(msg);
|
||||
Console.WriteLine();
|
||||
|
||||
UserId = bin.UserId;
|
||||
UsedAuthToken = bin.UsedAuthToken;
|
||||
|
||||
|
||||
@@ -10,9 +10,11 @@ namespace EpinelPS.LobbyServer.Wallet
|
||||
var req = await ReadData<ReqRefreshChargeCurrencyData>();
|
||||
var user = GetUser();
|
||||
|
||||
var response = new ResRefreshChargeCurrencyData();
|
||||
response.FreeCash = new();
|
||||
response.ChargeCash = new();
|
||||
ResRefreshChargeCurrencyData response = new()
|
||||
{
|
||||
FreeCash = new() { Type = (int)CurrencyType.FreeCash },
|
||||
ChargeCash = new() { Type = (int)CurrencyType.ChargeCash }
|
||||
};
|
||||
|
||||
foreach (var item in user.Currency)
|
||||
{
|
||||
|
||||
@@ -126,6 +126,12 @@ namespace EpinelPS.Utils
|
||||
items.Add(item);
|
||||
}
|
||||
|
||||
foreach (var item in reward.UserItems)
|
||||
{
|
||||
// TODO: do these need to be combined?
|
||||
result.UserItems.Add(item);
|
||||
}
|
||||
|
||||
foreach (var c in reward.Character)
|
||||
{
|
||||
Console.WriteLine("MergeRewards - TODO Character");
|
||||
|
||||
@@ -187,8 +187,10 @@ namespace EpinelPS.Utils
|
||||
|
||||
// prep payload
|
||||
MemoryStream msm = new();
|
||||
msm.WriteByte(88);
|
||||
msm.WriteByte(0);
|
||||
msm.WriteByte(67);
|
||||
msm.WriteByte(129);
|
||||
|
||||
// TODO: write message length
|
||||
|
||||
msm.Write(message);
|
||||
|
||||
|
||||
@@ -106,11 +106,20 @@ namespace EpinelPS.Utils
|
||||
{
|
||||
newItem.Count += item.reward_value;
|
||||
|
||||
// Tell the client the reward and its amount
|
||||
ret.Item.Add(new NetItemData()
|
||||
{
|
||||
Count = item.reward_value,
|
||||
Tid = item.reward_id,
|
||||
Isn = newItem.Isn
|
||||
//Isn = newItem.Isn
|
||||
});
|
||||
|
||||
// Tell the client the new amount of this item
|
||||
ret.UserItems.Add(new NetUserItemData()
|
||||
{
|
||||
Isn = newItem.Isn,
|
||||
Tid = newItem.ItemType,
|
||||
Count = newItem.Count
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -127,7 +136,15 @@ namespace EpinelPS.Utils
|
||||
{
|
||||
Count = item.reward_value,
|
||||
Tid = item.reward_id,
|
||||
Isn = id
|
||||
//Isn = id
|
||||
});
|
||||
|
||||
// Tell the client the new amount of this item (which is the same as user did not have item previously)
|
||||
ret.UserItems.Add(new NetUserItemData()
|
||||
{
|
||||
Isn = id,
|
||||
Tid = item.reward_id,
|
||||
Count = item.reward_value
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user