Handler_CommonDB.cpp
上传用户:szopptop
上传日期:2013-04-23
资源大小:1047k
文件大小:17k
源码类别:

模拟服务器

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. void SendRDBSocket(int nCertification, char *pszData1, char *pszData2, int nData2Len);
  3. CMapInfo* InitMapInfo(int nServerIndex)
  4. {
  5. char szQuery[1024];
  6. CRecordset *pRec = g_pConnCommon->CreateRecordset();
  7. sprintf( szQuery, "SELECT COUNT(*) AS FLD_COUNT FROM TBL_MAPINFO WHERE FLD_SERVERINDEX = %d", nServerIndex );
  8. if (pRec->Execute( szQuery ))
  9. {
  10. if (pRec->Fetch())
  11. g_nNumOfMapInfo = atoi( pRec->Get( "FLD_COUNT" ) );
  12. }
  13. g_pConnCommon->DestroyRecordset( pRec );
  14. if (g_nNumOfMapInfo < 0) return NULL;
  15. CMapInfo* pMapInfo = new CMapInfo[g_nNumOfMapInfo];
  16. sprintf( szQuery, "SELECT * FROM TBL_MAPINFO WHERE FLD_SERVERINDEX = %d", nServerIndex );
  17. pRec = g_pConnCommon->CreateRecordset();
  18. if (pRec->Execute( szQuery ))
  19. {
  20. for (int i = 0; i < g_nNumOfMapInfo; i++)
  21. {
  22. if (pRec->Fetch())
  23. {
  24. strcpy(pMapInfo[i].szMapFileName, pRec->Get( "FLD_MAPFILENAME" ) );
  25. ChangeSpaceToNull(pMapInfo[i].szMapFileName);
  26. strcpy(pMapInfo[i].szMapName, pRec->Get( "FLD_MAPNAME" ) );
  27. ChangeSpaceToNull(pMapInfo[i].szMapName);
  28. pMapInfo[i].dwAttribute = atoi( pRec->Get( "FLD_ATTRIBUTE" ) );
  29. pMapInfo[i].btMapSeries = atoi( pRec->Get( "FLD_MAPSERIES" ) );
  30. pMapInfo[i].btMapSeriesValue = atoi( pRec->Get( "FLD_MAPSERIESVAL" ) );
  31. }
  32. }
  33. }
  34. g_pConnCommon->DestroyRecordset( pRec );
  35. return pMapInfo;
  36. }
  37. void InitStdItemEtcInfo()
  38. {
  39. char szQuery[1024];
  40. CRecordset *pRec;
  41. pRec= g_pConnCommon->CreateRecordset();
  42. sprintf( szQuery, "SELECT COUNT(*) AS FLD_COUNT FROM TBL_STDITEM_ETC");
  43. if (pRec->Execute( szQuery ))
  44. {
  45. if (pRec->Fetch())
  46. g_nStdItemEtc = atoi( pRec->Get( "FLD_COUNT" ) );
  47. }
  48. g_pConnCommon->DestroyRecordset( pRec );
  49. if (g_nStdItemEtc < 0) return;
  50. g_pStdItemEtc = new CStdItem[g_nStdItemEtc];
  51. sprintf( szQuery, "SELECT * FROM TBL_STDITEM_ETC ORDER BY FLD_INDEX");
  52. pRec = g_pConnCommon->CreateRecordset();
  53. if (pRec->Execute( szQuery ))
  54. {
  55. for (int i = 0; i < g_nStdItemEtc; i++)
  56. {
  57. if (pRec->Fetch())  
  58. {
  59. strcpy(g_pStdItemEtc[i].szName, pRec->Get( "FLD_NAME" ) );
  60. g_pStdItemEtc[i].wStdMode = atoi( pRec->Get( "FLD_STDMODE" ) );
  61. g_pStdItemEtc[i].wShape = atoi( pRec->Get( "FLD_SHAPE" ) );
  62. g_pStdItemEtc[i].wWeight = atoi( pRec->Get( "FLD_WEIGHT" ) );
  63. g_pStdItemEtc[i].dwLooks = atoi( pRec->Get( "FLD_LOOKS" ) );
  64. g_pStdItemEtc[i].wDuraMax = atoi( pRec->Get( "FLD_VAL1" ) );
  65. g_pStdItemEtc[i].dwRSource = atoi( pRec->Get( "FLD_VAL2" ) );
  66. g_pStdItemEtc[i].dwPrice = atoi( pRec->Get( "FLD_PRICE" ) );
  67. }
  68. }
  69. InsertLogMsgParam(IDS_FETCH_STDITEMETC, &g_nStdItemEtc, LOGPARAM_INT);
  70. }
  71. g_pConnCommon->DestroyRecordset( pRec );
  72. }
  73. void InitStdItemSpecial()
  74. {
  75. char szQuery[1024];
  76. CRecordset *pRec = g_pConnCommon->CreateRecordset();
  77. sprintf( szQuery, "SELECT COUNT(*) AS FLD_COUNT FROM TBL_STDITEM");
  78. if (pRec->Execute( szQuery ))
  79. {
  80. if (pRec->Fetch())
  81. g_nStdItemSpecial = atoi( pRec->Get( "FLD_COUNT" ) );
  82. }
  83. g_pConnCommon->DestroyRecordset( pRec );
  84. if (g_nStdItemSpecial < 0) return;
  85. g_pStdItemSpecial = new CStdItemSpecial[g_nStdItemSpecial];
  86. sprintf( szQuery, "SELECT * FROM TBL_STDITEM ORDER BY FLD_INDEX");
  87. pRec = g_pConnCommon->CreateRecordset();
  88. if (pRec->Execute( szQuery ))
  89. {
  90. for (int i = 0; i < g_nStdItemSpecial; i++)
  91. {
  92. if (pRec->Fetch())  
  93. {
  94. strcpy(g_pStdItemSpecial[i].szName, pRec->Get( "FLD_NAME" ) );
  95. g_pStdItemSpecial[i].wStdMode = (SHORT)atoi( pRec->Get( "FLD_STDMODE" ) );
  96. g_pStdItemSpecial[i].btType = (BYTE)atoi( pRec->Get( "FLD_TYPE" ) );
  97. g_pStdItemSpecial[i].wShape = (SHORT)atoi( pRec->Get( "FLD_SHAPE" ) );
  98. g_pStdItemSpecial[i].wWeight = (SHORT)atoi( pRec->Get( "FLD_WEIGHT" ) );
  99. g_pStdItemSpecial[i].wAniCount = (SHORT)atoi( pRec->Get( "FLD_ANICOUNT" ) );
  100. g_pStdItemSpecial[i].wSource = (SHORT)atoi( pRec->Get( "FLD_SOURCE" ) );
  101. g_pStdItemSpecial[i].dwLooks = (LONG)atoi( pRec->Get( "FLD_LOOKS" ) );
  102. g_pStdItemSpecial[i].wDuraMax = (WORD)atoi( pRec->Get( "FLD_DURAMAX" ) );
  103. g_pStdItemSpecial[i].wAC = (BYTE)atoi( pRec->Get( "FLD_AC" ) );
  104. g_pStdItemSpecial[i].wAC2 = (BYTE)atoi( pRec->Get( "FLD_AC2" ) );
  105. g_pStdItemSpecial[i].wMAC = (BYTE)atoi( pRec->Get( "FLD_MAC" ) );
  106. g_pStdItemSpecial[i].wMAC2 = (BYTE)atoi( pRec->Get( "FLD_MAC2" ) );
  107. g_pStdItemSpecial[i].wDC = (BYTE)atoi( pRec->Get( "FLD_DC" ) );
  108. g_pStdItemSpecial[i].wDC2 = (BYTE)atoi( pRec->Get( "FLD_DC2" ) );
  109. g_pStdItemSpecial[i].wMC = (BYTE)atoi( pRec->Get( "FLD_MC" ) );
  110. g_pStdItemSpecial[i].wMC2 = (BYTE)atoi( pRec->Get( "FLD_MC2" ) );
  111. g_pStdItemSpecial[i].wSC = (BYTE)atoi( pRec->Get( "FLD_SC" ) );
  112. g_pStdItemSpecial[i].wSC2 = (BYTE)atoi( pRec->Get( "FLD_SC2" ) );
  113. g_pStdItemSpecial[i].wNeed = (SHORT)atoi( pRec->Get( "FLD_NEED" ) );
  114. g_pStdItemSpecial[i].wNeedLevel = (SHORT)atoi( pRec->Get( "FLD_NEEDLEVEL" ) );
  115. g_pStdItemSpecial[i].dwPrice = (LONG)atoi( pRec->Get( "FLD_PRICE" ) );
  116. g_pStdItemSpecial[i].dwStock = (LONG)atoi( pRec->Get( "FLD_STOCK" ) );
  117. g_pStdItemSpecial[i].m_btWater = (BYTE)atoi( pRec->Get( "FLD_WATER1" ) );
  118. g_pStdItemSpecial[i].m_btWater2 = (BYTE)atoi( pRec->Get( "FLD_WATER2" ) );
  119. g_pStdItemSpecial[i].m_btFire = (BYTE)atoi( pRec->Get( "FLD_FIRE1" ) );
  120. g_pStdItemSpecial[i].m_btFire2 = (BYTE)atoi( pRec->Get( "FLD_FIRE2" ) );
  121. g_pStdItemSpecial[i].m_btWind = (BYTE)atoi( pRec->Get( "FLD_WIND1" ) );
  122. g_pStdItemSpecial[i].m_btWind2 = (BYTE)atoi( pRec->Get( "FLD_WIND2" ) );
  123. g_pStdItemSpecial[i].m_btLight = (BYTE)atoi( pRec->Get( "FLD_LIGHT1" ) );
  124. g_pStdItemSpecial[i].m_btLight2 = (BYTE)atoi( pRec->Get( "FLD_LIGHT2" ) );
  125. g_pStdItemSpecial[i].m_btEarth = (BYTE)atoi( pRec->Get( "FLD_EARTH1" ) );
  126. g_pStdItemSpecial[i].m_btEarth2 = (BYTE)atoi( pRec->Get( "FLD_EARTH2" ) );
  127. }
  128. }
  129. InsertLogMsgParam(IDS_FETCH_STDITEMACCESSORY, &g_nStdItemSpecial, LOGPARAM_INT);
  130. }
  131. g_pConnCommon->DestroyRecordset( pRec );
  132. }
  133. void InitMonsterGenInfo()
  134. {
  135. char szQuery[1024];
  136. CRecordset *pRec = g_pConnCommon->CreateRecordset();
  137. sprintf( szQuery, "SELECT COUNT(*) AS FLD_COUNT FROM TBL_MONGEN");
  138. if (pRec->Execute( szQuery ))
  139. {
  140. if (pRec->Fetch())
  141. g_nNumOfMonGenInfo = atoi( pRec->Get( "FLD_COUNT" ) );
  142. }
  143. g_pConnCommon->DestroyRecordset( pRec );
  144. if (g_nNumOfMonGenInfo < 0) return;
  145. g_pMonGenInfo = new CMonsterGenInfo[g_nNumOfMonGenInfo + 1];
  146. sprintf( szQuery, "SELECT * FROM TBL_MONGEN ORDER BY FLD_MAPNAME");
  147. pRec = g_pConnCommon->CreateRecordset();
  148. if (pRec->Execute( szQuery ))
  149. {
  150. for (int i = 0; i < g_nNumOfMonGenInfo; i++)
  151. {
  152. if (pRec->Fetch())  
  153. {
  154. strcpy(g_pMonGenInfo[i].szMapName, pRec->Get( "FLD_MAPNAME" ) );
  155. strcpy(g_pMonGenInfo[i].szMonName, pRec->Get( "FLD_MONNAME" ) );
  156. g_pMonGenInfo[i].dwZenTime = atoi( pRec->Get( "FLD_GENTIME" ) ) * 60000;
  157. g_pMonGenInfo[i].dwStartTime = 0;
  158. g_pMonGenInfo[i].nMonIndex = atoi( pRec->Get( "FLD_MONINDEX" ) );
  159. g_pMonGenInfo[i].nCount = atoi( pRec->Get( "FLD_COUNT" ) );
  160. g_pMonGenInfo[i].nX = atoi( pRec->Get( "FLD_X" ) );
  161. g_pMonGenInfo[i].nY = atoi( pRec->Get( "FLD_Y" ) );
  162. g_pMonGenInfo[i].nAreaX = atoi( pRec->Get( "FLD_AREA_X" ) );
  163. g_pMonGenInfo[i].nAreaY = atoi( pRec->Get( "FLD_AREA_Y" ) );
  164. }
  165. }
  166. InsertLogMsgParam(IDS_FETCH_MONGEN, &g_nNumOfMonGenInfo, LOGPARAM_INT);
  167. }
  168. g_pConnCommon->DestroyRecordset( pRec );
  169. }
  170. // **************************************************************************************
  171. //
  172. // Initializing Monster Item Generate Information
  173. //
  174. // **************************************************************************************
  175. void InitMonItemInfo()
  176. {
  177. int nMonIndex;
  178. char szQuery[1024];
  179. CRecordset *pRec = g_pConnCommon->CreateRecordset();
  180. sprintf( szQuery, "SELECT * FROM TBL_MONITEM");
  181. if (pRec->Execute( szQuery ))
  182. {
  183. while (pRec->Fetch())
  184. {
  185. nMonIndex = atoi( pRec->Get( "FLD_MONSTER" ));
  186. CMonItem* pMonItem = new CMonItem;
  187. if (pMonItem)
  188. {
  189. pMonItem->m_btItemType = atoi( pRec->Get( "FLD_TYPE" ));
  190. pMonItem->m_wItemIndex = atoi( pRec->Get( "FLD_ITEM" ));
  191. pMonItem->m_nPoint = atoi( pRec->Get( "FLD_PROBABLY" ));
  192. pMonItem->m_wCount = atoi( pRec->Get( "FLD_COUNT" ));
  193. if (g_pMonRaceInfo && (nMonIndex <= g_nNumOfMonRaceInfo))
  194. g_pMonRaceInfo[nMonIndex].m_xMonItemList.AddNewNode(pMonItem);
  195. }
  196. }
  197. }
  198. g_pConnCommon->DestroyRecordset( pRec );
  199. }
  200. // **************************************************************************************
  201. //
  202. // Initializing Monster Information
  203. //
  204. // **************************************************************************************
  205. void InitMonRaceInfo()
  206. {
  207. char szQuery[1024];
  208. CRecordset *pRec = g_pConnCommon->CreateRecordset();
  209. sprintf( szQuery, "SELECT COUNT(*) AS FLD_COUNT FROM TBL_MONSTER");
  210. if (pRec->Execute( szQuery ))
  211. {
  212. if (pRec->Fetch())
  213. g_nNumOfMonRaceInfo = atoi( pRec->Get( "FLD_COUNT" ) );
  214. }
  215. g_pConnCommon->DestroyRecordset( pRec );
  216. if (g_nNumOfMonRaceInfo < 0) return;
  217. g_pMonRaceInfo = new CMonRaceInfo[g_nNumOfMonRaceInfo];
  218. sprintf( szQuery, "SELECT * FROM TBL_MONSTER ORDER BY FLD_INDEX");
  219. pRec = g_pConnCommon->CreateRecordset();
  220. if (pRec->Execute( szQuery ))
  221. {
  222. for (int i = 0; i < g_nNumOfMonRaceInfo; i++)
  223. {
  224. if (pRec->Fetch())  
  225. {
  226. g_pMonRaceInfo[i].nIndex = i;
  227. strcpy(g_pMonRaceInfo[i].szMonName, pRec->Get( "FLD_NAME" ) );
  228. ChangeSpaceToNull(g_pMonRaceInfo[i].szMonName);
  229. g_pMonRaceInfo[i].nMonRace = atoi( pRec->Get( "FLD_RACE" ) );
  230. g_pMonRaceInfo[i].nAppear = atoi( pRec->Get( "FLD_APPR" ) );
  231. g_pMonRaceInfo[i].btUndead = (BYTE)atoi( pRec->Get( "FLD_UNDEAD" ) );
  232. g_pMonRaceInfo[i].Level = (BYTE)atoi( pRec->Get( "FLD_LEVEL" ) );
  233. g_pMonRaceInfo[i].HP = atoi( pRec->Get( "FLD_HP" ) );
  234. g_pMonRaceInfo[i].MP = atoi( pRec->Get( "FLD_MP" ) );
  235. g_pMonRaceInfo[i].AC = atoi( pRec->Get( "FLD_AC" ) );
  236. g_pMonRaceInfo[i].MAC = atoi( pRec->Get( "FLD_MAC" ) );
  237. g_pMonRaceInfo[i].DC =  MAKEWORD((BYTE)atoi( pRec->Get( "FLD_DC" ) ), (BYTE)atoi( pRec->Get( "FLD_MAXDC" ) ));
  238. g_pMonRaceInfo[i].dwAttackSpeed = atoi( pRec->Get( "FLD_ATTACKSPEED" ) );
  239. g_pMonRaceInfo[i].dwWalkSpeed = atoi( pRec->Get( "FLD_WALKSPEED" ) );
  240. g_pMonRaceInfo[i].Speed = atoi( pRec->Get( "FLD_SPEED" ) );
  241. g_pMonRaceInfo[i].Hit = atoi( pRec->Get( "FLD_HIT" ) );
  242. g_pMonRaceInfo[i].ViewRange = (BYTE)atoi( pRec->Get( "FLD_VIEWRANGE" ) );
  243. g_pMonRaceInfo[i].wRaceIndex = atoi( pRec->Get( "FLD_RACEINDEX" ) );
  244. g_pMonRaceInfo[i].Exp = atoi( pRec->Get( "FLD_EXP" ) );
  245. g_pMonRaceInfo[i].wEscape = atoi( pRec->Get( "FLD_ESCAPE" ) );
  246. g_pMonRaceInfo[i].m_wWater = MAKEWORD((BYTE)atoi( pRec->Get( "FLD_WATER1" ) ), (BYTE)atoi( pRec->Get( "FLD_WATER2" ) ));
  247. g_pMonRaceInfo[i].m_wFire = MAKEWORD((BYTE)atoi( pRec->Get( "FLD_FIRE1" ) ), (BYTE)atoi( pRec->Get( "FLD_FIRE2" ) ));
  248. g_pMonRaceInfo[i].m_wWind = MAKEWORD((BYTE)atoi( pRec->Get( "FLD_WIND1" ) ), (BYTE)atoi( pRec->Get( "FLD_WIND2" ) ));
  249. g_pMonRaceInfo[i].m_wLight = MAKEWORD((BYTE)atoi( pRec->Get( "FLD_LIGHT1" ) ), (BYTE)atoi( pRec->Get( "FLD_LIGHT2" ) ));
  250. g_pMonRaceInfo[i].m_wEarth = MAKEWORD((BYTE)atoi( pRec->Get( "FLD_EARTH1" ) ), (BYTE)atoi( pRec->Get( "FLD_EARTH2" ) ));
  251. }
  252. }
  253. InsertLogMsgParam(IDS_FETCH_MONSTER, &g_nNumOfMonRaceInfo, LOGPARAM_INT);
  254. }
  255. g_pConnCommon->DestroyRecordset( pRec );
  256. InitMonItemInfo();
  257. }
  258. void InitMerchantInfo()
  259. {
  260. char szQuery[1024];
  261. CRecordset *pRec = g_pConnCommon->CreateRecordset();
  262. sprintf( szQuery, "SELECT COUNT(*) AS FLD_COUNT FROM TBL_MERCHANT");
  263. if (pRec->Execute( szQuery ))
  264. {
  265. if (pRec->Fetch())
  266. g_nNumOfMurchantInfo = atoi( pRec->Get( "FLD_COUNT" ) );
  267. }
  268. g_pConnCommon->DestroyRecordset( pRec );
  269. if (g_nNumOfMurchantInfo < 0) return;
  270. g_pMerchantInfo = new CMerchantInfo[g_nNumOfMurchantInfo];
  271. sprintf( szQuery, "SELECT * FROM TBL_MERCHANT ORDER BY FLD_ID");
  272. pRec = g_pConnCommon->CreateRecordset();
  273. if (pRec->Execute( szQuery ))
  274. {
  275. for (int i = 0; i < g_nNumOfMurchantInfo; i++)
  276. {
  277. if (pRec->Fetch())  
  278. {
  279. strcpy(g_pMerchantInfo[i].szNPCName, pRec->Get( "FLD_NPCNAME" ) );
  280. ChangeSpaceToNull(g_pMerchantInfo[i].szNPCName);
  281. strcpy(g_pMerchantInfo[i].szMapName, pRec->Get( "FLD_MAPNAME" ) );
  282. ChangeSpaceToNull(g_pMerchantInfo[i].szMapName);
  283. g_pMerchantInfo[i].nPosX = atoi( pRec->Get( "FLD_POSX" ) );
  284. g_pMerchantInfo[i].nPosY = atoi( pRec->Get( "FLD_POSY" ) );
  285. g_pMerchantInfo[i].sFace = atoi( pRec->Get( "FLD_FACE" ) );
  286. g_pMerchantInfo[i].sBody = atoi( pRec->Get( "FLD_BODY" ) );
  287. g_pMerchantInfo[i].sGender = atoi( pRec->Get( "FLD_GENDER" ) );
  288. }
  289. }
  290. InsertLogMsgParam(IDS_FETCH_MERCHANT, &g_nNumOfMurchantInfo, LOGPARAM_INT);
  291. }
  292. g_pConnCommon->DestroyRecordset( pRec );
  293. }
  294. void InitMagicInfo()
  295. {
  296. char szQuery[1024];
  297. CRecordset *pRec = g_pConnCommon->CreateRecordset();
  298. sprintf( szQuery, "SELECT COUNT(*) AS FLD_COUNT FROM TBL_MAGIC");
  299. if (pRec->Execute( szQuery ))
  300. {
  301. if (pRec->Fetch())
  302. g_nNumOfMagicInfo = atoi( pRec->Get( "FLD_COUNT" ) );
  303. }
  304. g_pConnCommon->DestroyRecordset( pRec );
  305. if (g_nNumOfMagicInfo < 0) return;
  306. g_pMagicInfo = new CMagicInfo[g_nNumOfMagicInfo];
  307. sprintf( szQuery, "SELECT * FROM TBL_MAGIC ORDER BY FLD_INDEX");
  308. pRec = g_pConnCommon->CreateRecordset();
  309. if (pRec->Execute( szQuery ))
  310. {
  311. for (int i = 0; i < g_nNumOfMagicInfo; i++)
  312. {
  313. if (pRec->Fetch())  
  314. {
  315. g_pMagicInfo[i].nIndex = atoi( pRec->Get( "FLD_INDEX" ) );
  316. strcpy(g_pMagicInfo[i].szName, pRec->Get( "FLD_NAME" ) );
  317. ChangeSpaceToNull(g_pMagicInfo[i].szName);
  318. g_pMagicInfo[i].sEffectType = atoi( pRec->Get( "FLD_EFFECTTYPE" ) );
  319. g_pMagicInfo[i].sEffect = atoi( pRec->Get( "FLD_EFFECT" ) );
  320. g_pMagicInfo[i].sSpell = atoi( pRec->Get( "FLD_SPELL" ) );
  321. g_pMagicInfo[i].sPower = atoi( pRec->Get( "FLD_POWER" ) );
  322. g_pMagicInfo[i].sMaxPower = atoi( pRec->Get( "FLD_MAXPOWER" ) );
  323. g_pMagicInfo[i].sDefSpell = atoi( pRec->Get( "FLD_DEFSPELL" ) );
  324. g_pMagicInfo[i].sDefPower = atoi( pRec->Get( "FLD_DEFPOWER" ) );
  325. g_pMagicInfo[i].sDefMaxPower = atoi( pRec->Get( "FLD_DEFMAXPOWER" ) );
  326. g_pMagicInfo[i].sJob = atoi( pRec->Get( "FLD_JOB" ) );
  327. g_pMagicInfo[i].sNeed[0] = atoi( pRec->Get( "FLD_NEEDL1" ) );
  328. g_pMagicInfo[i].nTrain[0] = atoi( pRec->Get( "FLD_L1TRAIN" ) );
  329. g_pMagicInfo[i].sNeed[1] = atoi( pRec->Get( "FLD_NEEDL2" ) );
  330. g_pMagicInfo[i].nTrain[1] = atoi( pRec->Get( "FLD_L2TRAIN" ) );
  331. g_pMagicInfo[i].sNeed[2] = atoi( pRec->Get( "FLD_NEEDL3" ) );
  332. g_pMagicInfo[i].nTrain[2] = atoi( pRec->Get( "FLD_L3TRAIN" ) );
  333. g_pMagicInfo[i].sDelay = atoi( pRec->Get( "FLD_DELAY" ) );
  334. }
  335. }
  336. InsertLogMsgParam(IDS_FETCH_MAGICDATA, &g_nNumOfMagicInfo, LOGPARAM_INT);
  337. }
  338. g_pConnCommon->DestroyRecordset( pRec );
  339. }
  340. void InitMoveMapEventInfo()
  341. {
  342. char szQuery[1024];
  343. CRecordset *pRec = g_pConnCommon->CreateRecordset();
  344. sprintf( szQuery, "SELECT COUNT(*) AS FLD_COUNT FROM TBL_MOVEMAPEVENT");
  345. if (pRec->Execute( szQuery ))
  346. {
  347. if (pRec->Fetch())
  348. g_nNumOfMoveMapEventInfo = atoi( pRec->Get( "FLD_COUNT" ) );
  349. }
  350. g_pConnCommon->DestroyRecordset( pRec );
  351. if (g_nNumOfMoveMapEventInfo < 0) return;
  352. g_pMoveMapEventInfo = new CMoveMapEventInfo[g_nNumOfMoveMapEventInfo];
  353. sprintf( szQuery, "SELECT * FROM TBL_MOVEMAPEVENT ORDER BY FLD_INDEX");
  354. pRec = g_pConnCommon->CreateRecordset();
  355. if (pRec->Execute( szQuery ))
  356. {
  357. for (int i = 0; i < g_nNumOfMoveMapEventInfo; i++)
  358. {
  359. if (pRec->Fetch())  
  360. {
  361. strcpy(g_pMoveMapEventInfo[i].szSMapFileName, pRec->Get( "FLD_SMAPFILENAME" ) );
  362. strcpy(g_pMoveMapEventInfo[i].szDMapFileName, pRec->Get( "FLD_DMAPFILENAME" ) );
  363. g_pMoveMapEventInfo[i].nSX = atoi( pRec->Get( "FLD_SX" ) );
  364. g_pMoveMapEventInfo[i].nSY = atoi( pRec->Get( "FLD_SY" ) );
  365. g_pMoveMapEventInfo[i].nDX = atoi( pRec->Get( "FLD_DX" ) );
  366. g_pMoveMapEventInfo[i].nDY = atoi( pRec->Get( "FLD_DY" ) );
  367. g_pMoveMapEventInfo[i].fIsOpen = FALSE;
  368. }
  369. }
  370. InsertLogMsgParam(IDS_FETCH_MOVEMAPEVENT, &g_nNumOfMoveMapEventInfo, LOGPARAM_INT);
  371. }
  372. g_pConnCommon->DestroyRecordset( pRec );
  373. }
  374. CMagicInfo* GetMagicInfo(int nMagicID)
  375. {
  376.   if (g_pMagicInfo[nMagicID].nIndex == nMagicID)
  377. return &g_pMagicInfo[nMagicID];
  378. for (int i = 0; i < g_nNumOfMagicInfo; i++)
  379. {
  380. if (g_pMagicInfo[i].nIndex == nMagicID)
  381. return &g_pMagicInfo[i];
  382. }
  383. return NULL;
  384. }
  385. CMonsterGenInfo* GetMonGenInfo(char *pszMonName)
  386. {
  387. int nCmpLen;
  388. int nLen = memlen(pszMonName) - 1;
  389. for (int i = 0; i < g_nNumOfMonGenInfo; i++)
  390. {
  391. nCmpLen = memlen(g_pMonGenInfo[i].szMonName) - 1;
  392. if (nCmpLen == nLen)
  393. {
  394. if (memcmp(g_pMonGenInfo[i].szMonName, pszMonName, nLen) == 0)
  395. return &g_pMonGenInfo[i];
  396. }
  397. }
  398. return NULL;
  399. }
  400. CMonRaceInfo* GetMonRaceInfo(char *pszMonName)
  401. {
  402. int nCmpLen;
  403. int nLen = memlen(pszMonName) - 1;
  404. for (int i = 0; i < g_nNumOfMonRaceInfo; i++)
  405. {
  406. nCmpLen = memlen(g_pMonRaceInfo[i].szMonName) - 1;
  407. if (nCmpLen == nLen)
  408. {
  409. if (memcmp(g_pMonRaceInfo[i].szMonName, pszMonName, nLen) == 0)
  410. return &g_pMonRaceInfo[i];
  411. }
  412. }
  413. return NULL;
  414. }