226 lines
5.9 KiB
C++
226 lines
5.9 KiB
C++
|
|
#include "StdAfx.h"
|
|||
|
|
#include "Resource.h"
|
|||
|
|
#include "Tableframesink.h"
|
|||
|
|
#include "GameServerManager.h"
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#ifndef _DEBUG
|
|||
|
|
#define ANDROID_SERVICE_DLL_NAME TEXT("NiuNiuAndroid.dll") //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#else
|
|||
|
|
#define ANDROID_SERVICE_DLL_NAME TEXT("NiuNiuAndroid.dll") //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>캯<EFBFBD><ECBAAF>
|
|||
|
|
CGameServiceManager::CGameServiceManager(void)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_GameServiceAttrib.wKindID=KIND_ID;
|
|||
|
|
m_GameServiceAttrib.wChairCount=GAME_PLAYER;
|
|||
|
|
m_GameServiceAttrib.wSupporType=(GAME_GENRE_GOLD|GAME_GENRE_SCORE|GAME_GENRE_MATCH|GAME_GENRE_EDUCATE);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ܱ<EFBFBD>־
|
|||
|
|
m_GameServiceAttrib.cbDynamicJoin = TRUE;
|
|||
|
|
m_GameServiceAttrib.cbAndroidUser=TRUE;
|
|||
|
|
m_GameServiceAttrib.cbOffLineTrustee=FALSE;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_GameServiceAttrib.dwServerVersion=VERSION_SERVER;
|
|||
|
|
m_GameServiceAttrib.dwClientVersion=VERSION_CLIENT;
|
|||
|
|
lstrcpyn(m_GameServiceAttrib.szGameName,GAME_NAME,CountArray(m_GameServiceAttrib.szGameName));
|
|||
|
|
lstrcpyn(m_GameServiceAttrib.szDataBaseName,szTreasureDB,CountArray(m_GameServiceAttrib.szDataBaseName));
|
|||
|
|
lstrcpyn(m_GameServiceAttrib.szClientEXEName,TEXT("NiuNiu.exe"),CountArray(m_GameServiceAttrib.szClientEXEName));
|
|||
|
|
lstrcpyn(m_GameServiceAttrib.szServerDLLName,TEXT("NiuNiuServer.dll"),CountArray(m_GameServiceAttrib.szServerDLLName));
|
|||
|
|
|
|||
|
|
m_pDlgCustomRule=NULL;
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CGameServiceManager::~CGameServiceManager(void)
|
|||
|
|
{
|
|||
|
|
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
SafeDelete(m_pDlgCustomRule);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>ӿڲ<D3BF>ѯ
|
|||
|
|
VOID * CGameServiceManager::QueryInterface(const IID & Guid, DWORD dwQueryVer)
|
|||
|
|
{
|
|||
|
|
QUERYINTERFACE(IGameServiceManager,Guid,dwQueryVer);
|
|||
|
|
QUERYINTERFACE(IGameServiceCustomRule,Guid,dwQueryVer);
|
|||
|
|
QUERYINTERFACE_IUNKNOWNEX(IGameServiceManager,Guid,dwQueryVer);
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7>
|
|||
|
|
VOID * CGameServiceManager::CreateTableFrameSink(REFGUID Guid, DWORD dwQueryVer)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CTableFrameSink * pTableFrameSink=NULL;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
pTableFrameSink=new CTableFrameSink();
|
|||
|
|
if (pTableFrameSink==NULL) throw TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>");
|
|||
|
|
void * pObject=pTableFrameSink->QueryInterface(Guid,dwQueryVer);
|
|||
|
|
if (pObject==NULL) throw TEXT("<EFBFBD>ӿڲ<EFBFBD>ѯʧ<EFBFBD><EFBFBD>");
|
|||
|
|
return pObject;
|
|||
|
|
}
|
|||
|
|
catch (...) {}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
SafeDelete(pTableFrameSink);
|
|||
|
|
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
bool CGameServiceManager::GetServiceAttrib(tagGameServiceAttrib & GameServiceAttrib)
|
|||
|
|
{
|
|||
|
|
GameServiceAttrib=m_GameServiceAttrib;
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CGameServiceManager::RectifyParameter(tagGameServiceOption & GameServiceOption)
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(&GameServiceOption!=NULL);
|
|||
|
|
if (&GameServiceOption==NULL) return false;
|
|||
|
|
|
|||
|
|
//<2F><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>
|
|||
|
|
GameServiceOption.lCellScore=__max(1L,GameServiceOption.lCellScore);
|
|||
|
|
|
|||
|
|
////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
//if (GameServiceOption.wServerType!=GAME_GENRE_SCORE)
|
|||
|
|
//{
|
|||
|
|
// GameServiceOption.lMinTableScore=__max(GameServiceOption.lCellScore*50L,GameServiceOption.lMinTableScore);
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
CTableFrameSink::ReadServerConfig(&GameServiceOption);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
bool CGameServiceManager::SaveCustomRule(LPBYTE pcbCustomRule, WORD wCustonSize)
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7>״̬
|
|||
|
|
ASSERT(m_pDlgCustomRule!=NULL);
|
|||
|
|
if (m_pDlgCustomRule==NULL) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(wCustonSize>=sizeof(tagCustomRule));
|
|||
|
|
tagCustomRule * pCustomRule=(tagCustomRule *)pcbCustomRule;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
if (m_pDlgCustomRule->GetCustomRule(*pCustomRule)==false)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CGameServiceManager::DefaultCustomRule(LPBYTE pcbCustomRule, WORD wCustonSize)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(wCustonSize>=sizeof(tagCustomRule));
|
|||
|
|
tagCustomRule * pCustomRule=(tagCustomRule *)pcbCustomRule;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
pCustomRule->lRoomStorageStart = 100000;
|
|||
|
|
pCustomRule->lRoomStorageDeduct = 0;
|
|||
|
|
pCustomRule->lRoomStorageMax1 = 1000000;
|
|||
|
|
pCustomRule->lRoomStorageMul1 = 50;
|
|||
|
|
pCustomRule->lRoomStorageMax2 = 5000000;
|
|||
|
|
pCustomRule->lRoomStorageMul2 = 80;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><CBB4><EFBFBD>ȡ<EFBFBD><C8A1>
|
|||
|
|
pCustomRule->lRobotScoreMin = 100000;
|
|||
|
|
pCustomRule->lRobotScoreMax = 1000000;
|
|||
|
|
pCustomRule->lRobotBankGet = 1000000;
|
|||
|
|
pCustomRule->lRobotBankGetBanker = 10000000;
|
|||
|
|
pCustomRule->lRobotBankStoMul = 10;
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
HWND CGameServiceManager::CreateCustomRule(CWnd * pParentWnd, CRect rcCreate, LPBYTE pcbCustomRule, WORD wCustonSize)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (m_pDlgCustomRule==NULL)
|
|||
|
|
{
|
|||
|
|
m_pDlgCustomRule=new CDlgCustomRule;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (m_pDlgCustomRule->m_hWnd==NULL)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
|
|||
|
|
AfxSetResourceHandle(GetModuleHandle(m_GameServiceAttrib.szServerDLLName));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pDlgCustomRule->Create(IDD_CUSTOM_RULE,pParentWnd);
|
|||
|
|
|
|||
|
|
//<2F><>ԭ<EFBFBD><D4AD>Դ
|
|||
|
|
AfxSetResourceHandle(GetModuleHandle(NULL));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
ASSERT(wCustonSize>=sizeof(tagCustomRule));
|
|||
|
|
m_pDlgCustomRule->SetCustomRule(*((tagCustomRule *)pcbCustomRule));
|
|||
|
|
|
|||
|
|
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|||
|
|
m_pDlgCustomRule->SetWindowPos(NULL,rcCreate.left,rcCreate.top,rcCreate.Width(),rcCreate.Height(),SWP_NOZORDER|SWP_SHOWWINDOW);
|
|||
|
|
|
|||
|
|
return m_pDlgCustomRule->GetSafeHwnd();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
VOID * CGameServiceManager::CreateAndroidUserItemSink(REFGUID Guid, DWORD dwQueryVer)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (m_AndroidServiceHelper.GetInterface() == NULL)
|
|||
|
|
{
|
|||
|
|
m_AndroidServiceHelper.SetModuleCreateInfo(ANDROID_SERVICE_DLL_NAME, "CreateGameServiceManager");
|
|||
|
|
|
|||
|
|
if (!m_AndroidServiceHelper.CreateInstance()) throw 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
VOID *pAndroidObject = m_AndroidServiceHelper->CreateAndroidUserItemSink(Guid, dwQueryVer);
|
|||
|
|
if (pAndroidObject == NULL)
|
|||
|
|
{
|
|||
|
|
CTraceService::TraceString(TEXT("CGameServiceManager<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>"), TraceLevel_Exception);
|
|||
|
|
throw TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>");
|
|||
|
|
}
|
|||
|
|
return pAndroidObject;
|
|||
|
|
}
|
|||
|
|
catch (...) {}
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
VOID * CGameServiceManager::CreateGameDataBaseEngineSink(REFGUID Guid, DWORD dwQueryVer)
|
|||
|
|
{
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
extern "C" __declspec(dllexport) VOID * CreateGameServiceManager(REFGUID Guid, DWORD dwInterfaceVer)
|
|||
|
|
{
|
|||
|
|
static CGameServiceManager GameServiceManager;
|
|||
|
|
return GameServiceManager.QueryInterface(Guid,dwInterfaceVer);
|
|||
|
|
}
|