Commit 0cf202a5 authored by hex's avatar hex

fix bugss and add https support

parent ee0428d5
Pipeline #38539 failed
......@@ -211,6 +211,17 @@ public class MonoCardInDeckManager : MonoBehaviour
rigidbody.useGravity = false;
}
public bool IsInDeckArea()
{
// 此逻辑专门用于检查卡片是否在物理上位于有效的卡组区域内。
Vector3 to_ltemp = refLectPosition(gameObject.transform.position);
if (to_ltemp.x < -15.2f || to_ltemp.x > 15.2f)
{
return false;
}
return true;
}
public bool getIfAlive()
{
// 步骤 1: 检查不可逆的“死亡”状态,这在任何模式下都适用。
......@@ -226,16 +237,8 @@ public class MonoCardInDeckManager : MonoBehaviour
}
else // (condition == DeckManager.Condition.editDeck)
{
// 在“编辑卡组”模式下,我们执行原有的严格边界检查。
// 将卡片拖到边界外意味着“丢弃”。
Vector3 to_ltemp = refLectPosition(gameObject.transform.position);
if (to_ltemp.x < -15.2f || to_ltemp.x > 15.2f)
{
return false;
}
return IsInDeckArea();
}
// 如果通过了所有检查,则卡片是存活的。
return true;
}
public static Vector3 refLectPosition(Vector3 pos)
......
......@@ -140,11 +140,11 @@ public static class TcpHelper
break;
case StocMessage.ChangeSide:
Program.I().room.StocMessage_ChangeSide(r);
TcpHelper.SaveRecord();
// TcpHelper.SaveRecord();
break;
case StocMessage.WaitingSide:
Program.I().room.StocMessage_WaitingSide(r);
TcpHelper.SaveRecord();
// TcpHelper.SaveRecord();
break;
case StocMessage.DeckCount:
Program.I().room.StocMessage_DeckCount(r);
......@@ -166,11 +166,11 @@ public static class TcpHelper
break;
case StocMessage.DuelEnd:
Program.I().room.StocMessage_DuelEnd(r);
TcpHelper.SaveRecord();
// TcpHelper.SaveRecord();
break;
case StocMessage.Replay:
Program.I().room.StocMessage_Replay(r);
TcpHelper.SaveRecord();
// TcpHelper.SaveRecord();
break;
case StocMessage.TimeLimit:
Program.I().ocgcore.StocMessage_TimeLimit(r);
......@@ -475,6 +475,7 @@ public static class TcpHelper
public static List<Package> readPackagesInRecord(string path)
{
UnityEngine.Debug.Log(path);
List<Package> re = null;
try
{
......
......@@ -541,7 +541,7 @@ public class Program : MonoBehaviour
bool lflistUpdated = false;
bool stringsUpdated = false;
// 1. 下载 cards.cdb
string cardsUrl = "http://cdn01.moestart.com/koishipro/ygopro-database/zh-CN/cards.cdb";
string cardsUrl = "https://cdn02.moecube.com:444/koishipro/ygopro-database/zh-CN/cards.cdb";
string cardsPath = Path.Combine(dbDir, "cards.cdb");
yield return StartCoroutine(
UnityFileDownloader.DownloadFileAsync(
......@@ -559,7 +559,7 @@ public class Program : MonoBehaviour
);
// 2. 下载 lflist.conf
string lflistUrl = "http://cdn01.moestart.com/koishipro/ygopro-database/zh-CN/lflist.conf";
string lflistUrl = "https://cdn02.moecube.com:444/koishipro/ygopro-database/zh-CN/lflist.conf";
string lflistPath = Path.Combine(dbDir, "lflist.conf");
yield return StartCoroutine(
UnityFileDownloader.DownloadFileAsync(
......@@ -577,7 +577,7 @@ public class Program : MonoBehaviour
);
// 3. 下载 strings.conf
string stringsUrl =
"http://cdn01.moestart.com/koishipro/ygopro-database/zh-CN/strings.conf";
"https://cdn02.moecube.com:444/koishipro/ygopro-database/zh-CN/strings.conf";
string stringsPath = Path.Combine(dbDir, "strings.conf");
yield return StartCoroutine(
UnityFileDownloader.DownloadFileAsync(
......
......@@ -857,12 +857,6 @@ public class GameTextureManager
);
path = "picture/card/" + pic.code.ToString() + ".jpg";
}
/*if (!File.Exists(path) && pic.code != 0 && AutoPicDownload)
{
//先行卡 (177x254)
df.Download("http://download.ygo2019.xyz/ygopro2-data/expansions/pics/" + pic.code.ToString() + ".jpg", "picture/cardIn8thEdition/" + pic.code.ToString() + ".jpg");
path = "picture/cardIn8thEdition/" + pic.code.ToString() + ".jpg";
}*/
LoadCardPicture(pic, path);
}
catch (Exception e)
......
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using UnityEngine;
public static class GlobalCertificateManager
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
public static void Initialize()
{
// 注册全局的证书验证回调
ServicePointManager.ServerCertificateValidationCallback =
MyRemoteCertificateValidationCallback;
Debug.Log("全局证书验证回调已注册,将接受所有HTTPS证书。");
}
/// <summary>
/// 自定义的证书验证回调方法。
/// </summary>
/// <param name="sender">请求发送者</param>
/// <param name="certificate">服务器提供的证书</param>
/// <param name="chain">证书链</param>
/// <param name="sslPolicyErrors">SSL策略错误</param>
/// <returns>始终返回true,表示接受该证书</returns>
public static bool MyRemoteCertificateValidationCallback(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors
)
{
// return true;
// Case 1: 证书本身没有问题,直接通过
if (sslPolicyErrors == SslPolicyErrors.None)
{
return true;
}
// Case 2: 如果错误是 RemoteCertificateChainErrors,
// 这通常意味着证书链有问题,比如找不到吊销列表或者根证书不受信任。
// 我们将尝试进行一次忽略吊销检查的自定义验证。
if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateChainErrors) != 0)
{
// 创建一个新的证书链对象
X509Chain customChain = new X509Chain();
// 设置自定义验证策略
customChain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; // <-- 核心:不检查证书吊销
customChain.ChainPolicy.VerificationFlags =
X509VerificationFlags.AllowUnknownCertificateAuthority; // 可选:如果你的服务器是自签名证书,需要加上这句。如果服务器证书是由受信任的公共CA颁发的,可以去掉这句。
// 使用 X509Certificate2,因为它包含更完整的信息
X509Certificate2 cert2 = new X509Certificate2(certificate);
// 使用自定义策略进行验证
bool isChainValid = customChain.Build(cert2);
// 如果自定义验证构建成功,说明在忽略吊销检查的前提下,证书是可信的
if (isChainValid)
{
return true;
}
}
// Case 3: 对于其他错误(如名称不匹配 RemoteCertificateNameMismatch)或自定义验证失败,
// 我们认为证书无效。
Debug.LogErrorFormat("证书验证失败. SslPolicyErrors: {0}", sslPolicyErrors);
return false;
}
}
......@@ -80,15 +80,15 @@ public class UnityFileDownloader
switch (extension)
{
case ".png":
return 7;
return 20;
case ".jpg":
return 4;
return 20;
case ".cdb":
return 30;
return 50;
case ".conf":
return 3;
return 20;
default:
return 10;
return 20;
}
}
}
......@@ -677,9 +677,9 @@ namespace Percy
int len = result & 0xFFFF;
if (len > 0)
{
byte[] arr = new byte[4096];
dll.get_message(duel, _buffer);
Marshal.Copy(_buffer, arr, 0, 4096);
var arr = new byte[0x2000];
dll.get_message(duel, _buffer);
Marshal.Copy(_buffer, arr, 0, 0x2000);
bool breakOut = false;
MemoryStream stream = new MemoryStream(arr);
BinaryReader reader = new BinaryReader(stream);
......@@ -1051,11 +1051,11 @@ namespace Percy
move(1);
count = move(1);
move(1);
move(1);
move(4);
move(4);
for (int i = 0; i < count; i++)
{
move(1);
move(1);
move(4);
move(4);
......@@ -1091,6 +1091,7 @@ namespace Percy
move(move(1) * 7);
break;
case GameMessage.ConfirmCards:
move(1);
move(1);
move(move(1) * 7);
break;
......
......@@ -1636,12 +1636,12 @@ public class DeckManager : ServantWithCardDescription
cardInDragging.endDrag();
// 第二步:逻辑判断是否仍应纳入卡组
if (cardInDragging.getIfAlive())
if (condition == Condition.changeSide && !cardInDragging.IsInDeckArea()) { }
else if (cardInDragging.getIfAlive())
{
deckDirty = true;
}
// 第三步:整理数据结构(IMain、ISide等)
// 第三步:整理数据结构(IMain、ISide等)
ArrangeObjectDeck(true);
// 第四步:更新卡片在场景中的位置与角度(含Tween)
......
......@@ -144,6 +144,7 @@ public class selectReplay : WindowServantSP
var collection = TcpHelper.readPackagesInRecord(path);
foreach (var item in collection)
{
Debug.Log(item.Fuction);
if (item.Fuction == (int)YGOSharp.OCGWrapper.Enums.GameMessage.sibyl_replay)
{
returnValue = item.Data.reader.ReadToEnd();
......@@ -155,13 +156,7 @@ public class selectReplay : WindowServantSP
{
Debug.Log(e);
}
if (returnValue != null)
{
if (returnValue.Length < 50)
{
returnValue = null;
}
}
Debug.Log(returnValue);
return returnValue;
}
......@@ -178,6 +173,19 @@ public class selectReplay : WindowServantSP
returnValue.DataSize = reader.ReadInt32();
returnValue.Hash = reader.ReadInt32();
returnValue.Props = reader.ReadBytes(8);
if (returnValue.ID == 0x32707279) // REPLAY_ID_YRP2
{
for (int i = 0; i < 8; i++)
{
reader.ReadUInt32();
// returnValue.SeedsV2[i] = reader.ReadUInt32();
}
for (int i = 0; i < 4; i++) // other flags, unused for now
{
reader.ReadUInt32();
}
}
byte[] raw = reader.ReadToEnd();
if ((returnValue.Flag & 0x1) > 0)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment