intif.c 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/showmsg.h"
  4. #include "../common/socket.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/malloc.h"
  8. #include "../common/strlib.h"
  9. #include "map.h"
  10. #include "battle.h"
  11. #include "chrif.h"
  12. #include "clif.h"
  13. #include "pc.h"
  14. #include "intif.h"
  15. #include "log.h"
  16. #include "storage.h"
  17. #include "party.h"
  18. #include "guild.h"
  19. #include "pet.h"
  20. #include "atcommand.h"
  21. #include "mercenary.h"
  22. #include "homunculus.h"
  23. #include "elemental.h"
  24. #include "mail.h"
  25. #include "quest.h"
  26. #include <sys/types.h>
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include <signal.h>
  30. #include <fcntl.h>
  31. #include <string.h>
  32. static const int packet_len_table[]={
  33. -1,-1,27,-1, -1, 0,37,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f
  34. 0, 0, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810
  35. 39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820
  36. 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830
  37. -1, 0, 0,14, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, //0x3840
  38. -1,-1, 7, 7, 7,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus]
  39. -1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3860 Quests [Kevin] [Inkfish]
  40. -1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 3, 3, 0, //0x3870 Mercenaries [Zephyrus] / Elemental [pakpil]
  41. 11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880
  42. -1,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3890 Homunculus [albator]
  43. };
  44. extern int char_fd; // inter server Fd used for char_fd
  45. #define inter_fd char_fd // alias
  46. //-----------------------------------------------------------------
  47. // Send to inter server
  48. int CheckForCharServer(void)
  49. {
  50. return ((char_fd <= 0) || session[char_fd] == NULL || session[char_fd]->wdata == NULL);
  51. }
  52. // pet
  53. int intif_create_pet(int account_id,int char_id,short pet_class,short pet_lv,short pet_egg_id,
  54. short pet_equip,short intimate,short hungry,char rename_flag,char incuvate,char *pet_name)
  55. {
  56. if (CheckForCharServer())
  57. return 0;
  58. WFIFOHEAD(inter_fd, 24 + NAME_LENGTH);
  59. WFIFOW(inter_fd,0) = 0x3080;
  60. WFIFOL(inter_fd,2) = account_id;
  61. WFIFOL(inter_fd,6) = char_id;
  62. WFIFOW(inter_fd,10) = pet_class;
  63. WFIFOW(inter_fd,12) = pet_lv;
  64. WFIFOW(inter_fd,14) = pet_egg_id;
  65. WFIFOW(inter_fd,16) = pet_equip;
  66. WFIFOW(inter_fd,18) = intimate;
  67. WFIFOW(inter_fd,20) = hungry;
  68. WFIFOB(inter_fd,22) = rename_flag;
  69. WFIFOB(inter_fd,23) = incuvate;
  70. memcpy(WFIFOP(inter_fd,24),pet_name,NAME_LENGTH);
  71. WFIFOSET(inter_fd,24+NAME_LENGTH);
  72. return 0;
  73. }
  74. int intif_request_petdata(int account_id,int char_id,int pet_id)
  75. {
  76. if (CheckForCharServer())
  77. return 0;
  78. WFIFOHEAD(inter_fd, 14);
  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. WFIFOHEAD(inter_fd, sizeof(struct s_pet) + 8);
  91. WFIFOW(inter_fd,0) = 0x3082;
  92. WFIFOW(inter_fd,2) = sizeof(struct s_pet) + 8;
  93. WFIFOL(inter_fd,4) = account_id;
  94. memcpy(WFIFOP(inter_fd,8),p,sizeof(struct s_pet));
  95. WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
  96. return 0;
  97. }
  98. int intif_delete_petdata(int pet_id)
  99. {
  100. if (CheckForCharServer())
  101. return 0;
  102. WFIFOHEAD(inter_fd,6);
  103. WFIFOW(inter_fd,0) = 0x3083;
  104. WFIFOL(inter_fd,2) = pet_id;
  105. WFIFOSET(inter_fd,6);
  106. return 1;
  107. }
  108. int intif_rename(struct map_session_data *sd, int type, char *name)
  109. {
  110. if (CheckForCharServer())
  111. return 1;
  112. WFIFOHEAD(inter_fd,NAME_LENGTH+12);
  113. WFIFOW(inter_fd,0) = 0x3006;
  114. WFIFOL(inter_fd,2) = sd->status.account_id;
  115. WFIFOL(inter_fd,6) = sd->status.char_id;
  116. WFIFOB(inter_fd,10) = type; //Type: 0 - PC, 1 - PET, 2 - HOM
  117. memcpy(WFIFOP(inter_fd,11),name, NAME_LENGTH);
  118. WFIFOSET(inter_fd,NAME_LENGTH+12);
  119. return 0;
  120. }
  121. // GM Send a message
  122. int intif_broadcast(const char* mes, int len, int type)
  123. {
  124. int lp = type ? 4 : 0;
  125. // Send to the local players
  126. clif_broadcast(NULL, mes, len, type, ALL_CLIENT);
  127. if (CheckForCharServer())
  128. return 0;
  129. if (other_mapserver_count < 1)
  130. return 0; //No need to send.
  131. WFIFOHEAD(inter_fd, 16 + lp + len);
  132. WFIFOW(inter_fd,0) = 0x3000;
  133. WFIFOW(inter_fd,2) = 16 + lp + len;
  134. WFIFOL(inter_fd,4) = 0xFF000000; // 0xFF000000 color signals standard broadcast
  135. WFIFOW(inter_fd,8) = 0; // fontType not used with standard broadcast
  136. WFIFOW(inter_fd,10) = 0; // fontSize not used with standard broadcast
  137. WFIFOW(inter_fd,12) = 0; // fontAlign not used with standard broadcast
  138. WFIFOW(inter_fd,14) = 0; // fontY not used with standard broadcast
  139. if (type == 0x10) // bc_blue
  140. WFIFOL(inter_fd,16) = 0x65756c62; //If there's "blue" at the beginning of the message, game client will display it in blue instead of yellow.
  141. else if (type == 0x20) // bc_woe
  142. WFIFOL(inter_fd,16) = 0x73737373; //If there's "ssss", game client will recognize message as 'WoE broadcast'.
  143. memcpy(WFIFOP(inter_fd,16 + lp), mes, len);
  144. WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
  145. return 0;
  146. }
  147. int intif_broadcast2(const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY)
  148. {
  149. // Send to the local players
  150. if (fontColor == 0xFE000000) // This is main chat message [LuzZza]
  151. clif_MainChatMessage(mes);
  152. else
  153. clif_broadcast2(NULL, mes, len, fontColor, fontType, fontSize, fontAlign, fontY, ALL_CLIENT);
  154. if (CheckForCharServer())
  155. return 0;
  156. if (other_mapserver_count < 1)
  157. return 0; //No need to send.
  158. WFIFOHEAD(inter_fd, 16 + len);
  159. WFIFOW(inter_fd,0) = 0x3000;
  160. WFIFOW(inter_fd,2) = 16 + len;
  161. WFIFOL(inter_fd,4) = fontColor;
  162. WFIFOW(inter_fd,8) = fontType;
  163. WFIFOW(inter_fd,10) = fontSize;
  164. WFIFOW(inter_fd,12) = fontAlign;
  165. WFIFOW(inter_fd,14) = fontY;
  166. memcpy(WFIFOP(inter_fd,16), mes, len);
  167. WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
  168. return 0;
  169. }
  170. /// send a message using the main chat system
  171. /// <sd> the source of message
  172. /// <message> the message that was sent
  173. int intif_main_message(struct map_session_data* sd, const char* message)
  174. {
  175. char output[256];
  176. nullpo_ret(sd);
  177. // format the message for main broadcasting
  178. snprintf( output, sizeof(output), msg_txt(386), sd->status.name, message );
  179. // send the message using the inter-server broadcast service
  180. intif_broadcast2( output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0 );
  181. // log the chat message
  182. log_chat( LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message );
  183. return 0;
  184. }
  185. // The transmission of Wisp/Page to inter-server (player not found on this server)
  186. int intif_wis_message(struct map_session_data *sd, char *nick, char *mes, int mes_len)
  187. {
  188. nullpo_ret(sd);
  189. if (CheckForCharServer())
  190. return 0;
  191. if (other_mapserver_count < 1)
  192. { //Character not found.
  193. clif_wis_end(sd->fd, 1);
  194. return 0;
  195. }
  196. WFIFOHEAD(inter_fd,mes_len + 52);
  197. WFIFOW(inter_fd,0) = 0x3001;
  198. WFIFOW(inter_fd,2) = mes_len + 52;
  199. memcpy(WFIFOP(inter_fd,4), sd->status.name, NAME_LENGTH);
  200. memcpy(WFIFOP(inter_fd,4+NAME_LENGTH), nick, NAME_LENGTH);
  201. memcpy(WFIFOP(inter_fd,4+2*NAME_LENGTH), mes, mes_len);
  202. WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
  203. if (battle_config.etc_log)
  204. ShowInfo("intif_wis_message from %s to %s (message: '%s')\n", sd->status.name, nick, mes);
  205. return 0;
  206. }
  207. // The reply of Wisp/page
  208. int intif_wis_replay(int id, int flag)
  209. {
  210. if (CheckForCharServer())
  211. return 0;
  212. WFIFOHEAD(inter_fd,7);
  213. WFIFOW(inter_fd,0) = 0x3002;
  214. WFIFOL(inter_fd,2) = id;
  215. WFIFOB(inter_fd,6) = flag; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
  216. WFIFOSET(inter_fd,7);
  217. if (battle_config.etc_log)
  218. ShowInfo("intif_wis_replay: id: %d, flag:%d\n", id, flag);
  219. return 0;
  220. }
  221. // The transmission of GM only Wisp/Page from server to inter-server
  222. int intif_wis_message_to_gm(char *wisp_name, int permission, char *mes)
  223. {
  224. int mes_len;
  225. if (CheckForCharServer())
  226. return 0;
  227. mes_len = strlen(mes) + 1; // + null
  228. WFIFOHEAD(inter_fd, mes_len + 32);
  229. WFIFOW(inter_fd,0) = 0x3003;
  230. WFIFOW(inter_fd,2) = mes_len + 32;
  231. memcpy(WFIFOP(inter_fd,4), wisp_name, NAME_LENGTH);
  232. WFIFOL(inter_fd,4+NAME_LENGTH) = permission;
  233. memcpy(WFIFOP(inter_fd,8+NAME_LENGTH), mes, mes_len);
  234. WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
  235. if (battle_config.etc_log)
  236. ShowNotice("intif_wis_message_to_gm: from: '%s', required permission: %d, message: '%s'.\n", wisp_name, permission, mes);
  237. return 0;
  238. }
  239. int intif_regtostr(char* str, struct global_reg *reg, int qty)
  240. {
  241. int len =0, i;
  242. for (i = 0; i < qty; i++) {
  243. len+= sprintf(str+len, "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place.
  244. len+= sprintf(str+len, "%s", reg[i].value)+1;
  245. }
  246. return len;
  247. }
  248. //Request for saving registry values.
  249. int intif_saveregistry(struct map_session_data *sd, int type)
  250. {
  251. struct global_reg *reg;
  252. int count;
  253. int i, p;
  254. if (CheckForCharServer())
  255. return -1;
  256. switch (type) {
  257. case 3: //Character reg
  258. reg = sd->save_reg.global;
  259. count = sd->save_reg.global_num;
  260. sd->state.reg_dirty &= ~0x4;
  261. break;
  262. case 2: //Account reg
  263. reg = sd->save_reg.account;
  264. count = sd->save_reg.account_num;
  265. sd->state.reg_dirty &= ~0x2;
  266. break;
  267. case 1: //Account2 reg
  268. reg = sd->save_reg.account2;
  269. count = sd->save_reg.account2_num;
  270. sd->state.reg_dirty &= ~0x1;
  271. break;
  272. default: //Broken code?
  273. ShowError("intif_saveregistry: Invalid type %d\n", type);
  274. return -1;
  275. }
  276. WFIFOHEAD(inter_fd, 288 * MAX_REG_NUM+13);
  277. WFIFOW(inter_fd,0)=0x3004;
  278. WFIFOL(inter_fd,4)=sd->status.account_id;
  279. WFIFOL(inter_fd,8)=sd->status.char_id;
  280. WFIFOB(inter_fd,12)=type;
  281. for( p = 13, i = 0; i < count; i++ ) {
  282. if (reg[i].str[0] != '\0' && reg[i].value[0] != '\0') {
  283. p+= sprintf((char*)WFIFOP(inter_fd,p), "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place.
  284. p+= sprintf((char*)WFIFOP(inter_fd,p), "%s", reg[i].value)+1;
  285. }
  286. }
  287. WFIFOW(inter_fd,2)=p;
  288. WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
  289. return 0;
  290. }
  291. //Request the registries for this player.
  292. int intif_request_registry(struct map_session_data *sd, int flag)
  293. {
  294. nullpo_ret(sd);
  295. sd->save_reg.account2_num = -1;
  296. sd->save_reg.account_num = -1;
  297. sd->save_reg.global_num = -1;
  298. if (CheckForCharServer())
  299. return 0;
  300. WFIFOHEAD(inter_fd,6);
  301. WFIFOW(inter_fd,0) = 0x3005;
  302. WFIFOL(inter_fd,2) = sd->status.account_id;
  303. WFIFOL(inter_fd,6) = sd->status.char_id;
  304. WFIFOB(inter_fd,10) = (flag&1?1:0); //Request Acc Reg 2
  305. WFIFOB(inter_fd,11) = (flag&2?1:0); //Request Acc Reg
  306. WFIFOB(inter_fd,12) = (flag&4?1:0); //Request Char Reg
  307. WFIFOSET(inter_fd,13);
  308. return 0;
  309. }
  310. int intif_request_guild_storage(int account_id,int guild_id)
  311. {
  312. if (CheckForCharServer())
  313. return 0;
  314. WFIFOHEAD(inter_fd,10);
  315. WFIFOW(inter_fd,0) = 0x3018;
  316. WFIFOL(inter_fd,2) = account_id;
  317. WFIFOL(inter_fd,6) = guild_id;
  318. WFIFOSET(inter_fd,10);
  319. return 0;
  320. }
  321. int intif_send_guild_storage(int account_id,struct guild_storage *gstor)
  322. {
  323. if (CheckForCharServer())
  324. return 0;
  325. WFIFOHEAD(inter_fd,sizeof(struct guild_storage)+12);
  326. WFIFOW(inter_fd,0) = 0x3019;
  327. WFIFOW(inter_fd,2) = (unsigned short)sizeof(struct guild_storage)+12;
  328. WFIFOL(inter_fd,4) = account_id;
  329. WFIFOL(inter_fd,8) = gstor->guild_id;
  330. memcpy( WFIFOP(inter_fd,12),gstor, sizeof(struct guild_storage) );
  331. WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
  332. return 0;
  333. }
  334. // Party creation request
  335. int intif_create_party(struct party_member *member,char *name,int item,int item2)
  336. {
  337. if (CheckForCharServer())
  338. return 0;
  339. nullpo_ret(member);
  340. WFIFOHEAD(inter_fd,64);
  341. WFIFOW(inter_fd,0) = 0x3020;
  342. WFIFOW(inter_fd,2) = 30+sizeof(struct party_member);
  343. memcpy(WFIFOP(inter_fd,4),name, NAME_LENGTH);
  344. WFIFOB(inter_fd,28)= item;
  345. WFIFOB(inter_fd,29)= item2;
  346. memcpy(WFIFOP(inter_fd,30), member, sizeof(struct party_member));
  347. WFIFOSET(inter_fd,WFIFOW(inter_fd, 2));
  348. return 0;
  349. }
  350. // Party information request
  351. int intif_request_partyinfo(int party_id, int char_id)
  352. {
  353. if (CheckForCharServer())
  354. return 0;
  355. WFIFOHEAD(inter_fd,10);
  356. WFIFOW(inter_fd,0) = 0x3021;
  357. WFIFOL(inter_fd,2) = party_id;
  358. WFIFOL(inter_fd,6) = char_id;
  359. WFIFOSET(inter_fd,10);
  360. return 0;
  361. }
  362. // Request to add a member to party
  363. int intif_party_addmember(int party_id,struct party_member *member)
  364. {
  365. if (CheckForCharServer())
  366. return 0;
  367. WFIFOHEAD(inter_fd,42);
  368. WFIFOW(inter_fd,0)=0x3022;
  369. WFIFOW(inter_fd,2)=8+sizeof(struct party_member);
  370. WFIFOL(inter_fd,4)=party_id;
  371. memcpy(WFIFOP(inter_fd,8),member,sizeof(struct party_member));
  372. WFIFOSET(inter_fd,WFIFOW(inter_fd, 2));
  373. return 1;
  374. }
  375. // Request to change party configuration (exp,item share)
  376. int intif_party_changeoption(int party_id,int account_id,int exp,int item)
  377. {
  378. if (CheckForCharServer())
  379. return 0;
  380. WFIFOHEAD(inter_fd,14);
  381. WFIFOW(inter_fd,0)=0x3023;
  382. WFIFOL(inter_fd,2)=party_id;
  383. WFIFOL(inter_fd,6)=account_id;
  384. WFIFOW(inter_fd,10)=exp;
  385. WFIFOW(inter_fd,12)=item;
  386. WFIFOSET(inter_fd,14);
  387. return 0;
  388. }
  389. // Request to leave party
  390. int intif_party_leave(int party_id,int account_id, int char_id)
  391. {
  392. if (CheckForCharServer())
  393. return 0;
  394. WFIFOHEAD(inter_fd,14);
  395. WFIFOW(inter_fd,0)=0x3024;
  396. WFIFOL(inter_fd,2)=party_id;
  397. WFIFOL(inter_fd,6)=account_id;
  398. WFIFOL(inter_fd,10)=char_id;
  399. WFIFOSET(inter_fd,14);
  400. return 0;
  401. }
  402. // Request keeping party for new map ??
  403. int intif_party_changemap(struct map_session_data *sd,int online)
  404. {
  405. int m, mapindex;
  406. if (CheckForCharServer())
  407. return 0;
  408. if(!sd)
  409. return 0;
  410. if( (m=map_mapindex2mapid(sd->mapindex)) >= 0 && map[m].instance_id )
  411. mapindex = map[map[m].instance_src_map].index;
  412. else
  413. mapindex = sd->mapindex;
  414. WFIFOHEAD(inter_fd,19);
  415. WFIFOW(inter_fd,0)=0x3025;
  416. WFIFOL(inter_fd,2)=sd->status.party_id;
  417. WFIFOL(inter_fd,6)=sd->status.account_id;
  418. WFIFOL(inter_fd,10)=sd->status.char_id;
  419. WFIFOW(inter_fd,14)=mapindex;
  420. WFIFOB(inter_fd,16)=online;
  421. WFIFOW(inter_fd,17)=sd->status.base_level;
  422. WFIFOSET(inter_fd,19);
  423. return 1;
  424. }
  425. // Request breaking party
  426. int intif_break_party(int party_id)
  427. {
  428. if (CheckForCharServer())
  429. return 0;
  430. WFIFOHEAD(inter_fd,6);
  431. WFIFOW(inter_fd,0)=0x3026;
  432. WFIFOL(inter_fd,2)=party_id;
  433. WFIFOSET(inter_fd,6);
  434. return 0;
  435. }
  436. // Sending party chat
  437. int intif_party_message(int party_id,int account_id,const char *mes,int len)
  438. {
  439. if (CheckForCharServer())
  440. return 0;
  441. if (other_mapserver_count < 1)
  442. return 0; //No need to send.
  443. WFIFOHEAD(inter_fd,len + 12);
  444. WFIFOW(inter_fd,0)=0x3027;
  445. WFIFOW(inter_fd,2)=len+12;
  446. WFIFOL(inter_fd,4)=party_id;
  447. WFIFOL(inter_fd,8)=account_id;
  448. memcpy(WFIFOP(inter_fd,12),mes,len);
  449. WFIFOSET(inter_fd,len+12);
  450. return 0;
  451. }
  452. // Request a new leader for party
  453. int intif_party_leaderchange(int party_id,int account_id,int char_id)
  454. {
  455. if (CheckForCharServer())
  456. return 0;
  457. WFIFOHEAD(inter_fd,14);
  458. WFIFOW(inter_fd,0)=0x3029;
  459. WFIFOL(inter_fd,2)=party_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. // Request a Guild creation
  466. int intif_guild_create(const char *name,const struct guild_member *master)
  467. {
  468. if (CheckForCharServer())
  469. return 0;
  470. nullpo_ret(master);
  471. WFIFOHEAD(inter_fd,sizeof(struct guild_member)+(8+NAME_LENGTH));
  472. WFIFOW(inter_fd,0)=0x3030;
  473. WFIFOW(inter_fd,2)=sizeof(struct guild_member)+(8+NAME_LENGTH);
  474. WFIFOL(inter_fd,4)=master->account_id;
  475. memcpy(WFIFOP(inter_fd,8),name,NAME_LENGTH);
  476. memcpy(WFIFOP(inter_fd,8+NAME_LENGTH),master,sizeof(struct guild_member));
  477. WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
  478. return 0;
  479. }
  480. // Request Guild information
  481. int intif_guild_request_info(int guild_id)
  482. {
  483. if (CheckForCharServer())
  484. return 0;
  485. WFIFOHEAD(inter_fd,6);
  486. WFIFOW(inter_fd,0) = 0x3031;
  487. WFIFOL(inter_fd,2) = guild_id;
  488. WFIFOSET(inter_fd,6);
  489. return 0;
  490. }
  491. // Request to add member to the guild
  492. int intif_guild_addmember(int guild_id,struct guild_member *m)
  493. {
  494. if (CheckForCharServer())
  495. return 0;
  496. WFIFOHEAD(inter_fd,sizeof(struct guild_member)+8);
  497. WFIFOW(inter_fd,0) = 0x3032;
  498. WFIFOW(inter_fd,2) = sizeof(struct guild_member)+8;
  499. WFIFOL(inter_fd,4) = guild_id;
  500. memcpy(WFIFOP(inter_fd,8),m,sizeof(struct guild_member));
  501. WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
  502. return 0;
  503. }
  504. // Request a new leader for guild
  505. int intif_guild_change_gm(int guild_id, const char* name, int len)
  506. {
  507. if (CheckForCharServer())
  508. return 0;
  509. WFIFOHEAD(inter_fd, len + 8);
  510. WFIFOW(inter_fd, 0)=0x3033;
  511. WFIFOW(inter_fd, 2)=len+8;
  512. WFIFOL(inter_fd, 4)=guild_id;
  513. memcpy(WFIFOP(inter_fd,8),name,len);
  514. WFIFOSET(inter_fd,len+8);
  515. return 0;
  516. }
  517. // Request to leave guild
  518. int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const char *mes)
  519. {
  520. if (CheckForCharServer())
  521. return 0;
  522. WFIFOHEAD(inter_fd, 55);
  523. WFIFOW(inter_fd, 0) = 0x3034;
  524. WFIFOL(inter_fd, 2) = guild_id;
  525. WFIFOL(inter_fd, 6) = account_id;
  526. WFIFOL(inter_fd,10) = char_id;
  527. WFIFOB(inter_fd,14) = flag;
  528. safestrncpy((char*)WFIFOP(inter_fd,15),mes,40);
  529. WFIFOSET(inter_fd,55);
  530. return 0;
  531. }
  532. //Update request / Lv online status of the guild members
  533. int intif_guild_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_)
  534. {
  535. if (CheckForCharServer())
  536. return 0;
  537. WFIFOHEAD(inter_fd, 19);
  538. WFIFOW(inter_fd, 0) = 0x3035;
  539. WFIFOL(inter_fd, 2) = guild_id;
  540. WFIFOL(inter_fd, 6) = account_id;
  541. WFIFOL(inter_fd,10) = char_id;
  542. WFIFOB(inter_fd,14) = online;
  543. WFIFOW(inter_fd,15) = lv;
  544. WFIFOW(inter_fd,17) = class_;
  545. WFIFOSET(inter_fd,19);
  546. return 0;
  547. }
  548. //Guild disbanded notification
  549. int intif_guild_break(int guild_id)
  550. {
  551. if (CheckForCharServer())
  552. return 0;
  553. WFIFOHEAD(inter_fd, 6);
  554. WFIFOW(inter_fd, 0) = 0x3036;
  555. WFIFOL(inter_fd, 2) = guild_id;
  556. WFIFOSET(inter_fd,6);
  557. return 0;
  558. }
  559. // Send a guild message
  560. int intif_guild_message(int guild_id,int account_id,const char *mes,int len)
  561. {
  562. if (CheckForCharServer())
  563. return 0;
  564. if (other_mapserver_count < 1)
  565. return 0; //No need to send.
  566. WFIFOHEAD(inter_fd, len + 12);
  567. WFIFOW(inter_fd,0)=0x3037;
  568. WFIFOW(inter_fd,2)=len+12;
  569. WFIFOL(inter_fd,4)=guild_id;
  570. WFIFOL(inter_fd,8)=account_id;
  571. memcpy(WFIFOP(inter_fd,12),mes,len);
  572. WFIFOSET(inter_fd,len+12);
  573. return 0;
  574. }
  575. // Request a change of Guild basic information
  576. int intif_guild_change_basicinfo(int guild_id,int type,const void *data,int len)
  577. {
  578. if (CheckForCharServer())
  579. return 0;
  580. WFIFOHEAD(inter_fd, len + 10);
  581. WFIFOW(inter_fd,0)=0x3039;
  582. WFIFOW(inter_fd,2)=len+10;
  583. WFIFOL(inter_fd,4)=guild_id;
  584. WFIFOW(inter_fd,8)=type;
  585. memcpy(WFIFOP(inter_fd,10),data,len);
  586. WFIFOSET(inter_fd,len+10);
  587. return 0;
  588. }
  589. // Request a change of Guild member information
  590. int intif_guild_change_memberinfo(int guild_id,int account_id,int char_id,
  591. int type,const void *data,int len)
  592. {
  593. if (CheckForCharServer())
  594. return 0;
  595. WFIFOHEAD(inter_fd, len + 18);
  596. WFIFOW(inter_fd, 0)=0x303a;
  597. WFIFOW(inter_fd, 2)=len+18;
  598. WFIFOL(inter_fd, 4)=guild_id;
  599. WFIFOL(inter_fd, 8)=account_id;
  600. WFIFOL(inter_fd,12)=char_id;
  601. WFIFOW(inter_fd,16)=type;
  602. memcpy(WFIFOP(inter_fd,18),data,len);
  603. WFIFOSET(inter_fd,len+18);
  604. return 0;
  605. }
  606. // Request a change of Guild title
  607. int intif_guild_position(int guild_id,int idx,struct guild_position *p)
  608. {
  609. if (CheckForCharServer())
  610. return 0;
  611. WFIFOHEAD(inter_fd, sizeof(struct guild_position)+12);
  612. WFIFOW(inter_fd,0)=0x303b;
  613. WFIFOW(inter_fd,2)=sizeof(struct guild_position)+12;
  614. WFIFOL(inter_fd,4)=guild_id;
  615. WFIFOL(inter_fd,8)=idx;
  616. memcpy(WFIFOP(inter_fd,12),p,sizeof(struct guild_position));
  617. WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
  618. return 0;
  619. }
  620. // Request an update of Guildskill skillnum
  621. int intif_guild_skillup(int guild_id, int skill_num, int account_id, int max)
  622. {
  623. if( CheckForCharServer() )
  624. return 0;
  625. WFIFOHEAD(inter_fd, 18);
  626. WFIFOW(inter_fd, 0) = 0x303c;
  627. WFIFOL(inter_fd, 2) = guild_id;
  628. WFIFOL(inter_fd, 6) = skill_num;
  629. WFIFOL(inter_fd, 10) = account_id;
  630. WFIFOL(inter_fd, 14) = max;
  631. WFIFOSET(inter_fd, 18);
  632. return 0;
  633. }
  634. // Request a new guild relationship
  635. int intif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag)
  636. {
  637. if (CheckForCharServer())
  638. return 0;
  639. WFIFOHEAD(inter_fd,19);
  640. WFIFOW(inter_fd, 0)=0x303d;
  641. WFIFOL(inter_fd, 2)=guild_id1;
  642. WFIFOL(inter_fd, 6)=guild_id2;
  643. WFIFOL(inter_fd,10)=account_id1;
  644. WFIFOL(inter_fd,14)=account_id2;
  645. WFIFOB(inter_fd,18)=flag;
  646. WFIFOSET(inter_fd,19);
  647. return 0;
  648. }
  649. // Request to change guild notice
  650. int intif_guild_notice(int guild_id,const char *mes1,const char *mes2)
  651. {
  652. if (CheckForCharServer())
  653. return 0;
  654. WFIFOHEAD(inter_fd,186);
  655. WFIFOW(inter_fd,0)=0x303e;
  656. WFIFOL(inter_fd,2)=guild_id;
  657. memcpy(WFIFOP(inter_fd,6),mes1,MAX_GUILDMES1);
  658. memcpy(WFIFOP(inter_fd,66),mes2,MAX_GUILDMES2);
  659. WFIFOSET(inter_fd,186);
  660. return 0;
  661. }
  662. // Request to change guild emblem
  663. int intif_guild_emblem(int guild_id,int len,const char *data)
  664. {
  665. if (CheckForCharServer())
  666. return 0;
  667. if(guild_id<=0 || len<0 || len>2000)
  668. return 0;
  669. WFIFOHEAD(inter_fd,len + 12);
  670. WFIFOW(inter_fd,0)=0x303f;
  671. WFIFOW(inter_fd,2)=len+12;
  672. WFIFOL(inter_fd,4)=guild_id;
  673. WFIFOL(inter_fd,8)=0;
  674. memcpy(WFIFOP(inter_fd,12),data,len);
  675. WFIFOSET(inter_fd,len+12);
  676. return 0;
  677. }
  678. /**
  679. * Requests guild castles data from char-server.
  680. * @param num Number of castles, size of castle_ids array.
  681. * @param castle_ids Pointer to array of castle IDs.
  682. */
  683. int intif_guild_castle_dataload(int num, int *castle_ids)
  684. {
  685. if (CheckForCharServer())
  686. return 0;
  687. WFIFOHEAD(inter_fd, 4 + num * sizeof(int));
  688. WFIFOW(inter_fd, 0) = 0x3040;
  689. WFIFOW(inter_fd, 2) = 4 + num * sizeof(int);
  690. memcpy(WFIFOP(inter_fd, 4), castle_ids, num * sizeof(int));
  691. WFIFOSET(inter_fd, WFIFOW(inter_fd, 2));
  692. return 1;
  693. }
  694. // Request change castle guild owner and save data
  695. int intif_guild_castle_datasave(int castle_id,int index, int value)
  696. {
  697. if (CheckForCharServer())
  698. return 0;
  699. WFIFOHEAD(inter_fd,9);
  700. WFIFOW(inter_fd,0)=0x3041;
  701. WFIFOW(inter_fd,2)=castle_id;
  702. WFIFOB(inter_fd,4)=index;
  703. WFIFOL(inter_fd,5)=value;
  704. WFIFOSET(inter_fd,9);
  705. return 1;
  706. }
  707. //-----------------------------------------------------------------
  708. // Homunculus Packets send to Inter server [albator]
  709. //-----------------------------------------------------------------
  710. int intif_homunculus_create(int account_id, struct s_homunculus *sh)
  711. {
  712. if (CheckForCharServer())
  713. return 0;
  714. WFIFOHEAD(inter_fd, sizeof(struct s_homunculus)+8);
  715. WFIFOW(inter_fd,0) = 0x3090;
  716. WFIFOW(inter_fd,2) = sizeof(struct s_homunculus)+8;
  717. WFIFOL(inter_fd,4) = account_id;
  718. memcpy(WFIFOP(inter_fd,8),sh,sizeof(struct s_homunculus));
  719. WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
  720. return 0;
  721. }
  722. int intif_homunculus_requestload(int account_id, int homun_id)
  723. {
  724. if (CheckForCharServer())
  725. return 0;
  726. WFIFOHEAD(inter_fd, 10);
  727. WFIFOW(inter_fd,0) = 0x3091;
  728. WFIFOL(inter_fd,2) = account_id;
  729. WFIFOL(inter_fd,6) = homun_id;
  730. WFIFOSET(inter_fd, 10);
  731. return 1;
  732. }
  733. int intif_homunculus_requestsave(int account_id, struct s_homunculus* sh)
  734. {
  735. if (CheckForCharServer())
  736. return 0;
  737. WFIFOHEAD(inter_fd, sizeof(struct s_homunculus)+8);
  738. WFIFOW(inter_fd,0) = 0x3092;
  739. WFIFOW(inter_fd,2) = sizeof(struct s_homunculus)+8;
  740. WFIFOL(inter_fd,4) = account_id;
  741. memcpy(WFIFOP(inter_fd,8),sh,sizeof(struct s_homunculus));
  742. WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
  743. return 0;
  744. }
  745. int intif_homunculus_requestdelete(int homun_id)
  746. {
  747. if (CheckForCharServer())
  748. return 0;
  749. WFIFOHEAD(inter_fd, 6);
  750. WFIFOW(inter_fd, 0) = 0x3093;
  751. WFIFOL(inter_fd,2) = homun_id;
  752. WFIFOSET(inter_fd,6);
  753. return 0;
  754. }
  755. //-----------------------------------------------------------------
  756. // Packets receive from inter server
  757. // Wisp/Page reception // rewritten by [Yor]
  758. int intif_parse_WisMessage(int fd)
  759. {
  760. struct map_session_data* sd;
  761. char *wisp_source;
  762. char name[NAME_LENGTH];
  763. int id, i;
  764. id=RFIFOL(fd,4);
  765. safestrncpy(name, (char*)RFIFOP(fd,32), NAME_LENGTH);
  766. sd = map_nick2sd(name);
  767. if(sd == NULL || strcmp(sd->status.name, name) != 0)
  768. { //Not found
  769. intif_wis_replay(id,1);
  770. return 0;
  771. }
  772. if(sd->state.ignoreAll) {
  773. intif_wis_replay(id, 2);
  774. return 0;
  775. }
  776. wisp_source = (char *) RFIFOP(fd,8); // speed up [Yor]
  777. for(i=0; i < MAX_IGNORE_LIST &&
  778. sd->ignore[i].name[0] != '\0' &&
  779. strcmp(sd->ignore[i].name, wisp_source) != 0
  780. ; i++);
  781. if (i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0')
  782. { //Ignored
  783. intif_wis_replay(id, 2);
  784. return 0;
  785. }
  786. //Success to send whisper.
  787. clif_wis_message(sd->fd, wisp_source, (char*)RFIFOP(fd,56),RFIFOW(fd,2)-56);
  788. intif_wis_replay(id,0); // succes
  789. return 0;
  790. }
  791. // Wisp/page transmission result reception
  792. int intif_parse_WisEnd(int fd)
  793. {
  794. struct map_session_data* sd;
  795. if (battle_config.etc_log)
  796. ShowInfo("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
  797. sd = (struct map_session_data *)map_nick2sd((char *) RFIFOP(fd,2));
  798. if (sd != NULL)
  799. clif_wis_end(sd->fd, RFIFOB(fd,26));
  800. return 0;
  801. }
  802. static int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va)
  803. {
  804. int permission = va_arg(va, int);
  805. char *wisp_name;
  806. char *message;
  807. int len;
  808. if (!pc_has_permission(sd, permission))
  809. return 0;
  810. wisp_name = va_arg(va, char*);
  811. message = va_arg(va, char*);
  812. len = va_arg(va, int);
  813. clif_wis_message(sd->fd, wisp_name, message, len);
  814. return 1;
  815. }
  816. // Received wisp message from map-server via char-server for ALL gm
  817. // 0x3003/0x3803 <packet_len>.w <wispname>.24B <permission>.l <message>.?B
  818. int mapif_parse_WisToGM(int fd)
  819. {
  820. int permission, mes_len;
  821. char Wisp_name[NAME_LENGTH];
  822. char mbuf[255];
  823. char *message;
  824. mes_len = RFIFOW(fd,2) - 32;
  825. message = (char *) (mes_len >= 255 ? (char *) aMalloc(mes_len) : mbuf);
  826. permission = RFIFOL(fd,28);
  827. safestrncpy(Wisp_name, (char*)RFIFOP(fd,4), NAME_LENGTH);
  828. safestrncpy(message, (char*)RFIFOP(fd,32), mes_len);
  829. // information is sent to all online GM
  830. map_foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len);
  831. if (message != mbuf)
  832. aFree(message);
  833. return 0;
  834. }
  835. // Request player registre
  836. int intif_parse_Registers(int fd)
  837. {
  838. int j,p,len,max, flag;
  839. struct map_session_data *sd;
  840. struct global_reg *reg;
  841. int *qty;
  842. int account_id = RFIFOL(fd,4), char_id = RFIFOL(fd,8);
  843. struct auth_node *node = chrif_auth_check(account_id, char_id, ST_LOGIN);
  844. if (node)
  845. sd = node->sd;
  846. else { //Normally registries should arrive for in log-in chars.
  847. sd = map_id2sd(account_id);
  848. if (sd && RFIFOB(fd,12) == 3 && sd->status.char_id != char_id)
  849. sd = NULL; //Character registry from another character.
  850. }
  851. if (!sd) return 1;
  852. flag = (sd->save_reg.global_num == -1 || sd->save_reg.account_num == -1 || sd->save_reg.account2_num == -1);
  853. switch (RFIFOB(fd,12)) {
  854. case 3: //Character Registry
  855. reg = sd->save_reg.global;
  856. qty = &sd->save_reg.global_num;
  857. max = GLOBAL_REG_NUM;
  858. break;
  859. case 2: //Account Registry
  860. reg = sd->save_reg.account;
  861. qty = &sd->save_reg.account_num;
  862. max = ACCOUNT_REG_NUM;
  863. break;
  864. case 1: //Account2 Registry
  865. reg = sd->save_reg.account2;
  866. qty = &sd->save_reg.account2_num;
  867. max = ACCOUNT_REG2_NUM;
  868. break;
  869. default:
  870. ShowError("intif_parse_Registers: Unrecognized type %d\n",RFIFOB(fd,12));
  871. return 0;
  872. }
  873. for(j=0,p=13;j<max && p<RFIFOW(fd,2);j++){
  874. sscanf((char*)RFIFOP(fd,p), "%31c%n", reg[j].str,&len);
  875. reg[j].str[len]='\0';
  876. p += len+1; //+1 to skip the '\0' between strings.
  877. sscanf((char*)RFIFOP(fd,p), "%255c%n", reg[j].value,&len);
  878. reg[j].value[len]='\0';
  879. p += len+1;
  880. }
  881. *qty = j;
  882. if (flag && sd->save_reg.global_num > -1 && sd->save_reg.account_num > -1 && sd->save_reg.account2_num > -1)
  883. pc_reg_received(sd); //Received all registry values, execute init scripts and what-not. [Skotlex]
  884. return 1;
  885. }
  886. int intif_parse_LoadGuildStorage(int fd)
  887. {
  888. struct guild_storage *gstor;
  889. struct map_session_data *sd;
  890. int guild_id;
  891. guild_id = RFIFOL(fd,8);
  892. if(guild_id <= 0)
  893. return 1;
  894. sd=map_id2sd( RFIFOL(fd,4) );
  895. if(sd==NULL){
  896. ShowError("intif_parse_LoadGuildStorage: user not found %d\n",RFIFOL(fd,4));
  897. return 1;
  898. }
  899. gstor=guild2storage(guild_id);
  900. if(!gstor) {
  901. ShowWarning("intif_parse_LoadGuildStorage: error guild_id %d not exist\n",guild_id);
  902. return 1;
  903. }
  904. if (gstor->storage_status == 1) { // Already open.. lets ignore this update
  905. ShowWarning("intif_parse_LoadGuildStorage: storage received for a client already open (User %d:%d)\n", sd->status.account_id, sd->status.char_id);
  906. return 1;
  907. }
  908. if (gstor->dirty) { // Already have storage, and it has been modified and not saved yet! Exploit! [Skotlex]
  909. ShowWarning("intif_parse_LoadGuildStorage: received storage for an already modified non-saved storage! (User %d:%d)\n", sd->status.account_id, sd->status.char_id);
  910. return 1;
  911. }
  912. if( RFIFOW(fd,2)-12 != sizeof(struct guild_storage) ){
  913. ShowError("intif_parse_LoadGuildStorage: data size error %d %d\n",RFIFOW(fd,2)-12 , sizeof(struct guild_storage));
  914. gstor->storage_status = 0;
  915. return 1;
  916. }
  917. memcpy(gstor,RFIFOP(fd,12),sizeof(struct guild_storage));
  918. storage_guild_storageopen(sd);
  919. return 0;
  920. }
  921. // ACK guild_storage saved
  922. int intif_parse_SaveGuildStorage(int fd)
  923. {
  924. storage_guild_storagesaved(/*RFIFOL(fd,2), */RFIFOL(fd,6));
  925. return 0;
  926. }
  927. // ACK party creation
  928. int intif_parse_PartyCreated(int fd)
  929. {
  930. if(battle_config.etc_log)
  931. ShowInfo("intif: party created by account %d\n\n", RFIFOL(fd,2));
  932. party_created(RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10),RFIFOL(fd,11), (char *)RFIFOP(fd,15));
  933. return 0;
  934. }
  935. // Receive party info
  936. int intif_parse_PartyInfo(int fd)
  937. {
  938. if( RFIFOW(fd,2) == 12 ){
  939. ShowWarning("intif: party noinfo (char_id=%d party_id=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8));
  940. party_recv_noinfo(RFIFOL(fd,8), RFIFOL(fd,4));
  941. return 0;
  942. }
  943. if( RFIFOW(fd,2) != 8+sizeof(struct party) )
  944. ShowError("intif: party info : data size error (char_id=%d party_id=%d packet_len=%d expected_len=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8), RFIFOW(fd,2), 8+sizeof(struct party));
  945. party_recv_info((struct party *)RFIFOP(fd,8), RFIFOL(fd,4));
  946. return 0;
  947. }
  948. // ACK adding party member
  949. int intif_parse_PartyMemberAdded(int fd)
  950. {
  951. if(battle_config.etc_log)
  952. ShowInfo("intif: party member added Party (%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
  953. party_member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10), RFIFOB(fd, 14));
  954. return 0;
  955. }
  956. // ACK changing party option
  957. int intif_parse_PartyOptionChanged(int fd)
  958. {
  959. party_optionchanged(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOB(fd,14));
  960. return 0;
  961. }
  962. // ACK member leaving party
  963. int intif_parse_PartyMemberWithdraw(int fd)
  964. {
  965. if(battle_config.etc_log)
  966. ShowInfo("intif: party member withdraw: Party(%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
  967. party_member_withdraw(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
  968. return 0;
  969. }
  970. // ACK party break
  971. int intif_parse_PartyBroken(int fd)
  972. {
  973. party_broken(RFIFOL(fd,2));
  974. return 0;
  975. }
  976. // ACK party on new map
  977. int intif_parse_PartyMove(int fd)
  978. {
  979. party_recv_movemap(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOW(fd,14),RFIFOB(fd,16),RFIFOW(fd,17));
  980. return 0;
  981. }
  982. // ACK party messages
  983. int intif_parse_PartyMessage(int fd)
  984. {
  985. party_recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12);
  986. return 0;
  987. }
  988. // ACK guild creation
  989. int intif_parse_GuildCreated(int fd)
  990. {
  991. guild_created(RFIFOL(fd,2),RFIFOL(fd,6));
  992. return 0;
  993. }
  994. // ACK guild infos
  995. int intif_parse_GuildInfo(int fd)
  996. {
  997. if(RFIFOW(fd,2) == 8) {
  998. ShowWarning("intif: guild noinfo %d\n",RFIFOL(fd,4));
  999. guild_recv_noinfo(RFIFOL(fd,4));
  1000. return 0;
  1001. }
  1002. if( RFIFOW(fd,2)!=sizeof(struct guild)+4 )
  1003. ShowError("intif: guild info : data size error Gid: %d recv size: %d Expected size: %d\n",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild)+4);
  1004. guild_recv_info((struct guild *)RFIFOP(fd,4));
  1005. return 0;
  1006. }
  1007. // ACK adding guild member
  1008. int intif_parse_GuildMemberAdded(int fd)
  1009. {
  1010. if(battle_config.etc_log)
  1011. ShowInfo("intif: guild member added %d %d %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14));
  1012. guild_member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14));
  1013. return 0;
  1014. }
  1015. // ACK member leaving guild
  1016. int intif_parse_GuildMemberWithdraw(int fd)
  1017. {
  1018. guild_member_withdraw(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),(char *)RFIFOP(fd,55),(char *)RFIFOP(fd,15));
  1019. return 0;
  1020. }
  1021. // ACK guild member basic info
  1022. int intif_parse_GuildMemberInfoShort(int fd)
  1023. {
  1024. guild_recv_memberinfoshort(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17));
  1025. return 0;
  1026. }
  1027. // ACK guild break
  1028. int intif_parse_GuildBroken(int fd)
  1029. {
  1030. guild_broken(RFIFOL(fd,2),RFIFOB(fd,6));
  1031. return 0;
  1032. }
  1033. // basic guild info change notice
  1034. // 0x3839 <packet len>.w <guild id>.l <type>.w <data>.?b
  1035. int intif_parse_GuildBasicInfoChanged(int fd)
  1036. {
  1037. //int len = RFIFOW(fd,2) - 10;
  1038. int guild_id = RFIFOL(fd,4);
  1039. int type = RFIFOW(fd,8);
  1040. //void* data = RFIFOP(fd,10);
  1041. struct guild* g = guild_search(guild_id);
  1042. if( g == NULL )
  1043. return 0;
  1044. switch(type) {
  1045. case GBI_EXP: g->exp = RFIFOQ(fd,10); break;
  1046. case GBI_GUILDLV: g->guild_lv = RFIFOW(fd,10); break;
  1047. case GBI_SKILLPOINT: g->skill_point = RFIFOL(fd,10); break;
  1048. }
  1049. return 0;
  1050. }
  1051. // guild member info change notice
  1052. // 0x383a <packet len>.w <guild id>.l <account id>.l <char id>.l <type>.w <data>.?b
  1053. int intif_parse_GuildMemberInfoChanged(int fd)
  1054. {
  1055. //int len = RFIFOW(fd,2) - 18;
  1056. int guild_id = RFIFOL(fd,4);
  1057. int account_id = RFIFOL(fd,8);
  1058. int char_id = RFIFOL(fd,12);
  1059. int type = RFIFOW(fd,16);
  1060. //void* data = RFIFOP(fd,18);
  1061. struct guild* g;
  1062. int idx;
  1063. g = guild_search(guild_id);
  1064. if( g == NULL )
  1065. return 0;
  1066. idx = guild_getindex(g,account_id,char_id);
  1067. if( idx == -1 )
  1068. return 0;
  1069. switch( type ) {
  1070. case GMI_POSITION: g->member[idx].position = RFIFOW(fd,18); guild_memberposition_changed(g,idx,RFIFOW(fd,18)); break;
  1071. case GMI_EXP: g->member[idx].exp = RFIFOQ(fd,18); break;
  1072. case GMI_HAIR: g->member[idx].hair = RFIFOW(fd,18); break;
  1073. case GMI_HAIR_COLOR: g->member[idx].hair_color = RFIFOW(fd,18); break;
  1074. case GMI_GENDER: g->member[idx].gender = RFIFOW(fd,18); break;
  1075. case GMI_CLASS: g->member[idx].class_ = RFIFOW(fd,18); break;
  1076. case GMI_LEVEL: g->member[idx].lv = RFIFOW(fd,18); break;
  1077. }
  1078. return 0;
  1079. }
  1080. // ACK change of guild title
  1081. int intif_parse_GuildPosition(int fd)
  1082. {
  1083. if( RFIFOW(fd,2)!=sizeof(struct guild_position)+12 )
  1084. ShowError("intif: guild info : data size error\n %d %d %d",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild_position)+12);
  1085. guild_position_changed(RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12));
  1086. return 0;
  1087. }
  1088. // ACK change of guild skill update
  1089. int intif_parse_GuildSkillUp(int fd)
  1090. {
  1091. guild_skillupack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
  1092. return 0;
  1093. }
  1094. // ACK change of guild relationship
  1095. int intif_parse_GuildAlliance(int fd)
  1096. {
  1097. guild_allianceack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),RFIFOB(fd,18),(char *) RFIFOP(fd,19),(char *) RFIFOP(fd,43));
  1098. return 0;
  1099. }
  1100. // ACK change of guild notice
  1101. int intif_parse_GuildNotice(int fd)
  1102. {
  1103. guild_notice_changed(RFIFOL(fd,2),(char *) RFIFOP(fd,6),(char *) RFIFOP(fd,66));
  1104. return 0;
  1105. }
  1106. // ACK change of guild emblem
  1107. int intif_parse_GuildEmblem(int fd)
  1108. {
  1109. guild_emblem_changed(RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8), (char *)RFIFOP(fd,12));
  1110. return 0;
  1111. }
  1112. // ACK guild message
  1113. int intif_parse_GuildMessage(int fd)
  1114. {
  1115. guild_recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12);
  1116. return 0;
  1117. }
  1118. // Reply guild castle data request
  1119. int intif_parse_GuildCastleDataLoad(int fd)
  1120. {
  1121. return guild_castledataloadack(RFIFOW(fd,2), (struct guild_castle *)RFIFOP(fd,4));
  1122. }
  1123. // ACK change of guildmaster
  1124. int intif_parse_GuildMasterChanged(int fd)
  1125. {
  1126. return guild_gm_changed(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
  1127. }
  1128. // Request pet creation
  1129. int intif_parse_CreatePet(int fd)
  1130. {
  1131. pet_get_egg(RFIFOL(fd,2),RFIFOL(fd,7),RFIFOB(fd,6));
  1132. return 0;
  1133. }
  1134. // ACK pet data
  1135. int intif_parse_RecvPetData(int fd)
  1136. {
  1137. struct s_pet p;
  1138. int len;
  1139. len=RFIFOW(fd,2);
  1140. if(sizeof(struct s_pet)!=len-9) {
  1141. if(battle_config.etc_log)
  1142. ShowError("intif: pet data: data size error %d %d\n",sizeof(struct s_pet),len-9);
  1143. }
  1144. else{
  1145. memcpy(&p,RFIFOP(fd,9),sizeof(struct s_pet));
  1146. pet_recv_petdata(RFIFOL(fd,4),&p,RFIFOB(fd,8));
  1147. }
  1148. return 0;
  1149. }
  1150. // ACK pet save data
  1151. int intif_parse_SavePetOk(int fd)
  1152. {
  1153. if(RFIFOB(fd,6) == 1)
  1154. ShowError("pet data save failure\n");
  1155. return 0;
  1156. }
  1157. // ACK deleting pet
  1158. int intif_parse_DeletePetOk(int fd)
  1159. {
  1160. if(RFIFOB(fd,2) == 1)
  1161. ShowError("pet data delete failure\n");
  1162. return 0;
  1163. }
  1164. // ACK changing name resquest, players,pets,hommon
  1165. int intif_parse_ChangeNameOk(int fd)
  1166. {
  1167. struct map_session_data *sd = NULL;
  1168. if((sd=map_id2sd(RFIFOL(fd,2)))==NULL ||
  1169. sd->status.char_id != RFIFOL(fd,6))
  1170. return 0;
  1171. switch (RFIFOB(fd,10)) {
  1172. case 0: //Players [NOT SUPPORTED YET]
  1173. break;
  1174. case 1: //Pets
  1175. pet_change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11));
  1176. break;
  1177. case 2: //Hom
  1178. merc_hom_change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11));
  1179. break;
  1180. }
  1181. return 0;
  1182. }
  1183. //----------------------------------------------------------------
  1184. // Homunculus recv packets [albator]
  1185. int intif_parse_CreateHomunculus(int fd)
  1186. {
  1187. int len;
  1188. len=RFIFOW(fd,2)-9;
  1189. if(sizeof(struct s_homunculus)!=len) {
  1190. if(battle_config.etc_log)
  1191. ShowError("intif: create homun data: data size error %d != %d\n",sizeof(struct s_homunculus),len);
  1192. return 0;
  1193. }
  1194. merc_hom_recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8)) ;
  1195. return 0;
  1196. }
  1197. int intif_parse_RecvHomunculusData(int fd)
  1198. {
  1199. int len;
  1200. len=RFIFOW(fd,2)-9;
  1201. if(sizeof(struct s_homunculus)!=len) {
  1202. if(battle_config.etc_log)
  1203. ShowError("intif: homun data: data size error %d %d\n",sizeof(struct s_homunculus),len);
  1204. return 0;
  1205. }
  1206. merc_hom_recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8));
  1207. return 0;
  1208. }
  1209. int intif_parse_SaveHomunculusOk(int fd)
  1210. {
  1211. if(RFIFOB(fd,6) != 1)
  1212. ShowError("homunculus data save failure for account %d\n", RFIFOL(fd,2));
  1213. return 0;
  1214. }
  1215. int intif_parse_DeleteHomunculusOk(int fd)
  1216. {
  1217. if(RFIFOB(fd,2) != 1)
  1218. ShowError("Homunculus data delete failure\n");
  1219. return 0;
  1220. }
  1221. /**************************************
  1222. QUESTLOG SYSTEM FUNCTIONS
  1223. ***************************************/
  1224. int intif_request_questlog(TBL_PC *sd)
  1225. {
  1226. WFIFOHEAD(inter_fd,6);
  1227. WFIFOW(inter_fd,0) = 0x3060;
  1228. WFIFOL(inter_fd,2) = sd->status.char_id;
  1229. WFIFOSET(inter_fd,6);
  1230. return 0;
  1231. }
  1232. int intif_parse_questlog(int fd)
  1233. {
  1234. int char_id = RFIFOL(fd, 4);
  1235. int i;
  1236. TBL_PC * sd = map_charid2sd(char_id);
  1237. //User not online anymore
  1238. if(!sd)
  1239. return -1;
  1240. sd->avail_quests = sd->num_quests = (RFIFOW(fd, 2)-8)/sizeof(struct quest);
  1241. memset(&sd->quest_log, 0, sizeof(sd->quest_log));
  1242. for( i = 0; i < sd->num_quests; i++ )
  1243. {
  1244. memcpy(&sd->quest_log[i], RFIFOP(fd, i*sizeof(struct quest)+8), sizeof(struct quest));
  1245. sd->quest_index[i] = quest_search_db(sd->quest_log[i].quest_id);
  1246. if( sd->quest_index[i] < 0 )
  1247. {
  1248. ShowError("intif_parse_questlog: quest %d not found in DB.\n",sd->quest_log[i].quest_id);
  1249. sd->avail_quests--;
  1250. sd->num_quests--;
  1251. i--;
  1252. continue;
  1253. }
  1254. if( sd->quest_log[i].state == Q_COMPLETE )
  1255. sd->avail_quests--;
  1256. }
  1257. quest_pc_login(sd);
  1258. return 0;
  1259. }
  1260. int intif_parse_questsave(int fd)
  1261. {
  1262. int cid = RFIFOL(fd, 2);
  1263. TBL_PC *sd = map_id2sd(cid);
  1264. if( !RFIFOB(fd, 6) )
  1265. ShowError("intif_parse_questsave: Failed to save quest(s) for character %d!\n", cid);
  1266. else if( sd )
  1267. sd->save_quest = false;
  1268. return 0;
  1269. }
  1270. int intif_quest_save(TBL_PC *sd)
  1271. {
  1272. int len;
  1273. if(CheckForCharServer())
  1274. return 0;
  1275. len = sizeof(struct quest)*sd->num_quests + 8;
  1276. WFIFOHEAD(inter_fd, len);
  1277. WFIFOW(inter_fd,0) = 0x3061;
  1278. WFIFOW(inter_fd,2) = len;
  1279. WFIFOL(inter_fd,4) = sd->status.char_id;
  1280. if( sd->num_quests )
  1281. memcpy(WFIFOP(inter_fd,8), &sd->quest_log, sizeof(struct quest)*sd->num_quests);
  1282. WFIFOSET(inter_fd, len);
  1283. return 0;
  1284. }
  1285. /*==========================================
  1286. * MAIL SYSTEM
  1287. * By Zephyrus
  1288. *==========================================*/
  1289. /*------------------------------------------
  1290. * Inbox Request
  1291. * flag: 0 Update Inbox | 1 OpenMail
  1292. *------------------------------------------*/
  1293. int intif_Mail_requestinbox(int char_id, unsigned char flag)
  1294. {
  1295. if (CheckForCharServer())
  1296. return 0;
  1297. WFIFOHEAD(inter_fd,7);
  1298. WFIFOW(inter_fd,0) = 0x3048;
  1299. WFIFOL(inter_fd,2) = char_id;
  1300. WFIFOB(inter_fd,6) = flag;
  1301. WFIFOSET(inter_fd,7);
  1302. return 0;
  1303. }
  1304. int intif_parse_Mail_inboxreceived(int fd)
  1305. {
  1306. struct map_session_data *sd;
  1307. unsigned char flag = RFIFOB(fd,8);
  1308. sd = map_charid2sd(RFIFOL(fd,4));
  1309. if (sd == NULL)
  1310. {
  1311. ShowError("intif_parse_Mail_inboxreceived: char not found %d\n",RFIFOL(fd,4));
  1312. return 1;
  1313. }
  1314. if (RFIFOW(fd,2) - 9 != sizeof(struct mail_data))
  1315. {
  1316. ShowError("intif_parse_Mail_inboxreceived: data size error %d %d\n", RFIFOW(fd,2) - 9, sizeof(struct mail_data));
  1317. return 1;
  1318. }
  1319. //FIXME: this operation is not safe [ultramage]
  1320. memcpy(&sd->mail.inbox, RFIFOP(fd,9), sizeof(struct mail_data));
  1321. sd->mail.changed = false; // cache is now in sync
  1322. if (flag)
  1323. clif_Mail_refreshinbox(sd);
  1324. else if( battle_config.mail_show_status && ( battle_config.mail_show_status == 1 || sd->mail.inbox.unread ) )
  1325. {
  1326. char output[128];
  1327. sprintf(output, msg_txt(510), sd->mail.inbox.unchecked, sd->mail.inbox.unread + sd->mail.inbox.unchecked);
  1328. clif_disp_onlyself(sd, output, strlen(output));
  1329. }
  1330. return 0;
  1331. }
  1332. /*------------------------------------------
  1333. * Mail Read
  1334. *------------------------------------------*/
  1335. int intif_Mail_read(int mail_id)
  1336. {
  1337. if (CheckForCharServer())
  1338. return 0;
  1339. WFIFOHEAD(inter_fd,6);
  1340. WFIFOW(inter_fd,0) = 0x3049;
  1341. WFIFOL(inter_fd,2) = mail_id;
  1342. WFIFOSET(inter_fd,6);
  1343. return 0;
  1344. }
  1345. /*------------------------------------------
  1346. * Get Attachment
  1347. *------------------------------------------*/
  1348. int intif_Mail_getattach(int char_id, int mail_id)
  1349. {
  1350. if (CheckForCharServer())
  1351. return 0;
  1352. WFIFOHEAD(inter_fd,10);
  1353. WFIFOW(inter_fd,0) = 0x304a;
  1354. WFIFOL(inter_fd,2) = char_id;
  1355. WFIFOL(inter_fd,6) = mail_id;
  1356. WFIFOSET(inter_fd, 10);
  1357. return 0;
  1358. }
  1359. int intif_parse_Mail_getattach(int fd)
  1360. {
  1361. struct map_session_data *sd;
  1362. struct item item;
  1363. int zeny = RFIFOL(fd,8);
  1364. sd = map_charid2sd( RFIFOL(fd,4) );
  1365. if (sd == NULL)
  1366. {
  1367. ShowError("intif_parse_Mail_getattach: char not found %d\n",RFIFOL(fd,4));
  1368. return 1;
  1369. }
  1370. if (RFIFOW(fd,2) - 12 != sizeof(struct item))
  1371. {
  1372. ShowError("intif_parse_Mail_getattach: data size error %d %d\n", RFIFOW(fd,2) - 16, sizeof(struct item));
  1373. return 1;
  1374. }
  1375. memcpy(&item, RFIFOP(fd,12), sizeof(struct item));
  1376. mail_getattachment(sd, zeny, &item);
  1377. return 0;
  1378. }
  1379. /*------------------------------------------
  1380. * Delete Message
  1381. *------------------------------------------*/
  1382. int intif_Mail_delete(int char_id, int mail_id)
  1383. {
  1384. if (CheckForCharServer())
  1385. return 0;
  1386. WFIFOHEAD(inter_fd,10);
  1387. WFIFOW(inter_fd,0) = 0x304b;
  1388. WFIFOL(inter_fd,2) = char_id;
  1389. WFIFOL(inter_fd,6) = mail_id;
  1390. WFIFOSET(inter_fd,10);
  1391. return 0;
  1392. }
  1393. int intif_parse_Mail_delete(int fd)
  1394. {
  1395. int char_id = RFIFOL(fd,2);
  1396. int mail_id = RFIFOL(fd,6);
  1397. bool failed = RFIFOB(fd,10);
  1398. struct map_session_data *sd = map_charid2sd(char_id);
  1399. if (sd == NULL)
  1400. {
  1401. ShowError("intif_parse_Mail_delete: char not found %d\n", char_id);
  1402. return 1;
  1403. }
  1404. if (!failed)
  1405. {
  1406. int i;
  1407. ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
  1408. if( i < MAIL_MAX_INBOX )
  1409. {
  1410. memset(&sd->mail.inbox.msg[i], 0, sizeof(struct mail_message));
  1411. sd->mail.inbox.amount--;
  1412. }
  1413. if( sd->mail.inbox.full )
  1414. intif_Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails
  1415. }
  1416. clif_Mail_delete(sd->fd, mail_id, failed);
  1417. return 0;
  1418. }
  1419. /*------------------------------------------
  1420. * Return Message
  1421. *------------------------------------------*/
  1422. int intif_Mail_return(int char_id, int mail_id)
  1423. {
  1424. if (CheckForCharServer())
  1425. return 0;
  1426. WFIFOHEAD(inter_fd,10);
  1427. WFIFOW(inter_fd,0) = 0x304c;
  1428. WFIFOL(inter_fd,2) = char_id;
  1429. WFIFOL(inter_fd,6) = mail_id;
  1430. WFIFOSET(inter_fd,10);
  1431. return 0;
  1432. }
  1433. int intif_parse_Mail_return(int fd)
  1434. {
  1435. struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
  1436. int mail_id = RFIFOL(fd,6);
  1437. short fail = RFIFOB(fd,10);
  1438. if( sd == NULL )
  1439. {
  1440. ShowError("intif_parse_Mail_return: char not found %d\n",RFIFOL(fd,2));
  1441. return 1;
  1442. }
  1443. if( !fail )
  1444. {
  1445. int i;
  1446. ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
  1447. if( i < MAIL_MAX_INBOX )
  1448. {
  1449. memset(&sd->mail.inbox.msg[i], 0, sizeof(struct mail_message));
  1450. sd->mail.inbox.amount--;
  1451. }
  1452. if( sd->mail.inbox.full )
  1453. intif_Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails
  1454. }
  1455. clif_Mail_return(sd->fd, mail_id, fail);
  1456. return 0;
  1457. }
  1458. /*------------------------------------------
  1459. * Send Mail
  1460. *------------------------------------------*/
  1461. int intif_Mail_send(int account_id, struct mail_message *msg)
  1462. {
  1463. int len = sizeof(struct mail_message) + 8;
  1464. if (CheckForCharServer())
  1465. return 0;
  1466. WFIFOHEAD(inter_fd,len);
  1467. WFIFOW(inter_fd,0) = 0x304d;
  1468. WFIFOW(inter_fd,2) = len;
  1469. WFIFOL(inter_fd,4) = account_id;
  1470. memcpy(WFIFOP(inter_fd,8), msg, sizeof(struct mail_message));
  1471. WFIFOSET(inter_fd,len);
  1472. return 1;
  1473. }
  1474. static void intif_parse_Mail_send(int fd)
  1475. {
  1476. struct mail_message msg;
  1477. struct map_session_data *sd;
  1478. bool fail;
  1479. if( RFIFOW(fd,2) - 4 != sizeof(struct mail_message) )
  1480. {
  1481. ShowError("intif_parse_Mail_send: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct mail_message));
  1482. return;
  1483. }
  1484. memcpy(&msg, RFIFOP(fd,4), sizeof(struct mail_message));
  1485. fail = (msg.id == 0);
  1486. // notify sender
  1487. sd = map_charid2sd(msg.send_id);
  1488. if( sd != NULL )
  1489. {
  1490. if( fail )
  1491. mail_deliveryfail(sd, &msg);
  1492. else
  1493. {
  1494. clif_Mail_send(sd->fd, false);
  1495. if( save_settings&16 )
  1496. chrif_save(sd, 0);
  1497. }
  1498. }
  1499. }
  1500. static void intif_parse_Mail_new(int fd)
  1501. {
  1502. struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
  1503. int mail_id = RFIFOL(fd,6);
  1504. const char* sender_name = (char*)RFIFOP(fd,10);
  1505. const char* title = (char*)RFIFOP(fd,34);
  1506. if( sd == NULL )
  1507. return;
  1508. sd->mail.changed = true;
  1509. clif_Mail_new(sd->fd, mail_id, sender_name, title);
  1510. }
  1511. /*==========================================
  1512. * AUCTION SYSTEM
  1513. * By Zephyrus
  1514. *==========================================*/
  1515. int intif_Auction_requestlist(int char_id, short type, int price, const char* searchtext, short page)
  1516. {
  1517. int len = NAME_LENGTH + 16;
  1518. if( CheckForCharServer() )
  1519. return 0;
  1520. WFIFOHEAD(inter_fd,len);
  1521. WFIFOW(inter_fd,0) = 0x3050;
  1522. WFIFOW(inter_fd,2) = len;
  1523. WFIFOL(inter_fd,4) = char_id;
  1524. WFIFOW(inter_fd,8) = type;
  1525. WFIFOL(inter_fd,10) = price;
  1526. WFIFOW(inter_fd,14) = page;
  1527. memcpy(WFIFOP(inter_fd,16), searchtext, NAME_LENGTH);
  1528. WFIFOSET(inter_fd,len);
  1529. return 0;
  1530. }
  1531. static void intif_parse_Auction_results(int fd)
  1532. {
  1533. struct map_session_data *sd = map_charid2sd(RFIFOL(fd,4));
  1534. short count = RFIFOW(fd,8);
  1535. short pages = RFIFOW(fd,10);
  1536. uint8* data = RFIFOP(fd,12);
  1537. if( sd == NULL )
  1538. return;
  1539. clif_Auction_results(sd, count, pages, data);
  1540. }
  1541. int intif_Auction_register(struct auction_data *auction)
  1542. {
  1543. int len = sizeof(struct auction_data) + 4;
  1544. if( CheckForCharServer() )
  1545. return 0;
  1546. WFIFOHEAD(inter_fd,len);
  1547. WFIFOW(inter_fd,0) = 0x3051;
  1548. WFIFOW(inter_fd,2) = len;
  1549. memcpy(WFIFOP(inter_fd,4), auction, sizeof(struct auction_data));
  1550. WFIFOSET(inter_fd,len);
  1551. return 1;
  1552. }
  1553. static void intif_parse_Auction_register(int fd)
  1554. {
  1555. struct map_session_data *sd;
  1556. struct auction_data auction;
  1557. if( RFIFOW(fd,2) - 4 != sizeof(struct auction_data) )
  1558. {
  1559. ShowError("intif_parse_Auction_register: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct auction_data));
  1560. return;
  1561. }
  1562. memcpy(&auction, RFIFOP(fd,4), sizeof(struct auction_data));
  1563. if( (sd = map_charid2sd(auction.seller_id)) == NULL )
  1564. return;
  1565. if( auction.auction_id > 0 )
  1566. {
  1567. clif_Auction_message(sd->fd, 1); // Confirmation Packet ??
  1568. if( save_settings&32 )
  1569. chrif_save(sd,0);
  1570. }
  1571. else
  1572. {
  1573. int zeny = auction.hours*battle_config.auction_feeperhour;
  1574. clif_Auction_message(sd->fd, 4);
  1575. pc_additem(sd, &auction.item, auction.item.amount, LOG_TYPE_AUCTION);
  1576. log_zeny(sd, LOG_TYPE_AUCTION, sd, zeny);
  1577. pc_getzeny(sd, zeny);
  1578. }
  1579. }
  1580. int intif_Auction_cancel(int char_id, unsigned int auction_id)
  1581. {
  1582. if( CheckForCharServer() )
  1583. return 0;
  1584. WFIFOHEAD(inter_fd,10);
  1585. WFIFOW(inter_fd,0) = 0x3052;
  1586. WFIFOL(inter_fd,2) = char_id;
  1587. WFIFOL(inter_fd,6) = auction_id;
  1588. WFIFOSET(inter_fd,10);
  1589. return 0;
  1590. }
  1591. static void intif_parse_Auction_cancel(int fd)
  1592. {
  1593. struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
  1594. int result = RFIFOB(fd,6);
  1595. if( sd == NULL )
  1596. return;
  1597. switch( result )
  1598. {
  1599. case 0: clif_Auction_message(sd->fd, 2); break;
  1600. case 1: clif_Auction_close(sd->fd, 2); break;
  1601. case 2: clif_Auction_close(sd->fd, 1); break;
  1602. case 3: clif_Auction_message(sd->fd, 3); break;
  1603. }
  1604. }
  1605. int intif_Auction_close(int char_id, unsigned int auction_id)
  1606. {
  1607. if( CheckForCharServer() )
  1608. return 0;
  1609. WFIFOHEAD(inter_fd,10);
  1610. WFIFOW(inter_fd,0) = 0x3053;
  1611. WFIFOL(inter_fd,2) = char_id;
  1612. WFIFOL(inter_fd,6) = auction_id;
  1613. WFIFOSET(inter_fd,10);
  1614. return 0;
  1615. }
  1616. static void intif_parse_Auction_close(int fd)
  1617. {
  1618. struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
  1619. unsigned char result = RFIFOB(fd,6);
  1620. if( sd == NULL )
  1621. return;
  1622. clif_Auction_close(sd->fd, result);
  1623. if( result == 0 )
  1624. {
  1625. // FIXME: Leeching off a parse function
  1626. clif_parse_Auction_cancelreg(fd, sd);
  1627. intif_Auction_requestlist(sd->status.char_id, 6, 0, "", 1);
  1628. }
  1629. }
  1630. int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, int bid)
  1631. {
  1632. int len = 16 + NAME_LENGTH;
  1633. if( CheckForCharServer() )
  1634. return 0;
  1635. WFIFOHEAD(inter_fd,len);
  1636. WFIFOW(inter_fd,0) = 0x3055;
  1637. WFIFOW(inter_fd,2) = len;
  1638. WFIFOL(inter_fd,4) = char_id;
  1639. WFIFOL(inter_fd,8) = auction_id;
  1640. WFIFOL(inter_fd,12) = bid;
  1641. memcpy(WFIFOP(inter_fd,16), name, NAME_LENGTH);
  1642. WFIFOSET(inter_fd,len);
  1643. return 0;
  1644. }
  1645. static void intif_parse_Auction_bid(int fd)
  1646. {
  1647. struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
  1648. int bid = RFIFOL(fd,6);
  1649. unsigned char result = RFIFOB(fd,10);
  1650. if( sd == NULL )
  1651. return;
  1652. clif_Auction_message(sd->fd, result);
  1653. if( bid > 0 )
  1654. {
  1655. log_zeny(sd, LOG_TYPE_AUCTION, sd, bid);
  1656. pc_getzeny(sd, bid);
  1657. }
  1658. if( result == 1 )
  1659. { // To update the list, display your buy list
  1660. clif_parse_Auction_cancelreg(fd, sd);
  1661. intif_Auction_requestlist(sd->status.char_id, 7, 0, "", 1);
  1662. }
  1663. }
  1664. // Used to send 'You have won the auction' and 'You failed to won the auction' messages
  1665. static void intif_parse_Auction_message(int fd)
  1666. {
  1667. struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
  1668. unsigned char result = RFIFOB(fd,6);
  1669. if( sd == NULL )
  1670. return;
  1671. clif_Auction_message(sd->fd, result);
  1672. }
  1673. /*==========================================
  1674. * Mercenary's System
  1675. *------------------------------------------*/
  1676. int intif_mercenary_create(struct s_mercenary *merc)
  1677. {
  1678. int size = sizeof(struct s_mercenary) + 4;
  1679. if( CheckForCharServer() )
  1680. return 0;
  1681. WFIFOHEAD(inter_fd,size);
  1682. WFIFOW(inter_fd,0) = 0x3070;
  1683. WFIFOW(inter_fd,2) = size;
  1684. memcpy(WFIFOP(inter_fd,4), merc, sizeof(struct s_mercenary));
  1685. WFIFOSET(inter_fd,size);
  1686. return 0;
  1687. }
  1688. int intif_parse_mercenary_received(int fd)
  1689. {
  1690. int len = RFIFOW(fd,2) - 5;
  1691. if( sizeof(struct s_mercenary) != len )
  1692. {
  1693. if( battle_config.etc_log )
  1694. ShowError("intif: create mercenary data size error %d != %d\n", sizeof(struct s_mercenary), len);
  1695. return 0;
  1696. }
  1697. merc_data_received((struct s_mercenary*)RFIFOP(fd,5), RFIFOB(fd,4));
  1698. return 0;
  1699. }
  1700. int intif_mercenary_request(int merc_id, int char_id)
  1701. {
  1702. if (CheckForCharServer())
  1703. return 0;
  1704. WFIFOHEAD(inter_fd,10);
  1705. WFIFOW(inter_fd,0) = 0x3071;
  1706. WFIFOL(inter_fd,2) = merc_id;
  1707. WFIFOL(inter_fd,6) = char_id;
  1708. WFIFOSET(inter_fd,10);
  1709. return 0;
  1710. }
  1711. int intif_mercenary_delete(int merc_id)
  1712. {
  1713. if (CheckForCharServer())
  1714. return 0;
  1715. WFIFOHEAD(inter_fd,6);
  1716. WFIFOW(inter_fd,0) = 0x3072;
  1717. WFIFOL(inter_fd,2) = merc_id;
  1718. WFIFOSET(inter_fd,6);
  1719. return 0;
  1720. }
  1721. int intif_parse_mercenary_deleted(int fd)
  1722. {
  1723. if( RFIFOB(fd,2) != 1 )
  1724. ShowError("Mercenary data delete failure\n");
  1725. return 0;
  1726. }
  1727. int intif_mercenary_save(struct s_mercenary *merc)
  1728. {
  1729. int size = sizeof(struct s_mercenary) + 4;
  1730. if( CheckForCharServer() )
  1731. return 0;
  1732. WFIFOHEAD(inter_fd,size);
  1733. WFIFOW(inter_fd,0) = 0x3073;
  1734. WFIFOW(inter_fd,2) = size;
  1735. memcpy(WFIFOP(inter_fd,4), merc, sizeof(struct s_mercenary));
  1736. WFIFOSET(inter_fd,size);
  1737. return 0;
  1738. }
  1739. int intif_parse_mercenary_saved(int fd)
  1740. {
  1741. if( RFIFOB(fd,2) != 1 )
  1742. ShowError("Mercenary data save failure\n");
  1743. return 0;
  1744. }
  1745. /*==========================================
  1746. * Elemental's System
  1747. *------------------------------------------*/
  1748. int intif_elemental_create(struct s_elemental *ele)
  1749. {
  1750. int size = sizeof(struct s_elemental) + 4;
  1751. if( CheckForCharServer() )
  1752. return 0;
  1753. WFIFOHEAD(inter_fd,size);
  1754. WFIFOW(inter_fd,0) = 0x307c;
  1755. WFIFOW(inter_fd,2) = size;
  1756. memcpy(WFIFOP(inter_fd,4), ele, sizeof(struct s_elemental));
  1757. WFIFOSET(inter_fd,size);
  1758. return 0;
  1759. }
  1760. int intif_parse_elemental_received(int fd)
  1761. {
  1762. int len = RFIFOW(fd,2) - 5;
  1763. if( sizeof(struct s_elemental) != len )
  1764. {
  1765. if( battle_config.etc_log )
  1766. ShowError("intif: create elemental data size error %d != %d\n", sizeof(struct s_elemental), len);
  1767. return 0;
  1768. }
  1769. elemental_data_received((struct s_elemental*)RFIFOP(fd,5), RFIFOB(fd,4));
  1770. return 0;
  1771. }
  1772. int intif_elemental_request(int ele_id, int char_id)
  1773. {
  1774. if (CheckForCharServer())
  1775. return 0;
  1776. WFIFOHEAD(inter_fd,10);
  1777. WFIFOW(inter_fd,0) = 0x307d;
  1778. WFIFOL(inter_fd,2) = ele_id;
  1779. WFIFOL(inter_fd,6) = char_id;
  1780. WFIFOSET(inter_fd,10);
  1781. return 0;
  1782. }
  1783. int intif_elemental_delete(int ele_id)
  1784. {
  1785. if (CheckForCharServer())
  1786. return 0;
  1787. WFIFOHEAD(inter_fd,6);
  1788. WFIFOW(inter_fd,0) = 0x307e;
  1789. WFIFOL(inter_fd,2) = ele_id;
  1790. WFIFOSET(inter_fd,6);
  1791. return 0;
  1792. }
  1793. int intif_parse_elemental_deleted(int fd)
  1794. {
  1795. if( RFIFOB(fd,2) != 1 )
  1796. ShowError("Elemental data delete failure\n");
  1797. return 0;
  1798. }
  1799. int intif_elemental_save(struct s_elemental *ele)
  1800. {
  1801. int size = sizeof(struct s_elemental) + 4;
  1802. if( CheckForCharServer() )
  1803. return 0;
  1804. WFIFOHEAD(inter_fd,size);
  1805. WFIFOW(inter_fd,0) = 0x307f;
  1806. WFIFOW(inter_fd,2) = size;
  1807. memcpy(WFIFOP(inter_fd,4), ele, sizeof(struct s_elemental));
  1808. WFIFOSET(inter_fd,size);
  1809. return 0;
  1810. }
  1811. int intif_parse_elemental_saved(int fd)
  1812. {
  1813. if( RFIFOB(fd,2) != 1 )
  1814. ShowError("Elemental data save failure\n");
  1815. return 0;
  1816. }
  1817. void intif_request_accinfo( int u_fd, int aid, int group_id, char* query ) {
  1818. WFIFOHEAD(inter_fd,2 + 4 + 4 + 4 + NAME_LENGTH);
  1819. WFIFOW(inter_fd,0) = 0x3007;
  1820. WFIFOL(inter_fd,2) = u_fd;
  1821. WFIFOL(inter_fd,6) = aid;
  1822. WFIFOL(inter_fd,10) = group_id;
  1823. safestrncpy(WFIFOP(inter_fd,14), query, NAME_LENGTH);
  1824. WFIFOSET(inter_fd,2 + 4 + 4 + 4 + NAME_LENGTH);
  1825. return;
  1826. }
  1827. void intif_parse_MessageToFD(int fd) {
  1828. int u_fd = RFIFOL(fd,4);
  1829. if( session[u_fd] && session[u_fd]->session_data ) {
  1830. int aid = RFIFOL(fd,8);
  1831. struct map_session_data * sd = session[u_fd]->session_data;
  1832. /* matching e.g. previous fd owner didn't dc during request or is still the same */
  1833. if( sd->bl.id == aid ) {
  1834. char msg[512];
  1835. safestrncpy(msg, (char*)RFIFOP(fd,12), RFIFOW(fd,2) - 12);
  1836. clif_displaymessage(u_fd,msg);
  1837. }
  1838. }
  1839. return;
  1840. }
  1841. //-----------------------------------------------------------------
  1842. // Communication from the inter server
  1843. // Return a 0 (false) if there were any errors.
  1844. // 1, 2 if there are not enough to return the length of the packet if the packet processing
  1845. int intif_parse(int fd)
  1846. {
  1847. int packet_len, cmd;
  1848. cmd = RFIFOW(fd,0);
  1849. // Verify ID of the packet
  1850. if(cmd<0x3800 || cmd>=0x3800+(sizeof(packet_len_table)/sizeof(packet_len_table[0])) ||
  1851. packet_len_table[cmd-0x3800]==0){
  1852. return 0;
  1853. }
  1854. // Check the length of the packet
  1855. packet_len = packet_len_table[cmd-0x3800];
  1856. if(packet_len==-1){
  1857. if(RFIFOREST(fd)<4)
  1858. return 2;
  1859. packet_len = RFIFOW(fd,2);
  1860. }
  1861. if((int)RFIFOREST(fd)<packet_len){
  1862. return 2;
  1863. }
  1864. // Processing branch
  1865. switch(cmd){
  1866. case 0x3800:
  1867. if (RFIFOL(fd,4) == 0xFF000000) //Normal announce.
  1868. clif_broadcast(NULL, (char *) RFIFOP(fd,16), packet_len-16, 0, ALL_CLIENT);
  1869. else if (RFIFOL(fd,4) == 0xFE000000) //Main chat message [LuzZza]
  1870. clif_MainChatMessage((char *)RFIFOP(fd,16));
  1871. else //Color announce.
  1872. clif_broadcast2(NULL, (char *) RFIFOP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT);
  1873. break;
  1874. case 0x3801: intif_parse_WisMessage(fd); break;
  1875. case 0x3802: intif_parse_WisEnd(fd); break;
  1876. case 0x3803: mapif_parse_WisToGM(fd); break;
  1877. case 0x3804: intif_parse_Registers(fd); break;
  1878. case 0x3806: intif_parse_ChangeNameOk(fd); break;
  1879. case 0x3807: intif_parse_MessageToFD(fd); break;
  1880. case 0x3818: intif_parse_LoadGuildStorage(fd); break;
  1881. case 0x3819: intif_parse_SaveGuildStorage(fd); break;
  1882. case 0x3820: intif_parse_PartyCreated(fd); break;
  1883. case 0x3821: intif_parse_PartyInfo(fd); break;
  1884. case 0x3822: intif_parse_PartyMemberAdded(fd); break;
  1885. case 0x3823: intif_parse_PartyOptionChanged(fd); break;
  1886. case 0x3824: intif_parse_PartyMemberWithdraw(fd); break;
  1887. case 0x3825: intif_parse_PartyMove(fd); break;
  1888. case 0x3826: intif_parse_PartyBroken(fd); break;
  1889. case 0x3827: intif_parse_PartyMessage(fd); break;
  1890. case 0x3830: intif_parse_GuildCreated(fd); break;
  1891. case 0x3831: intif_parse_GuildInfo(fd); break;
  1892. case 0x3832: intif_parse_GuildMemberAdded(fd); break;
  1893. case 0x3834: intif_parse_GuildMemberWithdraw(fd); break;
  1894. case 0x3835: intif_parse_GuildMemberInfoShort(fd); break;
  1895. case 0x3836: intif_parse_GuildBroken(fd); break;
  1896. case 0x3837: intif_parse_GuildMessage(fd); break;
  1897. case 0x3839: intif_parse_GuildBasicInfoChanged(fd); break;
  1898. case 0x383a: intif_parse_GuildMemberInfoChanged(fd); break;
  1899. case 0x383b: intif_parse_GuildPosition(fd); break;
  1900. case 0x383c: intif_parse_GuildSkillUp(fd); break;
  1901. case 0x383d: intif_parse_GuildAlliance(fd); break;
  1902. case 0x383e: intif_parse_GuildNotice(fd); break;
  1903. case 0x383f: intif_parse_GuildEmblem(fd); break;
  1904. case 0x3840: intif_parse_GuildCastleDataLoad(fd); break;
  1905. case 0x3843: intif_parse_GuildMasterChanged(fd); break;
  1906. //Quest system
  1907. case 0x3860: intif_parse_questlog(fd); break;
  1908. case 0x3861: intif_parse_questsave(fd); break;
  1909. // Mail System
  1910. case 0x3848: intif_parse_Mail_inboxreceived(fd); break;
  1911. case 0x3849: intif_parse_Mail_new(fd); break;
  1912. case 0x384a: intif_parse_Mail_getattach(fd); break;
  1913. case 0x384b: intif_parse_Mail_delete(fd); break;
  1914. case 0x384c: intif_parse_Mail_return(fd); break;
  1915. case 0x384d: intif_parse_Mail_send(fd); break;
  1916. // Auction System
  1917. case 0x3850: intif_parse_Auction_results(fd); break;
  1918. case 0x3851: intif_parse_Auction_register(fd); break;
  1919. case 0x3852: intif_parse_Auction_cancel(fd); break;
  1920. case 0x3853: intif_parse_Auction_close(fd); break;
  1921. case 0x3854: intif_parse_Auction_message(fd); break;
  1922. case 0x3855: intif_parse_Auction_bid(fd); break;
  1923. // Mercenary System
  1924. case 0x3870: intif_parse_mercenary_received(fd); break;
  1925. case 0x3871: intif_parse_mercenary_deleted(fd); break;
  1926. case 0x3872: intif_parse_mercenary_saved(fd); break;
  1927. // Elemental System
  1928. case 0x387c: intif_parse_elemental_received(fd); break;
  1929. case 0x387d: intif_parse_elemental_deleted(fd); break;
  1930. case 0x387e: intif_parse_elemental_saved(fd); break;
  1931. case 0x3880: intif_parse_CreatePet(fd); break;
  1932. case 0x3881: intif_parse_RecvPetData(fd); break;
  1933. case 0x3882: intif_parse_SavePetOk(fd); break;
  1934. case 0x3883: intif_parse_DeletePetOk(fd); break;
  1935. case 0x3890: intif_parse_CreateHomunculus(fd); break;
  1936. case 0x3891: intif_parse_RecvHomunculusData(fd); break;
  1937. case 0x3892: intif_parse_SaveHomunculusOk(fd); break;
  1938. case 0x3893: intif_parse_DeleteHomunculusOk(fd); break;
  1939. default:
  1940. ShowError("intif_parse : unknown packet %d %x\n",fd,RFIFOW(fd,0));
  1941. return 0;
  1942. }
  1943. // Skip packet
  1944. RFIFOSKIP(fd,packet_len);
  1945. return 1;
  1946. }