#ifndef _NETGLOBAL_H
#define _NETGLOBAL_H

#include "../NetWaker/CliNetWaker.h"
#include "ObjectDataClass.h"
//#include "../roledata/RoleDataEx.h"

using namespace std;

struct  ServerID
{
    ServerID()
    {
        m_iMaster		= -1;
        m_iLocal        = -1;
		m_iChat			= -1;
    };

    int						m_iMaster;
    int                     m_iLocal;
	int						m_iChat;
};


class CNetGlobal
{
public:
	static	void				Initial(const char* db_filename);
	static	void				Release();
	static	void				Process( FLOAT frameTime, FLOAT elapsedTime );
    static  FunctionSchedularClass* Schedular();

	static GameObjDbStructEx*	St_GetObjDB(int OrgID);
	//當角色狀態有改變時
	static  void				St_UpDateEvent(RoleDataEx *Role , RoleUpdateEvent Event);

	static	GameObjDbStructEx*	GetObj( int ObjID )				{ return g_ObjectData->GetObj(ObjID); }
	static	RoleDataEx*         RoleData()						{ return &_RoleData; }
protected:

	static bool							_IsInitial;
	static CliNetWaker			        _Net;
	static ServerID			            _ServerNetID;
	static FunctionSchedularClass*      _Schedular;
	static RoleDataEx					_RoleData;                     //角色資料

    // 功能設定
    static void		SetSrvID_Master	( int iServerID )			{ _ServerNetID.m_iMaster = iServerID; }
    static void		SetSrvID_Local	( int iServerID )			{ _ServerNetID.m_iLocal = iServerID; }
	static void		SetSrvID_Chat	( int iServerID )			{ _ServerNetID.m_iChat = iServerID; }

    static void     Print( int iLV, char* format,... );
    static bool     NetConnect( char* IP , int Port , char* Account , char* Password );
    static bool     Logout();

    // 封包傳輸
    static bool     SendToLocal		( int Size , void* Data		);
    static bool		SendToMaster	( int iSize, void* pData	);
    static bool     SendToChat		( int Size , void* Data		);

};
//-------------------------------------------------------------------------------------------------
#define Def_PrintLV1     1	// 訊息輸出
#define Def_PrintLV2     2	// 特殊訊息
#define Def_PrintLV3     3	// 不可能會發生的錯誤, 如玩家發送錯誤封包
#define Def_PrintLV4     4	// 內不不可能產生的問題
#define Def_PrintLV5     5	// 會當
//-------------------------------------------------------------------------------------------------
#endif