intif.c 30 KB

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