诸暨麻将添加redis
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1186 lines
42 KiB

  1. #include "StdAfx.h"
  2. #include "ModuleDBParameter.h"
  3. #include "ServerInfoManager.h"
  4. //////////////////////////////////////////////////////////////////////////////////
  5. //构造函数
  6. CServerInfoBuffer::CServerInfoBuffer()
  7. {
  8. }
  9. //析构函数
  10. CServerInfoBuffer::~CServerInfoBuffer()
  11. {
  12. //变量定义
  13. WORD wServerID = 0;
  14. tagGameServerInfo * pGameServerInfo = NULL;
  15. POSITION Position = m_GameServerInfoMap.GetStartPosition();
  16. //删除索引
  17. while (Position != NULL)
  18. {
  19. m_GameServerInfoMap.GetNextAssoc(Position, wServerID, pGameServerInfo);
  20. SafeDelete(pGameServerInfo);
  21. }
  22. //删除数组
  23. for (INT_PTR i = 0; i < m_GameServerInfoArray.GetCount(); i++)
  24. {
  25. pGameServerInfo = m_GameServerInfoArray[i];
  26. SafeDelete(pGameServerInfo);
  27. }
  28. //删除引用
  29. m_GameServerInfoMap.RemoveAll();
  30. m_GameServerInfoArray.RemoveAll();
  31. return;
  32. }
  33. //重置数据
  34. bool CServerInfoBuffer::ResetServerInfo()
  35. {
  36. //变量定义
  37. WORD wServerID = 0;
  38. tagGameServerInfo * pGameServerInfo = NULL;
  39. POSITION Position = m_GameServerInfoMap.GetStartPosition();
  40. //删除对象
  41. while (Position != NULL)
  42. {
  43. m_GameServerInfoMap.GetNextAssoc(Position, wServerID, pGameServerInfo);
  44. m_GameServerInfoArray.Add(pGameServerInfo);
  45. }
  46. //删除索引
  47. m_GameServerInfoMap.RemoveAll();
  48. return true;
  49. }
  50. //删除数据
  51. bool CServerInfoBuffer::DeleteServerInfo(WORD wServerID)
  52. {
  53. //查找类型
  54. tagGameServerInfo * pGameServerInfo = NULL;
  55. if (m_GameServerInfoMap.Lookup(wServerID, pGameServerInfo) == FALSE) return false;
  56. //删除数据
  57. m_GameServerInfoMap.RemoveKey(wServerID);
  58. m_GameServerInfoArray.Add(pGameServerInfo);
  59. //设置变量
  60. ZeroMemory(pGameServerInfo, sizeof(tagGameServerInfo));
  61. return true;
  62. }
  63. //插入数据
  64. bool CServerInfoBuffer::InsertServerInfo(tagGameServerInfo * pGameServerInfo)
  65. {
  66. //效验参数
  67. ASSERT(pGameServerInfo != NULL);
  68. if (pGameServerInfo == NULL) return false;
  69. //查找现存
  70. WORD wServerID = pGameServerInfo->wServerID;
  71. tagGameServerInfo * pGameServerInsert = SearchServerInfo(wServerID);
  72. //创建判断
  73. if (pGameServerInsert == NULL)
  74. {
  75. //创建对象
  76. pGameServerInsert = CreateServerInfo();
  77. //结果判断
  78. if (pGameServerInsert == NULL)
  79. {
  80. ASSERT(FALSE);
  81. return false;
  82. }
  83. }
  84. //设置数据
  85. m_GameServerInfoMap[wServerID] = pGameServerInsert;
  86. CopyMemory(pGameServerInsert, pGameServerInfo, sizeof(tagGameServerInfo));
  87. return true;
  88. }
  89. //获取数目
  90. DWORD CServerInfoBuffer::GetServerInfoCount()
  91. {
  92. return (DWORD)(m_GameServerInfoMap.GetCount());
  93. }
  94. //查找数据
  95. tagGameServerInfo * CServerInfoBuffer::SearchServerInfo(WORD wServerID)
  96. {
  97. tagGameServerInfo * pGameServerInfo = NULL;
  98. m_GameServerInfoMap.Lookup(wServerID, pGameServerInfo);
  99. return pGameServerInfo;
  100. }
  101. //创建对象
  102. tagGameServerInfo * CServerInfoBuffer::CreateServerInfo()
  103. {
  104. //变量定义
  105. tagGameServerInfo * pGameServerInfo = NULL;
  106. //创建对象
  107. try
  108. {
  109. INT_PTR nArrayCount = m_GameServerInfoArray.GetCount();
  110. if (nArrayCount > 0)
  111. {
  112. pGameServerInfo = m_GameServerInfoArray[nArrayCount - 1];
  113. m_GameServerInfoArray.RemoveAt(nArrayCount - 1);
  114. }
  115. else
  116. {
  117. pGameServerInfo = new tagGameServerInfo;
  118. if (pGameServerInfo == NULL) return NULL;
  119. }
  120. }
  121. catch (...) { return false; }
  122. //设置变量
  123. ZeroMemory(pGameServerInfo, sizeof(tagGameServerInfo));
  124. return pGameServerInfo;
  125. }
  126. //////////////////////////////////////////////////////////////////////////////////
  127. //构造函数
  128. CMatchOptionBuffer::CMatchOptionBuffer()
  129. {
  130. }
  131. //析构函数
  132. CMatchOptionBuffer::~CMatchOptionBuffer()
  133. {
  134. //变量定义
  135. tagGameMatchOption * pGameMatchOption = NULL;
  136. //删除数组
  137. m_GameMatchOptionBuffer.Append(m_GameMatchOptionArray);
  138. for (INT_PTR i = 0; i < m_GameMatchOptionBuffer.GetCount(); i++)
  139. {
  140. pGameMatchOption = m_GameMatchOptionBuffer[i];
  141. SafeDelete(pGameMatchOption);
  142. }
  143. //删除引用
  144. m_GameMatchOptionArray.RemoveAll();
  145. m_GameMatchOptionBuffer.RemoveAll();
  146. return;
  147. }
  148. //重置数据
  149. bool CMatchOptionBuffer::ResetMatchOption()
  150. {
  151. //添加对象
  152. m_GameMatchOptionBuffer.Append(m_GameMatchOptionArray);
  153. //删除元素
  154. m_GameMatchOptionArray.RemoveAll();
  155. return true;
  156. }
  157. //删除数据
  158. bool CMatchOptionBuffer::DeleteMatchOption(DWORD dwMatchID, DWORD wMatchNO)
  159. {
  160. //变量定义
  161. tagGameMatchOption * pGameMatchOption = NULL;
  162. //查找对象
  163. for (INT_PTR i = 0; i < m_GameMatchOptionArray.GetCount(); i++)
  164. {
  165. pGameMatchOption = m_GameMatchOptionArray[i];
  166. if (pGameMatchOption->dwMatchID == dwMatchID && pGameMatchOption->dwMatchNO == wMatchNO)
  167. {
  168. //删除数据
  169. m_GameMatchOptionArray.RemoveAt(i);
  170. m_GameMatchOptionBuffer.Add(pGameMatchOption);
  171. //设置变量
  172. ZeroMemory(pGameMatchOption, sizeof(tagGameMatchOption));
  173. break;
  174. }
  175. }
  176. return true;
  177. }
  178. //插入数据
  179. bool CMatchOptionBuffer::InsertMatchOption(tagGameMatchOption * pGameMatchOption)
  180. {
  181. //效验参数
  182. ASSERT(pGameMatchOption != NULL);
  183. if (pGameMatchOption == NULL) return false;
  184. //查找现存
  185. tagGameMatchOption * pGameMatchInsert = SearchMatchOption(pGameMatchOption->dwMatchID, pGameMatchOption->dwMatchNO);
  186. //创建判断
  187. if (pGameMatchInsert == NULL)
  188. {
  189. //创建对象
  190. pGameMatchInsert = CreateMatchOption();
  191. //结果判断
  192. if (pGameMatchInsert == NULL)
  193. {
  194. ASSERT(FALSE);
  195. return false;
  196. }
  197. }
  198. //设置数据
  199. m_GameMatchOptionArray.Add(pGameMatchInsert);
  200. CopyMemory(pGameMatchInsert, pGameMatchOption, sizeof(tagGameMatchOption));
  201. return true;
  202. }
  203. //获取数目
  204. DWORD CMatchOptionBuffer::GetMatchOptionCount()
  205. {
  206. return (DWORD)(m_GameMatchOptionArray.GetCount());
  207. }
  208. //查找数据
  209. tagGameMatchOption * CMatchOptionBuffer::SearchMatchOption(DWORD dwMatchID, DWORD wMatchNO)
  210. {
  211. //变量定义
  212. tagGameMatchOption * pGameMatchOption = NULL;
  213. //查找对象
  214. for (INT_PTR i = 0; i < m_GameMatchOptionArray.GetCount(); i++)
  215. {
  216. pGameMatchOption = m_GameMatchOptionArray[i];
  217. if (pGameMatchOption->dwMatchID == dwMatchID && pGameMatchOption->dwMatchNO == wMatchNO)
  218. {
  219. return pGameMatchOption;
  220. }
  221. }
  222. return NULL;
  223. }
  224. //创建对象
  225. tagGameMatchOption * CMatchOptionBuffer::CreateMatchOption()
  226. {
  227. //变量定义
  228. tagGameMatchOption * pGameMatchOption = NULL;
  229. //创建对象
  230. try
  231. {
  232. INT_PTR nArrayCount = m_GameMatchOptionBuffer.GetCount();
  233. if (nArrayCount > 0)
  234. {
  235. pGameMatchOption = m_GameMatchOptionBuffer[nArrayCount - 1];
  236. m_GameMatchOptionBuffer.RemoveAt(nArrayCount - 1);
  237. }
  238. else
  239. {
  240. pGameMatchOption = new tagGameMatchOption;
  241. if (pGameMatchOption == NULL) return NULL;
  242. }
  243. }
  244. catch (...) { return false; }
  245. //设置变量
  246. ZeroMemory(pGameMatchOption, sizeof(tagGameMatchOption));
  247. return pGameMatchOption;
  248. }
  249. //////////////////////////////////////////////////////////////////////////////////
  250. //构造函数
  251. CServerInfoManager::CServerInfoManager()
  252. {
  253. }
  254. //析构函数
  255. CServerInfoManager::~CServerInfoManager()
  256. {
  257. }
  258. //加载房间 \存储过程\数据库SQL\DataBase\Script\Platform\存储过程\平台数据库\房间管理.sql
  259. bool CServerInfoManager::LoadGameServerInfo(TCHAR szMachineID[LEN_MACHINE_ID], CServerInfoBuffer & ServerInfoBuffer)
  260. {
  261. //变量定义
  262. CDataBaseAide PlatformDBAide;
  263. CDataBaseHelper PlatformDBModule;
  264. //执行逻辑
  265. try
  266. {
  267. //连接数据库
  268. if (ConnectPlatformDB(PlatformDBModule) == false)
  269. {
  270. ASSERT(FALSE);
  271. return false;
  272. }
  273. //设置对象
  274. PlatformDBAide.SetDataBase(PlatformDBModule.GetInterface());
  275. //插入参数
  276. PlatformDBAide.ResetParameter();
  277. PlatformDBAide.AddParameter(TEXT("@wServerID"), 0);
  278. PlatformDBAide.AddParameter(TEXT("@strServiceMachine"), szMachineID);
  279. //输出信息
  280. TCHAR szDescribeString[128] = TEXT("");
  281. PlatformDBAide.AddParameterOutput(TEXT("@strErrorDescribe"), szDescribeString, sizeof(szDescribeString), adParamOutput);
  282. //读取列表
  283. if (PlatformDBAide.ExecuteProcess(TEXT("GSP_GS_LoadGameRoomItem"), true) != DB_SUCCESS)
  284. {
  285. //获取信息
  286. PlatformDBAide.GetParameter(TEXT("@strErrorDescribe"), szDescribeString, CountArray(szDescribeString));
  287. //错误提示
  288. CTraceService::TraceString(szDescribeString, TraceLevel_Exception);
  289. //错误提示
  290. AfxMessageBox(szDescribeString, MB_ICONERROR);
  291. return false;
  292. }
  293. //清空列表
  294. ServerInfoBuffer.ResetServerInfo();
  295. //读取列表
  296. while (PlatformDBModule->IsRecordsetEnd() == false)
  297. {
  298. //读取数据
  299. tagGameServerInfo GameServerResult;
  300. ReadGameServerInfo(PlatformDBAide, GameServerResult);
  301. //插入列表
  302. ServerInfoBuffer.InsertServerInfo(&GameServerResult);
  303. //移动记录
  304. PlatformDBModule->MoveToNext();
  305. }
  306. return true;
  307. }
  308. catch (IDataBaseException * pIException)
  309. {
  310. //错误信息
  311. LPCTSTR pszDescribe = pIException->GetExceptionDescribe();
  312. CTraceService::TraceString(pszDescribe, TraceLevel_Exception);
  313. //错误提示
  314. AfxMessageBox(pszDescribe, MB_ICONERROR);
  315. return false;
  316. }
  317. return false;
  318. }
  319. //加载房间
  320. bool CServerInfoManager::LoadGameServerInfo(TCHAR szMachineID[LEN_MACHINE_ID], WORD wServerID, tagGameServerInfo & GameServerResult)
  321. {
  322. //变量定义
  323. CDataBaseAide PlatformDBAide;
  324. CDataBaseHelper PlatformDBModule;
  325. //执行逻辑
  326. try
  327. {
  328. //连接数据库
  329. if (ConnectPlatformDB(PlatformDBModule) == false)
  330. {
  331. ASSERT(FALSE);
  332. return false;
  333. }
  334. //设置对象
  335. PlatformDBAide.SetDataBase(PlatformDBModule.GetInterface());
  336. //读取列表
  337. PlatformDBAide.ResetParameter();
  338. PlatformDBAide.AddParameter(TEXT("@wServerID"), wServerID);
  339. PlatformDBAide.AddParameter(TEXT("@strServiceMachine"), szMachineID);
  340. //输出信息
  341. TCHAR szDescribeString[128] = TEXT("");
  342. PlatformDBAide.AddParameterOutput(TEXT("@strErrorDescribe"), szDescribeString, sizeof(szDescribeString), adParamOutput);
  343. //读取列表
  344. if (PlatformDBAide.ExecuteProcess(TEXT("GSP_GS_LoadGameRoomItem"), true) != DB_SUCCESS)
  345. {
  346. //获取信息
  347. PlatformDBAide.GetParameter(TEXT("@strErrorDescribe"), szDescribeString, CountArray(szDescribeString));
  348. //错误提示
  349. CTraceService::TraceString(szDescribeString, TraceLevel_Exception);
  350. //错误提示
  351. AfxMessageBox(szDescribeString, MB_ICONERROR);
  352. return false;
  353. }
  354. //读取数据
  355. if (PlatformDBModule->IsRecordsetEnd() == false)
  356. {
  357. ReadGameServerInfo(PlatformDBAide, GameServerResult);
  358. return true;
  359. }
  360. return false;
  361. }
  362. catch (IDataBaseException * pIException)
  363. {
  364. //错误信息
  365. LPCTSTR pszDescribe = pIException->GetExceptionDescribe();
  366. CTraceService::TraceString(pszDescribe, TraceLevel_Exception);
  367. //错误提示
  368. AfxMessageBox(pszDescribe, MB_ICONERROR);
  369. return false;
  370. }
  371. return false;
  372. }
  373. //加载奖励
  374. WORD CServerInfoManager::LoadGameMatchReward(DWORD dwMatchID, DWORD dwMatchNO)
  375. {
  376. //变量定义
  377. CDataBaseAide PlatformDBAide;
  378. CDataBaseHelper PlatformDBModule;
  379. //执行逻辑
  380. try
  381. {
  382. //连接数据库
  383. if (ConnectPlatformDB(PlatformDBModule) == false)
  384. {
  385. ASSERT(FALSE);
  386. return false;
  387. }
  388. //设置对象
  389. PlatformDBAide.SetDataBase(PlatformDBModule.GetInterface());
  390. //插入参数
  391. PlatformDBAide.ResetParameter();
  392. PlatformDBAide.AddParameter(TEXT("@dwMatchID"), dwMatchID);
  393. PlatformDBAide.AddParameter(TEXT("@dwMatchNo"), dwMatchNO);
  394. //读取列表
  395. if (PlatformDBAide.ExecuteProcess(TEXT("GSP_GS_LoadMatchReward"), true) == DB_SUCCESS)
  396. {
  397. return PlatformDBModule->GetRecordCount();
  398. }
  399. return 0;
  400. }
  401. catch (IDataBaseException * pIException)
  402. {
  403. //错误信息
  404. LPCTSTR pszDescribe = pIException->GetExceptionDescribe();
  405. CTraceService::TraceString(pszDescribe, TraceLevel_Exception);
  406. //错误提示
  407. AfxMessageBox(pszDescribe, MB_ICONERROR);
  408. return 0;
  409. }
  410. return 0;
  411. }
  412. //加载比赛
  413. bool CServerInfoManager::LoadGameMatchOption(WORD wKindID, CMatchOptionBuffer & MatchOptionBuffer)
  414. {
  415. //变量定义
  416. CDataBaseAide PlatformDBAide;
  417. CDataBaseHelper PlatformDBModule;
  418. //执行逻辑
  419. try
  420. {
  421. //连接数据库
  422. if (ConnectPlatformDB(PlatformDBModule) == false)
  423. {
  424. ASSERT(FALSE);
  425. return false;
  426. }
  427. //设置对象
  428. PlatformDBAide.SetDataBase(PlatformDBModule.GetInterface());
  429. //插入参数
  430. PlatformDBAide.ResetParameter();
  431. PlatformDBAide.AddParameter(TEXT("@wKindID"), wKindID);
  432. PlatformDBAide.AddParameter(TEXT("@dwMatchID"), 0);
  433. PlatformDBAide.AddParameter(TEXT("@dwMatchNo"), 0);
  434. //输出信息
  435. TCHAR szDescribeString[128] = TEXT("");
  436. PlatformDBAide.AddParameterOutput(TEXT("@strErrorDescribe"), szDescribeString, sizeof(szDescribeString), adParamOutput);
  437. //读取列表
  438. if (PlatformDBAide.ExecuteProcess(TEXT("GSP_GS_LoadGameMatchItem"), true) != DB_SUCCESS)
  439. {
  440. //获取信息
  441. PlatformDBAide.GetParameter(TEXT("@strErrorDescribe"), szDescribeString, CountArray(szDescribeString));
  442. //错误提示
  443. CTraceService::TraceString(szDescribeString, TraceLevel_Exception);
  444. //错误提示
  445. AfxMessageBox(szDescribeString, MB_ICONERROR);
  446. return false;
  447. }
  448. //清空列表
  449. MatchOptionBuffer.ResetMatchOption();
  450. //读取列表
  451. while (PlatformDBModule->IsRecordsetEnd() == false)
  452. {
  453. //读取数据
  454. tagGameMatchOption GameMatchResult;
  455. ReadGameMatchOption(PlatformDBAide, GameMatchResult);
  456. //插入列表
  457. MatchOptionBuffer.InsertMatchOption(&GameMatchResult);
  458. //移动记录
  459. PlatformDBModule->MoveToNext();
  460. }
  461. return true;
  462. }
  463. catch (IDataBaseException * pIException)
  464. {
  465. //错误信息
  466. LPCTSTR pszDescribe = pIException->GetExceptionDescribe();
  467. CTraceService::TraceString(pszDescribe, TraceLevel_Exception);
  468. //错误提示
  469. AfxMessageBox(pszDescribe, MB_ICONERROR);
  470. return false;
  471. }
  472. return false;
  473. }
  474. //加载房间
  475. bool CServerInfoManager::LoadGameMatchOption(WORD wKindID, DWORD dwMatchID, DWORD dwMatchNO, tagGameMatchOption & GameMatchResult)
  476. {
  477. //变量定义
  478. CDataBaseAide PlatformDBAide;
  479. CDataBaseHelper PlatformDBModule;
  480. //执行逻辑
  481. try
  482. {
  483. //连接数据库
  484. if (ConnectPlatformDB(PlatformDBModule) == false)
  485. {
  486. ASSERT(FALSE);
  487. return false;
  488. }
  489. //设置对象
  490. PlatformDBAide.SetDataBase(PlatformDBModule.GetInterface());
  491. //读取列表
  492. PlatformDBAide.ResetParameter();
  493. PlatformDBAide.AddParameter(TEXT("@wKindID"), wKindID);
  494. PlatformDBAide.AddParameter(TEXT("@dwMatchID"), dwMatchID);
  495. PlatformDBAide.AddParameter(TEXT("@dwMatchNo"), dwMatchNO);
  496. //输出信息
  497. TCHAR szDescribeString[128] = TEXT("");
  498. PlatformDBAide.AddParameterOutput(TEXT("@strErrorDescribe"), szDescribeString, sizeof(szDescribeString), adParamOutput);
  499. //读取列表
  500. if (PlatformDBAide.ExecuteProcess(TEXT("GSP_GS_LoadGameMatchItem"), true) != DB_SUCCESS)
  501. {
  502. //获取信息
  503. PlatformDBAide.GetParameter(TEXT("@strErrorDescribe"), szDescribeString, CountArray(szDescribeString));
  504. //错误提示
  505. CTraceService::TraceString(szDescribeString, TraceLevel_Exception);
  506. //错误提示
  507. AfxMessageBox(szDescribeString, MB_ICONERROR);
  508. return false;
  509. }
  510. //读取数据
  511. if (PlatformDBModule->IsRecordsetEnd() == false)
  512. {
  513. ReadGameMatchOption(PlatformDBAide, GameMatchResult);
  514. return true;
  515. }
  516. return false;
  517. }
  518. catch (IDataBaseException * pIException)
  519. {
  520. //错误信息
  521. LPCTSTR pszDescribe = pIException->GetExceptionDescribe();
  522. CTraceService::TraceString(pszDescribe, TraceLevel_Exception);
  523. //错误提示
  524. AfxMessageBox(pszDescribe, MB_ICONERROR);
  525. return false;
  526. }
  527. return false;
  528. }
  529. //删除房间
  530. bool CServerInfoManager::DeleteGameServer(WORD wServerID)
  531. {
  532. //变量定义
  533. CDataBaseAide PlatformDBAide;
  534. CDataBaseHelper PlatformDBModule;
  535. //执行逻辑
  536. try
  537. {
  538. //连接数据库
  539. if (ConnectPlatformDB(PlatformDBModule) == false)
  540. {
  541. ASSERT(FALSE);
  542. return false;
  543. }
  544. //设置对象
  545. PlatformDBAide.SetDataBase(PlatformDBModule.GetInterface());
  546. //插入参数
  547. PlatformDBAide.ResetParameter();
  548. PlatformDBAide.AddParameter(TEXT("@wServerID"), wServerID);
  549. //输出信息
  550. TCHAR szDescribeString[128] = TEXT("");
  551. PlatformDBAide.AddParameterOutput(TEXT("@strErrorDescribe"), szDescribeString, sizeof(szDescribeString), adParamOutput);
  552. //执行命令
  553. if (PlatformDBAide.ExecuteProcess(TEXT("GSP_GS_DeleteGameRoom"), false) != DB_SUCCESS)
  554. {
  555. //获取信息
  556. PlatformDBAide.GetParameter(TEXT("@strErrorDescribe"), szDescribeString, CountArray(szDescribeString));
  557. //错误提示
  558. CTraceService::TraceString(szDescribeString, TraceLevel_Exception);
  559. //错误提示
  560. AfxMessageBox(szDescribeString, MB_ICONERROR);
  561. return false;
  562. }
  563. return true;
  564. }
  565. catch (IDataBaseException * pIException)
  566. {
  567. //错误信息
  568. LPCTSTR pszDescribe = pIException->GetExceptionDescribe();
  569. CTraceService::TraceString(pszDescribe, TraceLevel_Exception);
  570. //错误提示
  571. AfxMessageBox(pszDescribe, MB_ICONERROR);
  572. }
  573. return false;
  574. }
  575. //插入房间 \存储过程\数据库SQL\DataBase\Script\Platform\存储过程\平台数据库\房间管理.sql
  576. bool CServerInfoManager::InsertGameServer(tagGameServerCreate * pGameServerCreate, tagGameServerInfo & GameServerResult)
  577. {
  578. //变量定义
  579. CDataBaseAide PlatformDBAide;
  580. CDataBaseHelper PlatformDBModule;
  581. //执行逻辑
  582. try
  583. {
  584. //连接数据库
  585. if (ConnectPlatformDB(PlatformDBModule) == false)
  586. {
  587. ASSERT(FALSE);
  588. return false;
  589. }
  590. //设置对象
  591. PlatformDBAide.SetDataBase(PlatformDBModule.GetInterface());
  592. //扩展配置
  593. TCHAR szCustomRule[CountArray(pGameServerCreate->cbCustomRule) * 2 + 1] = TEXT("");
  594. for (INT i = 0; i < CountArray(pGameServerCreate->cbCustomRule); i++) _stprintf(&szCustomRule[i * 2], TEXT("%02X"), pGameServerCreate->cbCustomRule[i]);
  595. //插入参数
  596. PlatformDBAide.ResetParameter();
  597. PlatformDBAide.AddParameter(TEXT("@wGameID"), pGameServerCreate->wGameID);
  598. PlatformDBAide.AddParameter(TEXT("@wKindID"), pGameServerCreate->wKindID);
  599. PlatformDBAide.AddParameter(TEXT("@wNodeID"), pGameServerCreate->wNodeID);
  600. PlatformDBAide.AddParameter(TEXT("@wSortID"), pGameServerCreate->wSortID);
  601. PlatformDBAide.AddParameter(TEXT("@lCellScore"), pGameServerCreate->lCellScore);
  602. PlatformDBAide.AddParameter(TEXT("@wRevenueRatio"), pGameServerCreate->wRevenueRatio);
  603. PlatformDBAide.AddParameter(TEXT("@lServiceScore"), pGameServerCreate->lServiceScore);
  604. PlatformDBAide.AddParameter(TEXT("@lRestrictScore"), pGameServerCreate->lRestrictScore);
  605. PlatformDBAide.AddParameter(TEXT("@lMinTableScore"), pGameServerCreate->lMinTableScore);
  606. PlatformDBAide.AddParameter(TEXT("@lMinEnterScore"), pGameServerCreate->lMinEnterScore);
  607. PlatformDBAide.AddParameter(TEXT("@lMaxEnterScore"), pGameServerCreate->lMaxEnterScore);
  608. PlatformDBAide.AddParameter(TEXT("@cbMinEnterMember"), pGameServerCreate->cbMinEnterMember);
  609. PlatformDBAide.AddParameter(TEXT("@cbMaxEnterMember"), pGameServerCreate->cbMaxEnterMember);
  610. PlatformDBAide.AddParameter(TEXT("@dwServerRule"), pGameServerCreate->dwServerRule);
  611. PlatformDBAide.AddParameter(TEXT("@dwAttachUserRight"), pGameServerCreate->dwAttachUserRight);
  612. PlatformDBAide.AddParameter(TEXT("@wMaxPlayer"), pGameServerCreate->wMaxPlayer);
  613. PlatformDBAide.AddParameter(TEXT("@wTableCount"), pGameServerCreate->wTableCount);
  614. PlatformDBAide.AddParameter(TEXT("@wServerPort"), pGameServerCreate->wServerPort);
  615. PlatformDBAide.AddParameter(TEXT("@wServerKind"), pGameServerCreate->wServerKind);
  616. PlatformDBAide.AddParameter(TEXT("@wServerType"), pGameServerCreate->wServerType);
  617. PlatformDBAide.AddParameter(TEXT("@strServerName"), pGameServerCreate->szServerName);
  618. PlatformDBAide.AddParameter(TEXT("@strServerPasswd"), pGameServerCreate->szServerPasswd);
  619. PlatformDBAide.AddParameter(TEXT("@cbDistributeRule"), pGameServerCreate->cbDistributeRule);
  620. PlatformDBAide.AddParameter(TEXT("@wMinDistributeUser"), pGameServerCreate->wMinDistributeUser);
  621. PlatformDBAide.AddParameter(TEXT("@wDistributeTimeSpace"), pGameServerCreate->wDistributeTimeSpace);
  622. PlatformDBAide.AddParameter(TEXT("@wDistributeDrawCount"), pGameServerCreate->wDistributeDrawCount);
  623. PlatformDBAide.AddParameter(TEXT("@wMinPartakeGameUser"), pGameServerCreate->wMinPartakeGameUser);
  624. PlatformDBAide.AddParameter(TEXT("@wMaxPartakeGameUser"), pGameServerCreate->wMaxPartakeGameUser);
  625. PlatformDBAide.AddParameter(TEXT("@strDataBaseName"), pGameServerCreate->szDataBaseName);
  626. PlatformDBAide.AddParameter(TEXT("@strDataBaseAddr"), pGameServerCreate->szDataBaseAddr);
  627. PlatformDBAide.AddParameter(TEXT("@strCustomRule"), szCustomRule);
  628. PlatformDBAide.AddParameter(TEXT("@strServiceMachine"), pGameServerCreate->szServiceMachine);
  629. //输出信息
  630. TCHAR szDescribeString[128] = TEXT("");
  631. PlatformDBAide.AddParameterOutput(TEXT("@strErrorDescribe"), szDescribeString, sizeof(szDescribeString), adParamOutput);
  632. //执行命令
  633. if (PlatformDBAide.ExecuteProcess(TEXT("GSP_GS_InsertGameRoom"), true) != DB_SUCCESS)
  634. {
  635. //获取信息
  636. PlatformDBAide.GetParameter(TEXT("@strErrorDescribe"), szDescribeString, CountArray(szDescribeString));
  637. //错误提示
  638. CTraceService::TraceString(szDescribeString, TraceLevel_Exception);
  639. //错误提示
  640. AfxMessageBox(szDescribeString, MB_ICONERROR);
  641. return false;
  642. }
  643. //读取资料
  644. ReadGameServerInfo(PlatformDBAide, GameServerResult);
  645. return true;
  646. }
  647. catch (IDataBaseException * pIException)
  648. {
  649. //错误信息
  650. LPCTSTR pszDescribe = pIException->GetExceptionDescribe();
  651. CTraceService::TraceString(pszDescribe, TraceLevel_Exception);
  652. //错误提示
  653. AfxMessageBox(pszDescribe, MB_ICONERROR);
  654. }
  655. return false;
  656. }
  657. //修改房间
  658. bool CServerInfoManager::ModifyGameServer(tagGameServerCreate * pGameServerCreate, tagGameServerInfo & GameServerResult)
  659. {
  660. //变量定义
  661. CDataBaseAide PlatformDBAide;
  662. CDataBaseHelper PlatformDBModule;
  663. //执行逻辑
  664. try
  665. {
  666. //连接数据库
  667. if (ConnectPlatformDB(PlatformDBModule) == false)
  668. {
  669. ASSERT(FALSE);
  670. return false;
  671. }
  672. //设置对象
  673. PlatformDBAide.SetDataBase(PlatformDBModule.GetInterface());
  674. //扩展配置
  675. TCHAR szCustomRule[CountArray(pGameServerCreate->cbCustomRule) * 2 + 1] = TEXT("");
  676. for (INT i = 0; i < CountArray(pGameServerCreate->cbCustomRule); i++) _stprintf(&szCustomRule[i * 2], TEXT("%02X"), pGameServerCreate->cbCustomRule[i]);
  677. //插入参数
  678. PlatformDBAide.ResetParameter();
  679. PlatformDBAide.AddParameter(TEXT("@wServerID"), pGameServerCreate->wServerID);
  680. PlatformDBAide.AddParameter(TEXT("@wKindID"), pGameServerCreate->wKindID);
  681. PlatformDBAide.AddParameter(TEXT("@wNodeID"), pGameServerCreate->wNodeID);
  682. PlatformDBAide.AddParameter(TEXT("@wSortID"), pGameServerCreate->wSortID);
  683. PlatformDBAide.AddParameter(TEXT("@lCellScore"), pGameServerCreate->lCellScore);
  684. PlatformDBAide.AddParameter(TEXT("@wRevenueRatio"), pGameServerCreate->wRevenueRatio);
  685. PlatformDBAide.AddParameter(TEXT("@lServiceScore"), pGameServerCreate->lServiceScore);
  686. PlatformDBAide.AddParameter(TEXT("@lRestrictScore"), pGameServerCreate->lRestrictScore);
  687. PlatformDBAide.AddParameter(TEXT("@lMinTableScore"), pGameServerCreate->lMinTableScore);
  688. PlatformDBAide.AddParameter(TEXT("@lMinEnterScore"), pGameServerCreate->lMinEnterScore);
  689. PlatformDBAide.AddParameter(TEXT("@lMaxEnterScore"), pGameServerCreate->lMaxEnterScore);
  690. PlatformDBAide.AddParameter(TEXT("@cbMinEnterMember"), pGameServerCreate->cbMinEnterMember);
  691. PlatformDBAide.AddParameter(TEXT("@cbMaxEnterMember"), pGameServerCreate->cbMaxEnterMember);
  692. PlatformDBAide.AddParameter(TEXT("@dwServerRule"), pGameServerCreate->dwServerRule);
  693. PlatformDBAide.AddParameter(TEXT("@dwAttachUserRight"), pGameServerCreate->dwAttachUserRight);
  694. PlatformDBAide.AddParameter(TEXT("@wMaxPlayer"), pGameServerCreate->wMaxPlayer);
  695. PlatformDBAide.AddParameter(TEXT("@wTableCount"), pGameServerCreate->wTableCount);
  696. PlatformDBAide.AddParameter(TEXT("@wServerPort"), pGameServerCreate->wServerPort);
  697. PlatformDBAide.AddParameter(TEXT("@wServerKind"), pGameServerCreate->wServerKind);
  698. PlatformDBAide.AddParameter(TEXT("@wServerType"), pGameServerCreate->wServerType);
  699. PlatformDBAide.AddParameter(TEXT("@strServerName"), pGameServerCreate->szServerName);
  700. PlatformDBAide.AddParameter(TEXT("@strServerPasswd"), pGameServerCreate->szServerPasswd);
  701. PlatformDBAide.AddParameter(TEXT("@cbDistributeRule"), pGameServerCreate->cbDistributeRule);
  702. PlatformDBAide.AddParameter(TEXT("@wMinDistributeUser"), pGameServerCreate->wMinDistributeUser);
  703. PlatformDBAide.AddParameter(TEXT("@wDistributeTimeSpace"), pGameServerCreate->wDistributeTimeSpace);
  704. PlatformDBAide.AddParameter(TEXT("@wDistributeDrawCount"), pGameServerCreate->wDistributeDrawCount);
  705. PlatformDBAide.AddParameter(TEXT("@wMinPartakeGameUser"), pGameServerCreate->wMinPartakeGameUser);
  706. PlatformDBAide.AddParameter(TEXT("@wMaxPartakeGameUser"), pGameServerCreate->wMaxPartakeGameUser);
  707. PlatformDBAide.AddParameter(TEXT("@strDataBaseName"), pGameServerCreate->szDataBaseName);
  708. PlatformDBAide.AddParameter(TEXT("@strDataBaseAddr"), pGameServerCreate->szDataBaseAddr);
  709. PlatformDBAide.AddParameter(TEXT("@strCustomRule"), szCustomRule);
  710. PlatformDBAide.AddParameter(TEXT("@strServiceMachine"), pGameServerCreate->szServiceMachine);
  711. //输出信息
  712. TCHAR szDescribeString[128] = TEXT("");
  713. PlatformDBAide.AddParameterOutput(TEXT("@strErrorDescribe"), szDescribeString, sizeof(szDescribeString), adParamOutput);
  714. //执行命令
  715. if (PlatformDBAide.ExecuteProcess(TEXT("GSP_GS_ModifyGameRoom"), true) != DB_SUCCESS)
  716. {
  717. //获取信息
  718. PlatformDBAide.GetParameter(TEXT("@strErrorDescribe"), szDescribeString, CountArray(szDescribeString));
  719. //错误提示
  720. CTraceService::TraceString(szDescribeString, TraceLevel_Exception);
  721. //错误提示
  722. AfxMessageBox(szDescribeString, MB_ICONERROR);
  723. return false;
  724. }
  725. //读取资料
  726. ReadGameServerInfo(PlatformDBAide, GameServerResult);
  727. return true;
  728. }
  729. catch (IDataBaseException * pIException)
  730. {
  731. //错误信息
  732. LPCTSTR pszDescribe = pIException->GetExceptionDescribe();
  733. CTraceService::TraceString(pszDescribe, TraceLevel_Exception);
  734. //错误提示
  735. AfxMessageBox(pszDescribe, MB_ICONERROR);
  736. return false;
  737. }
  738. return false;
  739. }
  740. //连接数据
  741. bool CServerInfoManager::ConnectPlatformDB(CDataBaseHelper & PlatformDBModule)
  742. {
  743. //获取参数
  744. CModuleDBParameter * pModuleDBParameter = CModuleDBParameter::GetModuleDBParameter();
  745. tagDataBaseParameter * pDataBaseParameter = pModuleDBParameter->GetPlatformDBParameter();
  746. //创建对象
  747. if ((PlatformDBModule.GetInterface() == NULL) && (PlatformDBModule.CreateInstance() == false))
  748. {
  749. AfxMessageBox(TEXT("CreateGameServer 创建 PlatformDBModule 对象失败"), MB_ICONERROR);
  750. return false;
  751. }
  752. //设置连接
  753. PlatformDBModule->SetConnectionInfo(pDataBaseParameter->szDataBaseAddr, pDataBaseParameter->wDataBasePort,
  754. pDataBaseParameter->szDataBaseName, pDataBaseParameter->szDataBaseUser, pDataBaseParameter->szDataBasePass);
  755. //发起连接
  756. PlatformDBModule->OpenConnection();
  757. return true;
  758. }
  759. //读取房间
  760. bool CServerInfoManager::ReadGameServerInfo(CDataBaseAide & PlatformDBAide, tagGameServerInfo & GameServerResult)
  761. {
  762. //设置变量
  763. ZeroMemory(&GameServerResult, sizeof(GameServerResult));
  764. //索引变量
  765. GameServerResult.wGameID = PlatformDBAide.GetValue_WORD(TEXT("GameID"));
  766. GameServerResult.wServerID = PlatformDBAide.GetValue_WORD(TEXT("ServerID"));
  767. //挂接属性
  768. GameServerResult.wKindID = PlatformDBAide.GetValue_WORD(TEXT("KindID"));
  769. GameServerResult.wNodeID = PlatformDBAide.GetValue_WORD(TEXT("NodeID"));
  770. GameServerResult.wSortID = PlatformDBAide.GetValue_WORD(TEXT("SortID"));
  771. //版本信息
  772. GameServerResult.dwClientVersion = PlatformDBAide.GetValue_DWORD(TEXT("ClientVersion"));
  773. GameServerResult.dwServerVersion = PlatformDBAide.GetValue_DWORD(TEXT("ServerVersion"));
  774. //模块属性
  775. PlatformDBAide.GetValue_String(TEXT("GameName"), GameServerResult.szGameName, CountArray(GameServerResult.szGameName));
  776. PlatformDBAide.GetValue_String(TEXT("ServerDLLName"), GameServerResult.szServerDLLName, CountArray(GameServerResult.szServerDLLName));
  777. PlatformDBAide.GetValue_String(TEXT("ClientEXEName"), GameServerResult.szClientEXEName, CountArray(GameServerResult.szClientEXEName));
  778. //税收配置
  779. GameServerResult.lCellScore = PlatformDBAide.GetValue_LONG(TEXT("CellScore"));
  780. GameServerResult.wRevenueRatio = PlatformDBAide.GetValue_WORD(TEXT("RevenueRatio"));
  781. GameServerResult.lServiceScore = PlatformDBAide.GetValue_LONGLONG(TEXT("ServiceScore"));
  782. //房间配置
  783. GameServerResult.lRestrictScore = PlatformDBAide.GetValue_LONGLONG(TEXT("RestrictScore"));
  784. GameServerResult.lMinTableScore = PlatformDBAide.GetValue_LONGLONG(TEXT("MinTableScore"));
  785. GameServerResult.lMinEnterScore = PlatformDBAide.GetValue_LONGLONG(TEXT("MinEnterScore"));
  786. GameServerResult.lMaxEnterScore = PlatformDBAide.GetValue_LONGLONG(TEXT("MaxEnterScore"));
  787. //会员限制
  788. GameServerResult.cbMinEnterMember = PlatformDBAide.GetValue_BYTE(TEXT("MinEnterMember"));
  789. GameServerResult.cbMaxEnterMember = PlatformDBAide.GetValue_BYTE(TEXT("MaxEnterMember"));
  790. //房间配置
  791. GameServerResult.dwServerRule = PlatformDBAide.GetValue_DWORD(TEXT("ServerRule"));
  792. GameServerResult.dwAttachUserRight = PlatformDBAide.GetValue_DWORD(TEXT("AttachUserRight"));
  793. //房间属性
  794. GameServerResult.wMaxPlayer = PlatformDBAide.GetValue_WORD(TEXT("MaxPlayer"));
  795. GameServerResult.wTableCount = PlatformDBAide.GetValue_WORD(TEXT("TableCount"));
  796. GameServerResult.wServerPort = PlatformDBAide.GetValue_WORD(TEXT("ServerPort"));
  797. GameServerResult.wServerKind = PlatformDBAide.GetValue_WORD(TEXT("ServerKind"));
  798. GameServerResult.wServerType = PlatformDBAide.GetValue_WORD(TEXT("ServerType")); ///---游戏模式0x0001 //金币类型 0x0002//点值类型 0x0004 //比赛类型 0x0008//训练类型
  799. PlatformDBAide.GetValue_String(TEXT("ServerName"), GameServerResult.szServerName, CountArray(GameServerResult.szServerName));
  800. PlatformDBAide.GetValue_String(TEXT("ServerPasswd"), GameServerResult.szServerPasswd, CountArray(GameServerResult.szServerPasswd));
  801. //分组属性
  802. GameServerResult.cbDistributeRule = PlatformDBAide.GetValue_BYTE(TEXT("DistributeRule"));
  803. GameServerResult.wMinDistributeUser = PlatformDBAide.GetValue_WORD(TEXT("MinDistributeUser"));
  804. GameServerResult.wDistributeTimeSpace = PlatformDBAide.GetValue_WORD(TEXT("DistributeTimeSpace"));
  805. GameServerResult.wDistributeDrawCount = PlatformDBAide.GetValue_WORD(TEXT("DistributeDrawCount"));
  806. GameServerResult.wMinPartakeGameUser = PlatformDBAide.GetValue_WORD(TEXT("MinPartakeGameUser"));
  807. GameServerResult.wMaxPartakeGameUser = PlatformDBAide.GetValue_WORD(TEXT("MaxPartakeGameUser"));
  808. //数据属性
  809. PlatformDBAide.GetValue_String(TEXT("DataBaseName"), GameServerResult.szDataBaseName, CountArray(GameServerResult.szDataBaseName));
  810. PlatformDBAide.GetValue_String(TEXT("DataBaseAddr"), GameServerResult.szDataBaseAddr, CountArray(GameServerResult.szDataBaseAddr));
  811. //扩展配置
  812. TCHAR szCustomRule[CountArray(GameServerResult.cbCustomRule) * 2 + 1];
  813. PlatformDBAide.GetValue_String(TEXT("CustomRule"), szCustomRule, CountArray(szCustomRule));
  814. PlatformDBAide.GetValue_String(TEXT("ServiceMachine"), GameServerResult.szServiceMachine, CountArray(GameServerResult.szServiceMachine));
  815. //扩展配置
  816. if (szCustomRule[0] != 0)
  817. {
  818. //获取长度
  819. ASSERT(lstrlen(szCustomRule) % 2 == 0);
  820. INT nCustomRuleSize = lstrlen(szCustomRule) / 2;
  821. //转换字符
  822. for (INT i = 0; i < nCustomRuleSize; i++)
  823. {
  824. //获取字符
  825. TCHAR cbChar1 = szCustomRule[i * 2];
  826. TCHAR cbChar2 = szCustomRule[i * 2 + 1];
  827. //效验字符
  828. ASSERT((cbChar1 >= TEXT('0')) && (cbChar1 <= TEXT('9')) || (cbChar1 >= TEXT('A')) && (cbChar1 <= TEXT('F')));
  829. ASSERT((cbChar2 >= TEXT('0')) && (cbChar2 <= TEXT('9')) || (cbChar2 >= TEXT('A')) && (cbChar2 <= TEXT('F')));
  830. //生成结果
  831. if ((cbChar2 >= TEXT('0')) && (cbChar2 <= TEXT('9'))) GameServerResult.cbCustomRule[i] += (cbChar2 - TEXT('0'));
  832. if ((cbChar2 >= TEXT('A')) && (cbChar2 <= TEXT('F'))) GameServerResult.cbCustomRule[i] += (cbChar2 - TEXT('A') + 0x0A);
  833. //生成结果
  834. if ((cbChar1 >= TEXT('0')) && (cbChar1 <= TEXT('9'))) GameServerResult.cbCustomRule[i] += (cbChar1 - TEXT('0')) * 0x10;
  835. if ((cbChar1 >= TEXT('A')) && (cbChar1 <= TEXT('F'))) GameServerResult.cbCustomRule[i] += (cbChar1 - TEXT('A') + 0x0A) * 0x10;
  836. }
  837. }
  838. //本地版本
  839. LPCTSTR pszServerDLLName = GameServerResult.szServerDLLName;
  840. CWHService::GetModuleVersion(pszServerDLLName, GameServerResult.dwNativeVersion);
  841. return true;
  842. }
  843. //读取比赛
  844. bool CServerInfoManager::ReadGameMatchOption(CDataBaseAide & PlatformDBAide, tagGameMatchOption & GameMatchResult)
  845. {
  846. //设置变量
  847. ZeroMemory(&GameMatchResult, sizeof(GameMatchResult));
  848. //索引变量
  849. GameMatchResult.dwMatchID = PlatformDBAide.GetValue_DWORD(TEXT("MatchID"));
  850. GameMatchResult.dwMatchNO = PlatformDBAide.GetValue_DWORD(TEXT("MatchNo"));
  851. //费用信息
  852. GameMatchResult.cbMatchFeeType = PlatformDBAide.GetValue_BYTE(TEXT("MatchFeeType"));
  853. GameMatchResult.lMatchFee = PlatformDBAide.GetValue_LONGLONG(TEXT("MatchFee"));
  854. //比赛信息
  855. GameMatchResult.cbMemberOrder = PlatformDBAide.GetValue_BYTE(TEXT("MemberOrder"));
  856. GameMatchResult.cbMatchType = PlatformDBAide.GetValue_BYTE(TEXT("MatchType"));
  857. PlatformDBAide.GetValue_String(TEXT("MatchName"), GameMatchResult.szMatchName, CountArray(GameMatchResult.szMatchName));
  858. //定时赛制
  859. if (GameMatchResult.cbMatchType == MATCH_TYPE_LOCKTIME)
  860. {
  861. //比赛局数
  862. GameMatchResult.MatchType.LockTime.wMatchPlayCount = PlatformDBAide.GetValue_LONGLONG(TEXT("MinPlayCount"));
  863. //时间配置
  864. PlatformDBAide.GetValue_SystemTime(TEXT("StartTime"), GameMatchResult.MatchType.LockTime.MatchStartTime);
  865. PlatformDBAide.GetValue_SystemTime(TEXT("EndTime"), GameMatchResult.MatchType.LockTime.MatchEndTime);
  866. //比赛分数
  867. GameMatchResult.MatchType.LockTime.lMatchInitScore = PlatformDBAide.GetValue_LONGLONG(TEXT("InitScore"));
  868. GameMatchResult.MatchType.LockTime.lMatchCullScore = PlatformDBAide.GetValue_LONGLONG(TEXT("CullScore"));
  869. }
  870. //定时赛制
  871. if (GameMatchResult.cbMatchType == MATCH_TYPE_IMMEDIATE)
  872. {
  873. //人数信息
  874. GameMatchResult.MatchType.Immediate.wStartUserCount = PlatformDBAide.GetValue_WORD(TEXT("StartUserCount"));
  875. GameMatchResult.MatchType.Immediate.wAndroidUserCount = PlatformDBAide.GetValue_WORD(TEXT("AndroidUserCount"));
  876. //分数信息
  877. GameMatchResult.MatchType.Immediate.dwInitalBase = PlatformDBAide.GetValue_DWORD(TEXT("InitialBase"));
  878. GameMatchResult.MatchType.Immediate.dwInitalScore = PlatformDBAide.GetValue_DWORD(TEXT("InitialScore"));
  879. GameMatchResult.MatchType.Immediate.wMinEnterGold = PlatformDBAide.GetValue_WORD(TEXT("MinEnterGold"));
  880. //局数信息
  881. GameMatchResult.MatchType.Immediate.cbPlayCount = PlatformDBAide.GetValue_BYTE(TEXT("PlayCount"));
  882. GameMatchResult.MatchType.Immediate.cbSwitchTableCount = PlatformDBAide.GetValue_BYTE(TEXT("SwitchTableCount"));
  883. GameMatchResult.MatchType.Immediate.wPrecedeTimer = PlatformDBAide.GetValue_WORD(TEXT("PrecedeTimer"));
  884. }
  885. return true;
  886. }
  887. //加载场馆信息列表 \存储过程\数据库SQL\DataBase\Script\Platform\存储过程\平台数据库\加载场列馆表.sql
  888. bool CServerInfoManager::LoadVenueInfos(int wKindID, std::vector<tagVenueInfo>& vecVenueInfo)
  889. {
  890. vecVenueInfo.clear();
  891. //变量定义
  892. CDataBaseAide PlatformDBAide;
  893. CDataBaseHelper PlatformDBModule;
  894. //执行逻辑
  895. try
  896. {
  897. //连接数据库
  898. if (ConnectPlatformDB(PlatformDBModule) == false)
  899. {
  900. ASSERT(FALSE);
  901. return false;
  902. }
  903. //设置对象
  904. PlatformDBAide.SetDataBase(PlatformDBModule.GetInterface());
  905. //插入参数
  906. PlatformDBAide.ResetParameter();
  907. PlatformDBAide.AddParameter(TEXT("@wKindID"), wKindID);
  908. //读取列表
  909. PlatformDBAide.ExecuteProcess(TEXT("GSP_GP_LoadVenues"), true);
  910. //读取列表
  911. while (PlatformDBModule->IsRecordsetEnd() == false)
  912. {
  913. //读取数据
  914. tagVenueInfo venueInfo;
  915. venueInfo.wVenueID = PlatformDBAide.GetValue_WORD(TEXT("id")); //场馆ID
  916. PlatformDBAide.GetValue_String(TEXT("name"), venueInfo.szVenuName, CountArray(venueInfo.szVenuName)); //场馆名称
  917. venueInfo.sBaseScore = PlatformDBAide.GetValue_LONGLONG(TEXT("base_score")); //底分
  918. venueInfo.sMinScore = PlatformDBAide.GetValue_LONGLONG(TEXT("min_score")); //下限
  919. venueInfo.sMaxScore = PlatformDBAide.GetValue_LONGLONG(TEXT("max_score")); //上限
  920. venueInfo.wKindID = PlatformDBAide.GetValue_WORD(TEXT("kind_id")); //游戏类型id
  921. PlatformDBAide.GetValue_String(TEXT("KindName"), venueInfo.szKindName, CountArray(venueInfo.szKindName));//游戏类型名称
  922. venueInfo.btOpenFlag = PlatformDBAide.GetValue_BYTE(TEXT("open_flag")); //开放标志
  923. venueInfo.lRestrictScore = PlatformDBAide.GetValue_LONGLONG(TEXT("restrict_score")); //限制积分
  924. venueInfo.wRevenueRatio = PlatformDBAide.GetValue_WORD(TEXT("revenue_ratio")); //税收比例 (税收比例和服务费用二选一)
  925. venueInfo.sServiceScore = PlatformDBAide.GetValue_LONGLONG(TEXT("service_score")); //服务费用
  926. PlatformDBAide.GetValue_String(TEXT("ext_config"), venueInfo.szExtConfig, CountArray(venueInfo.szExtConfig));//游戏扩展配置(用来设置各玩法的配置,协议格式定义为#分隔的字符中)
  927. ///---校验下
  928. if (venueInfo.sMinScore != 0 && venueInfo.sMinScore < venueInfo.sBaseScore || (venueInfo.sMaxScore != 0 && venueInfo.sMaxScore < venueInfo.sBaseScore))
  929. {
  930. CString strError;
  931. strError.Format(L"场馆[%s(%d)]配置有误(上、下限应大于等于底注,或者不限(等于0)", venueInfo.szVenuName, venueInfo.wVenueID);
  932. CTraceService::TraceString(strError, TraceLevel_Exception);
  933. //错误提示
  934. AfxMessageBox(strError, MB_ICONERROR);
  935. }
  936. else
  937. {
  938. vecVenueInfo.push_back(venueInfo);
  939. }
  940. //移动记录
  941. PlatformDBModule->MoveToNext();
  942. }
  943. }
  944. catch (IDataBaseException * pIException)
  945. {
  946. //错误信息
  947. LPCTSTR pszDescribe = pIException->GetExceptionDescribe();
  948. CTraceService::TraceString(pszDescribe, TraceLevel_Exception);
  949. //错误提示
  950. AfxMessageBox(pszDescribe, MB_ICONERROR);
  951. return false;
  952. }
  953. //if (vecVenueInfo.size()==0)
  954. //{
  955. // //错误提示
  956. // AfxMessageBox(TEXT("还没有配置该玩法的场馆的信息,请前往配置"), MB_ICONERROR);
  957. // CTraceService::TraceString(TEXT("还没有配置该玩法的场馆的信息,请前往配置"), TraceLevel_Exception);
  958. //}
  959. return true;
  960. }
  961. //////////////////////////////////////////////////////////////////////////////////