WIP: add code logic send Combo_Save to server
This commit is contained in:
@@ -269,6 +269,7 @@ GameObject:
|
||||
- component: {fileID: 2091984348760918456}
|
||||
- component: {fileID: 7421153329155037236}
|
||||
- component: {fileID: 2013061949432893537}
|
||||
- component: {fileID: 6315749802264791665}
|
||||
m_Layer: 5
|
||||
m_Name: EscapeBtn
|
||||
m_TagString: Untagged
|
||||
@@ -378,6 +379,18 @@ MonoBehaviour:
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!114 &6315749802264791665
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 934635620553056957}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 96de7d56a4514c979bdd93568dba2031, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1131583467895984856
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -457,142 +470,6 @@ MonoBehaviour:
|
||||
m_PointerBehavior: 0
|
||||
m_CursorLockBehavior: 0
|
||||
m_ScrollDeltaPerTick: 6
|
||||
--- !u!1 &1180649769221527971
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1908310604726647551}
|
||||
- component: {fileID: 7432323784403002332}
|
||||
- component: {fileID: 6253396656395833156}
|
||||
m_Layer: 5
|
||||
m_Name: Text (TMP)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1908310604726647551
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1180649769221527971}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8680646788002276863}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &7432323784403002332
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1180649769221527971}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &6253396656395833156
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1180649769221527971}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text:
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4281479730
|
||||
m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_fontColorGradientPreset: {fileID: 0}
|
||||
m_spriteAsset: {fileID: 0}
|
||||
m_tintAllSprites: 0
|
||||
m_StyleSheet: {fileID: 0}
|
||||
m_TextStyleHashCode: -1183493901
|
||||
m_overrideHtmlColors: 0
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 24
|
||||
m_fontSizeBase: 24
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 2
|
||||
m_VerticalAlignment: 512
|
||||
m_textAlignment: 65535
|
||||
m_characterSpacing: 0
|
||||
m_wordSpacing: 0
|
||||
m_lineSpacing: 0
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 0
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
m_horizontalMapping: 0
|
||||
m_verticalMapping: 0
|
||||
m_uvLineOffset: 0
|
||||
m_geometrySortingOrder: 0
|
||||
m_IsTextObjectScaleStatic: 0
|
||||
m_VertexBufferAutoSizeReduction: 0
|
||||
m_useMaxVisibleDescender: 1
|
||||
m_pageToDisplay: 1
|
||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!1 &1182266301883914285
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -824,6 +701,8 @@ MonoBehaviour:
|
||||
minSwipeDistance: 0.1
|
||||
speedX: 60
|
||||
speedY: 500
|
||||
_useEditorSpeed: 1
|
||||
_editorSpeed: {x: 150, y: 600}
|
||||
--- !u!1 &2174337589232334013
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2700,152 +2579,6 @@ MonoBehaviour:
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!1 &5721980010412121515
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8680646788002276863}
|
||||
- component: {fileID: 8076476413184855661}
|
||||
- component: {fileID: 8851603462695586251}
|
||||
- component: {fileID: 5556504023802397200}
|
||||
- component: {fileID: 1370263596141727443}
|
||||
m_Layer: 5
|
||||
m_Name: ExitBtn
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &8680646788002276863
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5721980010412121515}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1908310604726647551}
|
||||
m_Father: {fileID: 3483809415181351540}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 1}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: -880, y: -66.70001}
|
||||
m_SizeDelta: {x: 85, y: 99}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &8076476413184855661
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5721980010412121515}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &8851603462695586251
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5721980010412121515}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: 052d4b5b3b147d04cbd00f737f5c7c53, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &5556504023802397200
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5721980010412121515}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 8851603462695586251}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1890210201668811196}
|
||||
m_TargetAssemblyTypeName: CECUIManager, Assembly-CSharp
|
||||
m_MethodName: ShowUI
|
||||
m_Mode: 5
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument: Win_Quest
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
--- !u!114 &1370263596141727443
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5721980010412121515}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 96de7d56a4514c979bdd93568dba2031, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &5885931642767984348
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3531,7 +3264,6 @@ RectTransform:
|
||||
- {fileID: 984617901920738932}
|
||||
- {fileID: 2783469216819378410}
|
||||
- {fileID: 8913509984865075419}
|
||||
- {fileID: 8680646788002276863}
|
||||
- {fileID: 5823843793071880086}
|
||||
- {fileID: 1462603449517194619}
|
||||
- {fileID: 7020286574697807252}
|
||||
|
||||
@@ -43,5 +43,5 @@ MonoBehaviour:
|
||||
prefab: {fileID: 5492547392745930423, guid: 54cccb2c6a758a24183474cd385ccb2c, type: 3}
|
||||
- id: CDlgInfoTooltip
|
||||
prefab: {fileID: 6830833846243993097, guid: 97dd1de3aba08a04980849e40d5c1ea4, type: 3}
|
||||
- id: CDlgInfoTooltip
|
||||
prefab: {fileID: 6830833846243993097, guid: 97dd1de3aba08a04980849e40d5c1ea4, type: 3}
|
||||
- id: Win_Message2
|
||||
prefab: {fileID: 1590197940424963217, guid: 0c248d0510a114829b58d62d2ecc3b5e, type: 3}
|
||||
|
||||
@@ -1373,6 +1373,7 @@ namespace BrewMonster
|
||||
|
||||
public void SaveBlockedID()
|
||||
{
|
||||
// TODO
|
||||
// Note: Would need character ID
|
||||
// string strDir = Path.Combine(Application.persistentDataPath, "userdata", "blacklist");
|
||||
// Directory.CreateDirectory(strDir);
|
||||
|
||||
@@ -496,6 +496,7 @@ namespace BrewMonster
|
||||
data.AddRange(BitConverter.GetBytes(i));
|
||||
data.AddRange(BitConverter.GetBytes((int)pSC.GetType()));
|
||||
|
||||
// TODO: implement other shortcut types
|
||||
switch ((CECShortcut.ShortcutType)pSC.GetType())
|
||||
{
|
||||
/* case CECShortcut.ShortcutType.SCT_COMMAND:
|
||||
@@ -551,7 +552,7 @@ namespace BrewMonster
|
||||
}*/
|
||||
|
||||
default:
|
||||
Debug.LogError("CECShortcutSet::SaveConfigData - Unknown shortcut type");
|
||||
Debug.LogError($"CECShortcutSet::SaveConfigData - Unknown shortcut type = { pSC.GetType()}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,14 @@ namespace BrewMonster.Scripts
|
||||
btn = GetComponent<Button>();
|
||||
btn.onClick.AddListener(ToggleDlgExit);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if ( Input.GetKeyDown(KeyCode.Escape) )
|
||||
{
|
||||
ToggleDlgExit();
|
||||
}
|
||||
}
|
||||
|
||||
void ToggleDlgExit()
|
||||
{
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace BrewMonster
|
||||
|
||||
private void OnEscapeClicked()
|
||||
{
|
||||
// Open the exit dialog , not directly exit the game
|
||||
return;
|
||||
if(EC_Game.GetGameRun()?.GetHostPlayer() != null)
|
||||
{
|
||||
EC_Game.GetGameRun()?.GetHostPlayer().OnClickBtnEscape();
|
||||
|
||||
@@ -20,6 +20,8 @@ public partial class CECGameRun
|
||||
private static CECGameRun instance;
|
||||
|
||||
#region PROPERTIES AND FIELDS
|
||||
|
||||
private const uint USERCFG_VERSION = 3;
|
||||
|
||||
private GameObject _playerPrefab;
|
||||
private GameObject _monsterPrefab;//CECMonster
|
||||
@@ -100,6 +102,8 @@ public partial class CECGameRun
|
||||
AddressableManager.Instance.OnDispose += Dispose;
|
||||
StartGame(0, Vector3.zero);
|
||||
|
||||
|
||||
m_pWorld = CECWorld.Instance;
|
||||
m_pendingLogout = new CECPendingActionArray( false);
|
||||
}
|
||||
|
||||
@@ -297,8 +301,6 @@ public partial class CECGameRun
|
||||
/// <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");
|
||||
@@ -732,122 +734,92 @@ public partial class CECGameRun
|
||||
public void SetSellingRoleID(int roleid) { m_iSellingRoleID = roleid; }
|
||||
public int GetSellingRoleID() { return m_iSellingRoleID; }
|
||||
|
||||
/* --- Original C++ SaveConfigsToServer (for comparison) ---
|
||||
DWORD CECGameRun::SaveConfigsToServer()
|
||||
{
|
||||
if (!m_pWorld || !m_pWorld->GetHostPlayer() || !m_pWorld->GetHostPlayer()->HostIsReady() || !m_pUIManager->GetInGameUIMan())
|
||||
return 0;
|
||||
g_pGame->GetConfigs()->SaveBlockedID();
|
||||
int iTotalSize = 0;
|
||||
iTotalSize += sizeof (DWORD);
|
||||
iTotalSize += sizeof (int);
|
||||
int iHostSize = 0;
|
||||
CECHostPlayer* pHost = m_pWorld->GetHostPlayer();
|
||||
pHost->SaveConfigData(NULL, &iHostSize);
|
||||
iTotalSize += iHostSize;
|
||||
iTotalSize += sizeof (int);
|
||||
DWORD dwUISize = 0;
|
||||
CECGameUIMan* pGameUI = (CECGameUIMan*)m_pUIManager->GetInGameUIMan();
|
||||
pGameUI->GetUserLayout(NULL, dwUISize);
|
||||
iTotalSize += (int)dwUISize;
|
||||
iTotalSize += sizeof (int);
|
||||
int iSettingSize = 0;
|
||||
g_pGame->GetConfigs()->SaveUserConfigData(NULL, &iSettingSize);
|
||||
iTotalSize += iSettingSize;
|
||||
void* pDataBuf = a_malloctemp(iTotalSize);
|
||||
if (!pDataBuf) { glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECGameRun::SaveConfigsToServer", __LINE__); return 0; }
|
||||
BYTE* pData = (BYTE*)pDataBuf;
|
||||
*((DWORD*)pData) = USERCFG_VERSION;
|
||||
pData += sizeof (DWORD);
|
||||
*((int*)pData) = iHostSize;
|
||||
pData += sizeof (int);
|
||||
pHost->SaveConfigData(pData, &iHostSize);
|
||||
pData += iHostSize;
|
||||
*((int*)pData) = (int)dwUISize;
|
||||
pData += sizeof (int);
|
||||
pGameUI->GetUserLayout(pData, dwUISize);
|
||||
pData += dwUISize;
|
||||
*((int*)pData) = iSettingSize;
|
||||
pData += sizeof (int);
|
||||
g_pGame->GetConfigs()->SaveUserConfigData(pData, &iSettingSize);
|
||||
pData += iSettingSize;
|
||||
if (m_pCfgDataBuf) {
|
||||
if (m_iCfgDataSize == iTotalSize && !memcmp(m_pCfgDataBuf, pDataBuf, iTotalSize)) { a_freetemp(pDataBuf); return 1; }
|
||||
a_free(m_pCfgDataBuf); m_pCfgDataBuf = NULL; m_iCfgDataSize = 0;
|
||||
}
|
||||
if ((m_pCfgDataBuf = (BYTE*)a_malloc(iTotalSize))) { memcpy(m_pCfgDataBuf, pDataBuf, iTotalSize); m_iCfgDataSize = iTotalSize; }
|
||||
DWORD dwCompLen = iTotalSize * 2;
|
||||
void* pCompBuf = a_malloctemp(dwCompLen);
|
||||
if (!pCompBuf) { a_freetemp(pDataBuf); glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECGameRun::SaveConfigsToServer", __LINE__); return 0; }
|
||||
int iVerLen = sizeof (DWORD);
|
||||
memcpy(pCompBuf, pDataBuf, iVerLen);
|
||||
BYTE* pSrc = (BYTE*)pDataBuf + iVerLen;
|
||||
BYTE* pDst = (BYTE*)pCompBuf + iVerLen;
|
||||
dwCompLen -= iVerLen;
|
||||
int iRes = AFilePackage::Compress(pSrc, iTotalSize - iVerLen, pDst, &dwCompLen);
|
||||
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);
|
||||
return iRes;
|
||||
}
|
||||
--- End original C++ --- */
|
||||
// Save necessary user configs (UI, shortcut, accelerate keys, etc.) to server
|
||||
// ����ֵ: 0(����ʧ��), 1(���������ظ�����), 2(�������������Э��)
|
||||
public uint SaveConfigsToServer()
|
||||
{
|
||||
const uint USERCFG_VERSION = 3;
|
||||
|
||||
// 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;
|
||||
|
||||
EC_Game.GetConfigs().SaveBlockedID();
|
||||
// g_pGame->GetConfigs()->SaveBlockedID();
|
||||
EC_Game.GetConfigs().SaveBlockedID(); // TODO: Check if this is needed here
|
||||
|
||||
// Calculate total size: version + host + UI + settings
|
||||
// int iTotalSize = 0;
|
||||
// iTotalSize += sizeof (DWORD);
|
||||
// iTotalSize += sizeof (int);
|
||||
// int iHostSize = 0;
|
||||
// CECHostPlayer* pHost = m_pWorld->GetHostPlayer();
|
||||
// pHost->SaveConfigData(NULL, &iHostSize);
|
||||
// iTotalSize += iHostSize;
|
||||
// iTotalSize += sizeof (int);
|
||||
int iTotalSize = sizeof(uint);
|
||||
|
||||
int iHostSize = 0;
|
||||
pHost.SaveConfigData(null, ref iHostSize);
|
||||
iTotalSize += sizeof(int) + iHostSize;
|
||||
|
||||
// DWORD dwUISize = 0;
|
||||
// CECGameUIMan* pGameUI = (CECGameUIMan*)m_pUIManager->GetInGameUIMan();
|
||||
// pGameUI->GetUserLayout(NULL, dwUISize);
|
||||
// iTotalSize += (int)dwUISize;
|
||||
// iTotalSize += sizeof (int);
|
||||
uint dwUISize = 0;
|
||||
pGameUI.GetUserLayout(null, ref dwUISize);
|
||||
iTotalSize += sizeof(int) + (int)dwUISize;
|
||||
|
||||
// int iSettingSize = 0;
|
||||
// g_pGame->GetConfigs()->SaveUserConfigData(NULL, &iSettingSize);
|
||||
// iTotalSize += iSettingSize;
|
||||
int iSettingSize = 0;
|
||||
EC_Game.GetConfigs().SaveUserConfigData(null, out iSettingSize);
|
||||
iTotalSize += sizeof(int) + iSettingSize;
|
||||
|
||||
// void* pDataBuf = a_malloctemp(iTotalSize);
|
||||
// if (!pDataBuf) { glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECGameRun::SaveConfigsToServer", __LINE__); return 0; }
|
||||
// BYTE* pData = (BYTE*)pDataBuf;
|
||||
byte[] pDataBuf = new byte[iTotalSize];
|
||||
int offset = 0;
|
||||
|
||||
// Write version
|
||||
// *((DWORD*)pData) = USERCFG_VERSION;
|
||||
// pData += sizeof (DWORD);
|
||||
Buffer.BlockCopy(BitConverter.GetBytes(USERCFG_VERSION), 0, pDataBuf, offset, sizeof(uint));
|
||||
offset += sizeof(uint);
|
||||
|
||||
// Write host block (length + data)
|
||||
// *((int*)pData) = iHostSize;
|
||||
// pData += sizeof (int);
|
||||
// pHost->SaveConfigData(pData, &iHostSize);
|
||||
// pData += iHostSize;
|
||||
Buffer.BlockCopy(BitConverter.GetBytes(iHostSize), 0, pDataBuf, offset, sizeof(int));
|
||||
offset += sizeof(int);
|
||||
pHost.SaveConfigData(pDataBuf, ref iHostSize, offset);
|
||||
offset += iHostSize;
|
||||
|
||||
// Write UI block (length + data)
|
||||
// *((int*)pData) = (int)dwUISize;
|
||||
// pData += sizeof (int);
|
||||
// pGameUI->GetUserLayout(pData, dwUISize);
|
||||
// pData += dwUISize;
|
||||
Buffer.BlockCopy(BitConverter.GetBytes((int)dwUISize), 0, pDataBuf, offset, sizeof(int));
|
||||
offset += sizeof(int);
|
||||
pGameUI.GetUserLayout(pDataBuf, ref dwUISize);
|
||||
offset += (int)dwUISize;
|
||||
|
||||
// Write user setting block (length + data)
|
||||
// *((int*)pData) = iSettingSize;
|
||||
// pData += sizeof (int);
|
||||
// g_pGame->GetConfigs()->SaveUserConfigData(pData, &iSettingSize);
|
||||
// pData += iSettingSize;
|
||||
Buffer.BlockCopy(BitConverter.GetBytes(iSettingSize), 0, pDataBuf, offset, sizeof(int));
|
||||
offset += sizeof(int);
|
||||
EC_Game.GetConfigs().SaveUserConfigData(pDataBuf, offset, out iSettingSize);
|
||||
offset += iSettingSize;
|
||||
|
||||
// Here we make a cache. If the data will be sent is same as last
|
||||
// time, we can ignore it.
|
||||
// Skip send if data is identical to last time
|
||||
// if (m_pCfgDataBuf) {
|
||||
// if (m_iCfgDataSize == iTotalSize && !memcmp(m_pCfgDataBuf, pDataBuf, iTotalSize)) { a_freetemp(pDataBuf); return 1; }
|
||||
// a_free(m_pCfgDataBuf); m_pCfgDataBuf = NULL; m_iCfgDataSize = 0;
|
||||
// }
|
||||
if (m_pCfgDataBuf != null && m_iCfgDataSize == iTotalSize)
|
||||
{
|
||||
bool same = true;
|
||||
@@ -856,21 +828,34 @@ public partial class CECGameRun
|
||||
if (same)
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_pCfgDataBuf = null;
|
||||
m_iCfgDataSize = 0;
|
||||
|
||||
// if ((m_pCfgDataBuf = (BYTE*)a_malloc(iTotalSize))) { memcpy(m_pCfgDataBuf, pDataBuf, iTotalSize); m_iCfgDataSize = iTotalSize; }
|
||||
m_pCfgDataBuf = new byte[iTotalSize];
|
||||
Buffer.BlockCopy(pDataBuf, 0, m_pCfgDataBuf, 0, iTotalSize);
|
||||
m_iCfgDataSize = iTotalSize;
|
||||
|
||||
// Compress payload (version kept uncompressed)
|
||||
// DWORD dwCompLen = iTotalSize * 2;
|
||||
// void* pCompBuf = a_malloctemp(dwCompLen);
|
||||
// if (!pCompBuf) { a_freetemp(pDataBuf); glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECGameRun::SaveConfigsToServer", __LINE__); return 0; }
|
||||
// int iVerLen = sizeof (DWORD);
|
||||
// memcpy(pCompBuf, pDataBuf, iVerLen);
|
||||
// BYTE* pSrc = (BYTE*)pDataBuf + iVerLen;
|
||||
// BYTE* pDst = (BYTE*)pCompBuf + iVerLen;
|
||||
// dwCompLen -= iVerLen;
|
||||
// int iRes = AFilePackage::Compress(pSrc, iTotalSize - iVerLen, pDst, &dwCompLen);
|
||||
int iVerLen = sizeof(uint);
|
||||
int compLen = (iTotalSize - iVerLen) * 2;
|
||||
byte[] pCompBuf = new byte[iVerLen + compLen];
|
||||
Buffer.BlockCopy(pDataBuf, 0, pCompBuf, 0, iVerLen);
|
||||
|
||||
int iRes = AFilePackage.Compress(pDataBuf, iTotalSize - iVerLen, pCompBuf, iVerLen, ref compLen);
|
||||
|
||||
// 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);
|
||||
// return iRes;
|
||||
if (iRes == 0)
|
||||
{
|
||||
var session = UnityGameSession.Instance?.GameSession;
|
||||
@@ -882,9 +867,7 @@ public partial class CECGameRun
|
||||
}
|
||||
else
|
||||
BMLogger.LogWarning($"CECGameRun::SaveConfigsToServer, Failed to compress config data ({iRes}:{iTotalSize})");
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public void ReleasePendingActions()
|
||||
|
||||
Reference in New Issue
Block a user