intif.c 59 KB

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