|
想要查看内容赶紧注册登陆吧!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
#include "StdAfx.h"
#include "Resource.h"
#include "Tableframesink.h"
#include "GameServerManager.h"
#include "..\消息定义\CMD_Thirteen.h"
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//构造函数
CGameServiceManager::CGameServiceManager(void)
{
//控件变量
m_pDlgCustomRule=NULL;
//内核属性
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);
//功能标志
m_GameServiceAttrib.cbDynamicJoin=TRUE;
m_GameServiceAttrib.cbAndroidUser=FALSE;
m_GameServiceAttrib.cbOffLineTrustee=FALSE;
//服务属性
m_GameServiceAttrib.dwServerVersion=VERSION_SERVER;
m_GameServiceAttrib.dwClientVersion=VERSION_CLIENT;
lstrcpyn(m_GameServiceAttrib.szGameName,GAME_NAME,CountArray(m_GameServiceAttrib.szGameName));
lstrcpyn(m_GameServiceAttrib.szDataBaseName,TEXT("QPTreasureDB"),CountArray(m_GameServiceAttrib.szDataBaseName));
lstrcpyn(m_GameServiceAttrib.szClientEXEName,TEXT("Thirteen.EXE"),CountArray(m_GameServiceAttrib.szClientEXEName));
lstrcpyn(m_GameServiceAttrib.szServerDLLName,TEXT("ThirteenServer.DLL"),CountArray(m_GameServiceAttrib.szServerDLLName));
return;
}
//析构函数
CGameServiceManager::~CGameServiceManager(void)
{
}
//接口查询
VOID * CGameServiceManager:ueryInterface(const IID & Guid, DWORD dwQueryVer)
{
QUERYINTERFACE(IGameServiceManager,Guid,dwQueryVer);
QUERYINTERFACE(IGameServiceCustomRule,Guid,dwQueryVer);
QUERYINTERFACE_IUNKNOWNEX(IGameServiceManager,Guid,dwQueryVer);
return NULL;
}
//创建游戏桌
VOID * CGameServiceManager::CreateTableFrameSink(REFGUID Guid, DWORD dwQueryVer)
{
//建立对象
CTableFrameSink * pTableFrameSink=NULL;
try
{
pTableFrameSink=new CTableFrameSink();
if (pTableFrameSink==NULL) throw TEXT("创建失败");
void * pObject=pTableFrameSink->QueryInterface(Guid,dwQueryVer);
if (pObject==NULL) throw TEXT("接口查询失败");
return pObject;
}
catch (...) {}
//清理对象
SafeDelete(pTableFrameSink);
return NULL;
}
//创建机器
VOID * CGameServiceManager::CreateAndroidUserItemSink(REFGUID Guid, DWORD dwQueryVer)
{
return NULL;
}
//创建数据
VOID * CGameServiceManager::CreateGameDataBaseEngineSink(REFGUID Guid, DWORD dwQueryVer)
{
return NULL;
}
//获取属性
bool CGameServiceManager::GetServiceAttrib(tagGameServiceAttrib & GameServiceAttrib)
{
GameServiceAttrib=m_GameServiceAttrib;
return true;
}
//参数修改
bool CGameServiceManager::RectifyParameter(tagGameServiceOption & GameServiceOption)
{
//效验参数
ASSERT(&GameServiceOption!=NULL);
if (&GameServiceOption==NULL) return false;
//积分调整
GameServiceOption.lCellScore=__max(1L,GameServiceOption.lCellScore);
//金币房间
if (GameServiceOption.wServerType&GAME_GENRE_GOLD)
{
GameServiceOption.lMinTableScore=__max(GameServiceOption.lCellScore*300L,GameServiceOption.lMinTableScore);
}
return true;
}
//获取配置
bool CGameServiceManager::SaveCustomRule(LPBYTE pcbCustomRule, WORD wCustonSize)
{
//效验状态
ASSERT(m_pDlgCustomRule!=NULL);
if (m_pDlgCustomRule==NULL) return false;
//变量定义
ASSERT(wCustonSize>=sizeof(tagCustomRule));
tagCustomRule * pCustomRule=(tagCustomRule *)pcbCustomRule;
//获取配置
if (m_pDlgCustomRule->GetCustomRule(*pCustomRule)==false)
{
return false;
}
return true;
}
//默认配置
bool CGameServiceManager:efaultCustomRule(LPBYTE pcbCustomRule, WORD wCustonSize)
{
//变量定义
ASSERT(wCustonSize>=sizeof(tagCustomRule));
tagCustomRule * pCustomRule=(tagCustomRule *)pcbCustomRule;
//设置变量
pCustomRule->cbTimeOutCard=20;
pCustomRule->cbTimeStartGame=30;
pCustomRule->cbTimeCallScore=20;
pCustomRule->cbTimeHeadOutCard=30;
//游戏控制
pCustomRule->wMaxScoreTimes=32;
pCustomRule->wFleeScoreTimes=12;
pCustomRule->cbFleeScorePatch=FALSE;
return true;
}
//创建窗口
HWND CGameServiceManager::CreateCustomRule(CWnd * pParentWnd, CRect rcCreate, LPBYTE pcbCustomRule, WORD wCustonSize)
{
//创建窗口
if (m_pDlgCustomRule==NULL)
{
m_pDlgCustomRule=new CDlgCustomRule;
}
//创建窗口
if (m_pDlgCustomRule->m_hWnd==NULL)
{
//设置资源
AfxSetResourceHandle(GetModuleHandle(m_GameServiceAttrib.szServerDLLName));
//创建窗口
m_pDlgCustomRule->Create(IDD_CUSTOM_RULE,pParentWnd);
//还原资源
AfxSetResourceHandle(GetModuleHandle(NULL));
}
//设置变量
ASSERT(wCustonSize>=sizeof(tagCustomRule));
m_pDlgCustomRule->SetCustomRule(*((tagCustomRule *)pcbCustomRule));
//显示窗口
m_pDlgCustomRule->SetWindowPos(NULL,rcCreate.left,rcCreate.top,rcCreate.Width(),rcCreate.Height(),SWP_NOZORDER|SWP_SHOWWINDOW);
return m_pDlgCustomRule->GetSafeHwnd();
}
//////////////////////////////////////////////////////////////////////////////////
//建立对象函数
extern "C" __declspec(dllexport) VOID * CreateGameServiceManager(const GUID & Guid, DWORD dwInterfaceVer)
{
static CGameServiceManager GameServiceManager;
return GameServiceManager.QueryInterface(Guid,dwInterfaceVer);
}
//////////////////////////////////////////////////////////////////////////
|
|