get config

This commit is contained in:
VDH
2025-11-18 18:54:56 +07:00
parent de738b8f16
commit 8ee2477681
25 changed files with 4788 additions and 3182 deletions
@@ -44,7 +44,7 @@ namespace BrewMonster.Scripts
public static int EQUIPIVTR_GENERALCARD6 = 37;
public static int SIZE_ALL_EQUIPIVTR = 38;
public static int SIZE_GENERALCARD_EQUIPIVTR = 6; // SIZE_ALL_EQUIPIVTR - EQUIPIVTR_GENERALCARD1
// Inventory size constants
public static int IVTRSIZE_EQUIPPACK = 32; // Equipment (SIZE_ALL_EQUIPIVTR)
public static int IVTRSIZE_TASKPACK = 32; // Task pack
@@ -57,9 +57,18 @@ namespace BrewMonster.Scripts
public static int IVTRSIZE_BOOTHBPACK = 12; // Default booth pack for buying
public static int IVTRSIZE_BOOTHSPACK_MAX = 20; // Max booth pack for selling (player may use certificate...)
public static int IVTRSIZE_BOOTHBPACK_MAX = 20; // Max booth pack for buying
public static int IVTRSIZE_CLIENTCARDPACK = 32; // Client pack for general card collection
public static int NUM_NPCIVTR = 8; // NPC inventory number
}
public enum Shortcut
{
NUM_HOSTSCSETS1 = 5, // expanded from 3 to 5 (2009.05.27)
NUM_HOSTSCSETS2 = 3,
SIZE_HOSTSCSET1 = 9, // expanded from 6 to 9 (2009.05.27)
SIZE_HOSTSCSET2 = 8,
SIZE_FASHIONSCSET = 240,
};
}
@@ -105,3 +105,5 @@ namespace BrewMonster.Managers
}
+316 -314
View File
@@ -12,364 +12,366 @@ using System.Text;
using BrewMonster;
using UnityEngine;
public class CECHostMove
{
ushort m_wMoveStamp;
float m_fMoveTime;
CECHostPlayer m_pHost;
bool m_bStop;
const float MOVECMD_INTERVAL = .5f;
Vector3 m_vLastSevPos;
STOPMOVE m_DelayedStop;
ulong cmdstopdelayCounter = 500;
ulong cmdmovedelayCounter = 500;
ulong m_dwLastTime;
Vector3 m_vLastPos;
float m_fAverSpeedH;
int m_iBlockedCnt; // Move blocked counter
bool m_bSlideLock; // Locked when slide
float m_fBlockTime; // Block time counter
float m_fBlockMove; // Block move counter
A3DVECTOR3 m_vBlockMove;
bool m_bLocalMove; // true, Moving info isn't sent to server
public CECHostMove(CECHostPlayer pHost)
namespace BrewMonster {
public class CECHostMove
{
m_wMoveStamp = 0;
m_fMoveTime = 0.0f;
m_pHost = pHost;
m_bStop = false;
cmdstopdelayCounter = 500;
m_DelayedStop = new STOPMOVE();
}
ushort m_wMoveStamp;
float m_fMoveTime;
CECHostPlayer m_pHost;
bool m_bStop;
const float MOVECMD_INTERVAL = .5f;
Vector3 m_vLastSevPos;
STOPMOVE m_DelayedStop;
ulong cmdstopdelayCounter = 500;
ulong cmdmovedelayCounter = 500;
ulong m_dwLastTime;
Vector3 m_vLastPos;
float m_fAverSpeedH;
int m_iBlockedCnt; // Move blocked counter
bool m_bSlideLock; // Locked when slide
float m_fBlockTime; // Block time counter
float m_fBlockMove; // Block move counter
A3DVECTOR3 m_vBlockMove;
bool m_bLocalMove; // true, Moving info isn't sent to server
public void Tick(ulong dwDeltaTime)
{
cmdstopdelayCounter += dwDeltaTime;
cmdmovedelayCounter += dwDeltaTime;
if (cmdstopdelayCounter >= 500 && m_DelayedStop.bValid)
public CECHostMove(CECHostPlayer pHost)
{
var m = m_DelayedStop;
m_wMoveStamp = 0;
m_fMoveTime = 0.0f;
m_pHost = pHost;
m_bStop = false;
cmdstopdelayCounter = 500;
m_DelayedStop = new STOPMOVE();
}
// a_GetTime() . Environment.TickCount (ms)
ulong dwCurrent = (ulong)Mathf.RoundToInt(Time.time * 1000);
public void Tick(ulong dwDeltaTime)
{
cmdstopdelayCounter += dwDeltaTime;
cmdmovedelayCounter += dwDeltaTime;
if (cmdstopdelayCounter >= 500 && m_DelayedStop.bValid)
{
var m = m_DelayedStop;
// iTime: thời gian tích lũy (ms) + delta từ timestamp đến hiện tại
int iTime = (int)((m.fTime * 1000f)
+ ((dwCurrent > m.dwTimeStamp) ? (dwCurrent - m.dwTimeStamp) : 0));
// a_GetTime() . Environment.TickCount (ms)
ulong dwCurrent = (ulong)Mathf.RoundToInt(Time.time * 1000);
// tính tốc độ trung bình (giây = iTime * 0.001f)
float fSpeed = l_CalcAverageSpeed(m_vLastSevPos, m.vPos, iTime * 0.001f, m.fSpeed);
// iTime: thời gian tích lũy (ms) + delta từ timestamp đến hiện tại
int iTime = (int)((m.fTime * 1000f)
+ ((dwCurrent > m.dwTimeStamp) ? (dwCurrent - m.dwTimeStamp) : 0));
int iMoveMode = m.iMoveMode;
// tính tốc độ trung bình (giây = iTime * 0.001f)
float fSpeed = l_CalcAverageSpeed(m_vLastSevPos, m.vPos, iTime * 0.001f, m.fSpeed);
// make a potential check with tuojigua
int iMoveMode = m.iMoveMode;
// make a potential check with tuojigua
iMoveMode |= (int)GPMoveMode.GP_MOVE_DEAD;
UnityGameSession.Instance.c2s_SendCmdStopMove(
m.vPos, fSpeed, iMoveMode, m.byDir, m_wMoveStamp++, iTime
);
// Record this position
m_vLastSevPos = m.vPos;
Reset();
}
m_dwLastTime = Math.Max(m_dwLastTime, 1);
Vector3 vOffset = m_pHost.transform.position - m_vLastPos;
m_fAverSpeedH = EC_Utility.MagnitudeH(vOffset) * 1000.0f / m_dwLastTime;
m_vLastPos = m_pHost.transform.position;
m_dwLastTime = dwDeltaTime;
}
public void SendStopMoveCmd()
{
int iMoveMode = (int)GPMoveMode.GP_MOVE_RUN;
float fSpeed = 0f;
switch (m_pHost.GetMoveEnv())
{
case CECPlayer.Move_environment.MOVEENV_AIR:
iMoveMode |= (int)GPMoveMode.GP_MOVE_AIR;
fSpeed = m_pHost.GetFlySpeed();
break;
//case EC_Player.Move_environment.MOVEENV_WATER:
// iMoveMode |= (int)GPMoveMode.GP_MOVE_WATER;
// fSpeed = m_pHost.GetSwimSpeedSev();
// break;
default:
fSpeed = m_pHost.GetGroundSpeed();
break;
}
SendStopMoveCmd(EC_Utility.ToVector3(m_pHost.GetPos()), fSpeed, iMoveMode);
}
public void SendStopMoveCmd(in Vector3 vPos, float fSpeed, int iMoveMode)
{
Debug.LogWarning("HoangDev : SendStopMoveCmd");
iMoveMode |= (int)GPMoveMode.GP_MOVE_DEAD;
UnityGameSession.Instance.c2s_SendCmdStopMove(
m.vPos, fSpeed, iMoveMode, m.byDir, m_wMoveStamp++, iTime
);
if (cmdstopdelayCounter >= 500)
{
Vector3 vDir = m_pHost.transform.forward;
byte byDir = EC_Utility.glb_CompressDirH(vDir.x, vDir.z);
fSpeed = l_CalcAverageSpeed(m_vLastSevPos, vPos, m_fMoveTime, fSpeed);
int iTime = (int)(m_fMoveTime * 1000);
// Record this position
m_vLastSevPos = m.vPos;
UnityGameSession.Instance.c2s_SendCmdStopMove(vPos, fSpeed, iMoveMode, byDir, m_wMoveStamp++, iTime);
Reset();
m_vLastSevPos = vPos;
Reset();
}
else
{
Vector3 vDir = m_pHost.transform.forward;
byte byDir = EC_Utility.glb_CompressDirH(vDir.x, vDir.z);
if (!m_DelayedStop.bValid)
{
m_DelayedStop.dwTimeStamp = (ulong)Mathf.RoundToInt(Time.time * 1000);
m_DelayedStop.fTime = m_fMoveTime;
}
m_DelayedStop.bValid = true;
m_DelayedStop.byDir = byDir;
m_DelayedStop.vPos = vPos;
m_DelayedStop.iMoveMode = iMoveMode;
m_DelayedStop.fSpeed = fSpeed;
}
m_fMoveTime = 0.0f;
}
public void SendMoveCmd(in Vector3 vCurPos, in Vector3 vVel, int iMoveMode, bool bForceSend = false)
{
Vector3 vMoveDir = vVel;
float fSpeed = vMoveDir.magnitude;
SendMoveCmd(vCurPos, fSpeed, iMoveMode, bForceSend);
}
m_dwLastTime = Math.Max(m_dwLastTime, 1);
Vector3 vOffset = m_pHost.transform.position - m_vLastPos;
m_fAverSpeedH = EC_Utility.MagnitudeH(vOffset) * 1000.0f / m_dwLastTime;
m_vLastPos = m_pHost.transform.position;
m_dwLastTime = dwDeltaTime;
}
public void SendStopMoveCmd()
{
int iMoveMode = (int)GPMoveMode.GP_MOVE_RUN;
float fSpeed = 0f;
switch (m_pHost.GetMoveEnv())
public void SendMoveCmd(A3DVECTOR3 vCurPos, int iDestType, A3DVECTOR3 vDest, A3DVECTOR3 vVel, int iMoveMode, bool bForceSend = false)
{
case CECPlayer.Move_environment.MOVEENV_AIR:
iMoveMode |= (int)GPMoveMode.GP_MOVE_AIR;
fSpeed = m_pHost.GetFlySpeed();
break;
//case EC_Player.Move_environment.MOVEENV_WATER:
// iMoveMode |= (int)GPMoveMode.GP_MOVE_WATER;
// fSpeed = m_pHost.GetSwimSpeedSev();
// break;
default:
fSpeed = m_pHost.GetGroundSpeed();
break;
A3DVECTOR3 vMoveDir = vVel;
float fSpeed = vMoveDir.Normalize();
SendMoveCmd(vCurPos, iDestType, vDest, vMoveDir, fSpeed, iMoveMode, bForceSend);
}
SendStopMoveCmd(EC_Utility.ToVector3(m_pHost.GetPos()), fSpeed, iMoveMode);
}
public void SendStopMoveCmd(in Vector3 vPos, float fSpeed, int iMoveMode)
{
Debug.LogWarning("HoangDev : SendStopMoveCmd");
iMoveMode |= (int)GPMoveMode.GP_MOVE_DEAD;
void SendMoveCmd(A3DVECTOR3 vCurPos, int iDestType, A3DVECTOR3 vDest,
A3DVECTOR3 vMoveDir, float fSpeed, int iMoveMode, bool bForceSend)
if (cmdstopdelayCounter >= 500)
{
Vector3 vDir = m_pHost.transform.forward;
byte byDir = EC_Utility.glb_CompressDirH(vDir.x, vDir.z);
fSpeed = l_CalcAverageSpeed(m_vLastSevPos, vPos, m_fMoveTime, fSpeed);
Vector3 pos = new Vector3(vCurPos.x, vCurPos.y, vCurPos.z);
SendMoveCmd(pos, fSpeed, iMoveMode, bForceSend);
}
void SendMoveCmd(in Vector3 vCurPos,
float fSpeed, int iMoveMode, bool bForceSend)
{
if (m_bStop)
{
// m_CmdTimeCnt.Reset();
cmdmovedelayCounter = (ulong)(m_fMoveTime * 1000);
m_bStop = false;
}
if (!bForceSend && cmdmovedelayCounter < 500)
return;
int iTime = (int)(m_fMoveTime * 1000);
UnityGameSession.Instance.c2s_SendCmdStopMove(vPos, fSpeed, iMoveMode, byDir, m_wMoveStamp++, iTime);
m_vLastSevPos = vPos;
Reset();
}
else
{
Vector3 vDir = m_pHost.transform.forward;
byte byDir = EC_Utility.glb_CompressDirH(vDir.x, vDir.z);
if (!m_DelayedStop.bValid)
if (iTime < 200)
{
m_DelayedStop.dwTimeStamp = (ulong)Mathf.RoundToInt(Time.time * 1000);
m_DelayedStop.fTime = m_fMoveTime;
if (iTime == 0 || !bForceSend)
{
// if time is too little, wait again
cmdmovedelayCounter = (ulong)(iTime);
return;
}
}
m_DelayedStop.bValid = true;
m_DelayedStop.byDir = byDir;
m_DelayedStop.vPos = vPos;
m_DelayedStop.iMoveMode = iMoveMode;
m_DelayedStop.fSpeed = fSpeed;
cmdmovedelayCounter = 0;
m_DelayedStop.bValid = false;
fSpeed = l_CalcAverageSpeed(m_vLastSevPos, vCurPos, m_fMoveTime, fSpeed);
m_fMoveTime = 0.0f;
iMoveMode |= (int)GPMoveMode.GP_MOVE_DEAD;
UnityGameSession.Instance.c2s_CmdPlayerMove(vCurPos, vCurPos, iTime/* MOVECMD_INTERVAL */, fSpeed, iMoveMode, m_wMoveStamp++);
m_vLastSevPos = vCurPos;
}
m_fMoveTime = 0.0f;
}
public void SendMoveCmd(in Vector3 vCurPos, in Vector3 vVel, int iMoveMode, bool bForceSend = false)
{
Vector3 vMoveDir = vVel;
float fSpeed = vMoveDir.magnitude;
SendMoveCmd(vCurPos, fSpeed, iMoveMode, bForceSend);
}
public void SendMoveCmd(A3DVECTOR3 vCurPos, int iDestType, A3DVECTOR3 vDest, A3DVECTOR3 vVel, int iMoveMode, bool bForceSend = false)
{
A3DVECTOR3 vMoveDir = vVel;
float fSpeed = vMoveDir.Normalize();
SendMoveCmd(vCurPos, iDestType, vDest, vMoveDir, fSpeed, iMoveMode, bForceSend);
}
void SendMoveCmd(A3DVECTOR3 vCurPos, int iDestType, A3DVECTOR3 vDest,
A3DVECTOR3 vMoveDir, float fSpeed, int iMoveMode, bool bForceSend)
{
Vector3 pos = new Vector3(vCurPos.x, vCurPos.y, vCurPos.z);
SendMoveCmd(pos, fSpeed, iMoveMode, bForceSend);
}
void SendMoveCmd(in Vector3 vCurPos,
float fSpeed, int iMoveMode, bool bForceSend)
{
if (m_bStop)
float l_CalcAverageSpeed(in Vector3 p1, in Vector3 p2, float fTime, float fDefSpeed)
{
// m_CmdTimeCnt.Reset();
cmdmovedelayCounter = (ulong)(m_fMoveTime * 1000);
m_bStop = false;
}
if (!bForceSend && cmdmovedelayCounter < 500)
return;
if (Mathf.Approximately(fTime, 0f))
return fDefSpeed;
int iTime = (int)(m_fMoveTime * 1000);
Vector3 d = p2 - p1;
float fSpeed = d.magnitude / fTime;
if (iTime < 200)
{
if (iTime == 0 || !bForceSend)
if (fTime < 0.05f || fSpeed > 50.0f)
{
// if time is too little, wait again
cmdmovedelayCounter = (ulong)(iTime);
return;
}
}
cmdmovedelayCounter = 0;
m_DelayedStop.bValid = false;
fSpeed = l_CalcAverageSpeed(m_vLastSevPos, vCurPos, m_fMoveTime, fSpeed);
m_fMoveTime = 0.0f;
iMoveMode |= (int)GPMoveMode.GP_MOVE_DEAD;
UnityGameSession.Instance.c2s_CmdPlayerMove(vCurPos, vCurPos, iTime/* MOVECMD_INTERVAL */, fSpeed, iMoveMode, m_wMoveStamp++);
m_vLastSevPos = vCurPos;
}
float l_CalcAverageSpeed(in Vector3 p1, in Vector3 p2, float fTime, float fDefSpeed)
{
if (Mathf.Approximately(fTime, 0f))
return fDefSpeed;
Vector3 d = p2 - p1;
float fSpeed = d.magnitude / fTime;
if (fTime < 0.05f || fSpeed > 50.0f)
{
// tương đương ASSERT(0) trong C++, ở đây có thể Debug.LogWarning
Debug.LogWarning("CalcAverageSpeed: invalid input, fallback to default speed.");
return fDefSpeed;
}
return fSpeed;
}
private void Reset()
{
cmdstopdelayCounter = 0;
m_bStop = true;
m_fBlockTime = 0.0f;
m_fBlockMove = 0.0f;
m_DelayedStop.bValid = false;
}
public void GroundMove(float ftime)
{
m_fMoveTime += ftime;
}
struct STOPMOVE
{
public bool bValid; // Valid flag
public Vector3 vPos;
public float fSpeed;
public int iMoveMode;
public byte byDir;
public ulong dwTimeStamp;
public float fTime;
};
// Check whether host meet a slope
// vMoveDirH: normalized horizontal moving direction
// fMaxSpeed (out): maximum vertical speed
public bool MeetSlope(A3DVECTOR3 vMoveDirH, float fMaxSpeedV)
{
A3DVECTOR3 vTangent = m_pHost.m_GndInfo.vGndNormal;
float d = vTangent.MagnitudeH();
float tan = d / (float)Math.Abs(vTangent.y);
float max = m_pHost.GetGroundSpeed() * tan * 0.96f;
// Prevent max is too small, tan60 = 1.732
EC_Utility.a_ClampFloor(max, m_pHost.GetGroundSpeed() * 1.732f);
fMaxSpeedV = EC_Utility.a_Min(max, 19.5f);
// fMaxSpeedV = 100.0f;
vTangent.y = 0.0f;
vTangent.Normalize();
if (A3DVECTOR3.DotProduct(vMoveDirH, vTangent) <= -0.85f)
return true;
return false;
}
public A3DVECTOR3 GroundMove(A3DVECTOR3 vDirH, float fSpeedH, float fTime, float fSpeedV = 0f, float fGravity = 9.8f)
{
A3DVECTOR3 vRealDirH = vDirH;
if (Math.Abs(vRealDirH.y) > 0.0001)
{
vRealDirH.y = 0.0f;
vRealDirH.Normalize();
}
// OnGroundMove only accept positive speed value
if (fSpeedH < 0.0f)
{
vRealDirH = -vDirH;
fSpeedH = -fSpeedH;
}
//int idInst = g_pGame.GetGameRun().GetWorld().GetInstanceID();
//CECInstance pInstance = g_pGame.GetGameRun().GetInstance(idInst);
//if (pInstance.GetLimitJump())
//fGravity *= 4.0f;
CDR_INFO cdr = m_pHost.m_CDRInfo;
var pos = m_pHost.m_aabbServer.Center;
cdr.vCenter = new Vector3(pos.x, pos.y, pos.z);
cdr.vXOZVelDir = new Vector3(vRealDirH.x, vRealDirH.y, vRealDirH.z);
cdr.fSpeed = fSpeedH;
cdr.t = fTime;
cdr.fGravityAccel = fGravity;
cdr.fYVel += fSpeedV;
EC_CDR.OnGroundMove(ref cdr);
//if (g_pGame.GetGameRun().GetWorld().GetAssureMove())
// g_pGame.GetGameRun().GetWorld().GetAssureMove().AssureMove(m_pHost.m_aabbServer.Center, cdr.vCenter);
if (cdr.vTPNormal != Vector3.zero)
m_pHost.SetGroundNormal(new A3DVECTOR3(cdr.vTPNormal.x, cdr.vTPNormal.y, cdr.vTPNormal.z));
else
m_pHost.SetGroundNormal(GPDataTypeHelper.g_vAxisY);
A3DVECTOR3 vNewPos = new A3DVECTOR3(cdr.vCenter.x, cdr.vCenter.y, cdr.vCenter.z) - GPDataTypeHelper.g_vAxisY * m_pHost.m_aabbServer.Extents.y;
m_iBlockedCnt = 0;
m_fBlockMove += (vNewPos - m_pHost.GetPos()).Magnitude();
m_vBlockMove += vNewPos - m_pHost.GetPos();
if ((m_fBlockTime += fTime) >= 1.0f)
{
if (m_fBlockMove < GPDataTypeHelper.MIN_MOVELEN_ON_GROUND || m_vBlockMove.Magnitude() < GPDataTypeHelper.MIN_MOVELEN_FOR_DETECT_VIBRATION)
{
m_iBlockedCnt = 5;
// tương đương ASSERT(0) trong C++, ở đây có thể Debug.LogWarning
Debug.LogWarning("CalcAverageSpeed: invalid input, fallback to default speed.");
return fDefSpeed;
}
return fSpeed;
}
private void Reset()
{
cmdstopdelayCounter = 0;
m_bStop = true;
m_fBlockTime = 0.0f;
m_fBlockMove = 0.0f;
m_vBlockMove.Clear();
m_DelayedStop.bValid = false;
}
m_fMoveTime += fTime;
m_pHost.m_CDRInfo.vTPNormal = cdr.vTPNormal;
return vNewPos;
public void GroundMove(float ftime)
{
m_fMoveTime += ftime;
}
struct STOPMOVE
{
public bool bValid; // Valid flag
public Vector3 vPos;
public float fSpeed;
public int iMoveMode;
public byte byDir;
public ulong dwTimeStamp;
public float fTime;
};
// Check whether host meet a slope
// vMoveDirH: normalized horizontal moving direction
// fMaxSpeed (out): maximum vertical speed
public bool MeetSlope(A3DVECTOR3 vMoveDirH, float fMaxSpeedV)
{
A3DVECTOR3 vTangent = m_pHost.m_GndInfo.vGndNormal;
float d = vTangent.MagnitudeH();
float tan = d / (float)Math.Abs(vTangent.y);
float max = m_pHost.GetGroundSpeed() * tan * 0.96f;
// Prevent max is too small, tan60 = 1.732
EC_Utility.a_ClampFloor(max, m_pHost.GetGroundSpeed() * 1.732f);
fMaxSpeedV = EC_Utility.a_Min(max, 19.5f);
// fMaxSpeedV = 100.0f;
vTangent.y = 0.0f;
vTangent.Normalize();
if (A3DVECTOR3.DotProduct(vMoveDirH, vTangent) <= -0.85f)
return true;
return false;
}
public A3DVECTOR3 GroundMove(A3DVECTOR3 vDirH, float fSpeedH, float fTime, float fSpeedV = 0f, float fGravity = 9.8f)
{
A3DVECTOR3 vRealDirH = vDirH;
if (Math.Abs(vRealDirH.y) > 0.0001)
{
vRealDirH.y = 0.0f;
vRealDirH.Normalize();
}
// OnGroundMove only accept positive speed value
if (fSpeedH < 0.0f)
{
vRealDirH = -vDirH;
fSpeedH = -fSpeedH;
}
//int idInst = g_pGame.GetGameRun().GetWorld().GetInstanceID();
//CECInstance pInstance = g_pGame.GetGameRun().GetInstance(idInst);
//if (pInstance.GetLimitJump())
//fGravity *= 4.0f;
CDR_INFO cdr = m_pHost.m_CDRInfo;
var pos = m_pHost.m_aabbServer.Center;
cdr.vCenter = new Vector3(pos.x, pos.y, pos.z);
cdr.vXOZVelDir = new Vector3(vRealDirH.x, vRealDirH.y, vRealDirH.z);
cdr.fSpeed = fSpeedH;
cdr.t = fTime;
cdr.fGravityAccel = fGravity;
cdr.fYVel += fSpeedV;
EC_CDR.OnGroundMove(ref cdr);
//if (g_pGame.GetGameRun().GetWorld().GetAssureMove())
// g_pGame.GetGameRun().GetWorld().GetAssureMove().AssureMove(m_pHost.m_aabbServer.Center, cdr.vCenter);
if (cdr.vTPNormal != Vector3.zero)
m_pHost.SetGroundNormal(new A3DVECTOR3(cdr.vTPNormal.x, cdr.vTPNormal.y, cdr.vTPNormal.z));
else
m_pHost.SetGroundNormal(GPDataTypeHelper.g_vAxisY);
A3DVECTOR3 vNewPos = new A3DVECTOR3(cdr.vCenter.x, cdr.vCenter.y, cdr.vCenter.z) - GPDataTypeHelper.g_vAxisY * m_pHost.m_aabbServer.Extents.y;
m_iBlockedCnt = 0;
m_fBlockMove += (vNewPos - m_pHost.GetPos()).Magnitude();
m_vBlockMove += vNewPos - m_pHost.GetPos();
if ((m_fBlockTime += fTime) >= 1.0f)
{
if (m_fBlockMove < GPDataTypeHelper.MIN_MOVELEN_ON_GROUND || m_vBlockMove.Magnitude() < GPDataTypeHelper.MIN_MOVELEN_FOR_DETECT_VIBRATION)
{
m_iBlockedCnt = 5;
}
m_fBlockTime = 0.0f;
m_fBlockMove = 0.0f;
m_vBlockMove.Clear();
}
m_fMoveTime += fTime;
m_pHost.m_CDRInfo.vTPNormal = cdr.vTPNormal;
return vNewPos;
}
public int MoveBlocked() { return m_iBlockedCnt; }
public void SetSlideLock(bool bLock) { m_bSlideLock = bLock; }
// Is stoping ?
public bool IsStop() { return m_bStop; }
}
public struct CDR_INFO
{
//the aabb
public Vector3 vCenter;
//@note : the caller should make sure ext(.x, .y, .z) > 0. By Kuiwu[22/9/2005]
public Vector3 vExtent;
public int MoveBlocked() { return m_iBlockedCnt; }
public void SetSlideLock(bool bLock) { m_bSlideLock = bLock; }
// Is stoping ?
public bool IsStop() { return m_bStop; }
}
public struct CDR_INFO
{
//the aabb
public Vector3 vCenter;
//@note : the caller should make sure ext(.x, .y, .z) > 0. By Kuiwu[22/9/2005]
public Vector3 vExtent;
public float fStepHeight;
public float fStepHeight;
// Velocity Info
public Vector3 vXOZVelDir;
public float fYVel;
public float fSpeed;
// Velocity Info
public Vector3 vXOZVelDir;
public float fYVel;
public float fSpeed;
// time span ( sec )
public float t;
// time span ( sec )
public float t;
// Gravity acceleration
public float fGravityAccel;
// Gravity acceleration
public float fGravityAccel;
// the Climb Slope Thresh
public float fSlopeThresh;
// the Climb Slope Thresh
public float fSlopeThresh;
// Tangent plane Info
public Vector3 vTPNormal;
// Tangent plane Info
public Vector3 vTPNormal;
// Absolute Velocity: output for forcast!
public Vector3 vAbsVelocity;
// Absolute Velocity: output for forcast!
public Vector3 vAbsVelocity;
//the moving dist
public float fMoveDist;
};
//the moving dist
public float fMoveDist;
};
}
@@ -1,5 +1,7 @@
using BrewMonster;
using BrewMonster.Assets.PerfectWorld.Scripts.UI;
using BrewMonster.Managers;
using BrewMonster.Network;
using BrewMonster.Scripts.Player;
using BrewMonster.Scripts.Skills;
using CSNetwork.C2SCommand;
@@ -354,6 +356,7 @@ namespace CSNetwork
case ProtocolType.PROTOCOL_PLAYERBASEINFO_RE:
OnPrtcPlayerBaseInfoRe(protocol);
break;
case ProtocolType.PROTOCOL_GETUICONFIG_RE: OnPrtcGetConfigRe(protocol); break;
default:
_logger.Log(LogType.Warning, $"Received unhandled protocol type: {protocol.GetPType()}");
break;
@@ -682,14 +685,14 @@ namespace CSNetwork
break;
}
case CommandID.LEVEL_UP:
{
cmd_level_up pCmdLevelUp = GPDataTypeHelper.FromBytes<cmd_level_up>(pDataBuf);;
if (ISPLAYERID(pCmdLevelUp.id))
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERLEVELUP, MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader);
else if (ISNPCID(pCmdLevelUp.id))
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCLEVELUP, MANAGER_INDEX.MAN_NPC, 0, pDataBuf, pCmdHeader);
break;
}
{
cmd_level_up pCmdLevelUp = GPDataTypeHelper.FromBytes<cmd_level_up>(pDataBuf); ;
if (ISPLAYERID(pCmdLevelUp.id))
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERLEVELUP, MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader);
else if (ISNPCID(pCmdLevelUp.id))
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCLEVELUP, MANAGER_INDEX.MAN_NPC, 0, pDataBuf, pCmdHeader);
break;
}
}
}
@@ -962,7 +965,12 @@ namespace CSNetwork
_logger.Log(LogType.Warning, $"HoangDev : publicChat {publicChat}");
SendProtocol(publicChat);
}
public void LoadConfigData()
{
getuiconfig p = new getuiconfig();
p.Roleid = m_iCharID;
SendProtocol(p);
}
private void SetCharacterID(int iCharID)
{
m_iCharID = iCharID;
@@ -987,7 +995,68 @@ namespace CSNetwork
this.context = context;
}
}
public void OnPrtcGetConfigRe(Protocol pProtocol)
{
getuiconfig_re p = (getuiconfig_re)pProtocol;
if (p.Result != (int)ErrCode.ERR_SUCCESS)
BMLogger.LogError("CECGameSession::OnPrtcGetConfigRe, link return error code of " + p.Result);
else
{
if (!EC_Game.GetGameRun().LoadConfigsFromServer(p.UiConfig.RawBuffer, p.UiConfig.Size))
{
// if load failed then use current setting directly
//TODO : fix later
//g_pGame.GetConfigs().ApplyUserSetting();
}
// Now, Get config data request is sent after all host initial data ready.
// so when we receive this reply, we can do some last work before game
// really starts. Maybe it's not the best place to do these work, but
// now we do it here.
// Enalbe game UI
//CECGameUIMan* pGameUI = (CECGameUIMan*)g_pGame->GetGameRun()->GetUIManager()->GetInGameUIMan();
//if (pGameUI)
//{
// pGameUI->EnableUI(true);
// // Get referral name for adding friend or other display
// RoleInfo info = g_pGame->GetGameRun()->GetSelectedRoleInfo();
// if (info.referrer_role > 0)
// GetPlayerBriefInfo(1, &info.referrer_role, 2);
//}
//CECHostPlayer* pHost = g_pGame->GetGameRun()->GetHostPlayer();
//pHost->OnAllInitDataReady();
//if (pHost->IsGM())
//{
// CDlgCountryMap* pDlgCountryMap = (CDlgCountryMap*)pGameUI->GetDialog("Win_CountryMap");
// pDlgCountryMap->GetConfig();
//}
//g_pGame->GetConfigs()->ApplyOptimizeSetting();
//if (g_pGame->GetConfigs()->IsMiniClient())
// CECMCDownload::GetInstance().SendGetDownloadOK();
// if (g_pGame->GetConfigs()->IsSendLogicCheckInfo()){
// // Ïò·þÎñÆ÷·¢ËÍ»úÆ÷ʶ±ðÂë
// LogicHelp::LogicCheck logicChecker;
// unsigned char buffer[1024] = {0};
// int actualSize = logicChecker.ReceiveMessage(buffer, sizeof(buffer)/sizeof(buffer[0]));
// if (actualSize <= 0){
//#ifdef LOG_PROTOCOL
// a_LogOutput(1, "LogicHelp::LogicCheck ReceiveMessage returns %d", actualSize);
//#endif
// }else{
//#ifdef LOG_PROTOCOL
// a_LogOutput(1, "LogicHelp::LogicCheck ReceiveMessage returns %d bytes:%s", actualSize, glb_FormatOctets(Octets(buffer, actualSize)));
//#endif
// sendClientMachineInfo(buffer, actualSize);
// }
// }
}
}
private void OnPrtcPlayerBaseInfoRe(Protocol pProtocol)
{
playerbaseinfo_re p = (playerbaseinfo_re)pProtocol;
@@ -1060,16 +1129,16 @@ namespace CSNetwork
int iNumSend = iNumLimit;
if (iCount + iNumLimit > iNumRole)
iNumSend = iNumRole - iCount;
if (iNumSend > 0)
{
p.playerList = new();
for (int i = 0; i < iNumSend; i++)
p.playerList.Add(aRoleIDs[iCount + i]);
p.playerList.Add(aRoleIDs[iCount + i]);
SendProtocol(p);
}
iCount += iNumSend;
}
@@ -1085,7 +1154,7 @@ namespace CSNetwork
// int iNumSend = iNumLimit;
// if (iCount + iNumLimit > iNumID)
// iNumSend = iNumID - iCount;
// if (iNumSend > 0)
// {
// }
@@ -1095,7 +1164,7 @@ namespace CSNetwork
public void GetRoleCustomizeData(int iNumRole, List<int> aRoleIDs)
{
if (iNumRole <= 0 || aRoleIDs == null || aRoleIDs.Count == 0) return;
int iNumLimit = 240;
int iCount = 0;
@@ -1108,8 +1177,8 @@ namespace CSNetwork
if (iCount + iNumLimit > iNumRole)
iNumSend = iNumRole - iCount;
for (int i=0; i < iNumSend; i++)
p.playerlist.Add(aRoleIDs[iCount+i]);
for (int i = 0; i < iNumSend; i++)
p.playerlist.Add(aRoleIDs[iCount + i]);
SendProtocol(p);
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
namespace CSNetwork.Protocols
{
public class getuiconfig_re : Protocol
{
public int Result { get; set; }
public int Roleid { get; set; }
public int Localsid { get; set; }
public Octets UiConfig { get; set; }
public getuiconfig_re() : base(ProtocolType.PROTOCOL_GETUICONFIG_RE)
{
UiConfig = new Octets();
}
public override Protocol Clone() => new getuiconfig_re
{
Result = Result,
Roleid = Roleid,
Localsid = Localsid,
UiConfig = UiConfig
};
public override void Marshal(OctetsStream os)
{
os.Write(Result);
os.Write(Roleid);
os.Write(Localsid);
os.Write(UiConfig);
}
public override void Unmarshal(OctetsStream os)
{
Result = os.ReadInt32();
Roleid = os.ReadInt32();
Localsid = os.ReadInt32();
UiConfig = os.ReadOctets();
}
public override int PriorPolicy() => 1;
public override bool SizePolicy(int size) => size <= 4096;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2f1504051817c6c4486bc9ea6123022f
@@ -0,0 +1,198 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BrewMonster
{
enum ErrCode
{
ERR_SUCCESS = 0, //³É¹¦
ERR_TOBECONTINUE = 1, //³É¹¦£¬²¢ÇÒ»¹Óиü¶àÊý¾Ýδ´«µÝÍ꣬ĿǰδÓÃ
ERR_INVALID_ACCOUNT = 2, //ÕʺŲ»´æÔÚ
ERR_INVALID_PASSWORD = 3, //ÃÜÂë´íÎó
ERR_TIMEOUT = 4, //³¬Ê±
ERR_INVALID_ARGUMENT = 5, //²ÎÊý´íÎó
ERR_FRIEND_SYNCHRONIZE = 6, //ºÃÓÑÐÅÏ¢±£´æµ½Êý¾Ý¿âʱÎÞ·¨Í¬²½
ERR_SERVERNOTSUPPLY = 7, //¸Ã·þÎñÆ÷²»Ö§³Ö¸ÃÇëÇó
ERR_COMMUNICATION = 8, //ÍøÂçͨѶ´íÎó
ERR_ACCOUNTLOCKED = 9, //¶à´ÎÖØ¸´µÇ½£¬µ±Ç°Óû§µÄÒ»¸öµÇ½ÕýÔÚ±»´¦Àí£¬´¦ÓÚËø¶¨×´Ì¬
ERR_MULTILOGIN = 10, //¶à´ÎÖØ¸´µÇ½£¬ÇÒÓû§Ñ¡Ôñ×Ô¶¯ÏÂÏß
// keyexchange
ERR_INVALID_NONCE = 11, //ÎÞЧµÄnonceÖµ
// deliver use
ERR_DELIVER_SEND = 21, //ת·¢Ê§°Ü
ERR_DELIVER_TIMEOUT = 22, //ת·¢³¬Ê±
//player login
ERR_LOGINFAIL = 31, //µÇ½ÓÎϷʧ°Ü
ERR_KICKOUT = 32, //±»ÌßÏÂÏß
ERR_CREATEROLE = 33, //´´½¨½Çɫʧ°Ü
ERR_DELETEROLE = 34, //ɾ³ý½Çɫʧ°Ü
ERR_ROLELIST = 35, //»ñµÃ½ÇÉ«Áбíʧ°Ü
ERR_UNDODELROLE = 36, //³·Ïúɾ³ý½Çɫʧ°Ü
ERR_LINKISFULL = 39, //·þÎñÆ÷ÈËÊýÒÑÂú
//add friend
ERR_ADDFRD_REQUEST = 51, //ÇëÇó¼ÓΪºÃÓÑ
ERR_ADDFRD_REFUSE = 52, //¾Ü¾ø¼ÓΪºÃÓÑ
ERR_ADDFRD_AGREE = 53, //ͬÒâ¼ÓΪºÃÓÑ
ERR_ADDFRD_AGREEANDADD = 54, //ͬÒⲢϣÍû½«¶Ô·½¼ÓΪºÃÓÑ
//QQ DB retcode
ERR_FAILED = 41,
ERR_EXCEPTION = 42,
ERR_NOTFOUND = 43,
ERR_INVALIDHANDLE = 44,
ERR_DUPLICATRECORD = 45,
ERR_NOFREESPACE = 46,
//game DB
ERR_DATANOTFIND = 60, //Êý¾Ý²»´æÔÚ
ERR_GENERAL = 61,
ERR_ERR_UNAVAILABLE = 65, //ÒÑ»éÈËÊ¿²»ÄÜɾ³ý½ÇÉ«
//faction error code (101-200)
ERR_FC_NETWORKERR = 101, //·þÎñÆ÷ÍøÂçͨѶ´íÎó
ERR_FC_INVALID_OPERATION = 102, //ÎÞЧµÄ²Ù×÷ÀàÐÍ
ERR_FC_OP_TIMEOUT = 103, //²Ù×÷³¬Ê±
ERR_FC_CREATE_ALREADY = 104, //Íæ¼ÒÒѾ­ÊÇij¸ö°ïÅɵijÉÔ±£¬²»ÄÜÔÙ´´½¨°ïÅÉ
ERR_FC_CREATE_DUP = 105, //°ïÅÉÃû³ÆÖظ´
ERR_FC_DBFAILURE = 106, //Êý¾Ý¿âIO´íÎó
ERR_FC_NO_PRIVILEGE = 107, //ûÓÐÏà¹Ø²Ù×÷µÄȨÏÞ
ERR_FC_INVALIDNAME = 108, //²»ÄÜʹÓôËÃû³Æ
ERR_FC_FULL = 109, //ÈËÊýÒÑ´ïÉÏÏÞ
ERR_FC_APPLY_REJOIN = 110, //ÒѾ­ÊÇij¸ö°ïÅɵijÉÔ±£¬ÉêÇëʧ°Ü
ERR_FC_JOIN_SUCCESS = 111, //³É¹¦¼ÓÈë°ïÅÉ
ERR_FC_JOIN_REFUSE = 112, //ÉêÇë±»¾Ü¾ø
ERR_FC_ACCEPT_REACCEPT = 113, //±»Åú×¼¼ÓÈë°ïÅɵÄÍæ¼ÒÒѾ­¼ÓÈë°ïÅÉ
ERR_FC_FACTION_NOTEXIST = 114, //°ïÅɲ»´æÔÚorÍæ¼ÒûÓÐÉêÇë¹ý¼ÓÈë±¾°ïÅÉ
ERR_FC_NOTAMEMBER = 115, //Íæ¼Ò²»ÊDZ¾°ïÅɵİïÖÚ
ERR_FC_CHECKCONDITION = 116, //²»Âú×ã²Ù×÷Ìõ¼þ£¬ÈçSP²»¹»£¬×ʽ𲻹»
ERR_FC_DATAERROR = 117, //²Ù×÷²ÎÊýÀàÐÍ´íÎ󣬿ͻ§¶ËÌá½»µÄ²Ù×÷²ÎÊý¸ñʽ´íÎó
ERR_FC_OFFLINE = 118, //Íæ¼Ò²»ÔÚÏß
ERR_FC_INVALID_IN_PVP = 441, //°ïÅÉ¿ªÆôÂÓ¶áģʽÆÚ¼ä²»ÄܽøÐиòÙ×÷
//ÁÄÌìÊÒ´íÎó´úÂë
ERR_CHAT_CREATE_FAILED = 151, //´´½¨Ê§°Ü
ERR_CHAT_INVALID_SUBJECT = 152, //·Ç·¨Ö÷Ìâ
ERR_CHAT_ROOM_NOT_FOUND = 153, //ÁÄÌìÊÒ²»´æÔÚ
ERR_CHAT_JOIN_REFUSED = 154, //¼ÓÈëÇëÇ󱻾ܾø
ERR_CHAT_INVITE_REFUSED = 155, //ÁÄÌìÑûÇë±»¾Ü¾ø
ERR_CHAT_INVALID_PASSWORD = 156, //ÁÄÌìÊÒÃÜÂë´íÎó
ERR_CHAT_INVALID_ROLE = 157, //½ÇɫδÕÒµ½
ERR_CHAT_PERMISSION_DENY = 158, //ûÓÐȨÏÞ
ERR_CHAT_EXCESSIVE = 159, //¼ÓÈëÁÄÌìÊÒ¹ý¶à
ERR_CHAT_ROOM_FULL = 160, //ÈËÊýÒÑ´ïÉÏÏÞ
ERR_CHAT_SEND_FAILURE = 161, //·¢ËÍʧ°Ü
//ÓÊÏäϵͳ´íÎó´úÂë
ERR_MS_DBSVR_INV = 211, //Êý¾Ý¿â·þÎñ²»¿ÉÁ¬½Ó
ERR_MS_MAIL_INV = 212, //Óʼþ²»´æÔÚ
ERR_MS_ATTACH_INV = 213, //´íÎóµÄ¸½¼þÐÅÏ¢
ERR_MS_SEND_SELF = 214, //½ûÖ¹¸ø×Ô¼º·¢ËÍÓʼþ
ERR_MS_ACCOUNTFROZEN = 215, //Ä¿±êÓÊÏäÒѾ­¶³½á
ERR_MS_AGAIN = 216, //ÓÊÏä·þÎñÔÝʱ²»¿ÉÓÃ
ERR_MS_BOXFULL = 217, //Ä¿±êÓÊÏäÒÑÂú
//ÅÄÂô´íÎó´úÂë
ERR_AS_MAILBOXFULL = 220, //Íæ¼ÒÐÅÏäÎÞÊ£Óà¿Õ¼ä
ERR_AS_ITEM_INV = 221, //´íÎóµÄÅÄÂôÎïÆ·ÐÅÏ¢
ERR_AS_MARKET_UNOPEN = 222, //ÅÄÂô³¡Î´¿ª·Å£¨Î´Íê³É³õʼ»¯£©
ERR_AS_ID_EXHAUSE = 223, //ÅÄÂôºÅÓþ¡
ERR_AS_ATTEND_OVF = 224, //²ÎÓëµÄÅÄÂôÊý´ïµ½ÉÏÏÞ
ERR_AS_BID_LOWBID = 225, //³ö¼Û¹ýµÍ¾ºÅÄʧ°Ü
ERR_AS_BID_NOTFOUND = 226, //δÕÒµ½¸ÃÅÄÂôʼþ
ERR_AS_BID_BINSUCCESS = 227, //Ò»¿Ú¼ÛÂò¶Ï
ERR_AS_BID_UNREDEEMABLE = 228, //²»ÄÜÊê»Ø
ERR_AS_BID_INVALIDPRICE = 229, //¾º¼ÛÔö·ù³¬¹ýϵͳÔÊÐí°²È«É趨£¬Çë¼ì²éÊäÈë¼Û¸ñ
ERR_SP_NOT_INIT = 231, //ϵͳûÓгõʼ»¯Íê³É
ERR_SP_SPARETIME = 232, //Ê£Óàʱ¼ä²»Âú×ã¹ÒÊÛÌõ¼þ
ERR_SP_INVA_POINT = 233, //ÎÞЧµÄ¹ÒÊÛµãÊý£¬±ØÐëÊÇ30ÔªµÄÕûÊý±¶
ERR_SP_EXPIRED = 234, //¸Ãµã¿¨ÒѾ­¹ýÆÚ
ERR_SP_NOMONEY = 237, //ÐéÄâ±Ò²»×ã
ERR_SP_SELLING = 239, //µã¿¨ÒѾ­´¦ÓÚÏúÊÛ״̬
ERR_SP_MONEYEXCEED = 242, //½ðÇ®Êý´ïµ½ÉÏÏÞ
ERR_SP_BUYSELF = 243, //²»ÄܹºÂò×Ô¼º¹ÒÊ۵ĵ㿨
ERR_SP_EXCESS = 245, //½ûÖ¹¹ý¶È½»Ò׳´Âôµã¿¨
//³ÇÕ½´íÎó´úÂë
ERR_BS_INVALIDROLE = 260, //½ÇÉ«Éí·Ý²»·ûºÏ
ERR_BS_FAILED = 261, //¾º¼Ûʧ°Ü
ERR_BS_OUTOFSERVICE = 262, //³ÇÕ½·þÎñÔÝʱ²»¿ÉÓÃ
ERR_BS_NEWBIE_BANNED = 263, //¼ÓÈë°ïÅÉ72СʱÄÚ²»ÔÊÐí½øÈë³ÇÕ½
//ÏßÉÏÍÆ¹ã(online promote)´íÎó´úÂë (¶ÔÓ¦server_error.txtÖеĴíÎóÐÅÏ¢)
ERR_OP_DOWN_OFFLINE = 281, //"Íæ¼ÒûÓÐÔÚÏßµÄÏÂÏß"
ERR_OP_UP_NOT_LOAD = 282, //"Íæ¼ÒµÄÉÏÏßÐÅÏ¢»¹Î´¼ÓÔØ"
ERR_OP_PICKINGUP = 283, //"Íæ¼ÒÕýÔÚÌáÈ¡ºèÀûÖµ"
ERR_OP_NO_DIVIDEND = 284, //"ÉÏÏßûÓпÉÌáÈ¡µÄºèÀûÖµ"
ERR_OP_DB_ERROR = 285, //"Êý¾Ý¿â·ÃÎÊ´íÎó"
ERR_OR_INVALID_PCODE = 286, //"ÍÆ¹ãÂë²»ÕýÈ·"
ERR_OP_NOT_IN_CURR_SERVER = 287, //"ÍÆ¹ãÈ˲»ÔÚ±¾·þÎñÆ÷"
ERR_OP_INVALID_LEVEL = 288, //"20¼¶ÒÔÏÂÍæ¼Ò²»ÄÜÍÆ¹ãÏÂÏß"
ERR_OP_NOT_IN_CURR_REGION = 289, //"ÍÆ¹ãÈ˲»ÔÚ±¾Çø"
ERR_OP_ALREADY_BINDED = 290, //"ÉÏÏßÒѾ­°ó¶¨£¬ÎÞ·¨Ôٴΰó¶¨"
ERR_OP_REPUATION = 291, //"»ñÈ¡ÍÆ¹ãÁ´½ÓÉùÍûÖµ²»¹»"
//Ïû·Ñ·µ»ý·Ö(consume return points)´íÎó´úÂë (¶ÔÓ¦server_error.txtÖеĴíÎóÐÅÏ¢)
ERR_CRP_PLAYER_OFFLINE = 301, //"Íæ¼ÒÒѾ­ÀëÏß"
ERR_CRP_DB_BUSY = 302, //"Êý¾Ý¿â·±Ã¦"
ERR_CRP_DB_ERROR = 303, //"Êý¾Ý¿â·ÃÎÊ´íÎó"
ERR_CRP_NOT_ENOUGH_POINTS = 304, //"»ý·Ö²»×ã"
ERR_CRP_INVALID_CHANGE_TIME = 305, //"δÔڻÆÚÄÚ²»Äܶһ»»ý·Ö"
ERR_CRP_INVALID_RETURN_TYPE = 306, //"ÎÞЧµÄ·µ»¹·½Ê½"
//½»Òׯ½Ì¨´íÎó´úÂë (¶ÔÓ¦server_error.txtÖеĴíÎóÐÅÏ¢)
ERR_WT_UNOPEN = 311, // ½»Ò×먦·Å
ERR_WT_SN_EXHAUSE = 312, // ÎÞ·¨»ñµÃÓÐЧ½»Ò׺Å
ERR_WT_CANNOT_POST = 313, // ÎÞ·¨¼ÄÊÛ
ERR_WT_CANNOT_CANCELPOST = 314, // ÎÞ·¨È¡Ïû¼ÄÊÛ
ERR_WT_NOT_ENOUGH_DEPOSIT = 315, // ½»Ò×±£Ö¤½ð²»×ã
ERR_WT_ILLEGAL_SELL_PERIOD = 316, // ½»Ò×ÉϼÜʱ¼ä²»ºÏ·¨
ERR_WT_ENTRY_NOT_FOUND = 317, // ½»Ò׺ŶÔÓ¦ÎïÆ·²»´æÔÚ
ERR_WT_ENTRY_IS_BUSY = 318, // ͬ²½²Ù×÷ÖУ¬ÎÞ·¨½ÓÊܽ»Ò×ÇëÇó
ERR_WT_SN_ROLEID_MISMATCH = 319, // ½»Ò׺ÅÓë½ÇÉ«²»Æ¥Åä
ERR_WT_TIMESTAMP_MISMATCH = 320, // ½»ÒײÙ×÷ʱ´Á²»Æ¥Åä
ERR_WT_ENTRY_HAS_BEEN_SOLD = 321, // ÎïÆ·ÒÑÊÛ³ö
ERR_WT_BUYER_NOT_EXIST = 322, // Âò¼Ò²»´æÔÚ
ERR_WT_SN_USERID_MISMATCH = 323, // ½»Ò׺ÅÓëÕʺŲ»Æ¥Åä
ERR_WT_ILLEGAL_SELL_PRICE = 324, // Éϼܼ۸ñ²»ºÏ·¨
ERR_WT_TOO_MANY_ATTEND_SELL = 325, // ¼ÄÊÛÎïÆ·¹ý¶à
ERR_WT_MAILBOX_FULL = 326, // ÓÊÏäÒÑÂú£¬²»¿É½øÐвÙ×÷
ERR_WT_BUYER_STATUS_INAPPROPRIATE,
ERR_WT_BUYER_NOT_EXIST_2,
ERR_WT_SELLER_NOT_EXIST,
ERR_WT_BUYER_CONDITION_NOT_MATCH,
ERR_WT_HAS_ATTEND_SELL,
ERR_WT_USER_OTHER_ROLE_ON_SALE,
//É̳ǾºÅÄ´íÎó´úÂë (¶ÔÓ¦server_error.txtÖеĴíÎóÐÅÏ¢)
ERR_SA_ENTRY_NOT_FOUND = 341, // ¾º¼ÛÎïÆ·²»´æÔÚ
ERR_SA_ENTRY_IS_BUSY = 342, // ¾º¼ÛÎïÆ·Í¬²½²Ù×÷ÖУ¬ÎÞ·¨½ÓÊܾº¼ÛÇëÇó
ERR_SA_CANNOT_BID = 343, // µ±Ç°ÎÞ·¨¾º¼Û
ERR_SA_LOW_BIDPRICE = 344, // ¾º¼Û¹ýµÍ
ERR_SA_BID_FAILED = 345, // ¾º¼Ûʧ°Ü£¬ÓÐÈ˸øÁ˸ü¸ßµÄ¾º¼Û
ERR_SA_USER_NOT_FOUND = 346, // ²ÎÓ뾺¼ÛÕ˺Ų»´æÔÚ
ERR_SA_USER_IS_BUSY = 347, // Õ˺Åͬ²½²Ù×÷ÖУ¬ÎÞ·¨½ÓÊܾº¼ÛÇëÇó
ERR_SA_CASH_NOT_ENOUGH = 348, // ¾º¼ÛÔª±¦²»×ã
ERR_SA_CASH_OVERFLOW = 349, // ¾º¼ÛÔª±¦Ïà¹ØµÄÒç³ö´íÎ󣨴æÈë»òÈ¡³ö£©
ERR_SA_CASH_NOT_ENOUGH_FOR_TRANSFER,
// ¹úÍõÑ¡¾Ù´íÎó´úÂë
ERR_KE_CANNOT_APPLY_CANDIDATE = 471,
ERR_KE_CANDIDATE_APPLY_EXCEED_UPPER_LIMIT,
ERR_KE_ALREADY_APPLY_CANDIDATE,
ERR_KE_CANNOT_VOTE,
ERR_KE_CANDIDATE_NOT_EXIST,
ERR_TANK_BATTLE_NOT_OPEN = 490,
ERR_TANK_BATTLE_ALREADY_APPLY,
ERR_TANK_BATTLE_SWITCH_TIMEOUT,
ERR_TANK_BATTLE_NOT_APPLY_MAP,
};
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 21f97ff846f97be4bbcaf0d2e6fe93a1
@@ -180,6 +180,10 @@ namespace BrewMonster.Network
{
Instance._gameSession.RequestDropIvtrItem(index, amount);
}
public static void LoadConfigData()
{
Instance._gameSession.LoadConfigData();
}
public static void RequestCheckSecurityPassWd(string password)
{
Instance._gameSession.RequestCheckSecurityPassWd(password);
@@ -298,7 +302,6 @@ namespace BrewMonster.Network
}
actDone?.Invoke(true);
}
void OnDestroy()
{
_gameSession.Disconnect();
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0f3afd074eb1e4348a1732d7c1e12c7e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,862 @@
/*
* FILE: CECShortcutSet.cs
*
* DESCRIPTION: Shortcut set management
*
* CREATED BY: Duyuxin, 2005/1/5
* CONVERTED TO C#: 2025
*
* HISTORY:
*
* Copyright (c) 2005 Archosaur Studio, All Rights Reserved.
*/
using BrewMonster.Assets.PerfectWorld.Scripts.Skills;
using BrewMonster.Network;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace BrewMonster
{
/// <summary>
/// Manages a set of shortcuts for quick access to items, skills, commands, etc.
/// </summary>
public class CECShortcutSet
{
#region Fields
private List<CECShortcut> m_aShortcuts; // Shortcut array
#endregion
#region Constructor and Destructor
public CECShortcutSet()
{
m_aShortcuts = new List<CECShortcut>();
}
#endregion
#region Initialization and Release
/// <summary>
/// Initialize the shortcut set with a specified size
/// </summary>
/// <param name="iSize">Number of shortcut slots</param>
/// <returns>True if successful</returns>
public bool Init(int iSize)
{
m_aShortcuts = new List<CECShortcut>(iSize);
for (int i = 0; i < iSize; i++)
{
m_aShortcuts.Add(null);
}
return true;
}
/// <summary>
/// Release all shortcuts and clear the set
/// </summary>
public void Release()
{
// Clear all shortcuts
for (int i = 0; i < m_aShortcuts.Count; i++)
{
if (m_aShortcuts[i] != null)
{
// In C#, we don't need explicit deletion, just clear references
m_aShortcuts[i] = null;
}
}
m_aShortcuts.Clear();
}
#endregion
#region Shortcut Creation Methods
/// <summary>
/// Create an item shortcut at specified position
/// </summary>
/* public bool CreateItemShortcut(int iSlot, int iIvtr, int iIvtrSlot, CECIvtrItem pItem)
{
CECSCItem pItemSC = new CECSCItem();
if (pItemSC == null)
return false;
if (!pItemSC.Init(iIvtr, iIvtrSlot, pItem))
{
Debug.LogError("CECShortcutSet::CreateItemShortcut, Failed to initialize item shortcut");
return false;
}
SetShortcut(iSlot, pItemSC);
return true;
}*/
/// <summary>
/// Create a skill shortcut at specified position
/// </summary>
public bool CreateSkillShortcut(int iSlot, CECSkill pSkill)
{
CECSCSkill pSkillSC = new CECSCSkill();
if (pSkillSC == null)
return false;
if (!pSkillSC.Init(pSkill))
{
Debug.LogError("CECShortcutSet::CreateSkillShortcut, Failed to initialize skill shortcut");
return false;
}
SetShortcut(iSlot, pSkillSC);
return true;
}
/// <summary>
/// Create a skill group shortcut at specified position
/// </summary>
/* public bool CreateSkillGroupShortcut(int iSlot, int iGroupIdx)
{
CECSCSkillGrp pSkillGrpSC = new CECSCSkillGrp();
if (pSkillGrpSC == null)
return false;
if (!pSkillGrpSC.Init(iGroupIdx))
{
Debug.LogError("CECShortcutSet::CreateSkillGroupShortcut, Failed to initialize skill group shortcut");
return false;
}
SetShortcut(iSlot, pSkillGrpSC);
return true;
}*/
/// <summary>
/// Create a pet shortcut at specified position
/// </summary>
/* public bool CreatePetShortcut(int iSlot, int iPetIndex)
{
CECSCPet pPetSC = new CECSCPet();
if (pPetSC == null)
return false;
if (!pPetSC.Init(iPetIndex))
{
Debug.LogError("CECShortcutSet::CreatePetShortcut, Failed to initialize pet shortcut");
return false;
}
SetShortcut(iSlot, pPetSC);
return true;
}*/
/// <summary>
/// Create an auto fashion shortcut at specified position
/// </summary>
/* public bool CreateAutoFashionShortcut(int iSlot, int iFashionIdx)
{
CECSCAutoFashion pAutoFashionSC = new CECSCAutoFashion();
if (pAutoFashionSC == null)
return false;
if (!pAutoFashionSC.Init(iFashionIdx))
{
Debug.LogError("CECShortcutSet::CreateAutoFashionShortcut, Failed to initialize auto fashion shortcut");
return false;
}
SetShortcut(iSlot, pAutoFashionSC);
return true;
}
/// <summary>
/// Create a system module shortcut at specified position
/// </summary>
public bool CreateSystemModuleShortcut(int iSlot, int iSys)
{
CECSCSysModule pSysModule = new CECSCSysModule();
if (pSysModule == null)
return false;
if (!pSysModule.Init(iSys))
{
Debug.LogError("CECShortcutSet::CreateSystemModuleShortcut, Failed to initialize system module shortcut");
return false;
}
SetShortcut(iSlot, pSysModule);
return true;
}*/
/// <summary>
/// Duplicate a shortcut to specified position
/// </summary>
public bool CreateClonedShortcut(int iSlot, CECShortcut pShortcut)
{
CECShortcut pDest = pShortcut.Clone();
if (pDest == null)
return false;
SetShortcut(iSlot, pDest);
return true;
}
#endregion
#region Shortcut Management
/// <summary>
/// Put a shortcut into set and return the old shortcut at that position
/// </summary>
/// <param name="iSlot">Slot index</param>
/// <param name="pShortcut">Shortcut to place</param>
/// <returns>Previous shortcut at that position</returns>
public CECShortcut PutShortcut(int iSlot, CECShortcut pShortcut)
{
if (iSlot < 0 || iSlot >= m_aShortcuts.Count)
return null;
CECShortcut pOldShortcut = m_aShortcuts[iSlot];
m_aShortcuts[iSlot] = pShortcut;
return pOldShortcut;
}
/// <summary>
/// Get a shortcut from set
/// </summary>
/// <param name="iSlot">Slot index</param>
/// <param name="bRemove">If true, remove the shortcut from the set</param>
/// <returns>Shortcut at the specified position</returns>
public CECShortcut GetShortcut(int iSlot, bool bRemove = false)
{
if (iSlot < 0 || iSlot >= m_aShortcuts.Count)
return null;
CECShortcut pShortcut = m_aShortcuts[iSlot];
if (bRemove)
m_aShortcuts[iSlot] = null;
return pShortcut;
}
/// <summary>
/// Set a shortcut into set and release old shortcut at this position automatically
/// </summary>
public void SetShortcut(int iSlot, CECShortcut pShortcut)
{
if (iSlot < 0 || iSlot >= m_aShortcuts.Count)
return;
// Clear old shortcut (C# garbage collection will handle cleanup)
if (m_aShortcuts[iSlot] != null)
{
m_aShortcuts[iSlot] = null;
}
m_aShortcuts[iSlot] = pShortcut;
}
/// <summary>
/// Exchange shortcuts in two slots
/// </summary>
public void ExchangeShortcut(int iSlot1, int iSlot2)
{
if (iSlot1 < 0 || iSlot1 >= m_aShortcuts.Count ||
iSlot2 < 0 || iSlot2 >= m_aShortcuts.Count)
return;
if (iSlot1 != iSlot2)
{
CECShortcut pShortcut = m_aShortcuts[iSlot1];
m_aShortcuts[iSlot1] = m_aShortcuts[iSlot2];
m_aShortcuts[iSlot2] = pShortcut;
}
}
/// <summary>
/// Remove all shortcuts
/// </summary>
public void RemoveAllShortcuts()
{
for (int i = 0; i < m_aShortcuts.Count; i++)
{
if (m_aShortcuts[i] != null)
{
m_aShortcuts[i] = null;
}
}
}
/// <summary>
/// Remove skill and skill group shortcuts
/// </summary>
public void RemoveSkillShortcuts()
{
for (int i = 0; i < m_aShortcuts.Count; i++)
{
CECShortcut pSC = m_aShortcuts[i];
if (pSC == null)
continue;
if (pSC.GetType() == CECShortcut.ShortcutType.SCT_SKILL ||
pSC.GetType() == CECShortcut.ShortcutType.SCT_SKILLGRP)
{
m_aShortcuts[i] = null;
}
}
}
#endregion
#region Update Methods
/// <summary>
/// Update item shortcut when item position changed
/// </summary>
/* public void UpdateMovedItemSC(int tidItem, int iSrcIvtr, int iSrcSlot, int iDstIvtr, int iDstSlot)
{
for (int i = 0; i < m_aShortcuts.Count; i++)
{
CECShortcut pSC = m_aShortcuts[i];
if (pSC == null || pSC.GetType() != CECShortcut.ShortcutType.SCT_ITEM)
continue;
CECSCItem pItemSC = (CECSCItem)pSC;
if (pItemSC.GetInventory() == iSrcIvtr && pItemSC.GetIvtrSlot() == iSrcSlot)
{
Debug.Assert(pItemSC.GetItemTID() == tidItem);
pItemSC.MoveItem(iDstIvtr, iDstSlot);
}
}
}*/
/// <summary>
/// Update item shortcut when item removed
/// </summary>
/* public void UpdateRemovedItemSC(int tidItem, int iIvtr, int iSlot, int iSameItem)
{
for (int i = 0; i < m_aShortcuts.Count; i++)
{
CECShortcut pSC = m_aShortcuts[i];
if (pSC == null || pSC.GetType() != CECShortcut.ShortcutType.SCT_ITEM)
continue;
CECSCItem pItemSC = (CECSCItem)pSC;
if (pItemSC.GetInventory() == iIvtr && pItemSC.GetIvtrSlot() == iSlot)
{
Debug.Assert(pItemSC.GetItemTID() == tidItem);
if (pItemSC.GetAutoFindFlag() && iSameItem >= 0)
pItemSC.MoveItem(iIvtr, iSameItem);
else
SetShortcut(i, null);
}
}
}*/
/// <summary>
/// Update item shortcut when two items exchanged
/// </summary>
/*public void UpdateExchangedItemSC(int tidItem1, int iIvtr1, int iSlot1,
int tidItem2, int iIvtr2, int iSlot2)
{
for (int i = 0; i < m_aShortcuts.Count; i++)
{
CECShortcut pSC = m_aShortcuts[i];
if (pSC == null || pSC.GetType() != CECShortcut.ShortcutType.SCT_ITEM)
continue;
CECSCItem pItemSC = (CECSCItem)pSC;
if (pItemSC.GetInventory() == iIvtr1 && pItemSC.GetIvtrSlot() == iSlot1)
{
Debug.Assert(pItemSC.GetItemTID() == tidItem1);
pItemSC.MoveItem(iIvtr2, iSlot2);
}
else if (pItemSC.GetInventory() == iIvtr2 && pItemSC.GetIvtrSlot() == iSlot2)
{
Debug.Assert(pItemSC.GetItemTID() == tidItem2);
pItemSC.MoveItem(iIvtr1, iSlot1);
}
}
}
/// <summary>
/// Update pet shortcut when pet freed
/// </summary>
public void UpdateFreedPetSC(int iPetIndex)
{
for (int i = 0; i < m_aShortcuts.Count; i++)
{
CECShortcut pSC = m_aShortcuts[i];
if (pSC == null || pSC.GetType() != CECShortcut.ShortcutType.SCT_PET)
continue;
CECSCPet pPetSC = (CECSCPet)pSC;
if (pPetSC.GetPetIndex() == iPetIndex)
SetShortcut(i, null);
}
}*/
#endregion
#region Skill Management
/// <summary>
/// Replace skill id in skill shortcuts
/// </summary>
public void ReplaceSkillID(int idOld, CECSkill pNewSkill)
{
for (int i = 0; i < m_aShortcuts.Count; i++)
{
CECShortcut pSC = m_aShortcuts[i];
if (pSC == null || pSC.GetType() != CECShortcut.ShortcutType.SCT_SKILL)
continue;
// Replace skill
CECSCSkill pSkillSC = (CECSCSkill)pSC;
CECSkill pSkill = pSkillSC.GetSkill();
if (pSkill.GetSkillID() == idOld)
pSkillSC.SetSkill(pNewSkill);
}
}
/// <summary>
/// Replace skill id in skill shortcuts using skill array
/// </summary>
public void ReplaceSkillID(SkillArrayWrapper skillArray, CECSkill pNewSkill)
{
for (int i = 0; i < skillArray.Count(); i++)
{
ReplaceSkillID((int)skillArray[i], pNewSkill);
}
}
/// <summary>
/// Remove skill shortcut by skill ID
/// </summary>
public bool RemoveSkillShortcut(int idSkill)
{
bool bRemove = false;
for (int i = 0; i < GetShortcutNum(); i++)
{
CECShortcut pSC = GetShortcut(i);
if (pSC == null)
continue;
if (pSC.GetType() == CECShortcut.ShortcutType.SCT_SKILL)
{
CECSCSkill pSkillSC = (CECSCSkill)pSC;
CECSkill pSkill = pSkillSC.GetSkill();
if (pSkill != null && pSkill.GetSkillID() == idSkill)
{
SetShortcut(i, null);
bRemove = true;
continue;
}
}
}
return bRemove;
}
#endregion
#region Serialization
/// <summary>
/// Save shortcut configs to specified buffer
/// </summary>
public bool SaveConfigData(out byte[] dataBuffer)
{
List<byte> data = new List<byte>();
for (int i = 0; i < m_aShortcuts.Count; i++)
{
CECShortcut pSC = m_aShortcuts[i];
if (pSC == null)
continue;
// Record shortcut's position and type
data.AddRange(BitConverter.GetBytes(i));
data.AddRange(BitConverter.GetBytes((int)pSC.GetType()));
switch (pSC.GetType())
{
/* case CECShortcut.ShortcutType.SCT_COMMAND:
{
CECSCCommand cmdSC = (CECSCCommand)pSC;
data.AddRange(BitConverter.GetBytes(cmdSC.GetCommandID()));
data.AddRange(BitConverter.GetBytes((int)cmdSC.GetParam()));
break;
}
*/
case CECShortcut.ShortcutType.SCT_SKILL:
{
CECSCSkill skillSC = (CECSCSkill)pSC;
data.AddRange(BitConverter.GetBytes(skillSC.GetSkill().GetSkillID()));
break;
}
/* case CECShortcut.ShortcutType.SCT_ITEM:
{
CECSCItem itemSC = (CECSCItem)pSC;
data.AddRange(BitConverter.GetBytes(itemSC.GetInventory()));
data.AddRange(BitConverter.GetBytes(itemSC.GetIvtrSlot()));
data.AddRange(BitConverter.GetBytes(itemSC.GetItemTID()));
break;
}
case CECShortcut.ShortcutType.SCT_SKILLGRP:
{
CECSCSkillGrp skillGrpSC = (CECSCSkillGrp)pSC;
data.AddRange(BitConverter.GetBytes(skillGrpSC.GetGroupIndex()));
break;
}
case CECShortcut.ShortcutType.SCT_PET:
{
CECSCPet petSC = (CECSCPet)pSC;
data.AddRange(BitConverter.GetBytes(petSC.GetPetIndex()));
break;
}
case CECShortcut.ShortcutType.SCT_AUTOFASHION:
{
CECSCAutoFashion fashionSC = (CECSCAutoFashion)pSC;
data.AddRange(BitConverter.GetBytes(fashionSC.GetAutoFashionIndex()));
break;
}
case CECShortcut.ShortcutType.SCT_SYSMODULE:
{
CECSCSysModule sysSC = (CECSCSysModule)pSC;
data.AddRange(BitConverter.GetBytes(sysSC.GetSysModID()));
break;
}*/
default:
Debug.LogError("CECShortcutSet::SaveConfigData - Unknown shortcut type");
break;
}
}
// Add the end flag
data.AddRange(BitConverter.GetBytes(-1));
dataBuffer = data.ToArray();
return true;
}
/// <summary>
/// Load shortcut configs from specified buffer
/// </summary>
public bool LoadConfigData(byte[] pDataBuf, uint dwVer)
{
if (pDataBuf == null || pDataBuf.Length == 0)
return false;
int offset = 0;
CECGameRun pGameRun = EC_Game.GetGameRun();
CECHostPlayer pHost = pGameRun.GetHostPlayer();
Debug.Assert(pHost != null);
while (offset < pDataBuf.Length)
{
int iSlot = BitConverter.ToInt32(pDataBuf, offset);
offset += sizeof(int);
if (iSlot < 0)
break; // Meet end flag
int iSCType = BitConverter.ToInt32(pDataBuf, offset);
offset += sizeof(int);
switch ((CECShortcut.ShortcutType)iSCType)
{
/*case CECShortcut.ShortcutType.SCT_COMMAND:
{
int iCommand = BitConverter.ToInt32(pDataBuf, offset);
offset += sizeof(int);
int iParam = 0;
if (dwVer >= 2)
{
iParam = BitConverter.ToInt32(pDataBuf, offset);
offset += sizeof(int);
}
CECSCCommand pCmdSC = null;
if (iCommand == CECSCCommand.CMD_PLAYPOSE)
pCmdSC = pGameRun.GetPoseCmdShortcut(iParam);
else
pCmdSC = pGameRun.GetCmdShortcut(iCommand);
if (pCmdSC != null)
CreateClonedShortcut(iSlot, pCmdSC);
break;
}*/
case CECShortcut.ShortcutType.SCT_SKILL:
{
int idSkill = BitConverter.ToInt32(pDataBuf, offset);
offset += sizeof(int);
CECSkill pSkill = pHost.GetPositiveSkillByID(idSkill, true);
if (pSkill == null)
pSkill = pHost.GetEquipSkillByID(idSkill);
CECSkill pSkill2 = null;
/* CECHostGoblin pGoblin = (CECHostGoblin)pHost.GetGoblinModel();
if (pGoblin != null)
{
pSkill2 = pGoblin.GetSkillByID(idSkill);
}*/
if (pSkill != null)
CreateSkillShortcut(iSlot, pSkill);
else if (pSkill2 != null)
CreateSkillShortcut(iSlot, pSkill2);
break;
}
/* case CECShortcut.ShortcutType.SCT_ITEM:
{
int iPack = BitConverter.ToInt32(pDataBuf, offset);
offset += sizeof(int);
int iIvtrSlot = BitConverter.ToInt32(pDataBuf, offset);
offset += sizeof(int);
int idItem = BitConverter.ToInt32(pDataBuf, offset);
offset += sizeof(int);
CECInventory pPack = pHost.GetPack(iPack);
if (pPack == null)
{
Debug.LogError("CECShortcutSet::LoadConfigData - Invalid inventory");
return false;
}
CECIvtrItem pItem = pPack.GetItem(iIvtrSlot);
if (pItem != null)
CreateItemShortcut(iSlot, iPack, iIvtrSlot, pItem);
break;
}
case CECShortcut.ShortcutType.SCT_SKILLGRP:
{
if (dwVer >= 3)
{
int iGroupIdx = BitConverter.ToInt32(pDataBuf, offset);
offset += sizeof(int);
if (iGroupIdx >= 0)
CreateSkillGroupShortcut(iSlot, iGroupIdx);
}
else
{
Debug.LogError("CECShortcutSet::LoadConfigData - Invalid version for skill group");
return false;
}
break;
}
case CECShortcut.ShortcutType.SCT_PET:
{
if (dwVer >= 4)
{
int iPetIndex = BitConverter.ToInt32(pDataBuf, offset);
offset += sizeof(int);
if (iPetIndex >= 0)
CreatePetShortcut(iSlot, iPetIndex);
}
else
{
Debug.LogError("CECShortcutSet::LoadConfigData - Invalid version for pet");
return false;
}
break;
}
case CECShortcut.ShortcutType.SCT_AUTOFASHION:
{
if (dwVer >= 5)
{
int iAutoFashionIndex = BitConverter.ToInt32(pDataBuf, offset);
offset += sizeof(int);
if (iAutoFashionIndex >= 0)
CreateAutoFashionShortcut(iSlot, iAutoFashionIndex);
}
else
{
Debug.LogError("CECShortcutSet::LoadConfigData - Invalid version for auto fashion");
return false;
}
break;
}
case CECShortcut.ShortcutType.SCT_SYSMODULE:
{
if (dwVer > 10)
{
int iSys = BitConverter.ToInt32(pDataBuf, offset);
offset += sizeof(int);
if (iSys >= 0)
CreateSystemModuleShortcut(iSlot, iSys);
}
else
{
Debug.LogError("CECShortcutSet::LoadConfigData - Invalid version for system module");
return false;
}
break;
}*/
default:
Debug.LogError("CECShortcutSet::LoadConfigData - Unknown shortcut type");
return false;
}
}
return true;
}
#endregion
#region Properties
/// <summary>
/// Get the number of shortcuts in the set
/// </summary>
public int GetShortcutNum()
{
return m_aShortcuts.Count;
}
#endregion
}
#region Placeholder Classes
// These classes are referenced but not defined in the provided files
// They should be implemented separately based on EC_Shortcut.h/cpp
public abstract class CECShortcut
{
public enum ShortcutType
{
SCT_NONE = 0,
SCT_COMMAND,
SCT_SKILL,
SCT_ITEM,
SCT_SKILLGRP,
SCT_PET,
SCT_AUTOFASHION,
SCT_SYSMODULE
}
public abstract ShortcutType GetType();
public abstract CECShortcut Clone();
}
/* public class CECSCCommand : CECShortcut
{
public const int CMD_PLAYPOSE = 1; // Example constant
public override ShortcutType GetType() => ShortcutType.SCT_COMMAND;
public override CECShortcut Clone() => null;
public int GetCommandID() => 0;
public int GetParam() => 0;
}
public class CECSCSkill : CECShortcut
{
private CECSkill m_pSkill;
public override ShortcutType GetType() => ShortcutType.SCT_SKILL;
public override CECShortcut Clone() => null;
public bool Init(CECSkill pSkill) { m_pSkill = pSkill; return true; }
public CECSkill GetSkill() => m_pSkill;
public void SetSkill(CECSkill pSkill) { m_pSkill = pSkill; }
}
public class CECSCItem : CECShortcut
{
private int m_iInventory;
private int m_iIvtrSlot;
private int m_iItemTID;
private bool m_bAutoFind;
public override ShortcutType GetType() => ShortcutType.SCT_ITEM;
public override CECShortcut Clone() => null;
public bool Init(int iIvtr, int iSlot, CECIvtrItem pItem)
{
m_iInventory = iIvtr;
m_iIvtrSlot = iSlot;
return true;
}
public int GetInventory() => m_iInventory;
public int GetIvtrSlot() => m_iIvtrSlot;
public int GetItemTID() => m_iItemTID;
public bool GetAutoFindFlag() => m_bAutoFind;
public void MoveItem(int iIvtr, int iSlot) { m_iInventory = iIvtr; m_iIvtrSlot = iSlot; }
}*/
/* public class CECSCSkillGrp : CECShortcut
{
private int m_iGroupIdx;
public override ShortcutType GetType() => ShortcutType.SCT_SKILLGRP;
public override CECShortcut Clone() => null;
public bool Init(int iGroupIdx) { m_iGroupIdx = iGroupIdx; return true; }
public int GetGroupIndex() => m_iGroupIdx;
}
public class CECSCPet : CECShortcut
{
private int m_iPetIndex;
public override ShortcutType GetType() => ShortcutType.SCT_PET;
public override CECShortcut Clone() => null;
public bool Init(int iPetIndex) { m_iPetIndex = iPetIndex; return true; }
public int GetPetIndex() => m_iPetIndex;
}
public class CECSCAutoFashion : CECShortcut
{
private int m_iFashionIdx;
public override ShortcutType GetType() => ShortcutType.SCT_AUTOFASHION;
public override CECShortcut Clone() => null;
public bool Init(int iFashionIdx) { m_iFashionIdx = iFashionIdx; return true; }
public int GetAutoFashionIndex() => m_iFashionIdx;
}
public class CECSCSysModule : CECShortcut
{
private int m_iSysModID;
public override ShortcutType GetType() => ShortcutType.SCT_SYSMODULE;
public override CECShortcut Clone() => null;
public bool Init(int iSys) { m_iSysModID = iSys; return true; }
public int GetSysModID() => m_iSysModID;
}
// Placeholder classes for dependencies
public class CECIvtrItem { }
public class CECInventory
{
public CECIvtrItem GetItem(int slot) => null;
}
public class CECHostGoblin
{
public CECSkill GetSkillByID(int id) => null;
}*/
#endregion
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c8c517455cc397744bae3b6f9ddc1c38
@@ -2,24 +2,27 @@ using BrewMonster.Scripts.Player;
using UnityEngine;
using static CECPlayer;
public class PlayerIdleState : PlayerState
namespace BrewMonster
{
public PlayerIdleState(CECHostPlayer characterCtrl) : base(characterCtrl)
public class PlayerIdleState : PlayerState
{
}
public PlayerIdleState(CECHostPlayer characterCtrl) : base(characterCtrl)
{
}
public override void Enter()
{
_characterCtrl.PlayAction((int)PLAYER_ACTION_TYPE.ACT_STAND, true, 1, false);
}
public override void Enter()
{
_characterCtrl.PlayAction((int)PLAYER_ACTION_TYPE.ACT_STAND, true, 1, false);
}
public override void Exit()
{
}
public override void Exit()
{
public override void Update()
{
}
public override void Update()
{
}
}
}
}
@@ -2,25 +2,28 @@ using BrewMonster.Scripts.Player;
using UnityEngine;
using static CECPlayer;
public class PlayerMoveState : PlayerState
namespace BrewMonster
{
public PlayerMoveState(CECHostPlayer characterCtrl) : base(characterCtrl)
public class PlayerMoveState : PlayerState
{
}
public PlayerMoveState(CECHostPlayer characterCtrl) : base(characterCtrl)
{
}
public override void Enter()
{
_characterCtrl.PlayAction((int)PLAYER_ACTION_TYPE.ACT_WALK,true,1,false);
}
public override void Enter()
{
_characterCtrl.PlayAction((int)PLAYER_ACTION_TYPE.ACT_WALK, true, 1, false);
}
public override void Exit()
{
_characterCtrl.StopMovement();
}
public override void Exit()
{
_characterCtrl.StopMovement();
}
public override void Update()
{
_characterCtrl.HandleMovement();
}
public override void Update()
{
_characterCtrl.HandleMovement();
}
}
}
}
@@ -1,6 +1,6 @@
using UnityEngine;
namespace BrewMonster.Scripts.Player
namespace BrewMonster
{
public abstract class PlayerState
{
@@ -304,7 +304,7 @@ public class CECPlayerActionPlayPolicy
{
if (m_pPlayer != null)
{
EventBus.PublishChannel(m_pPlayer.GetPlayerInfo().cid, new CECPlayer.CleearComActFlagAllRankNodesEvent(bSignalCurrent));
EventBus.PublishChannel(m_pPlayer.GetPlayerInfo().cid, new CECPlayer.ClearComActFlagAllRankNodesEvent(bSignalCurrent));
}
}
@@ -8,9 +8,9 @@ using System.Threading.Tasks;
using Unity.VisualScripting;
using static BrewMonster.SkillArrayWrapper;
namespace BrewMonster.Assets.PerfectWorld.Scripts.Skills
namespace BrewMonster
{
public class CECSCSkill
public class CECSCSkill : CECShortcut
{
CECSkill m_pSkill;
public bool Init(CECSkill pSkill)
@@ -59,5 +59,18 @@ namespace BrewMonster.Assets.PerfectWorld.Scripts.Skills
return true;
}
public CECSkill GetSkill() { return m_pSkill; }
public void SetSkill(CECSkill pSkill) { m_pSkill = pSkill; }
public override ShortcutType GetType()
{
//TODO: Fix later
return ShortcutType.SCT_ITEM;
}
public override CECShortcut Clone()
{
return this;
}
}
}
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BrewMonster
{
public class CECRTDebug
{
}
public class CECDataReader
{
private byte[] data;
private int offset;
private int length;
public CECDataReader(byte[] data, int offset, int length)
{
this.data = data;
this.offset = offset;
this.length = length;
}
public int ReadInt()
{
if (offset + sizeof(int) > offset + length)
throw new System.InvalidOperationException("Not enough data to read int");
int value = System.BitConverter.ToInt32(data, offset);
offset += sizeof(int);
return value;
}
public byte[] ReadData(int size)
{
if (offset + size > offset + length)
throw new System.InvalidOperationException($"Not enough data to read {size} bytes");
byte[] result = new byte[size];
System.Array.Copy(data, offset, result, 0, size);
offset += size;
return result;
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 05e5b2cfadf599b45a6a7439a1ccd200
+116 -2
View File
@@ -21,7 +21,6 @@ public partial class CECGameRun : MonoBehaviour, IMsgHandler
//[SerializeField] private Transform ground;
CECHostPlayer hostPlayer;
public CinemachineFreeLook freeLookCam;
public float rotateSpeedX = 300f; // tốc độ xoay ngang
public float rotateSpeedY = 2f; // tốc độ xoay dọc
private CECWorld m_pWorld;
@@ -61,7 +60,6 @@ public partial class CECGameRun : MonoBehaviour, IMsgHandler
EC_ManMessage.RegisterHandler(this);
}
public void Log(string s)
{
Debug.LogError(s);
@@ -160,4 +158,120 @@ public partial class CECGameRun : MonoBehaviour, IMsgHandler
// freeLookCam.m_YAxis.m_MaxSpeed = 0;
// }
//}
/// <summary>
/// Load necessary user configs (UI, shortcut, accelerate keys) from server
/// 从服务器加载必要的用户配置(UI、快捷键、加速键)
/// </summary>
/// <param name="pDataBuf">Config data buffer / 配置数据缓冲区</param>
/// <param name="iDataSize">Data size / 数据大小</param>
/// <returns>True if loaded successfully / 加载成功返回true</returns>
public bool LoadConfigsFromServer(byte[] pDataBuf, int iDataSize)
{
const uint USERCFG_VERSION = 3;
if (pDataBuf == null || iDataSize == 0)
{
BMLogger.LogError("CECGameRun::LoadConfigsFromServer, configs data is empty");
return false;
}
// TODO: Uncomment when these objects are available
// Debug.Assert(m_pWorld != null && m_pWorld.GetHostPlayer() != null && m_pUIManager.GetInGameUIMan() != null);
int offset = 0;
// Read version / 读取版本号
uint dwVer = System.BitConverter.ToUInt32(pDataBuf, offset);
offset += sizeof(uint);
if (dwVer > USERCFG_VERSION)
{
Debug.LogError($"CECGameRun::LoadConfigsFromServer, version {dwVer} > {USERCFG_VERSION}");
return false;
}
byte[] pUncompBuf = null;
uint dwRealLen = (uint)(iDataSize - sizeof(uint));
byte[] pData = pDataBuf;
int dataOffset = offset;
if (dwVer >= 3)
{
// Uncompress config data / 解压配置数据
dwRealLen = 4096;
pUncompBuf = new byte[dwRealLen];
// Extract compressed data / 提取压缩数据
byte[] compressedData = new byte[iDataSize - sizeof(uint)];
System.Array.Copy(pDataBuf, offset, compressedData, 0, compressedData.Length);
// TODO: Implement AFilePackage::Uncompress equivalent
int iRes = EC_Utility.UncompressData(compressedData, compressedData.Length, pUncompBuf, ref dwRealLen);
if (iRes != 0)
{
// 解压失败,过程出错 / Decompression failed, process error
BMLogger.LogError($"CECGameRun::LoadConfigsFromServer, Failed to uncompress configs data ({iRes}:{iDataSize})");
return false;
}
pData = pUncompBuf;
dataOffset = 0;
}
try
{
// Create data reader / 创建数据读取器
CECDataReader dr = new CECDataReader(pData, dataOffset, (int)dwRealLen);
// Load host configs / 加载主机配置
CECHostPlayer pHost = GetHostPlayer();
if (pHost != null)
{
int iSize = dr.ReadInt();
byte[] hostConfigData = dr.ReadData(iSize);
if (!pHost.LoadConfigData(hostConfigData))
{
BMLogger.LogError("CECGameRun::LoadConfigsFromServer, Failed to load host configs");
return false;
}
}
// TODO: Uncomment when UI manager is available
// Load UI configs / 加载UI配置
// CECGameUIMan pGameUI = m_pUIManager.GetInGameUIMan();
// if (pGameUI != null)
// {
// int iSize = dr.ReadInt();
// byte[] uiConfigData = dr.ReadData(iSize);
// if (!pGameUI.SetUserLayout(uiConfigData, iSize))
// {
// BMLogger.LogError("CECGameRun::LoadConfigsFromServer, Failed to set user layout");
// return false;
// }
// }
// Load user settings / 加载用户设置
if (dwVer >= 2)
{
// TODO: Uncomment when game configs are available
// int iSize = dr.ReadInt();
// byte[] settingsData = dr.ReadData(iSize);
// if (!g_pGame.GetConfigs().LoadUserConfigData(settingsData, iSize))
// {
// BMLogger.LogError("CECGameRun::LoadConfigsFromServer, Failed to load user config data");
// return false;
// }
}
}
catch (System.Exception e)
{
BMLogger.LogError($"CECGameRun::LoadConfigsFromServer, data read error: {e.Message}");
return false;
}
return true;
}
}
+107 -97
View File
@@ -4,118 +4,128 @@ using CSNetwork;
using CSNetwork.GPDataType;
using UnityEngine;
using System.Runtime.InteropServices;
using BrewMonster.Network;
// ׶ // Contribution info
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct CONTRIB_INFO
namespace BrewMonster
{
public int consume_contrib; // ѵ // Consume contribution
public int exp_contrib; // ɶһɾ // Experience contribution
public int cumulate_contrib; // ۻֵ // Cumulative contribution
// public CONTRIB_INFO()
// {
// consume_contrib = 0;
// exp_contrib = 0;
// cumulate_contrib = 0;
// }
}
public partial class CECHostPlayer
{
private int m_idTradePlayer; // ID of player who is trading with us
private CECTaskInterface m_pTaskInterface;
private int m_iBoothState; // Booth state. 0, none; 1, prepare; 2, open booth; 3, visite other's booth
private CONTRIB_INFO m_contribInfo;
public CECTaskInterface GetTaskInterface()
// ׶ // Contribution info
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct CONTRIB_INFO
{
return m_pTaskInterface;
public int consume_contrib; // ѵ // Consume contribution
public int exp_contrib; // ɶһɾ // Experience contribution
public int cumulate_contrib; // ۻֵ // Cumulative contribution
// public CONTRIB_INFO()
// {
// consume_contrib = 0;
// exp_contrib = 0;
// cumulate_contrib = 0;
// }
}
// Is host player trading ?
public bool IsTrading() { return m_idTradePlayer != 0; }
public CONTRIB_INFO GetContribInfo()
public partial class CECHostPlayer
{
return m_contribInfo;
}
public int GetBoothState()
{
return m_iBoothState;
}
private void OnMsgHstTaskData(ECMSG Msg)
{
// decode header to distinguish TASK_DATA vs TASK_VAR_DATA
// if (!(Msg.dwParam2 is cmd_header header))
// {
// Debug.LogError("OnMsgHstTaskData: invalid header");
// return;
// }
private int m_idTradePlayer; // ID of player who is trading with us
private CECTaskInterface m_pTaskInterface;
private int m_iBoothState; // Booth state. 0, none; 1, prepare; 2, open booth; 3, visite other's booth
private CONTRIB_INFO m_contribInfo;
int header = Convert.ToInt32(Msg.dwParam2);
public CECTaskInterface GetTaskInterface()
{
return m_pTaskInterface;
}
byte[] pDataBuf = Msg.dwParam1 as byte[];
if (pDataBuf == null)
{
Debug.LogError("OnMsgHstTaskData: missing payload buffer");
return;
}
// Is host player trading ?
public bool IsTrading() { return m_idTradePlayer != 0; }
if (header == CommandID.TASK_DATA)
{
#if !LOAD_TASK_TEMPL
return; // Task templates loading not implemented in C#
public CONTRIB_INFO GetContribInfo()
{
return m_contribInfo;
}
public int GetBoothState()
{
return m_iBoothState;
}
private void OnMsgHstTaskData(ECMSG Msg)
{
// decode header to distinguish TASK_DATA vs TASK_VAR_DATA
// if (!(Msg.dwParam2 is cmd_header header))
// {
// Debug.LogError("OnMsgHstTaskData: invalid header");
// return;
// }
int header = Convert.ToInt32(Msg.dwParam2);
byte[] pDataBuf = Msg.dwParam1 as byte[];
if (pDataBuf == null)
{
Debug.LogError("OnMsgHstTaskData: missing payload buffer");
return;
}
if (header == CommandID.TASK_DATA)
{
#if LOAD_TASK_TEMPL
return; // Task templates loading not implemented in C#
// Parse aggregated task buffers
cmd_task_data pCmd = cmd_task_data.FromBuffer(pDataBuf);
// cmd_task_data pCmd = GPDataTypeHelper.FromBytes<cmd_task_data>(pDataBuf);
// Release and recreate task interface
m_pTaskInterface = null;
m_pTaskInterface = new CECTaskInterface(this);
if (!m_pTaskInterface.Init(
pCmd.active_list, (int)pCmd.active_list_size,
pCmd.finished_list, (int)pCmd.finished_list_size,
pCmd.finished_time_list, (int)pCmd.finished_time_list_size,
pCmd.finished_count, (int)pCmd.finished_count_size,
pCmd.storage_task, (int)pCmd.storage_task_size))
{
Debug.LogError("CECHostPlayer::OnMsgHstTaskData, failed to initialize task interface");
return;
}
m_pTaskInterface.CheckPQEnterWorldInit();
#endif
// Parse aggregated task buffers
cmd_task_data pCmd = cmd_task_data.FromBuffer(pDataBuf);
// cmd_task_data pCmd = GPDataTypeHelper.FromBytes<cmd_task_data>(pDataBuf);
// Release and recreate task interface
m_pTaskInterface = null;
m_pTaskInterface = new CECTaskInterface(this);
// check if player has equipped goblin (not yet implemented in C#)
// TODO: implement goblin initialization when equipment system is ready
if (!m_pTaskInterface.Init(
pCmd.active_list, (int)pCmd.active_list_size,
pCmd.finished_list, (int)pCmd.finished_list_size,
pCmd.finished_time_list, (int)pCmd.finished_time_list_size,
pCmd.finished_count, (int)pCmd.finished_count_size,
pCmd.storage_task, (int)pCmd.storage_task_size))
{
Debug.LogError("CECHostPlayer::OnMsgHstTaskData, failed to initialize task interface");
return;
}
// GET_ALL_DATA end flag tasks were here in C++ (LoadConfigData), omitted in C#
UnityGameSession.LoadConfigData();
m_pTaskInterface.CheckPQEnterWorldInit();
// if (UpdateEquipSkills()) UpdateEquipSkillCoolDown(); // methods not ported yet
}
#if LOAD_TASK_TEMPL
// check if player has equipped goblin (not yet implemented in C#)
// TODO: implement goblin initialization when equipment system is ready
else if (header == CommandID.TASK_VAR_DATA)
{
// Minimal forwarding; original code passes inner data pointer and size
if (m_pTaskInterface != null)
{
OnServerNotify(m_pTaskInterface, pDataBuf, pDataBuf.Length);
}
else
{
Debug.LogError("OnMsgHstTaskData: m_pTaskInterface is null on TASK_VAR_DATA");
}
}
#endif
// GET_ALL_DATA end flag tasks were here in C++ (LoadConfigData), omitted in C#
}
// if (UpdateEquipSkills()) UpdateEquipSkillCoolDown(); // methods not ported yet
}
else if (header == CommandID.TASK_VAR_DATA)
{
// Minimal forwarding; original code passes inner data pointer and size
if (m_pTaskInterface != null)
{
OnServerNotify(m_pTaskInterface, pDataBuf, pDataBuf.Length);
}
else
{
Debug.LogError("OnMsgHstTaskData: m_pTaskInterface is null on TASK_VAR_DATA");
}
}
private void OnServerNotify(CECTaskInterface pInterface, byte[] data, int size)
{
// TODO: Implement server notify handling for task var data
}
}
private void OnServerNotify(CECTaskInterface pInterface, byte[] data, int size)
{
// TODO: Implement server notify handling for task var data
}
}
File diff suppressed because it is too large Load Diff
+37 -34
View File
@@ -3,52 +3,55 @@ using BrewMonster.Scripts;
using BrewMonster.Scripts.Managers;
using ModelRenderer.Scripts.GameData;
public partial class CECHostPlayer
namespace BrewMonster
{
public int[] m_aEquips = new int[InventoryConst.IVTRSIZE_EQUIPPACK];
public bool UpdateEquipSkins()
public partial class CECHostPlayer
{
var equipPack = EC_Inventory.GetPack(EC_Inventory.IVTRTYPE_EQUIPPACK);
public int[] m_aEquips = new int[InventoryConst.IVTRSIZE_EQUIPPACK];
int[] aNewEquips = new int[InventoryConst.IVTRSIZE_EQUIPPACK];
EC_IvtrItem pItem = null;
for (int i = 0; i < InventoryConst.IVTRSIZE_EQUIPPACK; i++)
public bool UpdateEquipSkins()
{
var equipPack = EC_Inventory.GetPack(EC_Inventory.IVTRTYPE_EQUIPPACK);
if (equipPack.TryGetValue(i, out pItem))
int[] aNewEquips = new int[InventoryConst.IVTRSIZE_EQUIPPACK];
EC_IvtrItem pItem = null;
for (int i = 0; i < InventoryConst.IVTRSIZE_EQUIPPACK; i++)
{
aNewEquips[i] = pItem.m_tid;
if (equipPack.TryGetValue(i, out pItem))
{
aNewEquips[i] = pItem.m_tid;
}
}
ShowEquipments(aNewEquips, true, true);
return true;
}
ShowEquipments(aNewEquips, true, true);
return true;
}
public void ShowEquipments(int[] pEquipmentID, bool bLoadAtOnce, bool bForceLoad)
{
var elemendataman = BrewMonster.ElementDataManProvider.GetElementDataMan();
DATA_TYPE DataType = default;
for (int i = 0; i < InventoryConst.IVTRSIZE_EQUIPPACK; i++)
public void ShowEquipments(int[] pEquipmentID, bool bLoadAtOnce, bool bForceLoad)
{
if (pEquipmentID[i] != m_aEquips[i])
var elemendataman = BrewMonster.ElementDataManProvider.GetElementDataMan();
DATA_TYPE DataType = default;
for (int i = 0; i < InventoryConst.IVTRSIZE_EQUIPPACK; i++)
{
// new equipment. Need to load and equip to host player
var equipData = elemendataman.get_data_ptr((uint)pEquipmentID[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
switch (DataType)
if (pEquipmentID[i] != m_aEquips[i])
{
case DATA_TYPE.DT_WEAPON_ESSENCE:
var weaponData = (WEAPON_ESSENCE)equipData;
BMLogger.Log($"ShowEquipments():: Weapon Essence: {weaponData.FileModelRight} -- {weaponData.FileModelLeft}");
break;
case DATA_TYPE.DT_ARMOR_ESSENCE:
var armorData = (ARMOR_ESSENCE)equipData;
BMLogger.Log($"ShowEquipments():: Armor Essence: {armorData.RealName}");
break;
default:
break;
// new equipment. Need to load and equip to host player
var equipData = elemendataman.get_data_ptr((uint)pEquipmentID[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
switch (DataType)
{
case DATA_TYPE.DT_WEAPON_ESSENCE:
var weaponData = (WEAPON_ESSENCE)equipData;
BMLogger.Log($"ShowEquipments():: Weapon Essence: {weaponData.FileModelRight} -- {weaponData.FileModelLeft}");
break;
case DATA_TYPE.DT_ARMOR_ESSENCE:
var armorData = (ARMOR_ESSENCE)equipData;
BMLogger.Log($"ShowEquipments():: Armor Essence: {armorData.RealName}");
break;
default:
break;
}
}
}
}
+43
View File
@@ -2,6 +2,8 @@ using BrewMonster;
using CSNetwork.GPDataType;
using System;
using System.Collections;
using System.IO;
using System.IO.Compression;
using System.Runtime.InteropServices;
using System.Text;
using UnityEngine;
@@ -63,6 +65,47 @@ public static class EC_Utility
Marshal.FreeHGlobal(ptr);
}
}
public static byte[] UncompressData(byte[] compressedData, int expectedSize)
{
// Bỏ header zlib 2 byte (0x78 0x9C hoặc tương tự)
int start = 2;
int len = compressedData.Length - 6; // bỏ 4 byte ADLER32 cuối
using var ms = new MemoryStream(compressedData, start, len);
using var ds = new DeflateStream(ms, CompressionMode.Decompress);
using var outMs = new MemoryStream(expectedSize);
ds.CopyTo(outMs);
return outMs.ToArray();
}
public static int UncompressData(
byte[] compressedBuffer,
int compressedLength,
byte[] outBuffer,
ref uint outLength)
{
try
{
byte[] result = UncompressData(compressedBuffer, (int)outLength);
if (result.Length > outBuffer.Length)
return -1; // dest buffer quá nhỏ giống C++
Buffer.BlockCopy(result, 0, outBuffer, 0, result.Length);
outLength = (uint)result.Length;
return 0; // OK
}
catch (InvalidDataException)
{
return -2; // inflate failed
}
catch
{
return -2;
}
}
public static Vector3 glb_DecompressDirH(byte byDir)
{
const float fInter = 360.0f / 256.0f;
@@ -1,4 +1,5 @@
using BrewMonster.Scripts.Player;
using BrewMonster;
using BrewMonster.Scripts.Player;
using UnityEngine;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;