CoreShell.cpp
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:63k
源码类别:

模拟服务器

开发平台:

C/C++

  1. /*****************************************************************************************
  2. // 外界访问Core接口方法
  3. // Copyright : Kingsoft 2002
  4. // Author :   
  5. // CreateTime: 2002-9-12
  6. ------------------------------------------------------------------------------------------
  7. *****************************************************************************************/
  8. #include "KCore.h"
  9. #include "GameDataDef.h"
  10. #include "CoreShell.h"
  11. #ifndef _SERVER
  12. #include "CoreDrawGameObj.h"
  13. #include "ImgRef.h"
  14. #endif
  15. #include "KPlayer.h"
  16. #include "KPlayerSet.h"
  17. #include "KItemList.h"
  18. #include "KSubWorldSet.h"
  19. #include "KProtocolProcess.h"
  20. #ifndef _SERVER
  21. #include "KNpcResList.h"
  22. #include "Scene/KScenePlaceC.h"
  23. #include "kskills.h"
  24. #include "GameDataDef.h"
  25. #include "MsgGenreDef.h"
  26. #include "KOption.h"
  27. #include "KSubWorld.h"
  28. #endif
  29. #include "KBuySell.h"
  30. #define NPC_TRADE_BOX_WIDTH 6
  31. #define NPC_TRADE_BOX_HEIGHT 10
  32. #define MAX_TRADE_ITEM_WIDTH 2
  33. #define MAX_TRADE_ITEM_HEIGHT 4
  34. IClientCallback* l_pDataChangedNotifyFunc = 0;
  35. class KCoreShell : public iCoreShell
  36. {
  37. public:
  38. int  GetProtocolSize(BYTE byProtocol);
  39. int  Debug(unsigned int uDataId, unsigned int uParam, int nParam);
  40. int  OperationRequest(unsigned int uOper, unsigned int uParam, int nParam);
  41. void ProcessInput(unsigned int uMsg, unsigned int uParam, int nParam);
  42. int  FindSelectPlayer(int x, int y, void* pReturn);
  43. int FindSpecialPlayer(char* Name, void* pReturn);
  44. int ChatSpecialPlayer(void* pPlayer, const char* pMsgBuff, unsigned short nMsgLength);
  45. int  GetGameData(unsigned int uDataId, unsigned int uParam, int nParam);
  46. int  FreeGameData(unsigned int uDataId, unsigned int uParam, int nParam);
  47. void DrawGameObj(unsigned int uObjGenre, unsigned int uId, int x, int y, int Width, int Height, int nParam);
  48. void DrawGameSpace();
  49. DWORD GetPing();
  50. void SendPing();
  51. int  SetCallDataChangedNofify(IClientCallback* pNotifyFunc);
  52. void NetMsgCallbackFunc(void* pMsgData);
  53. void SetRepresentShell(struct iRepresentShell* pRepresent);
  54. void SetMusicInterface(void* pMusicInterface);
  55. void SetRepresentAreaSize(int nWidth, int nHeight);
  56. int  Breathe();
  57. void Release(); //释放接口对象
  58. void SetClient(LPVOID pClient);
  59. void SendNewDataToServer(void* pData, int nLength);
  60. };
  61. static KCoreShell g_CoreShell;
  62. CORE_API void g_InitCore();
  63. #ifndef _STANDALONE
  64. extern "C" __declspec(dllexport)
  65. #endif
  66. iCoreShell* CoreGetShell()
  67. {
  68. g_InitCore();
  69. return &g_CoreShell;
  70. }
  71. //--------------------------------------------------------------------------
  72. // 功能:发出游戏世界数据改变的通知函数
  73. // 返回:如未被注册通知函数,则直接返回0,否则返回通知函数执行结果。
  74. //--------------------------------------------------------------------------
  75. void CoreDataChanged(unsigned int uDataId, unsigned int uParam, int nParam)
  76. {
  77. if (l_pDataChangedNotifyFunc)
  78. l_pDataChangedNotifyFunc->CoreDataChanged(uDataId, uParam, nParam);
  79. }
  80. void KCoreShell::Release()
  81. {
  82. g_ReleaseCore();
  83. }
  84. //--------------------------------------------------------------------------
  85. // 功能:接受与分派处理网络消息
  86. //--------------------------------------------------------------------------
  87. void KCoreShell::NetMsgCallbackFunc(void* pMsgData)
  88. {
  89. #ifndef _SERVER
  90. g_ProtocolProcess.ProcessNetMsg((BYTE *)pMsgData);
  91. #endif
  92. }
  93. //--------------------------------------------------------------------------
  94. // 功能:设置游戏世界数据改变的通知函数
  95. // 参数:fnCoreDataChangedCallback pNotifyFunc --> 通知函数的指针。
  96. // 返回:返回值为非0值表示注册成功,否则表示失败。
  97. //--------------------------------------------------------------------------
  98. int KCoreShell::SetCallDataChangedNofify(IClientCallback* pNotifyFunc)
  99. {
  100. l_pDataChangedNotifyFunc = pNotifyFunc;
  101. return true;
  102. }
  103. //--------------------------------------------------------------------------
  104. // 功能:从游戏世界获取数据
  105. // 参数:unsigned int uDataId --> 表示获取游戏数据的数据项内容索引,其值为梅举类型
  106. // GAMEDATA_INDEX的取值之一。
  107. //   unsigned int uParam  --> 依据uDataId的取值情况而定
  108. //   int nParam --> 依据uDataId的取值情况而定
  109. // 返回:依据uDataId的取值情况而定。
  110. //--------------------------------------------------------------------------
  111. int KCoreShell::GetGameData(unsigned int uDataId, unsigned int uParam, int nParam)
  112. {
  113. int nRet = 0;
  114. switch(uDataId)
  115. {
  116. case GDI_PLAYER_IS_MALE:
  117. nRet = (Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_NpcSettingIdx == PLAYER_MALE_NPCTEMPLATEID);
  118. break;
  119. case GDI_TRADE_ITEM_PRICE:
  120. if (uParam)
  121. {
  122. KUiObjAtContRegion *pObj = (KUiObjAtContRegion *)uParam;
  123. KItem* pItem = NULL;
  124. switch(pObj->Obj.uGenre)
  125. {
  126. case CGOG_ITEM:
  127. {
  128. if (pObj->Obj.uId > 0)
  129. {
  130. pItem = &Item[pObj->Obj.uId];
  131. }
  132. }
  133. break;
  134. case CGOG_NPCSELLITEM:
  135. {
  136. int nBuyIdx = Player[CLIENT_PLAYER_INDEX].m_BuyInfo.m_nBuyIdx;
  137. if (nBuyIdx != -1)
  138. {
  139. int nIndex = BuySell.GetItemIndex(nBuyIdx, pObj->Obj.uId);
  140. if (nIndex >= 0)
  141. pItem = BuySell.GetItem(nIndex);
  142. }
  143. }
  144. break;
  145. default:
  146. break;
  147. }
  148. if (!pItem)
  149. break;
  150. KUiItemBuySelInfo *pInfo = (KUiItemBuySelInfo *)nParam;
  151. if (pObj->eContainer == UOC_NPC_SHOP)
  152. pInfo->nPrice = pItem->GetPrice();
  153. else
  154. pInfo->nPrice = pItem->GetPrice() / BUY_SELL_SCALE;
  155. strcpy(pInfo->szItemName, pItem->GetName());
  156. nRet = (pItem->GetGenre() != item_task);
  157. }
  158. else
  159. {
  160. nParam = 0;
  161. nRet = 0;
  162. }
  163. break;
  164. //游戏对象描述说明文本串
  165. //uParam = (KUiGameObject*) 描述游戏对象的结构数据的指针
  166. //nParam = (char*) 指向一个缓冲区的指针,其空间不少于256字节。
  167. case GDI_GAME_OBJ_DESC_INCLUDE_TRADEINFO:
  168. #ifndef _SERVER
  169. if (nParam && uParam)
  170. {
  171. KUiObjAtContRegion* pObj = (KUiObjAtContRegion *)uParam;
  172. char* pszDescript = (char *)nParam;
  173. pszDescript[0] = 0;
  174. switch(pObj->Obj.uGenre)
  175. {
  176. case CGOG_ITEM:
  177. {
  178. if (pObj->eContainer == UOC_EQUIPTMENT)
  179. {
  180. int nActive = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetActiveAttribNum(pObj->Obj.uId);
  181. Item[pObj->Obj.uId].GetDesc(pszDescript, true, BUY_SELL_SCALE, nActive);
  182. }
  183. else
  184. Item[pObj->Obj.uId].GetDesc(pszDescript, true, BUY_SELL_SCALE);
  185. }
  186. break;
  187. case CGOG_NPCSELLITEM:
  188. {
  189. int nIdx = -1;
  190. if (-1 == Player[CLIENT_PLAYER_INDEX].m_BuyInfo.m_nBuyIdx)
  191. break;
  192. nIdx = BuySell.GetItemIndex(Player[CLIENT_PLAYER_INDEX].m_BuyInfo.m_nBuyIdx, pObj->Obj.uId);
  193. KItem* pItem = NULL;
  194. if (nIdx < 0)
  195. break;
  196. pItem = BuySell.GetItem(nIdx);
  197. if (!pItem)
  198. break;
  199. pItem->GetDesc(pszDescript, true);
  200. }
  201. break;
  202. }
  203. }
  204. #endif
  205. break;
  206. case GDI_GAME_OBJ_DESC:
  207. #ifndef _SERVER
  208. if (nParam && uParam)
  209. {
  210. KUiObjAtContRegion* pObj = (KUiObjAtContRegion *)uParam;
  211. char* pszDescript = (char *)nParam;
  212. pszDescript[0] = 0;
  213. switch(pObj->Obj.uGenre)
  214. {
  215. case CGOG_ITEM:
  216. {
  217. if (pObj->eContainer == UOC_EQUIPTMENT)
  218. {
  219. int nActive = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetActiveAttribNum(pObj->Obj.uId);
  220. Item[pObj->Obj.uId].GetDesc(pszDescript, false, 1, nActive);
  221. }
  222. else
  223. Item[pObj->Obj.uId].GetDesc(pszDescript);
  224. }
  225. break;
  226. case CGOG_SKILL:
  227. case CGOG_SKILL_FIGHT:
  228. case CGOG_SKILL_LIVE:
  229. case CGOG_SKILL_SHORTCUT:
  230. {
  231. int nLevel = Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_SkillList.GetLevel(pObj->Obj.uId);
  232. _ASSERT(nLevel >= 0);
  233. if (pObj->Obj.uId >0)
  234. {
  235. KSkill::GetDesc(
  236. pObj->Obj.uId,
  237. nLevel,
  238. pszDescript,
  239. Player[CLIENT_PLAYER_INDEX].m_nIndex,
  240. (pObj->Obj.uGenre == CGOG_SKILL_SHORTCUT)?false:true
  241. );
  242. }
  243. }
  244. break;
  245. case CGOG_PLAYER_FACE:
  246. break;
  247. case CGOG_NPCSELLITEM:
  248. {
  249. int nIdx = -1;
  250. if (-1 == Player[CLIENT_PLAYER_INDEX].m_BuyInfo.m_nBuyIdx)
  251. break;
  252. nIdx = BuySell.GetItemIndex(Player[CLIENT_PLAYER_INDEX].m_BuyInfo.m_nBuyIdx, pObj->Obj.uId);
  253. KItem* pItem = NULL;
  254. if (nIdx < 0)
  255. break;
  256. pItem = BuySell.GetItem(nIdx);
  257. if (!pItem)
  258. break;
  259. pItem->GetDesc(pszDescript);
  260. }
  261. break;
  262. }
  263. }
  264. break;
  265. #endif
  266. //主角的一些不易变的数据
  267. //uParam = (KUiPlayerBaseInfo*)pInfo
  268. case GDI_PLAYER_BASE_INFO:
  269. #ifndef _SERVER
  270. if (uParam)
  271. {
  272. KUiPlayerBaseInfo* pInfo = (KUiPlayerBaseInfo*)uParam;
  273. strcpy(pInfo->Name,Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].Name);
  274. //to do:no implements in this version
  275. pInfo->Agname[0] = 0;
  276. pInfo->Title[0] = 0;
  277. if (Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_btRankId)
  278. {
  279. char szRankId[5];
  280. itoa(Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_btRankId, szRankId, 10);
  281. g_RankTabSetting.GetString(szRankId, "RANKSTR", "", pInfo->Title, 32);
  282. }
  283. pInfo->nCurFaction = Player[CLIENT_PLAYER_INDEX].m_cFaction.m_nCurFaction;
  284. }
  285. #endif
  286. break;
  287. //主角的一些易变的数据
  288. //uParam = (KUiPlayerRuntimeInfo*)pInfo
  289. case GDI_PLAYER_RT_INFO:
  290. if (uParam)
  291. {
  292. KUiPlayerRuntimeInfo* pInfo = (KUiPlayerRuntimeInfo*)uParam;
  293. pInfo->nLifeFull = Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_CurrentLifeMax; //生命满值
  294. pInfo->nLife = Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_CurrentLife; //生命
  295. pInfo->nManaFull = Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_CurrentManaMax; //内力满值
  296. pInfo->nMana = Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_CurrentMana; //内力
  297. pInfo->nStaminaFull = Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_CurrentStaminaMax; //体力满值
  298. pInfo->nStamina = Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_CurrentStamina; //体力
  299. pInfo->nAngryFull = 0; //怒满值
  300. pInfo->nAngry = 0; //怒
  301. pInfo->nExperienceFull = Player[CLIENT_PLAYER_INDEX].m_dwNextLevelExp; //经验满值
  302. pInfo->nExperience = Player[CLIENT_PLAYER_INDEX].m_dwExp; //经验
  303. pInfo->nCurLevelExperience = Player[CLIENT_PLAYER_INDEX].m_dwNextLevelExp - PlayerSet.m_cLevelAdd.GetLevelExp(Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_Level - 1);
  304. pInfo->byActionDisable = 0;
  305. //to do 给pInfo->bActionDisable、赋予合适的值
  306. pInfo->byAction = PA_NONE;
  307. #ifndef _SERVER
  308. if (Player[CLIENT_PLAYER_INDEX].m_RunStatus)
  309. pInfo->byAction |= PA_RUN;
  310. #endif
  311. if (Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_Doing == do_sit)
  312. pInfo->byAction |= PA_SIT;
  313. pInfo->wReserved = 0;
  314. }
  315. break;
  316. //主角的一些易变的属性数据
  317. //uParam = (KUiPlayerAttribute*)pInfo
  318. case GDI_PLAYER_RT_ATTRIBUTE:
  319. #ifndef _SERVER
  320. if (uParam)
  321. {
  322. KUiPlayerAttribute* pInfo = (KUiPlayerAttribute*)uParam;
  323. KNpc* pNpc = &Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex];
  324. pInfo->nMoney = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetMoney(room_equipment); //银两
  325. pInfo->nBARemainPoint = Player[CLIENT_PLAYER_INDEX].m_nAttributePoint; //基本属性剩余点数
  326. pInfo->nStrength = Player[CLIENT_PLAYER_INDEX].m_nCurStrength; //力量
  327. pInfo->nDexterity = Player[CLIENT_PLAYER_INDEX].m_nCurDexterity; //敏捷
  328. pInfo->nVitality = Player[CLIENT_PLAYER_INDEX].m_nCurVitality; //活力
  329. pInfo->nEnergy = Player[CLIENT_PLAYER_INDEX].m_nCurEngergy; //精力
  330. Player[CLIENT_PLAYER_INDEX].GetEchoDamage(&pInfo->nKillMIN, &pInfo->nKillMAX, 0); //最大最小杀伤力
  331. Player[CLIENT_PLAYER_INDEX].GetEchoDamage(&pInfo->nRightKillMin , &pInfo->nRightKillMax, 1);
  332. pInfo->nAttack = pNpc->m_CurrentAttackRating; //攻击力
  333. pInfo->nDefence = pNpc->m_CurrentDefend; //防御力
  334. pInfo->nMoveSpeed = pNpc->m_CurrentRunSpeed; //移动速度
  335. pInfo->nAttackSpeed = pNpc->m_CurrentAttackSpeed; //攻击速度
  336. //物理防御
  337. if (pNpc->m_CurrentPhysicsResistMax >= pNpc->m_CurrentPhysicsResist)
  338. pInfo->nPhyDef = pNpc->m_CurrentPhysicsResist;
  339. else
  340. pInfo->nPhyDef = pNpc->m_CurrentPhysicsResistMax;
  341. //冰冻防御
  342. if (pNpc->m_CurrentColdResistMax >= pNpc->m_CurrentColdResist)
  343. pInfo->nCoolDef = pNpc->m_CurrentColdResist;
  344. else
  345. pInfo->nCoolDef = pNpc->m_CurrentColdResistMax;
  346. //闪电防御
  347. if (pNpc->m_CurrentLightResistMax >= pNpc->m_CurrentLightResist)
  348. pInfo->nLightDef = pNpc->m_CurrentLightResist;
  349. else
  350. pInfo->nLightDef = pNpc->m_CurrentLightResistMax;
  351. //火焰防御
  352. if (pNpc->m_CurrentFireResistMax >= pNpc->m_CurrentFireResist)
  353. pInfo->nFireDef = pNpc->m_CurrentFireResist;
  354. else
  355. pInfo->nFireDef = pNpc->m_CurrentFireResistMax;
  356. //毒素防御
  357. if (pNpc->m_CurrentPoisonResistMax >= pNpc->m_CurrentPoisonResist)
  358. pInfo->nPoisonDef = pNpc->m_CurrentPoisonResist;
  359. else
  360. pInfo->nPoisonDef = pNpc->m_CurrentPoisonResistMax;
  361. pInfo->nLevel = pNpc->m_Level;
  362. // 根据玩家状态显示 状态文字 not end 不应该是状态,应该是五行属性 spe
  363. memset(pInfo->StatusDesc, 0, sizeof(pInfo->StatusDesc));
  364. switch(pNpc->m_Series)
  365. {
  366. case series_water:
  367. strcpy(pInfo->StatusDesc, "水系");
  368. break;
  369. case series_wood:
  370. strcpy(pInfo->StatusDesc, "木系");
  371. break;
  372. case series_metal:
  373. strcpy(pInfo->StatusDesc, "金系");
  374. break;
  375. case series_fire:
  376. strcpy(pInfo->StatusDesc, "火系");
  377. break;
  378. case series_earth:
  379. strcpy(pInfo->StatusDesc, "土系");
  380. break;
  381. }
  382. }
  383. break;
  384. //主角的立即使用物品与武功
  385. //uParam = (KUiPlayerImmedItemSkill*)pInfo
  386. #endif
  387. case GDI_PLAYER_IMMED_ITEMSKILL:
  388. #ifndef _SERVER
  389. if (uParam)
  390. {
  391. KUiPlayerImmedItemSkill* pInfo = (KUiPlayerImmedItemSkill*)uParam;
  392. memset(pInfo,0,sizeof(KUiPlayerImmedItemSkill));
  393. pInfo->IMmediaSkill[0].uGenre = CGOG_SKILL_SHORTCUT;
  394. pInfo->IMmediaSkill[0].uId = Player[CLIENT_PLAYER_INDEX].GetLeftSkill();
  395. pInfo->IMmediaSkill[1].uGenre = CGOG_SKILL_SHORTCUT;
  396. pInfo->IMmediaSkill[1].uId = Player[CLIENT_PLAYER_INDEX].GetRightSkill();
  397. for (int i = 0; i < MAX_IMMEDIACY_ITEM; i++)
  398. {
  399. pInfo->ImmediaItem[i].uId = Player[CLIENT_PLAYER_INDEX].m_ItemList.m_Room[room_immediacy].FindItem(i, 0);
  400. if (pInfo->ImmediaItem[i].uId > 0)
  401. {
  402. pInfo->ImmediaItem[i].uGenre = CGOG_ITEM;
  403. }
  404. else
  405. {
  406. pInfo->ImmediaItem[i].uGenre = CGOG_NOTHING;
  407. }
  408. }
  409. }
  410. break;
  411. //主角随身携带的钱
  412. //nRet = 主角随身携带的钱
  413. #endif
  414. case GDI_PLAYER_HOLD_MONEY:
  415. nRet = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetMoney(room_equipment);
  416. break;
  417. //主角随身携带的物品等
  418. //uParam = (KUiObjAtRegion*) pInfo -> KUiObjAtRegion结构数组的指针,KUiObjAtRegion
  419. // 结构用于存储物品或者武功的数据及其放置区域位置信息。
  420. //nParam = pInfo数组中包含KUiObjAtRegion结构的数目
  421. //Return = 如果返回值小于等于传入参数nParam,其值表示pInfo数组中的前多少个KUiObjAtRegion
  422. // 结构被填充了有效的数据;否则表示需要传入包含多少个KUiObjAtRegion结构的数组
  423. // 才够存储全部的随身携带的物品信息。
  424. // flying添加了一个是否可以骑马的请求,在这里实现,gg可乐一罐,mm请吃KFC哦
  425. case GDI_PLAYER_CAN_RIDE:
  426. // 实现分支的代码在这里添加
  427. break;
  428. case GDI_ITEM_TAKEN_WITH:
  429. nRet = 0;
  430. if (uParam)
  431. {
  432. int nCount = 0;
  433. KUiObjAtRegion* pInfo = (KUiObjAtRegion*)uParam;
  434. PlayerItem* pItem = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetFirstItem();
  435. if (pItem && pItem->nPlace == pos_equiproom)
  436. {
  437. pInfo->Obj.uGenre = CGOG_ITEM;
  438. pInfo->Obj.uId = pItem->nIdx;
  439. pInfo->Region.h = pItem->nX;
  440. pInfo->Region.v = pItem->nY;
  441. pInfo->Region.Width = Item[pItem->nIdx].GetWidth();
  442. pInfo->Region.Height = Item[pItem->nIdx].GetHeight();
  443. nCount++;
  444. pInfo++;
  445. }
  446. while(pItem)
  447. {
  448. pItem = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetNextItem();
  449. if (pItem && pItem->nPlace == pos_equiproom)
  450. {
  451. pInfo->Obj.uGenre = CGOG_ITEM;
  452. pInfo->Obj.uId = pItem->nIdx;
  453. pInfo->Region.h = pItem->nX;
  454. pInfo->Region.v = pItem->nY;
  455. pInfo->Region.Width = Item[pItem->nIdx].GetWidth();
  456. pInfo->Region.Height = Item[pItem->nIdx].GetHeight();
  457. nCount++;
  458. pInfo++;
  459. }
  460. if (nCount > nParam)
  461. break;
  462. }
  463. nRet = nCount;
  464. }
  465. else
  466. {
  467. int nCount = 0;
  468. PlayerItem* pItem = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetFirstItem();
  469. if (pItem && pItem->nPlace == pos_equiproom)
  470. nCount++;
  471. while(pItem)
  472. {
  473. pItem = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetNextItem();
  474. if (pItem && pItem->nPlace == pos_equiproom)
  475. nCount++;
  476. }
  477. nRet = nCount;
  478. }
  479. break;
  480. //主角装备物品
  481. //uParam = (KUiObjAtRegion*)pInfo -> 包含10个元素的KUiObjAtRegion结构数组指针,
  482. // KUiObjAtRegion结构用于存储装备的数据和放置位置信息。
  483. // KUiObjAtRegion::Region::h 表示属于第几套装备
  484. // KUiObjAtRegion::Region::v 表示属于哪个位置的装备,其值为梅举类型
  485. // UI_EQUIPMENT_POSITION的取值之一。请参看UI_EQUIPMENT_POSITION的注释。
  486. //nParam = 要获取的是第几套装备信息
  487. //Return =  其值表示pInfo数组中的前多少个KUiObjAtRegion结构被填充了有效的数据。
  488. case GDI_EQUIPMENT:
  489. nRet = 0;
  490. if (uParam)
  491. {
  492. // TODO:暂时没有做第二套装备
  493. if (nParam == 1)
  494. break;
  495. int PartConvert[itempart_num] = 
  496. {
  497. UIEP_HEAD, UIEP_BODY,
  498. UIEP_WAIST, UIEP_HAND,
  499. UIEP_FOOT, UIEP_FINESSE,
  500. UIEP_NECK, UIEP_FINGER1,
  501. UIEP_FINGER2, UIEP_WAIST_DECOR,
  502. UIEP_HORSE,
  503. };
  504. int nCount = 0;
  505. KUiObjAtRegion* pInfo = (KUiObjAtRegion*)uParam;
  506. for (int i = 0; i < itempart_num; i++)
  507. {
  508. pInfo->Obj.uId = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetEquipment(i);
  509. if (pInfo->Obj.uId)
  510. {
  511. pInfo->Obj.uGenre = CGOG_ITEM;
  512. pInfo->Region.Width = Item[pInfo->Obj.uId].GetWidth();
  513. pInfo->Region.Height = Item[pInfo->Obj.uId].GetHeight();
  514. pInfo->Region.h = 0;
  515. pInfo->Region.v = PartConvert[i];
  516. }
  517. else
  518. {
  519. pInfo->Obj.uGenre = CGOG_NOTHING;
  520. }
  521. nCount++;
  522. pInfo++;
  523. }
  524. nRet = nCount;
  525. }
  526. break;
  527. //交易操作相关的数据
  528. //uParam = (UI_TRADE_OPER_DATA)eOper 具体含义见UI_TRADE_OPER_DATA
  529. //nParam 具体应用与含义由uParam的取值状况决定,见UI_TRADE_OPER_DATA的说明
  530. //Return 具体含义由uParam的取值状况决定,见UI_TRADE_OPER_DATA的说明
  531. //主角的生活技能数据
  532. case GDI_TRADE_OPER_DATA:
  533. #ifndef _SERVER
  534. if (uParam == UTOD_IS_LOCKED)
  535. nRet = Player[CLIENT_PLAYER_INDEX].m_cTrade.m_nTradeLock;
  536. else if (uParam == UTOD_IS_TRADING)
  537. nRet = Player[CLIENT_PLAYER_INDEX].m_cTrade.m_nTradeState;
  538. else if (uParam == UTOD_IS_OTHER_LOCKED)
  539. nRet = Player[CLIENT_PLAYER_INDEX].m_cTrade.m_nTradeDestLock;
  540. else if (uParam == UTOD_IS_WILLING)
  541. {
  542. nRet = (Player[CLIENT_PLAYER_INDEX].m_cMenuState.m_nState == PLAYER_MENU_STATE_TRADEOPEN);
  543. }
  544. #endif
  545. break;
  546. //uParam = (KUiPlayerLiveSkillBase*) pInfo -> 主角的生活技能数据
  547. case GDI_LIVE_SKILL_BASE:
  548. if (uParam)
  549. {
  550. KUiPlayerLiveSkillBase* pInfo = (KUiPlayerLiveSkillBase*)uParam;
  551. //to do:no implements in this version;
  552. pInfo->nLiveExperience = 0 ;
  553. pInfo->nRemainPoint = 0 ;
  554. pInfo->nLiveExperienceFull = 0 ;
  555. memset(pInfo,0,sizeof(KUiPlayerLiveSkillBase));
  556. }
  557. break;
  558. //主角掌握的各项生活技能
  559. //uParam = (unsigned int*) pSkills -> 包含10个unsigned int的数组用于存储各项生活技能的id。
  560. case GDI_LIVE_SKILLS:
  561. if (uParam)
  562. {
  563. //to do:no implements in this version;
  564. KUiSkillData* pInfo = (KUiSkillData*)uParam;
  565. memset(pInfo,0,sizeof(KUiSkillData)*10);
  566. }
  567. break;
  568. //剩余战斗技能点数
  569. //Return = 剩余战斗技能点数
  570. case GDI_FIGHT_SKILL_POINT:
  571. //to do:no implements in this version;
  572. nRet = Player[CLIENT_PLAYER_INDEX].m_nSkillPoint;
  573. break;
  574. //主角掌握的各项战斗技能
  575. //uParam = (unsigned int*) pSkills -> 包含30个unsigned int的数组用于存储各项战斗技能的id。
  576. case GDI_FIGHT_SKILLS:
  577. #ifndef _SERVER
  578. if (uParam)
  579. {
  580. KUiSkillData* pSkills = (KUiSkillData*)uParam;
  581. Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_SkillList.GetSkillSortList(pSkills);
  582. }
  583. #endif
  584. break;
  585. //显示左键技能列表
  586. //uParam = (KUiSkillData*) pSkills -> 包含65个KUiSkillData的数组用于存储各技能的数据。
  587. // KUiSkillData::nLevel用来表述技能显示在第几行
  588. //Return = 返回有效数据的Skills的数目
  589. case GDI_LEFT_ENABLE_SKILLS:
  590. #ifndef _SERVER
  591. {
  592. KUiSkillData * pSkills = (KUiSkillData*)uParam;
  593. int nCount = Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_SkillList.GetLeftSkillSortList(pSkills);
  594. return nCount;
  595. }
  596. #endif
  597. break;
  598. //显示右键技能列表
  599. //uParam = (KUiSkillData*) pSkills -> 包含65个KUiSkillData的数组用于存储各技能的数据。
  600. // KUiSkillData::nLevel用来表述技能显示在第几行
  601. //Return = 返回有效数据的Skills的数目
  602. case GDI_RIGHT_ENABLE_SKILLS:
  603. #ifndef _SERVER
  604. {
  605. KUiSkillData * pSkills = (KUiSkillData*)uParam;
  606. int nCount = Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_SkillList.GetRightSkillSortList(pSkills);
  607. return nCount;
  608. }
  609. #endif
  610. break;
  611. //主角的自创武功
  612. //uParam = (unsigned int*) pSkills -> 包含5个unsigned int的数组用于存储各项自创武功的id。
  613. case GDI_CUSTOM_SKILLS:
  614. if (uParam)
  615. {
  616. //to do: no implements in this version;
  617. KUiSkillData* pSkills = (KUiSkillData*)uParam;
  618. memset(pSkills,0,sizeof(KUiSkillData)*5);
  619. }
  620. break;
  621. //主角所在的队伍信息
  622. //uParam = (KUiPlayerTeam*)pTeam -> 队伍信息
  623. //nParam = 队长id,如果此值为0表示获取的是自己所在的队伍
  624. //Return = pTeam结构是否被填充信息。
  625. case GDI_TEAM_INFO:
  626. #ifndef _SERVER
  627. if (uParam)
  628. {
  629. //to do: waiting for... ;
  630. KUiPlayerTeam* pTeam = (KUiPlayerTeam*)uParam;
  631. if (nParam == 0)
  632. nRet = Player[CLIENT_PLAYER_INDEX].m_cTeam.GetInfo(pTeam);
  633. else
  634. ;
  635. }
  636. #endif
  637. break;
  638. //获取主角所在队伍成员列表
  639. //uParam = (KUiPlayerItem*)pList -> 人员信息列表
  640. //nParam = pList数组中包含KUiPlayerItem结构的数目
  641. //Return = 如果返回值小于等于传入参数nParam,其值表示pList数组中的前多少个KUiPlayerItem
  642. // 结构被填充了有效的数据;否则表示需要传入包含多少个KUiPlayerItem结构的数组
  643. // 才够存储全部的成员信息。
  644. case GDI_TEAM_MEMBER_LIST:
  645. #ifndef _SERVER
  646. nRet = g_Team[0].GetMemberInfo((KUiPlayerItem *)uParam, nParam);
  647. #endif
  648. break;
  649. case GDI_TEAM_REFUSE_INVITE_STATUS:
  650. #ifndef _SERVER
  651. nRet = Player[CLIENT_PLAYER_INDEX].m_cTeam.GetAutoRefuseState();
  652. #endif
  653. break;
  654. //想加入(玩家所在家)队伍的其它玩家的列表
  655. //uParam = (KUiPlayerItem*)pPlayerList -> KUiPlayerItem结构数组的指针,KUiPlayerItem
  656. // 结构用于预加入的其它玩家的信息。
  657. //nParam = pPlayerList数组中包含KUiPlayerItem结构的数目
  658. //Return = 如果返回值小于等于传入参数nParam,其值表示pPlayerList数组中的前多少个元素被填
  659. // 充了有效的数据;否则表示需要传入包含多少个元素的数组才够存储全部的信息。
  660. case GDI_TEAM_TOJOIN_LIST:
  661. #ifndef _SERVER
  662. if (uParam)
  663. {
  664. int nCount = 0;
  665. for(int i = 0; i < MAX_TEAM_APPLY_LIST; i++)
  666. {
  667. if (Player[CLIENT_PLAYER_INDEX].m_cTeam.m_sApplyList[i].m_dwNpcID > 0)
  668. nCount++;
  669. }
  670. if (nParam >= nCount)
  671. {
  672. KUiPlayerItem* pPlayerList = (KUiPlayerItem*)uParam;
  673. int nPos = 0; 
  674. for(int i = 0;i < MAX_TEAM_APPLY_LIST;i++)
  675. {
  676.  if (Player[CLIENT_PLAYER_INDEX].m_cTeam.m_sApplyList[i].m_dwNpcID > 0)
  677.  {
  678.  pPlayerList[nPos].uId = Player[CLIENT_PLAYER_INDEX].m_cTeam.m_sApplyList[i].m_dwNpcID;  
  679.  pPlayerList[nPos].nIndex = 0;
  680.  strcpy(pPlayerList[nPos].Name,Player[CLIENT_PLAYER_INDEX].m_cTeam.m_sApplyList[i].m_szName);
  681.  nPos++;
  682.  }
  683. }
  684. }
  685. nRet = nCount ;
  686. }
  687. #endif
  688. break;
  689. //获取周围玩家的列表
  690. //uParam = (KUiPlayerItem*)pList -> 人员信息列表
  691. // KUiPlayerItem::nData = 0
  692. //nParam = pList数组中包含KUiPlayerItem结构的数目
  693. //Return = 如果返回值小于等于传入参数nParam,其值表示pList数组中的前多少个KUiPlayerItem
  694. // 结构被填充了有效的数据;否则表示需要传入包含多少个KUiPlayerItem结构的数组
  695. // 才够存储全部人员信息。
  696. case GDI_NEARBY_PLAYER_LIST:
  697. #ifndef _SERVER
  698. nRet = NpcSet.GetAroundNotFriendPlayer((KUiPlayerItem*)uParam, nParam);
  699. #endif
  700. break;
  701. //获取周围孤单可受邀请的玩家的列表
  702. //参数含义同GDI_NEARBY_PLAYER_LIST
  703. case GDI_NEARBY_IDLE_PLAYER_LIST:
  704. #ifndef _SERVER
  705. nRet = NpcSet.GetAroundPlayerForTeamInvite((KUiPlayerItem*)uParam, nParam);
  706. #endif
  707. break;
  708. //主角统帅能力相关的数据
  709. //uParam = (KUiPlayerLeaderShip*) -> 主角统帅能力相关的数据结构指针
  710. case GDI_PLAYER_LEADERSHIP:
  711. #ifndef _SERVER
  712. if (uParam)
  713. {
  714. KUiPlayerLeaderShip* pInfo = (KUiPlayerLeaderShip*)uParam ;
  715. pInfo->nLeaderShipExperience = Player[CLIENT_PLAYER_INDEX].m_dwLeadExp ; //统帅力经验值
  716. //to do: waiting for...;
  717. pInfo->nLeaderShipExperienceFull = Player[CLIENT_PLAYER_INDEX].m_dwNextLevelExp; //统帅力经验值
  718. pInfo->nLeaderShipLevel = Player[CLIENT_PLAYER_INDEX].m_dwLeadLevel ; //统帅力等级
  719. }
  720. #endif
  721. break;
  722. case GDI_NPC_RES:
  723. #ifndef _SERVER
  724. if (uParam)
  725. {
  726. RoleBaseInfo* pInfo = (RoleBaseInfo *)uParam;
  727. KNpcRes* pRes = NULL;
  728. pRes = new KNpcRes;
  729. if (pRes)
  730. {
  731. char szName[32];
  732. if (pInfo->Sex)
  733. strcpy(szName, "女主角");
  734. else
  735. strcpy(szName, "男主角");
  736. pRes->Init(szName, &g_NpcResList);
  737. pRes->SetAction(cdo_fightstand);
  738. // pRes->SetArmor(pInfo->ArmorType);
  739. // pRes->SetHelm(pInfo->HelmType);
  740. // pRes->SetWeapon(pInfo->WeaponType);
  741. pRes->SetRideHorse(FALSE);
  742. }
  743. nRet = (int)pRes;
  744. }
  745. #endif
  746. break;
  747. //获得物品在某个环境位置的属性状态
  748. //uParam = (KUiGameObject*)pObj(当nParam==0时)物品的信息
  749. //uParam = (KUiObjAtContRegion*)pObj(当nParam!=0时)物品的信息
  750. //nParam = (int)(bool)bJustTry  是否只是尝试放置
  751. //Return = (ITEM_IN_ENVIRO_PROP)eProp 物品的属性状态
  752. case GDI_ITEM_IN_ENVIRO_PROP:
  753. #ifndef _SERVER
  754. {
  755. if (!nParam)
  756. {
  757. KUiGameObject *pObj = (KUiGameObject *)uParam;
  758. if (pObj->uGenre != CGOG_ITEM && pObj->uGenre != CGOG_NPCSELLITEM)
  759. break;
  760. KItem* pItem = NULL;
  761. if (pObj->uGenre == CGOG_ITEM && pObj->uId > 0 && pObj->uId < MAX_ITEM)
  762. {
  763. pItem = &Item[pObj->uId];
  764. }
  765. else if (pObj->uGenre == CGOG_NPCSELLITEM)
  766. {
  767. int nIdx = BuySell.GetItemIndex(Player[CLIENT_PLAYER_INDEX].m_BuyInfo.m_nBuyIdx, pObj->uId);
  768. pItem = BuySell.GetItem(nIdx);
  769. }
  770. _ASSERT(pItem);
  771. if (!pItem || pItem->GetGenre() != item_equip)
  772. break;
  773. if (Player[CLIENT_PLAYER_INDEX].m_ItemList.CanEquip(pItem))
  774. {
  775. nRet = IIEP_NORMAL;
  776. }
  777. else
  778. {
  779. nRet = IIEP_NOT_USEABLE;
  780. }
  781. }
  782. else
  783. {
  784. KUiObjAtContRegion *pObj = (KUiObjAtContRegion *)uParam;
  785. if (pObj->Obj.uGenre != CGOG_ITEM || pObj->Obj.uId >= MAX_ITEM)
  786. break;
  787. int PartConvert[itempart_num] = 
  788. itempart_head, itempart_weapon,
  789. itempart_amulet, itempart_cuff,
  790. itempart_body, itempart_belt,
  791. itempart_ring1, itempart_ring2,
  792. itempart_pendant, itempart_foot,
  793. itempart_horse,
  794. };
  795. _ASSERT(pObj->eContainer < itempart_num);
  796. if (pObj->eContainer >= itempart_num || pObj->eContainer < 0)
  797. break;
  798. if (Item[pObj->Obj.uId].GetGenre() != item_equip)
  799. break;
  800. int nPlace = PartConvert[pObj->eContainer];
  801. if (Player[CLIENT_PLAYER_INDEX].m_ItemList.CanEquip(pObj->Obj.uId, nPlace))
  802. {
  803. nRet = IIEP_NORMAL;
  804. }
  805. else
  806. {
  807. nRet = IIEP_NOT_USEABLE;
  808. }
  809. }
  810. }
  811. #endif
  812. break;
  813. //与NPC的买卖
  814. //uParam = (KUiObjAtContRegion*) pInfo -> KUiObjAtRegion结构数组的指针,KUiObjAtRegion
  815. // 结构用于存储物品的数据及其放置区域位置信息。
  816. // 其中KUiObjAtContRegion::nContainer值表示第几页的物品
  817. //nParam = pInfo数组中包含KUiObjAtRegion结构的数目
  818. //Return = 如果返回值小于等于传入参数nParam,其值表示pInfo数组中的前多少个KUiObjAtRegion
  819. // 结构被填充了有效的数据;否则表示需要传入包含多少个KUiObjAtRegion结构的数组
  820. // 才够存储全部的npc列出来交易的物品信息。
  821. case GDI_TRADE_NPC_ITEM:
  822. #ifndef _SERVER
  823. nRet = 0;
  824. if (uParam)
  825. {
  826. int nCount = 0;
  827. int nPage = 0;
  828. int nIndex = 0;
  829. int nBuyIdx = Player[CLIENT_PLAYER_INDEX].m_BuyInfo.m_nBuyIdx;
  830. KUiObjAtContRegion* pInfo = (KUiObjAtContRegion *)uParam;
  831. if (nBuyIdx == -1)
  832. break;
  833. if (nBuyIdx >= BuySell.GetHeight())
  834. break;
  835. if (!BuySell.m_pShopRoom)
  836. break;
  837. BuySell.m_pShopRoom->Clear();
  838. for (int i = 0; i < BuySell.GetWidth(); i++)
  839. {
  840. nIndex = BuySell.GetItemIndex(nBuyIdx, i);
  841. KItem* pItem = BuySell.GetItem(nIndex);
  842. if (nIndex >= 0 && pItem)
  843. {
  844. // Set pInfo->Obj.uGenre
  845. pInfo->Obj.uGenre = CGOG_NPCSELLITEM;
  846. // Set pInfo->Obj.uId
  847. pInfo->Obj.uId = i;
  848. POINT Pos;
  849. if (BuySell.m_pShopRoom->FindRoom(pItem->GetWidth(), pItem->GetHeight(), &Pos))
  850. {
  851. // nIndex + 1保证不为0
  852. BuySell.m_pShopRoom->PlaceItem(Pos.x, Pos.y, nIndex + 1, pItem->GetWidth(), pItem->GetHeight());
  853. }
  854. else
  855. {
  856. nPage++;
  857. BuySell.m_pShopRoom->Clear();
  858. // Clear完成后必然成功,所以没有判断
  859. BuySell.m_pShopRoom->FindRoom(pItem->GetWidth(), pItem->GetHeight(), &Pos);
  860. BuySell.m_pShopRoom->PlaceItem(Pos.x, Pos.y, nIndex + 1, pItem->GetWidth(), pItem->GetHeight());
  861. }
  862. pInfo->Region.h = Pos.x;
  863. pInfo->Region.v = Pos.y;
  864. pInfo->Region.Width = pItem->GetWidth();
  865. pInfo->Region.Height = pItem->GetHeight();
  866. pInfo->nContainer = nPage;
  867. nCount++;
  868. pInfo++;
  869. }
  870. }
  871. nRet = nCount;
  872. }
  873. else
  874. {
  875. int nCount = 0;
  876. int nIndex = 0;
  877. int nBuyIdx = Player[CLIENT_PLAYER_INDEX].m_BuyInfo.m_nBuyIdx;
  878. if (nBuyIdx == -1)
  879. break;
  880. if (nBuyIdx >= BuySell.GetHeight())
  881. break;
  882. for (int i = 0; i < BuySell.GetWidth(); i++)
  883. {
  884. nIndex = BuySell.GetItemIndex(nBuyIdx, i);
  885. KItem* pItem = BuySell.GetItem(nIndex);
  886. if (nIndex >= 0 && pItem)
  887. {
  888. nCount++;
  889. }
  890. }
  891. nRet = nCount;
  892. }
  893. #endif
  894. break;
  895. case GDI_CHAT_SEND_CHANNEL_LIST:
  896. #ifndef _SERVER
  897. nRet = Player[CLIENT_PLAYER_INDEX].m_cChat.SendSelectChannelList((KUiChatChannel*)uParam, nParam);
  898. #endif
  899. break;
  900. case GDI_CHAT_RECEIVE_CHANNEL_LIST:
  901. #ifndef _SERVER
  902. nRet = Player[CLIENT_PLAYER_INDEX].m_cChat.SendTakeChannelList((KUiChatChannel*)uParam, nParam);
  903. #endif
  904. break;
  905. case GDI_CHAT_CURRENT_SEND_CHANNEL:
  906. #ifndef _SERVER
  907. nRet = Player[CLIENT_PLAYER_INDEX].m_cChat.GetCurChannel((KUiChatChannel*)uParam);
  908. #endif
  909. break;
  910. case GDI_CHAT_GROUP_INFO:
  911. #ifndef _SERVER
  912. nRet = Player[CLIENT_PLAYER_INDEX].m_cChat.IGetTeamInfo(nParam, (KUiChatGroupInfo*)uParam);
  913. #endif
  914. break;
  915. //聊天一个好友分组中好友的信息
  916. //uParam = (KUiPlayerItem*)pList -> 人员信息列表
  917. // KUiPlayerItem::nData = (CHAT_STATUS)eFriendStatus 好友的当前状态
  918. //nParam = 要获取列表的好友分组的索引
  919. //Return = 其值表示pList数组中的前多少个KUiPlayerItem结构被填充了有效的数据.
  920. case GDI_CHAT_FRIENDS_IN_AGROUP:
  921. #ifndef _SERVER
  922. nRet = Player[CLIENT_PLAYER_INDEX].m_cChat.IGetTeamFriendInfo(nParam, (KUiPlayerItem*)uParam);
  923. #endif
  924. break;
  925. case GDI_ITEM_IN_STORE_BOX:
  926. #ifndef _SERVER
  927. nRet = 0;
  928. if (uParam)
  929. {
  930. int nCount = 0;
  931. KUiObjAtRegion* pInfo = (KUiObjAtRegion*)uParam;
  932. pInfo->Obj.uGenre = CGOG_MONEY;
  933. pInfo->Obj.uId = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetMoney(room_repository);
  934. nCount++;
  935. pInfo++;
  936. PlayerItem* pItem = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetFirstItem();
  937. if (pItem && pItem->nPlace == pos_repositoryroom)
  938. {
  939. pInfo->Obj.uGenre = CGOG_ITEM;
  940. pInfo->Obj.uId = pItem->nIdx;
  941. pInfo->Region.h = pItem->nX;
  942. pInfo->Region.v = pItem->nY;
  943. pInfo->Region.Width = Item[pItem->nIdx].GetWidth();
  944. pInfo->Region.Height = Item[pItem->nIdx].GetHeight();
  945. nCount++;
  946. pInfo++;
  947. }
  948. while(pItem)
  949. {
  950. pItem = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetNextItem();
  951. if (pItem && pItem->nPlace == pos_repositoryroom)
  952. {
  953. pInfo->Obj.uGenre = CGOG_ITEM;
  954. pInfo->Obj.uId = pItem->nIdx;
  955. pInfo->Region.h = pItem->nX;
  956. pInfo->Region.v = pItem->nY;
  957. pInfo->Region.Width = Item[pItem->nIdx].GetWidth();
  958. pInfo->Region.Height = Item[pItem->nIdx].GetHeight();
  959. nCount++;
  960. pInfo++;
  961. }
  962. if (nCount > nParam)
  963. break;
  964. }
  965. nRet = nCount;
  966. }
  967. else
  968. {
  969. int nCount = 0;
  970. // 第一个是钱
  971. nCount++;
  972. // 后面是装备
  973. PlayerItem* pItem = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetFirstItem();
  974. if (pItem && pItem->nPlace == pos_repositoryroom)
  975. nCount++;
  976. while(pItem)
  977. {
  978. pItem = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetNextItem();
  979. if (pItem && pItem->nPlace == pos_repositoryroom)
  980. nCount++;
  981. }
  982. nRet = nCount;
  983. }
  984. #endif
  985. break;
  986. case GDI_SCENE_TIME_INFO:
  987. #ifndef _SERVER
  988. if (uParam)
  989. {
  990. KUiSceneTimeInfo* pInfo = (KUiSceneTimeInfo*)uParam;
  991. g_ScenePlace.GetSceneNameAndFocus(pInfo->szSceneName, pInfo->nSceneId,
  992. pInfo->nScenePos0, pInfo->nScenePos1);
  993. pInfo->nGameSpaceTime = (SubWorld[0].m_dwCurrentTime / 100) % 1440;
  994. }
  995. #endif
  996. break;
  997. }
  998. return nRet;
  999. }
  1000. int KCoreShell::FreeGameData(unsigned int uDataId, unsigned int uParam, int nParam)
  1001. {
  1002. int nRet = 0;
  1003. switch(uDataId)
  1004. {
  1005. case GDI_NPC_RES:
  1006. #ifndef _SERVER
  1007. delete (KNpcRes *)uParam;
  1008. #endif
  1009. break;
  1010. }
  1011. return nRet;
  1012. }
  1013. //--------------------------------------------------------------------------
  1014. // 功能:向游戏发送操作
  1015. // 参数:unsigned int uDataId --> Core外部客户对core的操作请求的索引定义
  1016. // 其值为梅举类型GAMEOPERATION_INDEX的取值之一。
  1017. //   unsigned int uParam  --> 依据uOperId的取值情况而定
  1018. //   int nParam --> 依据uOperId的取值情况而定
  1019. // 返回:如果成功发送操作请求,函数返回非0值,否则返回0值。
  1020. //--------------------------------------------------------------------------
  1021. int KCoreShell::OperationRequest(unsigned int uOper, unsigned int uParam, int nParam)
  1022. {
  1023. int nRet = 1;
  1024. switch(uOper)
  1025. {
  1026. //uParam = (const char*)pszFileName
  1027. case GOI_PLAY_SOUND:
  1028. #ifndef _SERVER
  1029. if (uParam)
  1030. {
  1031. static KCacheNode* pSndNode = NULL;
  1032. KWavSound* pSound = NULL;
  1033. pSndNode = (KCacheNode*)g_SoundCache.GetNode((char *)uParam, (KCacheNode * )pSndNode);
  1034. pSound = (KWavSound*)pSndNode->m_lpData;
  1035. if (pSound)
  1036. {
  1037. if (pSound->IsPlaying())
  1038. break;
  1039. pSound->Play(0, Option.GetSndVolume(), 0);
  1040. }
  1041. }
  1042. #endif
  1043. break;
  1044. case GOI_PLAYER_RENASCENCE:
  1045. {
  1046. #ifndef _SERVER
  1047. int nReviveType;
  1048. if (nParam) // bBackTown
  1049. {
  1050. nReviveType = REMOTE_REVIVE_TYPE;
  1051. }
  1052. else
  1053. {
  1054. nReviveType = LOCAL_REVIVE_TYPE;
  1055. }
  1056. // SendClientCmdRevive(nReviveType);
  1057. SendClientCmdRevive();
  1058. #endif
  1059. }
  1060. break;
  1061. case GOI_MONEY_INOUT_STORE_BOX:
  1062. {
  1063. #ifndef _SERVER
  1064. BOOL bIn = (BOOL)uParam;
  1065. int nMoney = nParam;
  1066. int nSrcRoom, nDesRoom;
  1067. if (bIn)
  1068. {
  1069. nSrcRoom = room_equipment;
  1070. nDesRoom = room_repository;
  1071. }
  1072. else
  1073. {
  1074. nDesRoom = room_equipment;
  1075. nSrcRoom = room_repository;
  1076. }
  1077. Player[CLIENT_PLAYER_INDEX].m_ItemList.ExchangeMoney(nSrcRoom, nDesRoom, nMoney);
  1078. #endif
  1079. }
  1080. break;
  1081. //离开游戏
  1082. case GOI_EXIT_GAME:
  1083. #ifndef _SERVER
  1084. Player[CLIENT_PLAYER_INDEX].SaveClientSkillData();
  1085. g_SubWorldSet.Close();
  1086. #endif
  1087. // if (g_pClient)
  1088. // g_pClient->Shutdown();
  1089. break;
  1090. case GOI_TRADE_NPC_BUY:
  1091. {
  1092. #ifndef _SERVER
  1093. KUiObjAtContRegion* pObject1 = (KUiObjAtContRegion*)uParam;
  1094. if (CGOG_NPCSELLITEM != pObject1->Obj.uGenre)
  1095. break;
  1096. int nIdx = 0;
  1097. KItem* pItem = NULL;
  1098. nIdx = BuySell.GetItemIndex(Player[CLIENT_PLAYER_INDEX].m_BuyInfo.m_nBuyIdx, pObject1->Obj.uId);
  1099. pItem = BuySell.GetItem(nIdx);
  1100. int nWidth, nHeight;
  1101. ItemPos Pos;
  1102. nWidth = pItem->GetWidth();
  1103. nHeight = pItem->GetHeight();
  1104. if (!Player[CLIENT_PLAYER_INDEX].m_ItemList.SearchPosition(nWidth, nHeight, &Pos))
  1105. {
  1106. nRet = 0;
  1107. break;
  1108. }
  1109. if (Pos.nPlace != pos_equiproom)
  1110. {
  1111. nRet = 0;
  1112. KSystemMessage sMsg;
  1113. strcpy(sMsg.szMessage, MSG_SHOP_NO_ROOM);
  1114. sMsg.eType = SMT_SYSTEM;
  1115. sMsg.byConfirmType = SMCT_CLICK;
  1116. sMsg.byPriority = 1;
  1117. sMsg.byParamSize = 0;
  1118. CoreDataChanged(GDCNI_SYSTEM_MESSAGE, (unsigned int)&sMsg, 0);
  1119. break;
  1120. }
  1121. if (Player[CLIENT_PLAYER_INDEX].m_ItemList.GetEquipmentMoney() < pItem->GetPrice())
  1122. {
  1123. nRet = 0;
  1124. KSystemMessage sMsg;
  1125. strcpy(sMsg.szMessage, MSG_SHOP_NO_MONEY);
  1126. sMsg.eType = SMT_SYSTEM;
  1127. sMsg.byConfirmType = SMCT_CLICK;
  1128. sMsg.byPriority = 1;
  1129. sMsg.byParamSize = 0;
  1130. CoreDataChanged(GDCNI_SYSTEM_MESSAGE, (unsigned int)&sMsg, 0);
  1131. break;
  1132. }
  1133. SendClientCmdBuy(pObject1->Obj.uId, pos_equiproom, Pos.nX, Pos.nY);
  1134. #endif
  1135. }
  1136. break;
  1137. case GOI_TRADE_NPC_SELL:
  1138. {
  1139. #ifndef _SERVER
  1140. KUiObjAtContRegion* pObject1 = (KUiObjAtContRegion*)uParam;
  1141. // KUiObjAtContRegion* pObject2 = (KUiObjAtContRegion*)nParam;
  1142. if (CGOG_ITEM != pObject1->Obj.uGenre)
  1143. break;
  1144. //放下去的东西不为空,所以是卖东西
  1145. int nIdx = pObject1->Obj.uId; //Player[CLIENT_PLAYER_INDEX].m_ItemList.Hand();
  1146. if (nIdx > 0 && nIdx < MAX_ITEM)
  1147. {
  1148. if (Item[nIdx].GetGenre() == item_task)
  1149. {
  1150. KSystemMessage sMsg;
  1151. sprintf(sMsg.szMessage, MSG_TRADE_TASK_ITEM);
  1152. sMsg.eType = SMT_NORMAL;
  1153. sMsg.byConfirmType = SMCT_NONE;
  1154. sMsg.byPriority = 0;
  1155. sMsg.byParamSize = 0;
  1156. CoreDataChanged(GDCNI_SYSTEM_MESSAGE, (unsigned int)&sMsg, 0);
  1157. return 0;
  1158. }
  1159. SendClientCmdSell(Item[nIdx].GetID());
  1160. return 1;
  1161. }
  1162. else
  1163. {
  1164. return 0;
  1165. }
  1166. #endif
  1167. }
  1168. break;
  1169. case GOI_SWITCH_OBJECT:
  1170. //uParam = (KUiObjAtContRegion*)pObject1 -> 拿起的物品操作前的信息
  1171. //nParam = (KUiObjAtContRegion*)pObject2 -> 放下的物品操作后的信息
  1172. {
  1173. #ifndef _SERVER
  1174. ItemPos P1, P2;
  1175. int PartConvert[itempart_num] = 
  1176. itempart_head, itempart_weapon,
  1177. itempart_amulet, itempart_cuff,
  1178. itempart_body, itempart_belt,
  1179. itempart_ring1, itempart_ring2,
  1180. itempart_pendant, itempart_foot,
  1181. itempart_horse,
  1182. };
  1183. KUiObjAtContRegion* pObject1 = (KUiObjAtContRegion*)uParam;
  1184. KUiObjAtContRegion* pObject2 = (KUiObjAtContRegion*)nParam;
  1185. if (!pObject1 && !pObject2)
  1186. break;
  1187. if (pObject1)
  1188. {
  1189. switch(pObject1->eContainer)
  1190. {
  1191. case UOC_STORE_BOX:
  1192. P1.nPlace = pos_repositoryroom;
  1193. P1.nX = pObject1->Region.h;
  1194. P1.nY = pObject1->Region.v;
  1195. break;
  1196. case UOC_IMMEDIA_ITEM:
  1197. P1.nPlace = pos_immediacy;
  1198. P1.nX = pObject1->Region.h;
  1199. P1.nY = pObject1->Region.v;
  1200. break;
  1201. case UOC_ITEM_TAKE_WITH:
  1202. P1.nPlace = pos_equiproom;
  1203. P1.nX = pObject1->Region.h;
  1204. P1.nY = pObject1->Region.v;
  1205. break;
  1206. case UOC_EQUIPTMENT:
  1207. {
  1208. // TODO:暂时没有第二装备
  1209. if (pObject1->Region.h == 1)
  1210. break;
  1211. P1.nPlace = pos_equip;
  1212. P1.nX = PartConvert[pObject1->Region.v];
  1213. }
  1214. break;
  1215. case UOC_TO_BE_TRADE:
  1216. P1.nPlace = pos_traderoom;
  1217. P1.nX = pObject1->Region.h;
  1218. P1.nY = pObject1->Region.v;
  1219. break;
  1220. case UOC_NPC_SHOP:
  1221. if (CGOG_NPCSELLITEM != pObject1->Obj.uGenre)
  1222. break;
  1223. int nIdx = 0;
  1224. KItem* pItem = NULL;
  1225. nIdx = BuySell.GetItemIndex(Player[CLIENT_PLAYER_INDEX].m_BuyInfo.m_nBuyIdx, pObject1->Obj.uId);
  1226. pItem = BuySell.GetItem(nIdx);
  1227. int nWidth, nHeight;
  1228. ItemPos Pos;
  1229. nWidth = pItem->GetWidth();
  1230. nHeight = pItem->GetHeight();
  1231. if (!Player[CLIENT_PLAYER_INDEX].m_ItemList.SearchPosition(nWidth, nHeight, &Pos))
  1232. {
  1233. nRet = 0;
  1234. KSystemMessage sMsg;
  1235. strcpy(sMsg.szMessage, MSG_SHOP_NO_ROOM);
  1236. sMsg.eType = SMT_SYSTEM;
  1237. sMsg.byConfirmType = SMCT_CLICK;
  1238. sMsg.byPriority = 1;
  1239. sMsg.byParamSize = 0;
  1240. CoreDataChanged(GDCNI_SYSTEM_MESSAGE, (unsigned int)&sMsg, 0);
  1241. break;
  1242. }
  1243. if (Pos.nPlace != pos_equiproom)
  1244. {
  1245. nRet = 0;
  1246. KSystemMessage sMsg;
  1247. strcpy(sMsg.szMessage, MSG_SHOP_NO_ROOM);
  1248. sMsg.eType = SMT_SYSTEM;
  1249. sMsg.byConfirmType = SMCT_CLICK;
  1250. sMsg.byPriority = 1;
  1251. sMsg.byParamSize = 0;
  1252. CoreDataChanged(GDCNI_SYSTEM_MESSAGE, (unsigned int)&sMsg, 0);
  1253. break;
  1254. }
  1255. if (Player[CLIENT_PLAYER_INDEX].m_ItemList.GetEquipmentMoney() < pItem->GetPrice())
  1256. {
  1257. nRet = 0;
  1258. KSystemMessage sMsg;
  1259. strcpy(sMsg.szMessage, MSG_SHOP_NO_MONEY);
  1260. sMsg.eType = SMT_SYSTEM;
  1261. sMsg.byConfirmType = SMCT_CLICK;
  1262. sMsg.byPriority = 1;
  1263. sMsg.byParamSize = 0;
  1264. CoreDataChanged(GDCNI_SYSTEM_MESSAGE, (unsigned int)&sMsg, 0);
  1265. break;
  1266. }
  1267. // 拿起来的东西不为空,所以是买东西
  1268. SendClientCmdBuy(pObject1->Obj.uId, pos_equiproom, Pos.nX, Pos.nY);
  1269. break;
  1270. }
  1271. }
  1272. if (pObject2)
  1273. {
  1274. switch(pObject2->eContainer)
  1275. {
  1276. case UOC_STORE_BOX:
  1277. P2.nPlace = pos_repositoryroom;
  1278. P2.nX = pObject2->Region.h;
  1279. P2.nY = pObject2->Region.v;
  1280. break;
  1281. case UOC_IMMEDIA_ITEM:
  1282. P2.nPlace = pos_immediacy;
  1283. P2.nX = pObject2->Region.h;
  1284. P2.nY = pObject2->Region.v;
  1285. break;
  1286. case UOC_ITEM_TAKE_WITH:
  1287. P2.nPlace = pos_equiproom;
  1288. P2.nX = pObject2->Region.h;
  1289. P2.nY = pObject2->Region.v;
  1290. break;
  1291. case UOC_EQUIPTMENT:
  1292. {
  1293. // TODO:暂时没有第二装备
  1294. if (pObject2->Region.h == 1)
  1295. break;
  1296. P2.nPlace = pos_equip;
  1297. P2.nX = PartConvert[pObject2->Region.v];
  1298. }
  1299. break;
  1300. case UOC_TO_BE_TRADE:
  1301. P2.nPlace = pos_traderoom;
  1302. P2.nX = pObject2->Region.h;
  1303. P2.nY = pObject2->Region.v;
  1304. break;
  1305. case UOC_NPC_SHOP:
  1306. break;
  1307. }
  1308. }
  1309. if (!pObject1)
  1310. {
  1311. memcpy(&P1, &P2, sizeof(P1));
  1312. }
  1313. if (!pObject2)
  1314. {
  1315. memcpy(&P2, &P1, sizeof(P1));
  1316. }
  1317. Player[CLIENT_PLAYER_INDEX].MoveItem(P1, P2);
  1318. #endif
  1319. }
  1320. break;
  1321. //玩家点完对话框
  1322. case GOI_INFORMATION_CONFIRM_NOTIFY:
  1323. {
  1324. #ifndef _SERVER
  1325. PLAYER_SELECTUI_COMMAND command;
  1326. command.nSelectIndex = 0;
  1327. Player[CLIENT_PLAYER_INDEX].OnSelectFromUI(&command, UI_TALKDIALOG);
  1328. #endif
  1329. break;
  1330. }
  1331. //问题选择答案
  1332. //nParma = nAnswerIndex
  1333. case GOI_QUESTION_CHOOSE:
  1334. #ifndef _SERVER
  1335. if (g_bUISelLastSelCount == 0 )
  1336. break;
  1337. {
  1338. PLAYER_SELECTUI_COMMAND command;
  1339. command.nSelectIndex = nParam;
  1340. Player[CLIENT_PLAYER_INDEX].OnSelectFromUI(&command, UI_SELECTDIALOG);
  1341. }
  1342. #endif
  1343. break;
  1344. //使用物品
  1345. //uParam = (KUiObjAtRegion*)pInfo -> 物品的数据以及物品原来摆放的位置
  1346. //nParam = 物品使用前放置的位置,取值为枚举类型UIOBJECT_CONTAINER。
  1347. case GOI_USE_ITEM:
  1348. //to do: waiting for...
  1349. #ifndef _SERVER
  1350. if (uParam)
  1351. {
  1352. KUiObjAtRegion* pInfo = (KUiObjAtRegion*) uParam;
  1353. int nPlace = nParam;
  1354. ItemPos Pos;
  1355. switch(nPlace)
  1356. {
  1357. case UOC_ITEM_TAKE_WITH:
  1358. Pos.nPlace = pos_equiproom;
  1359. break;
  1360. case UOC_IMMEDIA_ITEM:
  1361. Pos.nPlace = pos_immediacy;
  1362. break;
  1363. default:
  1364. Pos.nPlace = -1;
  1365. break;
  1366. }
  1367. Pos.nX = pInfo->Region.h;
  1368. Pos.nY = pInfo->Region.v;
  1369. if (pInfo->Obj.uGenre == CGOG_ITEM && pInfo->Obj.uId > 0 && Pos.nPlace != -1)
  1370. Player[CLIENT_PLAYER_INDEX].ApplyUseItem(pInfo->Obj.uId, Pos);
  1371. }
  1372. #endif
  1373. break;
  1374. //穿上装备
  1375. //uParam = (KUiObjAtRegion*)pInfo -> 装备的数据和放置位置信息
  1376. // KUiObjAtRegion::Region::h 表示属于第几套装备
  1377. // KUiObjAtRegion::Region::v 表示属于哪个位置的装备,其值为梅举类型
  1378. // UI_EQUIPMENT_POSITION的取值之一。请参看UI_EQUIPMENT_POSITION的注释。
  1379. case GOI_WEAR_EQUIP:
  1380. //to do: waiting for...
  1381. #ifndef _SERVER
  1382. if (uParam)
  1383. {
  1384. KUiObjAtRegion* pInfo = (KUiObjAtRegion*) uParam;
  1385. }
  1386. #endif
  1387. break;
  1388. //施展武功/技能
  1389. //uParam = (KUiGameObject*)pInfo -> 技能数据
  1390. case GOI_USE_SKILL:
  1391. #ifndef _SERVER
  1392. if (uParam)
  1393. {
  1394. //to do:wating for...
  1395. KUiGameObject* pInfo = (KUiGameObject*)uParam;
  1396. }
  1397. #endif
  1398. break;
  1399. //设置立即技能
  1400. //uParam = (KUiGameObject*)pSKill, 技能信息
  1401. //nParam = 立即位置,0表示为右键技能,1至4表示为F1至F4技能
  1402. case GOI_SET_IMMDIA_SKILL:
  1403. #ifndef _SERVER
  1404. if (uParam)
  1405. {
  1406. KUiGameObject* pSkill = (KUiGameObject*)uParam;
  1407. if (nParam == 0)
  1408. //to do : modify;
  1409. {
  1410. if ( (int)pSkill->uId > 0 )
  1411. Player[CLIENT_PLAYER_INDEX].SetLeftSkill((int)pSkill->uId);
  1412. else if ((int)(pSkill->uId) == -1) //设置当前物理技能为左技能
  1413. {
  1414. int nDetailType = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetWeaponType();
  1415. int nParticularType = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetWeaponParticular();
  1416. //近身武器
  1417. if (nDetailType == 0)
  1418. {
  1419. Player[CLIENT_PLAYER_INDEX].SetLeftSkill(g_nMeleeWeaponSkill[nParticularType]);
  1420. }//远程武器
  1421. else if (nDetailType == 1)
  1422. {
  1423. Player[CLIENT_PLAYER_INDEX].SetLeftSkill(g_nRangeWeaponSkill[nParticularType]);
  1424. }//空手
  1425. else if (nDetailType == -1)
  1426. {
  1427. Player[CLIENT_PLAYER_INDEX].SetLeftSkill(g_nHandSkill);
  1428. }
  1429. }
  1430. }
  1431. else if (nParam == 1)
  1432. {
  1433. if ((int)pSkill->uId > 0)
  1434. Player[CLIENT_PLAYER_INDEX].SetRightSkill((int)pSkill->uId);
  1435. else if ((int)(pSkill->uId) == -1)
  1436. {
  1437. int nDetailType = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetWeaponType();
  1438. int nParticularType = Player[CLIENT_PLAYER_INDEX].m_ItemList.GetWeaponParticular();
  1439. if (nDetailType == 0)
  1440. {
  1441. Player[CLIENT_PLAYER_INDEX].SetRightSkill(g_nMeleeWeaponSkill[nParticularType]);
  1442. }
  1443. else if (nDetailType == 1)
  1444. {
  1445. Player[CLIENT_PLAYER_INDEX].SetRightSkill(g_nRangeWeaponSkill[nParticularType]);
  1446. }
  1447. else if (nDetailType == -1)
  1448. {
  1449. Player[CLIENT_PLAYER_INDEX].SetRightSkill(g_nHandSkill);
  1450. }
  1451. }
  1452. }
  1453. }
  1454. #endif
  1455. break;
  1456. //增强一种技能,,一次加一点
  1457. //uParam = 技能类属
  1458. //nParam = (uint)技能id
  1459. case GOI_TONE_UP_SKILL:
  1460. //to do : waiting for...
  1461. {
  1462. #ifndef _SERVER
  1463. Player[CLIENT_PLAYER_INDEX].ApplyAddSkillLevel((int)nParam, 1);
  1464. #endif
  1465. }
  1466. break;
  1467. //增强一些属性的值,一次加一点
  1468. //uParam = 表示要增强的是哪个属性,取值为UI_PLAYER_ATTRIBUTE的梅举值之一
  1469. case GOI_TONE_UP_ATTRIBUTE:
  1470. #ifndef _SERVER
  1471. switch (uParam)
  1472. {
  1473. case UIPA_STRENGTH: //力量
  1474. Player[CLIENT_PLAYER_INDEX].ApplyAddBaseAttribute(0, 1);
  1475. break;
  1476. case UIPA_DEXTERITY: //敏捷
  1477. Player[CLIENT_PLAYER_INDEX].ApplyAddBaseAttribute(1, 1);
  1478. break;
  1479. case UIPA_VITALITY: //活力
  1480. Player[CLIENT_PLAYER_INDEX].ApplyAddBaseAttribute(2, 1);
  1481. break;
  1482. case UIPA_ENERGY: //精力
  1483. Player[CLIENT_PLAYER_INDEX].ApplyAddBaseAttribute(3, 1);
  1484. break;
  1485. }
  1486. #endif
  1487. break;
  1488. //===========组队相关==================
  1489. case GOI_TEAM_COLLECT_NEARBY_LIST:
  1490. #ifndef _SERVER
  1491. NpcSet.GetAroundOpenCaptain(Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_Camp);
  1492. #endif
  1493. break;
  1494. case GOI_TEAM_APPLY:
  1495. if (uParam)
  1496. #ifndef _SERVER
  1497. Player[CLIENT_PLAYER_INDEX].ApplyAddTeam(((KUiTeamItem*)uParam)->Leader.nIndex);
  1498. #endif
  1499. break;
  1500. case GOI_TRAM_REFUSE_INVITE:
  1501. #ifndef _SERVER
  1502. Player[CLIENT_PLAYER_INDEX].m_cTeam.SetAutoRefuseInvite(nParam);
  1503. #endif
  1504. break;
  1505. //新组队伍
  1506. //uParam = (const char*)pTeamName -> 新组队伍的名称
  1507. case GOI_TEAM_NEW:
  1508. #ifndef _SERVER
  1509. Player[CLIENT_PLAYER_INDEX].ApplyCreateTeam();//(char*)uParam);
  1510. #endif
  1511. break;
  1512. //任命队长
  1513. //uParam = uNewLeaderId -> 新队长的id
  1514. case GOI_TEAM_APPOINT:
  1515. #ifndef _SERVER
  1516. Player[CLIENT_PLAYER_INDEX].ApplyTeamChangeCaptain(((KUiPlayerItem*)uParam)->uId);
  1517. #endif
  1518. break;
  1519. //邀请别人加入队伍
  1520. case GOI_TEAM_INVITE:
  1521. #ifndef _SERVER
  1522. if (uParam)
  1523. {
  1524. Player[CLIENT_PLAYER_INDEX].TeamInviteAdd(((KUiPlayerItem*)uParam)->uId);
  1525. KSystemMessage sMsg;
  1526. sprintf(sMsg.szMessage, MSG_TEAM_SEND_INVITE, ((KUiPlayerItem*)uParam)->Name);
  1527. sMsg.eType = SMT_NORMAL;
  1528. sMsg.byConfirmType = SMCT_NONE;
  1529. sMsg.byPriority = 0;
  1530. sMsg.byParamSize = 0;
  1531. CoreDataChanged(GDCNI_SYSTEM_MESSAGE, (unsigned int)&sMsg, 0);
  1532. }
  1533. #endif
  1534. break;
  1535. //踢除队里的一个队员
  1536. //uParam = uMemberId -> 要踢除的队员的id
  1537. case GOI_TEAM_KICK:
  1538. #ifndef _SERVER
  1539. Player[CLIENT_PLAYER_INDEX].TeamKickMember(((KUiPlayerItem*)uParam)->uId);
  1540. #endif
  1541. break;
  1542. //批准他人加入队伍
  1543. //uParam = uPlayerId -> 欲批准的人的id
  1544. case GOI_TEAM_APPROVE:
  1545. #ifndef _SERVER
  1546. if (uParam)
  1547. {
  1548. if (nParam)
  1549. {
  1550. Player[CLIENT_PLAYER_INDEX].AcceptTeamMember(((KUiPlayerItem*)uParam)->uId);
  1551. }
  1552. else
  1553. {
  1554. Player[CLIENT_PLAYER_INDEX].m_cTeam.DeleteOneFromApplyList(((KUiPlayerItem*)uParam)->uId);
  1555. Player[CLIENT_PLAYER_INDEX].m_cTeam.UpdateInterface();
  1556. }
  1557. }
  1558. #endif
  1559. break;
  1560. //离开队伍
  1561. #ifndef _SERVER
  1562. case GOI_TEAM_LEAVE:
  1563. Player[CLIENT_PLAYER_INDEX].LeaveTeam();
  1564. break;
  1565. // 队伍开放、关闭
  1566. case GOI_TEAM_CLOSE:
  1567. if (nParam)
  1568. {
  1569. Player[CLIENT_PLAYER_INDEX].ApplyTeamOpenClose(TRUE);
  1570. }
  1571. else
  1572. Player[CLIENT_PLAYER_INDEX].ApplyTeamOpenClose(FALSE);
  1573. break;
  1574. //对组队邀请的回复
  1575. //uParam = (KUiPlayerItem*)pTeamLeader 发出组队邀请的队长
  1576. //nParam = (int)(bool)bAccept 是否接受邀请
  1577. case GOI_TEAM_INVITE_RESPONSE:
  1578. if (uParam)
  1579. {
  1580. KUiPlayerItem *pTeamLeader = (KUiPlayerItem*)uParam;
  1581. if (nParam)
  1582. {
  1583. Player[CLIENT_PLAYER_INDEX].m_cTeam.ReplyInvite(pTeamLeader->nIndex, 1);
  1584. }
  1585. else
  1586. {
  1587. Player[CLIENT_PLAYER_INDEX].m_cTeam.ReplyInvite(pTeamLeader->nIndex, 0);
  1588. }
  1589. }
  1590. break;
  1591. //答应/拒绝交易请求
  1592. //uParam = (KUiPlayerItem*)pRequestPlayer 发出请求的玩家
  1593. //nParam = (int)(bool)bAccept 是否接受请求
  1594. case GOI_TRADE_INVITE_RESPONSE:
  1595. if (uParam)
  1596. {
  1597. KTrade::ReplyInvite(((KUiPlayerItem*)uParam)->nIndex, nParam);
  1598. }
  1599. break;
  1600. //增减一个欲卖出的物品
  1601. //uParam = (KUiObjAtRegion*) pObject -> 物品信息,其中坐标信息为在交易界面中的坐标
  1602. //nParam = bAdd -> 0值表示减少,1值表示增加
  1603. //Remark : 如果物品是金钱的话,则KUiObjAtRegion::Obj::uId表示把金钱额调整为这个值,且nParam无意义。
  1604. case GOI_TRADE_DESIRE_ITEM:
  1605. if (uParam)
  1606. {
  1607. KUiObjAtRegion* pInfo = (KUiObjAtRegion*) uParam;
  1608. if (pInfo->Obj.uGenre != CGOG_MONEY)
  1609. break;
  1610. Player[CLIENT_PLAYER_INDEX].TradeMoveMoney(pInfo->Obj.uId);
  1611. }
  1612. break;
  1613. //有无交易意向
  1614. //nParam = bWilling
  1615. case GOI_TRADE_WILLING:
  1616. if (Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].GetMenuState() == PLAYER_MENU_STATE_TRADEOPEN)
  1617. {
  1618. Player[CLIENT_PLAYER_INDEX].TradeApplyClose();
  1619. }
  1620. else
  1621. {
  1622. Player[CLIENT_PLAYER_INDEX].TradeApplyOpen((char*)uParam, nParam);
  1623. }
  1624. break;
  1625. //锁定交易
  1626. //nParam = (int)(book)bLock 是否锁定
  1627. case GOI_TRADE_LOCK:
  1628. if ( !Player[CLIENT_PLAYER_INDEX].CheckTrading() )
  1629. break;
  1630. if (Player[CLIENT_PLAYER_INDEX].m_cTrade.m_nTradeLock)
  1631. Player[CLIENT_PLAYER_INDEX].TradeApplyLock(0);
  1632. else
  1633. Player[CLIENT_PLAYER_INDEX].TradeApplyLock(1);
  1634. break;
  1635. //交易
  1636. case GOI_TRADE:
  1637. if ( !Player[CLIENT_PLAYER_INDEX].CheckTrading() )
  1638. break;
  1639. if (Player[CLIENT_PLAYER_INDEX].m_cTrade.m_nTradeLock != 1 || Player[CLIENT_PLAYER_INDEX].m_cTrade.m_nTradeDestLock != 1)
  1640. break;
  1641. if (Player[CLIENT_PLAYER_INDEX].m_cTrade.m_nTradeState == 0)
  1642. {
  1643. Player[CLIENT_PLAYER_INDEX].TradeDecision(1); // 交易确定
  1644. }
  1645. else
  1646. {
  1647. Player[CLIENT_PLAYER_INDEX].TradeDecision(2); // 交易确定取消
  1648. }
  1649. break;
  1650. //交易取消
  1651. case GOI_TRADE_CANCEL:
  1652. if ( !Player[CLIENT_PLAYER_INDEX].CheckTrading() )
  1653. break;
  1654. Player[CLIENT_PLAYER_INDEX].TradeDecision(0); // 交易取消
  1655. break;
  1656. //查询是否可以丢某个东西到游戏窗口
  1657. //uParam = (KUiGameObject*)pObject -> 物品信息
  1658. //nParam = 被拖动东西的当前坐标(绝对坐标),横坐标在低16位,纵坐标在高16位。(像素点坐标)
  1659. //Return = 是否可以放下
  1660. case GOI_DROP_ITEM_QUERY:
  1661. //to do : waiting for...
  1662. break;
  1663. case GOI_SEND_MSG:
  1664. if (uParam && nParam)
  1665. Player[CLIENT_PLAYER_INDEX].SendChat((KUiMsgParam*)nParam, (char*)uParam);
  1666. break;
  1667. case GOI_SET_SEND_CHAT_CHANNEL: //设置当前发送消息的频道
  1668. if (uParam)
  1669. {
  1670. KUiChatChannel* pChannelInfo = (KUiChatChannel*)uParam;// pChannelInfo 要设置的频道的信息
  1671. Player[CLIENT_PLAYER_INDEX].m_cChat.SetCurChannel(pChannelInfo->nChannelNo, pChannelInfo->uChannelId, pChannelInfo->nChannelIndex);
  1672. }
  1673. break;
  1674. // 设置当前发送消息的频道为与某人单聊
  1675. //uParam = (KUiPlayerItem*) pFriend
  1676. case GOI_SET_SEND_WHISPER_CHANNEL:
  1677. if (uParam)
  1678. {
  1679. if (((KUiPlayerItem*)uParam)->nIndex)
  1680. {
  1681. int nIdx = NpcSet.SearchName(((KUiPlayerItem*)uParam)->Name);
  1682. if (nIdx > 0)
  1683. {
  1684. Player[CLIENT_PLAYER_INDEX].m_cChat.SetCurChannel(CHAT_CUR_CHANNEL_SCREENSINGLE, Npc[nIdx].m_dwID, 0);
  1685. }
  1686. else
  1687. {
  1688. KSystemMessage sMsg;
  1689. sprintf(sMsg.szMessage, MSG_CHAT_FRIEND_NOT_NEAR, ((KUiPlayerItem*)uParam)->Name);
  1690. sMsg.eType = SMT_NORMAL;
  1691. sMsg.byConfirmType = SMCT_NONE;
  1692. sMsg.byPriority = 0;
  1693. sMsg.byParamSize = 0;
  1694. CoreDataChanged(GDCNI_SYSTEM_MESSAGE, (unsigned int)&sMsg, 0);
  1695. }
  1696. }
  1697. else
  1698. {
  1699. KSystemMessage sMsg;
  1700. sprintf(sMsg.szMessage, MSG_CHAT_FRIEND_NOT_ONLINE, ((KUiPlayerItem*)uParam)->Name);
  1701. sMsg.eType = SMT_NORMAL;
  1702. sMsg.byConfirmType = SMCT_NONE;
  1703. sMsg.byPriority = 0;
  1704. sMsg.byParamSize = 0;
  1705. CoreDataChanged(GDCNI_SYSTEM_MESSAGE, (unsigned int)&sMsg, 0);
  1706. }
  1707. }
  1708. break;
  1709. case GOI_SET_RECEIVE_CHAT_CHANNEL://设置订阅/取消消息频道
  1710. if (uParam)
  1711. {
  1712. //uParam = (KUiChatChannel*) pChannelInfo 要设置的频道的信息
  1713. //nParam = (int)(bool) bEnable 是否订阅
  1714. KUiChatChannel* pChannelInfo = (KUiChatChannel*)uParam;// pChannelInfo 要设置的频道的信息
  1715. if (nParam)
  1716. {
  1717. Player[CLIENT_PLAYER_INDEX].m_cChat.AddChannel(pChannelInfo->nChannelNo);
  1718. }
  1719. else
  1720. {
  1721. Player[CLIENT_PLAYER_INDEX].m_cChat.SubChannel(pChannelInfo->nChannelNo);
  1722. }
  1723. }
  1724. break;
  1725. //新建聊天好友组
  1726. //uParam = (const char*) pGroupName
  1727. //Return = (int)(bool) bSuccessed
  1728. case GOI_CHAT_GROUP_NEW:
  1729. Player[CLIENT_PLAYER_INDEX].m_cChat.AddTeam(Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].Name, (char*)uParam);
  1730. CoreDataChanged(GDCNI_CHAT_GROUP, 0, 0);
  1731. break;
  1732. //重命名聊天好友组
  1733. //uParam = (const char*) pGroupName
  1734. //nParam = nIndex 组索引
  1735. //Return = (int)(bool) bSuccessed
  1736. case GOI_CHAT_GROUP_RENAME:
  1737. Player[CLIENT_PLAYER_INDEX].m_cChat.RenameTeam(nParam, (char*)uParam, Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].Name);
  1738. CoreDataChanged(GDCNI_CHAT_GROUP, 0, 0);
  1739. break;
  1740. //删除聊天好友组
  1741. //nParam = nIndex 组索引
  1742. //Return = (int)(bool) bSuccessed
  1743. case GOI_CHAT_GROUP_DELETE:
  1744. Player[CLIENT_PLAYER_INDEX].m_cChat.DeleteTeam(nParam, Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].Name);
  1745. CoreDataChanged(GDCNI_CHAT_GROUP, 0, 0);
  1746. break;
  1747. //新添加聊天好友
  1748. //uParam = (KUiPlayerItem*)pFriend
  1749. // KUiPlayerItem::nData = 0
  1750. case GOI_CHAT_FRIEND_ADD:
  1751. {
  1752. Player[CLIENT_PLAYER_INDEX].m_cChat.ApplyAddFriend(((KUiPlayerItem*)uParam)->uId);
  1753. KSystemMessage sMsg;
  1754. sprintf(sMsg.szMessage, MSG_CHAT_APPLY_ADD_FRIEND, ((KUiPlayerItem*)uParam)->Name);
  1755. sMsg.eType = SMT_NORMAL;
  1756. sMsg.byConfirmType = SMCT_NONE;
  1757. sMsg.byPriority = 0;
  1758. sMsg.byParamSize = 0;
  1759. CoreDataChanged(GDCNI_SYSTEM_MESSAGE, (unsigned int)&sMsg, 0);
  1760. }
  1761. break;
  1762. //删除聊天好友
  1763. //uParam = (KUiPlayerItem*)pFriend
  1764. // KUiPlayerItem::nData = 0
  1765. //nParam = nGroupIndex 好友所在的组的索引
  1766. //Return = (int)(bool) bSuccessed
  1767. case GOI_CHAT_FRIEND_DELETE:
  1768. {
  1769. Player[CLIENT_PLAYER_INDEX].m_cChat.ApplyDeleteFriend(((KUiPlayerItem*)uParam)->uId, nParam, Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].Name);
  1770. KSystemMessage sMsg;
  1771. sprintf(sMsg.szMessage, MSG_CHAT_DELETE_FRIEND, ((KUiPlayerItem*)uParam)->Name);
  1772. sMsg.eType = SMT_NORMAL;
  1773. sMsg.byConfirmType = SMCT_NONE;
  1774. sMsg.byPriority = 0;
  1775. sMsg.byParamSize = 0;
  1776. CoreDataChanged(GDCNI_SYSTEM_MESSAGE, (unsigned int)&sMsg, 0);
  1777. }
  1778. break;
  1779. //好友移到新组
  1780. //uParam = (KUiPlayerItem*)pFriend
  1781. // KUiPlayerItem::nData = 0
  1782. //nParam = nGroupIndex 好友所到的新组的索引
  1783. case GOI_CHAT_FRIEND_MOVE:
  1784. {
  1785. KUiPlayerItem *pPlayer = (KUiPlayerItem*)uParam;
  1786. int nSrcTeamNo = Player[CLIENT_PLAYER_INDEX].m_cChat.GetTeamNo(pPlayer->uId);
  1787. if (nSrcTeamNo == -1)
  1788. {
  1789. // 失败,如果需要发消息,在此
  1790. break;
  1791. }
  1792. if (Player[CLIENT_PLAYER_INDEX].m_cChat.OneFriendChangeTeam(pPlayer->uId, nSrcTeamNo, nParam))
  1793. { // 成功
  1794. CoreDataChanged(GDCNI_CHAT_GROUP, 0, 0);
  1795. }
  1796. else
  1797. {
  1798. // 失败,如果需要发消息,在此
  1799. }
  1800. }
  1801. break;
  1802. //发给好友一条讯息
  1803. //uParam = (KUiChatMessage*)pMessage 消息数据
  1804. //nParam = (KUiPlayerItem*)pFriend   发来讯息的好友
  1805. case GOI_CHAT_WORDS_TO_FRIEND:
  1806. {
  1807. char szSentence[MAX_SENTENCE_LENGTH];
  1808. KUiChatMessage *pMsg = (KUiChatMessage*)uParam;
  1809. KUiMsgParam sMsg;
  1810. sMsg.eGenre = MSG_G_CHAT;
  1811. sMsg.szName[0] = 0;
  1812. memset(sMsg.cChatPrefix, 0, sizeof(sMsg.cChatPrefix));
  1813. sMsg.cChatPrefixLen = sizeof(unsigned int);
  1814. sMsg.cChatPrefix[0] = ((char*)(&pMsg->uColor))[3];
  1815. sMsg.cChatPrefix[1] = ((char*)(&pMsg->uColor))[2];
  1816. sMsg.cChatPrefix[2] = ((char*)(&pMsg->uColor))[1];
  1817. sMsg.cChatPrefix[3] = ((char*)(&pMsg->uColor))[0];
  1818. if (pMsg->nContentLen >= MAX_SENTENCE_LENGTH)
  1819. {
  1820. memcpy(szSentence, pMsg->szContent, MAX_SENTENCE_LENGTH - 1);
  1821. szSentence[MAX_SENTENCE_LENGTH - 1] = 0;
  1822. sMsg.nMsgLength = MAX_SENTENCE_LENGTH - 1;
  1823. }
  1824. else
  1825. {
  1826. memcpy(szSentence, pMsg->szContent, pMsg->nContentLen);
  1827. szSentence[pMsg->nContentLen] = 0;
  1828. sMsg.nMsgLength = pMsg->nContentLen;
  1829. }
  1830. Player[CLIENT_PLAYER_INDEX].m_cChat.QQSendSentence(
  1831. ((KUiPlayerItem*)nParam)->uId,
  1832. ((KUiPlayerItem*)nParam)->nIndex, &sMsg, szSentence);
  1833. }
  1834. break;
  1835. //对别人要加自己为好友的回复
  1836. //uParam = (KUiPlayerItem*)pRequestPlayer 发出请求的玩家
  1837. //nParam = (int)(bool)bAccept 是否接受请求
  1838. case GOI_CHAT_FRIEND_INVITE:
  1839. if (uParam)
  1840. {
  1841. if (nParam)
  1842. {
  1843. Player[CLIENT_PLAYER_INDEX].ChatAddFriend(((KUiPlayerItem*)uParam)->nIndex);
  1844. }
  1845. else
  1846. {
  1847. Player[CLIENT_PLAYER_INDEX].ChatRefuseFriend(((KUiPlayerItem*)uParam)->nIndex);
  1848. }
  1849. }
  1850. break;
  1851. case GOI_OPTION_SETTING: //选项设置
  1852. if (uParam == OPTION_DYNALIGHT)
  1853. {
  1854. g_ScenePlace.EnableDynamicLights(nParam != 0);
  1855. if (g_pRepresent)
  1856. g_pRepresent->SetOption(DYNAMICLIGHT, nParam != 0);
  1857. }
  1858. else if (uParam == OPTION_PERSPECTIVE)
  1859. {
  1860. if (g_pRepresent)
  1861. g_pRepresent->SetOption(PERSPECTIVE, nParam != 0);
  1862. }
  1863. else if (uParam == OPTION_MUSIC_VALUE)
  1864. Option.SetMusicVolume(nParam);
  1865. else if (uParam == OPTION_SOUND_VALUE)
  1866. Option.SetSndVolume(nParam);
  1867. else if (uParam == OPTION_BRIGHTNESS)
  1868. Option.SetGamma(nParam);
  1869. break;
  1870. case GOI_PLAYER_ACTION:
  1871. {
  1872. switch(uParam)
  1873. {
  1874. case PA_RUN:
  1875. Player[CLIENT_PLAYER_INDEX].m_RunStatus = !Player[CLIENT_PLAYER_INDEX].m_RunStatus;
  1876. break;
  1877. case PA_SIT:
  1878. if (!Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_bRideHorse)
  1879. {
  1880. if (Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].m_Doing != do_sit)
  1881. Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].SendCommand(do_sit);
  1882. else
  1883. Npc[Player[CLIENT_PLAYER_INDEX].m_nIndex].SendCommand(do_stand);
  1884. SendClientCmdSit();
  1885. }
  1886. else
  1887. {
  1888. KSystemMessage Msg;
  1889. Msg.byConfirmType = SMCT_CLICK;
  1890. Msg.eType = SMT_PLAYER;
  1891. Msg.byPriority = 1;
  1892. Msg.byParamSize = 0;
  1893. strcpy(Msg.szMessage, "骑马时无法打坐!");
  1894. CoreDataChanged(GDCNI_SYSTEM_MESSAGE, (unsigned int)&Msg, 0);
  1895. }
  1896. break;
  1897. }
  1898. }
  1899. break;
  1900. case GOI_IS_SCENE_MAP_SHOWING:
  1901. g_ScenePlace.SetMapParam(uParam, nParam);
  1902. break;
  1903. case GOI_PAINT_SCENE_MAP:
  1904. if (uParam)
  1905. {
  1906. nRet = g_ScenePlace.PaintMap(((KUiRegion*)uParam)->h,
  1907. ((KUiRegion*)uParam)->v, (KUiRegion*)nParam);
  1908. }
  1909. break;
  1910. #endif
  1911. default:
  1912. nRet = 0;
  1913. break;
  1914. }
  1915. return nRet;
  1916. }
  1917. //--------------------------------------------------------------------------
  1918. // 功能:发送输入设备的输入操作消息
  1919. //--------------------------------------------------------------------------
  1920. void KCoreShell::ProcessInput(unsigned int uMsg, unsigned int uParam, int nParam)
  1921. {
  1922. #ifndef _SERVER
  1923. Player[CLIENT_PLAYER_INDEX].ProcessInputMsg(uMsg, uParam, nParam);
  1924. #endif
  1925. }
  1926. int KCoreShell::FindSelectPlayer(int x, int y, void* pReturn)
  1927. {
  1928. #ifndef _SERVER
  1929. Player[CLIENT_PLAYER_INDEX].FindSelectNpc(x, y, relation_none | relation_ally | relation_enemy);
  1930. int nT = Player[CLIENT_PLAYER_INDEX].GetTargetNpc();
  1931. if (nT > 0 &&
  1932. Npc[nT].m_Kind == kind_player)
  1933. {
  1934. if (pReturn)
  1935. {
  1936. KUiPlayerItem* p = (KUiPlayerItem*)pReturn;
  1937. strncpy(p->Name, Npc[nT].Name, 32);
  1938. p->nIndex = Npc[nT].m_Index;
  1939. p->uId = Npc[nT].m_dwID;
  1940. }
  1941. return true;
  1942. }
  1943. #endif
  1944. return false;
  1945. }
  1946. int KCoreShell::FindSpecialPlayer(char* Name, void* pReturn)
  1947. {
  1948. if (Name == NULL || Name[0] == 0)
  1949. return false;
  1950. for (int nT = 0; nT < MAX_NPC; nT++)
  1951. {
  1952. if (Npc[nT].m_Kind == kind_player &&
  1953. strcmp(Npc[nT].Name, Name) == 0)
  1954. {
  1955. if (pReturn)
  1956. {
  1957. KUiPlayerItem* p = (KUiPlayerItem*)pReturn;
  1958. strncpy(p->Name, Npc[nT].Name, 32);
  1959. p->nIndex = Npc[nT].m_Index;
  1960. p->uId = Npc[nT].m_dwID;
  1961. }
  1962. return true;
  1963. }
  1964. }
  1965. return false;
  1966. }
  1967. int KCoreShell::ChatSpecialPlayer(void* pPlayer, const char* pMsgBuff, unsigned short nMsgLength)
  1968. {
  1969. KUiPlayerItem* p = (KUiPlayerItem*)pPlayer;
  1970. if (p)
  1971. {
  1972. if (p->nIndex >= 0 && p->nIndex < MAX_NPC)
  1973. {
  1974. int nTalker = p->nIndex;
  1975. if (Npc[nTalker].m_Kind == kind_player &&
  1976. Npc[nTalker].m_dwID == p->uId)
  1977. {
  1978. memset(Npc[nTalker].m_szChatBuffer, 0, sizeof(Npc[nTalker].m_szChatBuffer));
  1979. memcpy(Npc[nTalker].m_szChatBuffer, pMsgBuff, nMsgLength);
  1980. Npc[nTalker].m_nCurChatTime = NPC_SHOW_CHAT_TIME_LENGTH;
  1981. return true;
  1982. }
  1983. }
  1984. }
  1985. return false;
  1986. }
  1987. //--------------------------------------------------------------------------
  1988. // 功能:绘制游戏对象
  1989. //--------------------------------------------------------------------------
  1990. void KCoreShell::DrawGameObj(unsigned int uObjGenre, unsigned int uId, int x, int y, int Width, int Height, int nParam)
  1991. {
  1992. #ifndef _SERVER
  1993. if (g_pRepresent)
  1994. CoreDrawGameObj(uObjGenre, uId, x, y, Width, Height, nParam);
  1995. #endif
  1996. }
  1997. #ifndef _SERVER
  1998. #include "../../Represent/iRepresent/iRepresentshell.h"
  1999. #endif
  2000. //--------------------------------------------------------------------------
  2001. // 功能:绘制游戏世界
  2002. //--------------------------------------------------------------------------
  2003. void KCoreShell::DrawGameSpace()
  2004. {
  2005. #ifndef _SERVER
  2006. if (g_pRepresent)
  2007. {
  2008. g_ScenePlace.Paint();
  2009. Player[CLIENT_PLAYER_INDEX].DrawSelectInfo();
  2010. }
  2011. #endif
  2012. }
  2013. //--------------------------------------------------------------------------
  2014. // 功能:设置绘图接口实例的指针
  2015. //--------------------------------------------------------------------------
  2016. void KCoreShell::SetRepresentShell(struct iRepresentShell* pRepresent)
  2017. {
  2018. #ifndef _SERVER
  2019. g_pRepresent = pRepresent;
  2020. g_ScenePlace.RepresentShellReset();
  2021. #endif
  2022. }
  2023. void KCoreShell::SetMusicInterface(void* pMusicInterface)
  2024. {
  2025. #ifndef _SERVER
  2026. g_pMusic = (KMusic*)pMusicInterface;
  2027. #endif
  2028. }
  2029. //日常活动,core如果要寿终正寝则返回0,否则返回非0值
  2030. int KCoreShell::Breathe()
  2031. {
  2032. g_SubWorldSet.MessageLoop();
  2033. g_SubWorldSet.MainLoop();
  2034. #ifndef _SERVER
  2035. g_ScenePlace.Breathe();
  2036. #endif
  2037. return true;
  2038. }
  2039. int KCoreShell::GetProtocolSize(BYTE byProtocol)
  2040. {
  2041. if (byProtocol <= s2c_clientbegin || byProtocol >= s2c_end)
  2042. return -1;
  2043. return g_nProtocolSize[byProtocol - s2c_clientbegin - 1];
  2044. }
  2045. #ifdef SWORDONLINE_SHOW_DBUG_INFO
  2046. extern int g_bShowObstacle;
  2047. extern bool g_bShowGameInfo; //是否显示游戏(场景)信息
  2048. #endif
  2049. int KCoreShell::Debug(unsigned int uDataId, unsigned int uParam, int nParam)
  2050. {
  2051. #ifdef SWORDONLINE_SHOW_DBUG_INFO
  2052. switch(uDataId)
  2053. {
  2054. case DEBUG_SHOWINFO:
  2055. Player[CLIENT_PLAYER_INDEX].m_DebugMode = !Player[CLIENT_PLAYER_INDEX].m_DebugMode;
  2056. g_bShowGameInfo = !g_bShowGameInfo;
  2057. break;
  2058. case DEBUG_SHOWOBSTACLE:
  2059. g_bShowObstacle = !g_bShowObstacle;
  2060. break;
  2061. }
  2062. #endif
  2063. return 0;
  2064. }
  2065. DWORD KCoreShell::GetPing()
  2066. {
  2067. #ifndef _SERVER
  2068. return g_SubWorldSet.GetPing();
  2069. #else
  2070. return 0;
  2071. #endif
  2072. }
  2073. void KCoreShell::SendPing()
  2074. {
  2075. #ifndef _SERVER
  2076. SendClientCmdPing();
  2077. #endif
  2078. }
  2079. void KCoreShell::SetRepresentAreaSize(int nWidth, int nHeight)
  2080. {
  2081. #ifndef _SERVER
  2082. g_ScenePlace.SetRepresentAreaSize(nWidth, nHeight);
  2083. #endif
  2084. }
  2085. void KCoreShell::SetClient(LPVOID pClient)
  2086. {
  2087. #ifndef _SERVER
  2088. g_SetClient(pClient);
  2089. #endif
  2090. }
  2091. void KCoreShell::SendNewDataToServer(void* pData, int nLength)
  2092. {
  2093. #ifndef _SERVER
  2094. if (g_pClient)
  2095. g_pClient->SendPackToServer(pData, nLength);
  2096. #endif
  2097. }