intif.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133
  1. // $Id: intif.c,v 1.2 2004/09/25 05:32:18 MouseJstr Exp $
  2. #include <sys/types.h>
  3. #ifdef _WIN32
  4. #include <winsock.h>
  5. #else
  6. #include <sys/socket.h>
  7. #include <netinet/in.h>
  8. #endif
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #ifndef _WIN32
  12. #include <sys/time.h>
  13. #include <sys/ioctl.h>
  14. #include <unistd.h>
  15. #include <arpa/inet.h>
  16. #endif
  17. #include <signal.h>
  18. #include <fcntl.h>
  19. #include <string.h>
  20. #include "socket.h"
  21. #include "timer.h"
  22. #include "map.h"
  23. #include "battle.h"
  24. #include "chrif.h"
  25. #include "clif.h"
  26. #include "pc.h"
  27. #include "intif.h"
  28. #include "storage.h"
  29. #include "party.h"
  30. #include "guild.h"
  31. #include "pet.h"
  32. #include "nullpo.h"
  33. #ifdef MEMWATCH
  34. #include "memwatch.h"
  35. #endif
  36. static const int packet_len_table[]={
  37. -1,-1,27,-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  38. -1, 7, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0,
  39. 35,-1,11,15, 34,29, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0,
  40. 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1,
  41. 9, 9,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  42. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  43. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  44. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  45. 11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  46. };
  47. extern int char_fd; // inter serverのfdはchar_fdを使う
  48. #define inter_fd (char_fd) // エイリアス
  49. //-----------------------------------------------------------------
  50. // inter serverへの送信
  51. int CheckForCharServer() {
  52. return ((char_fd == -1) || session[char_fd] == NULL || session[char_fd]->wdata == NULL);
  53. }
  54. // pet
  55. int intif_create_pet(int account_id,int char_id,short pet_class,short pet_lv,short pet_egg_id,
  56. short pet_equip,short intimate,short hungry,char rename_flag,char incuvate,char *pet_name)
  57. {
  58. if (CheckForCharServer())
  59. return 0;
  60. WFIFOW(inter_fd,0) = 0x3080;
  61. WFIFOL(inter_fd,2) = account_id;
  62. WFIFOL(inter_fd,6) = char_id;
  63. WFIFOW(inter_fd,10) = pet_class;
  64. WFIFOW(inter_fd,12) = pet_lv;
  65. WFIFOW(inter_fd,14) = pet_egg_id;
  66. WFIFOW(inter_fd,16) = pet_equip;
  67. WFIFOW(inter_fd,18) = intimate;
  68. WFIFOW(inter_fd,20) = hungry;
  69. WFIFOB(inter_fd,22) = rename_flag;
  70. WFIFOB(inter_fd,23) = incuvate;
  71. memcpy(WFIFOP(inter_fd,24),pet_name,24);
  72. WFIFOSET(inter_fd,48);
  73. return 0;
  74. }
  75. int intif_request_petdata(int account_id,int char_id,int pet_id)
  76. {
  77. if (CheckForCharServer())
  78. return 0;
  79. WFIFOW(inter_fd,0) = 0x3081;
  80. WFIFOL(inter_fd,2) = account_id;
  81. WFIFOL(inter_fd,6) = char_id;
  82. WFIFOL(inter_fd,10) = pet_id;
  83. WFIFOSET(inter_fd,14);
  84. return 0;
  85. }
  86. int intif_save_petdata(int account_id,struct s_pet *p)
  87. {
  88. if (CheckForCharServer())
  89. return 0;
  90. WFIFOW(inter_fd,0) = 0x3082;
  91. WFIFOW(inter_fd,2) = sizeof(struct s_pet) + 8;
  92. WFIFOL(inter_fd,4) = account_id;
  93. memcpy(WFIFOP(inter_fd,8),p,sizeof(struct s_pet));
  94. WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
  95. return 0;
  96. }
  97. int intif_delete_petdata(int pet_id)
  98. {
  99. if (CheckForCharServer())
  100. return 0;
  101. WFIFOW(inter_fd,0) = 0x3083;
  102. WFIFOL(inter_fd,2) = pet_id;
  103. WFIFOSET(inter_fd,6);
  104. return 0;
  105. }
  106. // GMメッセージを送信
  107. int intif_GMmessage(char* mes,int len,int flag)
  108. {
  109. int lp = (flag&0x10) ? 8 : 4;
  110. if (CheckForCharServer())
  111. return 0;
  112. WFIFOW(inter_fd,0) = 0x3000;
  113. WFIFOW(inter_fd,2) = lp + len;
  114. WFIFOL(inter_fd,4) = 0x65756c62;
  115. memcpy(WFIFOP(inter_fd,lp), mes, len);
  116. WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
  117. return 0;
  118. }
  119. // The transmission of Wisp/Page to inter-server (player not found on this server)
  120. int intif_wis_message(struct map_session_data *sd, char *nick, char *mes, int mes_len) {
  121. nullpo_retr(0, sd);
  122. if (CheckForCharServer())
  123. return 0;
  124. WFIFOW(inter_fd,0) = 0x3001;
  125. WFIFOW(inter_fd,2) = mes_len + 52;
  126. memcpy(WFIFOP(inter_fd,4), sd->status.name, 24);
  127. memcpy(WFIFOP(inter_fd,28), nick, 24);
  128. memcpy(WFIFOP(inter_fd,52), mes, mes_len);
  129. WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
  130. if (battle_config.etc_log)
  131. printf("intif_wis_message from %s to %s (message: '%s')\n", sd->status.name, nick, mes);
  132. return 0;
  133. }
  134. // The reply of Wisp/page
  135. int intif_wis_replay(int id, int flag) {
  136. if (CheckForCharServer())
  137. return 0;
  138. WFIFOW(inter_fd,0) = 0x3002;
  139. WFIFOL(inter_fd,2) = id;
  140. WFIFOB(inter_fd,6) = flag; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
  141. WFIFOSET(inter_fd,7);
  142. if (battle_config.etc_log)
  143. printf("intif_wis_replay: id: %d, flag:%d\n", id, flag);
  144. return 0;
  145. }
  146. // The transmission of GM only Wisp/Page from server to inter-server
  147. int intif_wis_message_to_gm(char *Wisp_name, int min_gm_level, char *mes, int mes_len) {
  148. if (CheckForCharServer())
  149. return 0;
  150. WFIFOW(inter_fd,0) = 0x3003;
  151. WFIFOW(inter_fd,2) = mes_len + 30;
  152. memcpy(WFIFOP(inter_fd,4), Wisp_name, 24);
  153. WFIFOW(inter_fd,28) = (short)min_gm_level;
  154. memcpy(WFIFOP(inter_fd,30), mes, mes_len);
  155. WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
  156. if (battle_config.etc_log)
  157. printf("intif_wis_message_to_gm: from: '%s', min level: %d, message: '%s'.\n", Wisp_name, min_gm_level, mes);
  158. return 0;
  159. }
  160. // アカウント変数送信
  161. int intif_saveaccountreg(struct map_session_data *sd) {
  162. int j,p;
  163. if (CheckForCharServer())
  164. return 0;
  165. nullpo_retr(0, sd);
  166. WFIFOW(inter_fd,0) = 0x3004;
  167. WFIFOL(inter_fd,4) = sd->bl.id;
  168. for(j=0,p=8;j<sd->status.account_reg_num;j++,p+=36){
  169. memcpy(WFIFOP(inter_fd,p),sd->status.account_reg[j].str,32);
  170. WFIFOL(inter_fd,p+32)=sd->status.account_reg[j].value;
  171. }
  172. WFIFOW(inter_fd,2)=p;
  173. WFIFOSET(inter_fd,p);
  174. return 0;
  175. }
  176. // アカウント変数要求
  177. int intif_request_accountreg(struct map_session_data *sd)
  178. {
  179. nullpo_retr(0, sd);
  180. if (CheckForCharServer())
  181. return 0;
  182. WFIFOW(inter_fd,0) = 0x3005;
  183. WFIFOL(inter_fd,2) = sd->bl.id;
  184. WFIFOSET(inter_fd,6);
  185. return 0;
  186. }
  187. // 倉庫データ要求
  188. int intif_request_storage(int account_id)
  189. {
  190. if (CheckForCharServer())
  191. return 0;
  192. WFIFOW(inter_fd,0) = 0x3010;
  193. WFIFOL(inter_fd,2) = account_id;
  194. WFIFOSET(inter_fd,6);
  195. return 0;
  196. }
  197. // 倉庫データ送信
  198. int intif_send_storage(struct storage *stor)
  199. {
  200. if (CheckForCharServer())
  201. return 0;
  202. nullpo_retr(0, stor);
  203. WFIFOW(inter_fd,0) = 0x3011;
  204. WFIFOW(inter_fd,2) = sizeof(struct storage)+8;
  205. WFIFOL(inter_fd,4) = stor->account_id;
  206. memcpy( WFIFOP(inter_fd,8),stor, sizeof(struct storage) );
  207. WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
  208. return 0;
  209. }
  210. int intif_request_guild_storage(int account_id,int guild_id)
  211. {
  212. if (CheckForCharServer())
  213. return 0;
  214. WFIFOW(inter_fd,0) = 0x3018;
  215. WFIFOL(inter_fd,2) = account_id;
  216. WFIFOL(inter_fd,6) = guild_id;
  217. WFIFOSET(inter_fd,10);
  218. return 0;
  219. }
  220. int intif_send_guild_storage(int account_id,struct guild_storage *gstor)
  221. {
  222. if (CheckForCharServer())
  223. return 0;
  224. WFIFOW(inter_fd,0) = 0x3019;
  225. WFIFOW(inter_fd,2) = sizeof(struct guild_storage)+12;
  226. WFIFOL(inter_fd,4) = account_id;
  227. WFIFOL(inter_fd,8) = gstor->guild_id;
  228. memcpy( WFIFOP(inter_fd,12),gstor, sizeof(struct guild_storage) );
  229. WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
  230. return 0;
  231. }
  232. // パーティ作成要求
  233. int intif_create_party(struct map_session_data *sd,char *name)
  234. {
  235. if (CheckForCharServer())
  236. return 0;
  237. nullpo_retr(0, sd);
  238. WFIFOW(inter_fd,0) = 0x3020;
  239. WFIFOL(inter_fd,2) = sd->status.account_id;
  240. memcpy(WFIFOP(inter_fd, 6),name,24);
  241. memcpy(WFIFOP(inter_fd,30),sd->status.name,24);
  242. memcpy(WFIFOP(inter_fd,54),map[sd->bl.m].name,16);
  243. WFIFOW(inter_fd,70)= sd->status.base_level;
  244. WFIFOSET(inter_fd,72);
  245. // if(battle_config.etc_log)
  246. // printf("intif: create party\n");
  247. return 0;
  248. }
  249. // パーティ情報要求
  250. int intif_request_partyinfo(int party_id)
  251. {
  252. if (CheckForCharServer())
  253. return 0;
  254. WFIFOW(inter_fd,0) = 0x3021;
  255. WFIFOL(inter_fd,2) = party_id;
  256. WFIFOSET(inter_fd,6);
  257. // if(battle_config.etc_log)
  258. // printf("intif: request party info\n");
  259. return 0;
  260. }
  261. // パーティ追加要求
  262. int intif_party_addmember(int party_id,int account_id)
  263. {
  264. struct map_session_data *sd;
  265. if (CheckForCharServer())
  266. return 0;
  267. sd=map_id2sd(account_id);
  268. // if(battle_config.etc_log)
  269. // printf("intif: party add member %d %d\n",party_id,account_id);
  270. if(sd!=NULL){
  271. WFIFOW(inter_fd,0)=0x3022;
  272. WFIFOL(inter_fd,2)=party_id;
  273. WFIFOL(inter_fd,6)=account_id;
  274. memcpy(WFIFOP(inter_fd,10),sd->status.name,24);
  275. memcpy(WFIFOP(inter_fd,34),map[sd->bl.m].name,16);
  276. WFIFOW(inter_fd,50)=sd->status.base_level;
  277. WFIFOSET(inter_fd,52);
  278. }
  279. return 0;
  280. }
  281. // パーティ設定変更
  282. int intif_party_changeoption(int party_id,int account_id,int exp,int item)
  283. {
  284. if (CheckForCharServer())
  285. return 0;
  286. WFIFOW(inter_fd,0)=0x3023;
  287. WFIFOL(inter_fd,2)=party_id;
  288. WFIFOL(inter_fd,6)=account_id;
  289. WFIFOW(inter_fd,10)=exp;
  290. WFIFOW(inter_fd,12)=item;
  291. WFIFOSET(inter_fd,14);
  292. return 0;
  293. }
  294. // パーティ脱退要求
  295. int intif_party_leave(int party_id,int account_id)
  296. {
  297. if (CheckForCharServer())
  298. return 0;
  299. // if(battle_config.etc_log)
  300. // printf("intif: party leave %d %d\n",party_id,account_id);
  301. WFIFOW(inter_fd,0)=0x3024;
  302. WFIFOL(inter_fd,2)=party_id;
  303. WFIFOL(inter_fd,6)=account_id;
  304. WFIFOSET(inter_fd,10);
  305. return 0;
  306. }
  307. // パーティ移動要求
  308. int intif_party_changemap(struct map_session_data *sd,int online)
  309. {
  310. if (CheckForCharServer())
  311. return 0;
  312. if(sd!=NULL){
  313. WFIFOW(inter_fd,0)=0x3025;
  314. WFIFOL(inter_fd,2)=sd->status.party_id;
  315. WFIFOL(inter_fd,6)=sd->status.account_id;
  316. memcpy(WFIFOP(inter_fd,10),map[sd->bl.m].name,16);
  317. WFIFOB(inter_fd,26)=online;
  318. WFIFOW(inter_fd,27)=sd->status.base_level;
  319. WFIFOSET(inter_fd,29);
  320. }
  321. // if(battle_config.etc_log)
  322. // printf("party: change map\n");
  323. return 0;
  324. }
  325. // パーティー解散要求
  326. int intif_break_party(int party_id)
  327. {
  328. if (CheckForCharServer())
  329. return 0;
  330. WFIFOW(inter_fd,0)=0x3026;
  331. WFIFOL(inter_fd,2)=party_id;
  332. WFIFOSET(inter_fd,6);
  333. return 0;
  334. }
  335. // パーティ会話送信
  336. int intif_party_message(int party_id,int account_id,char *mes,int len)
  337. {
  338. if (CheckForCharServer())
  339. return 0;
  340. // if(battle_config.etc_log)
  341. // printf("intif_party_message: %s\n",mes);
  342. WFIFOW(inter_fd,0)=0x3027;
  343. WFIFOW(inter_fd,2)=len+12;
  344. WFIFOL(inter_fd,4)=party_id;
  345. WFIFOL(inter_fd,8)=account_id;
  346. memcpy(WFIFOP(inter_fd,12),mes,len);
  347. WFIFOSET(inter_fd,len+12);
  348. return 0;
  349. }
  350. // パーティ競合チェック要求
  351. int intif_party_checkconflict(int party_id,int account_id,char *nick)
  352. {
  353. if (CheckForCharServer())
  354. return 0;
  355. WFIFOW(inter_fd,0)=0x3028;
  356. WFIFOL(inter_fd,2)=party_id;
  357. WFIFOL(inter_fd,6)=account_id;
  358. memcpy(WFIFOP(inter_fd,10),nick,24);
  359. WFIFOSET(inter_fd,34);
  360. return 0;
  361. }
  362. // ギルド作成要求
  363. int intif_guild_create(const char *name,const struct guild_member *master)
  364. {
  365. if (CheckForCharServer())
  366. return 0;
  367. nullpo_retr(0, master);
  368. WFIFOW(inter_fd,0)=0x3030;
  369. WFIFOW(inter_fd,2)=sizeof(struct guild_member)+32;
  370. WFIFOL(inter_fd,4)=master->account_id;
  371. memcpy(WFIFOP(inter_fd,8),name,24);
  372. memcpy(WFIFOP(inter_fd,32),master,sizeof(struct guild_member));
  373. WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
  374. return 0;
  375. }
  376. // ギルド情報要求
  377. int intif_guild_request_info(int guild_id)
  378. {
  379. if (CheckForCharServer())
  380. return 0;
  381. WFIFOW(inter_fd,0) = 0x3031;
  382. WFIFOL(inter_fd,2) = guild_id;
  383. WFIFOSET(inter_fd,6);
  384. return 0;
  385. }
  386. // ギルドメンバ追加要求
  387. int intif_guild_addmember(int guild_id,struct guild_member *m)
  388. {
  389. if (CheckForCharServer())
  390. return 0;
  391. WFIFOW(inter_fd,0) = 0x3032;
  392. WFIFOW(inter_fd,2) = sizeof(struct guild_member)+8;
  393. WFIFOL(inter_fd,4) = guild_id;
  394. memcpy(WFIFOP(inter_fd,8),m,sizeof(struct guild_member));
  395. WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
  396. return 0;
  397. }
  398. // ギルドメンバ脱退/追放要求
  399. int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const char *mes)
  400. {
  401. if (CheckForCharServer())
  402. return 0;
  403. WFIFOW(inter_fd, 0) = 0x3034;
  404. WFIFOL(inter_fd, 2) = guild_id;
  405. WFIFOL(inter_fd, 6) = account_id;
  406. WFIFOL(inter_fd,10) = char_id;
  407. WFIFOB(inter_fd,14) = flag;
  408. memcpy(WFIFOP(inter_fd,15),mes,40);
  409. WFIFOSET(inter_fd,55);
  410. return 0;
  411. }
  412. // ギルドメンバのオンライン状況/Lv更新要求
  413. int intif_guild_memberinfoshort(int guild_id,
  414. int account_id,int char_id,int online,int lv,int class)
  415. {
  416. if (CheckForCharServer())
  417. return 0;
  418. WFIFOW(inter_fd, 0) = 0x3035;
  419. WFIFOL(inter_fd, 2) = guild_id;
  420. WFIFOL(inter_fd, 6) = account_id;
  421. WFIFOL(inter_fd,10) = char_id;
  422. WFIFOB(inter_fd,14) = online;
  423. WFIFOW(inter_fd,15) = lv;
  424. WFIFOW(inter_fd,17) = class;
  425. WFIFOSET(inter_fd,19);
  426. return 0;
  427. }
  428. // ギルド解散通知
  429. int intif_guild_break(int guild_id)
  430. {
  431. if (CheckForCharServer())
  432. return 0;
  433. WFIFOW(inter_fd, 0) = 0x3036;
  434. WFIFOL(inter_fd, 2) = guild_id;
  435. WFIFOSET(inter_fd,6);
  436. return 0;
  437. }
  438. // ギルド会話送信
  439. int intif_guild_message(int guild_id,int account_id,char *mes,int len)
  440. {
  441. if (CheckForCharServer())
  442. return 0;
  443. WFIFOW(inter_fd,0)=0x3037;
  444. WFIFOW(inter_fd,2)=len+12;
  445. WFIFOL(inter_fd,4)=guild_id;
  446. WFIFOL(inter_fd,8)=account_id;
  447. memcpy(WFIFOP(inter_fd,12),mes,len);
  448. WFIFOSET(inter_fd,len+12);
  449. return 0;
  450. }
  451. // ギルド競合チェック要求
  452. int intif_guild_checkconflict(int guild_id,int account_id,int char_id)
  453. {
  454. if (CheckForCharServer())
  455. return 0;
  456. WFIFOW(inter_fd, 0)=0x3038;
  457. WFIFOL(inter_fd, 2)=guild_id;
  458. WFIFOL(inter_fd, 6)=account_id;
  459. WFIFOL(inter_fd,10)=char_id;
  460. WFIFOSET(inter_fd,14);
  461. return 0;
  462. }
  463. // ギルド基本情報変更要求
  464. int intif_guild_change_basicinfo(int guild_id,int type,const void *data,int len)
  465. {
  466. if (CheckForCharServer())
  467. return 0;
  468. WFIFOW(inter_fd,0)=0x3039;
  469. WFIFOW(inter_fd,2)=len+10;
  470. WFIFOL(inter_fd,4)=guild_id;
  471. WFIFOW(inter_fd,8)=type;
  472. memcpy(WFIFOP(inter_fd,10),data,len);
  473. WFIFOSET(inter_fd,len+10);
  474. return 0;
  475. }
  476. // ギルドメンバ情報変更要求
  477. int intif_guild_change_memberinfo(int guild_id,int account_id,int char_id,
  478. int type,const void *data,int len)
  479. {
  480. if (CheckForCharServer())
  481. return 0;
  482. WFIFOW(inter_fd, 0)=0x303a;
  483. WFIFOW(inter_fd, 2)=len+18;
  484. WFIFOL(inter_fd, 4)=guild_id;
  485. WFIFOL(inter_fd, 8)=account_id;
  486. WFIFOL(inter_fd,12)=char_id;
  487. WFIFOW(inter_fd,16)=type;
  488. memcpy(WFIFOP(inter_fd,18),data,len);
  489. WFIFOSET(inter_fd,len+18);
  490. return 0;
  491. }
  492. // ギルド役職変更要求
  493. int intif_guild_position(int guild_id,int idx,struct guild_position *p)
  494. {
  495. if (CheckForCharServer())
  496. return 0;
  497. WFIFOW(inter_fd,0)=0x303b;
  498. WFIFOW(inter_fd,2)=sizeof(struct guild_position)+12;
  499. WFIFOL(inter_fd,4)=guild_id;
  500. WFIFOL(inter_fd,8)=idx;
  501. memcpy(WFIFOP(inter_fd,12),p,sizeof(struct guild_position));
  502. WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
  503. return 0;
  504. }
  505. // ギルドスキルアップ要求
  506. int intif_guild_skillup(int guild_id,int skill_num,int account_id,int flag)
  507. {
  508. if (CheckForCharServer())
  509. return 0;
  510. WFIFOW(inter_fd, 0)=0x303c;
  511. WFIFOL(inter_fd, 2)=guild_id;
  512. WFIFOL(inter_fd, 6)=skill_num;
  513. WFIFOL(inter_fd,10)=account_id;
  514. //WFIFOL(inter_fd,14)=flag;
  515. WFIFOSET(inter_fd,14);
  516. return 0;
  517. }
  518. // ギルド同盟/敵対要求
  519. int intif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag)
  520. {
  521. if (CheckForCharServer())
  522. return 0;
  523. WFIFOW(inter_fd, 0)=0x303d;
  524. WFIFOL(inter_fd, 2)=guild_id1;
  525. WFIFOL(inter_fd, 6)=guild_id2;
  526. WFIFOL(inter_fd,10)=account_id1;
  527. WFIFOL(inter_fd,14)=account_id2;
  528. WFIFOB(inter_fd,18)=flag;
  529. WFIFOSET(inter_fd,19);
  530. return 0;
  531. }
  532. // ギルド告知変更要求
  533. int intif_guild_notice(int guild_id,const char *mes1,const char *mes2)
  534. {
  535. if (CheckForCharServer())
  536. return 0;
  537. WFIFOW(inter_fd,0)=0x303e;
  538. WFIFOL(inter_fd,2)=guild_id;
  539. memcpy(WFIFOP(inter_fd,6),mes1,60);
  540. memcpy(WFIFOP(inter_fd,66),mes2,120);
  541. WFIFOSET(inter_fd,186);
  542. return 0;
  543. }
  544. // ギルドエンブレム変更要求
  545. int intif_guild_emblem(int guild_id,int len,const char *data)
  546. {
  547. if (CheckForCharServer())
  548. return 0;
  549. if(guild_id<=0 || len<0 || len>2000)
  550. return 0;
  551. WFIFOW(inter_fd,0)=0x303f;
  552. WFIFOW(inter_fd,2)=len+12;
  553. WFIFOL(inter_fd,4)=guild_id;
  554. WFIFOL(inter_fd,8)=0;
  555. memcpy(WFIFOP(inter_fd,12),data,len);
  556. WFIFOSET(inter_fd,len+12);
  557. return 0;
  558. }
  559. //現在のギルド城占領ギルドを調べる
  560. int intif_guild_castle_dataload(int castle_id,int index)
  561. {
  562. if (CheckForCharServer())
  563. return 0;
  564. WFIFOW(inter_fd,0)=0x3040;
  565. WFIFOW(inter_fd,2)=castle_id;
  566. WFIFOB(inter_fd,4)=index;
  567. WFIFOSET(inter_fd,5);
  568. return 0;
  569. }
  570. //ギルド城占領ギルド変更要求
  571. int intif_guild_castle_datasave(int castle_id,int index, int value)
  572. {
  573. if (CheckForCharServer())
  574. return 0;
  575. WFIFOW(inter_fd,0)=0x3041;
  576. WFIFOW(inter_fd,2)=castle_id;
  577. WFIFOB(inter_fd,4)=index;
  578. WFIFOL(inter_fd,5)=value;
  579. WFIFOSET(inter_fd,9);
  580. return 0;
  581. }
  582. //-----------------------------------------------------------------
  583. // Packets receive from inter server
  584. // Wisp/Page reception
  585. int intif_parse_WisMessage(int fd) { // rewritten by [Yor]
  586. struct map_session_data* sd;
  587. int id=RFIFOL(fd,4);
  588. int i=0; //,j=0;
  589. // if(battle_config.etc_log)
  590. // printf("intif_parse_wismessage: %d %s %s %s\n",id,RFIFOP(fd,6),RFIFOP(fd,30),RFIFOP(fd,54) );
  591. sd=map_nick2sd(RFIFOP(fd,32)); // 送信先を探す
  592. if(sd!=NULL && strcmp(sd->status.name, RFIFOP(fd,32)) == 0){
  593. /*
  594. for(i=0;i<MAX_WIS_REFUSAL;i++){ //拒否リストに名前があるかどうか判定してあれば拒否
  595. if(strcmp(sd->wis_refusal[i],RFIFOP(fd,8))==0){
  596. j++;
  597. break;
  598. }
  599. }
  600. */
  601. if(sd->ignoreAll == 1)
  602. intif_wis_replay(RFIFOL(fd,4), 2); // 受信拒否
  603. /*
  604. else if(j>0)
  605. intif_wis_replay(id,2); // 受信拒否
  606. else{
  607. */
  608. if(i == MAX_IGNORE_LIST) {
  609. clif_wis_message(sd->fd,RFIFOP(fd,8),RFIFOP(fd,56),RFIFOW(fd,2)-56);
  610. intif_wis_replay(RFIFOL(fd,4),0); // 送信成功
  611. }
  612. }else
  613. intif_wis_replay(id,1); // そんな人いません
  614. return 0;
  615. }
  616. // Wisp/page transmission result reception
  617. int intif_parse_WisEnd(int fd) {
  618. struct map_session_data* sd;
  619. if (battle_config.etc_log)
  620. printf("intif_parse_wisend: player: %s, flag: %d\n", RFIFOP(fd,2), RFIFOB(fd,26)); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
  621. sd = map_nick2sd(RFIFOP(fd,2));
  622. if (sd != NULL)
  623. clif_wis_end(sd->fd, RFIFOB(fd,26));
  624. return 0;
  625. }
  626. // Received wisp message from map-server via char-server for ALL gm
  627. int mapif_parse_WisToGM(int fd) { // 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B
  628. int i, min_gm_level;
  629. struct map_session_data *pl_sd;
  630. char Wisp_name[24];
  631. char mbuf[255];
  632. char *message = ((RFIFOW(fd,2) - 30) >= sizeof(mbuf)) ? (char *) malloc((RFIFOW(fd,2) - 30)) : mbuf;
  633. min_gm_level = (int)RFIFOW(fd,28);
  634. memcpy(Wisp_name, RFIFOP(fd,4), 24);
  635. Wisp_name[23] = '\0';
  636. memcpy(message, RFIFOP(fd,30), RFIFOW(fd,2) - 30);
  637. message[sizeof(message) - 1] = '\0';
  638. // information is sended to all online GM
  639. for (i = 0; i < fd_max; i++)
  640. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth)
  641. if (pc_isGM(pl_sd) >= min_gm_level)
  642. clif_wis_message(i, Wisp_name, message, strlen(message) + 1);
  643. if (message != mbuf)
  644. free(message);
  645. return 0;
  646. }
  647. // アカウント変数通知
  648. int intif_parse_AccountReg(int fd) {
  649. int j,p;
  650. struct map_session_data *sd;
  651. if( (sd=map_id2sd(RFIFOL(fd,4)))==NULL )
  652. return 1;
  653. for(p=8,j=0;p<RFIFOW(fd,2) && j<ACCOUNT_REG_NUM;p+=36,j++){
  654. memcpy(sd->status.account_reg[j].str,RFIFOP(fd,p),32);
  655. sd->status.account_reg[j].value=RFIFOL(fd,p+32);
  656. }
  657. sd->status.account_reg_num = j;
  658. // printf("intif: accountreg\n");
  659. return 0;
  660. }
  661. // 倉庫データ受信
  662. int intif_parse_LoadStorage(int fd) {
  663. struct storage *stor;
  664. struct map_session_data *sd;
  665. stor = account2storage( RFIFOL(fd,4));
  666. if (RFIFOW(fd,2)-8 != sizeof(struct storage)) {
  667. if (battle_config.error_log)
  668. printf("intif_parse_LoadStorage: data size error %d %d\n", RFIFOW(fd,2)-8, sizeof(struct storage));
  669. return 1;
  670. }
  671. sd=map_id2sd( RFIFOL(fd,4) );
  672. if(sd==NULL){
  673. if(battle_config.error_log)
  674. printf("intif_parse_LoadStorage: user not found %d\n",RFIFOL(fd,4));
  675. return 1;
  676. }
  677. if(battle_config.save_log)
  678. printf("intif_openstorage: %d\n",RFIFOL(fd,4) );
  679. memcpy(stor,RFIFOP(fd,8),sizeof(struct storage));
  680. stor->dirty=0;
  681. stor->storage_status=1;
  682. sd->state.storage_flag = 0;
  683. clif_storageitemlist(sd,stor);
  684. clif_storageequiplist(sd,stor);
  685. clif_updatestorageamount(sd,stor);
  686. return 0;
  687. }
  688. // 倉庫データ送信成功
  689. int intif_parse_SaveStorage(int fd)
  690. {
  691. if(battle_config.save_log)
  692. printf("intif_savestorage: done %d %d\n",RFIFOL(fd,2),RFIFOB(fd,6) );
  693. return 0;
  694. }
  695. int intif_parse_LoadGuildStorage(int fd)
  696. {
  697. struct guild_storage *gstor;
  698. struct map_session_data *sd;
  699. int guild_id = RFIFOL(fd,8);
  700. if(guild_id > 0) {
  701. gstor=guild2storage(guild_id);
  702. if(!gstor) {
  703. if(battle_config.error_log)
  704. printf("intif_parse_LoadGuildStorage: error guild_id %d not exist\n",guild_id);
  705. return 1;
  706. }
  707. if( RFIFOW(fd,2)-12 != sizeof(struct guild_storage) ){
  708. gstor->storage_status = 0;
  709. if(battle_config.error_log)
  710. printf("intif_parse_LoadGuildStorage: data size error %d %d\n",RFIFOW(fd,2)-12 , sizeof(struct guild_storage));
  711. return 1;
  712. }
  713. sd=map_id2sd( RFIFOL(fd,4) );
  714. if(sd==NULL){
  715. if(battle_config.error_log)
  716. printf("intif_parse_LoadGuildStorage: user not found %d\n",RFIFOL(fd,4));
  717. return 1;
  718. }
  719. if(battle_config.save_log)
  720. printf("intif_open_guild_storage: %d\n",RFIFOL(fd,4) );
  721. memcpy(gstor,RFIFOP(fd,12),sizeof(struct guild_storage));
  722. gstor->storage_status = 1;
  723. sd->state.storage_flag = 1;
  724. clif_guildstorageitemlist(sd,gstor);
  725. clif_guildstorageequiplist(sd,gstor);
  726. clif_updateguildstorageamount(sd,gstor);
  727. }
  728. return 0;
  729. }
  730. int intif_parse_SaveGuildStorage(int fd)
  731. {
  732. if(battle_config.save_log) {
  733. printf("intif_save_guild_storage: done %d %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOB(fd,10) );
  734. }
  735. return 0;
  736. }
  737. // パーティ作成可否
  738. int intif_parse_PartyCreated(int fd)
  739. {
  740. if(battle_config.etc_log)
  741. printf("intif: party created\n");
  742. party_created(RFIFOL(fd,2),RFIFOB(fd,6),RFIFOL(fd,7),RFIFOP(fd,11));
  743. return 0;
  744. }
  745. // パーティ情報
  746. int intif_parse_PartyInfo(int fd)
  747. {
  748. if( RFIFOW(fd,2)==8){
  749. if(battle_config.error_log)
  750. printf("intif: party noinfo %d\n",RFIFOL(fd,4));
  751. party_recv_noinfo(RFIFOL(fd,4));
  752. return 0;
  753. }
  754. // printf("intif: party info %d\n",RFIFOL(fd,4));
  755. if( RFIFOW(fd,2)!=sizeof(struct party)+4 ){
  756. if(battle_config.error_log)
  757. printf("intif: party info : data size error %d %d %d\n",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct party)+4);
  758. }
  759. party_recv_info((struct party *)RFIFOP(fd,4));
  760. return 0;
  761. }
  762. // パーティ追加通知
  763. int intif_parse_PartyMemberAdded(int fd)
  764. {
  765. if(battle_config.etc_log)
  766. printf("intif: party member added %d %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOB(fd,10));
  767. party_member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOB(fd,10));
  768. return 0;
  769. }
  770. // パーティ設定変更通知
  771. int intif_parse_PartyOptionChanged(int fd)
  772. {
  773. party_optionchanged(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOB(fd,14));
  774. return 0;
  775. }
  776. // パーティ脱退通知
  777. int intif_parse_PartyMemberLeaved(int fd)
  778. {
  779. if(battle_config.etc_log)
  780. printf("intif: party member leaved %d %d %s\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOP(fd,10));
  781. party_member_leaved(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOP(fd,10));
  782. return 0;
  783. }
  784. // パーティ解散通知
  785. int intif_parse_PartyBroken(int fd)
  786. {
  787. party_broken(RFIFOL(fd,2));
  788. return 0;
  789. }
  790. // パーティ移動通知
  791. int intif_parse_PartyMove(int fd)
  792. {
  793. // if(battle_config.etc_log)
  794. // printf("intif: party move %d %d %s %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOP(fd,10),RFIFOB(fd,26),RFIFOW(fd,27));
  795. party_recv_movemap(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOP(fd,10),RFIFOB(fd,26),RFIFOW(fd,27));
  796. return 0;
  797. }
  798. // パーティメッセージ
  799. int intif_parse_PartyMessage(int fd)
  800. {
  801. // if(battle_config.etc_log)
  802. // printf("intif_parse_PartyMessage: %s\n",RFIFOP(fd,12));
  803. party_recv_message(RFIFOL(fd,4),RFIFOL(fd,8),RFIFOP(fd,12),RFIFOW(fd,2)-12);
  804. return 0;
  805. }
  806. // ギルド作成可否
  807. int intif_parse_GuildCreated(int fd)
  808. {
  809. guild_created(RFIFOL(fd,2),RFIFOL(fd,6));
  810. return 0;
  811. }
  812. // ギルド情報
  813. int intif_parse_GuildInfo(int fd)
  814. {
  815. if( RFIFOW(fd,2)==8){
  816. if(battle_config.error_log)
  817. printf("intif: guild noinfo %d\n",RFIFOL(fd,4));
  818. guild_recv_noinfo(RFIFOL(fd,4));
  819. return 0;
  820. }
  821. // if(battle_config.etc_log)
  822. // printf("intif: guild info %d\n",RFIFOL(fd,4));
  823. if( RFIFOW(fd,2)!=sizeof(struct guild)+4 ){
  824. if(battle_config.error_log)
  825. printf("intif: guild info : data size error\n %d %d %d",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild)+4);
  826. }
  827. guild_recv_info((struct guild *)RFIFOP(fd,4));
  828. return 0;
  829. }
  830. // ギルドメンバ追加通知
  831. int intif_parse_GuildMemberAdded(int fd)
  832. {
  833. if(battle_config.etc_log)
  834. printf("intif: guild member added %d %d %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14));
  835. guild_member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14));
  836. return 0;
  837. }
  838. // ギルドメンバ脱退/追放通知
  839. int intif_parse_GuildMemberLeaved(int fd)
  840. {
  841. guild_member_leaved(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),
  842. RFIFOP(fd,55),RFIFOP(fd,15));
  843. return 0;
  844. }
  845. // ギルドメンバオンライン状態/Lv変更通知
  846. int intif_parse_GuildMemberInfoShort(int fd)
  847. {
  848. guild_recv_memberinfoshort(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17));
  849. return 0;
  850. }
  851. // ギルド解散通知
  852. int intif_parse_GuildBroken(int fd)
  853. {
  854. guild_broken(RFIFOL(fd,2),RFIFOB(fd,6));
  855. return 0;
  856. }
  857. // ギルド基本情報変更通知
  858. int intif_parse_GuildBasicInfoChanged(int fd)
  859. {
  860. int type=RFIFOW(fd,8),guild_id=RFIFOL(fd,4);
  861. void *data=RFIFOP(fd,10);
  862. struct guild *g=guild_search(guild_id);
  863. short dw=*((short *)data);
  864. int dd=*((int *)data);
  865. if( g==NULL )
  866. return 0;
  867. switch(type){
  868. case GBI_EXP: g->exp=dd; break;
  869. case GBI_GUILDLV: g->guild_lv=dw; break;
  870. case GBI_SKILLPOINT: g->skill_point=dd; break;
  871. }
  872. return 0;
  873. }
  874. // ギルドメンバ情報変更通知
  875. int intif_parse_GuildMemberInfoChanged(int fd)
  876. {
  877. int type=RFIFOW(fd,16),guild_id=RFIFOL(fd,4);
  878. int account_id=RFIFOL(fd,8),char_id=RFIFOL(fd,12);
  879. void *data=RFIFOP(fd,18);
  880. struct guild *g=guild_search(guild_id);
  881. int idx,dd=*((int *)data);
  882. if( g==NULL )
  883. return 0;
  884. idx=guild_getindex(g,account_id,char_id);
  885. switch(type){
  886. case GMI_POSITION:
  887. g->member[idx].position=dd;
  888. guild_memberposition_changed(g,idx,dd);
  889. break;
  890. case GMI_EXP:
  891. g->member[idx].exp=dd;
  892. break;
  893. }
  894. return 0;
  895. }
  896. // ギルド役職変更通知
  897. int intif_parse_GuildPosition(int fd)
  898. {
  899. if( RFIFOW(fd,2)!=sizeof(struct guild_position)+12 ){
  900. if(battle_config.error_log)
  901. printf("intif: guild info : data size error\n %d %d %d",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild_position)+12);
  902. }
  903. guild_position_changed(RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12));
  904. return 0;
  905. }
  906. // ギルドスキル割り振り通知
  907. int intif_parse_GuildSkillUp(int fd)
  908. {
  909. guild_skillupack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
  910. return 0;
  911. }
  912. // ギルド同盟/敵対通知
  913. int intif_parse_GuildAlliance(int fd)
  914. {
  915. guild_allianceack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),
  916. RFIFOB(fd,18),RFIFOP(fd,19),RFIFOP(fd,43));
  917. return 0;
  918. }
  919. // ギルド告知変更通知
  920. int intif_parse_GuildNotice(int fd)
  921. {
  922. guild_notice_changed(RFIFOL(fd,2),RFIFOP(fd,6),RFIFOP(fd,66));
  923. return 0;
  924. }
  925. // ギルドエンブレム変更通知
  926. int intif_parse_GuildEmblem(int fd)
  927. {
  928. guild_emblem_changed(RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8),RFIFOP(fd,12));
  929. return 0;
  930. }
  931. // ギルド会話受信
  932. int intif_parse_GuildMessage(int fd)
  933. {
  934. guild_recv_message(RFIFOL(fd,4),RFIFOL(fd,8),RFIFOP(fd,12),RFIFOW(fd,2)-12);
  935. return 0;
  936. }
  937. // ギルド城データ要求返信
  938. int intif_parse_GuildCastleDataLoad(int fd)
  939. {
  940. return guild_castledataloadack(RFIFOW(fd,2),RFIFOB(fd,4),RFIFOL(fd,5));
  941. }
  942. // ギルド城データ変更通知
  943. int intif_parse_GuildCastleDataSave(int fd)
  944. {
  945. return guild_castledatasaveack(RFIFOW(fd,2),RFIFOB(fd,4),RFIFOL(fd,5));
  946. }
  947. // ギルド城データ一括受信(初期化時)
  948. int intif_parse_GuildCastleAllDataLoad(int fd)
  949. {
  950. return guild_castlealldataload(RFIFOW(fd,2),(struct guild_castle *)RFIFOP(fd,4));
  951. }
  952. // pet
  953. int intif_parse_CreatePet(int fd)
  954. {
  955. pet_get_egg(RFIFOL(fd,2),RFIFOL(fd,7),RFIFOB(fd,6));
  956. return 0;
  957. }
  958. int intif_parse_RecvPetData(int fd)
  959. {
  960. struct s_pet p;
  961. int len=RFIFOW(fd,2);
  962. if(sizeof(struct s_pet)!=len-9) {
  963. if(battle_config.etc_log)
  964. printf("intif: pet data: data size error %d %d\n",sizeof(struct s_pet),len-9);
  965. }
  966. else{
  967. memcpy(&p,RFIFOP(fd,9),sizeof(struct s_pet));
  968. pet_recv_petdata(RFIFOL(fd,4),&p,RFIFOB(fd,8));
  969. }
  970. return 0;
  971. }
  972. int intif_parse_SavePetOk(int fd)
  973. {
  974. if(RFIFOB(fd,6) == 1) {
  975. if(battle_config.error_log)
  976. printf("pet data save failure\n");
  977. }
  978. return 0;
  979. }
  980. int intif_parse_DeletePetOk(int fd)
  981. {
  982. if(RFIFOB(fd,2) == 1) {
  983. if(battle_config.error_log)
  984. printf("pet data delete failure\n");
  985. }
  986. return 0;
  987. }
  988. //-----------------------------------------------------------------
  989. // inter serverからの通信
  990. // エラーがあれば0(false)を返すこと
  991. // パケットが処理できれば1,パケット長が足りなければ2を返すこと
  992. int intif_parse(int fd)
  993. {
  994. int packet_len;
  995. int cmd = RFIFOW(fd,0);
  996. // パケットのID確認
  997. if(cmd<0x3800 || cmd>=0x3800+(sizeof(packet_len_table)/sizeof(packet_len_table[0])) ||
  998. packet_len_table[cmd-0x3800]==0){
  999. return 0;
  1000. }
  1001. // パケットの長さ確認
  1002. packet_len = packet_len_table[cmd-0x3800];
  1003. if(packet_len==-1){
  1004. if(RFIFOREST(fd)<4)
  1005. return 2;
  1006. packet_len = RFIFOW(fd,2);
  1007. }
  1008. // if(battle_config.etc_log)
  1009. // printf("intif_parse %d %x %d %d\n",fd,cmd,packet_len,RFIFOREST(fd));
  1010. if(RFIFOREST(fd)<packet_len){
  1011. return 2;
  1012. }
  1013. // 処理分岐
  1014. switch(cmd){
  1015. case 0x3800: clif_GMmessage(NULL,RFIFOP(fd,4),packet_len-4,0); break;
  1016. case 0x3801: intif_parse_WisMessage(fd); break;
  1017. case 0x3802: intif_parse_WisEnd(fd); break;
  1018. case 0x3803: mapif_parse_WisToGM(fd); break;
  1019. case 0x3804: intif_parse_AccountReg(fd); break;
  1020. case 0x3810: intif_parse_LoadStorage(fd); break;
  1021. case 0x3811: intif_parse_SaveStorage(fd); break;
  1022. case 0x3818: intif_parse_LoadGuildStorage(fd); break;
  1023. case 0x3819: intif_parse_SaveGuildStorage(fd); break;
  1024. case 0x3820: intif_parse_PartyCreated(fd); break;
  1025. case 0x3821: intif_parse_PartyInfo(fd); break;
  1026. case 0x3822: intif_parse_PartyMemberAdded(fd); break;
  1027. case 0x3823: intif_parse_PartyOptionChanged(fd); break;
  1028. case 0x3824: intif_parse_PartyMemberLeaved(fd); break;
  1029. case 0x3825: intif_parse_PartyMove(fd); break;
  1030. case 0x3826: intif_parse_PartyBroken(fd); break;
  1031. case 0x3827: intif_parse_PartyMessage(fd); break;
  1032. case 0x3830: intif_parse_GuildCreated(fd); break;
  1033. case 0x3831: intif_parse_GuildInfo(fd); break;
  1034. case 0x3832: intif_parse_GuildMemberAdded(fd); break;
  1035. case 0x3834: intif_parse_GuildMemberLeaved(fd); break;
  1036. case 0x3835: intif_parse_GuildMemberInfoShort(fd); break;
  1037. case 0x3836: intif_parse_GuildBroken(fd); break;
  1038. case 0x3837: intif_parse_GuildMessage(fd); break;
  1039. case 0x3839: intif_parse_GuildBasicInfoChanged(fd); break;
  1040. case 0x383a: intif_parse_GuildMemberInfoChanged(fd); break;
  1041. case 0x383b: intif_parse_GuildPosition(fd); break;
  1042. case 0x383c: intif_parse_GuildSkillUp(fd); break;
  1043. case 0x383d: intif_parse_GuildAlliance(fd); break;
  1044. case 0x383e: intif_parse_GuildNotice(fd); break;
  1045. case 0x383f: intif_parse_GuildEmblem(fd); break;
  1046. case 0x3840: intif_parse_GuildCastleDataLoad(fd); break;
  1047. case 0x3841: intif_parse_GuildCastleDataSave(fd); break;
  1048. case 0x3842: intif_parse_GuildCastleAllDataLoad(fd); break;
  1049. case 0x3880: intif_parse_CreatePet(fd); break;
  1050. case 0x3881: intif_parse_RecvPetData(fd); break;
  1051. case 0x3882: intif_parse_SavePetOk(fd); break;
  1052. case 0x3883: intif_parse_DeletePetOk(fd); break;
  1053. default:
  1054. if(battle_config.error_log)
  1055. printf("intif_parse : unknown packet %d %x\n",fd,RFIFOW(fd,0));
  1056. return 0;
  1057. }
  1058. // パケット読み飛ばし
  1059. RFIFOSKIP(fd,packet_len);
  1060. return 1;
  1061. }