diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs index e0d9bce34c..e70d330201 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs @@ -2889,5 +2889,17 @@ namespace CSNetwork.GPDataType { public int id; }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_object_enter_sanctuary + { + public int id; // self id or pet id. + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_object_leave_sanctuary + { + public int id; // self id or pet id. + }; } diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs index 2b39d0e647..dba6c7c1c8 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs @@ -1296,6 +1296,10 @@ namespace CSNetwork EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCEXTSTATE, MANAGER_INDEX.MAN_NPC, 0, pDataBuf, pCmdHeader); break; } + case CommandID.ENTER_SANCTUARY: + case CommandID.LEAVE_SANCTUARY: + EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_SANCTUARY, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader); + break; default: #if UNITY_EDITOR if (isDebug) diff --git a/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs b/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs index ae80abe037..ddf8312fb7 100644 --- a/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs @@ -362,6 +362,19 @@ namespace BrewMonster.Network return "a61"; } } + + public string GetWorldInstanceName(int idInst) + { + switch (idInst) + { + case 161: + return "a61"; + case 169: + return "a69"; + default: + return ""; + } + } /// Make sure username and password is set before calling this method private async Task ConnectAsync(string ip, int port) { diff --git a/Assets/PerfectWorld/Scripts/Players/EC_HostMsg.cs b/Assets/PerfectWorld/Scripts/Players/EC_HostMsg.cs index d844edb57e..c111743781 100644 --- a/Assets/PerfectWorld/Scripts/Players/EC_HostMsg.cs +++ b/Assets/PerfectWorld/Scripts/Players/EC_HostMsg.cs @@ -501,14 +501,14 @@ namespace BrewMonster void OnMsgHstSetPlayerLimit(ECMSG Msg) { cmd_set_player_limit pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); - if (pCmd.index >= 0 && pCmd.index < (int)PLAYER_LIMIT.PLAYER_LIMIT_MAX) - m_playerLimits[pCmd.index] = (pCmd.b != 0); + if (pCmd.index >= 0 && pCmd.index < (int)PLAYER_LIMIT.PLAYER_LIMIT_MAX) + m_playerLimits[pCmd.index] = (pCmd.b != 0); } // Get time counter of using item in pack public bool GetUsingItemTimeCnt(ref uint dwCurTime, ref uint dwMaxTime, ref int? piItem/* NULL */) { - if(m_pWorkMan == null) + if (m_pWorkMan == null) { return false; } @@ -525,6 +525,47 @@ namespace BrewMonster return true; } + + void OnMsgHstSanctuary(ECMSG Msg) + { + if (Convert.ToInt32(Msg.dwParam2) == CommandID.ENTER_SANCTUARY) + { + cmd_object_enter_sanctuary pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + + if (pCmd.id == m_PlayerInfo.cid) + { + m_bInSanctuary = true; + + // Print a notify + EC_Game.GetGameRun().AddFixedMessage((int)FixedMsg.FIXMSG_ENTERSHELTER); + } + else + { + m_bPetInSanctuary = true; + + EC_Game.GetGameRun().AddFixedMessage((int)FixedMsg.FIXMSG_PET_ENTERSHELTER); + } + } + + else if (Convert.ToInt32(Msg.dwParam2) == CommandID.LEAVE_SANCTUARY) + { + cmd_object_leave_sanctuary pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + + if (pCmd.id == m_PlayerInfo.cid) + { + m_bInSanctuary = false; + + // Print a notify + EC_Game.GetGameRun().AddFixedMessage((int)FixedMsg.FIXMSG_LEAVESHELTER); + } + else + { + m_bPetInSanctuary = false; + + EC_Game.GetGameRun().AddFixedMessage((int)FixedMsg.FIXMSG_PET_LEAVESHELTER); + } + } + } } } diff --git a/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs b/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs index 434c4a6d76..57937f8ef4 100644 --- a/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs +++ b/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs @@ -388,6 +388,11 @@ namespace BrewMonster.UI m_pDlgTask.TraceTask(ulTaskId); } } + + public void ShowErrorMsg(string pszMsg, string pszName) + { + CECUIManager.Instance.ShowMessageBox(pszName, pszMsg, MessageBoxType.YesButton); + } } public enum EC_GAMEUI_ICONS : byte { diff --git a/Assets/PerfectWorld/Scripts/World/CECWorld.cs b/Assets/PerfectWorld/Scripts/World/CECWorld.cs index 194f64e27b..a929005c48 100644 --- a/Assets/PerfectWorld/Scripts/World/CECWorld.cs +++ b/Assets/PerfectWorld/Scripts/World/CECWorld.cs @@ -15,6 +15,7 @@ namespace BrewMonster.Scripts.World uint m_dwBornStamp = 0; CECAssureMove m_pAssureMove; // object used to assure move int m_idInst = 161; // id of instance + int m_iParallelWorldID = 0; public uint GetBornStamp() { return m_dwBornStamp++; } @@ -186,5 +187,7 @@ namespace BrewMonster.Scripts.World // // ɾ³ýËæ»úµØÍ¼ÐÅÏ¢ // CECRandomMapProcess::DeleteAllRandomMapDataForSingleUser(); } + + public int GetCurParallelWorld(){ return m_iParallelWorldID; } } } diff --git a/Assets/Scripts/CECHostPlayer.World.cs b/Assets/Scripts/CECHostPlayer.World.cs index eb0c5a47ae..c81bc56248 100644 --- a/Assets/Scripts/CECHostPlayer.World.cs +++ b/Assets/Scripts/CECHostPlayer.World.cs @@ -2,8 +2,9 @@ using BrewMonster.Scripts; using CSNetwork; using CSNetwork.GPDataType; -using System.Runtime.InteropServices; using Cysharp.Threading.Tasks; +using System; +using System.Runtime.InteropServices; using UnityEngine; using static BrewMonster.Scripts.CECHPWork; @@ -199,52 +200,77 @@ namespace BrewMonster // 此方法实现了原始 C++ 代码中的 Goto 逻辑 private bool Goto(int idInst, Vector3 vPos, int iParallelWorldID) { + Action actDone = () => + { + // Stop all current work and goto specified position + // 停止所有当前工作并转到指定位置 + if (m_pWorkMan != null) + { + // Stop auto-moving if active + // 如果正在自动移动则停止 + // Note: IsAutoMoving check would go here if available + // 注意:如果可用,IsAutoMoving 检查将放在这里 + if (IsAutoMoving()) + { + CECHPWorkMove pWorkMove = (m_pWorkMan.GetRunningWork(CECHPWork.Host_work_ID.WORK_MOVETOPOS) as CECHPWorkMove); + pWorkMove.SetUseAutoMoveDialog(false); + pWorkMove.PressCancel(); + pWorkMove.Finish(); + } + // Finish all work + // 完成所有工作 + m_pWorkMan.FinishAllWork(true); + } + + if (!IsFlying()) + ShowWing(false); + // Add a little height to ensure player's AABB won't embed with building + // 增加一点高度以确保玩家的 AABB 不会嵌入建筑物 + vPos += EC_Utility.ToVector3(GPDataTypeHelper.g_vAxisY) * 0.1f; + + // Ensure we are not under ground (terrain height check would go here) + // 确保我们不会在地下(地形高度检查将放在这里) + // Note: Terrain height check is skipped for now as it requires world access + // 注意:暂时跳过地形高度检查,因为它需要世界访问 + A3DVECTOR3 vNormal = new A3DVECTOR3(); + float vTerrainHeight = vPos.y; + if (Physics.RaycastNonAlloc(vPos, (Vector3.down), hits, 1000f, 1 << 6) > 0) + { + vTerrainHeight = hits[0].point.y; + vNormal = EC_Utility.ToA3DVECTOR3(hits[0].normal); + } + if (vPos.y < vTerrainHeight) + { + vPos.y = vTerrainHeight; + } + // Set position + // 设置位置 + SetPos(vPos); + + m_CDRInfo.vTPNormal = vPos.y <= vTerrainHeight + 0.1f ? vNormal : g_vOrigin; + m_CDRInfo.fYVel = 0.0f; + m_CDRInfo.vAbsVelocity.Clear(); + // Reset jump state if available + // 如果可用则重置跳跃状态 + ResetJump(); // Uncomment if ResetJump method exists + + m_MoveCtrl.SetHostLastPos(EC_Utility.ToA3DVECTOR3(vPos)); + m_MoveCtrl.SetLastSevPos(EC_Utility.ToA3DVECTOR3(vPos)); + // Update camera if available + // 如果可用则更新相机 + // UpdateFollowCamera(false, 10); // Uncomment if UpdateFollowCamera method exists + + LitModelHolder.Instance.LoadAllObjectsNearTargetPosition(vPos).Forget(); + }; // Jump to instance (change world/instance) // 跳转到实例(更改世界/实例) // Note: JumpToInstance is currently a stub in CECGameRun, so we skip the call for now // 注意:JumpToInstance 目前在 CECGameRun 中是一个存根,所以我们现在跳过调用 - // if (CECGameRun.Instance != null && !CECGameRun.Instance.JumpToInstance(idInst, vPos, iParallelWorldID)) - // { - // Debug.LogError($"CECHostPlayer::Goto, Failed to jump to instance {idInst}"); - // return false; - // } - - // Stop all current work and goto specified position - // 停止所有当前工作并转到指定位置 - if (m_pWorkMan != null) + if (CECGameRun.Instance != null && !CECGameRun.Instance.JumpToInstance(idInst, vPos, iParallelWorldID, actDone)) { - // Stop auto-moving if active - // 如果正在自动移动则停止 - // Note: IsAutoMoving check would go here if available - // 注意:如果可用,IsAutoMoving 检查将放在这里 - - // Finish all work - // 完成所有工作 - m_pWorkMan.FinishAllWork(true); + Debug.LogError($"CECHostPlayer::Goto, Failed to jump to instance {idInst}"); + return false; } - - // Add a little height to ensure player's AABB won't embed with building - // 增加一点高度以确保玩家的 AABB 不会嵌入建筑物 - vPos.y += 0.1f; - - // Ensure we are not under ground (terrain height check would go here) - // 确保我们不会在地下(地形高度检查将放在这里) - // Note: Terrain height check is skipped for now as it requires world access - // 注意:暂时跳过地形高度检查,因为它需要世界访问 - - // Set position - // 设置位置 - SetPos(vPos); - - // Reset jump state if available - // 如果可用则重置跳跃状态 - // ResetJump(); // Uncomment if ResetJump method exists - - // Update camera if available - // 如果可用则更新相机 - // UpdateFollowCamera(false, 10); // Uncomment if UpdateFollowCamera method exists - - LitModelHolder.Instance.LoadAllObjectsNearTargetPosition(vPos).Forget(); return true; } @@ -263,5 +289,15 @@ namespace BrewMonster { return m_pWorkMan.IsMoving(); } + + // Is auto moving ? + bool IsAutoMoving() + { + CECHPWork pWork = m_pWorkMan.GetRunningWork(CECHPWork.Host_work_ID.WORK_MOVETOPOS); + if (pWork != null) + return (pWork as CECHPWorkMove).GetAutoMove(); + else + return false; + } } } \ No newline at end of file diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index 0e0169866b..dd5aa37e9b 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -580,6 +580,7 @@ namespace BrewMonster case EC_MsgDef.MSG_PM_PLAYERCHGSHAPE : OnMsgPlayerChgShape(Msg); break; case EC_MsgDef.MSG_HST_SETMOVESTAMP: OnMsgHstSetMoveStamp(Msg); break; + case EC_MsgDef.MSG_HST_SANCTUARY: OnMsgHstSanctuary(Msg); break; default: // Uncomment to debug unhandled messages diff --git a/Assets/Scripts/EC_GameRun.cs b/Assets/Scripts/EC_GameRun.cs index f0d7d24579..2a650b3674 100644 --- a/Assets/Scripts/EC_GameRun.cs +++ b/Assets/Scripts/EC_GameRun.cs @@ -1,4 +1,5 @@ using BrewMonster; +using BrewMonster.Common; using BrewMonster.Managers; using BrewMonster.Network; using BrewMonster.Scripts; @@ -8,16 +9,17 @@ using BrewMonster.UI; using CSNetwork; using CSNetwork.GPDataType; using CSNetwork.Protocols.RPCData; +using PerfectWorld.Scripts.Shop; using System; using System.Collections.Generic; using System.Data; +using System.IO; using System.Linq; using System.Threading.Tasks; -using PerfectWorld.Scripts.Shop; using Unity.Cinemachine; using Unity.VisualScripting; using UnityEngine; -using BrewMonster.Common; +using UnityEngine.SceneManagement; public partial class CECGameRun : ITickable { @@ -170,7 +172,7 @@ public partial class CECGameRun : ITickable // memset(&m_WallowInfo, 0, sizeof(m_WallowInfo)); m_iGameState = (int)GameState.GS_GAME; // - // if (!g_pGame->LoadInGameRes()) + // if (!g_pGame.LoadInGameRes()) // { // a_LogOutput(1, "CECGameRun::StartGame, Failed to call LoadInGameRes()."); // return false; @@ -184,11 +186,11 @@ public partial class CECGameRun : ITickable // } // // Create default game world - if (!JumpToInstance(idInst, vHostPos)) - { - // a_LogOutput(1, "CECGameRun::StartGame, Failed to create game world."); - return false; - } + //if (!JumpToInstance(idInst, vHostPos)) + //{ + // // a_LogOutput(1, "CECGameRun::StartGame, Failed to create game world."); + // return false; + //} // // // ÉèÖÿç·þ³É¹¦±êʶ£¬ÒÔÀûÓÚ CECGameUIMan ¸ù¾Ý¿ç·þ״̬×öÏàÓ¦³õʼ»¯ // if (CECCrossServer::Instance().IsWaitLogin()){ @@ -213,7 +215,7 @@ public partial class CECGameRun : ITickable // } // // // Reset faction manager - // g_pGame->GetFactionMan()->Release(false); + // g_pGame.GetFactionMan().Release(false); // // Create shortcuts if (!CreateShortcuts()) @@ -223,23 +225,23 @@ public partial class CECGameRun : ITickable } // // // Change UI manager - // if (!m_pUIManager->ChangeCurUIManager(CECUIManager::UIMAN_INGAME)) + // if (!m_pUIManager.ChangeCurUIManager(CECUIManager::UIMAN_INGAME)) // { // a_LogOutput(1, "CECGameRun::StartGame, Failed to change UI manager."); // return false; // } - // m_pInputFilter->LoadHotKey(); + // m_pInputFilter.LoadHotKey(); // - // CECGameUIMan* pGameUIMan = m_pUIManager->GetInGameUIMan(); + // CECGameUIMan* pGameUIMan = m_pUIManager.GetInGameUIMan(); // if (pGameUIMan) - // pGameUIMan->ChangeWorldInstance(idInst); + // pGameUIMan.ChangeWorldInstance(idInst); // // l_SaveCfgCnt.Reset(); // // // Change cursor to default icon - // g_pGame->ChangeCursor(RES_CUR_NORMAL); + // g_pGame.ChangeCursor(RES_CUR_NORMAL); // // Discard current frame - // g_pGame->DiscardFrame(); + // g_pGame.DiscardFrame(); // // // Clear frame controller // memset(&l_fc, 0, sizeof (l_fc)); @@ -255,14 +257,76 @@ public partial class CECGameRun : ITickable // m_SellingRoleID = 0; // // // ÏÂÔØÆ÷ÏìÓ¦½øÈëÓÎϷ״̬ - // if( g_pGame->GetConfigs()->IsMiniClient() ) + // if( g_pGame.GetConfigs().IsMiniClient() ) // CECMCDownload::GetInstance().SendSwitchGame(true); // return true; } - private bool JumpToInstance(int idInst, Vector3 vHostPos, int iParallelWorldID = 0) + public bool JumpToInstance(int idInst, Vector3 vHostPos, int iParallelWorldID = 0, Action actDone = null) { + CECInstance pInst = GetInstance(idInst); + string nameScene = UnityGameSession.Instance.GetWorldInstanceName(idInst); + if (pInst == null || string.IsNullOrEmpty(nameScene)) + { + CECGameUIMan pGameUI = EC_Game.GetGameRun().GetUIManager().GetInGameUIMan(); + if (pGameUI != null) + pGameUI.ShowErrorMsg(pGameUI.GetStringFromTable(10700), ""); + + //EC_Game.GetGameSession().SetBreakLinkFlag(CECGameSession::LBR_MAP_INVALID); + //a_LogOutput(1, "CECGameRun::JumpToInstance, wrong instance id: %d", idInst); + return false; + } + if(m_pWorld != null) + { + if (m_pWorld.GetInstanceID() == pInst.GetID() /*&& m_pWorld.IsValid()*/) + { + // TO DO: fix later + //int iLast = m_pWorld.GetCurParallelWorld(); + //if (iLast == iParallelWorldID) + //{ + // //m_pWorld.SetLoadCenter(vPos); + //} + //else + //{ + // m_pWorld.OnParallelWorldChange(vPos, iParallelWorldID); + // CECUIHelper::UpdateParallelWorld(); + // if (iLast != 0) + // { + // CECGameUIMan pGameUI = EC_Game.GetGameRun().GetUIManager().GetInGameUIMan(); + // if (pGameUI != null) + // { + // ACString strMsg; + // strMsg.Format(pGameUI.GetStringFromTable(10703), pInst.GetName(), iParallelWorldID); + // CECUIHelper::AddHeartBeatHint(strMsg); + // } + // } + //} + return true; + } + else + { + // Release current world + ReleaseWorld(); + } + } + SceneLoader.SceneLoadProcess = SceneLoadProcess.Loading; + SceneLoader.LoadingProgress = 0; + UnityGameSession.Instance.LoadScene(nameScene, LoadSceneMode.Single, + (progress) => + { + LoadingSceneController.Instance.SetProgress(progress); + }, + (value) => + { + //isDoneWorldRender = value; + //isDoneNPCRender = true; + //isDoneWorldRender = true; + //actLoadChar?.Invoke(); + //UnityGameSession.EnterWorldAsync(roleInfo, OnEnterWorldComplete); + m_pWorld.SetInstanceID(idInst); + actDone?.Invoke(); + }); return true; } @@ -543,9 +607,9 @@ public partial class CECGameRun : ITickable // CECGameRun.unique_data* data = GetUniqueData(0); // if (data) // { - // if(data->type ==1) + // if(data.type ==1) // { - // return data->GetValueAsInt(); + // return data.GetValueAsInt(); // } // } return -1; @@ -872,22 +936,22 @@ public partial class CECGameRun : ITickable public uint SaveConfigsToServer() { - // if (!m_pWorld || !m_pWorld->GetHostPlayer() || !m_pWorld->GetHostPlayer()->HostIsReady() || !m_pUIManager->GetInGameUIMan()) + // if (!m_pWorld || !m_pWorld.GetHostPlayer() || !m_pWorld.GetHostPlayer().HostIsReady() || !m_pUIManager.GetInGameUIMan()) // return 0; CECHostPlayer pHost = GetHostPlayer(); CECGameUIMan pGameUI = m_pUIManager?.GetInGameUIMan() as CECGameUIMan; if (m_pWorld == null || pHost == null || !pHost.HostIsReady() || pGameUI == null) return 0; - // g_pGame->GetConfigs()->SaveBlockedID(); + // g_pGame.GetConfigs().SaveBlockedID(); EC_Game.GetConfigs().SaveBlockedID(); // TODO: Check if this is needed here // int iTotalSize = 0; // iTotalSize += sizeof (DWORD); // iTotalSize += sizeof (int); // int iHostSize = 0; - // CECHostPlayer* pHost = m_pWorld->GetHostPlayer(); - // pHost->SaveConfigData(NULL, &iHostSize); + // CECHostPlayer* pHost = m_pWorld.GetHostPlayer(); + // pHost.SaveConfigData(NULL, &iHostSize); // iTotalSize += iHostSize; // iTotalSize += sizeof (int); int iTotalSize = sizeof(uint); @@ -897,8 +961,8 @@ public partial class CECGameRun : ITickable iTotalSize += sizeof(int) + iHostSize; // DWORD dwUISize = 0; - // CECGameUIMan* pGameUI = (CECGameUIMan*)m_pUIManager->GetInGameUIMan(); - // pGameUI->GetUserLayout(NULL, dwUISize); + // CECGameUIMan* pGameUI = (CECGameUIMan*)m_pUIManager.GetInGameUIMan(); + // pGameUI.GetUserLayout(NULL, dwUISize); // iTotalSize += (int)dwUISize; // iTotalSize += sizeof (int); uint dwUISize = 0; @@ -906,7 +970,7 @@ public partial class CECGameRun : ITickable iTotalSize += sizeof(int) + (int)dwUISize; // int iSettingSize = 0; - // g_pGame->GetConfigs()->SaveUserConfigData(NULL, &iSettingSize); + // g_pGame.GetConfigs().SaveUserConfigData(NULL, &iSettingSize); // iTotalSize += iSettingSize; int iSettingSize = 0; EC_Game.GetConfigs().SaveUserConfigData(null, 0, out iSettingSize); @@ -927,7 +991,7 @@ public partial class CECGameRun : ITickable // *((int*)pData) = iHostSize; // pData += sizeof (int); - // pHost->SaveConfigData(pData, &iHostSize); + // pHost.SaveConfigData(pData, &iHostSize); // pData += iHostSize; Buffer.BlockCopy(BitConverter.GetBytes(iHostSize), 0, pDataBuf, offset, sizeof(int)); offset += sizeof(int); @@ -937,7 +1001,7 @@ public partial class CECGameRun : ITickable // *((int*)pData) = (int)dwUISize; // pData += sizeof (int); - // pGameUI->GetUserLayout(pData, dwUISize); + // pGameUI.GetUserLayout(pData, dwUISize); // pData += dwUISize; Buffer.BlockCopy(BitConverter.GetBytes((int)dwUISize), 0, pDataBuf, offset, sizeof(int)); offset += sizeof(int); @@ -947,7 +1011,7 @@ public partial class CECGameRun : ITickable // *((int*)pData) = iSettingSize; // pData += sizeof (int); - // g_pGame->GetConfigs()->SaveUserConfigData(pData, &iSettingSize); + // g_pGame.GetConfigs().SaveUserConfigData(pData, &iSettingSize); // pData += iSettingSize; Buffer.BlockCopy(BitConverter.GetBytes(iSettingSize), 0, pDataBuf, offset, sizeof(int)); offset += sizeof(int); @@ -992,7 +1056,7 @@ public partial class CECGameRun : ITickable Buffer.BlockCopy(pDataBuf, 0, pCompBuf, 0, iVerLen); int iRes = AFilePackage.Compress(pDataBuf, iVerLen,iTotalSize - iVerLen, pCompBuf, iVerLen, ref compLen); - // if (0 == iRes) { g_pGame->GetGameSession()->SaveConfigData(pCompBuf, dwCompLen+iVerLen); iRes = 2; } + // if (0 == iRes) { g_pGame.GetGameSession().SaveConfigData(pCompBuf, dwCompLen+iVerLen); iRes = 2; } // else { a_LogOutput(1, "CECGameRun::SaveConfigsToServer, Failed to compress config data (%d:%d)", iRes, iTotalSize); iRes = 0; } // a_freetemp(pDataBuf); // a_freetemp(pCompBuf); @@ -1022,27 +1086,27 @@ public partial class CECGameRun : ITickable public bool Tick(uint dwDeltaTime) { // if (GetWallowInfo().anti_wallow_active && - // g_pGame->GetGameSession()->IsConnected() && + // g_pGame.GetGameSession().IsConnected() && // GetGameState() == GS_GAME) // { // if (CECUIConfig::Instance().GetGameUI().nWallowHintType != CECUIConfig::GameUI::WHT_KOREA) // { // // ·À³ÁÃÔµ½3Сʱ£¬ÈôAU²»ÌßÈË£¨ÏûÏ¢¶ªÊ§£©£¬Ôò×Ô¶¯ÏÂÏß - // int stime = g_pGame->GetServerGMTTime(); + // int stime = g_pGame.GetServerGMTTime(); // int nTime = stime - GetWallowInfo().play_time; // if (nTime >= 3 * 3600) // { // // ÒѾ­³¬¹ý3Сʱ - // g_pGame->GetGameSession()->SetBreakLinkFlag(CECGameSession::LBR_ANTI_WALLOW); + // g_pGame.GetGameSession().SetBreakLinkFlag(CECGameSession::LBR_ANTI_WALLOW); // } // } // } // // DWORD dwTickTime = a_GetTime(); // - // CECGameSession* pSession = g_pGame->GetGameSession(); - // pSession->ProcessNewProtocols(); - // DWORD dwRealTime = g_pGame->GetRealTickTime(); + // CECGameSession* pSession = g_pGame.GetGameSession(); + // pSession.ProcessNewProtocols(); + // DWORD dwRealTime = g_pGame.GetRealTickTime(); if (m_iLogoutFlag >= 0) { @@ -1053,16 +1117,16 @@ public partial class CECGameRun : ITickable // CECReconnect::Instance().Tick(); // // if (m_pUIManager) - // m_bUIHasCursor = m_pUIManager->UIControlCursor(); + // m_bUIHasCursor = m_pUIManager.UIControlCursor(); // else // m_bUIHasCursor = false; // // // Deal input first // if (m_pInputCtrl) - // m_pInputCtrl->Tick(); + // m_pInputCtrl.Tick(); // // // Tick world - // if (!TickGameWorld(dwDeltaTime, g_pGame->GetViewport())) + // if (!TickGameWorld(dwDeltaTime, g_pGame.GetViewport())) // return false; // Tick UI @@ -1070,10 +1134,10 @@ public partial class CECGameRun : ITickable // m_pUIManager.Tick(); // // Tick GFX caster - // g_pGame->GetGFXCaster()->Tick(dwDeltaTime); + // g_pGame.GetGFXCaster().Tick(dwDeltaTime); // // // Tick GFX Manager - // g_pGame->GetA3DGFXExMan()->Tick(dwDeltaTime); + // g_pGame.GetA3DGFXExMan().Tick(dwDeltaTime); // // // A3DEngine::TickAnimation trigger animation of many objects. // // For example: A3DSky objects, GFX objects etc. @@ -1082,7 +1146,7 @@ public partial class CECGameRun : ITickable // while (dwAnimTime >= TIME_TICKANIMATION) // { // dwAnimTime -= TIME_TICKANIMATION; - // g_pGame->GetA3DEngine()->TickAnimation(); + // g_pGame.GetA3DEngine().TickAnimation(); // } // // // Update ear position so that all 3D sounds' positions are correct @@ -1093,30 +1157,30 @@ public partial class CECGameRun : ITickable // // CECHostPlayer* pHostPlayer = NULL; // if (m_pWorld) - // pHostPlayer = m_pWorld->GetHostPlayer(); + // pHostPlayer = m_pWorld.GetHostPlayer(); // - // A3DCamera * pCamera = g_pGame->GetViewport()->GetA3DCamera(); + // A3DCamera * pCamera = g_pGame.GetViewport().GetA3DCamera(); // - // if (GetGameState() == CECGameRun::GS_GAME && pHostPlayer && pHostPlayer->HostIsReady()) + // if (GetGameState() == CECGameRun::GS_GAME && pHostPlayer && pHostPlayer.HostIsReady()) // { - // AM3DSoundDevice * pAM3DSoundDevice = g_pGame->GetA3DEngine()->GetAMSoundEngine()->GetAM3DSoundDevice(); - // A3DVECTOR3 vecDir = pCamera->GetDirH(); + // AM3DSoundDevice * pAM3DSoundDevice = g_pGame.GetA3DEngine().GetAMSoundEngine().GetAM3DSoundDevice(); + // A3DVECTOR3 vecDir = pCamera.GetDirH(); // A3DVECTOR3 vecUp = A3DVECTOR3(0.0f, 1.0f, 0.0f); // // // Now we should adjust the 3d sound device's pos and orientation; // if (pAM3DSoundDevice) // { - // pAM3DSoundDevice->SetPosition(pHostPlayer->GetPos() + A3DVECTOR3(0.0f, 0.8f, 0.0f)); - // pAM3DSoundDevice->SetOrientation(vecDir, vecUp); - // pAM3DSoundDevice->UpdateChanges(); + // pAM3DSoundDevice.SetPosition(pHostPlayer.GetPos() + A3DVECTOR3(0.0f, 0.8f, 0.0f)); + // pAM3DSoundDevice.SetOrientation(vecDir, vecUp); + // pAM3DSoundDevice.UpdateChanges(); // } // } // else - // g_pGame->GetViewport()->GetA3DCamera()->UpdateEar(); + // g_pGame.GetViewport().GetA3DCamera().UpdateEar(); // } // // // Tick Run-Time debug information - // g_pGame->GetRTDebug()->Tick(dwDeltaTime); + // g_pGame.GetRTDebug().Tick(dwDeltaTime); // // // Save UI configs when time reached // if (m_iGameState == GS_GAME && l_SaveCfgCnt.IncCounter(dwRealTime)) @@ -1127,7 +1191,7 @@ public partial class CECGameRun : ITickable // // l_StatCnt.IncCounter(dwDeltaTime); // - // pSession->ClearOldProtocols(); + // pSession.ClearOldProtocols(); // // DWORD dwCurrentTick = a_GetTime(); // dwTickTime = (dwCurrentTick > dwTickTime) ? (dwCurrentTick - dwTickTime) : 0; @@ -1140,7 +1204,7 @@ public partial class CECGameRun : ITickable // l_fc.iTickTime += (int)dwTickTime; // } // - // if (GetGameState() == GS_GAME && GetHostPlayer() && GetHostPlayer()->HostIsReady()) + // if (GetGameState() == GS_GAME && GetHostPlayer() && GetHostPlayer().HostIsReady()) // { // if (l_bFirstQuery || l_DelayQueryCounter.IncCounter(dwDeltaTime)) // { @@ -1148,14 +1212,14 @@ public partial class CECGameRun : ITickable // // // ·¢ËÍÍøÂçÓµ¼·²éѯЭÒé // l_iDelayTimeStamp = timeGetTime(); - // g_pGame->GetGameSession()->c2s_CmdQueryNetworkDelay(l_iDelayTimeStamp); + // g_pGame.GetGameSession().c2s_CmdQueryNetworkDelay(l_iDelayTimeStamp); // l_DelayQueryCounter.Reset(); // l_bFirstQuery = false; // } // // if (l_QueryServerTime.IncCounter(dwDeltaTime)) // { - // g_pGame->GetGameSession()->c2s_CmdSendGetServerTime(); + // g_pGame.GetGameSession().c2s_CmdSendGetServerTime(); // l_QueryServerTime.Reset(); // } // } @@ -1163,7 +1227,7 @@ public partial class CECGameRun : ITickable // m_pendingLogout.Update(dwDeltaTime); // // // ÓÅ»¯ÄÚ´æµÄÕ¼Óà - // m_pMemSimplify->Tick(dwDeltaTime); + // m_pMemSimplify.Tick(dwDeltaTime); // // // ¸üÐÂÏÂÔØ×´Ì¬ // CECMCDownload::GetInstance().Tick(dwDeltaTime); @@ -1172,7 +1236,7 @@ public partial class CECGameRun : ITickable // CECAutoPolicy::GetInstance().Tick(dwDeltaTime); // // if(m_pRandomMapProc) - // m_pRandomMapProc->Tick(dwDeltaTime); + // m_pRandomMapProc.Tick(dwDeltaTime); // // #ifdef _PROFILE_MEMORY // g_TickMemoryHistory();