12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574 |
- // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
- // For more information, see LICENCE in the main folder
- #include <sys/types.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <signal.h>
- #include <fcntl.h>
- #include <string.h>
- #include "../common/showmsg.h"
- #include "../common/socket.h"
- #include "../common/timer.h"
- #include "../common/nullpo.h"
- #include "../common/malloc.h"
- #include "map.h"
- #include "battle.h"
- #include "chrif.h"
- #include "clif.h"
- #include "pc.h"
- #include "intif.h"
- #include "storage.h"
- #include "party.h"
- #include "guild.h"
- #include "pet.h"
- #include "atcommand.h"
- #include "mercenary.h" //albator
- static const int packet_len_table[]={
- -1,-1,27,-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f
- -1, 7, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810
- 39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820
- 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830
- 9, 9,-1,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3840
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 11,-1, 7, 3, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880
- -1,-1, 7, 3, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3890 Homunculus [albator]
- };
- extern int char_fd; // inter serverのfdはchar_fdを使う
- #define inter_fd (char_fd) // エイリアス
- //-----------------------------------------------------------------
- // inter serverへの送信
- int CheckForCharServer(void) {
- return ((char_fd <= 0) || session[char_fd] == NULL || session[char_fd]->wdata == NULL);
- }
- // pet
- int intif_create_pet(int account_id,int char_id,short pet_class,short pet_lv,short pet_egg_id,
- short pet_equip,short intimate,short hungry,char rename_flag,char incuvate,char *pet_name)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, 24 + NAME_LENGTH);
- WFIFOW(inter_fd,0) = 0x3080;
- WFIFOL(inter_fd,2) = account_id;
- WFIFOL(inter_fd,6) = char_id;
- WFIFOW(inter_fd,10) = pet_class;
- WFIFOW(inter_fd,12) = pet_lv;
- WFIFOW(inter_fd,14) = pet_egg_id;
- WFIFOW(inter_fd,16) = pet_equip;
- WFIFOW(inter_fd,18) = intimate;
- WFIFOW(inter_fd,20) = hungry;
- WFIFOB(inter_fd,22) = rename_flag;
- WFIFOB(inter_fd,23) = incuvate;
- memcpy(WFIFOP(inter_fd,24),pet_name,NAME_LENGTH);
- WFIFOSET(inter_fd,24+NAME_LENGTH);
- return 0;
- }
- int intif_request_petdata(int account_id,int char_id,int pet_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, 14);
- WFIFOW(inter_fd,0) = 0x3081;
- WFIFOL(inter_fd,2) = account_id;
- WFIFOL(inter_fd,6) = char_id;
- WFIFOL(inter_fd,10) = pet_id;
- WFIFOSET(inter_fd,14);
- return 0;
- }
- int intif_save_petdata(int account_id,struct s_pet *p)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, sizeof(struct s_pet) + 8);
- WFIFOW(inter_fd,0) = 0x3082;
- WFIFOW(inter_fd,2) = sizeof(struct s_pet) + 8;
- WFIFOL(inter_fd,4) = account_id;
- memcpy(WFIFOP(inter_fd,8),p,sizeof(struct s_pet));
- WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
- return 0;
- }
- int intif_delete_petdata(int pet_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,6);
- WFIFOW(inter_fd,0) = 0x3083;
- WFIFOL(inter_fd,2) = pet_id;
- WFIFOSET(inter_fd,6);
- return 1;
- }
- int intif_rename_pet(struct map_session_data *sd,char *name)
- {
- if (CheckForCharServer())
- return 1;
- WFIFOHEAD(inter_fd,NAME_LENGTH+11);
- WFIFOW(inter_fd,0) = 0x3084;
- WFIFOL(inter_fd,2) = sd->status.account_id;
- WFIFOL(inter_fd,6) = sd->status.char_id;
- memcpy(WFIFOP(inter_fd,10),name, NAME_LENGTH);
- WFIFOSET(inter_fd,NAME_LENGTH+11);
- return 0;
- }
- // GMメッセージを送信
- int intif_GMmessage(char* mes,int len,int flag)
- {
- int lp = (flag&0x10) ? 8 : 4;
- // Send to the local players
- clif_GMmessage(NULL, mes, len, flag);
- if (CheckForCharServer())
- return 0;
- if (other_mapserver_count < 1)
- return 0; //No need to send.
- WFIFOHEAD(inter_fd,lp + len + 4);
- WFIFOW(inter_fd,0) = 0x3000;
- WFIFOW(inter_fd,2) = lp + len + 4;
- WFIFOL(inter_fd,4) = 0xFF000000; //"invalid" color signals standard broadcast.
- WFIFOL(inter_fd,8) = 0x65756c62;
- memcpy(WFIFOP(inter_fd,4+lp), mes, len);
- WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
- return 0;
- }
- int intif_announce(char* mes,int len, unsigned long color, int flag)
- {
- // Send to the local players
- if(color == 0xFE000000) // This is main chat message [LuzZza]
- clif_MainChatMessage(mes);
- else
- clif_announce(NULL, mes, len, color, flag);
- if (CheckForCharServer())
- return 0;
- if (other_mapserver_count < 1)
- return 0; //No need to send.
- WFIFOHEAD(inter_fd, 8 + len);
- WFIFOW(inter_fd,0) = 0x3000;
- WFIFOW(inter_fd,2) = 8 + len;
- WFIFOL(inter_fd,4) = color;
- memcpy(WFIFOP(inter_fd,8), mes, len);
- WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
- return 0;
- }
- // The transmission of Wisp/Page to inter-server (player not found on this server)
- int intif_wis_message(struct map_session_data *sd, char *nick, char *mes, int mes_len) {
- nullpo_retr(0, sd);
- if (CheckForCharServer())
- return 0;
- if (other_mapserver_count < 1)
- { //Character not found.
- clif_wis_end(sd->fd, 1);
- return 0;
- }
- WFIFOHEAD(inter_fd,mes_len + 52);
- WFIFOW(inter_fd,0) = 0x3001;
- WFIFOW(inter_fd,2) = mes_len + 52;
- memcpy(WFIFOP(inter_fd,4), sd->status.name, NAME_LENGTH);
- memcpy(WFIFOP(inter_fd,4+NAME_LENGTH), nick, NAME_LENGTH);
- memcpy(WFIFOP(inter_fd,4+2*NAME_LENGTH), mes, mes_len);
- WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
- if (battle_config.etc_log)
- ShowInfo("intif_wis_message from %s to %s (message: '%s')\n", sd->status.name, nick, mes);
- return 0;
- }
- // The reply of Wisp/page
- int intif_wis_replay(int id, int flag) {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,7);
- WFIFOW(inter_fd,0) = 0x3002;
- WFIFOL(inter_fd,2) = id;
- WFIFOB(inter_fd,6) = flag; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
- WFIFOSET(inter_fd,7);
- if (battle_config.etc_log)
- ShowInfo("intif_wis_replay: id: %d, flag:%d\n", id, flag);
- return 0;
- }
- // The transmission of GM only Wisp/Page from server to inter-server
- int intif_wis_message_to_gm(char *Wisp_name, int min_gm_level, char *mes) {
- int mes_len;
- if (CheckForCharServer())
- return 0;
- mes_len = strlen(mes) + 1; // + null
- WFIFOHEAD(inter_fd, mes_len + 30);
- WFIFOW(inter_fd,0) = 0x3003;
- WFIFOW(inter_fd,2) = mes_len + 30;
- memcpy(WFIFOP(inter_fd,4), Wisp_name, NAME_LENGTH);
- WFIFOW(inter_fd,4+NAME_LENGTH) = (short)min_gm_level;
- memcpy(WFIFOP(inter_fd,6+NAME_LENGTH), mes, mes_len);
- WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
- if (battle_config.etc_log)
- ShowNotice("intif_wis_message_to_gm: from: '%s', min level: %d, message: '%s'.\n", Wisp_name, min_gm_level, mes);
- return 0;
- }
- int intif_regtostr(char* str, struct global_reg *reg, int qty) {
- int len =0, i;
- for (i = 0; i < qty; i++) {
- len+= sprintf(str+len, "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place.
- len+= sprintf(str+len, "%s", reg[i].value)+1;
- }
- return len;
- }
- //Request for saving registry values.
- int intif_saveregistry(struct map_session_data *sd, int type)
- {
- struct global_reg *reg;
- int count;
- if (CheckForCharServer())
- return -1;
- switch (type) {
- case 3: //Character reg
- reg = sd->save_reg.global;
- count = sd->save_reg.global_num;
- sd->state.reg_dirty &= ~0x4;
- break;
- case 2: //Account reg
- reg = sd->save_reg.account;
- count = sd->save_reg.account_num;
- sd->state.reg_dirty &= ~0x2;
- break;
- case 1: //Account2 reg
- reg = sd->save_reg.account2;
- count = sd->save_reg.account2_num;
- sd->state.reg_dirty &= ~0x1;
- break;
- default: //Broken code?
- if (battle_config.error_log)
- ShowError("intif_saveregistry: Invalid type %d\n", type);
- return -1;
- }
- WFIFOHEAD(inter_fd, 288 * MAX_REG_NUM+13);
- WFIFOW(inter_fd,0)=0x3004;
- WFIFOL(inter_fd,4)=sd->status.account_id;
- WFIFOL(inter_fd,8)=sd->status.char_id;
- WFIFOB(inter_fd,12)=type;
- if(count ==0){
- WFIFOW(inter_fd,2)=13;
- }else{
- int i,p;
- for (p=13,i = 0; i < count; i++) {
- if (reg[i].str[0] && reg[i].value != 0) {
- p+= sprintf(WFIFOP(inter_fd,p), "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place.
- p+= sprintf(WFIFOP(inter_fd,p), "%s", reg[i].value)+1;
- }
- }
- WFIFOW(inter_fd,2)=p;
- }
- WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
- return 0;
- }
- //Request the registries for this player.
- int intif_request_registry(struct map_session_data *sd, int flag)
- {
- nullpo_retr(0, sd);
- sd->save_reg.account2_num = -1;
- sd->save_reg.account_num = -1;
- sd->save_reg.global_num = -1;
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,6);
- WFIFOW(inter_fd,0) = 0x3005;
- WFIFOL(inter_fd,2) = sd->status.account_id;
- WFIFOL(inter_fd,6) = sd->status.char_id;
- WFIFOB(inter_fd,10) = (flag&1?1:0); //Request Acc Reg 2
- WFIFOB(inter_fd,11) = (flag&2?1:0); //Request Acc Reg
- WFIFOB(inter_fd,12) = (flag&4?1:0); //Request Char Reg
- WFIFOSET(inter_fd,13);
- return 0;
- }
- // 倉庫データ要求
- int intif_request_storage(int account_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,6);
- WFIFOW(inter_fd,0) = 0x3010;
- WFIFOL(inter_fd,2) = account_id;
- WFIFOSET(inter_fd,6);
- return 0;
- }
- // 倉庫データ送信
- int intif_send_storage(struct storage *stor)
- {
- if (CheckForCharServer())
- return 0;
- nullpo_retr(0, stor);
- WFIFOHEAD(inter_fd,sizeof(struct storage)+8);
- WFIFOW(inter_fd,0) = 0x3011;
- WFIFOW(inter_fd,2) = sizeof(struct storage)+8;
- WFIFOL(inter_fd,4) = stor->account_id;
- memcpy( WFIFOP(inter_fd,8),stor, sizeof(struct storage) );
- WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
- return 0;
- }
- int intif_request_guild_storage(int account_id,int guild_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,10);
- WFIFOW(inter_fd,0) = 0x3018;
- WFIFOL(inter_fd,2) = account_id;
- WFIFOL(inter_fd,6) = guild_id;
- WFIFOSET(inter_fd,10);
- return 0;
- }
- int intif_send_guild_storage(int account_id,struct guild_storage *gstor)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,sizeof(struct guild_storage)+12);
- WFIFOW(inter_fd,0) = 0x3019;
- WFIFOW(inter_fd,2) = sizeof(struct guild_storage)+12;
- WFIFOL(inter_fd,4) = account_id;
- WFIFOL(inter_fd,8) = gstor->guild_id;
- memcpy( WFIFOP(inter_fd,12),gstor, sizeof(struct guild_storage) );
- WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
- return 0;
- }
- // パーティ作成要求
- int intif_create_party(struct party_member *member,char *name,int item,int item2)
- {
- if (CheckForCharServer())
- return 0;
- nullpo_retr(0, member);
- WFIFOHEAD(inter_fd,64);
- WFIFOW(inter_fd,0) = 0x3020;
- WFIFOW(inter_fd,2) = 30+sizeof(struct party_member);
- memcpy(WFIFOP(inter_fd,4),name, NAME_LENGTH);
- WFIFOB(inter_fd,28)= item;
- WFIFOB(inter_fd,29)= item2;
- memcpy(WFIFOP(inter_fd,30), member, sizeof(struct party_member));
- WFIFOSET(inter_fd,WFIFOW(inter_fd, 2));
- return 0;
- }
- // パーティ情報要求
- int intif_request_partyinfo(int party_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,6);
- WFIFOW(inter_fd,0) = 0x3021;
- WFIFOL(inter_fd,2) = party_id;
- WFIFOSET(inter_fd,6);
- // if(battle_config.etc_log)
- // printf("intif: request party info\n");
- return 0;
- }
- // パーティ追加要求
- int intif_party_addmember(int party_id,struct party_member *member)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,42);
- WFIFOW(inter_fd,0)=0x3022;
- WFIFOW(inter_fd,2)=8+sizeof(struct party_member);
- WFIFOL(inter_fd,4)=party_id;
- memcpy(WFIFOP(inter_fd,8),member,sizeof(struct party_member));
- WFIFOSET(inter_fd,WFIFOW(inter_fd, 2));
- return 1;
- }
- // パーティ設定変更
- int intif_party_changeoption(int party_id,int account_id,int exp,int item)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,14);
- WFIFOW(inter_fd,0)=0x3023;
- WFIFOL(inter_fd,2)=party_id;
- WFIFOL(inter_fd,6)=account_id;
- WFIFOW(inter_fd,10)=exp;
- WFIFOW(inter_fd,12)=item;
- WFIFOSET(inter_fd,14);
- return 0;
- }
- // パーティ脱退要求
- int intif_party_leave(int party_id,int account_id, int char_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,14);
- WFIFOW(inter_fd,0)=0x3024;
- WFIFOL(inter_fd,2)=party_id;
- WFIFOL(inter_fd,6)=account_id;
- WFIFOL(inter_fd,10)=char_id;
- WFIFOSET(inter_fd,14);
- return 0;
- }
- // パーティ移動要求
- int intif_party_changemap(struct map_session_data *sd,int online)
- {
- if (CheckForCharServer())
- return 0;
- if(!sd)
- return 0;
- WFIFOHEAD(inter_fd,19);
- WFIFOW(inter_fd,0)=0x3025;
- WFIFOL(inter_fd,2)=sd->status.party_id;
- WFIFOL(inter_fd,6)=sd->status.account_id;
- WFIFOL(inter_fd,10)=sd->status.char_id;
- WFIFOW(inter_fd,14)=sd->mapindex;
- WFIFOB(inter_fd,16)=online;
- WFIFOW(inter_fd,17)=sd->status.base_level;
- WFIFOSET(inter_fd,19);
- return 1;
- }
- // パーティー解散要求
- int intif_break_party(int party_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,6);
- WFIFOW(inter_fd,0)=0x3026;
- WFIFOL(inter_fd,2)=party_id;
- WFIFOSET(inter_fd,6);
- return 0;
- }
- // パーティ会話送信
- int intif_party_message(int party_id,int account_id,char *mes,int len)
- {
- if (CheckForCharServer())
- return 0;
- if (other_mapserver_count < 1)
- return 0; //No need to send.
- WFIFOHEAD(inter_fd,len + 12);
- WFIFOW(inter_fd,0)=0x3027;
- WFIFOW(inter_fd,2)=len+12;
- WFIFOL(inter_fd,4)=party_id;
- WFIFOL(inter_fd,8)=account_id;
- memcpy(WFIFOP(inter_fd,12),mes,len);
- WFIFOSET(inter_fd,len+12);
- return 0;
- }
- // パーティ競合チェック要求
- int intif_party_checkconflict(int party_id,int account_id,int char_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,10 + NAME_LENGTH);
- WFIFOW(inter_fd,0)=0x3028;
- WFIFOL(inter_fd,2)=party_id;
- WFIFOL(inter_fd,6)=account_id;
- WFIFOL(inter_fd,10)=char_id;
- WFIFOSET(inter_fd,14);
- return 0;
- }
- int intif_party_leaderchange(int party_id,int account_id,int char_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,14);
- WFIFOW(inter_fd,0)=0x3029;
- WFIFOL(inter_fd,2)=party_id;
- WFIFOL(inter_fd,6)=account_id;
- WFIFOL(inter_fd,10)=char_id;
- WFIFOSET(inter_fd,14);
- return 0;
- }
- // ギルド作成要求
- int intif_guild_create(const char *name,const struct guild_member *master)
- {
- if (CheckForCharServer())
- return 0;
- nullpo_retr(0, master);
- WFIFOHEAD(inter_fd,sizeof(struct guild_member)+(8+NAME_LENGTH));
- WFIFOW(inter_fd,0)=0x3030;
- WFIFOW(inter_fd,2)=sizeof(struct guild_member)+(8+NAME_LENGTH);
- WFIFOL(inter_fd,4)=master->account_id;
- memcpy(WFIFOP(inter_fd,8),name,NAME_LENGTH);
- memcpy(WFIFOP(inter_fd,8+NAME_LENGTH),master,sizeof(struct guild_member));
- WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
- return 0;
- }
- // ギルド情報要求
- int intif_guild_request_info(int guild_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,6);
- WFIFOW(inter_fd,0) = 0x3031;
- WFIFOL(inter_fd,2) = guild_id;
- WFIFOSET(inter_fd,6);
- return 0;
- }
- // ギルドメンバ追加要求
- int intif_guild_addmember(int guild_id,struct guild_member *m)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,sizeof(struct guild_member)+8);
- WFIFOW(inter_fd,0) = 0x3032;
- WFIFOW(inter_fd,2) = sizeof(struct guild_member)+8;
- WFIFOL(inter_fd,4) = guild_id;
- memcpy(WFIFOP(inter_fd,8),m,sizeof(struct guild_member));
- WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
- return 0;
- }
- int intif_guild_change_gm(int guild_id, const char* name, int len)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, len + 8);
- WFIFOW(inter_fd, 0)=0x3033;
- WFIFOW(inter_fd, 2)=len+8;
- WFIFOL(inter_fd, 4)=guild_id;
- memcpy(WFIFOP(inter_fd,8),name,len);
- WFIFOSET(inter_fd,len+8);
- return 0;
- }
- // ギルドメンバ脱退/追放要求
- int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const char *mes)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, 55);
- WFIFOW(inter_fd, 0) = 0x3034;
- WFIFOL(inter_fd, 2) = guild_id;
- WFIFOL(inter_fd, 6) = account_id;
- WFIFOL(inter_fd,10) = char_id;
- WFIFOB(inter_fd,14) = flag;
- memcpy(WFIFOP(inter_fd,15),mes,40);
- WFIFOSET(inter_fd,55);
- return 0;
- }
- // ギルドメンバのオンライン状況/Lv更新要求
- int intif_guild_memberinfoshort(int guild_id,
- int account_id,int char_id,int online,int lv,int class_)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, 19);
- WFIFOW(inter_fd, 0) = 0x3035;
- WFIFOL(inter_fd, 2) = guild_id;
- WFIFOL(inter_fd, 6) = account_id;
- WFIFOL(inter_fd,10) = char_id;
- WFIFOB(inter_fd,14) = online;
- WFIFOW(inter_fd,15) = lv;
- WFIFOW(inter_fd,17) = class_;
- WFIFOSET(inter_fd,19);
- return 0;
- }
- // ギルド解散通知
- int intif_guild_break(int guild_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, 6);
- WFIFOW(inter_fd, 0) = 0x3036;
- WFIFOL(inter_fd, 2) = guild_id;
- WFIFOSET(inter_fd,6);
- return 0;
- }
- // ギルド会話送信
- int intif_guild_message(int guild_id,int account_id,char *mes,int len)
- {
- if (CheckForCharServer())
- return 0;
- if (other_mapserver_count < 1)
- return 0; //No need to send.
- WFIFOHEAD(inter_fd, len + 12);
- WFIFOW(inter_fd,0)=0x3037;
- WFIFOW(inter_fd,2)=len+12;
- WFIFOL(inter_fd,4)=guild_id;
- WFIFOL(inter_fd,8)=account_id;
- memcpy(WFIFOP(inter_fd,12),mes,len);
- WFIFOSET(inter_fd,len+12);
- return 0;
- }
- // ギルド競合チェック要求
- int intif_guild_checkconflict(int guild_id,int account_id,int char_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, 14);
- WFIFOW(inter_fd, 0)=0x3038;
- WFIFOL(inter_fd, 2)=guild_id;
- WFIFOL(inter_fd, 6)=account_id;
- WFIFOL(inter_fd,10)=char_id;
- WFIFOSET(inter_fd,14);
- return 0;
- }
- // ギルド基本情報変更要求
- int intif_guild_change_basicinfo(int guild_id,int type,const void *data,int len)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, len + 10);
- WFIFOW(inter_fd,0)=0x3039;
- WFIFOW(inter_fd,2)=len+10;
- WFIFOL(inter_fd,4)=guild_id;
- WFIFOW(inter_fd,8)=type;
- memcpy(WFIFOP(inter_fd,10),data,len);
- WFIFOSET(inter_fd,len+10);
- return 0;
- }
- // ギルドメンバ情報変更要求
- int intif_guild_change_memberinfo(int guild_id,int account_id,int char_id,
- int type,const void *data,int len)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, len + 18);
- WFIFOW(inter_fd, 0)=0x303a;
- WFIFOW(inter_fd, 2)=len+18;
- WFIFOL(inter_fd, 4)=guild_id;
- WFIFOL(inter_fd, 8)=account_id;
- WFIFOL(inter_fd,12)=char_id;
- WFIFOW(inter_fd,16)=type;
- memcpy(WFIFOP(inter_fd,18),data,len);
- WFIFOSET(inter_fd,len+18);
- return 0;
- }
- // ギルド役職変更要求
- int intif_guild_position(int guild_id,int idx,struct guild_position *p)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, sizeof(struct guild_position)+12);
- WFIFOW(inter_fd,0)=0x303b;
- WFIFOW(inter_fd,2)=sizeof(struct guild_position)+12;
- WFIFOL(inter_fd,4)=guild_id;
- WFIFOL(inter_fd,8)=idx;
- memcpy(WFIFOP(inter_fd,12),p,sizeof(struct guild_position));
- WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
- return 0;
- }
- // ギルドスキルアップ要求
- int intif_guild_skillup(int guild_id,int skill_num,int account_id,int flag)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,14);
- WFIFOW(inter_fd, 0)=0x303c;
- WFIFOL(inter_fd, 2)=guild_id;
- WFIFOL(inter_fd, 6)=skill_num;
- WFIFOL(inter_fd,10)=account_id;
- //WFIFOL(inter_fd,14)=flag;
- WFIFOSET(inter_fd,14);
- return 0;
- }
- // ギルド同盟/敵対要求
- int intif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,19);
- WFIFOW(inter_fd, 0)=0x303d;
- WFIFOL(inter_fd, 2)=guild_id1;
- WFIFOL(inter_fd, 6)=guild_id2;
- WFIFOL(inter_fd,10)=account_id1;
- WFIFOL(inter_fd,14)=account_id2;
- WFIFOB(inter_fd,18)=flag;
- WFIFOSET(inter_fd,19);
- return 0;
- }
- // ギルド告知変更要求
- int intif_guild_notice(int guild_id,const char *mes1,const char *mes2)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,186);
- WFIFOW(inter_fd,0)=0x303e;
- WFIFOL(inter_fd,2)=guild_id;
- memcpy(WFIFOP(inter_fd,6),mes1,60);
- memcpy(WFIFOP(inter_fd,66),mes2,120);
- WFIFOSET(inter_fd,186);
- return 0;
- }
- // ギルドエンブレム変更要求
- int intif_guild_emblem(int guild_id,int len,const char *data)
- {
- if (CheckForCharServer())
- return 0;
- if(guild_id<=0 || len<0 || len>2000)
- return 0;
- WFIFOHEAD(inter_fd,len + 12);
- WFIFOW(inter_fd,0)=0x303f;
- WFIFOW(inter_fd,2)=len+12;
- WFIFOL(inter_fd,4)=guild_id;
- WFIFOL(inter_fd,8)=0;
- memcpy(WFIFOP(inter_fd,12),data,len);
- WFIFOSET(inter_fd,len+12);
- return 0;
- }
- //現在のギルド城占領ギルドを調べる
- int intif_guild_castle_dataload(int castle_id,int index)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,5);
- WFIFOW(inter_fd,0)=0x3040;
- WFIFOW(inter_fd,2)=castle_id;
- WFIFOB(inter_fd,4)=index;
- WFIFOSET(inter_fd,5);
- return 0;
- }
- //ギルド城占領ギルド変更要求
- int intif_guild_castle_datasave(int castle_id,int index, int value)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd,9);
- WFIFOW(inter_fd,0)=0x3041;
- WFIFOW(inter_fd,2)=castle_id;
- WFIFOB(inter_fd,4)=index;
- WFIFOL(inter_fd,5)=value;
- WFIFOSET(inter_fd,9);
- return 0;
- }
- //-----------------------------------------------------------------
- // Homunculus Packets send to Inter server [albator]
- //-----------------------------------------------------------------
- int intif_homunculus_create(int account_id, struct s_homunculus *sh)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, sizeof(struct s_homunculus)+8);
- WFIFOW(inter_fd,0) = 0x3090;
- WFIFOW(inter_fd,2) = sizeof(struct s_homunculus)+8;
- WFIFOL(inter_fd,4) = account_id;
- memcpy(WFIFOP(inter_fd,8),sh,sizeof(struct s_homunculus));
- WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
- return 0;
- }
- int intif_homunculus_requestload(int account_id, int homun_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, 10);
- WFIFOW(inter_fd,0) = 0x3091;
- WFIFOL(inter_fd,2) = account_id;
- WFIFOL(inter_fd,6) = homun_id;
- WFIFOSET(inter_fd, 10);
- return 1;
- }
- int intif_homunculus_requestsave(int account_id, struct s_homunculus* sh)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, sizeof(struct s_homunculus)+8);
- WFIFOW(inter_fd,0) = 0x3092;
- WFIFOW(inter_fd,2) = sizeof(struct s_homunculus)+8;
- WFIFOL(inter_fd,4) = account_id;
- memcpy(WFIFOP(inter_fd,8),sh,sizeof(struct s_homunculus));
- WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
- return 0;
- }
- int intif_homunculus_requestdelete(int homun_id)
- {
- if (CheckForCharServer())
- return 0;
- WFIFOHEAD(inter_fd, 6);
- WFIFOW(inter_fd, 0) = 0x3093;
- WFIFOL(inter_fd,2) = homun_id;
- WFIFOSET(inter_fd,6);
- return 0;
- }
- //-----------------------------------------------------------------
- // Packets receive from inter server
- // Wisp/Page reception
- int intif_parse_WisMessage(int fd) { // rewritten by [Yor]
- struct map_session_data* sd;
- char *wisp_source;
- char name[NAME_LENGTH];
- int id, i;
- RFIFOHEAD(fd);
- id=RFIFOL(fd,4);
- memcpy(name, RFIFOP(fd,32), NAME_LENGTH);
- name[NAME_LENGTH-1] = '\0'; //In case name arrived without it's terminator. [Skotlex]
- sd = map_nick2sd(name);
- if(sd == NULL || strcmp(sd->status.name, name) != 0)
- { //Not found
- intif_wis_replay(id,1);
- return 0;
- }
- if(sd->state.ignoreAll) {
- intif_wis_replay(id, 2);
- return 0;
- }
- wisp_source = (char *) RFIFOP(fd,8); // speed up [Yor]
- for(i=0; i < MAX_IGNORE_LIST &&
- sd->ignore[i].name[0] != '\0' &&
- strcmp(sd->ignore[i].name, wisp_source) != 0
- ; i++);
-
- if (i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0')
- { //Ignored
- intif_wis_replay(id, 2);
- return 0;
- }
- //Success to send whisper.
- clif_wis_message(sd->fd, wisp_source, (char*)RFIFOP(fd,56),RFIFOW(fd,2)-56);
- intif_wis_replay(id,0); // 送信成功
- return 0;
- }
- // Wisp/page transmission result reception
- int intif_parse_WisEnd(int fd) {
- struct map_session_data* sd;
- RFIFOHEAD(fd);
- if (battle_config.etc_log)
- 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
- sd = (struct map_session_data *)map_nick2sd((char *) RFIFOP(fd,2));
- if (sd != NULL)
- clif_wis_end(sd->fd, RFIFOB(fd,26));
- return 0;
- }
- static int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va) {
- int min_gm_level = va_arg(va, int);
- char *wisp_name;
- char *message;
- int len;
- if (pc_isGM(sd) < min_gm_level) return 0;
- wisp_name = va_arg(va, char*);
- message = va_arg(va, char*);
- len = va_arg(va, int);
- clif_wis_message(sd->fd, wisp_name, message, len);
- return 1;
- }
- // Received wisp message from map-server via char-server for ALL gm
- int mapif_parse_WisToGM(int fd) { // 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B
- int min_gm_level, mes_len;
- char Wisp_name[NAME_LENGTH];
- char mbuf[255];
- char *message;
- RFIFOHEAD(fd);
- mes_len = RFIFOW(fd,2) - 30;
- message = (char *) (mes_len >= 255 ? (char *) aMallocA(mes_len) : mbuf);
- min_gm_level = (int)RFIFOW(fd,28);
- memcpy(Wisp_name, RFIFOP(fd,4), NAME_LENGTH);
- Wisp_name[NAME_LENGTH-1] = '\0';
- memcpy(message, RFIFOP(fd,30), mes_len);
- message[mes_len-1] = '\0';
- // information is sended to all online GM
- clif_foreachclient(mapif_parse_WisToGM_sub, min_gm_level, Wisp_name, message, mes_len);
- if (message != mbuf)
- aFree(message);
- return 0;
- }
- // アカウント変数通知
- int intif_parse_Registers(int fd) {
- int j,p,len,max, flag;
- struct map_session_data *sd;
- struct global_reg *reg;
- int *qty;
- RFIFOHEAD(fd);
- if( (sd=map_id2sd(RFIFOL(fd,4)))==NULL)
- return 1;
- if (RFIFOB(fd,12) == 3 && sd->status.char_id != RFIFOL(fd,8))
- return 1; //Character registry from another character.
- flag = (sd->save_reg.global_num == -1 || sd->save_reg.account_num == -1 || sd->save_reg.account2_num == -1);
- switch (RFIFOB(fd,12)) {
- case 3: //Character Registry
- reg = sd->save_reg.global;
- qty = &sd->save_reg.global_num;
- max = GLOBAL_REG_NUM;
- break;
- case 2: //Account Registry
- reg = sd->save_reg.account;
- qty = &sd->save_reg.account_num;
- max = ACCOUNT_REG_NUM;
- break;
- case 1: //Account2 Registry
- reg = sd->save_reg.account2;
- qty = &sd->save_reg.account2_num;
- max = ACCOUNT_REG2_NUM;
- break;
- default:
- if (battle_config.error_log)
- ShowError("intif_parse_Registers: Unrecognized type %d\n",RFIFOB(fd,12));
- return 0;
- }
- for(j=0,p=13;j<max && p<RFIFOW(fd,2);j++){
- sscanf(RFIFOP(fd,p), "%31c%n", reg[j].str,&len);
- reg[j].str[len]='\0';
- p += len+1; //+1 to skip the '\0' between strings.
- sscanf(RFIFOP(fd,p), "%255c%n", reg[j].value,&len);
- reg[j].value[len]='\0';
- p += len+1;
- }
- *qty = j;
- if (flag && sd->save_reg.global_num > -1 && sd->save_reg.account_num > -1 && sd->save_reg.account2_num > -1)
- pc_reg_received(sd); //Received all registry values, execute init scripts and what-not. [Skotlex]
- return 1;
- }
- // 倉庫データ受信
- int intif_parse_LoadStorage(int fd) {
- struct storage *stor;
- struct map_session_data *sd;
- RFIFOHEAD(fd);
- sd=map_id2sd( RFIFOL(fd,4) );
- if(sd==NULL){
- if(battle_config.error_log)
- ShowError("intif_parse_LoadStorage: user not found %d\n",RFIFOL(fd,4));
- return 1;
- }
- if (sd->state.finalsave)
- return 1; //Player is already scheduled to leave the server.
- stor = account2storage( RFIFOL(fd,4));
- if (stor->storage_status == 1) { // Already open.. lets ignore this update
- if (battle_config.error_log)
- ShowWarning("intif_parse_LoadStorage: storage received for a client already open (User %d:%d)\n", sd->status.account_id, sd->status.char_id);
- return 1;
- }
- if (stor->dirty) { // Already have storage, and it has been modified and not saved yet! Exploit! [Skotlex]
- if (battle_config.error_log)
- ShowWarning("intif_parse_LoadStorage: received storage for an already modified non-saved storage! (User %d:%d)\n", sd->status.account_id, sd->status.char_id);
- return 1;
- }
- if (RFIFOW(fd,2)-8 != sizeof(struct storage)) {
- if (battle_config.error_log)
- ShowError("intif_parse_LoadStorage: data size error %d %d\n", RFIFOW(fd,2)-8, sizeof(struct storage));
- return 1;
- }
- if(battle_config.save_log)
- ShowInfo("intif_openstorage: %d\n",RFIFOL(fd,4) );
- memcpy(stor,RFIFOP(fd,8),sizeof(struct storage));
- stor->dirty=0;
- stor->storage_status=1;
- sd->state.storage_flag = 1;
- clif_storagelist(sd,stor);
- clif_updatestorageamount(sd,stor);
- return 0;
- }
- // 倉庫データ送信成功
- int intif_parse_SaveStorage(int fd)
- {
- RFIFOHEAD(fd);
- if(battle_config.save_log)
- ShowInfo("intif_savestorage: done %d %d\n",RFIFOL(fd,2),RFIFOB(fd,6) );
- storage_storage_saved(RFIFOL(fd,2));
- return 0;
- }
- int intif_parse_LoadGuildStorage(int fd)
- {
- struct guild_storage *gstor;
- struct map_session_data *sd;
- int guild_id;
- RFIFOHEAD(fd);
- guild_id = RFIFOL(fd,8);
- if(guild_id <= 0)
- return 1;
- sd=map_id2sd( RFIFOL(fd,4) );
- if(sd==NULL){
- if(battle_config.error_log)
- ShowError("intif_parse_LoadGuildStorage: user not found %d\n",RFIFOL(fd,4));
- return 1;
- }
- gstor=guild2storage(guild_id);
- if(!gstor) {
- if(battle_config.error_log)
- ShowWarning("intif_parse_LoadGuildStorage: error guild_id %d not exist\n",guild_id);
- return 1;
- }
- if (gstor->storage_status == 1) { // Already open.. lets ignore this update
- if (battle_config.error_log)
- ShowWarning("intif_parse_LoadGuildStorage: storage received for a client already open (User %d:%d)\n", sd->status.account_id, sd->status.char_id);
- return 1;
- }
- if (gstor->dirty) { // Already have storage, and it has been modified and not saved yet! Exploit! [Skotlex]
- if (battle_config.error_log)
- 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);
- return 1;
- }
- if( RFIFOW(fd,2)-12 != sizeof(struct guild_storage) ){
- gstor->storage_status = 0;
- if(battle_config.error_log)
- ShowError("intif_parse_LoadGuildStorage: data size error %d %d\n",RFIFOW(fd,2)-12 , sizeof(struct guild_storage));
- return 1;
- }
- if(battle_config.save_log)
- ShowInfo("intif_open_guild_storage: %d\n",RFIFOL(fd,4) );
- memcpy(gstor,RFIFOP(fd,12),sizeof(struct guild_storage));
- gstor->storage_status = 1;
- sd->state.storage_flag = 2;
- clif_guildstoragelist(sd,gstor);
- clif_updateguildstorageamount(sd,gstor);
- return 0;
- }
- int intif_parse_SaveGuildStorage(int fd)
- {
- RFIFOHEAD(fd);
- if(battle_config.save_log) {
- ShowInfo("intif_save_guild_storage: done %d %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOB(fd,10) );
- }
- storage_guild_storagesaved(/*RFIFOL(fd,2), */RFIFOL(fd,6));
- return 0;
- }
- // パーティ作成可否
- int intif_parse_PartyCreated(int fd)
- {
- RFIFOHEAD(fd);
- if(battle_config.etc_log)
- ShowInfo("intif: party created by account %d\n\n", RFIFOL(fd,2));
- party_created(RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10),RFIFOL(fd,11), (char *)RFIFOP(fd,15));
- return 0;
- }
- // パーティ情報
- int intif_parse_PartyInfo(int fd)
- {
- RFIFOHEAD(fd);
- if( RFIFOW(fd,2)==8){
- if(battle_config.error_log)
- ShowWarning("intif: party noinfo %d\n",RFIFOL(fd,4));
- party_recv_noinfo(RFIFOL(fd,4));
- return 0;
- }
- // printf("intif: party info %d\n",RFIFOL(fd,4));
- if( RFIFOW(fd,2)!=sizeof(struct party)+4 ){
- if(battle_config.error_log)
- ShowError("intif: party info : data size error %d %d %d\n",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct party)+4);
- }
- party_recv_info((struct party *)RFIFOP(fd,4));
- return 0;
- }
- // パーティ追加通知
- int intif_parse_PartyMemberAdded(int fd)
- {
- RFIFOHEAD(fd);
- if(battle_config.etc_log)
- ShowInfo("intif: party member added Party (%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
- party_member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10), RFIFOB(fd, 14));
- return 0;
- }
- // パーティ設定変更通知
- int intif_parse_PartyOptionChanged(int fd)
- {
- RFIFOHEAD(fd);
- party_optionchanged(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOB(fd,14));
- return 0;
- }
- // パーティ脱退通知
- int intif_parse_PartyMemberLeaved(int fd)
- {
- RFIFOHEAD(fd);
- if(battle_config.etc_log)
- ShowInfo("intif: party member leaved: Party(%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
- party_member_leaved(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
- return 0;
- }
- // パーティ解散通知
- int intif_parse_PartyBroken(int fd)
- {
- RFIFOHEAD(fd);
- party_broken(RFIFOL(fd,2));
- return 0;
- }
- // パーティ移動通知
- int intif_parse_PartyMove(int fd)
- {
- RFIFOHEAD(fd);
- party_recv_movemap(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOW(fd,14),RFIFOB(fd,16),RFIFOW(fd,17));
- return 0;
- }
- // パーティメッセージ
- int intif_parse_PartyMessage(int fd)
- {
- RFIFOHEAD(fd);
- // if(battle_config.etc_log)
- // printf("intif_parse_PartyMessage: %s\n",RFIFOP(fd,12));
- party_recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12);
- return 0;
- }
- // ギルド作成可否
- int intif_parse_GuildCreated(int fd)
- {
- RFIFOHEAD(fd);
- guild_created(RFIFOL(fd,2),RFIFOL(fd,6));
- return 0;
- }
- // ギルド情報
- int intif_parse_GuildInfo(int fd)
- {
- RFIFOHEAD(fd);
- if( RFIFOW(fd,2)==8){
- if(battle_config.error_log)
- ShowWarning("intif: guild noinfo %d\n",RFIFOL(fd,4));
- guild_recv_noinfo(RFIFOL(fd,4));
- return 0;
- }
- // if(battle_config.etc_log)
- // printf("intif: guild info %d\n",RFIFOL(fd,4));
- if( RFIFOW(fd,2)!=sizeof(struct guild)+4 ){
- if(battle_config.error_log)
- 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);
- }
- guild_recv_info((struct guild *)RFIFOP(fd,4));
- return 0;
- }
- // ギルドメンバ追加通知
- int intif_parse_GuildMemberAdded(int fd)
- {
- RFIFOHEAD(fd);
- if(battle_config.etc_log)
- ShowInfo("intif: guild member added %d %d %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14));
- guild_member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14));
- return 0;
- }
- // ギルドメンバ脱退/追放通知
- int intif_parse_GuildMemberLeaved(int fd)
- {
- RFIFOHEAD(fd);
- guild_member_leaved(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),
- (char *) RFIFOP(fd,55), (char *) RFIFOP(fd,15));
- return 0;
- }
- // ギルドメンバオンライン状態/Lv変更通知
- int intif_parse_GuildMemberInfoShort(int fd)
- {
- RFIFOHEAD(fd);
- guild_recv_memberinfoshort(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17));
- return 0;
- }
- // ギルド解散通知
- int intif_parse_GuildBroken(int fd)
- {
- RFIFOHEAD(fd);
- guild_broken(RFIFOL(fd,2),RFIFOB(fd,6));
- return 0;
- }
- // ギルド基本情報変更通知
- int intif_parse_GuildBasicInfoChanged(int fd)
- {
- int type, guild_id;
- unsigned int dd;
- void *data;
- struct guild *g;
- short dw;
- RFIFOHEAD(fd);
- type=RFIFOW(fd,8);
- guild_id=RFIFOL(fd,4);
- data=RFIFOP(fd,10);
- g=guild_search(guild_id);
- dw=*((short *)data);
- dd=*((unsigned int *)data);
- if( g==NULL )
- return 0;
- switch(type){
- case GBI_EXP: g->exp=dd; break;
- case GBI_GUILDLV: g->guild_lv=dw; break;
- case GBI_SKILLPOINT: g->skill_point=dd; break;
- }
- return 0;
- }
- // ギルドメンバ情報変更通知
- int intif_parse_GuildMemberInfoChanged(int fd)
- {
- int type, guild_id, account_id, char_id, idx, dd;
- void* data;
- struct guild *g;
- RFIFOHEAD(fd);
- type=RFIFOW(fd,16);
- guild_id=RFIFOL(fd,4);
- account_id=RFIFOL(fd,8);
- char_id=RFIFOL(fd,12);
- data=RFIFOP(fd,18);
- g=guild_search(guild_id);
- dd=*((int *)data);
- if( g==NULL )
- return 0;
- idx=guild_getindex(g,account_id,char_id);
- switch(type){
- case GMI_POSITION:
- g->member[idx].position=dd;
- guild_memberposition_changed(g,idx,dd);
- break;
- case GMI_EXP:
- g->member[idx].exp=dd;
- break;
- case GMI_HAIR:
- g->member[idx].hair=dd;
- break;
- case GMI_HAIR_COLOR:
- g->member[idx].hair_color=dd;
- break;
- case GMI_GENDER:
- g->member[idx].gender=dd;
- break;
- case GMI_CLASS:
- g->member[idx].class_=dd;
- break;
- case GMI_LEVEL:
- g->member[idx].lv=dd;
- break;
- }
- return 0;
- }
- // ギルド役職変更通知
- int intif_parse_GuildPosition(int fd)
- {
- RFIFOHEAD(fd);
- if( RFIFOW(fd,2)!=sizeof(struct guild_position)+12 ){
- if(battle_config.error_log)
- ShowError("intif: guild info : data size error\n %d %d %d",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild_position)+12);
- }
- guild_position_changed(RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12));
- return 0;
- }
- // ギルドスキル割り振り通知
- int intif_parse_GuildSkillUp(int fd)
- {
- RFIFOHEAD(fd);
- guild_skillupack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
- return 0;
- }
- // ギルド同盟/敵対通知
- int intif_parse_GuildAlliance(int fd)
- {
- RFIFOHEAD(fd);
- 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));
- return 0;
- }
- // ギルド告知変更通知
- int intif_parse_GuildNotice(int fd)
- {
- RFIFOHEAD(fd);
- guild_notice_changed(RFIFOL(fd,2),(char *) RFIFOP(fd,6),(char *) RFIFOP(fd,66));
- return 0;
- }
- // ギルドエンブレム変更通知
- int intif_parse_GuildEmblem(int fd)
- {
- RFIFOHEAD(fd);
- guild_emblem_changed(RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8), (char *)RFIFOP(fd,12));
- return 0;
- }
- // ギルド会話受信
- int intif_parse_GuildMessage(int fd)
- {
- RFIFOHEAD(fd);
- guild_recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12);
- return 0;
- }
- // ギルド城データ要求返信
- int intif_parse_GuildCastleDataLoad(int fd)
- {
- RFIFOHEAD(fd);
- return guild_castledataloadack(RFIFOW(fd,2),RFIFOB(fd,4),RFIFOL(fd,5));
- }
- // ギルド城データ変更通知
- int intif_parse_GuildCastleDataSave(int fd)
- {
- RFIFOHEAD(fd);
- return guild_castledatasaveack(RFIFOW(fd,2),RFIFOB(fd,4),RFIFOL(fd,5));
- }
- // ギルド城データ一括受信(初期化時)
- int intif_parse_GuildCastleAllDataLoad(int fd)
- {
- RFIFOHEAD(fd);
- return guild_castlealldataload(RFIFOW(fd,2),(struct guild_castle *)RFIFOP(fd,4));
- }
- int intif_parse_GuildMasterChanged(int fd)
- {
- RFIFOHEAD(fd);
- return guild_gm_changed(RFIFOL(fd,2),RFIFOL(fd,6));
- }
- // pet
- int intif_parse_CreatePet(int fd)
- {
- RFIFOHEAD(fd);
- pet_get_egg(RFIFOL(fd,2),RFIFOL(fd,7),RFIFOB(fd,6));
- return 0;
- }
- int intif_parse_RecvPetData(int fd)
- {
- struct s_pet p;
- int len;
- RFIFOHEAD(fd);
- len=RFIFOW(fd,2);
- if(sizeof(struct s_pet)!=len-9) {
- if(battle_config.etc_log)
- ShowError("intif: pet data: data size error %d %d\n",sizeof(struct s_pet),len-9);
- }
- else{
- memcpy(&p,RFIFOP(fd,9),sizeof(struct s_pet));
- pet_recv_petdata(RFIFOL(fd,4),&p,RFIFOB(fd,8));
- }
- return 0;
- }
- int intif_parse_SavePetOk(int fd)
- {
- RFIFOHEAD(fd);
- if(RFIFOB(fd,6) == 1) {
- if(battle_config.error_log)
- ShowError("pet data save failure\n");
- }
- return 0;
- }
- int intif_parse_DeletePetOk(int fd)
- {
- RFIFOHEAD(fd);
- if(RFIFOB(fd,2) == 1) {
- if(battle_config.error_log)
- ShowError("pet data delete failure\n");
- }
- return 0;
- }
- int intif_parse_RenamePetOk(int fd)
- {
- struct map_session_data *sd = NULL;
- RFIFOHEAD(fd);
- if((sd=map_id2sd(RFIFOL(fd,2)))==NULL ||
- sd->status.char_id != RFIFOL(fd,6))
- return 0;
- if (RFIFOB(fd,10) == 0) {
- clif_displaymessage(sd->fd, msg_txt(280)); // You cannot use this name for your pet.
- clif_send_petstatus(sd); //Send status so client knows oet name change got rejected.
- return 0;
- }
- pet_change_name(sd, RFIFOP(fd,11),1);
- return 0;
- }
- //----------------------------------------------------------------
- // Homunculus recv packets [albator]
- int intif_parse_CreateHomunculus(int fd)
- {
- int len;
- RFIFOHEAD(fd);
- len=RFIFOW(fd,2)-9;
- if(sizeof(struct s_homunculus)!=len) {
- if(battle_config.etc_log)
- ShowError("intif: create homun data: data size error %d != %d\n",sizeof(struct s_homunculus),len);
- return 0;
- }
- merc_hom_recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8)) ;
- return 0;
- }
- int intif_parse_RecvHomunculusData(int fd)
- {
- int len;
- RFIFOHEAD(fd);
- len=RFIFOW(fd,2)-9;
- if(sizeof(struct s_homunculus)!=len) {
- if(battle_config.etc_log)
- ShowError("intif: homun data: data size error %d %d\n",sizeof(struct s_homunculus),len);
- return 0;
- }
- merc_hom_recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8));
- return 0;
- }
- int intif_parse_SaveHomunculusOk(int fd)
- {
- RFIFOHEAD(fd);
- if(RFIFOB(fd,6) != 1) {
- if(battle_config.error_log)
- ShowError("homunculus data save failure for account %d\n", RFIFOL(fd,2));
- }
- return 0;
- }
- int intif_parse_DeleteHomunculusOk(int fd)
- {
- RFIFOHEAD(fd);
- if(RFIFOB(fd,2) != 1) {
- if(battle_config.error_log)
- ShowError("Homunculus data delete failure\n");
- }
- return 0;
- }
- //-----------------------------------------------------------------
- // inter serverからの通信
- // エラーがあれば0(false)を返すこと
- // パケットが処理できれば1,パケット長が足りなければ2を返すこと
- int intif_parse(int fd)
- {
- int packet_len, cmd;
- RFIFOHEAD(fd);
- cmd = RFIFOW(fd,0);
- // パケットのID確認
- if(cmd<0x3800 || cmd>=0x3800+(sizeof(packet_len_table)/sizeof(packet_len_table[0])) ||
- packet_len_table[cmd-0x3800]==0){
- return 0;
- }
- // パケットの長さ確認
- packet_len = packet_len_table[cmd-0x3800];
- if(packet_len==-1){
- if(RFIFOREST(fd)<4)
- return 2;
- packet_len = RFIFOW(fd,2);
- }
- // if(battle_config.etc_log)
- // printf("intif_parse %d %x %d %d\n",fd,cmd,packet_len,RFIFOREST(fd));
- if((int)RFIFOREST(fd)<packet_len){
- return 2;
- }
- // 処理分岐
- switch(cmd){
- case 0x3800:
- if (RFIFOL(fd,4) == 0xFF000000) //Normal announce.
- clif_GMmessage(NULL,(char *) RFIFOP(fd,8),packet_len-8,0);
- else if (RFIFOL(fd,4) == 0xFE000000) //Main chat message [LuzZza]
- clif_MainChatMessage((char *)RFIFOP(fd,8));
- else //Color announce.
- clif_announce(NULL,(char *) RFIFOP(fd,8),packet_len-8,RFIFOL(fd,4),0);
- break;
- case 0x3801: intif_parse_WisMessage(fd); break;
- case 0x3802: intif_parse_WisEnd(fd); break;
- case 0x3803: mapif_parse_WisToGM(fd); break;
- case 0x3804: intif_parse_Registers(fd); break;
- case 0x3810: intif_parse_LoadStorage(fd); break;
- case 0x3811: intif_parse_SaveStorage(fd); break;
- case 0x3818: intif_parse_LoadGuildStorage(fd); break;
- case 0x3819: intif_parse_SaveGuildStorage(fd); break;
- case 0x3820: intif_parse_PartyCreated(fd); break;
- case 0x3821: intif_parse_PartyInfo(fd); break;
- case 0x3822: intif_parse_PartyMemberAdded(fd); break;
- case 0x3823: intif_parse_PartyOptionChanged(fd); break;
- case 0x3824: intif_parse_PartyMemberLeaved(fd); break;
- case 0x3825: intif_parse_PartyMove(fd); break;
- case 0x3826: intif_parse_PartyBroken(fd); break;
- case 0x3827: intif_parse_PartyMessage(fd); break;
- case 0x3830: intif_parse_GuildCreated(fd); break;
- case 0x3831: intif_parse_GuildInfo(fd); break;
- case 0x3832: intif_parse_GuildMemberAdded(fd); break;
- case 0x3834: intif_parse_GuildMemberLeaved(fd); break;
- case 0x3835: intif_parse_GuildMemberInfoShort(fd); break;
- case 0x3836: intif_parse_GuildBroken(fd); break;
- case 0x3837: intif_parse_GuildMessage(fd); break;
- case 0x3839: intif_parse_GuildBasicInfoChanged(fd); break;
- case 0x383a: intif_parse_GuildMemberInfoChanged(fd); break;
- case 0x383b: intif_parse_GuildPosition(fd); break;
- case 0x383c: intif_parse_GuildSkillUp(fd); break;
- case 0x383d: intif_parse_GuildAlliance(fd); break;
- case 0x383e: intif_parse_GuildNotice(fd); break;
- case 0x383f: intif_parse_GuildEmblem(fd); break;
- case 0x3840: intif_parse_GuildCastleDataLoad(fd); break;
- case 0x3841: intif_parse_GuildCastleDataSave(fd); break;
- case 0x3842: intif_parse_GuildCastleAllDataLoad(fd); break;
- case 0x3843: intif_parse_GuildMasterChanged(fd); break;
- case 0x3880: intif_parse_CreatePet(fd); break;
- case 0x3881: intif_parse_RecvPetData(fd); break;
- case 0x3882: intif_parse_SavePetOk(fd); break;
- case 0x3883: intif_parse_DeletePetOk(fd); break;
- case 0x3884: intif_parse_RenamePetOk(fd); break;
- case 0x3890: intif_parse_CreateHomunculus(fd); break;
- case 0x3891: intif_parse_RecvHomunculusData(fd); break;
- case 0x3892: intif_parse_SaveHomunculusOk(fd); break;
- case 0x3893: intif_parse_DeleteHomunculusOk(fd); break;
- default:
- if(battle_config.error_log)
- ShowError("intif_parse : unknown packet %d %x\n",fd,RFIFOW(fd,0));
- return 0;
- }
- // パケット読み飛ばし
- RFIFOSKIP(fd,packet_len);
- return 1;
- }
|