#pragma once

#include "..\..\RoleData\RoleData.h"
#include "..\NetWakerPGEnum.h"

//EM_PG_NEWCONNECT_M2D_XXX

//
//	Client Logout 通知 DB CENTER
//	Request Account's ROLE 資料, 
//


//----------------------------------------------------------------------------------------
struct PG_Login_M2C_IdentifyMaster
{
	PACKET_CONSTRUCT( PG_Login_M2C_IdentifyMaster );
};
//----------------------------------------------------------------------------------------
// Master Server -> DataCenter
// 要求玩家帳號角色資料

struct PG_Login_M2D_LoadAccountData
{	
	PACKET_CONSTRUCT( PG_Login_M2D_LoadAccountData );

	int						iClientID;		// MasterServer 本地端所連接的 ClientID
	char					szAccountName[ _MAX_ACCOUNT_SIZE_ ];
};

//----------------------------------------------------------------------------------------
// DateCenter -> Master Server
// 資料庫在處理角色帳號時發生錯誤

struct PG_Login_D2M_LoadAccountFailed
{
	GamePGCommandEnum		Command;

	int						iErrID;
	int						iClientID;

	PG_Login_D2M_LoadAccountFailed()
	{
		Command = EM_PG_Login_D2M_LoadAccountFailed;
	}
};

//----------------------------------------------------------------------------------------
// DateCenter -> Master Server
// 傳送玩家角色資料，一次一個角色資料，最後一筆Character.Type == ENUM_ObjectType_NULL
//----------------------------------------------------------------------------------------
struct PG_Login_D2M_RoleData
{
	GamePGCommandEnum		Command;

	int						iClientID;
	int						iDBID;								// 角色在資料庫中的索引號

	RoleData				Role;
	
	PG_Login_D2M_RoleData()			{ Command = EM_PG_Login_D2M_RoleData; }
};

struct PG_Login_D2M_RoleDataCount
{
	GamePGCommandEnum		Command;
	int						iClientID;
	int						iRoleCount;

	PG_Login_D2M_RoleDataCount()		{ Command = EM_PG_Login_D2M_RoleDataCount; }
};

//----------------------------------------------------------------------------------------
// Master Server -> Client
// 傳送玩家角色資料，一次一個角色資料，最後一筆Character.Type == ENUM_ObjectType_NULL
//----------------------------------------------------------------------------------------

struct PG_Login_M2C_SampleRoleData
{
	GamePGCommandEnum		Command;
	int						iDBID;
	SampleRoleData			SampleRole;

	PG_Login_M2C_SampleRoleData()
	{
		Command = EM_PG_Login_M2C_SampleRoleData;
	}
};

struct PG_Login_M2C_SampleRoleDataEnd
{
	GamePGCommandEnum		Command;

	PG_Login_M2C_SampleRoleDataEnd()
	{
		Command = EM_PG_Login_M2C_SampleRoleDataEnd;
	}
};



//----------------------------------------------------------------------------------------
// Client -> MasterServer
// Client 創角

struct CreateRoleData
{
	SampleRoleData		SampleRole;

	int					iHairColor;			
	int					iBodyColor;			
	int					iFaceID;			
	int					iHairID;			
	int					iRoleBaseID;		// 身體樣版
};

struct PG_Login_C2M_CreateRole
{
	GamePGCommandEnum	Command;

	int					iFieldIndex;	// 第幾個欄位
	//RoleData			Role;			// 角色資料

	CreateRoleData		CreateRole;


	//char				szAccountName[_MAX_ACCOUNT_SIZE_];
	//char				RoleName[_MAX_NAMERECORD_SIZE_];

	PG_Login_C2M_CreateRole()
	{
		Command = EM_PG_Login_C2M_CreateRole;
	}
};


struct PG_Login_M2D_CreateRole
{
	GamePGCommandEnum	Command;

	int					iClientID;		// 幫助 MasterServer 處理流程所留下的資料

	RoleData			Role;			// 角色資料
	char				szAccountName[_MAX_ACCOUNT_SIZE_];

	PG_Login_M2D_CreateRole()
	{
		Command = EM_PG_Login_M2D_CreateRole;
	}
};

//----------------------------------------------------------------------------------------
// Client -> MasterServer
// Client 創角結果

enum EM_CreateRoleResult
{
	EM_CreateRole_OK							= 0,
	EM_RoleNameExist							= -1,       //角色名稱重覆
    EM_SystemError                              = -2,
};

struct PG_Login_M2C_CreateRoleResult
{
	GamePGCommandEnum	Command;

	int					iDBID;
	EM_CreateRoleResult emResult;
	SampleRoleData		SampleRole;

	PG_Login_M2C_CreateRoleResult()	{ Command = EM_PG_Login_M2C_CreateRoleResult; }
};

struct PG_Login_D2M_CreateRoleResult
{
	GamePGCommandEnum	Command;


	char				RoleName[_MAX_NAMERECORD_SIZE_];
	int					iClientID;
	int					iDBID;
	EM_CreateRoleResult emResult;

	PG_Login_D2M_CreateRoleResult() { Command = EM_PG_Login_D2M_CreateRoleResult; }
};

//----------------------------------------------------------------------------------------
// Client -> MasterServer
// Client 刪角

struct PG_Login_C2M_DeleteRole
{
	GamePGCommandEnum	Command;
	int					iDBID;	// 刪除的角色資料 DBID

	PG_Login_C2M_DeleteRole()
	{
		Command = EM_PG_Login_C2M_DeleteRole;
	}
};

struct PG_Login_M2D_DeleteRole
{
	GamePGCommandEnum	Command;
	//int					iFieldIndex;	// 第幾個欄位
	//RoleData			Role;			// 角色資料
	int					iClientID;
	char				szAccountName[_MAX_ACCOUNT_SIZE_];
	char				szRoleName[_MAX_NAMERECORD_SIZE_];
	int					iDBID;

	PG_Login_M2D_DeleteRole()
	{
		Command = EM_PG_Login_M2D_DeleteRole;
	}
};

//----------------------------------------------------------------------------------------
// Client -> MasterServer
// Client 刪角結果

enum EM_DeleteRoleResult
{
	EM_DeleteRole_OK						= 0,
	EM_RoleNotExist							= -1,
    EM_DeleteSysErr                         = -2,
};

struct PG_Login_M2C_DeleteRoleResult
{
	GamePGCommandEnum	Command;
	EM_DeleteRoleResult emResult;		// 刪除角色的結果
	int					iDBID;			// 角色所在的欄位
	//char				szRoleName[_MAX_NAMERECORD_SIZE_];

	PG_Login_M2C_DeleteRoleResult()
	{
		Command = EM_PG_Login_M2C_DeleteRoleResult;
	}
};

struct PG_Login_D2M_DeleteRoleResult
{
	GamePGCommandEnum	Command;
	EM_DeleteRoleResult emResult;
	int					iDBID;
	//int				iFieldIndex;
	//char				szRoleName[_MAX_NAMERECORD_SIZE_];
	//char				szAccountName[_MAX_ACCOUNT_SIZE_];
	int					iClientID;

	PG_Login_D2M_DeleteRoleResult()
	{
		Command = EM_PG_Login_D2M_DeleteRoleResult;
	}
};



//----------------------------------------------------------------------------------------
// 將角色註冊進入世界

struct PG_Login_M2L_SetRoleToWorld
{
	GamePGCommandEnum		Command;
	int						iClientID;
	RoleData				Role;

	PG_Login_M2L_SetRoleToWorld()
	{
		Command = EM_PG_Login_M2L_SetRoleToWorld;
	}
};

//----------------------------------------------------------------------------------------
// 將角色註冊進入世界

enum EM_SelectRoleResult
{
	EM_SelectRole_OK			= 0,
	EM_SelectRole_No_This		= -1,
	EM_SelectRole_ZoneNotExist	= -2,
};

struct PG_Login_L2M_SetRoleToWorldResult
{
	GamePGCommandEnum			Command;
	int							iClientID;
	int							iDBID;	

	EM_SelectRoleResult			emResult;

	PG_Login_L2M_SetRoleToWorldResult()
	{
		Command = EM_PG_Login_L2M_SetRoleToWorldResult;
	}
};
//----------------------------------------------------------------------------------------
// Client -> MasterServer
// Client 選擇登入遊戲的角色

struct PG_Login_C2M_SelectRole
{
	GamePGCommandEnum	Command;
	int					iDBID;	// 第幾個欄位

	PG_Login_C2M_SelectRole()
	{
		Command = EM_PG_Login_C2M_SelectRole;
	}
};

//----------------------------------------------------------------------------------------
// MasterServer -> Client
// 回傳登入遊戲的角色結果

struct PG_Login_M2C_SelectRoleResult
{
	GamePGCommandEnum	Command;
	EM_SelectRoleResult	emResult;

	int					iDBID;	
	

	PG_Login_M2C_SelectRoleResult()
	{
		Command = EM_PG_Login_M2C_SelectRoleResult;
	}
};

//----------------------------------------------------------------------------------------
// Master Server -> Client
// 角色進入及離開了世界

struct PG_Login_M2C_EnterWorld
{	
	PACKET_CONSTRUCT( PG_Login_M2C_EnterWorld );
};

struct PG_Login_M2C_LeaveWorld
{	
	PACKET_CONSTRUCT( PG_Login_M2C_LeaveWorld );

	int					iDBID;
};