123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120 |
- // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
- // For more information, see LICENCE in the main folder
- #define DUMP_UNKNOWN_PACKET 0
- #define DUMP_ALL_PACKETS 0
- #include <stdio.h>
- #include <ctype.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdarg.h>
- #include <limits.h>
- #include <time.h>
- #include "../common/socket.h"
- #include "../common/timer.h"
- #include "../common/malloc.h"
- #include "../common/version.h"
- #include "../common/nullpo.h"
- #include "../common/showmsg.h"
- #include "map.h"
- #include "chrif.h"
- #include "clif.h"
- #include "pc.h"
- #include "status.h"
- #include "npc.h"
- #include "itemdb.h"
- #include "chat.h"
- #include "trade.h"
- #include "storage.h"
- #include "script.h"
- #include "skill.h"
- #include "atcommand.h"
- #include "charcommand.h"
- #include "intif.h"
- #include "battle.h"
- #include "mob.h"
- #include "party.h"
- #include "unit.h"
- #include "guild.h"
- #include "vending.h"
- #include "pet.h"
- #include "mercenary.h" //[orn]
- #include "log.h"
- #include "irc.h"
- struct Clif_Config {
- int packet_db_ver; //Preferred packet version.
- int connect_cmd[MAX_PACKET_VER + 1]; //Store the connect command for all versions. [Skotlex]
- } clif_config;
- struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB];
- static const int packet_len_table[MAX_PACKET_DB] = {
- 10, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- //#0x0040
- 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, 55, 17, 3, 37, 46, -1, 23, -1, 3,108, 3, 2,
- #if PACKETVER < 2
- 3, 28, 19, 11, 3, -1, 9, 5, 52, 51, 56, 58, 41, 2, 6, 6,
- #else // 78-7b 亀島以降 lv99エフェクト用
- 3, 28, 19, 11, 3, -1, 9, 5, 54, 53, 58, 60, 41, 2, 6, 6,
- #endif
- //#0x0080
- 7, 3, 2, 2, 2, 5, 16, 12, 10, 7, 29, 2, -1, -1, -1, 0, // 0x8b changed to 2 (was 23)
- 7, 22, 28, 2, 6, 30, -1, -1, 3, -1, -1, 5, 9, 17, 17, 6,
- 23, 6, 6, -1, -1, -1, -1, 8, 7, 6, 7, 4, 7, 0, -1, 6,
- 8, 8, 3, 3, -1, 6, 6, -1, 7, 6, 2, 5, 6, 44, 5, 3,
- //#0x00C0
- 7, 2, 6, 8, 6, 7, -1, -1, -1, -1, 3, 3, 6, 3, 2, 27, // 0xcd change to 3 (was 6)
- 3, 4, 4, 2, -1, -1, 3, -1, 6, 14, 3, -1, 28, 29, -1, -1,
- 30, 30, 26, 2, 6, 26, 3, 3, 8, 19, 5, 2, 3, 2, 2, 2,
- 3, 2, 6, 8, 21, 8, 8, 2, 2, 26, 3, -1, 6, 27, 30, 10,
- //#0x0100
- 2, 6, 6, 30, 79, 31, 10, 10, -1, -1, 4, 6, 6, 2, 11, -1,
- 10, 39, 4, 10, 31, 35, 10, 18, 2, 13, 15, 20, 68, 2, 3, 16,
- 6, 14, -1, -1, 21, 8, 8, 8, 8, 8, 2, 2, 3, 4, 2, -1,
- 6, 86, 6, -1, -1, 7, -1, 6, 3, 16, 4, 4, 4, 6, 24, 26,
- //#0x0140
- 22, 14, 6, 10, 23, 19, 6, 39, 8, 9, 6, 27, -1, 2, 6, 6,
- 110, 6, -1, -1, -1, -1, -1, 6, -1, 54, 66, 54, 90, 42, 6, 42,
- -1, -1, -1, -1, -1, 30, -1, 3, 14, 3, 30, 10, 43, 14,186,182,
- 14, 30, 10, 3, -1, 6,106, -1, 4, 5, 4, -1, 6, 7, -1, -1,
- //#0x0180
- 6, 3,106, 10, 10, 34, 0, 6, 8, 4, 4, 4, 29, -1, 10, 6,
- #if PACKETVER < 1
- 90, 86, 24, 6, 30,102, 8, 4, 8, 4, 14, 10, -1, 6, 2, 6,
- #else // 196 comodo以降 状態表示アイコン用
- 90, 86, 24, 6, 30,102, 9, 4, 8, 4, 14, 10, -1, 6, 2, 6,
- #endif
- 3, 3, 35, 5, 11, 26, -1, 4, 4, 6, 10, 12, 6, -1, 4, 4,
- 11, 7, -1, 67, 12, 18,114, 6, 3, 6, 26, 26, 26, 26, 2, 3,
- //#0x01C0, Set 0x1d5=-1
- 2, 14, 10, -1, 22, 22, 4, 2, 13, 97, 3, 9, 9, 30, 6, 28,
- 8, 14, 10, 35, 6, -1, 4, 11, 54, 53, 60, 2, -1, 47, 33, 6,
- 30, 8, 34, 14, 2, 6, 26, 2, 28, 81, 6, 10, 26, 2, -1, -1,
- -1, -1, 20, 10, 32, 9, 34, 14, 2, 6, 48, 56, -1, 4, 5, 10,
- //#0x200
- 26, -1, 26, 10, 18, 26, 11, 34, 14, 36, 10, 0, 0, -1, 32, 10, // 0x20c change to 0 (was 19)
- 22, 0, 26, 26, 42, -1, -1, 2, 2,282,282,10, 10, -1, -1, 66,
- 10, -1, -1, 8, 10, 2,282, 18, 18, 15, 58, 57, 64, 5, 71, 5,
- 12, 26, 9, 11, -1, -1, 10, 2, 282, 11, 4, 36, -1,-1, 4, 2,
- -1, -1, -1, -1, -1, 3, 4, 8, -1, 3, 70, 4, 8,12, 4, 10,
- 3, 32, -1, 3, 3, 5, 5, 8, 2, 3, -1, -1, 4,-1, 4
- };
- //Converts item type in case of pet eggs.
- #define itemtype(a) (a == 7)?4:a
- #define WBUFPOS(p,pos,x,y,dir) { unsigned char *__p = (p); __p+=(pos); __p[0] = (x)>>2; __p[1] = ((x)<<6) | (((y)>>4)&0x3f); __p[2] = ((y)<<4)|((dir)&0xf); }
- #define WBUFPOS2(p,pos,x0,y0,x1,y1) { unsigned char *__p = (p); __p+=(pos); __p[0] = (unsigned char)((x0)>>2); __p[1] = (unsigned char)(((x0)<<6) | (((y0)>>4)&0x3f)); __p[2] = (unsigned char)(((y0)<<4) | (((x1)>>6)&0x0f)); __p[3]=(unsigned char)(((x1)<<2) | (((y1)>>8)&0x03)); __p[4]=(unsigned char)(y1); }
- #define WFIFOPOS(fd,pos,x,y,dir) { WBUFPOS (WFIFOP(fd,pos),0,x,y,dir); }
- #define WFIFOPOS2(fd,pos,x0,y0,x1,y1) { WBUFPOS2(WFIFOP(fd,pos),0,x0,y0,x1,y1); }
- //To make the assignation of the level based on limits clearer/easier. [Skotlex]
- #define clif_setlevel(lv) (lv<battle_config.max_lv?lv:battle_config.max_lv-(lv<battle_config.aura_lv?1:0));
- //Removed sd->npc_shopid because there is no packet sent from the client when you cancel a buy!
- //Quick check to know if the player shouldn't be "busy" with something else to deny action requests. [Skotlex]
- #define clif_cant_act(sd) (sd->npc_id || sd->vender_id || sd->chatID || sd->sc.opt1 || sd->state.trading || sd->state.storage_flag)
- // Checks if SD is in a trade/shop (where messing with the inventory can cause problems/exploits)
- #define clif_trading(sd) (sd->npc_id || sd->vender_id || sd->state.trading )
- //To idenfity disguised characters.
- #define disguised(bl) (bl->type==BL_PC && ((TBL_PC*)bl)->disguise)
- static char map_ip_str[128];
- static in_addr_t map_ip;
- static in_addr_t bind_ip = INADDR_ANY;
- static int map_port = 5121;
- int map_fd;
- char talkie_mes[MESSAGE_SIZE];
- //These two will be used to verify the incoming player's validity.
- //It helps identify their client packet version correctly. [Skotlex]
- static int max_account_id = DEFAULT_MAX_ACCOUNT_ID;
- static int max_char_id = DEFAULT_MAX_CHAR_ID;
- int clif_parse (int fd);
- static void clif_hpmeter_single(int fd, struct map_session_data *sd);
- /*==========================================
- * map鯖のip設定
- *------------------------------------------
- */
- int clif_setip(char *ip)
- {
- char ip_str[16];
- map_ip = resolve_hostbyname(ip,NULL,ip_str);
- if (!map_ip) {
- ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
- return 0;
- }
- strncpy(map_ip_str, ip, sizeof(map_ip_str));
- ShowInfo("Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip_str);
- return 1;
- }
- void clif_setbindip(char *ip)
- {
- unsigned char ip_str[4];
- bind_ip = resolve_hostbyname(ip,ip_str,NULL);
- if (bind_ip) {
- ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%d.%d.%d.%d"CL_RESET"'.\n", ip, ip_str[0], ip_str[1], ip_str[2], ip_str[3]);
- } else {
- ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
- }
- }
- /*==========================================
- * map鯖のport設定
- *------------------------------------------
- */
- void clif_setport(int port)
- {
- map_port = port;
- }
- /*==========================================
- * map鯖のip読み出し
- *------------------------------------------
- */
- in_addr_t clif_getip(void)
- {
- return map_ip;
- }
- //Returns the ip casted as a basic type, to avoid needing to include the socket/net related libs by calling modules.
- unsigned long clif_getip_long(void)
- {
- return (unsigned long)map_ip;
- }
- //Refreshes map_server ip, returns the new ip if the ip changed, otherwise it
- //returns 0.
- unsigned long clif_refresh_ip(void) {
- in_addr_t new_ip;
- new_ip = resolve_hostbyname(map_ip_str, NULL, NULL);
- if (new_ip && new_ip != map_ip) {
- map_ip = new_ip;
- ShowInfo("Updating IP resolution of [%s].\n",map_ip_str);
- return (unsigned long)map_ip;
- }
- return 0;
- }
- /*==========================================
- * map鯖のport読み出し
- *------------------------------------------
- */
- int clif_getport(void)
- {
- return map_port;
- }
- /*==========================================
- * Counts connected players.
- *------------------------------------------
- */
- int clif_countusers(void)
- {
- int users = 0, i;
- struct map_session_data *sd;
- for(i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data*)session[i]->session_data) &&
- sd->state.auth && !(battle_config.hide_GM_session && pc_isGM(sd)))
- users++;
- }
- return users;
- }
- /*==========================================
- * 全てのclientに対してfunc()実行
- *------------------------------------------
- */
- int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) //recoded by sasuke, bug when player count gets higher [Kevin]
- {
- int i;
- va_list ap;
- struct map_session_data *sd;
- va_start(ap,func);
- for(i = 0; i < fd_max; i++) {
- if ( session[i] && session[i]->func_parse == clif_parse) {
- sd = (struct map_session_data*)session[i]->session_data;
- if ( sd && sd->state.auth && !sd->state.waitingdisconnect )
- func(sd, ap);
- }
- }
- va_end(ap);
- return 0;
- }
- /*==========================================
- * clif_sendでAREA*指定時用
- *------------------------------------------
- */
- int clif_send_sub(struct block_list *bl, va_list ap)
- {
- struct block_list *src_bl;
- struct map_session_data *sd;
- unsigned char *buf;
- int len, type;
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
- nullpo_retr(0, sd = (struct map_session_data *)bl);
- if (!sd->fd) //Avoid attempting to send to disconnected chars (may prevent buffer overrun errors?) [Skotlex]
- return 0;
- buf = va_arg(ap,unsigned char*);
- len = va_arg(ap,int);
- nullpo_retr(0, src_bl = va_arg(ap,struct block_list*));
- type = va_arg(ap,int);
- switch(type) {
- case AREA_WOS:
- if (bl == src_bl)
- return 0;
- break;
- case AREA_WOC:
- if (sd->chatID || bl == src_bl)
- return 0;
- break;
- case AREA_WOSC:
- {
- struct map_session_data *ssd = (struct map_session_data *)src_bl;
- if (ssd && (src_bl->type == BL_PC) && sd->chatID && (sd->chatID == ssd->chatID))
- return 0;
- }
- break;
- }
- if (session[sd->fd] != NULL) {
- WFIFOHEAD(sd->fd, len);
- if (WFIFOP(sd->fd,0) == buf) {
- printf("WARNING: Invalid use of clif_send function\n");
- printf(" Packet x%4x use a WFIFO of a player instead of to use a buffer.\n", WBUFW(buf,0));
- printf(" Please correct your code.\n");
- // don't send to not move the pointer of the packet for next sessions in the loop
- } else {
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- memcpy(WFIFOP(sd->fd,0), buf, len);
- //Check if hidden, better to modify the char's buffer than the
- //given buffer to prevent intravision affecting the packet as
- //it's being received by everyone. [Skotlex]
- /* New implementation... not quite correct yet as the client no longer
- * displays correctly the SI_INTRAVISION effect.
- if ((sd->special_state.intravision || sd->sc.data[SC_INTRAVISION].timer != -1 )
- && bl != src_bl && WFIFOW(sd->fd,0) == 0x0196)
- { //New intravision method, just modify the status change/start packet. [Skotlex]
- switch (WFIFOW(sd->fd,2)) {
- case SI_HIDING:
- case SI_CLOAKING:
- case SI_CHASEWALK:
- WFIFOW(sd->fd,2) = SI_INTRAVISION;
- }
- }
- */
- // Previous implementation.
- if ((sd->special_state.intravision || sd->sc.data[SC_INTRAVISION].timer != -1 ) && bl != src_bl) {
- struct status_change *sc = status_get_sc(src_bl);
- if(sc && (sc->option&(OPTION_HIDE|OPTION_CLOAK)))
- { //optionの修正
- switch(((unsigned short*)buf)[0])
- {
- #if PACKETVER > 6
- case 0x229:
- WFIFOL(sd->fd,10) &= ~(OPTION_HIDE|OPTION_CLOAK);
- break;
- case 0x22a:
- case 0x22b:
- case 0x22c:
- WFIFOL(sd->fd,12) &=~(OPTION_HIDE|OPTION_CLOAK);
- break;
- #endif
- #if PACKETVER > 3
- case 0x119:
- WFIFOW(sd->fd,10) &= ~(OPTION_HIDE|OPTION_CLOAK);
- break;
- case 0x1d8:
- case 0x1d9:
- case 0x1da:
- #endif
- case 0x78:
- case 0x79:
- case 0x7a:
- case 0x7b:
- case 0x7c:
- WFIFOW(sd->fd,12) &=~(OPTION_HIDE|OPTION_CLOAK);
- break;
- }
- }
- }
- WFIFOSET(sd->fd,len);
- }
- }
- }
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) {
- int i;
- struct map_session_data *sd = NULL;
- struct party_data *p = NULL;
- struct guild *g = NULL;
- int x0 = 0, x1 = 0, y0 = 0, y1 = 0;
- if (type != ALL_CLIENT &&
- type != CHAT_MAINCHAT) {
- nullpo_retr(0, bl);
- if (bl->type == BL_PC) {
- sd = (struct map_session_data *)bl;
- }
- }
- switch(type) {
- case ALL_CLIENT: //All player clients.
- for (i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data *)session[i]->session_data) != NULL&&
- sd->state.auth) {
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(i, len);
- memcpy(WFIFOP(i,0), buf, len);
- WFIFOSET(i,len);
- }
- }
- }
- break;
- case ALL_SAMEMAP: //All players on the same map
- for(i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
- sd->state.auth && sd->bl.m == bl->m) {
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(i,len);
- memcpy(WFIFOP(i,0), buf, len);
- WFIFOSET(i,len);
- }
- }
- }
- break;
- case AREA:
- case AREA_WOSC:
- if (sd && bl->prev == NULL) //Otherwise source misses the packet.[Skotlex]
- clif_send (buf, len, bl, SELF);
- case AREA_WOC:
- case AREA_WOS:
- map_foreachinarea(clif_send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE,
- BL_PC, buf, len, bl, type);
- break;
- case AREA_CHAT_WOC:
- map_foreachinarea(clif_send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5),
- bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC);
- break;
- case CHAT:
- case CHAT_WOS:
- {
- struct chat_data *cd;
- if (sd) {
- cd = (struct chat_data*)map_id2bl(sd->chatID);
- } else if (bl->type == BL_CHAT) {
- cd = (struct chat_data*)bl;
- } else break;
- if (cd == NULL)
- break;
- for(i = 0; i < cd->users; i++) {
- if (type == CHAT_WOS && cd->usersd[i] == sd)
- continue;
- if (packet_db[cd->usersd[i]->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- if (cd->usersd[i]->fd >0 && session[cd->usersd[i]->fd]) // Added check to see if session exists [PoW]
- {
- WFIFOHEAD(cd->usersd[i]->fd,len);
- memcpy(WFIFOP(cd->usersd[i]->fd,0), buf, len);
- WFIFOSET(cd->usersd[i]->fd,len);
- }
- }
- }
- }
- break;
- case CHAT_MAINCHAT: //[LuzZza]
- for(i=1; i<fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
- sd->state.mainchat && sd->fd) {
- WFIFOHEAD(sd->fd, len);
- memcpy(WFIFOP(sd->fd,0), buf, len);
- WFIFOSET(sd->fd, len);
- }
- }
- break;
- case PARTY_AREA:
- case PARTY_AREA_WOS:
- x0 = bl->x - AREA_SIZE;
- y0 = bl->y - AREA_SIZE;
- x1 = bl->x + AREA_SIZE;
- y1 = bl->y + AREA_SIZE;
- case PARTY:
- case PARTY_WOS:
- case PARTY_SAMEMAP:
- case PARTY_SAMEMAP_WOS:
- if (sd && sd->status.party_id)
- p = party_search(sd->status.party_id);
-
- if (p) {
- for(i=0;i<MAX_PARTY;i++){
- if ((sd = p->data[i].sd) == NULL)
- continue;
- if (!sd->fd || session[sd->fd] == NULL || sd->state.auth == 0
- || session[sd->fd]->session_data == NULL || sd->packet_ver > MAX_PACKET_VER)
- continue;
-
- if (sd->bl.id == bl->id && (type == PARTY_WOS || type == PARTY_SAMEMAP_WOS || type == PARTY_AREA_WOS))
- continue;
-
- if (type != PARTY && type != PARTY_WOS && bl->m != sd->bl.m)
- continue;
-
- if ((type == PARTY_AREA || type == PARTY_AREA_WOS) &&
- (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1))
- continue;
-
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(sd->fd,len);
- memcpy(WFIFOP(sd->fd,0), buf, len);
- WFIFOSET(sd->fd,len);
- }
- }
- if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
- break;
- for (i = 1; i < fd_max; i++){ // partyspy [Syrus22]
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
- sd->state.auth && sd->fd && sd->partyspy == p->party.party_id)
- {
- if (sd->fd && packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(sd->fd,len);
- memcpy(WFIFOP(sd->fd,0), buf, len);
- WFIFOSET(sd->fd,len);
- }
- }
- }
- }
- break;
- case DUEL:
- case DUEL_WOS:
- if (!sd || !sd->duel_group) break; //Invalid usage.
- x0 = sd->duel_group; //Here we use x0 to store the duel group. [Skotlex]
- for (i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data *)session[i]->session_data) != NULL &&
- sd->state.auth && sd->duel_group == x0) {
- if (type == DUEL_WOS && bl->id == sd->bl.id)
- continue;
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) {
- WFIFOHEAD(i, len);
- memcpy(WFIFOP(i,0), buf, len);
- WFIFOSET(i,len);
- }
- }
- }
- break;
- case SELF:
- if (sd && sd->fd && packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(sd->fd,len);
- memcpy(WFIFOP(sd->fd,0), buf, len);
- WFIFOSET(sd->fd,len);
- }
- break;
- // New definitions for guilds [Valaris] - Cleaned up and reorganized by [Skotlex]
- case GUILD_AREA:
- case GUILD_AREA_WOS:
- x0 = bl->x - AREA_SIZE;
- y0 = bl->y - AREA_SIZE;
- x1 = bl->x + AREA_SIZE;
- y1 = bl->y + AREA_SIZE;
- case GUILD_SAMEMAP:
- case GUILD_SAMEMAP_WOS:
- case GUILD:
- case GUILD_WOS:
- if (sd && sd->status.guild_id)
- g = guild_search(sd->status.guild_id);
- if (g) {
- for(i = 0; i < g->max_member; i++) {
- if ((sd = g->member[i].sd) != NULL) {
- if (!sd->fd || session[sd->fd] == NULL || sd->state.auth == 0
- || session[sd->fd]->session_data == NULL || sd->packet_ver > MAX_PACKET_VER)
- continue;
-
- if (sd->bl.id == bl->id && (type == GUILD_WOS || type == GUILD_SAMEMAP_WOS || type == GUILD_AREA_WOS))
- continue;
-
- if (type != GUILD && type != GUILD_WOS && sd->bl.m != bl->m)
- continue;
-
- if ((type == GUILD_AREA || type == GUILD_AREA_WOS) &&
- (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1))
- continue;
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(sd->fd,len);
- memcpy(WFIFOP(sd->fd,0), buf, len);
- WFIFOSET(sd->fd,len);
- }
- }
- }
- if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
- break;
- for (i = 1; i < fd_max; i++){ // guildspy [Syrus22]
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
- sd->state.auth && sd->fd && sd->guildspy == g->guild_id) {
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(sd->fd,len);
- memcpy(WFIFOP(sd->fd,0), buf, len);
- WFIFOSET(sd->fd,len);
- }
- }
- }
- }
- break;
- /* End [Valaris] */
- default:
- if (battle_config.error_log)
- ShowError("clif_send: Unrecognized type %d\n",type);
- return -1;
- }
- return 0;
- }
- //
- // パケット作って送信
- //
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_authok(struct map_session_data *sd) {
- int fd;
- if (!sd->fd)
- return 0;
- fd = sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x73]);
- WFIFOW(fd, 0) = 0x73;
- WFIFOL(fd, 2) = gettick();
- WFIFOPOS(fd, 6, sd->bl.x, sd->bl.y, sd->ud.dir);
- WFIFOB(fd, 9) = 5;
- WFIFOB(fd,10) = 5;
- WFIFOSET(fd,packet_len_table[0x73]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_authfail_fd(int fd, int type) {
- if (!fd || !session[fd] || session[fd]->func_parse != clif_parse) //clif_authfail should only be invoked on players!
- return 0;
- WFIFOHEAD(fd, packet_len_table[0x81]);
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = type;
- WFIFOSET(fd,packet_len_table[0x81]);
- clif_setwaitclose(fd);
- return 0;
- }
- /*==========================================
- * Used to know which is the max valid account/char id [Skotlex]
- *------------------------------------------
- */
- void clif_updatemaxid(int account_id, int char_id)
- {
- max_account_id = account_id;
- max_char_id = char_id;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_charselectok(int id) {
- struct map_session_data *sd;
- int fd;
- if ((sd = map_id2sd(id)) == NULL)
- return 1;
- if (!sd->fd)
- return 1;
- fd = sd->fd;
- WFIFOHEAD(fd, packet_len_table[0xb3]);
- WFIFOW(fd,0) = 0xb3;
- WFIFOB(fd,2) = 1;
- WFIFOSET(fd,packet_len_table[0xb3]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- static int clif_set009e(struct flooritem_data *fitem,unsigned char *buf) {
- int view;
- nullpo_retr(0, fitem);
- //009e <ID>.l <name ID>.w <identify flag>.B <X>.w <Y>.w <subX>.B <subY>.B <amount>.w
- WBUFW(buf, 0) = 0x9e;
- WBUFL(buf, 2) = fitem->bl.id;
- if ((view = itemdb_viewid(fitem->item_data.nameid)) > 0)
- WBUFW(buf, 6) = view;
- else
- WBUFW(buf, 6) = fitem->item_data.nameid;
- WBUFB(buf, 8) = fitem->item_data.identify;
- WBUFW(buf, 9) = fitem->bl.x;
- WBUFW(buf,11) = fitem->bl.y;
- WBUFB(buf,13) = fitem->subx;
- WBUFB(buf,14) = fitem->suby;
- WBUFW(buf,15) = fitem->item_data.amount;
- return packet_len_table[0x9e];
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_dropflooritem(struct flooritem_data *fitem) {
- unsigned char buf[64];
- nullpo_retr(0, fitem);
- if (fitem->item_data.nameid <= 0)
- return 0;
- clif_set009e(fitem, buf);
- clif_send(buf, packet_len_table[0x9e], &fitem->bl, AREA);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_clearflooritem(struct flooritem_data *fitem, int fd) {
- unsigned char buf[16];
- nullpo_retr(0, fitem);
- WBUFW(buf,0) = 0xa1;
- WBUFL(buf,2) = fitem->bl.id;
- if (fd == 0) {
- clif_send(buf, packet_len_table[0xa1], &fitem->bl, AREA);
- } else {
- WFIFOHEAD(fd,packet_len_table[0xa1]);
- memcpy(WFIFOP(fd,0), buf, 6);
- WFIFOSET(fd,packet_len_table[0xa1]);
- }
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_clearchar(struct block_list *bl, int type) {
- unsigned char buf[16];
- nullpo_retr(0, bl);
- WBUFW(buf,0) = 0x80;
- WBUFL(buf,2) = bl->id;
- WBUFB(buf,6) = type;
- clif_send(buf, packet_len_table[0x80], bl, type == 1 ? AREA : AREA_WOS);
- if(disguised(bl)) {
- WBUFL(buf,2) = -bl->id;
- clif_send(buf, packet_len_table[0x80], bl, SELF);
- }
- return 0;
- }
- static int clif_clearchar_delay_sub(int tid, unsigned int tick, int id, int data) {
- struct block_list *bl = (struct block_list *)id;
- clif_clearchar(bl,data);
- aFree(bl);
- return 0;
- }
- int clif_clearchar_delay(unsigned int tick, struct block_list *bl, int type) {
- struct block_list *tbl;
- tbl = aMalloc(sizeof (struct block_list));
- memcpy (tbl, bl, sizeof (struct block_list));
- add_timer(tick, clif_clearchar_delay_sub, (int)tbl, type);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_clearchar_id(int id, int type, int fd) {
- WFIFOHEAD(fd, packet_len_table[0x80]);
- WFIFOW(fd,0) = 0x80;
- WFIFOL(fd,2) = id;
- WFIFOB(fd,6) = (char)type; // Why use int for a char in the first place?
- WFIFOSET(fd, packet_len_table[0x80]);
- return 0;
- }
- void clif_get_weapon_view(TBL_PC* sd, unsigned short *rhand, unsigned short *lhand)
- {
- #if PACKETVER > 3
- struct item_data *id;
- #endif
- if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
- {
- *rhand = *lhand = 0;
- return;
- }
- #if PACKETVER < 4
- *rhand = sd->status.weapon;
- *lhand = sd->status.shield;
- #else
- if (sd->equip_index[9] >= 0 && sd->inventory_data[sd->equip_index[9]])
- {
- id = sd->inventory_data[sd->equip_index[9]];
- if (id->view_id > 0)
- *rhand = id->view_id;
- else
- *rhand = id->nameid;
- } else
- *rhand = 0;
- if (sd->equip_index[8] >= 0 && sd->equip_index[8] != sd->equip_index[9]
- && sd->inventory_data[sd->equip_index[8]])
- {
- id = sd->inventory_data[sd->equip_index[8]];
- if (id->view_id > 0)
- *lhand = id->view_id;
- else
- *lhand = id->nameid;
- } else
- *lhand = 0;
- #endif
- }
- static void clif_get_guild_data(struct block_list *bl, long *guild_id, short *emblem_id)
- {
- //TODO: There has to be a way to clean this up.
- switch (bl->type) {
- case BL_PC:
- *guild_id = ((TBL_PC*)bl)->status.guild_id;
- *emblem_id = ((TBL_PC*)bl)->guild_emblem_id;
- break;
- case BL_MOB:
- if (((TBL_MOB*)bl)->guardian_data) {
- *guild_id =((TBL_MOB*)bl)->guardian_data->guild_id;
- *emblem_id =((TBL_MOB*)bl)->guardian_data->emblem_id;
- }
- break;
- case BL_NPC:
- if (bl->subtype == SCRIPT && ((TBL_NPC*)bl)->u.scr.guild_id > 0) {
- struct guild *g = guild_search(((TBL_NPC*)bl)->u.scr.guild_id);
- if (g) {
- *guild_id =g->guild_id;
- *emblem_id =g->emblem_id;
- }
- }
- break;
- default:
- *guild_id = status_get_guild_id(bl);
- }
- return;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- static int clif_set0078(struct block_list *bl, struct view_data *vd, unsigned char *buf) {
- struct status_change *sc;
- struct map_session_data *sd;
- long guild_id=0;
- unsigned short emblem_id=0, lv;
- unsigned short dir;
- nullpo_retr(0, bl);
- BL_CAST(BL_PC, bl, sd);
- sc = status_get_sc(bl);
- clif_get_guild_data(bl, &guild_id, &emblem_id);
- dir = unit_getdir(bl);
- lv = status_get_lv(bl);
- if(pcdb_checkid(vd->class_)) {
- #if PACKETVER > 6
- malloc_set(buf,0,packet_len_table[0x22a]);
- WBUFW(buf,0)=0x22a;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFL(buf,12)=sc->option;
- WBUFL(buf,44)=sc->opt3;
- }
- WBUFW(buf,16)=vd->class_;
- WBUFW(buf,18)=vd->hair_style;
- WBUFW(buf,20)=vd->weapon;
- WBUFW(buf,22)=vd->shield;
- WBUFW(buf,24)=vd->head_bottom;
- WBUFW(buf,26)=vd->head_top;
- WBUFW(buf,28)=vd->head_mid;
- WBUFW(buf,30)=vd->hair_color;
- WBUFW(buf,32)=vd->cloth_color;
- WBUFW(buf,34)=sd?sd->head_dir:dir;
- WBUFL(buf,36)=guild_id;
- WBUFW(buf,40)=emblem_id;
- if (sd) {
- WBUFW(buf,42)=sd->status.manner;
- WBUFB(buf,48)=sd->status.karma;
- }
- WBUFB(buf,49)=vd->sex;
- WBUFPOS(buf,50,bl->x,bl->y,dir);
- WBUFB(buf,53)=5;
- WBUFB(buf,54)=5;
- WBUFB(buf,55)=vd->dead_sit;
- WBUFW(buf,56)=clif_setlevel(lv);
- return packet_len_table[0x22a];
- #elif PACKETVER > 3
- malloc_set(buf,0,packet_len_table[0x1d8]);
- WBUFW(buf,0)=0x1d8;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- WBUFW(buf,42)=sc->opt3;
- }
- WBUFW(buf,14)=vd->class_;
- WBUFW(buf,16)=vd->hair_style;
- WBUFW(buf,18)=vd->weapon;
- WBUFW(buf,20)=vd->shield;
- WBUFW(buf,22)=vd->head_bottom;
- WBUFW(buf,24)=vd->head_top;
- WBUFW(buf,26)=vd->head_mid;
- WBUFW(buf,28)=vd->hair_color;
- WBUFW(buf,30)=vd->cloth_color;
- WBUFW(buf,32)=sd?sd->head_dir:dir;
- WBUFL(buf,34)=guild_id;
- WBUFW(buf,38)=emblem_id;
- if (sd) {
- WBUFW(buf,40)=sd->status.manner;
- WBUFB(buf,44)=sd->status.karma;
- }
- WBUFB(buf,45)=vd->sex;
- WBUFPOS(buf,46,bl->x,bl->y,dir);
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFB(buf,51)=vd->dead_sit;
- WBUFW(buf,52)=clif_setlevel(lv);
- return packet_len_table[0x1d8];
- #else
- malloc_set(buf,0,packet_len_table[0x78]);
- WBUFW(buf,0)=0x78;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- WBUFW(buf,42)=sc->opt3;
- }
- WBUFW(buf,14)=vd->class_;
- WBUFW(buf,16)=vd->hair_style;
- WBUFW(buf,18)=vd->weapon;
- WBUFW(buf,20)=vd->head_bottom;
- WBUFW(buf,22)=vd->shield;
- WBUFW(buf,24)=vd->head_top;
- WBUFW(buf,26)=vd->head_mid;
- WBUFW(buf,28)=vd->hair_color;
- WBUFW(buf,30)=vd->cloth_color;
- WBUFW(buf,32)=sd?sd->head_dir:dir;
- WBUFL(buf,34)=guild_id;
- WBUFL(buf,38)=emblem_id;
- if (sd)
- WBUFB(buf,44)=sd->status.karma;
- WBUFB(buf,45)=vd->sex;
- WBUFPOS(buf,46,bl->x,bl->y,dir);
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFB(buf,51)=vd->dead_sit;
- WBUFW(buf,52)=clif_setlevel(lv);
- return packet_len_table[0x78];
- #endif
- }
- //Non-player sprites need just a few fields filled.
- malloc_set(buf,0,packet_len_table[0x78]);
- WBUFW(buf,0)=0x78;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- WBUFW(buf,42)=sc->opt3;
- }
- WBUFW(buf,14)=vd->class_;
- WBUFW(buf,16)=vd->hair_style; //Required for pets.
- WBUFW(buf,20)=vd->head_bottom; //Pet armor
- if (bl->type == BL_NPC && vd->class_ == 722)
- { //The hell, why flags work like this?
- WBUFL(buf,22)=emblem_id;
- WBUFL(buf,26)=guild_id;
- }
- WBUFW(buf,32)=dir;
- WBUFL(buf,34)=guild_id;
- WBUFL(buf,38)=emblem_id;
- WBUFPOS(buf,46,bl->x,bl->y,dir);
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFW(buf,52)=clif_setlevel(lv);
- return packet_len_table[0x78];
- }
- /*==========================================
- *
- *------------------------------------------
- */
- static int clif_set007b(struct block_list *bl, struct view_data *vd, struct unit_data *ud, unsigned char *buf) {
- struct status_change *sc;
- struct map_session_data *sd;
- long guild_id=0;
- unsigned short emblem_id=0, lv;
- nullpo_retr(0, bl);
- BL_CAST(BL_PC, bl, sd);
- sc = status_get_sc(bl);
-
- clif_get_guild_data(bl, &guild_id, &emblem_id);
- lv = status_get_lv(bl);
-
- if(pcdb_checkid(vd->class_)) {
- #if PACKETVER > 6
- malloc_set(buf,0,packet_len_table[0x22c]);
- WBUFW(buf,0)=0x22c;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)= sc->opt1;
- WBUFW(buf,10)= sc->opt2;
- WBUFL(buf,12)= sc->option;
- WBUFL(buf,48)= sc->opt3;
- }
- WBUFW(buf,16)=vd->class_;
- WBUFW(buf,18)=vd->hair_style;
- WBUFW(buf,20)=vd->weapon;
- WBUFW(buf,22)=vd->shield;
- WBUFW(buf,24)=vd->head_bottom;
- WBUFL(buf,26)=gettick();
- WBUFW(buf,30)=vd->head_top;
- WBUFW(buf,32)=vd->head_mid;
- WBUFW(buf,34)=vd->hair_color;
- WBUFW(buf,36)=vd->cloth_color;
- WBUFW(buf,38)=sd?sd->head_dir:unit_getdir(bl);
- WBUFL(buf,40)=guild_id;
- WBUFW(buf,44)=emblem_id;
- if (sd) {
- WBUFW(buf,46)=sd->status.manner;
- WBUFB(buf,52)=sd->status.karma;
- }
- WBUFB(buf,53)=vd->sex;
- WBUFPOS2(buf,54,bl->x,bl->y,ud->to_x,ud->to_y);
- WBUFB(buf,59)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,60)=0;
- WBUFB(buf,61)=0;
- WBUFW(buf,62)=clif_setlevel(lv);
- return packet_len_table[0x22c];
- #elif PACKETVER > 3
- malloc_set(buf,0,packet_len_table[0x1da]);
- WBUFW(buf,0)=0x1da;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- WBUFW(buf,46)=sc->opt3;
- }
- WBUFW(buf,14)=vd->class_;
- WBUFW(buf,16)=vd->hair_style;
- WBUFW(buf,18)=vd->weapon;
- WBUFW(buf,20)=vd->shield;
- WBUFW(buf,22)=vd->head_bottom;
- WBUFL(buf,24)=gettick();
- WBUFW(buf,28)=vd->head_top;
- WBUFW(buf,30)=vd->head_mid;
- WBUFW(buf,32)=vd->hair_color;
- WBUFW(buf,34)=vd->cloth_color;
- WBUFW(buf,36)=sd?sd->head_dir:unit_getdir(bl);
- WBUFL(buf,38)=guild_id;
- WBUFW(buf,42)=emblem_id;
- if (sd) {
- WBUFW(buf,44)=sd->status.manner;
- WBUFB(buf,48)=sd->status.karma;
- }
- WBUFB(buf,49)=vd->sex;
- WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- WBUFW(buf,58)=clif_setlevel(lv);
- return packet_len_table[0x1da];
- #else
- malloc_set(buf,0,packet_len_table[0x7b]);
- WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- WBUFW(buf,46)=sc->opt3;
- }
- WBUFW(buf,14)=vd->class_;
- WBUFW(buf,16)=vd->hair_style;
- WBUFW(buf,18)=vd->weapon;
- WBUFW(buf,20)=vd->head_bottom;
- WBUFL(buf,22)=gettick();
- WBUFW(buf,26)=vd->shield;
- WBUFW(buf,28)=vd->head_top;
- WBUFW(buf,30)=vd->head_mid;
- WBUFW(buf,32)=vd->hair_color;
- WBUFW(buf,34)=vd->cloth_color;
- WBUFW(buf,36)=sd?sd->head_dir:unit_getdir(bl);
- WBUFL(buf,38)=guild_id;
- WBUFL(buf,42)=emblem_id;
- if (sd)
- WBUFB(buf,48)=sd->status.karma;
- WBUFB(buf,49)=vd->sex;
- WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- WBUFW(buf,58)=clif_setlevel(lv);
- return packet_len_table[0x7b];
- #endif
- }
- //Non-player sprites only require a few fields.
- #if PACKETVER > 6
- malloc_set(buf,0,packet_len_table[0x22c]);
- WBUFW(buf,0)=0x22c;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFL(buf,12)=sc->option;
- WBUFL(buf,48)=sc->opt3;
- }
- WBUFW(buf,16)=vd->class_;
- WBUFW(buf,18)=vd->hair_style; //For pets
- WBUFW(buf,24)=vd->head_bottom; //Pet armor
- WBUFL(buf,26)=gettick();
- WBUFW(buf,38)=unit_getdir(bl);
- WBUFL(buf,40)=guild_id;
- WBUFL(buf,44)=emblem_id;
- WBUFPOS2(buf,54,bl->x,bl->y,ud->to_x,ud->to_y);
- WBUFB(buf,59)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,60)=0;
- WBUFB(buf,61)=0;
- WBUFW(buf,62)=clif_setlevel(lv);
- return packet_len_table[0x22c];
- #else
- malloc_set(buf,0,packet_len_table[0x7b]);
- WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- WBUFW(buf,46)=sc->opt3;
- }
- WBUFW(buf,14)=vd->class_;
- WBUFW(buf,16)=vd->hair_style; //For pets
- WBUFW(buf,20)=vd->head_bottom; //Pet armor
- WBUFL(buf,22)=gettick();
- WBUFW(buf,36)=unit_getdir(bl);
- WBUFL(buf,38)=guild_id;
- WBUFL(buf,42)=emblem_id;
- WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- WBUFW(buf,58)=clif_setlevel(lv);
- return packet_len_table[0x7b];
- #endif
- }
- //Modifies the buffer for disguise characters and sends it to self.
- //Flag = 0: change id to negative, buf will have disguise data.
- //Flag = 1: change id to positive, class and option to make your own char invisible.
- //Luckily, the offsets that need to be changed are the same in packets 0x78, 0x7b, 0x1d8 and 0x1da
- //But no longer holds true for those packet of PACKETVER 7.
- static void clif_setdisguise(struct map_session_data *sd, unsigned char *buf,int len, int flag) {
- if (flag) {
- #if PACKETVER > 6
- switch (WBUFW(buf,0)) {
- case 0x22c:
- case 0x22b:
- case 0x22a:
- WBUFL(buf,12)=OPTION_INVISIBLE;
- WBUFW(buf,16)=sd->status.class_;
- break;
- default:
- #endif
- WBUFL(buf,2)=sd->bl.id;
- WBUFW(buf,12)=OPTION_INVISIBLE;
- WBUFW(buf,14)=sd->status.class_;
- #if PACKETVER > 6
- break;
- }
- #endif
- } else {
- WBUFL(buf,2)=-sd->bl.id;
- }
- clif_send(buf, len, &sd->bl, SELF);
- }
- /*==========================================
- * クラスチェンジ typeはMobの場合は1で他は0?
- *------------------------------------------
- */
- int clif_class_change(struct block_list *bl,int class_,int type)
- {
- unsigned char buf[16];
- nullpo_retr(0, bl);
- if(!pcdb_checkid(class_)) {
- WBUFW(buf,0)=0x1b0;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=type;
- WBUFL(buf,7)=class_;
- clif_send(buf,packet_len_table[0x1b0],bl,AREA);
- }
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- static void clif_spiritball_single(int fd, struct map_session_data *sd)
- {
- WFIFOHEAD(fd, packet_len_table[0x1e1]);
- WFIFOW(fd,0)=0x1e1;
- WFIFOL(fd,2)=sd->bl.id;
- WFIFOW(fd,6)=sd->spiritball;
- WFIFOSET(fd, packet_len_table[0x1e1]);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- static int clif_set0192(int fd, int m, int x, int y, int type) {
- WFIFOHEAD(fd, packet_len_table[0x192]);
- WFIFOW(fd,0) = 0x192;
- WFIFOW(fd,2) = x;
- WFIFOW(fd,4) = y;
- WFIFOW(fd,6) = type;
- memcpy(WFIFOP(fd,8),map[m].name,MAP_NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0x192]);
- return 0;
- }
- // new and improved weather display [Valaris]
- static void clif_weather_sub(int fd, int id, int type) {
- WFIFOHEAD(fd, packet_len_table[0x1f3]);
- WFIFOW(fd,0) = 0x1f3;
- WFIFOL(fd,2) = id;
- WFIFOL(fd,6) = type;
- WFIFOSET(fd,packet_len_table[0x1f3]);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- static void clif_weather_check(struct map_session_data *sd) {
- int m = sd->bl.m, fd = sd->fd;
-
- if (map[m].flag.snow
- || map[m].flag.clouds
- || map[m].flag.fog
- || map[m].flag.fireworks
- || map[m].flag.sakura
- || map[m].flag.leaves
- || map[m].flag.rain
- || map[m].flag.clouds2)
- {
- if (map[m].flag.snow)
- clif_weather_sub(fd, sd->bl.id, 162);
- if (map[m].flag.clouds)
- clif_weather_sub(fd, sd->bl.id, 233);
- if (map[m].flag.clouds2)
- clif_weather_sub(fd, sd->bl.id, 516);
- if (map[m].flag.fog)
- clif_weather_sub(fd, sd->bl.id, 515);
- if (map[m].flag.fireworks) {
- clif_weather_sub(fd, sd->bl.id, 297);
- clif_weather_sub(fd, sd->bl.id, 299);
- clif_weather_sub(fd, sd->bl.id, 301);
- }
- if (map[m].flag.sakura)
- clif_weather_sub(fd, sd->bl.id, 163);
- if (map[m].flag.leaves)
- clif_weather_sub(fd, sd->bl.id, 333);
- if (map[m].flag.rain)
- clif_weather_sub(fd, sd->bl.id, 161);
- }
- }
- int clif_weather(int m) {
- int i;
- struct map_session_data *sd=NULL;
- for(i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = session[i]->session_data) != NULL &&
- sd->state.auth && sd->bl.m == m) {
- clif_weather_check(sd);
- }
- }
- return 0;
- }
- int clif_spawn(struct block_list *bl)
- {
- unsigned char buf[128];
- struct view_data *vd;
- nullpo_retr(0, bl);
- vd = status_get_viewdata(bl);
- if (!vd || vd->class_ == INVISIBLE_CLASS)
- return 0;
- if (pcdb_checkid(vd->class_))
- { //Player spawn packet.
- clif_set0078(bl, vd, buf);
- switch(WBUFW(buf,0)) {
- case 0x78: //Convert to 0x79
- WBUFW(buf, 0) = 0x79;
- WBUFW(buf,51) = WBUFW(buf,52); //Lv is placed on offset 52
- clif_send(buf, packet_len_table[0x79], bl, AREA_WOS);
- if (disguised(bl))
- clif_setdisguise((TBL_PC*)bl, buf, packet_len_table[0x79], 0);
- break;
- #if PACKETVER > 3
- case 0x1d8: //Convert to 0x1d9
- WBUFW(buf, 0) = 0x1d9;
- WBUFW(buf,51) = WBUFW(buf,52); //Lv is placed on offset 52
- clif_send(buf, packet_len_table[0x1d9], bl, AREA_WOS);
- if (disguised(bl))
- clif_setdisguise((TBL_PC*)bl, buf, packet_len_table[0x1d9], 0);
- break;
- #endif
- #if PACKETVER > 6
- case 0x22a: //Convert to 0x22b
- WBUFW(buf, 0) = 0x22b;
- WBUFW(buf,55) = WBUFW(buf,56); //Lv is placed on offset 56
- clif_send(buf, packet_len_table[0x22b], bl, AREA_WOS);
- if (disguised(bl))
- clif_setdisguise((TBL_PC*)bl, buf, packet_len_table[0x22b], 0);
- break;
- #endif
- }
- } else { //Mob spawn packet.
- struct status_change *sc = status_get_sc(bl);
- malloc_tsetdword(buf,0,sizeof(buf));
- WBUFW(buf,0)=0x7c;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- }
- WBUFW(buf,20)=vd->class_;
- WBUFW(buf,22)=vd->hair_style; //Required for pets.
- WBUFW(buf,24)=vd->head_bottom; //Pet armor
- WBUFPOS(buf,36,bl->x,bl->y,unit_getdir(bl));
- clif_send(buf,packet_len_table[0x7c],bl,AREA_WOS);
- if (disguised(bl)) {
- WBUFL(buf,2)=-bl->id;
- clif_send(buf,packet_len_table[0x7c],bl,SELF);
- }
- }
-
- if (vd->cloth_color)
- clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
-
- switch (bl->type)
- {
- case BL_PC:
- {
- TBL_PC *sd = ((TBL_PC*)bl);
- if (sd->spiritball > 0)
- clif_spiritball(sd);
- if(sd->state.size==2) // tiny/big players [Valaris]
- clif_specialeffect(bl,423,AREA);
- else if(sd->state.size==1)
- clif_specialeffect(bl,421,AREA);
- }
- break;
- case BL_MOB:
- {
- TBL_MOB *md = ((TBL_MOB*)bl);
- if(md->special_state.size==2) // tiny/big mobs [Valaris]
- clif_specialeffect(&md->bl,423,AREA);
- else if(md->special_state.size==1)
- clif_specialeffect(&md->bl,421,AREA);
- }
- break;
- }
- return 0;
- }
- //[orn]
- int clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag)
- {
- struct status_data *status;
- unsigned char buf[128];
-
- nullpo_retr(0, hd);
- status = &hd->battle_status;
- malloc_set(buf,0,packet_len_table[0x22e]);
- WBUFW(buf,0)=0x22e;
- memcpy(WBUFP(buf,2),hd->homunculus.name,NAME_LENGTH);
- // Bit field, bit 0 : rename_flag (1 = already renamed), bit 1 : homunc vaporized (1 = true), bit 2 : homunc dead (1 = true)
- WBUFB(buf,26)=hd->homunculus.rename_flag | (hd->homunculus.vaporize << 1) | (hd->homunculus.hp?0:4);
- WBUFW(buf,27)=hd->homunculus.level;
- WBUFW(buf,29)=hd->homunculus.hunger;
- WBUFW(buf,31)=(unsigned short) (hd->homunculus.intimacy / 100) ;
- WBUFW(buf,33)=0; // equip id
- WBUFW(buf,35)=cap_value(status->rhw.atk2+status->batk, 0, SHRT_MAX);
- WBUFW(buf,37)=cap_value(status->matk_max, 0, SHRT_MAX);
- WBUFW(buf,39)=status->hit;
- WBUFW(buf,41)=status->luk/3 + 1; //crit is a +1 decimal value! Just display purpose.[Vicious]
- WBUFW(buf,43)=status->def + status->vit ;
- WBUFW(buf,45)=status->mdef;
- WBUFW(buf,47)=status->flee;
- WBUFW(buf,49)=(flag)?0:status->amotion;
- if (status->max_hp > SHRT_MAX) {
- WBUFW(buf,51) = status->hp/(status->max_hp/100);
- WBUFW(buf,53) = 100;
- } else {
- WBUFW(buf,51)=status->hp;
- WBUFW(buf,53)=status->max_hp;
- }
- if (status->max_sp > SHRT_MAX) {
- WBUFW(buf,55) = status->sp/(status->max_sp/100);
- WBUFW(buf,57) = 100;
- } else {
- WBUFW(buf,55)=status->sp;
- WBUFW(buf,57)=status->max_sp;
- }
- WBUFL(buf,59)=hd->homunculus.exp;
- WBUFL(buf,63)=hd->exp_next;
- WBUFW(buf,67)=hd->homunculus.skillpts;
- WBUFW(buf,69)=1; // FIXME: Attackable? When exactly is a homun not attackable? [Skotlex]
- clif_send(buf,packet_len_table[0x22e],&sd->bl,SELF);
- return 0;
- }
- void clif_send_homdata(struct map_session_data *sd, int type, int param) { //[orn]
- int fd;
- nullpo_retv(sd);
- nullpo_retv(sd->hd);
- fd=sd->fd;
- WFIFOW(fd,0)=0x230;
- WFIFOW(fd,2)=type;
- WFIFOL(fd,4)=sd->hd->bl.id;
- WFIFOL(fd,8)=param;
- WFIFOSET(fd,packet_len_table[0x230]);
- return;
- }
- int clif_homskillinfoblock(struct map_session_data *sd) { //[orn]
- struct homun_data *hd;
- int fd;
- int i,j,len=4,id;
- nullpo_retr(0, sd);
- hd = sd->hd;
- if ( !hd )
- return 0 ;
- fd=sd->fd;
- WFIFOW(fd,0)=0x235;
- for ( i = 0; i < MAX_HOMUNSKILL; i++){
- if( (id = hd->homunculus.hskill[i].id) != 0 ){
- j = id - HM_SKILLBASE - 1 ;
- WFIFOW(fd,len ) = id ;
- WFIFOW(fd,len+2) = skill_get_inf(id) ;
- WFIFOW(fd,len+4) = 0 ;
- WFIFOW(fd,len+6) = hd->homunculus.hskill[j].lv ;
- WFIFOW(fd,len+8) = skill_get_sp(id,hd->homunculus.hskill[j].lv) ;
- WFIFOW(fd,len+10)= skill_get_range2(&sd->hd->bl, id,hd->homunculus.hskill[j].lv) ;
- strncpy(WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH) ;
- WFIFOB(fd,len+36) = (hd->homunculus.hskill[j].lv < merc_skill_tree_get_max(id, hd->homunculus.class_))?1:0;
- len+=37;
- }
- }
- WFIFOW(fd,2)=len;
- WFIFOSET(fd,len);
- return 0;
- }
- void clif_homskillup(struct map_session_data *sd, int skill_num) { //[orn]
- struct homun_data *hd;
- int fd,skillid;
- nullpo_retv(sd);
- skillid = skill_num - HM_SKILLBASE - 1;
- fd=sd->fd;
- hd=sd->hd;
- WFIFOW(fd,0) = 0x239;
- WFIFOW(fd,2) = skill_num;
- WFIFOW(fd,4) = hd->homunculus.hskill[skillid].lv;
- WFIFOW(fd,6) = skill_get_sp(skill_num,hd->homunculus.hskill[skillid].lv);
- WFIFOW(fd,8) = skill_get_range2(&hd->bl, skill_num,hd->homunculus.hskill[skillid].lv);
- WFIFOB(fd,10) = (hd->homunculus.hskill[skillid].lv < skill_get_max(hd->homunculus.hskill[skillid].id)) ? 1 : 0;
- WFIFOSET(fd,packet_len_table[0x239]);
- return;
- }
- void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) { //[orn]
- struct homun_data *hd;
- nullpo_retv(sd);
- if((hd=sd->hd) == NULL)
- return;
- RFIFOHEAD(fd);
- memcpy(hd->homunculus.name,RFIFOP(fd,2),24);
- hd->homunculus.rename_flag = 1;
- clif_hominfo(sd,hd,0);
- clif_charnameack(sd->fd,&hd->bl);
- }
- void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd) { //[orn]
- nullpo_retv(sd);
- if(!merc_is_hom_active(sd->hd))
- return;
- if (!unit_can_move(&sd->hd->bl))
- return;
- unit_walktoxy(&sd->hd->bl, sd->bl.x,sd->bl.y-1, 0);
- }
- void clif_parse_HomMoveTo(int fd,struct map_session_data *sd) { //[orn]
- int x,y,cmd;
- nullpo_retv(sd);
- if(!merc_is_hom_active(sd->hd))
- return;
- cmd = RFIFOW(fd,0);
- x = RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]) * 4 +
- (RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0] + 1) >> 6);
- y = ((RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]+1) & 0x3f) << 4) +
- (RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0] + 2) >> 4);
- if (!unit_can_move(&sd->hd->bl))
- return;
- unit_walktoxy(&(sd->hd->bl),x,y,0);
- }
- void clif_parse_HomAttack(int fd,struct map_session_data *sd) { //[orn]
- struct block_list *target;
- nullpo_retv(sd);
- if(!merc_is_hom_active(sd->hd))
- return;
-
- if ((target = map_id2bl(RFIFOL(fd,6))) == NULL || status_isdead(target))
- return;
- merc_stop_walking(sd->hd, 1);
- merc_stop_attack(sd->hd);
- unit_attack(&sd->hd->bl,RFIFOL(fd,6),1) ;
- }
- void clif_parse_HomMenu(int fd, struct map_session_data *sd) { //[orn]
- int cmd;
- RFIFOHEAD(fd);
- cmd = RFIFOW(fd,0);
- if(!merc_is_hom_active(sd->hd))
- return;
- merc_menu(sd,RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]));
- }
- int clif_hom_food(struct map_session_data *sd,int foodid,int fail) //[orn]
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x22f]);
- WFIFOW(fd,0)=0x22f;
- WFIFOB(fd,2)=fail;
- WFIFOW(fd,3)=foodid;
- WFIFOSET(fd,packet_len_table[0x22f]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_walkok(struct map_session_data *sd)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x87]);
- WFIFOW(fd,0)=0x87;
- WFIFOL(fd,2)=gettick();
- WFIFOPOS2(fd,6,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y);
- WFIFOB(fd,11)=0x88;
- WFIFOSET(fd,packet_len_table[0x87]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_movepc(struct map_session_data *sd) {
- unsigned char buf[256];
- nullpo_retr(0, sd);
- if (map[sd->bl.m].flag.snow
- || map[sd->bl.m].flag.clouds
- || map[sd->bl.m].flag.fog
- || map[sd->bl.m].flag.fireworks
- || map[sd->bl.m].flag.sakura
- || map[sd->bl.m].flag.leaves
- || map[sd->bl.m].flag.rain
- || map[sd->bl.m].flag.clouds2
- ) {
- malloc_set(buf,0,packet_len_table[0x7b]);
- WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=-10;
- WBUFW(buf,6)=sd->battle_status.speed;
- WBUFW(buf,8)=0;
- WBUFW(buf,10)=0;
- WBUFW(buf,12)=OPTION_INVISIBLE;
- WBUFW(buf,14)=100;
- WBUFL(buf,22)=gettick();
- WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y);
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- clif_send(buf, packet_len_table[0x7b], &sd->bl, SELF);
- }
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_move(struct block_list *bl) {
- struct view_data *vd;
- struct unit_data *ud;
- unsigned char buf[256];
- int len;
- nullpo_retr(0, bl);
-
- vd = status_get_viewdata(bl);
- if (!vd || vd->class_ == INVISIBLE_CLASS)
- return 0;
-
- ud = unit_bl2ud(bl);
- nullpo_retr(0, ud);
-
- len = clif_set007b(bl,vd,ud,buf);
- clif_send(buf,len,bl,AREA_WOS);
- if (disguised(bl))
- clif_setdisguise((TBL_PC*)bl, buf, len, 0);
-
- //Stupid client that needs this resent every time someone walks :X
- if(vd->cloth_color)
- clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
- switch(bl->type)
- {
- case BL_PC:
- {
- TBL_PC *sd = ((TBL_PC*)bl);
- // clif_movepc(sd);
- if(sd->state.size==2) // tiny/big players [Valaris]
- clif_specialeffect(&sd->bl,423,AREA);
- else if(sd->state.size==1)
- clif_specialeffect(&sd->bl,421,AREA);
- }
- break;
- case BL_MOB:
- {
- TBL_MOB *md = ((TBL_MOB*)bl);
- if(md->special_state.size==2) // tiny/big mobs [Valaris]
- clif_specialeffect(&md->bl,423,AREA);
- else if(md->special_state.size==1)
- clif_specialeffect(&md->bl,421,AREA);
- }
- break;
- }
- return 0;
- }
- /*==========================================
- * Delays the map_quit of a player after they are disconnected. [Skotlex]
- *------------------------------------------
- */
- static int clif_delayquit(int tid, unsigned int tick, int id, int data) {
- struct map_session_data *sd = NULL;
- //Remove player from map server
- if ((sd = map_id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player.
- map_quit(sd);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_quitsave(int fd,struct map_session_data *sd)
- {
- if (sd->state.waitingdisconnect || //Was already waiting to be disconnected.
- !battle_config.prevent_logout ||
- DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
- map_quit(sd);
- else if (sd->fd)
- { //Disassociate session from player (session is deleted after this function was called)
- //And set a timer to make him quit later.
- session[fd]->session_data = NULL;
- sd->fd = 0;
- add_timer(gettick() + 10000, clif_delayquit, sd->bl.id, 0);
- }
- }
- /*==========================================
- *
- *------------------------------------------
- */
- static int clif_waitclose(int tid, unsigned int tick, int id, int data) {
- if (session[id] && session[id]->func_parse == clif_parse) //Avoid disconnecting non-players, as pointed out by End of Exam [Skotlex]
- session[id]->eof = 1;
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_setwaitclose(int fd) {
- struct map_session_data *sd;
- // if player is not already in the game (double connection probably)
- if ((sd = (struct map_session_data*)session[fd]->session_data) == NULL) {
- // limited timer, just to send information.
- add_timer(gettick() + 1000, clif_waitclose, fd, 0);
- } else
- add_timer(gettick() + 5000, clif_waitclose, fd, 0);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_changemap(struct map_session_data *sd, short map, int x, int y) {
- int fd;
-
- nullpo_retr(0, sd);
- fd = sd->fd;
-
- WFIFOHEAD(fd, packet_len_table[0x91]);
- WFIFOW(fd,0) = 0x91;
- memcpy(WFIFOP(fd,2), mapindex_id2name(map), MAP_NAME_LENGTH);
- WFIFOW(fd,18) = x;
- WFIFOW(fd,20) = y;
- WFIFOSET(fd, packet_len_table[0x91]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_changemapserver(struct map_session_data *sd, char *mapname, int x, int y, int ip, int port) {
- int fd;
- nullpo_retr(0, sd);
- fd = sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x92]);
- WFIFOW(fd,0) = 0x92;
- //Better not trust the null-terminator is there. [Skotlex]
- memcpy(WFIFOP(fd,2), mapname, MAP_NAME_LENGTH);
- WFIFOB(fd,17) = 0; //Null terminator for mapname
- WFIFOW(fd,18) = x;
- WFIFOW(fd,20) = y;
- WFIFOL(fd,22) = ip;
- WFIFOW(fd,26) = port;
- WFIFOSET(fd, packet_len_table[0x92]);
- return 0;
- }
- int clif_blown(struct block_list *bl) {
- //Previous Aegis versions simply used clif_fixpos, but it seems clif_slide works better on current clients.
- // return clif_fixpos(bl);
- return clif_slide(bl, bl->x, bl->y);
-
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_fixpos(struct block_list *bl) {
- unsigned char buf[16];
- nullpo_retr(0, bl);
- WBUFW(buf,0)=0x88;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=bl->x;
- WBUFW(buf,8)=bl->y;
- clif_send(buf, packet_len_table[0x88], bl, AREA);
- if (disguised(bl)) {
- WBUFL(buf,2)=-bl->id;
- clif_send(buf, packet_len_table[0x88], bl, SELF);
- }
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_npcbuysell(struct map_session_data* sd, int id) {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0xc4]);
- WFIFOW(fd,0)=0xc4;
- WFIFOL(fd,2)=id;
- WFIFOSET(fd,packet_len_table[0xc4]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_buylist(struct map_session_data *sd, struct npc_data *nd) {
- struct item_data *id;
- int fd,i,val;
- nullpo_retr(0, sd);
- nullpo_retr(0, nd);
- fd=sd->fd;
- WFIFOHEAD(fd, 200 * 11 + 4);
- WFIFOW(fd,0)=0xc6;
- for(i=0;nd->u.shop_item[i].nameid > 0;i++){
- id = itemdb_search(nd->u.shop_item[i].nameid);
- val=nd->u.shop_item[i].value;
- WFIFOL(fd,4+i*11)=val;
- if (!id->flag.value_notdc)
- val=pc_modifybuyvalue(sd,val);
- WFIFOL(fd,8+i*11)=val;
- WFIFOB(fd,12+i*11)=itemtype(id->type);
- if (id->view_id > 0)
- WFIFOW(fd,13+i*11)=id->view_id;
- else
- WFIFOW(fd,13+i*11)=nd->u.shop_item[i].nameid;
- }
- WFIFOW(fd,2)=i*11+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_selllist(struct map_session_data *sd) {
- int fd,i,c=0,val;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd, MAX_INVENTORY * 10 + 4);
- WFIFOW(fd,0)=0xc7;
- for(i=0;i<MAX_INVENTORY;i++) {
- if(sd->status.inventory[i].nameid > 0 && sd->inventory_data[i]) {
- if (!itemdb_cansell(&sd->status.inventory[i], pc_isGM(sd)))
- continue;
- val=sd->inventory_data[i]->value_sell;
- if (val < 0)
- continue;
- WFIFOW(fd,4+c*10)=i+2;
- WFIFOL(fd,6+c*10)=val;
- if (!sd->inventory_data[i]->flag.value_notoc)
- val=pc_modifysellvalue(sd,val);
- WFIFOL(fd,10+c*10)=val;
- c++;
- }
- }
- WFIFOW(fd,2)=c*10+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_scriptmes(struct map_session_data *sd, int npcid, char *mes) {
- int fd;
- int slen = strlen(mes) + 9;
- WFIFOHEAD(fd, slen);
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOW(fd,0)=0xb4;
- WFIFOW(fd,2)=slen;
- WFIFOL(fd,4)=npcid;
- strcpy((char*)WFIFOP(fd,8),mes);
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_scriptnext(struct map_session_data *sd,int npcid) {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0xb5]);
- WFIFOW(fd,0)=0xb5;
- WFIFOL(fd,2)=npcid;
- WFIFOSET(fd,packet_len_table[0xb5]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_scriptclose(struct map_session_data *sd, int npcid) {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0xb6]);
- WFIFOW(fd,0)=0xb6;
- WFIFOL(fd,2)=npcid;
- WFIFOSET(fd,packet_len_table[0xb6]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_sendfakenpc(struct map_session_data *sd, int npcid) {
- int fd = sd->fd;
- //sd->npc_id = npcid;
- sd->state.using_fake_npc = 1;
- malloc_set(WFIFOP(fd,0), 0, packet_len_table[0x78]);
- WFIFOW(fd,0)=0x78;
- WFIFOL(fd,2)=npcid;
- WFIFOW(fd,14)=111;
- WFIFOPOS(fd,46,sd->bl.x,sd->bl.y,sd->ud.dir);
- WFIFOB(fd,49)=5;
- WFIFOB(fd,50)=5;
- WFIFOSET(fd, packet_len_table[0x78]);
- return;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_scriptmenu(struct map_session_data *sd, int npcid, char *mes) {
- int fd;
- int slen = strlen(mes) + 8;
- struct block_list *bl = NULL;
- WFIFOHEAD(fd, slen);
- nullpo_retr(0, sd);
- if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
- bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
- bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
- clif_sendfakenpc(sd, npcid);
- fd=sd->fd;
- WFIFOW(fd,0)=0xb7;
- WFIFOW(fd,2)=slen;
- WFIFOL(fd,4)=npcid;
- strcpy((char*)WFIFOP(fd,8),mes);
- WFIFOSET(fd,WFIFOW(fd,2));
-
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_scriptinput(struct map_session_data *sd, int npcid) {
- int fd;
- struct block_list *bl = NULL;
- nullpo_retr(0, sd);
- if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
- bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
- bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
- clif_sendfakenpc(sd, npcid);
-
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x142]);
- WFIFOW(fd,0)=0x142;
- WFIFOL(fd,2)=npcid;
- WFIFOSET(fd,packet_len_table[0x142]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_scriptinputstr(struct map_session_data *sd, int npcid) {
- int fd;
- struct block_list *bl = NULL;
- nullpo_retr(0, sd);
- if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
- bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
- bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
- clif_sendfakenpc(sd, npcid);
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x1d4]);
- WFIFOW(fd,0)=0x1d4;
- WFIFOL(fd,2)=npcid;
- WFIFOSET(fd,packet_len_table[0x1d4]);
-
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, int y, int id, int color) {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x144]);
- WFIFOW(fd,0)=0x144;
- WFIFOL(fd,2)=npc_id;
- WFIFOL(fd,6)=type;
- WFIFOL(fd,10)=x;
- WFIFOL(fd,14)=y;
- WFIFOB(fd,18)=id;
- WFIFOL(fd,19)=color;
- WFIFOSET(fd,packet_len_table[0x144]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_cutin(struct map_session_data *sd, char *image, int type) {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x1b3]);
- WFIFOW(fd,0)=0x1b3;
- strncpy((char*)WFIFOP(fd,2),image,64);
- WFIFOB(fd,66)=type;
- WFIFOSET(fd,packet_len_table[0x1b3]);
- return 0;
- }
- /*==========================================
- * Fills in card data from the given item and into the buffer. [Skotlex]
- *------------------------------------------
- */
- static void clif_addcards(unsigned char* buf, struct item* item)
- {
- int i=0,j;
- if (item == NULL) { //Blank data
- WBUFW(buf,0)=0;
- WBUFW(buf,2)=0;
- WBUFW(buf,4)=0;
- WBUFW(buf,6)=0;
- return;
- }
- if(item->card[0]==CARD0_PET) { //pet eggs
- WBUFW(buf,0)=0;
- WBUFW(buf,2)=0;
- WBUFW(buf,4)=0;
- WBUFW(buf,6)=item->card[3]; //Pet renamed flag.
- return;
- }
- if(item->card[0]==CARD0_FORGE || item->card[0]==CARD0_CREATE) { //Forged/created items
- WBUFW(buf,0)=item->card[0];
- WBUFW(buf,2)=item->card[1];
- WBUFW(buf,4)=item->card[2];
- WBUFW(buf,6)=item->card[3];
- return;
- }
- //Client only receives four cards.. so randomly send them a set of cards. [Skotlex]
- if (MAX_SLOTS > 4 && (j = itemdb_slot(item->nameid)) > 4)
- i = rand()%(j-3); //eg: 6 slots, possible i values: 0->3, 1->4, 2->5 => i = rand()%3;
- //Normal items.
- if (item->card[i] > 0 && (j=itemdb_viewid(item->card[i])) > 0)
- WBUFW(buf,0)=j;
- else
- WBUFW(buf,0)= item->card[i];
- if (item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0)
- WBUFW(buf,2)=j;
- else
- WBUFW(buf,2)=item->card[i];
- if (item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0)
- WBUFW(buf,4)=j;
- else
- WBUFW(buf,4)=item->card[i];
- if (item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0)
- WBUFW(buf,6)=j;
- else
- WBUFW(buf,6)=item->card[i];
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_additem(struct map_session_data *sd, int n, int amount, int fail) {
- int fd;
- unsigned char *buf;
- nullpo_retr(0, sd);
- fd = sd->fd;
- if (!session_isActive(fd)) //Sasuke-
- return 0;
- WFIFOHEAD(fd,packet_len_table[0xa0]);
- buf = WFIFOP(fd,0);
- if(fail) {
- WBUFW(buf,0)=0xa0;
- WBUFW(buf,2)=n+2;
- WBUFW(buf,4)=amount;
- WBUFW(buf,6)=0;
- WBUFB(buf,8)=0;
- WBUFB(buf,9)=0;
- WBUFB(buf,10)=0;
- WBUFW(buf,11)=0;
- WBUFW(buf,13)=0;
- WBUFW(buf,15)=0;
- WBUFW(buf,17)=0;
- WBUFW(buf,19)=0;
- WBUFB(buf,21)=0;
- WBUFB(buf,22)=fail;
- } else {
- if (n<0 || n>=MAX_INVENTORY || sd->status.inventory[n].nameid <=0 || sd->inventory_data[n] == NULL)
- return 1;
- WBUFW(buf,0)=0xa0;
- WBUFW(buf,2)=n+2;
- WBUFW(buf,4)=amount;
- if (sd->inventory_data[n]->view_id > 0)
- WBUFW(buf,6)=sd->inventory_data[n]->view_id;
- else
- WBUFW(buf,6)=sd->status.inventory[n].nameid;
- WBUFB(buf,8)=sd->status.inventory[n].identify;
- WBUFB(buf,9)=sd->status.inventory[n].attribute;
- WBUFB(buf,10)=sd->status.inventory[n].refine;
- clif_addcards(WBUFP(buf,11), &sd->status.inventory[n]);
- WBUFW(buf,19)=pc_equippoint(sd,n);
- WBUFB(buf,21)=itemtype(sd->inventory_data[n]->type);
- WBUFB(buf,22)=fail;
- }
- WFIFOSET(fd,packet_len_table[0xa0]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_delitem(struct map_session_data *sd,int n,int amount)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0xaf]);
- WFIFOW(fd,0)=0xaf;
- WFIFOW(fd,2)=n+2;
- WFIFOW(fd,4)=amount;
- WFIFOSET(fd,packet_len_table[0xaf]);
- return 0;
- }
- // Simplifies inventory/cart/storage packets by handling the packet section relevant to items. [Skotlex]
- // Equip is >= 0 for equippable items (holds the equip-point, is 0 for pet
- // armor/egg) -1 for stackable items, -2 for stackable items where arrows must send in the equip-point.
- void clif_item_sub(unsigned char *buf, int n, struct item *i, struct item_data *id, int equip)
- {
- if (id->view_id > 0)
- WBUFW(buf,n)=id->view_id;
- else
- WBUFW(buf,n)=i->nameid;
- WBUFB(buf,n+2)=itemtype(id->type);
- WBUFB(buf,n+3)=i->identify;
- if (equip >= 0) { //Equippable item
- WBUFW(buf,n+4)=equip;
- WBUFW(buf,n+6)=i->equip;
- WBUFB(buf,n+8)=i->attribute;
- WBUFB(buf,n+9)=i->refine;
- } else { //Stackable item.
- WBUFW(buf,n+4)=i->amount;
- if (equip == -2 && id->equip == EQP_AMMO)
- WBUFW(buf,n+6)=EQP_AMMO;
- else
- WBUFW(buf,n+6)=0;
- }
- }
- //Unified inventory function which sends all of the inventory (requires two packets, one for equipable items and one for stackable ones. [Skotlex]
- void clif_inventorylist(struct map_session_data *sd)
- {
- int i,n,ne,fd = sd->fd,arrow=-1;
- unsigned char *buf;
- unsigned char bufe[MAX_INVENTORY*20+4];
- #if PACKETVER < 5
- const int s = 10; //Entry size.
- #else
- const int s = 18;
- #endif
- WFIFOHEAD(fd, MAX_INVENTORY * s + 4);
- buf = WFIFOP(fd,0);
-
- for(i=0,n=0,ne=0;i<MAX_INVENTORY;i++){
- if (sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL)
- continue;
-
- if(!itemdb_isstackable2(sd->inventory_data[i]))
- { //Non-stackable (Equippable)
- WBUFW(bufe,ne*20+4)=i+2;
- clif_item_sub(bufe, ne*20+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i));
- clif_addcards(WBUFP(bufe, ne*20+16), &sd->status.inventory[i]);
- ne++;
- } else { //Stackable.
- WBUFW(buf,n*s+4)=i+2;
- clif_item_sub(buf, n*s+6, &sd->status.inventory[i], sd->inventory_data[i], -2);
- if (sd->inventory_data[i]->equip == EQP_AMMO &&
- sd->status.inventory[i].equip)
- arrow=i;
- #if PACKETVER >= 5
- clif_addcards(WBUFP(buf, n*s+14), &sd->status.inventory[i]);
- #endif
- n++;
- }
- }
- if (n) {
- #if PACKETVER < 5
- WBUFW(buf,0)=0xa3;
- #else
- WBUFW(buf,0)=0x1ee;
- #endif
- WBUFW(buf,2)=4+n*s;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- if(arrow >= 0)
- clif_arrowequip(sd,arrow);
- if(ne){
- WBUFW(bufe,0)=0xa4;
- WBUFW(bufe,2)=4+ne*20;
- clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
- }
- }
- //Required when items break/get-repaired. Only sends equippable item list.
- void clif_equiplist(struct map_session_data *sd)
- {
- int i,n,fd = sd->fd;
- unsigned char *buf;
- WFIFOHEAD(fd, MAX_INVENTORY * 20 + 4);
- buf = WFIFOP(fd,0);
-
- for(i=0,n=0;i<MAX_INVENTORY;i++){
- if (sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL)
- continue;
-
- if(itemdb_isstackable2(sd->inventory_data[i]))
- continue;
- //Equippable
- WBUFW(buf,n*20+4)=i+2;
- clif_item_sub(buf, n*20+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i));
- clif_addcards(WBUFP(buf, n*20+16), &sd->status.inventory[i]);
- n++;
- }
- if (n) {
- WBUFW(buf,0)=0xa4;
- WBUFW(buf,2)=4+n*20;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- }
- //Unified storage function which sends all of the storage (requires two packets, one for equipable items and one for stackable ones. [Skotlex]
- void clif_storagelist(struct map_session_data *sd,struct storage *stor)
- {
- struct item_data *id;
- int i,n,ne,fd=sd->fd;
- unsigned char *buf;
- unsigned char bufe[MAX_STORAGE*20+4];
- #if PACKETVER < 5
- const int s = 10; //Entry size.
- #else
- const int s = 18;
- #endif
- WFIFOHEAD(fd,MAX_STORAGE * s + 4);
- buf = WFIFOP(fd,0);
-
- for(i=0,n=0,ne=0;i<MAX_STORAGE;i++){
- if(stor->storage_[i].nameid<=0)
- continue;
- id = itemdb_search(stor->storage_[i].nameid);
- if(!itemdb_isstackable2(id))
- { //Equippable
- WBUFW(bufe,ne*20+4)=i+1;
- clif_item_sub(bufe, ne*20+6, &stor->storage_[i], id, id->equip);
- clif_addcards(WBUFP(bufe, ne*20+16), &stor->storage_[i]);
- ne++;
- } else { //Stackable
- WBUFW(buf,n*s+4)=i+1;
- clif_item_sub(buf, n*s+6, &stor->storage_[i], id,-1);
- #if PACKETVER >= 5
- clif_addcards(WBUFP(buf,n*s+14), &stor->storage_[i]);
- #endif
- n++;
- }
- }
- if(n){
- #if PACKETVER < 5
- WBUFW(buf,0)=0xa5;
- #else
- WBUFW(buf,0)=0x1f0;
- #endif
- WBUFW(buf,2)=4+n*s;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- if(ne){
- WBUFW(bufe,0)=0xa6;
- WBUFW(bufe,2)=4+ne*20;
- clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
- }
- }
- //Unified storage function which sends all of the storage (requires two packets, one for equipable items and one for stackable ones. [Skotlex]
- void clif_guildstoragelist(struct map_session_data *sd,struct guild_storage *stor)
- {
- struct item_data *id;
- int i,n,ne,fd=sd->fd;
- unsigned char *buf;
- unsigned char bufe[MAX_GUILD_STORAGE*20+4];
- #if PACKETVER < 5
- const int s = 10; //Entry size.
- #else
- const int s = 18;
- #endif
- WFIFOHEAD(fd,MAX_GUILD_STORAGE * s + 4);
- buf = WFIFOP(fd,0);
-
- for(i=0,n=0,ne=0;i<MAX_GUILD_STORAGE;i++){
- if(stor->storage_[i].nameid<=0)
- continue;
- id = itemdb_search(stor->storage_[i].nameid);
- if(!itemdb_isstackable2(id))
- { //Equippable
- WBUFW(bufe,ne*20+4)=i+1;
- clif_item_sub(bufe, ne*20+6, &stor->storage_[i], id, id->equip);
- clif_addcards(WBUFP(bufe, ne*20+16), &stor->storage_[i]);
- ne++;
- } else { //Stackable
- WBUFW(buf,n*s+4)=i+1;
- clif_item_sub(buf, n*s+6, &stor->storage_[i], id,-1);
- #if PACKETVER >= 5
- clif_addcards(WBUFP(buf,n*s+14), &stor->storage_[i]);
- #endif
- n++;
- }
- }
- if(n){
- #if PACKETVER < 5
- WBUFW(buf,0)=0xa5;
- #else
- WBUFW(buf,0)=0x1f0;
- #endif
- WBUFW(buf,2)=4+n*s;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- if(ne){
- WBUFW(bufe,0)=0xa6;
- WBUFW(bufe,2)=4+ne*20;
- clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
- }
- }
- void clif_cartlist(struct map_session_data *sd)
- {
- struct item_data *id;
- int i,n,ne,fd=sd->fd;
- unsigned char *buf;
- unsigned char bufe[MAX_CART*20+4];
- #if PACKETVER < 5
- const int s = 10; //Entry size.
- #else
- const int s = 18;
- #endif
- WFIFOHEAD(fd, MAX_CART * s + 4);
- buf = WFIFOP(fd,0);
-
- for(i=0,n=0,ne=0;i<MAX_CART;i++){
- if(sd->status.cart[i].nameid<=0)
- continue;
- id = itemdb_search(sd->status.cart[i].nameid);
- if(!itemdb_isstackable2(id))
- { //Equippable
- WBUFW(bufe,ne*20+4)=i+2;
- clif_item_sub(bufe, ne*20+6, &sd->status.cart[i], id, id->equip);
- clif_addcards(WBUFP(bufe, ne*20+16), &sd->status.cart[i]);
- ne++;
- } else { //Stackable
- WBUFW(buf,n*s+4)=i+2;
- clif_item_sub(buf, n*s+6, &sd->status.cart[i], id,-1);
- #if PACKETVER >= 5
- clif_addcards(WBUFP(buf,n*s+14), &sd->status.cart[i]);
- #endif
- n++;
- }
- }
- if(n){
- #if PACKETVER < 5
- WBUFW(buf,0)=0x123;
- #else
- WBUFW(buf,0)=0x1ef;
- #endif
- WBUFW(buf,2)=4+n*s;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- if(ne){
- WBUFW(bufe,0)=0x122;
- WBUFW(bufe,2)=4+ne*20;
- clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
- }
- return;
- }
- // Guild XY locators [Valaris]
- int clif_guild_xy(struct map_session_data *sd)
- {
- unsigned char buf[10];
- nullpo_retr(0, sd);
- WBUFW(buf,0)=0x1eb;
- WBUFL(buf,2)=sd->status.account_id;
- WBUFW(buf,6)=sd->bl.x;
- WBUFW(buf,8)=sd->bl.y;
- clif_send(buf,packet_len_table[0x1eb],&sd->bl,GUILD_SAMEMAP_WOS);
- return 0;
- }
- /*==========================================
- * Sends x/y dot to a single fd. [Skotlex]
- *------------------------------------------
- */
- int clif_guild_xy_single(int fd, struct map_session_data *sd)
- {
- WFIFOHEAD(fd,packet_len_table[0x1eb]);
- WFIFOW(fd,0)=0x1eb;
- WFIFOL(fd,2)=sd->status.account_id;
- WFIFOW(fd,6)=sd->bl.x;
- WFIFOW(fd,8)=sd->bl.y;
- WFIFOSET(fd,packet_len_table[0x1eb]);
- return 0;
- }
- // Guild XY locators [Valaris]
- int clif_guild_xy_remove(struct map_session_data *sd)
- {
- unsigned char buf[10];
- nullpo_retr(0, sd);
- WBUFW(buf,0)=0x1eb;
- WBUFL(buf,2)=sd->status.account_id;
- WBUFW(buf,6)=-1;
- WBUFW(buf,8)=-1;
- clif_send(buf,packet_len_table[0x1eb],&sd->bl,GUILD_SAMEMAP_WOS);
- return 0;
- }
- /*==========================================
- * ステータスを送りつける
- * 表示専用数字はこの中で計算して送る
- *------------------------------------------
- */
- int clif_updatestatus(struct map_session_data *sd,int type)
- {
- int fd,len=8;
- nullpo_retr(0, sd);
- fd=sd->fd;
- if ( !session_isActive(fd) ) // Invalid pointer fix, by sasuke [Kevin]
- return 0;
-
- WFIFOHEAD(fd, 14);
- WFIFOW(fd,0)=0xb0;
- WFIFOW(fd,2)=type;
- switch(type){
- // 00b0
- case SP_WEIGHT:
- pc_checkweighticon(sd);
- WFIFOW(fd,0)=0xb0; //Need to re-set as pc_checkweighticon can alter the buffer. [Skotlex]
- WFIFOW(fd,2)=type;
- WFIFOL(fd,4)=sd->weight;
- break;
- case SP_MAXWEIGHT:
- WFIFOL(fd,4)=sd->max_weight;
- break;
- case SP_SPEED:
- WFIFOL(fd,4)=sd->battle_status.speed;
- break;
- case SP_BASELEVEL:
- WFIFOL(fd,4)=sd->status.base_level;
- break;
- case SP_JOBLEVEL:
- WFIFOL(fd,4)=sd->status.job_level;
- break;
- case SP_KARMA: // Adding this back, I wonder if the client intercepts this - [Lance]
- WFIFOL(fd,4)=sd->status.karma;
- break;
- case SP_MANNER:
- WFIFOL(fd,4)=sd->status.manner;
- clif_changestatus(&sd->bl,SP_MANNER,sd->status.manner);
- break;
- case SP_STATUSPOINT:
- WFIFOL(fd,4)=sd->status.status_point;
- break;
- case SP_SKILLPOINT:
- WFIFOL(fd,4)=sd->status.skill_point;
- break;
- case SP_HIT:
- WFIFOL(fd,4)=sd->battle_status.hit;
- break;
- case SP_FLEE1:
- WFIFOL(fd,4)=sd->battle_status.flee;
- break;
- case SP_FLEE2:
- WFIFOL(fd,4)=sd->battle_status.flee2/10;
- break;
- case SP_MAXHP:
- WFIFOL(fd,4)=sd->battle_status.max_hp;
- break;
- case SP_MAXSP:
- WFIFOL(fd,4)=sd->battle_status.max_sp;
- break;
- case SP_HP:
- WFIFOL(fd,4)=sd->battle_status.hp;
- if (battle_config.disp_hpmeter)
- clif_hpmeter(sd);
- if (!battle_config.party_hp_mode && sd->status.party_id)
- clif_party_hp(sd);
- break;
- case SP_SP:
- WFIFOL(fd,4)=sd->battle_status.sp;
- break;
- case SP_ASPD:
- WFIFOL(fd,4)=sd->battle_status.amotion;
- break;
- case SP_ATK1:
- WFIFOL(fd,4)=sd->battle_status.batk +sd->battle_status.rhw.atk +sd->battle_status.lhw->atk;
- break;
- case SP_DEF1:
- WFIFOL(fd,4)=sd->battle_status.def;
- break;
- case SP_MDEF1:
- WFIFOL(fd,4)=sd->battle_status.mdef;
- break;
- case SP_ATK2:
- WFIFOL(fd,4)=sd->battle_status.rhw.atk2 + sd->battle_status.lhw->atk2;
- break;
- case SP_DEF2:
- WFIFOL(fd,4)=sd->battle_status.def2;
- break;
- case SP_MDEF2:
- //negative check (in case you have something like Berserk active)
- len = sd->battle_status.mdef2 - (sd->battle_status.vit>>1);
- if (len < 0) len = 0;
- WFIFOL(fd,4)= len;
- len = 8;
- break;
- case SP_CRITICAL:
- WFIFOL(fd,4)=sd->battle_status.cri/10;
- break;
- case SP_MATK1:
- WFIFOL(fd,4)=sd->battle_status.matk_max;
- break;
- case SP_MATK2:
- WFIFOL(fd,4)=sd->battle_status.matk_min;
- break;
- case SP_ZENY:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=sd->status.zeny;
- break;
- case SP_BASEEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=sd->status.base_exp;
- break;
- case SP_JOBEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=sd->status.job_exp;
- break;
- case SP_NEXTBASEEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=pc_nextbaseexp(sd);
- break;
- case SP_NEXTJOBEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=pc_nextjobexp(sd);
- break;
- // 00be 終了
- case SP_USTR:
- case SP_UAGI:
- case SP_UVIT:
- case SP_UINT:
- case SP_UDEX:
- case SP_ULUK:
- WFIFOW(fd,0)=0xbe;
- WFIFOB(fd,4)=pc_need_status_point(sd,type-SP_USTR+SP_STR);
- len=5;
- break;
- // 013a 終了
- case SP_ATTACKRANGE:
- WFIFOW(fd,0)=0x13a;
- WFIFOW(fd,2)=sd->battle_status.rhw.range;
- len=4;
- break;
- // 0141 終了
- case SP_STR:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.str;
- WFIFOL(fd,10)=sd->battle_status.str - sd->status.str;
- len=14;
- break;
- case SP_AGI:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.agi;
- WFIFOL(fd,10)=sd->battle_status.agi - sd->status.agi;
- len=14;
- break;
- case SP_VIT:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.vit;
- WFIFOL(fd,10)=sd->battle_status.vit - sd->status.vit;
- len=14;
- break;
- case SP_INT:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.int_;
- WFIFOL(fd,10)=sd->battle_status.int_ - sd->status.int_;
- len=14;
- break;
- case SP_DEX:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.dex;
- WFIFOL(fd,10)=sd->battle_status.dex - sd->status.dex;
- len=14;
- break;
- case SP_LUK:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.luk;
- WFIFOL(fd,10)=sd->battle_status.luk - sd->status.luk;
- len=14;
- break;
- case SP_CARTINFO:
- WFIFOW(fd,0)=0x121;
- WFIFOW(fd,2)=sd->cart_num;
- WFIFOW(fd,4)=sd->cart_max_num;
- WFIFOL(fd,6)=sd->cart_weight;
- WFIFOL(fd,10)=sd->cart_max_weight;
- len=14;
- break;
- default:
- if(battle_config.error_log)
- ShowError("clif_updatestatus : unrecognized type %d\n",type);
- return 1;
- }
- WFIFOSET(fd,len);
- return 0;
- }
- int clif_changestatus(struct block_list *bl,int type,int val)
- {
- unsigned char buf[12];
- struct map_session_data *sd = NULL;
- nullpo_retr(0, bl);
- if(bl->type == BL_PC)
- sd = (struct map_session_data *)bl;
- //printf("clif_changestatus id:%d type:%d val:%d\n",bl->id,type,val);
- if(sd){
- WBUFW(buf,0)=0x1ab;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=type;
- switch(type){
- case SP_MANNER:
- WBUFL(buf,8)=val;
- break;
- default:
- if(battle_config.error_log)
- ShowError("clif_changestatus : unrecognized type %d.\n",type);
- return 1;
- }
- clif_send(buf,packet_len_table[0x1ab],bl,AREA_WOS);
- }
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_changelook(struct block_list *bl,int type,int val)
- {
- unsigned char buf[32];
- struct map_session_data *sd = NULL;
- struct view_data *vd;
- vd = status_get_viewdata(bl);
- nullpo_retr(0, vd);
-
- if(bl->type == BL_PC)
- sd = (struct map_session_data *)bl;
- switch(type) {
- case LOOK_WEAPON:
- if (sd) clif_get_weapon_view(sd, &vd->weapon, &vd->shield);
- else vd->weapon = val;
- break;
- case LOOK_SHIELD:
- if (sd) clif_get_weapon_view(sd, &vd->weapon, &vd->shield);
- else vd->shield = val;
- break;
- case LOOK_BASE:
- vd->class_ = val;
- if (vd->class_ == JOB_WEDDING || vd->class_ == JOB_XMAS)
- vd->weapon = vd->shield = 0;
- if (vd->cloth_color && (
- (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) ||
- (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette)
- ))
- clif_changelook(bl,LOOK_CLOTHES_COLOR,0);
- break;
- case LOOK_HAIR:
- vd->hair_style = val;
- break;
- case LOOK_HEAD_BOTTOM:
- vd->head_bottom = val;
- break;
- case LOOK_HEAD_TOP:
- vd->head_top = val;
- break;
- case LOOK_HEAD_MID:
- vd->head_mid = val;
- break;
- case LOOK_HAIR_COLOR:
- vd->hair_color = val;
- break;
- case LOOK_CLOTHES_COLOR:
- if (val && (
- (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) ||
- (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette)
- ))
- val = 0;
- vd->cloth_color = val;
- break;
- case LOOK_SHOES:
- #if PACKETVER > 3
- if (sd) {
- int n;
- if((n = sd->equip_index[2]) >= 0 && sd->inventory_data[n]) {
- if(sd->inventory_data[n]->view_id > 0)
- val = sd->inventory_data[n]->view_id;
- else
- val = sd->status.inventory[n].nameid;
- }
- val = 0;
- }
- #endif
- //Shoes? No packet uses this....
- break;
- }
- #if PACKETVER < 4
- WBUFW(buf,0)=0xc3;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=type;
- WBUFB(buf,7)=val;
- clif_send(buf,packet_len_table[0xc3],bl,AREA);
- #else
- if(type == LOOK_WEAPON || type == LOOK_SHIELD) {
- WBUFW(buf,0)=0x1d7;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=LOOK_WEAPON;
- WBUFW(buf,7)=vd->weapon;
- WBUFW(buf,9)=vd->shield;
- clif_send(buf,packet_len_table[0x1d7],bl,AREA);
- }
- else
- {
- WBUFW(buf,0)=0x1d7;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=type;
- WBUFW(buf,7)=val;
- WBUFW(buf,9)=0;
- clif_send(buf,packet_len_table[0x1d7],bl,AREA);
- }
- #endif
- return 0;
- }
- //Sends a change-base-look packet required for traps as they are triggered.
- void clif_changetraplook(struct block_list *bl,int val)
- {
- unsigned char buf[32];
- #if PACKETVER < 4
- WBUFW(buf,0)=0xc3;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=LOOK_BASE;
- WBUFB(buf,7)=val;
- clif_send(buf,packet_len_table[0xc3],bl,AREA);
- #else
- WBUFW(buf,0)=0x1d7;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=LOOK_BASE;
- WBUFW(buf,7)=val;
- WBUFW(buf,9)=0;
- clif_send(buf,packet_len_table[0x1d7],bl,AREA);
- #endif
-
- }
- //For the stupid cloth-dye bug. Resends the given view data
- //to the area specified by bl.
- void clif_refreshlook(struct block_list *bl,int id,int type,int val,int area)
- {
- unsigned char buf[32];
- #if PACKETVER < 4
- WBUFW(buf,0)=0xc3;
- WBUFL(buf,2)=id;
- WBUFB(buf,6)=type;
- WBUFB(buf,7)=val;
- clif_send(buf,packet_len_table[0xc3],bl,area);
- #else
- WBUFW(buf,0)=0x1d7;
- WBUFL(buf,2)=id;
- WBUFB(buf,6)=type;
- WBUFW(buf,7)=val;
- WBUFW(buf,9)=0;
- clif_send(buf,packet_len_table[0x1d7],bl,area);
- #endif
- return;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_initialstatus(struct map_session_data *sd)
- {
- int fd;
- unsigned char *buf;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xbd]);
- buf=WFIFOP(fd,0);
- WBUFW(buf,0)=0xbd;
- WBUFW(buf,2)=(sd->status.status_point > SHRT_MAX)? SHRT_MAX:sd->status.status_point;
- WBUFB(buf,4)=(sd->status.str > UCHAR_MAX)? UCHAR_MAX:sd->status.str;
- WBUFB(buf,5)=pc_need_status_point(sd,SP_STR);
- WBUFB(buf,6)=(sd->status.agi > UCHAR_MAX)? UCHAR_MAX:sd->status.agi;
- WBUFB(buf,7)=pc_need_status_point(sd,SP_AGI);
- WBUFB(buf,8)=(sd->status.vit > UCHAR_MAX)? UCHAR_MAX:sd->status.vit;
- WBUFB(buf,9)=pc_need_status_point(sd,SP_VIT);
- WBUFB(buf,10)=(sd->status.int_ > UCHAR_MAX)? UCHAR_MAX:sd->status.int_;
- WBUFB(buf,11)=pc_need_status_point(sd,SP_INT);
- WBUFB(buf,12)=(sd->status.dex > UCHAR_MAX)? UCHAR_MAX:sd->status.dex;
- WBUFB(buf,13)=pc_need_status_point(sd,SP_DEX);
- WBUFB(buf,14)=(sd->status.luk > UCHAR_MAX)? UCHAR_MAX:sd->status.luk;
- WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK);
- WBUFW(buf,16) = sd->battle_status.batk + sd->battle_status.rhw.atk + sd->battle_status.lhw->atk;
- WBUFW(buf,18) = sd->battle_status.rhw.atk2 + sd->battle_status.lhw->atk2; //atk bonus
- WBUFW(buf,20) = sd->battle_status.matk_max;
- WBUFW(buf,22) = sd->battle_status.matk_min;
- WBUFW(buf,24) = sd->battle_status.def; // def
- WBUFW(buf,26) = sd->battle_status.def2;
- WBUFW(buf,28) = sd->battle_status.mdef; // mdef
- fd = sd->battle_status.mdef2 - (sd->battle_status.vit>>1);
- if (fd < 0) fd = 0; //Negative check for Frenzy'ed characters.
- WBUFW(buf,30) = fd;
- fd = sd->fd;
- WBUFW(buf,32) = sd->battle_status.hit;
- WBUFW(buf,34) = sd->battle_status.flee;
- WBUFW(buf,36) = sd->battle_status.flee2/10;
- WBUFW(buf,38) = sd->battle_status.cri/10;
- WBUFW(buf,40) = sd->status.karma;
- WBUFW(buf,42) = sd->status.manner;
- WFIFOSET(fd,packet_len_table[0xbd]);
- clif_updatestatus(sd,SP_STR);
- clif_updatestatus(sd,SP_AGI);
- clif_updatestatus(sd,SP_VIT);
- clif_updatestatus(sd,SP_INT);
- clif_updatestatus(sd,SP_DEX);
- clif_updatestatus(sd,SP_LUK);
- clif_updatestatus(sd,SP_ATTACKRANGE);
- clif_updatestatus(sd,SP_ASPD);
- return 0;
- }
- /*==========================================
- *矢装備
- *------------------------------------------
- */
- int clif_arrowequip(struct map_session_data *sd,int val)
- {
- int fd;
- nullpo_retr(0, sd);
- pc_stop_attack(sd); // [Valaris]
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x013c]);
- WFIFOW(fd,0)=0x013c;
- WFIFOW(fd,2)=val+2;//矢のアイテムID
- WFIFOSET(fd,packet_len_table[0x013c]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_arrow_fail(struct map_session_data *sd,int type)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x013b]);
- WFIFOW(fd,0)=0x013b;
- WFIFOW(fd,2)=type;
- WFIFOSET(fd,packet_len_table[0x013b]);
- return 0;
- }
- /*==========================================
- * 作成可能 矢リスト送信
- *------------------------------------------
- */
- int clif_arrow_create_list(struct map_session_data *sd)
- {
- int i, c, j;
- int fd;
- nullpo_retr(0, sd);
- fd = sd->fd;
- WFIFOHEAD(fd, MAX_SKILL_ARROW_DB*2+4);
- WFIFOW(fd,0) = 0x1ad;
- for (i = 0, c = 0; i < MAX_SKILL_ARROW_DB; i++) {
- if (skill_arrow_db[i].nameid > 0 &&
- (j = pc_search_inventory(sd, skill_arrow_db[i].nameid)) >= 0 &&
- !sd->status.inventory[j].equip && sd->status.inventory[j].identify)
- {
- if ((j = itemdb_viewid(skill_arrow_db[i].nameid)) > 0)
- WFIFOW(fd,c*2+4) = j;
- else
- WFIFOW(fd,c*2+4) = skill_arrow_db[i].nameid;
- c++;
- }
- }
- WFIFOW(fd,2) = c*2+4;
- WFIFOSET(fd, WFIFOW(fd,2));
- if (c > 0) {
- sd->menuskill_id = AC_MAKINGARROW;
- sd->menuskill_lv = c;
- }
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_statusupack(struct map_session_data *sd,int type,int ok,int val)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xbc]);
- WFIFOW(fd,0)=0xbc;
- WFIFOW(fd,2)=type;
- WFIFOB(fd,4)=ok;
- WFIFOB(fd,5)=val;
- WFIFOSET(fd,packet_len_table[0xbc]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_equipitemack(struct map_session_data *sd,int n,int pos,int ok)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xaa]);
- WFIFOW(fd,0)=0xaa;
- WFIFOW(fd,2)=n+2;
- WFIFOW(fd,4)=pos;
- WFIFOB(fd,6)=ok;
- WFIFOSET(fd,packet_len_table[0xaa]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_unequipitemack(struct map_session_data *sd,int n,int pos,int ok)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xac]);
- WFIFOW(fd,0)=0xac;
- WFIFOW(fd,2)=n+2;
- WFIFOW(fd,4)=pos;
- WFIFOB(fd,6)=ok;
- WFIFOSET(fd,packet_len_table[0xac]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_misceffect(struct block_list* bl,int type)
- {
- unsigned char buf[32];
- nullpo_retr(0, bl);
- WBUFW(buf,0) = 0x19b;
- WBUFL(buf,2) = bl->id;
- WBUFL(buf,6) = type;
- clif_send(buf,packet_len_table[0x19b],bl,AREA);
- return 0;
- }
- int clif_misceffect2(struct block_list *bl, int type) {
- unsigned char buf[24];
- nullpo_retr(0, bl);
- malloc_set(buf, 0, packet_len_table[0x1f3]);
- WBUFW(buf,0) = 0x1f3;
- WBUFL(buf,2) = bl->id;
- WBUFL(buf,6) = type;
- clif_send(buf, packet_len_table[0x1f3], bl, AREA);
- return 0;
- }
- /*==========================================
- * 表示オプション変更
- *------------------------------------------
- */
- int clif_changeoption(struct block_list* bl)
- {
- unsigned char buf[32];
- struct status_change *sc;
- nullpo_retr(0, bl);
- sc = status_get_sc(bl);
- if (!sc) return 0; //How can an option change if there's no sc?
-
- #if PACKETVER > 6
- WBUFW(buf,0) = 0x229;
- WBUFL(buf,2) = bl->id;
- WBUFW(buf,6) = sc->opt1;
- WBUFW(buf,8) = sc->opt2;
- WBUFL(buf,10) = sc->option;
- WBUFB(buf,14) = 0; // ??
- if(disguised(bl)) {
- clif_send(buf,packet_len_table[0x229],bl,AREA_WOS);
- WBUFL(buf,2) = -bl->id;
- clif_send(buf,packet_len_table[0x229],bl,SELF);
- WBUFL(buf,2) = bl->id;
- WBUFL(buf,10) = OPTION_INVISIBLE;
- clif_send(buf,packet_len_table[0x229],bl,SELF);
- } else
- clif_send(buf,packet_len_table[0x229],bl,AREA);
- #else
- WBUFW(buf,0) = 0x119;
- WBUFL(buf,2) = bl->id;
- WBUFW(buf,6) = sc->opt1;
- WBUFW(buf,8) = sc->opt2;
- WBUFW(buf,10) = sc->option;
- WBUFB(buf,12) = 0; // ??
- if(disguised(bl)) {
- clif_send(buf,packet_len_table[0x119],bl,AREA_WOS);
- WBUFL(buf,2) = -bl->id;
- clif_send(buf,packet_len_table[0x119],bl,SELF);
- WBUFL(buf,2) = bl->id;
- WBUFW(buf,10) = OPTION_INVISIBLE;
- clif_send(buf,packet_len_table[0x119],bl,SELF);
- } else
- clif_send(buf,packet_len_table[0x119],bl,AREA);
- #endif
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_useitemack(struct map_session_data *sd,int index,int amount,int ok)
- {
- nullpo_retr(0, sd);
- if(!ok) {
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xa8]);
- WFIFOW(fd,0)=0xa8;
- WFIFOW(fd,2)=index+2;
- WFIFOW(fd,4)=amount;
- WFIFOB(fd,6)=ok;
- WFIFOSET(fd,packet_len_table[0xa8]);
- }
- else {
- #if PACKETVER < 3
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xa8]);
- WFIFOW(fd,0)=0xa8;
- WFIFOW(fd,2)=index+2;
- WFIFOW(fd,4)=amount;
- WFIFOB(fd,6)=ok;
- WFIFOSET(fd,packet_len_table[0xa8]);
- #else
- unsigned char buf[32];
- WBUFW(buf,0)=0x1c8;
- WBUFW(buf,2)=index+2;
- if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0)
- WBUFW(buf,4)=sd->inventory_data[index]->view_id;
- else
- WBUFW(buf,4)=sd->status.inventory[index].nameid;
- WBUFL(buf,6)=sd->bl.id;
- WBUFW(buf,10)=amount;
- WBUFB(buf,12)=ok;
- clif_send(buf,packet_len_table[0x1c8],&sd->bl,AREA);
- #endif
- }
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_createchat(struct map_session_data *sd,int fail)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xd6]);
- WFIFOW(fd,0)=0xd6;
- WFIFOB(fd,2)=fail;
- WFIFOSET(fd,packet_len_table[0xd6]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_dispchat(struct chat_data *cd,int fd)
- {
- unsigned char buf[128]; // 最大title(60バイト)+17
- if(cd==NULL || *cd->owner==NULL)
- return 1;
- WBUFW(buf,0)=0xd7;
- WBUFW(buf,2)=strlen((const char*)cd->title)+17;
- WBUFL(buf,4)=(*cd->owner)->id;
- WBUFL(buf,8)=cd->bl.id;
- WBUFW(buf,12)=cd->limit;
- WBUFW(buf,14)=cd->users;
- WBUFB(buf,16)=cd->pub;
- strcpy((char*)WBUFP(buf,17),(const char*)cd->title);
- if(fd){
- WFIFOHEAD(fd, WBUFW(buf,2));
- memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2));
- WFIFOSET(fd,WBUFW(buf,2));
- } else {
- clif_send(buf,WBUFW(buf,2),*cd->owner,AREA_WOSC);
- }
- return 0;
- }
- /*==========================================
- * chatの状態変更成功
- * 外部の人用と命令コード(d7->df)が違うだけ
- *------------------------------------------
- */
- int clif_changechatstatus(struct chat_data *cd)
- {
- unsigned char buf[128]; // 最大title(60バイト)+17
- if(cd==NULL || cd->usersd[0]==NULL)
- return 1;
- WBUFW(buf,0)=0xdf;
- WBUFW(buf,2)=strlen((char*)cd->title)+17;
- WBUFL(buf,4)=cd->usersd[0]->bl.id;
- WBUFL(buf,8)=cd->bl.id;
- WBUFW(buf,12)=cd->limit;
- WBUFW(buf,14)=cd->users;
- WBUFB(buf,16)=cd->pub;
- strcpy((char*)WBUFP(buf,17),(const char*)cd->title);
- clif_send(buf,WBUFW(buf,2),&cd->usersd[0]->bl,CHAT);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_clearchat(struct chat_data *cd,int fd)
- {
- unsigned char buf[32];
- nullpo_retr(0, cd);
- WBUFW(buf,0)=0xd8;
- WBUFL(buf,2)=cd->bl.id;
- if(fd){
- WFIFOHEAD(fd,packet_len_table[0xd8]);
- memcpy(WFIFOP(fd,0),buf,packet_len_table[0xd8]);
- WFIFOSET(fd,packet_len_table[0xd8]);
- } else {
- clif_send(buf,packet_len_table[0xd8],*cd->owner,AREA_WOSC);
- }
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_joinchatfail(struct map_session_data *sd,int fail)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xda]);
- WFIFOW(fd,0)=0xda;
- WFIFOB(fd,2)=fail;
- WFIFOSET(fd,packet_len_table[0xda]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_joinchatok(struct map_session_data *sd,struct chat_data* cd)
- {
- int fd;
- int i;
- nullpo_retr(0, sd);
- nullpo_retr(0, cd);
- fd = sd->fd;
- if (!session_isActive(fd))
- return 0;
- WFIFOHEAD(fd, 8 + (28*cd->users));
- WFIFOW(fd, 0) = 0xdb;
- WFIFOW(fd, 2) = 8 + (28*cd->users);
- WFIFOL(fd, 4) = cd->bl.id;
- for (i = 0; i < cd->users; i++) {
- WFIFOL(fd, 8+i*28) = (i!=0) || ((*cd->owner)->type == BL_NPC);
- memcpy(WFIFOP(fd, 8+i*28+4), cd->usersd[i]->status.name, NAME_LENGTH);
- }
- WFIFOSET(fd, WFIFOW(fd, 2));
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_addchat(struct chat_data* cd,struct map_session_data *sd)
- {
- unsigned char buf[32];
- nullpo_retr(0, sd);
- nullpo_retr(0, cd);
- WBUFW(buf, 0) = 0x0dc;
- WBUFW(buf, 2) = cd->users;
- memcpy(WBUFP(buf, 4),sd->status.name,NAME_LENGTH);
- clif_send(buf,packet_len_table[0xdc],&sd->bl,CHAT_WOS);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_changechatowner(struct chat_data* cd,struct map_session_data *sd)
- {
- unsigned char buf[64];
- nullpo_retr(0, sd);
- nullpo_retr(0, cd);
- WBUFW(buf, 0) = 0xe1;
- WBUFL(buf, 2) = 1;
- memcpy(WBUFP(buf,6),cd->usersd[0]->status.name,NAME_LENGTH);
- WBUFW(buf,30) = 0xe1;
- WBUFL(buf,32) = 0;
- memcpy(WBUFP(buf,36),sd->status.name,NAME_LENGTH);
- clif_send(buf,packet_len_table[0xe1]*2,&sd->bl,CHAT);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_leavechat(struct chat_data* cd,struct map_session_data *sd)
- {
- unsigned char buf[32];
- nullpo_retr(0, sd);
- nullpo_retr(0, cd);
- WBUFW(buf, 0) = 0xdd;
- WBUFW(buf, 2) = cd->users-1;
- memcpy(WBUFP(buf,4),sd->status.name,NAME_LENGTH);
- WBUFB(buf,28) = 0;
- clif_send(buf,packet_len_table[0xdd],&sd->bl,CHAT);
- return 0;
- }
- /*==========================================
- * 取り引き要請受け
- *------------------------------------------
- */
- int clif_traderequest(struct map_session_data *sd,char *name)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xe5]);
- WFIFOW(fd,0)=0xe5;
- strcpy((char*)WFIFOP(fd,2),name);
-
- WFIFOSET(fd,packet_len_table[0xe5]);
- return 0;
- }
- /*==========================================
- * 取り引き要求応答
- *------------------------------------------
- */
- int clif_tradestart(struct map_session_data *sd,int type)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xe7]);
- WFIFOW(fd,0)=0xe7;
- WFIFOB(fd,2)=type;
- WFIFOSET(fd,packet_len_table[0xe7]);
- return 0;
- }
- /*==========================================
- * 相手方からのアイテム追加
- *------------------------------------------
- */
- int clif_tradeadditem(struct map_session_data *sd,struct map_session_data *tsd,int index,int amount)
- {
- int fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, tsd);
- fd=tsd->fd;
- WFIFOHEAD(fd,packet_len_table[0xe9]);
- WFIFOW(fd,0)=0xe9;
- WFIFOL(fd,2)=amount;
- if(index==0){
- WFIFOW(fd,6) = 0; // type id
- WFIFOB(fd,8) = 0; //identify flag
- WFIFOB(fd,9) = 0; // attribute
- WFIFOB(fd,10)= 0; //refine
- WFIFOW(fd,11)= 0; //card (4w)
- WFIFOW(fd,13)= 0; //card (4w)
- WFIFOW(fd,15)= 0; //card (4w)
- WFIFOW(fd,17)= 0; //card (4w)
- }
- else{
- index-=2; //index fix
- if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0)
- WFIFOW(fd,6) = sd->inventory_data[index]->view_id;
- else
- WFIFOW(fd,6) = sd->status.inventory[index].nameid; // type id
- WFIFOB(fd,8) = sd->status.inventory[index].identify; //identify flag
- WFIFOB(fd,9) = sd->status.inventory[index].attribute; // attribute
- WFIFOB(fd,10)= sd->status.inventory[index].refine; //refine
- clif_addcards(WFIFOP(fd, 11), &sd->status.inventory[index]);
- }
- WFIFOSET(fd,packet_len_table[0xe9]);
- return 0;
- }
- /*==========================================
- * アイテム追加成功/失敗
- *------------------------------------------
- */
- int clif_tradeitemok(struct map_session_data *sd,int index,int fail)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xea]);
- WFIFOW(fd,0)=0xea;
- WFIFOW(fd,2)=index;
- WFIFOB(fd,4)=fail;
- WFIFOSET(fd,packet_len_table[0xea]);
- return 0;
- }
- /*==========================================
- * 取り引きok押し
- *------------------------------------------
- */
- int clif_tradedeal_lock(struct map_session_data *sd,int fail)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xec]);
- WFIFOW(fd,0)=0xec;
- WFIFOB(fd,2)=fail; // 0=you 1=the other person
- WFIFOSET(fd,packet_len_table[0xec]);
- return 0;
- }
- /*==========================================
- * 取り引きがキャンセルされました
- *------------------------------------------
- */
- int clif_tradecancelled(struct map_session_data *sd)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xee]);
- WFIFOW(fd,0)=0xee;
- WFIFOSET(fd,packet_len_table[0xee]);
- return 0;
- }
- /*==========================================
- * 取り引き完了
- *------------------------------------------
- */
- int clif_tradecompleted(struct map_session_data *sd,int fail)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf0]);
- WFIFOW(fd,0)=0xf0;
- WFIFOB(fd,2)=fail;
- WFIFOSET(fd,packet_len_table[0xf0]);
- return 0;
- }
- /*==========================================
- * カプラ倉庫のアイテム数を更新
- *------------------------------------------
- */
- int clif_updatestorageamount(struct map_session_data *sd,struct storage *stor)
- {
- int fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, stor);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf2]);
- WFIFOW(fd,0) = 0xf2; // update storage amount
- WFIFOW(fd,2) = stor->storage_amount; //items
- WFIFOW(fd,4) = MAX_STORAGE; //items max
- WFIFOSET(fd,packet_len_table[0xf2]);
- return 0;
- }
- /*==========================================
- * カプラ倉庫にアイテムを追加する
- *------------------------------------------
- */
- int clif_storageitemadded(struct map_session_data *sd,struct storage *stor,int index,int amount)
- {
- int view,fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, stor);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf4]);
- WFIFOW(fd,0) =0xf4; // Storage item added
- WFIFOW(fd,2) =index+1; // index
- WFIFOL(fd,4) =amount; // amount
- if((view = itemdb_viewid(stor->storage_[index].nameid)) > 0)
- WFIFOW(fd,8) =view;
- else
- WFIFOW(fd,8) =stor->storage_[index].nameid; // id
- WFIFOB(fd,10)=stor->storage_[index].identify; //identify flag
- WFIFOB(fd,11)=stor->storage_[index].attribute; // attribute
- WFIFOB(fd,12)=stor->storage_[index].refine; //refine
- clif_addcards(WFIFOP(fd,13), &stor->storage_[index]);
- WFIFOSET(fd,packet_len_table[0xf4]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_updateguildstorageamount(struct map_session_data *sd,struct guild_storage *stor)
- {
- int fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, stor);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf2]);
- WFIFOW(fd,0) = 0xf2; // update storage amount
- WFIFOW(fd,2) = stor->storage_amount; //items
- WFIFOW(fd,4) = MAX_GUILD_STORAGE; //items max
- WFIFOSET(fd,packet_len_table[0xf2]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_guildstorageitemadded(struct map_session_data *sd,struct guild_storage *stor,int index,int amount)
- {
- int view,fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, stor);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf4]);
- WFIFOW(fd,0) =0xf4; // Storage item added
- WFIFOW(fd,2) =index+1; // index
- WFIFOL(fd,4) =amount; // amount
- if((view = itemdb_viewid(stor->storage_[index].nameid)) > 0)
- WFIFOW(fd,8) =view;
- else
- WFIFOW(fd,8) =stor->storage_[index].nameid; // id
- WFIFOB(fd,10)=stor->storage_[index].identify; //identify flag
- WFIFOB(fd,11)=stor->storage_[index].attribute; // attribute
- WFIFOB(fd,12)=stor->storage_[index].refine; //refine
- clif_addcards(WFIFOP(fd,13), &stor->storage_[index]);
- WFIFOSET(fd,packet_len_table[0xf4]);
- return 0;
- }
- /*==========================================
- * カプラ倉庫からアイテムを取り去る
- *------------------------------------------
- */
- int clif_storageitemremoved(struct map_session_data *sd,int index,int amount)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf6]);
- WFIFOW(fd,0)=0xf6; // Storage item removed
- WFIFOW(fd,2)=index+1;
- WFIFOL(fd,4)=amount;
- WFIFOSET(fd,packet_len_table[0xf6]);
- return 0;
- }
- /*==========================================
- * カプラ倉庫を閉じる
- *------------------------------------------
- */
- int clif_storageclose(struct map_session_data *sd)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf8]);
- WFIFOW(fd,0)=0xf8; // Storage Closed
- WFIFOSET(fd,packet_len_table[0xf8]);
- return 0;
- }
- //
- // callback系 ?
- //
- /*==========================================
- * PC表示
- *------------------------------------------
- */
- void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* dstsd)
- {
- int len;
- if(dstsd->chatID){
- struct chat_data *cd;
- cd=(struct chat_data*)map_id2bl(dstsd->chatID);
- if(cd && cd->usersd[0]==dstsd)
- clif_dispchat(cd,sd->fd);
- }
- if(dstsd->vender_id)
- clif_showvendingboard(&dstsd->bl,dstsd->message,sd->fd);
- if(dstsd->spiritball > 0)
- clif_spiritball_single(sd->fd, dstsd);
- if((sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting.
- (battle_config.disp_hpmeter && (len = pc_isGM(sd)) >= battle_config.disp_hpmeter && len >= pc_isGM(dstsd))
- )
- clif_hpmeter_single(sd->fd, dstsd);
- if(dstsd->status.manner < 0)
- clif_changestatus(&dstsd->bl,SP_MANNER,dstsd->status.manner);
-
- // pvp circle for duel [LuzZza]
- /*
- if(dstsd->duel_group)
- clif_specialeffect(&dstsd->bl, 159, 4);
- */
- }
- void clif_getareachar_char(struct map_session_data* sd,struct block_list *bl)
- {
- struct unit_data *ud;
- struct view_data *vd;
- int len;
-
- vd = status_get_viewdata(bl);
- if (!vd || vd->class_ == INVISIBLE_CLASS)
- return;
- ud = unit_bl2ud(bl);
- if (ud && ud->walktimer != -1)
- {
- #if PACKETVER > 6
- WFIFOHEAD(sd->fd, packet_len_table[0x22c]);
- #elif PACKETVER > 3
- WFIFOHEAD(sd->fd, packet_len_table[0x1da]);
- #else
- WFIFOHEAD(sd->fd, packet_len_table[0x7b]);
- #endif
- len = clif_set007b(bl,vd,ud,WFIFOP(sd->fd,0));
- WFIFOSET(sd->fd,len);
- } else {
- #if PACKETVER > 6
- WFIFOHEAD(sd->fd,packet_len_table[0x22a]);
- #elif PACKETVER > 3
- WFIFOHEAD(sd->fd,packet_len_table[0x1d8]);
- #else
- WFIFOHEAD(sd->fd,packet_len_table[0x78]);
- #endif
- len = clif_set0078(bl,vd,WFIFOP(sd->fd,0));
- WFIFOSET(sd->fd,len);
- }
- if (vd->cloth_color)
- clif_refreshlook(&sd->bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,SELF);
- switch (bl->type)
- {
- case BL_PC:
- {
- TBL_PC* tsd = (TBL_PC*)bl;
- clif_getareachar_pc(sd, tsd);
- if(tsd->state.size==2) // tiny/big players [Valaris]
- clif_specialeffect(bl,423,AREA);
- else if(tsd->state.size==1)
- clif_specialeffect(bl,421,AREA);
- }
- break;
- case BL_NPC:
- {
- if(((TBL_NPC*)bl)->chat_id)
- clif_dispchat((struct chat_data*)map_id2bl(((TBL_NPC*)bl)->chat_id),sd->fd);
- }
- break;
- case BL_MOB:
- {
- TBL_MOB* md = (TBL_MOB*)bl;
- if(md->special_state.size==2) // tiny/big mobs [Valaris]
- clif_specialeffect(bl,423,AREA);
- else if(md->special_state.size==1)
- clif_specialeffect(bl,421,AREA);
- }
- break;
- }
- }
- /*==========================================
- * Older fix pos packet.
- *------------------------------------------
- */
- int clif_fixpos2(struct block_list* bl)
- {
- struct unit_data *ud;
- struct view_data *vd;
- unsigned char buf[256];
- int len;
- nullpo_retr(0, bl);
- ud = unit_bl2ud(bl);
- vd = status_get_viewdata(bl);
- if (!vd || vd->class_ == INVISIBLE_CLASS)
- return 0;
-
- if(ud && ud->walktimer != -1)
- len = clif_set007b(bl,vd,ud,buf);
- else
- len = clif_set0078(bl,vd,buf);
- if (disguised(bl)) {
- clif_send(buf,len,bl,AREA_WOS);
- clif_setdisguise((TBL_PC*)bl, buf, len, 0);
- clif_setdisguise((TBL_PC*)bl, buf, len, 1);
- } else
- clif_send(buf,len,bl,AREA);
- return 0;
- }
- //Modifies the type of damage according to status changes [Skotlex]
- #define clif_calc_delay(type,delay) (type==1||type==4||type==0x0a)?type:(delay==0?9:type)
- /*==========================================
- * Estimates walk delay based on the damage criteria. [Skotlex]
- *------------------------------------------
- */
- static int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int damage, int div_) {
- if (type == 4 || type == 9 || damage <=0)
- return 0;
-
- if (bl->type == BL_PC) {
- if (battle_config.pc_walk_delay_rate != 100)
- delay = delay*battle_config.pc_walk_delay_rate/100;
- } else
- if (battle_config.walk_delay_rate != 100)
- delay = delay*battle_config.walk_delay_rate/100;
-
- if (div_ > 1) //Multi-hit skills mean higher delays.
- delay += battle_config.multihit_delay*(div_-1);
- return delay>0?delay:1; //Return 1 to specify there should be no noticeable delay, but you should stop walking.
- }
- /*==========================================
- * 通常攻撃エフェクト&ダメージ
- *------------------------------------------
- */
- int clif_damage(struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int damage,int div,int type,int damage2)
- {
- unsigned char buf[256];
- struct status_change *sc;
- nullpo_retr(0, src);
- nullpo_retr(0, dst);
- type = clif_calc_delay(type, ddelay); //Type defaults to 0 for normal attacks.
- sc = status_get_sc(dst);
- if(sc && sc->count) {
- if(sc->data[SC_HALLUCINATION].timer != -1) {
- if(damage > 0)
- damage = damage*(5+sc->data[SC_HALLUCINATION].val1) + rand()%100;
- if(damage2 > 0)
- damage2 = damage2*(5+sc->data[SC_HALLUCINATION].val1) + rand()%100;
- }
- }
- WBUFW(buf,0)=0x8a;
- WBUFL(buf,2)=src->id;
- WBUFL(buf,6)=dst->id;
- WBUFL(buf,10)=tick;
- WBUFL(buf,14)=sdelay;
- WBUFL(buf,18)=ddelay;
- if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
- WBUFW(buf,22)=damage?div:0;
- WBUFW(buf,27)=damage2?div:0;
- } else {
- WBUFW(buf,22)=(damage > SHRT_MAX)?SHRT_MAX:damage;
- WBUFW(buf,27)=damage2;
- }
- WBUFW(buf,24)=div;
- WBUFB(buf,26)=type;
- clif_send(buf,packet_len_table[0x8a],src,AREA);
- if(disguised(src)) {
- WBUFL(buf,2)=-src->id;
- if(damage > 0)
- WBUFW(buf,22)=-1;
- if(damage2 > 0)
- WBUFW(buf,27)=-1;
- clif_send(buf,packet_len_table[0x8a],src,SELF);
- }
- if (disguised(dst)) {
- WBUFL(buf,6)=-dst->id;
- if (disguised(src))
- WBUFL(buf,2)=src->id;
- else {
- if(damage > 0)
- WBUFW(buf,22)=-1;
- if(damage2 > 0)
- WBUFW(buf,27)=-1;
- }
- clif_send(buf,packet_len_table[0x8a],dst,SELF);
- }
- //Return adjusted can't walk delay for further processing.
- return clif_calc_walkdelay(dst,ddelay,type,damage+damage2,div);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fitem)
- {
- int view,fd;
- fd=sd->fd;
- //009d <ID>.l <item ID>.w <identify flag>.B <X>.w <Y>.w <amount>.w <subX>.B <subY>.B
- WFIFOHEAD(fd,packet_len_table[0x9d]);
- WFIFOW(fd,0)=0x9d;
- WFIFOL(fd,2)=fitem->bl.id;
- if((view = itemdb_viewid(fitem->item_data.nameid)) > 0)
- WFIFOW(fd,6)=view;
- else
- WFIFOW(fd,6)=fitem->item_data.nameid;
- WFIFOB(fd,8)=fitem->item_data.identify;
- WFIFOW(fd,9)=fitem->bl.x;
- WFIFOW(fd,11)=fitem->bl.y;
- WFIFOW(fd,13)=fitem->item_data.amount;
- WFIFOB(fd,15)=fitem->subx;
- WFIFOB(fd,16)=fitem->suby;
- WFIFOSET(fd,packet_len_table[0x9d]);
- }
- /*==========================================
- * 場所スキルエフェクトが視界に入る
- *------------------------------------------
- */
- int clif_getareachar_skillunit(struct map_session_data *sd,struct skill_unit *unit)
- {
- int fd;
- struct block_list *bl;
- fd=sd->fd;
- bl=map_id2bl(unit->group->src_id);
- #if PACKETVER >= 3
- if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
- WFIFOHEAD(fd,packet_len_table[0x1c9]);
- malloc_set(WFIFOP(fd,0),0,packet_len_table[0x1c9]);
- WFIFOW(fd, 0)=0x1c9;
- WFIFOL(fd, 2)=unit->bl.id;
- WFIFOL(fd, 6)=unit->group->src_id;
- WFIFOW(fd,10)=unit->bl.x;
- WFIFOW(fd,12)=unit->bl.y; // might be typo? [Lance]
- WFIFOB(fd,14)=unit->group->unit_id;
- WFIFOB(fd,15)=1;
- WFIFOB(fd,16)=1;
- memcpy(WFIFOP(fd,17),unit->group->valstr,MESSAGE_SIZE);
- WFIFOSET(fd,packet_len_table[0x1c9]);
- return 0;
- }
- #endif
- WFIFOHEAD(fd,packet_len_table[0x11f]);
- malloc_set(WFIFOP(fd,0),0,packet_len_table[0x11f]);
- WFIFOW(fd, 0)=0x11f;
- WFIFOL(fd, 2)=unit->bl.id;
- WFIFOL(fd, 6)=unit->group->src_id;
- WFIFOW(fd,10)=unit->bl.x;
- WFIFOW(fd,12)=unit->bl.y;
- //Use invisible unit id for traps.
- if (battle_config.traps_setting&1 && skill_get_inf2(unit->group->skill_id)&INF2_TRAP)
- WFIFOB(fd,14)=UNT_ATTACK_SKILLS;
- else
- WFIFOB(fd,14)=unit->group->unit_id;
- WFIFOB(fd,15)=0;
- WFIFOSET(fd,packet_len_table[0x11f]);
- if(unit->group->skill_id == WZ_ICEWALL)
- clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,5);
- return 0;
- /* Previous implementation guess of packet 0x1c9, who can understand what all those fields are for? [Skotlex]
- WFIFOHEAD(fd,packet_len_table[0x1c9]);
- malloc_set(WFIFOP(fd,0),0,packet_len_table[0x1c9]);
- WFIFOW(fd, 0)=0x1c9;
- WFIFOL(fd, 2)=unit->bl.id;
- WFIFOL(fd, 6)=unit->group->src_id;
- WFIFOW(fd,10)=unit->bl.x;
- WFIFOW(fd,12)=unit->bl.y;
- WFIFOB(fd,14)=unit->group->unit_id;
- WFIFOB(fd,15)=1;
- if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
- WFIFOB(fd,16)=1;
- memcpy(WFIFOP(fd,17),unit->group->valstr,MESSAGE_SIZE);
- } else {
- WFIFOL(fd,15+1)=0; //1-4調べた限り固定
- WFIFOL(fd,15+5)=0; //5-8調べた限り固定
- //9-12マップごとで一定の77-80とはまた違う4バイトのかなり大きな数字
- WFIFOL(fd,15+13)=unit->bl.y - 0x12; //13-16ユニットのY座標-18っぽい(Y:17でFF FF FF FF)
- WFIFOL(fd,15+17)=0x004f37dd; //17-20調べた限り固定
- WFIFOL(fd,15+21)=0x0012f674; //21-24調べた限り固定
- WFIFOL(fd,15+25)=0x0012f664; //25-28調べた限り固定
- WFIFOL(fd,15+29)=0x0012f654; //29-32調べた限り固定
- WFIFOL(fd,15+33)=0x77527bbc; //33-36調べた限り固定
- //37-39
- WFIFOB(fd,15+40)=0x2d; //40調べた限り固定
- WFIFOL(fd,15+41)=0; //41-44調べた限り0固定
- WFIFOL(fd,15+45)=0; //45-48調べた限り0固定
- WFIFOL(fd,15+49)=0; //49-52調べた限り0固定
- WFIFOL(fd,15+53)=0x0048d919; //53-56調べた限り固定
- WFIFOL(fd,15+57)=0x0000003e; //57-60調べた限り固定
- WFIFOL(fd,15+61)=0x0012f66c; //61-64調べた限り固定
- //65-68
- //69-72
- if(bl) WFIFOL(fd,15+73)=bl->y; //73-76術者のY座標
- WFIFOL(fd,15+77)=unit->bl.m; //77-80マップIDかなぁ?かなり2バイトで足りそうな数字
- WFIFOB(fd,15+81)=0xaa; //81終端文字0xaa
- }
- WFIFOSET(fd,packet_len_table[0x1c9]);
- #endif
- if(unit->group->skill_id == WZ_ICEWALL)
- clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,5);
- return 0;
- */
- }
- /*==========================================
- * 場所スキルエフェクトが視界から消える
- *------------------------------------------
- */
- int clif_clearchar_skillunit(struct skill_unit *unit,int fd)
- {
- nullpo_retr(0, unit);
- WFIFOHEAD(fd,packet_len_table[0x120]);
- WFIFOW(fd, 0)=0x120;
- WFIFOL(fd, 2)=unit->bl.id;
- WFIFOSET(fd,packet_len_table[0x120]);
- if(unit->group && unit->group->skill_id == WZ_ICEWALL)
- clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_01ac(struct block_list *bl)
- {
- unsigned char buf[32];
- nullpo_retr(0, bl);
- WBUFW(buf, 0) = 0x1ac;
- WBUFL(buf, 2) = bl->id;
- clif_send(buf,packet_len_table[0x1ac],bl,AREA);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_getareachar(struct block_list* bl,va_list ap)
- {
- struct map_session_data *sd;
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
- sd=va_arg(ap,struct map_session_data*);
- if (sd == NULL || session[sd->fd] == NULL)
- return 0;
- switch(bl->type){
- case BL_ITEM:
- clif_getareachar_item(sd,(struct flooritem_data*) bl);
- break;
- case BL_SKILL:
- clif_getareachar_skillunit(sd,(TBL_SKILL*)bl);
- break;
- default:
- if(&sd->bl == bl)
- break;
- clif_getareachar_char(sd,bl);
- break;
- }
- return 0;
- }
- /*==========================================
- * tbl has gone out of view-size of bl
- *------------------------------------------
- */
- int clif_outsight(struct block_list *bl,va_list ap)
- {
- struct block_list *tbl;
- struct view_data *vd;
- TBL_PC *sd, *tsd;
- tbl=va_arg(ap,struct block_list*);
- if(bl == tbl) return 0;
- BL_CAST(BL_PC, bl, sd);
- BL_CAST(BL_PC, tbl, tsd);
- if (tsd && tsd->fd)
- { //tsd has lost sight of the bl object.
- switch(bl->type){
- case BL_PC:
- if (((TBL_PC*)bl)->vd.class_ != INVISIBLE_CLASS)
- clif_clearchar_id(bl->id,0,tsd->fd);
- if(sd->chatID){
- struct chat_data *cd;
- cd=(struct chat_data*)map_id2bl(sd->chatID);
- if(cd->usersd[0]==sd)
- clif_dispchat(cd,tsd->fd);
- }
- if(sd->vender_id)
- clif_closevendingboard(bl,tsd->fd);
- break;
- case BL_ITEM:
- clif_clearflooritem((struct flooritem_data*)bl,tsd->fd);
- break;
- case BL_SKILL:
- clif_clearchar_skillunit((struct skill_unit *)bl,tsd->fd);
- break;
- default:
- if ((vd=status_get_viewdata(bl)) && vd->class_ != INVISIBLE_CLASS)
- clif_clearchar_id(bl->id,0,tsd->fd);
- break;
- }
- }
- if (sd && sd->fd)
- { //sd is watching tbl go out of view.
- if ((vd=status_get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS)
- clif_clearchar_id(tbl->id,0,sd->fd);
- }
- return 0;
- }
- /*==========================================
- * tbl has come into view of bl
- *------------------------------------------
- */
- int clif_insight(struct block_list *bl,va_list ap)
- {
- struct block_list *tbl;
- TBL_PC *sd, *tsd;
- tbl=va_arg(ap,struct block_list*);
- if (bl == tbl) return 0;
-
- BL_CAST(BL_PC, bl, sd);
- BL_CAST(BL_PC, tbl, tsd);
- if (tsd && tsd->fd)
- { //Tell tsd that bl entered into his view
- switch(bl->type){
- case BL_ITEM:
- clif_getareachar_item(tsd,(struct flooritem_data*)bl);
- break;
- case BL_SKILL:
- clif_getareachar_skillunit(tsd,(TBL_SKILL*)bl);
- break;
- default:
- clif_getareachar_char(tsd,bl);
- break;
- }
- }
- if (sd && sd->fd)
- { //Tell sd that tbl walked into his view
- clif_getareachar_char(sd,tbl);
- }
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range)
- {
- int fd,id, inf2;
- nullpo_retr(0, sd);
- fd=sd->fd;
- if( (id=sd->status.skill[skillid].id) <= 0 )
- return 0;
- WFIFOHEAD(fd,packet_len_table[0x147]);
- WFIFOW(fd,0)=0x147;
- WFIFOW(fd,2) = id;
- if(type < 0)
- WFIFOW(fd,4) = skill_get_inf(id);
- else
- WFIFOW(fd,4) = type;
- WFIFOW(fd,6) = 0;
- WFIFOW(fd,8) = sd->status.skill[skillid].lv;
- WFIFOW(fd,10) = skill_get_sp(id,sd->status.skill[skillid].lv);
- if(range < 0)
- range = skill_get_range2(&sd->bl, id,sd->status.skill[skillid].lv);
- WFIFOW(fd,12)= range;
- strncpy(WFIFOP(fd,14), skill_get_name(id), NAME_LENGTH);
- inf2 = skill_get_inf2(id);
- if(((!(inf2&INF2_QUEST_SKILL) || battle_config.quest_skill_learn) &&
- !(inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL))) ||
- (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill))
- //WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_get_max(id) && sd->status.skill[skillid].flag ==0 )? 1:0;
- WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_tree_get_max(id, sd->status.class_) && sd->status.skill[skillid].flag ==0 )? 1:0;
- else
- WFIFOB(fd,38) = 0;
- WFIFOSET(fd,packet_len_table[0x147]);
- return 0;
- }
- /*==========================================
- * スキルリストを送信する
- *------------------------------------------
- */
- int clif_skillinfoblock(struct map_session_data *sd)
- {
- int fd;
- int i,c,len=4,id, inf2;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd, MAX_SKILL * 37 + 4);
- WFIFOW(fd,0)=0x10f;
- for ( i = c = 0; i < MAX_SKILL; i++){
- if( (id=sd->status.skill[i].id)!=0 ){
- WFIFOW(fd,len ) = id;
- WFIFOW(fd,len+2) = skill_get_inf(id);
- WFIFOW(fd,len+4) = 0;
- WFIFOW(fd,len+6) = sd->status.skill[i].lv;
- WFIFOW(fd,len+8) = skill_get_sp(id,sd->status.skill[i].lv);
- WFIFOW(fd,len+10)= skill_get_range2(&sd->bl, id,sd->status.skill[i].lv);
- strncpy(WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH);
- inf2 = skill_get_inf2(id);
- if(((!(inf2&INF2_QUEST_SKILL) || battle_config.quest_skill_learn) &&
- !(inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL))) ||
- (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill) )
- WFIFOB(fd,len+36)= (sd->status.skill[i].lv < skill_tree_get_max(id, sd->status.class_) && sd->status.skill[i].flag ==0 )? 1:0;
- else
- WFIFOB(fd,len+36) = 0;
- len+=37;
- c++;
- }
- }
- WFIFOW(fd,2)=len;
- WFIFOSET(fd,len);
- return 0;
- }
- /*==========================================
- * スキル割り振り通知
- *------------------------------------------
- */
- int clif_skillup(struct map_session_data *sd,int skill_num)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x10e]);
- WFIFOW(fd,0) = 0x10e;
- WFIFOW(fd,2) = skill_num;
- WFIFOW(fd,4) = sd->status.skill[skill_num].lv;
- WFIFOW(fd,6) = skill_get_sp(skill_num,sd->status.skill[skill_num].lv);
- WFIFOW(fd,8) = skill_get_range2(&sd->bl,skill_num,sd->status.skill[skill_num].lv);
- //WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_get_max(sd->status.skill[skill_num].id)) ? 1 : 0;
- WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_tree_get_max(sd->status.skill[skill_num].id, sd->status.class_)) ? 1 : 0;
- WFIFOSET(fd,packet_len_table[0x10e]);
- return 0;
- }
- /*==========================================
- * スキル詠唱エフェクトを送信する
- *------------------------------------------
- */
- int clif_skillcasting(struct block_list* bl,
- int src_id,int dst_id,int dst_x,int dst_y,int skill_num,int casttime)
- {
- int pl = skill_get_pl(skill_num);
- unsigned char buf[32];
- WBUFW(buf,0) = 0x13e;
- WBUFL(buf,2) = src_id;
- WBUFL(buf,6) = dst_id;
- WBUFW(buf,10) = dst_x;
- WBUFW(buf,12) = dst_y;
- WBUFW(buf,14) = skill_num;
- WBUFL(buf,16) = pl<0?0:pl; //Avoid sending negatives as element [Skotlex]
- WBUFL(buf,20) = casttime;
- clif_send(buf,packet_len_table[0x13e], bl, AREA);
- if (disguised(bl)) {
- WBUFL(buf,2) = -src_id;
- WBUFL(buf,20) = 0;
- clif_send(buf,packet_len_table[0x13e], bl, SELF);
- }
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_skillcastcancel(struct block_list* bl)
- {
- unsigned char buf[16];
- nullpo_retr(0, bl);
- WBUFW(buf,0) = 0x1b9;
- WBUFL(buf,2) = bl->id;
- clif_send(buf,packet_len_table[0x1b9], bl, AREA);
- return 0;
- }
- /*==========================================
- * スキル詠唱失敗
- *------------------------------------------
- */
- int clif_skill_fail(struct map_session_data *sd,int skill_id,int type,int btype)
- {
- int fd;
- if (!sd) { //Since this is the most common nullpo....
- ShowDebug("clif_skill_fail: Error, received NULL sd for skill %d\n", skill_id);
- return 0;
- }
-
- fd=sd->fd;
- if(battle_config.display_skill_fail&1)
- return 0; //Disable all skill failed messages
- if(type==0x4 && !sd->state.showdelay)
- return 0; //Disable delay failed messages
-
- if(skill_id == RG_SNATCHER && battle_config.display_skill_fail&4)
- return 0;
- if(skill_id == TF_POISON && battle_config.display_skill_fail&8)
- return 0;
- WFIFOHEAD(fd,packet_len_table[0x110]);
- WFIFOW(fd,0) = 0x110;
- WFIFOW(fd,2) = skill_id;
- WFIFOW(fd,4) = btype;
- WFIFOW(fd,6) = 0;
- WFIFOB(fd,8) = 0;
- WFIFOB(fd,9) = type;
- WFIFOSET(fd,packet_len_table[0x110]);
- return 1;
- }
- /*==========================================
- * スキル攻撃エフェクト&ダメージ
- *------------------------------------------
- */
- int clif_skill_damage(struct block_list *src,struct block_list *dst,
- unsigned int tick,int sdelay,int ddelay,int damage,int div,int skill_id,int skill_lv,int type)
- {
- unsigned char buf[64];
- struct status_change *sc;
- nullpo_retr(0, src);
- nullpo_retr(0, dst);
- type = (type>0)?type:skill_get_hit(skill_id);
- type = clif_calc_delay(type, ddelay);
- sc = status_get_sc(dst);
- if(sc && sc->count) {
- if(sc->data[SC_HALLUCINATION].timer != -1 && damage > 0)
- damage = damage*(5+sc->data[SC_HALLUCINATION].val1) + rand()%100;
- }
- #if PACKETVER < 3
- WBUFW(buf,0)=0x114;
- WBUFW(buf,2)=skill_id;
- WBUFL(buf,4)=src->id;
- WBUFL(buf,8)=dst->id;
- WBUFL(buf,12)=tick;
- WBUFL(buf,16)=sdelay;
- WBUFL(buf,20)=ddelay;
- if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
- WBUFW(buf,24)=damage?div:0;
- } else {
- WBUFW(buf,24)=damage;
- }
- WBUFW(buf,26)=skill_lv;
- WBUFW(buf,28)=div;
- WBUFB(buf,30)=type;
- clif_send(buf,packet_len_table[0x114],src,AREA);
- if(disguised(src)) {
- WBUFL(buf,4)=-src->id;
- if(damage > 0)
- WBUFW(buf,24)=-1;
- clif_send(buf,packet_len_table[0x114],src,SELF);
- }
- if (disguised(dst)) {
- WBUFL(buf,8)=-dst->id;
- if (disguised(src))
- WBUFL(buf,4)=src->id;
- else if(damage > 0)
- WBUFW(buf,24)=-1;
- clif_send(buf,packet_len_table[0x114],dst,SELF);
- }
- #else
- WBUFW(buf,0)=0x1de;
- WBUFW(buf,2)=skill_id;
- WBUFL(buf,4)=src->id;
- WBUFL(buf,8)=dst->id;
- WBUFL(buf,12)=tick;
- WBUFL(buf,16)=sdelay;
- WBUFL(buf,20)=ddelay;
- if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
- WBUFL(buf,24)=damage?div:0;
- } else {
- WBUFL(buf,24)=damage;
- }
- WBUFW(buf,28)=skill_lv;
- WBUFW(buf,30)=div;
- WBUFB(buf,32)=type;
- clif_send(buf,packet_len_table[0x1de],src,AREA);
- if(disguised(src)) {
- WBUFL(buf,4)=-src->id;
- if(damage > 0)
- WBUFW(buf,24)=-1;
- clif_send(buf,packet_len_table[0x1de],src,SELF);
- }
- if (disguised(dst)) {
- WBUFL(buf,8)=-dst->id;
- if (disguised(src))
- WBUFL(buf,4)=src->id;
- else if(damage > 0)
- WBUFW(buf,24)=-1;
- clif_send(buf,packet_len_table[0x1de],dst,SELF);
- }
- #endif
- //Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex]
- return clif_calc_walkdelay(dst,ddelay,type,damage,div);
- }
- /*==========================================
- * 吹き飛ばしスキル攻撃エフェクト&ダメージ
- *------------------------------------------
- */
- int clif_skill_damage2(struct block_list *src,struct block_list *dst,
- unsigned int tick,int sdelay,int ddelay,int damage,int div,int skill_id,int skill_lv,int type)
- {
- unsigned char buf[64];
- struct status_change *sc;
- nullpo_retr(0, src);
- nullpo_retr(0, dst);
- type = (type>0)?type:skill_get_hit(skill_id);
- type = clif_calc_delay(type, ddelay);
- sc = status_get_sc(dst);
- if(sc && sc->count) {
- if(sc->data[SC_HALLUCINATION].timer != -1 && damage > 0)
- damage = damage*(5+sc->data[SC_HALLUCINATION].val1) + rand()%100;
- }
- WBUFW(buf,0)=0x115;
- WBUFW(buf,2)=skill_id;
- WBUFL(buf,4)=src->id;
- WBUFL(buf,8)=dst->id;
- WBUFL(buf,12)=tick;
- WBUFL(buf,16)=sdelay;
- WBUFL(buf,20)=ddelay;
- WBUFW(buf,24)=dst->x;
- WBUFW(buf,26)=dst->y;
- if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
- WBUFW(buf,28)=damage?div:0;
- } else {
- WBUFW(buf,28)=damage;
- }
- WBUFW(buf,30)=skill_lv;
- WBUFW(buf,32)=div;
- WBUFB(buf,34)=type;
- clif_send(buf,packet_len_table[0x115],src,AREA);
- if(disguised(src)) {
- WBUFL(buf,4)=-src->id;
- if(damage > 0)
- WBUFW(buf,28)=-1;
- clif_send(buf,packet_len_table[0x115],src,SELF);
- }
- if (disguised(dst)) {
- WBUFL(buf,8)=-dst->id;
- if (disguised(src))
- WBUFL(buf,4)=src->id;
- else if(damage > 0)
- WBUFW(buf,28)=-1;
- clif_send(buf,packet_len_table[0x115],dst,SELF);
- }
- //Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex]
- return clif_calc_walkdelay(dst,ddelay,type,damage,div);
- }
- /*==========================================
- * 支援/回復スキルエフェクト
- *------------------------------------------
- */
- int clif_skill_nodamage(struct block_list *src,struct block_list *dst,
- int skill_id,int heal,int fail)
- {
- unsigned char buf[32];
- nullpo_retr(0, dst);
- WBUFW(buf,0)=0x11a;
- WBUFW(buf,2)=skill_id;
- WBUFW(buf,4)=(heal > SHRT_MAX)? SHRT_MAX:heal;
- WBUFL(buf,6)=dst->id;
- WBUFL(buf,10)=src?src->id:0;
- WBUFB(buf,14)=fail;
- clif_send(buf,packet_len_table[0x11a],dst,AREA);
- if (disguised(dst)) {
- WBUFL(buf,6)=-dst->id;
- clif_send(buf,packet_len_table[0x115],dst,SELF);
- }
- if(src && disguised(src)) {
- WBUFL(buf,10)=-src->id;
- if (disguised(dst))
- WBUFL(buf,6)=dst->id;
- clif_send(buf,packet_len_table[0x115],src,SELF);
- }
- return fail;
- }
- /*==========================================
- * 場所スキルエフェクト
- *------------------------------------------
- */
- int clif_skill_poseffect(struct block_list *src,int skill_id,int val,int x,int y,int tick)
- {
- unsigned char buf[32];
- nullpo_retr(0, src);
- WBUFW(buf,0)=0x117;
- WBUFW(buf,2)=skill_id;
- WBUFL(buf,4)=src->id;
- WBUFW(buf,8)=val;
- WBUFW(buf,10)=x;
- WBUFW(buf,12)=y;
- WBUFL(buf,14)=tick;
- clif_send(buf,packet_len_table[0x117],src,AREA);
- if(disguised(src)) {
- WBUFL(buf,4)=-src->id;
- clif_send(buf,packet_len_table[0x117],src,SELF);
- }
- return 0;
- }
- /*==========================================
- * 場所スキルエフェクト表示
- *------------------------------------------
- */
- int clif_skill_setunit(struct skill_unit *unit)
- {
- unsigned char buf[128];
- struct block_list *bl;
- nullpo_retr(0, unit);
- bl=map_id2bl(unit->group->src_id);
- // These are invisible client-side, but are necessary because
- // otherwise the client will not know who caused the attack.
- // if (unit->group->unit_id == UNT_ATTACK_SKILLS)
- // return 0;
-
- #if PACKETVER >= 3
- if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
- malloc_set(WBUFP(buf, 0),0,packet_len_table[0x1c9]);
- WBUFW(buf, 0)=0x1c9;
- WBUFL(buf, 2)=unit->bl.id;
- WBUFL(buf, 6)=unit->group->src_id;
- WBUFW(buf,10)=unit->bl.x;
- WBUFW(buf,12)=unit->bl.y;
- if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) {
- WBUFB(buf,14)=unit->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE;
- } else {
- WBUFB(buf,14)=unit->group->unit_id;
- }
- WBUFB(buf,15)=1;
- WBUFB(buf,16)=1;
- memcpy(WBUFP(buf,17),unit->group->valstr,MESSAGE_SIZE);
- clif_send(buf,packet_len_table[0x1c9],&unit->bl,AREA);
- return 0;
- }
- #endif
- malloc_set(WBUFP(buf, 0),0,packet_len_table[0x11f]);
- WBUFW(buf, 0)=0x11f;
- WBUFL(buf, 2)=unit->bl.id;
- WBUFL(buf, 6)=unit->group->src_id;
- WBUFW(buf,10)=unit->bl.x;
- WBUFW(buf,12)=unit->bl.y;
- if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) {
- WBUFB(buf,14)=unit->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE;
- } else {
- WBUFB(buf,14)=unit->group->unit_id;
- }
- WBUFB(buf,15)=0;
- clif_send(buf,packet_len_table[0x11f],&unit->bl,AREA);
- return 0;
-
- /* Previous mysterious implementation noone really understands. [Skotlex]
- malloc_set(WBUFP(buf, 0),0,packet_len_table[0x1c9]);
- WBUFW(buf, 0)=0x1c9;
- WBUFL(buf, 2)=unit->bl.id;
- WBUFL(buf, 6)=unit->group->src_id;
- WBUFW(buf,10)=unit->bl.x;
- WBUFW(buf,12)=unit->bl.y;
- WBUFB(buf,14)=unit->group->unit_id;
- WBUFB(buf,15)=1;
- if(unit->group->unit_id==0xb0) { // Graffiti [Valaris]
- WBUFB(buf,16)=1;
- memcpy(WBUFP(buf,17),unit->group->valstr,MESSAGE_SIZE);
- } else {
- WBUFL(buf,15+1)=0; //1-4調べた限り固定
- WBUFL(buf,15+5)=0; //5-8調べた限り固定
- //9-12マップごとで一定の77-80とはまた違う4バイトのかなり大きな数字
- WBUFL(buf,15+13)=unit->bl.y - 0x12; //13-16ユニットのY座標-18っぽい(Y:17でFF FF FF FF)
- WBUFL(buf,15+17)=0x004f37dd; //17-20調べた限り固定(0x1b2で0x004fdbddだった)
- WBUFL(buf,15+21)=0x0012f674; //21-24調べた限り固定
- WBUFL(buf,15+25)=0x0012f664; //25-28調べた限り固定
- WBUFL(buf,15+29)=0x0012f654; //29-32調べた限り固定
- WBUFL(buf,15+33)=0x77527bbc; //33-36調べた限り固定
- //37-39
- WBUFB(buf,15+40)=0x2d; //40調べた限り固定
- WBUFL(buf,15+41)=0; //41-44調べた限り0固定
- WBUFL(buf,15+45)=0; //45-48調べた限り0固定
- WBUFL(buf,15+49)=0; //49-52調べた限り0固定
- WBUFL(buf,15+53)=0x0048d919; //53-56調べた限り固定(0x01b2で0x00495119だった)
- WBUFL(buf,15+57)=0x0000003e; //57-60調べた限り固定
- WBUFL(buf,15+61)=0x0012f66c; //61-64調べた限り固定
- //65-68
- //69-72
- if(bl) WBUFL(buf,15+73)=bl->y; //73-76術者のY座標
- WBUFL(buf,15+77)=unit->bl.m; //77-80マップIDかなぁ?かなり2バイトで足りそうな数字
- WBUFB(buf,15+81)=0xaa; //81終端文字0xaa
- }
- clif_send(buf,packet_len_table[0x1c9],&unit->bl,AREA);
- #endif
- return 0;
- */
- }
- /*==========================================
- * 場所スキルエフェクト削除
- *------------------------------------------
- */
- int clif_skill_delunit(struct skill_unit *unit)
- {
- unsigned char buf[16];
- nullpo_retr(0, unit);
- WBUFW(buf, 0)=0x120;
- WBUFL(buf, 2)=unit->bl.id;
- clif_send(buf,packet_len_table[0x120],&unit->bl,AREA);
- return 0;
- }
- /*==========================================
- * ワープ場所選択
- *------------------------------------------
- */
- int clif_skill_warppoint(struct map_session_data *sd,int skill_num,int skill_lv,
- const char *map1,const char *map2,const char *map3,const char *map4)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x11c]);
- WFIFOW(fd,0)=0x11c;
- WFIFOW(fd,2)=skill_num;
- strncpy((char*)WFIFOP(fd, 4),map1,MAP_NAME_LENGTH);
- strncpy((char*)WFIFOP(fd,20),map2,MAP_NAME_LENGTH);
- strncpy((char*)WFIFOP(fd,36),map3,MAP_NAME_LENGTH);
- strncpy((char*)WFIFOP(fd,52),map4,MAP_NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0x11c]);
- sd->menuskill_id = skill_num;
- if (skill_num == AL_WARP)
- sd->menuskill_lv = (sd->ud.skillx<<16)|sd->ud.skilly; //Store warp position here.
- else
- sd->menuskill_lv = skill_lv;
- return 0;
- }
- /*==========================================
- * メモ応答
- *------------------------------------------
- */
- int clif_skill_memo(struct map_session_data *sd,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x11e]);
- WFIFOW(fd,0)=0x11e;
- WFIFOB(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x11e]);
- return 0;
- }
- int clif_skill_teleportmessage(struct map_session_data *sd,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x189]);
- WFIFOW(fd,0)=0x189;
- WFIFOW(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x189]);
- return 0;
- }
- /*==========================================
- * モンスター情報
- *------------------------------------------
- */
- int clif_skill_estimation(struct map_session_data *sd,struct block_list *dst)
- {
- struct status_data *status;
- unsigned char buf[64];
- int i;//, fix;
- nullpo_retr(0, sd);
- nullpo_retr(0, dst);
- if(dst->type!=BL_MOB )
- return 0;
- status = status_get_status_data(dst);
- WBUFW(buf, 0)=0x18c;
- WBUFW(buf, 2)=status_get_class(dst);
- WBUFW(buf, 4)=status_get_lv(dst);
- WBUFW(buf, 6)=status->size;
- WBUFL(buf, 8)=status->hp;
- WBUFW(buf,12)= (battle_config.estimation_type&1?status->def:0)
- +(battle_config.estimation_type&2?status->def2:0);
- WBUFW(buf,14)=status->race;
- WBUFW(buf,16)= (battle_config.estimation_type&1?status->mdef:0)
- +(battle_config.estimation_type&2?status->mdef2:0);
- WBUFW(buf,18)= status->def_ele;
- for(i=0;i<9;i++)
- WBUFB(buf,20+i)= (unsigned char)battle_attr_fix(NULL,dst,100,i+1,status->def_ele, status->ele_lv);
- // The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex]
- // WBUFB(buf,20+i)= (unsigned char)((fix=battle_attr_fix(NULL,dst,100,i+1,status->def_ele, status->ele_lv))<0?0:fix);
- if(sd->status.party_id>0)
- clif_send(buf,packet_len_table[0x18c],&sd->bl,PARTY_SAMEMAP);
- else{
- WFIFOHEAD(sd->fd,packet_len_table[0x18c]);
- memcpy(WFIFOP(sd->fd,0),buf,packet_len_table[0x18c]);
- WFIFOSET(sd->fd,packet_len_table[0x18c]);
- }
- return 0;
- }
- /*==========================================
- * アイテム合成可能リスト
- *------------------------------------------
- */
- int clif_skill_produce_mix_list(struct map_session_data *sd, int trigger)
- {
- int i,c,view,fd;
- nullpo_retr(0, sd);
- if(sd->menuskill_id == AM_PHARMACY)
- return 0; //Avoid resending the menu twice or more times...
- fd=sd->fd;
- WFIFOHEAD(fd, MAX_SKILL_PRODUCE_DB * 8 + 8);
- WFIFOW(fd, 0)=0x18d;
- for(i=0,c=0;i<MAX_SKILL_PRODUCE_DB;i++){
- if( skill_can_produce_mix(sd,skill_produce_db[i].nameid,trigger, 1) ){
- if((view = itemdb_viewid(skill_produce_db[i].nameid)) > 0)
- WFIFOW(fd,c*8+ 4)= view;
- else
- WFIFOW(fd,c*8+ 4)= skill_produce_db[i].nameid;
- WFIFOW(fd,c*8+ 6)= 0x0012;
- WFIFOL(fd,c*8+ 8)= sd->status.char_id;
- c++;
- }
- }
- WFIFOW(fd, 2)=c*8+8;
- WFIFOSET(fd,WFIFOW(fd,2));
- if(c > 0) {
- sd->menuskill_id = AM_PHARMACY;
- sd->menuskill_lv = trigger;
- return 1;
- }
- return 0;
- }
- /*==========================================
- * Sends a status change packet to the object only, used for loading status changes. [Skotlex]
- *------------------------------------------
- */
- int clif_status_load(struct block_list *bl,int type, int flag)
- {
- int fd;
- if (type == SI_BLANK) //It shows nothing on the client...
- return 0;
-
- if (bl->type != BL_PC)
- return 0;
- fd = ((struct map_session_data*)bl)->fd;
-
- WFIFOHEAD(fd,packet_len_table[0x196]);
- WFIFOW(fd,0)=0x0196;
- WFIFOW(fd,2)=type;
- WFIFOL(fd,4)=bl->id;
- WFIFOB(fd,8)=flag; //Status start
- WFIFOSET(fd, packet_len_table[0x196]);
- return 0;
- }
- /*==========================================
- * 状態異常アイコン/メッセージ表示
- *------------------------------------------
- */
- int clif_status_change(struct block_list *bl,int type,int flag)
- {
- unsigned char buf[16];
- if (type == SI_BLANK) //It shows nothing on the client...
- return 0;
-
- nullpo_retr(0, bl);
- WBUFW(buf,0)=0x0196;
- WBUFW(buf,2)=type;
- WBUFL(buf,4)=bl->id;
- WBUFB(buf,8)=flag;
- clif_send(buf,packet_len_table[0x196],bl,AREA);
- return 0;
- }
- /*==========================================
- * Send message (modified by [Yor])
- *------------------------------------------
- */
- int clif_displaymessage(const int fd, char* mes)
- {
- // invalid pointer?
- nullpo_retr(-1, mes);
-
- //Console [Wizputer] //Scrapped, as these are shared by disconnected players =X [Skotlex]
- if (fd == 0)
- return 0;
- else {
- int len_mes = strlen(mes);
- if (len_mes > 0) { // don't send a void message (it's not displaying on the client chat). @help can send void line.
- WFIFOHEAD(fd, 5 + len_mes);
- WFIFOW(fd,0) = 0x8e;
- WFIFOW(fd,2) = 5 + len_mes; // 4 + len + NULL teminate
- memcpy(WFIFOP(fd,4), mes, len_mes + 1);
- WFIFOSET(fd, 5 + len_mes);
- }
- }
- return 0;
- }
- /*==========================================
- * 天の声を送信する
- *------------------------------------------
- */
- int clif_GMmessage(struct block_list *bl, char* mes, int len, int flag)
- {
- unsigned char *buf;
- int lp;
- lp = (flag & 0x10) ? 8 : 4;
- buf = (unsigned char*)aMallocA((len + lp + 8)*sizeof(unsigned char));
- WBUFW(buf,0) = 0x9a;
- WBUFW(buf,2) = len + lp;
- WBUFL(buf,4) = 0x65756c62;
- memcpy(WBUFP(buf,lp), mes, len);
- flag &= 0x07;
- clif_send(buf, WBUFW(buf,2), bl,
- (flag == 1) ? ALL_SAMEMAP :
- (flag == 2) ? AREA :
- (flag == 3) ? SELF :
- ALL_CLIENT);
- if(buf) aFree(buf);
- if(use_irc && irc_announce_flag && !flag)
- irc_announce(mes);
- return 0;
- }
- /*==========================================
- * グローバルメッセージ
- *------------------------------------------
- */
- void clif_GlobalMessage(struct block_list *bl,char *message)
- {
- char buf[100];
- int len;
- nullpo_retv(bl);
- if(!message)
- return;
- len = strlen(message)+1;
- WBUFW(buf,0)=0x8d;
- WBUFW(buf,2)=len+8;
- WBUFL(buf,4)=bl->id;
- strncpy((char *) WBUFP(buf,8),message,len);
- clif_send((unsigned char *) buf,WBUFW(buf,2),bl,ALL_CLIENT);
- }
- /*==========================================
- * Send main chat message [LuzZza]
- *------------------------------------------
- */
- void clif_MainChatMessage(char* message) {
- char buf[200];
- int len;
-
- if(!message)
- return;
-
- len = strlen(message)+1;
- if (len+8 > sizeof(buf)) {
- ShowDebug("clif_MainChatMessage: Received message too long (len %d): %s\n", len, message);
- len = sizeof(buf)-8;
- }
- WBUFW(buf,0)=0x8d;
- WBUFW(buf,2)=len+8;
- WBUFL(buf,4)=0;
- strncpy((char *) WBUFP(buf,8),message,len);
- clif_send((unsigned char *) buf,WBUFW(buf,2),NULL,CHAT_MAINCHAT);
- }
- /*==========================================
- * Does an announce message in the given color.
- *------------------------------------------
- */
- int clif_announce(struct block_list *bl, char* mes, int len, unsigned long color, int flag)
- {
- unsigned char *buf;
- buf = (unsigned char*)aMallocA((len + 16)*sizeof(unsigned char));
- WBUFW(buf,0) = 0x1c3;
- WBUFW(buf,2) = len + 16;
- WBUFL(buf,4) = color;
- WBUFW(buf,8) = 0x190; //Font style? Type?
- WBUFW(buf,10) = 0x0c; //12? Font size?
- WBUFL(buf,12) = 0; //Unknown!
- memcpy(WBUFP(buf,16), mes, len);
-
- flag &= 0x07;
- clif_send(buf, WBUFW(buf,2), bl,
- (flag == 1) ? ALL_SAMEMAP :
- (flag == 2) ? AREA :
- (flag == 3) ? SELF :
- ALL_CLIENT);
- if(buf) aFree(buf);
- return 0;
- }
- /*==========================================
- * HPSP回復エフェクトを送信する
- *------------------------------------------
- */
- int clif_heal(int fd,int type,int val)
- {
- WFIFOHEAD(fd,packet_len_table[0x13d]);
- WFIFOW(fd,0)=0x13d;
- WFIFOW(fd,2)=type;
- WFIFOW(fd,4)=val;
- WFIFOSET(fd,packet_len_table[0x13d]);
- return 0;
- }
- /*==========================================
- * 復活する
- *------------------------------------------
- */
- int clif_resurrection(struct block_list *bl,int type)
- {
- unsigned char buf[16];
- nullpo_retr(0, bl);
- WBUFW(buf,0)=0x148;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=type;
- clif_send(buf,packet_len_table[0x148],bl,type==1 ? AREA : AREA_WOS);
- if (disguised(bl))
- clif_spawn(bl);
- return 0;
- }
- /*==========================================
- * PVP実装?(仮)
- *------------------------------------------
- */
- int clif_set0199(int fd,int type)
- {
- WFIFOHEAD(fd,packet_len_table[0x199]);
- WFIFOW(fd,0)=0x199;
- WFIFOW(fd,2)=type;
- WFIFOSET(fd,packet_len_table[0x199]);
- return 0;
- }
- /*==========================================
- * PVP実装?(仮)
- *------------------------------------------
- */
- int clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type)
- {
- nullpo_retr(0, sd);
- if(type == 2) {
- WFIFOHEAD(sd->fd,packet_len_table[0x19a]);
- WFIFOW(sd->fd,0) = 0x19a;
- WFIFOL(sd->fd,2) = sd->bl.id;
- WFIFOL(sd->fd,6) = pvprank;
- WFIFOL(sd->fd,10) = pvpnum;
- WFIFOSET(sd->fd,packet_len_table[0x19a]);
- } else {
- unsigned char buf[32];
- WBUFW(buf,0) = 0x19a;
- WBUFL(buf,2) = sd->bl.id;
- if(sd->sc.option&(OPTION_HIDE|OPTION_CLOAK))
- WBUFL(buf,6) = ULONG_MAX; //On client displays as --
- else
- WBUFL(buf,6) = pvprank;
- WBUFL(buf,10) = pvpnum;
- if(sd->sc.option&OPTION_INVISIBLE)
- clif_send(buf,packet_len_table[0x19a],&sd->bl,SELF);
- else if(!type)
- clif_send(buf,packet_len_table[0x19a],&sd->bl,AREA);
- else
- clif_send(buf,packet_len_table[0x19a],&sd->bl,ALL_SAMEMAP);
- }
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_send0199(int map,int type)
- {
- struct block_list bl;
- unsigned char buf[16];
- bl.id = 0;
- bl.type = BL_NUL;
- bl.m = map;
- WBUFW(buf,0)=0x199;
- WBUFW(buf,2)=type;
- clif_send(buf,packet_len_table[0x199],&bl,ALL_SAMEMAP);
- return 0;
- }
- /*==========================================
- * 精錬エフェクトを送信する
- *------------------------------------------
- */
- int clif_refine(int fd,struct map_session_data *sd,int fail,int index,int val)
- {
- WFIFOHEAD(fd,packet_len_table[0x188]);
- WFIFOW(fd,0)=0x188;
- WFIFOW(fd,2)=fail;
- WFIFOW(fd,4)=index+2;
- WFIFOW(fd,6)=val;
- WFIFOSET(fd,packet_len_table[0x188]);
- return 0;
- }
- /*==========================================
- * Wisp/page is transmitted to the destination player
- *------------------------------------------
- */
- int clif_wis_message(int fd, char *nick, char *mes, int mes_len) // R 0097 <len>.w <nick>.24B <message>.?B
- {
- // printf("clif_wis_message(%d, %s, %s)\n", fd, nick, mes);
- WFIFOHEAD(fd, mes_len + NAME_LENGTH + 4);
- WFIFOW(fd,0) = 0x97;
- WFIFOW(fd,2) = mes_len + NAME_LENGTH + 4;
- memcpy(WFIFOP(fd,4), nick, NAME_LENGTH);
- memcpy(WFIFOP(fd,28), mes, mes_len);
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
- }
- /*==========================================
- * The transmission result of Wisp/page is transmitted to the source player
- *------------------------------------------
- */
- int clif_wis_end(int fd, int flag) // R 0098 <type>.B: 0: success to send wisper, 1: target character is not loged in, 2: ignored by target, 3: everyone ignored by target
- {
- WFIFOHEAD(fd,packet_len_table[0x98]);
- WFIFOW(fd,0) = 0x98;
- WFIFOW(fd,2) = flag;
- WFIFOSET(fd,packet_len_table[0x98]);
- return 0;
- }
- /*==========================================
- * キャラID名前引き結果を送信する
- *------------------------------------------
- */
- int clif_solved_charname(struct map_session_data *sd,int char_id)
- {
- char *p= map_charid2nick(char_id);
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- if(p!=NULL){
- WFIFOHEAD(fd,packet_len_table[0x194]);
- WFIFOW(fd,0)=0x194;
- WFIFOL(fd,2)=char_id;
- memcpy(WFIFOP(fd,6), p, NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0x194]);
- }else{
- map_reqchariddb(sd,char_id);
- chrif_searchcharid(char_id);
- }
- return 0;
- }
- /*==========================================
- * カードの挿入可能リストを返す
- *------------------------------------------
- */
- int clif_use_card(struct map_session_data *sd,int idx)
- {
- int i,c,ep;
- int fd=sd->fd;
- nullpo_retr(0, sd);
- if (idx < 0 || idx >= MAX_INVENTORY) //Crash-fix from bad packets.
- return 0;
- if (!sd->inventory_data[idx] || sd->inventory_data[idx]->type != IT_CARD)
- return 0; //Avoid parsing invalid item indexes (no card/no item)
-
- ep=sd->inventory_data[idx]->equip;
- WFIFOHEAD(fd,MAX_INVENTORY * 2 + 4);
- WFIFOW(fd,0)=0x017b;
- for(i=c=0;i<MAX_INVENTORY;i++){
- int j;
- if(sd->inventory_data[i] == NULL)
- continue;
- if(sd->inventory_data[i]->type!=IT_WEAPON && sd->inventory_data[i]->type!=IT_ARMOR)
- continue;
- if(itemdb_isspecial(sd->status.inventory[i].card[0])) //Can't slot it
- continue;
- if(sd->status.inventory[i].identify==0 ) //Not identified
- continue;
- if((sd->inventory_data[i]->equip&ep)==0) //Not equippable on this part.
- continue;
- if(sd->inventory_data[i]->type==IT_WEAPON && ep==EQP_HAND_L) //Shield card won't go on left weapon.
- continue;
- for(j=0;j<sd->inventory_data[i]->slot;j++){
- if( sd->status.inventory[i].card[j]==0 )
- break;
- }
- if(j==sd->inventory_data[i]->slot) // No room
- continue;
- WFIFOW(fd,4+c*2)=i+2;
- c++;
- }
- WFIFOW(fd,2)=4+c*2;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
- }
- /*==========================================
- * カードの挿入終了
- *------------------------------------------
- */
- int clif_insert_card(struct map_session_data *sd,int idx_equip,int idx_card,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x17d]);
- WFIFOW(fd,0)=0x17d;
- WFIFOW(fd,2)=idx_equip+2;
- WFIFOW(fd,4)=idx_card+2;
- WFIFOB(fd,6)=flag;
- WFIFOSET(fd,packet_len_table[0x17d]);
- return 0;
- }
- /*==========================================
- * 鑑定可能アイテムリスト送信
- *------------------------------------------
- */
- int clif_item_identify_list(struct map_session_data *sd)
- {
- int i,c;
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,MAX_INVENTORY * 2 + 4);
- WFIFOW(fd,0)=0x177;
- for(i=c=0;i<MAX_INVENTORY;i++){
- if(sd->status.inventory[i].nameid > 0 && !sd->status.inventory[i].identify){
- WFIFOW(fd,c*2+4)=i+2;
- c++;
- }
- }
- if(c > 0) {
- WFIFOW(fd,2)=c*2+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- sd->menuskill_id = MC_IDENTIFY;
- sd->menuskill_lv = c;
- }
- return 0;
- }
- /*==========================================
- * 鑑定結果
- *------------------------------------------
- */
- int clif_item_identified(struct map_session_data *sd,int idx,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x179]);
- WFIFOW(fd, 0)=0x179;
- WFIFOW(fd, 2)=idx+2;
- WFIFOB(fd, 4)=flag;
- WFIFOSET(fd,packet_len_table[0x179]);
- return 0;
- }
- /*==========================================
- * 修理可能アイテムリスト送信
- *------------------------------------------
- */
- int clif_item_repair_list(struct map_session_data *sd,struct map_session_data *dstsd)
- {
- int i,c;
- int fd;
- int nameid;
- nullpo_retr(0, sd);
- nullpo_retr(0, dstsd);
- fd=sd->fd;
- WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4);
- WFIFOW(fd,0)=0x1fc;
- for(i=c=0;i<MAX_INVENTORY;i++){
- if((nameid=dstsd->status.inventory[i].nameid) > 0 && dstsd->status.inventory[i].attribute!=0){// && skill_can_repair(sd,nameid)){
- WFIFOW(fd,c*13+4) = i;
- WFIFOW(fd,c*13+6) = nameid;
- WFIFOL(fd,c*13+8) = sd->status.char_id;
- WFIFOL(fd,c*13+12)= dstsd->status.char_id;
- WFIFOB(fd,c*13+16)= c;
- c++;
- }
- }
- if(c > 0) {
- WFIFOW(fd,2)=c*13+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- sd->menuskill_id = BS_REPAIRWEAPON;
- sd->menuskill_lv = dstsd->bl.id;
- }else
- clif_skill_fail(sd,sd->ud.skillid,0,0);
- return 0;
- }
- int clif_item_repaireffect(struct map_session_data *sd,int nameid,int flag)
- {
- int view,fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1fe]);
- WFIFOW(fd, 0)=0x1fe;
- if((view = itemdb_viewid(nameid)) > 0)
- WFIFOW(fd, 2)=view;
- else
- WFIFOW(fd, 2)=nameid;
- WFIFOB(fd, 4)=flag;
- WFIFOSET(fd,packet_len_table[0x1fe]);
- return 0;
- }
- /*==========================================
- * Weapon Refining - Taken from jAthena
- *------------------------------------------
- */
- int clif_item_refine_list(struct map_session_data *sd)
- {
- int i,c;
- int fd;
- int skilllv;
- int wlv;
- int refine_item[5];
- nullpo_retr(0, sd);
- skilllv = pc_checkskill(sd,WS_WEAPONREFINE);
- fd=sd->fd;
- refine_item[0] = -1;
- refine_item[1] = pc_search_inventory(sd,1010);
- refine_item[2] = pc_search_inventory(sd,1011);
- refine_item[3] = refine_item[4] = pc_search_inventory(sd,984);
- WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4);
- WFIFOW(fd,0)=0x221;
- for(i=c=0;i<MAX_INVENTORY;i++){
- if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].refine < skilllv &&
- sd->status.inventory[i].identify && (wlv=itemdb_wlv(sd->status.inventory[i].nameid)) >=1 &&
- refine_item[wlv]!=-1 && !(sd->status.inventory[i].equip&0x0022)){
- WFIFOW(fd,c*13+ 4)=i+2;
- WFIFOW(fd,c*13+ 6)=sd->status.inventory[i].nameid;
- WFIFOW(fd,c*13+ 8)=0; //TODO: Wonder what are these for? Perhaps ID of weapon's crafter if any?
- WFIFOW(fd,c*13+10)=0;
- WFIFOB(fd,c*13+12)=c;
- c++;
- }
- }
- WFIFOW(fd,2)=c*13+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- sd->menuskill_id = WS_WEAPONREFINE;
- sd->menuskill_lv = skilllv;
- return 0;
- }
- /*==========================================
- * アイテムによる一時的なスキル効果
- *------------------------------------------
- */
- int clif_item_skill(struct map_session_data *sd,int skillid,int skilllv,const char *name)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x147]);
- WFIFOW(fd, 0)=0x147;
- WFIFOW(fd, 2)=skillid;
- WFIFOW(fd, 4)=skill_get_inf(skillid);
- WFIFOW(fd, 6)=0;
- WFIFOW(fd, 8)=skilllv;
- WFIFOW(fd,10)=skill_get_sp(skillid,skilllv);
- WFIFOW(fd,12)=skill_get_range2(&sd->bl, skillid,skilllv);
- strncpy((char*)WFIFOP(fd,14),name,NAME_LENGTH);
- WFIFOB(fd,38)=0;
- WFIFOSET(fd,packet_len_table[0x147]);
- return 0;
- }
- /*==========================================
- * カートにアイテム追加
- *------------------------------------------
- */
- int clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail)
- {
- int view,fd;
- unsigned char *buf;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x124]);
- buf=WFIFOP(fd,0);
- if(n<0 || n>=MAX_CART || sd->status.cart[n].nameid<=0)
- return 1;
- WBUFW(buf,0)=0x124;
- WBUFW(buf,2)=n+2;
- WBUFL(buf,4)=amount;
- if((view = itemdb_viewid(sd->status.cart[n].nameid)) > 0)
- WBUFW(buf,8)=view;
- else
- WBUFW(buf,8)=sd->status.cart[n].nameid;
- WBUFB(buf,10)=sd->status.cart[n].identify;
- WBUFB(buf,11)=sd->status.cart[n].attribute;
- WBUFB(buf,12)=sd->status.cart[n].refine;
- clif_addcards(WBUFP(buf,13), &sd->status.cart[n]);
- WFIFOSET(fd,packet_len_table[0x124]);
- return 0;
- }
- /*==========================================
- * カートからアイテム削除
- *------------------------------------------
- */
- int clif_cart_delitem(struct map_session_data *sd,int n,int amount)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x125]);
- WFIFOW(fd,0)=0x125;
- WFIFOW(fd,2)=n+2;
- WFIFOL(fd,4)=amount;
- WFIFOSET(fd,packet_len_table[0x125]);
- return 0;
- }
- /*==========================================
- * 露店開設
- *------------------------------------------
- */
- int clif_openvendingreq(struct map_session_data *sd,int num)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x12d]);
- WFIFOW(fd,0)=0x12d;
- WFIFOW(fd,2)=num;
- WFIFOSET(fd,packet_len_table[0x12d]);
- return 0;
- }
- /*==========================================
- * 露店看板表示
- *------------------------------------------
- */
- int clif_showvendingboard(struct block_list* bl,char *message,int fd)
- {
- unsigned char buf[128];
- nullpo_retr(0, bl);
- WBUFW(buf,0)=0x131;
- WBUFL(buf,2)=bl->id;
- strncpy((char*)WBUFP(buf,6),message,80);
- if(fd){
- WFIFOHEAD(fd,packet_len_table[0x131]);
- memcpy(WFIFOP(fd,0),buf,packet_len_table[0x131]);
- WFIFOSET(fd,packet_len_table[0x131]);
- }else{
- clif_send(buf,packet_len_table[0x131],bl,AREA_WOS);
- }
- return 0;
- }
- /*==========================================
- * 露店看板消去
- *------------------------------------------
- */
- int clif_closevendingboard(struct block_list* bl,int fd)
- {
- unsigned char buf[16];
- nullpo_retr(0, bl);
- WBUFW(buf,0)=0x132;
- WBUFL(buf,2)=bl->id;
- if(fd){
- WFIFOHEAD(fd,packet_len_table[0x132]);
- memcpy(WFIFOP(fd,0),buf,packet_len_table[0x132]);
- WFIFOSET(fd,packet_len_table[0x132]);
- }else{
- clif_send(buf,packet_len_table[0x132],bl,AREA_WOS);
- }
- return 0;
- }
- /*==========================================
- * 露店アイテムリスト
- *------------------------------------------
- */
- int clif_vendinglist(struct map_session_data *sd,int id,struct vending *vending)
- {
- struct item_data *data;
- int i,n,index,fd;
- struct map_session_data *vsd;
- unsigned char *buf;
- nullpo_retr(0, sd);
- nullpo_retr(0, vending);
- nullpo_retr(0, vsd=map_id2sd(id));
- fd=sd->fd;
- WFIFOHEAD(fd, 8+vsd->vend_num*22);
- buf = WFIFOP(fd,0);
- for(i=0,n=0;i<vsd->vend_num;i++){
- if(vending[i].amount<=0)
- continue;
- WBUFL(buf,8+n*22)=vending[i].value;
- WBUFW(buf,12+n*22)=vending[i].amount;
- WBUFW(buf,14+n*22)=(index=vending[i].index)+2;
- if(vsd->status.cart[index].nameid <= 0 || vsd->status.cart[index].amount <= 0)
- continue;
- data = itemdb_search(vsd->status.cart[index].nameid);
- WBUFB(buf,16+n*22)=itemtype(data->type);
- if(data->view_id > 0)
- WBUFW(buf,17+n*22)=data->view_id;
- else
- WBUFW(buf,17+n*22)=vsd->status.cart[index].nameid;
- WBUFB(buf,19+n*22)=vsd->status.cart[index].identify;
- WBUFB(buf,20+n*22)=vsd->status.cart[index].attribute;
- WBUFB(buf,21+n*22)=vsd->status.cart[index].refine;
- clif_addcards(WBUFP(buf, 22+n*22), &vsd->status.cart[index]);
- n++;
- }
- if(n > 0){
- WBUFW(buf,0)=0x133;
- WBUFW(buf,2)=8+n*22;
- WBUFL(buf,4)=id;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- return 0;
- }
- /*==========================================
- * 露店アイテム購入失敗
- *------------------------------------------
- */
- int clif_buyvending(struct map_session_data *sd,int index,int amount,int fail)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x135]);
- WFIFOW(fd,0)=0x135;
- WFIFOW(fd,2)=index+2;
- WFIFOW(fd,4)=amount;
- WFIFOB(fd,6)=fail;
- WFIFOSET(fd,packet_len_table[0x135]);
- return 0;
- }
- /*==========================================
- * 露店開設成功
- *------------------------------------------
- */
- int clif_openvending(struct map_session_data *sd,int id,struct vending *vending)
- {
- struct item_data *data;
- int i,n,index,fd;
- unsigned char *buf;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd, 8+sd->vend_num*22);
- buf = WFIFOP(fd,0);
- for(i=0,n=0;i<sd->vend_num;i++){
- if (sd->vend_num > 2+pc_checkskill(sd,MC_VENDING)) return 0;
- WBUFL(buf,8+n*22)=vending[i].value;
- WBUFW(buf,12+n*22)=(index=vending[i].index)+2;
- WBUFW(buf,14+n*22)=vending[i].amount;
- if(sd->status.cart[index].nameid <= 0 || sd->status.cart[index].amount <= 0 || !sd->status.cart[index].identify ||
- sd->status.cart[index].attribute==1) // Prevent unidentified and broken items from being sold [Valaris]
- continue;
- data = itemdb_search(sd->status.cart[index].nameid);
- WBUFB(buf,16+n*22)=itemtype(data->type);
- if(data->view_id > 0)
- WBUFW(buf,17+n*22)=data->view_id;
- else
- WBUFW(buf,17+n*22)=sd->status.cart[index].nameid;
- WBUFB(buf,19+n*22)=sd->status.cart[index].identify;
- WBUFB(buf,20+n*22)=sd->status.cart[index].attribute;
- WBUFB(buf,21+n*22)=sd->status.cart[index].refine;
- clif_addcards(WBUFP(buf, 22+n*22), &sd->status.cart[index]);
- n++;
- }
- if(n > 0){
- WBUFW(buf,0)=0x136;
- WBUFW(buf,2)=8+n*22;
- WBUFL(buf,4)=id;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- return n;
- }
- /*==========================================
- * 露店アイテム販売報告
- *------------------------------------------
- */
- int clif_vendingreport(struct map_session_data *sd,int index,int amount)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x137]);
- WFIFOW(fd,0)=0x137;
- WFIFOW(fd,2)=index+2;
- WFIFOW(fd,4)=amount;
- WFIFOSET(fd,packet_len_table[0x137]);
- return 0;
- }
- /*==========================================
- * パーティ作成完了
- *------------------------------------------
- */
- int clif_party_created(struct map_session_data *sd,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xfa]);
- WFIFOW(fd,0)=0xfa;
- WFIFOB(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0xfa]);
- return 0;
- }
- int clif_party_main_info(struct party_data *p, int fd)
- {
- struct map_session_data *sd;
- int i;
- unsigned char buf[96];
-
- for (i=0; i<MAX_PARTY && !p->party.member[i].leader; i++);
- if (i >= MAX_PARTY) return 0; //Should never happen...
- sd = p->data[i].sd;
- WBUFW(buf,0)=0x1e9;
- WBUFL(buf,2)= p->party.member[i].account_id;
- WBUFL(buf,6)= 0; //We don't know yet what this long is about.
- WBUFW(buf,10)=sd?sd->bl.x:0;
- WBUFW(buf,12)=sd?sd->bl.y:0;
- WBUFB(buf,14)=(p->party.member[i].online)?0:1; //This byte is also unconfirmed...
- memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH);
- memcpy(WBUFP(buf,39), p->party.member[i].name, NAME_LENGTH);
- memcpy(WBUFP(buf,63), mapindex_id2name(p->party.member[i].map), MAP_NAME_LENGTH);
- WBUFB(buf,79) = (p->party.item&1)?1:0;
- WBUFB(buf,80) = (p->party.item&2)?1:0;
- if(fd>=0){
- WFIFOHEAD(fd,packet_len_table[0x1e9]);
- memcpy(WFIFOP(fd,0),buf,packet_len_table[0x1e9]);
- WFIFOSET(fd,packet_len_table[0x1e9]);
- return 1;
- }
- if (!sd) {
- for (i=0; i<MAX_PARTY && !p->data[i].sd; i++)
- if (i >= MAX_PARTY) return 0; //Should never happen...
- sd=p->data[i].sd;
- }
- clif_send(buf,packet_len_table[0x1e9],&sd->bl,PARTY);
- return 1;
- }
- int clif_party_join_info(struct party *p, struct map_session_data *sd)
- {
- unsigned char buf[96];
- WBUFW(buf,0)=0x1e9;
- WBUFL(buf,2)= sd->status.account_id;
- WBUFL(buf,6)= 0; //Apparently setting this to 1 makes you adoptable.
- WBUFW(buf,10)=sd->bl.x;
- WBUFW(buf,12)=sd->bl.y;
- WBUFB(buf,14)=0; //Unconfirmed byte.
- memcpy(WBUFP(buf,15), p->name, NAME_LENGTH);
- memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH);
- memcpy(WBUFP(buf,63), mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
- WBUFB(buf,79) = (p->item&1)?1:0;
- WBUFB(buf,80) = (p->item&2)?1:0;
- clif_send(buf,packet_len_table[0x1e9],&sd->bl,PARTY_WOS);
- return 1;
- }
- /*==========================================
- * パーティ情報送信
- *------------------------------------------
- */
- int clif_party_info(struct party_data *p,int fd)
- {
- unsigned char buf[1024];
- int i,c;
- struct map_session_data *sd=NULL;
- nullpo_retr(0, p);
- WBUFW(buf,0)=0xfb;
- memcpy(WBUFP(buf,4),p->party.name,NAME_LENGTH);
- for(i=c=0;i<MAX_PARTY;i++){
- struct party_member *m=&p->party.member[i];
- if(!m->account_id)
- continue;
- if(sd==NULL) sd=p->data[i].sd;
- WBUFL(buf,28+c*46)=m->account_id;
- memcpy(WBUFP(buf,28+c*46+ 4),m->name,NAME_LENGTH);
- memcpy(WBUFP(buf,28+c*46+28),mapindex_id2name(m->map),MAP_NAME_LENGTH);
- WBUFB(buf,28+c*46+44)=(m->leader)?0:1;
- WBUFB(buf,28+c*46+45)=(m->online)?0:1;
- c++;
- }
- WBUFW(buf,2)=28+c*46;
- if(fd>=0){ // fdが設定されてるならそれに送る
- WFIFOHEAD(fd, 28+c*46);
- memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2));
- WFIFOSET(fd,WFIFOW(fd,2));
- return 9;
- }
- if(sd!=NULL)
- clif_send(buf,WBUFW(buf,2),&sd->bl,PARTY);
- return 0;
- }
- /*==========================================
- * パーティ勧誘
- *------------------------------------------
- */
- int clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd)
- {
- int fd;
- struct party_data *p;
- nullpo_retr(0, sd);
- nullpo_retr(0, tsd);
- fd=tsd->fd;
- if( (p=party_search(sd->status.party_id))==NULL )
- return 0;
- WFIFOHEAD(fd,packet_len_table[0xfe]);
- WFIFOW(fd,0)=0xfe;
- WFIFOL(fd,2)=sd->status.account_id;
- memcpy(WFIFOP(fd,6),p->party.name,NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0xfe]);
- return 0;
- }
- /*==========================================
- * パーティ勧誘結果
- *------------------------------------------
- */
- int clif_party_inviteack(struct map_session_data *sd,char *nick,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xfd]);
- WFIFOW(fd,0)=0xfd;
- memcpy(WFIFOP(fd,2),nick,NAME_LENGTH);
- WFIFOB(fd,26)=flag;
- WFIFOSET(fd,packet_len_table[0xfd]);
- return 0;
- }
- /*==========================================
- * パーティ設定送信
- * flag & 0x001=exp変更ミス
- * 0x010=item変更ミス
- * 0x100=一人にのみ送信
- *------------------------------------------
- */
- int clif_party_option(struct party_data *p,struct map_session_data *sd,int flag)
- {
- unsigned char buf[16];
- nullpo_retr(0, p);
- // if(battle_config.etc_log)
- // printf("clif_party_option: %d %d %d\n",p->exp,p->item,flag);
- if(sd==NULL && flag==0){
- int i;
- for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
- if (i < MAX_PARTY)
- sd = p->data[i].sd;
- }
- if(sd==NULL)
- return 0;
- WBUFW(buf,0)=0x101;
- WBUFW(buf,2)=((flag&0x01)?2:p->party.exp);
- WBUFW(buf,4)=0; //NOTE: We don't know yet what this is for, it is NOT for item share rules, though. [Skotlex]
- if(flag==0)
- clif_send(buf,packet_len_table[0x101],&sd->bl,PARTY);
- else {
- WFIFOHEAD(sd->fd,packet_len_table[0x101]);
- memcpy(WFIFOP(sd->fd,0),buf,packet_len_table[0x101]);
- WFIFOSET(sd->fd,packet_len_table[0x101]);
- }
- return 0;
- }
- /*==========================================
- * パーティ脱退(脱退前に呼ぶこと)
- *------------------------------------------
- */
- int clif_party_leaved(struct party_data *p,struct map_session_data *sd,int account_id,char *name,int flag)
- {
- unsigned char buf[64];
- int i;
- nullpo_retr(0, p);
- WBUFW(buf,0)=0x105;
- WBUFL(buf,2)=account_id;
- memcpy(WBUFP(buf,6),name,NAME_LENGTH);
- WBUFB(buf,30)=flag&0x0f;
- if((flag&0xf0)==0){
- if(sd==NULL) {
- for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
- if (i < MAX_PARTY)
- sd = p->data[i].sd;
- }
- if (sd)
- clif_send(buf,packet_len_table[0x105],&sd->bl,PARTY);
- } else if (sd!=NULL) {
- WFIFOHEAD(sd->fd,packet_len_table[0x105]);
- memcpy(WFIFOP(sd->fd,0),buf,packet_len_table[0x105]);
- WFIFOSET(sd->fd,packet_len_table[0x105]);
- }
- return 0;
- }
- /*==========================================
- * パーティメッセージ送信
- *------------------------------------------
- */
- int clif_party_message(struct party_data *p,int account_id,char *mes,int len)
- {
- struct map_session_data *sd;
- int i;
- nullpo_retr(0, p);
- for(i=0; i < MAX_PARTY && !p->data[i].sd;i++);
- if(i < MAX_PARTY){
- unsigned char buf[1024];
- sd = p->data[i].sd;
- WBUFW(buf,0)=0x109;
- WBUFW(buf,2)=len+8;
- WBUFL(buf,4)=account_id;
- memcpy(WBUFP(buf,8),mes,len);
- clif_send(buf,len+8,&sd->bl,PARTY);
- }
- return 0;
- }
- /*==========================================
- * パーティ座標通知
- *------------------------------------------
- */
- int clif_party_xy(struct map_session_data *sd)
- {
- unsigned char buf[16];
- nullpo_retr(0, sd);
- WBUFW(buf,0)=0x107;
- WBUFL(buf,2)=sd->status.account_id;
- WBUFW(buf,6)=sd->bl.x;
- WBUFW(buf,8)=sd->bl.y;
- clif_send(buf,packet_len_table[0x107],&sd->bl,PARTY_SAMEMAP_WOS);
-
- return 0;
- }
- /*==========================================
- * Sends x/y dot to a single fd. [Skotlex]
- *------------------------------------------
- */
- int clif_party_xy_single(int fd, struct map_session_data *sd)
- {
- WFIFOHEAD(fd,packet_len_table[0x107]);
- WFIFOW(fd,0)=0x107;
- WFIFOL(fd,2)=sd->status.account_id;
- WFIFOW(fd,6)=sd->bl.x;
- WFIFOW(fd,8)=sd->bl.y;
- WFIFOSET(fd,packet_len_table[0x107]);
- return 0;
- }
- /*==========================================
- * パーティHP通知
- *------------------------------------------
- */
- int clif_party_hp(struct map_session_data *sd)
- {
- unsigned char buf[16];
- nullpo_retr(0, sd);
- WBUFW(buf,0)=0x106;
- WBUFL(buf,2)=sd->status.account_id;
- if (sd->battle_status.max_hp > SHRT_MAX) { //To correctly display the %hp bar. [Skotlex]
- WBUFW(buf,6) = sd->battle_status.hp/(sd->battle_status.max_hp/100);
- WBUFW(buf,8) = 100;
- } else {
- WBUFW(buf,6) = sd->battle_status.hp;
- WBUFW(buf,8) = sd->battle_status.max_hp;
- }
- clif_send(buf,packet_len_table[0x106],&sd->bl,PARTY_AREA_WOS);
- return 0;
- }
- /*==========================================
- * Sends HP bar to a single fd. [Skotlex]
- *------------------------------------------
- */
- static void clif_hpmeter_single(int fd, struct map_session_data *sd)
- {
- WFIFOHEAD(fd,packet_len_table[0x106]);
- WFIFOW(fd,0) = 0x106;
- WFIFOL(fd,2) = sd->status.account_id;
- if (sd->battle_status.max_hp > SHRT_MAX) { //To correctly display the %hp bar. [Skotlex]
- WFIFOW(fd,6) = sd->battle_status.hp/(sd->battle_status.max_hp/100);
- WFIFOW(fd,8) = 100;
- } else {
- WFIFOW(fd,6) = sd->battle_status.hp;
- WFIFOW(fd,8) = sd->battle_status.max_hp;
- }
- WFIFOSET (fd, packet_len_table[0x106]);
- }
- /*==========================================
- * GMへ場所とHP通知
- *------------------------------------------
- */
- int clif_hpmeter(struct map_session_data *sd)
- {
- struct map_session_data *sd2;
- unsigned char buf[16];
- int i, x0, y0, x1, y1;
- int level;
- nullpo_retr(0, sd);
- x0 = sd->bl.x - AREA_SIZE;
- y0 = sd->bl.y - AREA_SIZE;
- x1 = sd->bl.x + AREA_SIZE;
- y1 = sd->bl.y + AREA_SIZE;
- WBUFW(buf,0) = 0x106;
- WBUFL(buf,2) = sd->status.account_id;
- if (sd->battle_status.max_hp > SHRT_MAX) { //To correctly display the %hp bar. [Skotlex]
- WBUFW(buf,6) = sd->battle_status.hp/(sd->battle_status.max_hp/100);
- WBUFW(buf,8) = 100;
- } else {
- WBUFW(buf,6) = sd->battle_status.hp;
- WBUFW(buf,8) = sd->battle_status.max_hp;
- }
- for (i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd2 = (struct map_session_data*)session[i]->session_data) &&
- sd != sd2 && sd2->state.auth) {
- if (sd2->bl.m != sd->bl.m ||
- sd2->bl.x < x0 || sd2->bl.y < y0 ||
- sd2->bl.x > x1 || sd2->bl.y > y1 ||
- (level = pc_isGM(sd2)) < battle_config.disp_hpmeter ||
- level < pc_isGM(sd))
- continue;
- WFIFOHEAD (i, packet_len_table[0x106]);
- memcpy (WFIFOP(i,0), buf, packet_len_table[0x106]);
- WFIFOSET (i, packet_len_table[0x106]);
- }
- }
- return 0;
- }
- /*==========================================
- * パーティ場所移動(未使用)
- *------------------------------------------
- */
- int clif_party_move(struct party *p,struct map_session_data *sd,int online)
- {
- unsigned char buf[128];
- nullpo_retr(0, sd);
- nullpo_retr(0, p);
- WBUFW(buf, 0)=0x104;
- WBUFL(buf, 2)=sd->status.account_id;
- WBUFL(buf, 6)=0;
- WBUFW(buf,10)=sd->bl.x;
- WBUFW(buf,12)=sd->bl.y;
- WBUFB(buf,14)=!online;
- memcpy(WBUFP(buf,15),p->name, NAME_LENGTH);
- memcpy(WBUFP(buf,39),sd->status.name, NAME_LENGTH);
- memcpy(WBUFP(buf,63),map[sd->bl.m].name, MAP_NAME_LENGTH);
- clif_send(buf,packet_len_table[0x104],&sd->bl,PARTY);
- return 0;
- }
- /*==========================================
- * 攻撃するために移動が必要
- *------------------------------------------
- */
- int clif_movetoattack(struct map_session_data *sd,struct block_list *bl)
- {
- int fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, bl);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x139]);
- WFIFOW(fd, 0)=0x139;
- WFIFOL(fd, 2)=bl->id;
- WFIFOW(fd, 6)=bl->x;
- WFIFOW(fd, 8)=bl->y;
- WFIFOW(fd,10)=sd->bl.x;
- WFIFOW(fd,12)=sd->bl.y;
- WFIFOW(fd,14)=sd->battle_status.rhw.range;
- WFIFOSET(fd,packet_len_table[0x139]);
- return 0;
- }
- /*==========================================
- * 製造エフェクト
- *------------------------------------------
- */
- int clif_produceeffect(struct map_session_data *sd,int flag,int nameid)
- {
- int view,fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- // 名前の登録と送信を先にしておく
- if( map_charid2nick(sd->status.char_id)==NULL )
- map_addchariddb(sd->status.char_id,sd->status.name);
- clif_solved_charname(sd,sd->status.char_id);
- WFIFOHEAD(fd,packet_len_table[0x18f]);
- WFIFOW(fd, 0)=0x18f;
- WFIFOW(fd, 2)=flag;
- if((view = itemdb_viewid(nameid)) > 0)
- WFIFOW(fd, 4)=view;
- else
- WFIFOW(fd, 4)=nameid;
- WFIFOSET(fd,packet_len_table[0x18f]);
- return 0;
- }
- // pet
- int clif_catch_process(struct map_session_data *sd)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x19e]);
- WFIFOW(fd,0)=0x19e;
- WFIFOSET(fd,packet_len_table[0x19e]);
- sd->menuskill_id = SA_TAMINGMONSTER;
- if (sd->ud.skillid == SA_TAMINGMONSTER)
- sd->menuskill_lv = 0; //Free catch
- else
- sd->menuskill_lv = sd->itemid; //Consume catch
- return 0;
- }
- int clif_pet_rulet(struct map_session_data *sd,int data)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1a0]);
- WFIFOW(fd,0)=0x1a0;
- WFIFOB(fd,2)=data;
- WFIFOSET(fd,packet_len_table[0x1a0]);
- return 0;
- }
- /*==========================================
- * pet卵リスト作成
- *------------------------------------------
- */
- int clif_sendegg(struct map_session_data *sd)
- {
- //R 01a6 <len>.w <index>.w*
- int i,n=0,fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- if (battle_config.pet_no_gvg && map_flag_gvg(sd->bl.m))
- { //Disable pet hatching in GvG grounds during Guild Wars [Skotlex]
- clif_displaymessage(fd, "Pets are not allowed in Guild Wars.");
- return 0;
- }
- WFIFOHEAD(fd, MAX_INVENTORY * 2 + 4);
- WFIFOW(fd,0)=0x1a6;
- if(sd->status.pet_id <= 0) {
- for(i=0,n=0;i<MAX_INVENTORY;i++){
- if(sd->status.inventory[i].nameid<=0 || sd->inventory_data[i] == NULL ||
- sd->inventory_data[i]->type!=IT_PETEGG ||
- sd->status.inventory[i].amount<=0)
- continue;
- WFIFOW(fd,n*2+4)=i+2;
- n++;
- }
- }
- WFIFOW(fd,2)=4+n*2;
- WFIFOSET(fd,WFIFOW(fd,2));
- sd->menuskill_id = SA_TAMINGMONSTER;
- sd->menuskill_lv = -1;
- return 0;
- }
- int clif_send_petdata(struct map_session_data *sd,int type,int param)
- {
- int fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, sd->pd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1a4]);
- WFIFOW(fd,0)=0x1a4;
- WFIFOB(fd,2)=type;
- WFIFOL(fd,3)=sd->pd->bl.id;
- WFIFOL(fd,7)=param;
- WFIFOSET(fd,packet_len_table[0x1a4]);
- return 0;
- }
- int clif_send_petstatus(struct map_session_data *sd)
- {
- int fd;
- struct s_pet *pet;
- nullpo_retr(0, sd);
- nullpo_retr(0, sd->pd);
- fd=sd->fd;
- pet = &sd->pd->pet;
- WFIFOHEAD(fd,packet_len_table[0x1a2]);
- WFIFOW(fd,0)=0x1a2;
- memcpy(WFIFOP(fd,2),pet->name,NAME_LENGTH);
- WFIFOB(fd,26)=(battle_config.pet_rename == 1)? 0:pet->rename_flag;
- WFIFOW(fd,27)=pet->level;
- WFIFOW(fd,29)=pet->hungry;
- WFIFOW(fd,31)=pet->intimate;
- WFIFOW(fd,33)=pet->equip;
- WFIFOSET(fd,packet_len_table[0x1a2]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_pet_emotion(struct pet_data *pd,int param)
- {
- unsigned char buf[16];
- nullpo_retr(0, pd);
- malloc_set(buf,0,packet_len_table[0x1aa]);
- WBUFW(buf,0)=0x1aa;
- WBUFL(buf,2)=pd->bl.id;
- if(param >= 100 && pd->petDB->talk_convert_class) {
- if(pd->petDB->talk_convert_class < 0)
- return 0;
- else if(pd->petDB->talk_convert_class > 0) {
- param -= (pd->pet.class_ - 100)*100;
- param += (pd->petDB->talk_convert_class - 100)*100;
- }
- }
- WBUFL(buf,6)=param;
- clif_send(buf,packet_len_table[0x1aa],&pd->bl,AREA);
- return 0;
- }
- int clif_pet_performance(struct block_list *bl,int param)
- {
- unsigned char buf[16];
- nullpo_retr(0, bl);
- malloc_set(buf,0,packet_len_table[0x1a4]);
- WBUFW(buf,0)=0x1a4;
- WBUFB(buf,2)=4;
- WBUFL(buf,3)=bl->id;
- WBUFL(buf,7)=param;
- clif_send(buf,packet_len_table[0x1a4],bl,AREA);
- return 0;
- }
- int clif_pet_equip(struct pet_data *pd)
- {
- unsigned char buf[16];
- nullpo_retr(0, pd);
- malloc_set(buf,0,packet_len_table[0x1a4]);
- WBUFW(buf,0)=0x1a4;
- WBUFB(buf,2)=3;
- WBUFL(buf,3)=pd->bl.id;
- WBUFL(buf,7)=pd->vd.shield;
- clif_send(buf,packet_len_table[0x1a4],&pd->bl,AREA);
- return 0;
- }
- int clif_pet_food(struct map_session_data *sd,int foodid,int fail)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1a3]);
- WFIFOW(fd,0)=0x1a3;
- WFIFOB(fd,2)=fail;
- WFIFOW(fd,3)=foodid;
- WFIFOSET(fd,packet_len_table[0x1a3]);
- return 0;
- }
- /*==========================================
- * オートスペル リスト送信
- *------------------------------------------
- */
- int clif_autospell(struct map_session_data *sd,int skilllv)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1cd]);
- WFIFOW(fd, 0)=0x1cd;
- if(skilllv>0 && pc_checkskill(sd,MG_NAPALMBEAT)>0)
- WFIFOL(fd,2)= MG_NAPALMBEAT;
- else
- WFIFOL(fd,2)= 0x00000000;
- if(skilllv>1 && pc_checkskill(sd,MG_COLDBOLT)>0)
- WFIFOL(fd,6)= MG_COLDBOLT;
- else
- WFIFOL(fd,6)= 0x00000000;
- if(skilllv>1 && pc_checkskill(sd,MG_FIREBOLT)>0)
- WFIFOL(fd,10)= MG_FIREBOLT;
- else
- WFIFOL(fd,10)= 0x00000000;
- if(skilllv>1 && pc_checkskill(sd,MG_LIGHTNINGBOLT)>0)
- WFIFOL(fd,14)= MG_LIGHTNINGBOLT;
- else
- WFIFOL(fd,14)= 0x00000000;
- if(skilllv>4 && pc_checkskill(sd,MG_SOULSTRIKE)>0)
- WFIFOL(fd,18)= MG_SOULSTRIKE;
- else
- WFIFOL(fd,18)= 0x00000000;
- if(skilllv>7 && pc_checkskill(sd,MG_FIREBALL)>0)
- WFIFOL(fd,22)= MG_FIREBALL;
- else
- WFIFOL(fd,22)= 0x00000000;
- if(skilllv>9 && pc_checkskill(sd,MG_FROSTDIVER)>0)
- WFIFOL(fd,26)= MG_FROSTDIVER;
- else
- WFIFOL(fd,26)= 0x00000000;
- WFIFOSET(fd,packet_len_table[0x1cd]);
- sd->menuskill_id = SA_AUTOSPELL;
- sd->menuskill_lv = skilllv;
-
- return 0;
- }
- /*==========================================
- * ディボーションの青い糸
- *------------------------------------------
- */
- int clif_devotion(struct map_session_data *sd)
- {
- unsigned char buf[56];
- int i,n;
- nullpo_retr(0, sd);
- WBUFW(buf,0)=0x1cf;
- WBUFL(buf,2)=sd->bl.id;
- for(i=0,n=0;i<5;i++) {
- if (!sd->devotion[i])
- continue;
- WBUFL(buf,6+4*n)=sd->devotion[i];
- n++;
- }
- for(;n<5;n++)
- WBUFL(buf,6+4*n)=0;
-
- WBUFB(buf,26)=8;
- WBUFB(buf,27)=0;
- clif_send(buf,packet_len_table[0x1cf],&sd->bl,AREA);
- return 0;
- }
- int clif_marionette(struct block_list *src, struct block_list *target)
- {
- unsigned char buf[56];
- int n;
- WBUFW(buf,0)=0x1cf;
- WBUFL(buf,2)=src->id;
- for(n=0;n<5;n++)
- WBUFL(buf,6+4*n)=0;
- if (target) //The target goes on the second slot.
- WBUFL(buf,6+4) = target->id;
- WBUFB(buf,26)=8;
- WBUFB(buf,27)=0;
- clif_send(buf,packet_len_table[0x1cf],src,AREA);
- return 0;
- }
- /*==========================================
- * 氣球
- *------------------------------------------
- */
- int clif_spiritball(struct map_session_data *sd)
- {
- unsigned char buf[16];
- nullpo_retr(0, sd);
- WBUFW(buf,0)=0x1d0;
- WBUFL(buf,2)=sd->bl.id;
- WBUFW(buf,6)=sd->spiritball;
- clif_send(buf,packet_len_table[0x1d0],&sd->bl,AREA);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_combo_delay(struct block_list *bl,int wait)
- {
- unsigned char buf[32];
- nullpo_retr(0, bl);
- WBUFW(buf,0)=0x1d2;
- WBUFL(buf,2)=bl->id;
- WBUFL(buf,6)=wait;
- clif_send(buf,packet_len_table[0x1d2],bl,AREA);
- return 0;
- }
- /*==========================================
- *白刃取り
- *------------------------------------------
- */
- int clif_bladestop(struct block_list *src,struct block_list *dst,
- int _bool)
- {
- unsigned char buf[32];
- nullpo_retr(0, src);
- nullpo_retr(0, dst);
- WBUFW(buf,0)=0x1d1;
- WBUFL(buf,2)=src->id;
- WBUFL(buf,6)=dst->id;
- WBUFL(buf,10)=_bool;
- clif_send(buf,packet_len_table[0x1d1],src,AREA);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_changemapcell(int m,int x,int y,int cell_type,int type)
- {
- struct block_list bl;
- unsigned char buf[32];
- bl.type = BL_NUL;
- bl.m = m;
- bl.x = x;
- bl.y = y;
- WBUFW(buf,0) = 0x192;
- WBUFW(buf,2) = x;
- WBUFW(buf,4) = y;
- WBUFW(buf,6) = cell_type;
- memcpy(WBUFP(buf,8),map[m].name,MAP_NAME_LENGTH);
- if(!type)
- clif_send(buf,packet_len_table[0x192],&bl,AREA);
- else
- clif_send(buf,packet_len_table[0x192],&bl,ALL_SAMEMAP);
- return 0;
- }
- /*==========================================
- * MVPエフェクト
- *------------------------------------------
- */
- int clif_mvp_effect(struct map_session_data *sd)
- {
- unsigned char buf[16];
- nullpo_retr(0, sd);
- WBUFW(buf,0)=0x10c;
- WBUFL(buf,2)=sd->bl.id;
- clif_send(buf,packet_len_table[0x10c],&sd->bl,AREA);
- return 0;
- }
- /*==========================================
- * MVPアイテム所得
- *------------------------------------------
- */
- int clif_mvp_item(struct map_session_data *sd,int nameid)
- {
- int view,fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x10a]);
- WFIFOW(fd,0)=0x10a;
- if((view = itemdb_viewid(nameid)) > 0)
- WFIFOW(fd,2)=view;
- else
- WFIFOW(fd,2)=nameid;
- WFIFOSET(fd,packet_len_table[0x10a]);
- return 0;
- }
- /*==========================================
- * MVP経験値所得
- *------------------------------------------
- */
- int clif_mvp_exp(struct map_session_data *sd,unsigned long exp)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x10b]);
- WFIFOW(fd,0)=0x10b;
- WFIFOL(fd,2)=exp;
- WFIFOSET(fd,packet_len_table[0x10b]);
- return 0;
- }
- /*==========================================
- * ギルド作成可否通知
- *------------------------------------------
- */
- int clif_guild_created(struct map_session_data *sd,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x167]);
- WFIFOW(fd,0)=0x167;
- WFIFOB(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x167]);
- return 0;
- }
- /*==========================================
- * ギルド所属通知
- *------------------------------------------
- */
- int clif_guild_belonginfo(struct map_session_data *sd,struct guild *g)
- {
- int ps,fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, g);
- fd=sd->fd;
- ps=guild_getposition(sd,g);
- WFIFOHEAD(fd,packet_len_table[0x16c]);
- malloc_set(WFIFOP(fd,0),0,packet_len_table[0x16c]);
- WFIFOW(fd,0)=0x16c;
- WFIFOL(fd,2)=g->guild_id;
- WFIFOL(fd,6)=g->emblem_id;
- WFIFOL(fd,10)=g->position[ps].mode;
- memcpy(WFIFOP(fd,19),g->name,NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0x16c]);
- return 0;
- }
- /*==========================================
- * ギルドメンバログイン通知
- *------------------------------------------
- */
- int clif_guild_memberlogin_notice(struct guild *g,int idx,int flag)
- {
- unsigned char buf[64];
- nullpo_retr(0, g);
- WBUFW(buf, 0)=0x16d;
- WBUFL(buf, 2)=g->member[idx].account_id;
- WBUFL(buf, 6)=g->member[idx].char_id;
- WBUFL(buf,10)=flag;
- if(g->member[idx].sd==NULL){
- struct map_session_data *sd=guild_getavailablesd(g);
- if(sd!=NULL)
- clif_send(buf,packet_len_table[0x16d],&sd->bl,GUILD);
- }else
- clif_send(buf,packet_len_table[0x16d],&g->member[idx].sd->bl,GUILD_WOS);
- return 0;
- }
- // Function `clif_guild_memberlogin_notice` sends info about
- // logins and logouts of a guild member to the rest members.
- // But at the 1st time (after a player login or map changing)
- // the client won't show the message.
- // So I suggest use this function for sending "first-time-info"
- // to some player on entering the game or changing location.
- // At next time the client would always show the message.
- // The function sends all the statuses in the single packet
- // to economize traffic. [LuzZza]
- int clif_guild_send_onlineinfo(struct map_session_data *sd) {
- struct guild *g;
- char buf[14*128];
- int i, count=0, p_len;
-
- nullpo_retr(0, sd);
- p_len = packet_len_table[0x16d];
- if(!(g = guild_search(sd->status.guild_id)))
- return 0;
-
- for(i=0; i<g->max_member; i++) {
- if(g->member[i].account_id > 0 &&
- g->member[i].account_id != sd->status.account_id) {
- WBUFW(buf,count*p_len) = 0x16d;
- WBUFL(buf,count*p_len+2) = g->member[i].account_id;
- WBUFL(buf,count*p_len+6) = g->member[i].char_id;
- WBUFL(buf,count*p_len+10) = g->member[i].online;
- count++;
- }
- }
-
- clif_send(buf,p_len*count,&sd->bl,SELF);
- return 0;
- }
- /*==========================================
- * ギルドマスター通知(14dへの応答)
- *------------------------------------------
- */
- int clif_guild_masterormember(struct map_session_data *sd)
- {
- int type=0x57,fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- if(sd->state.gmaster_flag)
- type=0xd7;
- WFIFOHEAD(fd,packet_len_table[0x14e]);
- WFIFOW(fd,0)=0x14e;
- WFIFOL(fd,2)=type;
- WFIFOSET(fd,packet_len_table[0x14e]);
- return 0;
- }
- /*==========================================
- * Basic Info (Territories [Valaris])
- *------------------------------------------
- */
- int clif_guild_basicinfo(struct map_session_data *sd)
- {
- int fd,i,t=0;
- struct guild *g;
- struct guild_castle *gc=NULL;
- nullpo_retr(0, sd);
- fd=sd->fd;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
- WFIFOHEAD(fd,packet_len_table[0x1b6]);
- WFIFOW(fd, 0)=0x1b6;//0x150;
- WFIFOL(fd, 2)=g->guild_id;
- WFIFOL(fd, 6)=g->guild_lv;
- WFIFOL(fd,10)=g->connect_member;
- WFIFOL(fd,14)=g->max_member;
- WFIFOL(fd,18)=g->average_lv;
- WFIFOL(fd,22)=g->exp;
- WFIFOL(fd,26)=g->next_exp;
- WFIFOL(fd,30)=0; // 上納
- WFIFOL(fd,34)=0; // VW(性格の悪さ?:性向グラフ左右)
- WFIFOL(fd,38)=0; // RF(正義の度合い?:性向グラフ上下)
- WFIFOL(fd,42)=0; // 人数?
- memcpy(WFIFOP(fd,46),g->name, NAME_LENGTH);
- memcpy(WFIFOP(fd,70),g->master, NAME_LENGTH);
- for(i=0;i<MAX_GUILDCASTLE;i++){
- gc=guild_castle_search(i);
- if(!gc) continue;
- if(g->guild_id == gc->guild_id) t++;
- }
- if (t>=0 && t<=MAX_GUILDCASTLE) //(0=None, 1..24 = N of Casles) [Lupus]
- strncpy((char*)WFIFOP(fd,94),msg_txt(300+t),20);
- else
- strncpy((char*)WFIFOP(fd,94),msg_txt(299),20);
- WFIFOSET(fd,packet_len_table[WFIFOW(fd,0)]);
- clif_guild_emblem(sd,g); // Guild emblem vanish fix [Valaris]
- return 0;
- }
- /*==========================================
- * ギルド同盟/敵対情報
- *------------------------------------------
- */
- int clif_guild_allianceinfo(struct map_session_data *sd)
- {
- int fd,i,c;
- struct guild *g;
- nullpo_retr(0, sd);
- fd=sd->fd;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
- WFIFOHEAD(fd, MAX_GUILDALLIANCE * 32 + 4);
- WFIFOW(fd, 0)=0x14c;
- for(i=c=0;i<MAX_GUILDALLIANCE;i++){
- struct guild_alliance *a=&g->alliance[i];
- if(a->guild_id>0){
- WFIFOL(fd,c*32+4)=a->opposition;
- WFIFOL(fd,c*32+8)=a->guild_id;
- memcpy(WFIFOP(fd,c*32+12),a->name,NAME_LENGTH);
- c++;
- }
- }
- WFIFOW(fd, 2)=c*32+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
- }
- /*==========================================
- * ギルドメンバーリスト
- *------------------------------------------
- */
- int clif_guild_memberlist(struct map_session_data *sd)
- {
- int fd;
- int i,c;
- struct guild *g;
- nullpo_retr(0, sd);
- fd=sd->fd;
- if (!fd)
- return 0;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
- WFIFOHEAD(fd, g->max_member * 104 + 4);
- WFIFOW(fd, 0)=0x154;
- for(i=0,c=0;i<g->max_member;i++){
- struct guild_member *m=&g->member[i];
- if(m->account_id==0)
- continue;
- WFIFOL(fd,c*104+ 4)=m->account_id;
- WFIFOL(fd,c*104+ 8)=m->char_id;
- WFIFOW(fd,c*104+12)=m->hair;
- WFIFOW(fd,c*104+14)=m->hair_color;
- WFIFOW(fd,c*104+16)=m->gender;
- WFIFOW(fd,c*104+18)=m->class_;
- WFIFOW(fd,c*104+20)=m->lv;
- WFIFOL(fd,c*104+22)=m->exp;
- WFIFOL(fd,c*104+26)=m->online;
- WFIFOL(fd,c*104+30)=m->position;
- malloc_tsetword(WFIFOP(fd,c*104+34),0,50); // メモ?
- memcpy(WFIFOP(fd,c*104+84),m->name,NAME_LENGTH);
- c++;
- }
- WFIFOW(fd, 2)=c*104+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
- }
- /*==========================================
- * ギルド役職名リスト
- *------------------------------------------
- */
- int clif_guild_positionnamelist(struct map_session_data *sd)
- {
- int i,fd;
- struct guild *g;
- nullpo_retr(0, sd);
- fd=sd->fd;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
- WFIFOHEAD(fd, MAX_GUILDPOSITION * 28 + 4);
- WFIFOW(fd, 0)=0x166;
- for(i=0;i<MAX_GUILDPOSITION;i++){
- WFIFOL(fd,i*28+4)=i;
- memcpy(WFIFOP(fd,i*28+8),g->position[i].name,NAME_LENGTH);
- }
- WFIFOW(fd,2)=i*28+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
- }
- /*==========================================
- * ギルド役職情報リスト
- *------------------------------------------
- */
- int clif_guild_positioninfolist(struct map_session_data *sd)
- {
- int i,fd;
- struct guild *g;
- nullpo_retr(0, sd);
- fd=sd->fd;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
- WFIFOHEAD(fd, MAX_GUILDPOSITION * 16 + 4);
- WFIFOW(fd, 0)=0x160;
- for(i=0;i<MAX_GUILDPOSITION;i++){
- struct guild_position *p=&g->position[i];
- WFIFOL(fd,i*16+ 4)=i;
- WFIFOL(fd,i*16+ 8)=p->mode;
- WFIFOL(fd,i*16+12)=i;
- WFIFOL(fd,i*16+16)=p->exp_mode;
- }
- WFIFOW(fd, 2)=i*16+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
- }
- /*==========================================
- * ギルド役職変更通知
- *------------------------------------------
- */
- int clif_guild_positionchanged(struct guild *g,int idx)
- {
- struct map_session_data *sd;
- unsigned char buf[128];
- nullpo_retr(0, g);
- WBUFW(buf, 0)=0x174;
- WBUFW(buf, 2)=44;
- WBUFL(buf, 4)=idx;
- WBUFL(buf, 8)=g->position[idx].mode;
- WBUFL(buf,12)=idx;
- WBUFL(buf,16)=g->position[idx].exp_mode;
- memcpy(WBUFP(buf,20),g->position[idx].name,NAME_LENGTH);
- if( (sd=guild_getavailablesd(g))!=NULL )
- clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
- return 0;
- }
- /*==========================================
- * ギルドメンバ変更通知
- *------------------------------------------
- */
- int clif_guild_memberpositionchanged(struct guild *g,int idx)
- {
- struct map_session_data *sd;
- unsigned char buf[64];
- nullpo_retr(0, g);
- WBUFW(buf, 0)=0x156;
- WBUFW(buf, 2)=16;
- WBUFL(buf, 4)=g->member[idx].account_id;
- WBUFL(buf, 8)=g->member[idx].char_id;
- WBUFL(buf,12)=g->member[idx].position;
- if( (sd=guild_getavailablesd(g))!=NULL )
- clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
- return 0;
- }
- /*==========================================
- * ギルドエンブレム送信
- *------------------------------------------
- */
- int clif_guild_emblem(struct map_session_data *sd,struct guild *g)
- {
- int fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, g);
- fd=sd->fd;
- if(g->emblem_len<=0)
- return 0;
- WFIFOHEAD(fd,g->emblem_len+12);
- WFIFOW(fd,0)=0x152;
- WFIFOW(fd,2)=g->emblem_len+12;
- WFIFOL(fd,4)=g->guild_id;
- WFIFOL(fd,8)=g->emblem_id;
- memcpy(WFIFOP(fd,12),g->emblem_data,g->emblem_len);
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
- }
- /*==========================================
- * ギルドスキル送信
- *------------------------------------------
- */
- int clif_guild_skillinfo(struct map_session_data *sd)
- {
- int fd;
- int i,id,c,up=1;
- struct guild *g;
- nullpo_retr(0, sd);
- fd=sd->fd;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
- WFIFOHEAD(fd, MAX_GUILDSKILL * 37 + 6);
- WFIFOW(fd,0)=0x0162;
- WFIFOW(fd,4)=g->skill_point;
- for(i=c=0;i<MAX_GUILDSKILL;i++){
- if(g->skill[i].id>0 && guild_check_skill_require(g,g->skill[i].id)){
- WFIFOW(fd,c*37+ 6) = id = g->skill[i].id;
- WFIFOW(fd,c*37+ 8) = skill_get_inf(id);
- WFIFOW(fd,c*37+10) = 0;
- WFIFOW(fd,c*37+12) = g->skill[i].lv;
- WFIFOW(fd,c*37+14) = skill_get_sp(id,g->skill[i].lv);
- WFIFOW(fd,c*37+16) = skill_get_range(id,g->skill[i].lv);
- malloc_tsetdword(WFIFOP(fd,c*37+18),0,24);
- if(g->skill[i].lv < guild_skill_get_max(id) && (sd == g->member[0].sd))
- up = 1;
- else
- up = 0;
- WFIFOB(fd,c*37+42)= up;
- c++;
- }
- }
- WFIFOW(fd,2)=c*37+6;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
- }
- /*==========================================
- * ギルド告知送信
- *------------------------------------------
- */
- int clif_guild_notice(struct map_session_data *sd,struct guild *g)
- {
- int fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, g);
- fd = sd->fd;
- if ( !session_isActive(fd) ) //null pointer right here [Kevin]
- return 0;
-
- if (fd <= 0)
- return 0;
- if(*g->mes1==0 && *g->mes2==0)
- return 0;
- WFIFOHEAD(fd,packet_len_table[0x16f]);
- WFIFOW(fd,0)=0x16f;
- memcpy(WFIFOP(fd,2),g->mes1,60);
- memcpy(WFIFOP(fd,62),g->mes2,120);
- WFIFOSET(fd,packet_len_table[0x16f]);
- return 0;
- }
- /*==========================================
- * ギルドメンバ勧誘
- *------------------------------------------
- */
- int clif_guild_invite(struct map_session_data *sd,struct guild *g)
- {
- int fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, g);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x16a]);
- WFIFOW(fd,0)=0x16a;
- WFIFOL(fd,2)=g->guild_id;
- memcpy(WFIFOP(fd,6),g->name,NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0x16a]);
- return 0;
- }
- /*==========================================
- * ギルドメンバ勧誘結果
- *------------------------------------------
- */
- int clif_guild_inviteack(struct map_session_data *sd,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x169]);
- WFIFOW(fd,0)=0x169;
- WFIFOB(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x169]);
- return 0;
- }
- /*==========================================
- * ギルドメンバ脱退通知
- *------------------------------------------
- */
- int clif_guild_leave(struct map_session_data *sd,const char *name,const char *mes)
- {
- unsigned char buf[128];
- nullpo_retr(0, sd);
- WBUFW(buf, 0)=0x15a;
- memcpy(WBUFP(buf, 2),name,NAME_LENGTH);
- memcpy(WBUFP(buf,26),mes,40);
- clif_send(buf,packet_len_table[0x15a],&sd->bl,GUILD);
- return 0;
- }
- /*==========================================
- * ギルドメンバ追放通知
- *------------------------------------------
- */
- int clif_guild_expulsion(struct map_session_data *sd,const char *name,const char *mes,
- int account_id)
- {
- unsigned char buf[128];
- nullpo_retr(0, sd);
- WBUFW(buf, 0)=0x15c;
- memcpy(WBUFP(buf, 2),name,NAME_LENGTH);
- memcpy(WBUFP(buf,26),mes,40);
- memcpy(WBUFP(buf,66),"dummy",NAME_LENGTH);
- clif_send(buf,packet_len_table[0x15c],&sd->bl,GUILD);
- return 0;
- }
- /*==========================================
- * ギルド追放メンバリスト
- *------------------------------------------
- */
- int clif_guild_expulsionlist(struct map_session_data *sd)
- {
- int fd;
- int i,c;
- struct guild *g;
- nullpo_retr(0, sd);
- fd=sd->fd;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
- WFIFOHEAD(fd,MAX_GUILDEXPULSION * 88 + 4);
- WFIFOW(fd,0)=0x163;
- for(i=c=0;i<MAX_GUILDEXPULSION;i++){
- struct guild_expulsion *e=&g->expulsion[i];
- if(e->account_id>0){
- memcpy(WFIFOP(fd,c*88+ 4),e->name,NAME_LENGTH);
- memcpy(WFIFOP(fd,c*88+28),e->acc,24);
- memcpy(WFIFOP(fd,c*88+52),e->mes,44);
- c++;
- }
- }
- WFIFOW(fd,2)=c*88+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
- }
- /*==========================================
- * ギルド会話
- *------------------------------------------
- */
- int clif_guild_message(struct guild *g,int account_id,const char *mes,int len)
- {
- struct map_session_data *sd;
- unsigned char *buf;
- buf = (unsigned char*)aMallocA((len + 4)*sizeof(unsigned char));
- WBUFW(buf, 0) = 0x17f;
- WBUFW(buf, 2) = len + 4;
- memcpy(WBUFP(buf,4), mes, len);
- if ((sd = guild_getavailablesd(g)) != NULL)
- clif_send(buf, WBUFW(buf,2), &sd->bl, GUILD);
- if(buf) aFree(buf);
- return 0;
- }
- /*==========================================
- * ギルドスキル割り振り通知
- *------------------------------------------
- */
- int clif_guild_skillup(struct map_session_data *sd,int skill_num,int lv)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,11);
- WFIFOW(fd,0) = 0x10e;
- WFIFOW(fd,2) = skill_num;
- WFIFOW(fd,4) = lv;
- WFIFOW(fd,6) = skill_get_sp(skill_num,lv);
- WFIFOW(fd,8) = skill_get_range(skill_num,lv);
- WFIFOB(fd,10) = 1;
- WFIFOSET(fd,11);
- return 0;
- }
- /*==========================================
- * ギルド同盟要請
- *------------------------------------------
- */
- int clif_guild_reqalliance(struct map_session_data *sd,int account_id,const char *name)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x171]);
- WFIFOW(fd,0)=0x171;
- WFIFOL(fd,2)=account_id;
- memcpy(WFIFOP(fd,6),name,NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0x171]);
- return 0;
- }
- /*==========================================
- * ギルド同盟結果
- *------------------------------------------
- */
- int clif_guild_allianceack(struct map_session_data *sd,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x173]);
- WFIFOW(fd,0)=0x173;
- WFIFOL(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x173]);
- return 0;
- }
- /*==========================================
- * ギルド関係解消通知
- *------------------------------------------
- */
- int clif_guild_delalliance(struct map_session_data *sd,int guild_id,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd = sd->fd;
- if (fd <= 0)
- return 0;
- WFIFOHEAD(fd,packet_len_table[0x184]);
- WFIFOW(fd,0)=0x184;
- WFIFOL(fd,2)=guild_id;
- WFIFOL(fd,6)=flag;
- WFIFOSET(fd,packet_len_table[0x184]);
- return 0;
- }
- /*==========================================
- * ギルド敵対結果
- *------------------------------------------
- */
- int clif_guild_oppositionack(struct map_session_data *sd,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x181]);
- WFIFOW(fd,0)=0x181;
- WFIFOB(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x181]);
- return 0;
- }
- /*==========================================
- * ギルド関係追加
- *------------------------------------------
- */
- /*int clif_guild_allianceadded(struct guild *g,int idx)
- {
- unsigned char buf[64];
- WBUFW(fd,0)=0x185;
- WBUFL(fd,2)=g->alliance[idx].opposition;
- WBUFL(fd,6)=g->alliance[idx].guild_id;
- memcpy(WBUFP(fd,10),g->alliance[idx].name,NAME_LENGTH);
- clif_send(buf,packet_len_table[0x185],guild_getavailablesd(g),GUILD);
- return 0;
- }*/
- /*==========================================
- * ギルド解散通知
- *------------------------------------------
- */
- int clif_guild_broken(struct map_session_data *sd,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x15e]);
- WFIFOW(fd,0)=0x15e;
- WFIFOL(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x15e]);
- return 0;
- }
- /*==========================================
- * エモーション
- *------------------------------------------
- */
- void clif_emotion(struct block_list *bl,int type)
- {
- unsigned char buf[8];
- nullpo_retv(bl);
- WBUFW(buf,0)=0xc0;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=type;
- clif_send(buf,packet_len_table[0xc0],bl,AREA);
- }
- /*==========================================
- * トーキーボックス
- *------------------------------------------
- */
- void clif_talkiebox(struct block_list *bl,char* talkie)
- {
- unsigned char buf[86];
- nullpo_retv(bl);
- WBUFW(buf,0)=0x191;
- WBUFL(buf,2)=bl->id;
- memcpy(WBUFP(buf,6),talkie,MESSAGE_SIZE);
- clif_send(buf,packet_len_table[0x191],bl,AREA);
- }
- /*==========================================
- * 結婚エフェクト
- *------------------------------------------
- */
- void clif_wedding_effect(struct block_list *bl) {
- unsigned char buf[6];
- nullpo_retv(bl);
- WBUFW(buf,0) = 0x1ea;
- WBUFL(buf,2) = bl->id;
- clif_send(buf, packet_len_table[0x1ea], bl, AREA);
- }
- /*==========================================
- * あなたに逢いたい使用時名前叫び
- *------------------------------------------
- void clif_callpartner(struct map_session_data *sd)
- {
- unsigned char buf[26];
- char *p;
- nullpo_retv(sd);
- if(sd->status.partner_id){
- WBUFW(buf,0)=0x1e6;
- p = map_charid2nick(sd->status.partner_id);
- if(p){
- memcpy(WBUFP(buf,2),p,NAME_LENGTH);
- }else{
- map_reqchariddb(sd,sd->status.partner_id);
- chrif_searchcharid(sd->status.partner_id);
- WBUFB(buf,2) = 0;
- }
- clif_send(buf,packet_len_table[0x1e6],&sd->bl,AREA);
- }
- return;
- }
- */
- /*==========================================
- * Adopt baby [Celest]
- *------------------------------------------
- */
- void clif_adopt_process(struct map_session_data *sd)
- {
- int fd;
- nullpo_retv(sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1f8]);
- WFIFOW(fd,0)=0x1f8;
- WFIFOSET(fd,packet_len_table[0x1f8]);
- }
- /*==========================================
- * Marry [DracoRPG]
- *------------------------------------------
- */
- void clif_marriage_process(struct map_session_data *sd)
- {
- int fd;
- nullpo_retv(sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1e4]);
- WFIFOW(fd,0)=0x1e4;
- WFIFOSET(fd,packet_len_table[0x1e4]);
- }
- /*==========================================
- * Notice of divorce
- *------------------------------------------
- */
- void clif_divorced(struct map_session_data *sd, char *name)
- {
- int fd;
- nullpo_retv(sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x205]);
- WFIFOW(fd,0)=0x205;
- memcpy(WFIFOP(fd,2), name, NAME_LENGTH);
- WFIFOSET(fd, packet_len_table[0x205]);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_ReqAdopt(int fd, struct map_session_data *sd) {
- nullpo_retv(sd);
- WFIFOHEAD(fd,packet_len_table[0x1f6]);
- WFIFOW(fd,0)=0x1f6;
- WFIFOSET(fd, packet_len_table[0x1f6]);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_ReqMarriage(int fd, struct map_session_data *sd) {
- nullpo_retv(sd);
- WFIFOHEAD(fd,packet_len_table[0x1e2]);
- WFIFOW(fd,0)=0x1e2;
- WFIFOSET(fd, packet_len_table[0x1e2]);
- }
- /*==========================================
- * 座る
- *------------------------------------------
- */
- void clif_sitting(struct map_session_data *sd)
- {
- unsigned char buf[64];
- nullpo_retv(sd);
- WBUFW(buf, 0) = 0x8a;
- WBUFL(buf, 2) = sd->bl.id;
- WBUFB(buf,26) = 2;
- clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len)
- {
- int fd;
- nullpo_retr(0, sd);
- fd = sd->fd;
- if (!fd || !len) return 0; //Disconnected player.
- WFIFOHEAD(fd, len+5);
- WFIFOW(fd, 0) = 0x17f;
- WFIFOW(fd, 2) = len + 5;
- memcpy(WFIFOP(fd,4), mes, len);
- WFIFOSET(fd, WFIFOW(fd,2));
- return 1;
- }
- /*==========================================
- * Displays a message using the guild-chat colors to the specified targets. [Skotlex]
- *------------------------------------------
- */
- void clif_disp_message(struct block_list *src, char *mes, int len, int type)
- {
- unsigned char buf[1024];
- if (!len) return;
- WBUFW(buf, 0) = 0x17f;
- WBUFW(buf, 2) = len + 5;
- memcpy(WBUFP(buf,4), mes, len);
- clif_send(buf, WBUFW(buf,2), src, type);
- return;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_GM_kickack(struct map_session_data *sd, int id)
- {
- int fd;
- nullpo_retr(0, sd);
- fd = sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xcd]);
- WFIFOW(fd,0) = 0xcd;
- WFIFOL(fd,2) = id;
- WFIFOSET(fd, packet_len_table[0xcd]);
- return 0;
- }
- void clif_parse_QuitGame(int fd,struct map_session_data *sd);
- int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int type)
- {
- nullpo_retr(0, tsd);
- if(type)
- clif_GM_kickack(sd,tsd->status.account_id);
- WFIFOHEAD(tsd->fd,packet_len_table[0x18b]);
- WFIFOW(tsd->fd,0) = 0x18b;
- WFIFOW(tsd->fd,2) = 0;
- WFIFOSET(tsd->fd,packet_len_table[0x18b]);
- if (tsd->fd)
- {
- ShowDebug("clif_GM_kick: Disconnecting session #%d\n", tsd->fd);
- clif_setwaitclose(tsd->fd);
- } else { //Player has no session attached, delete it right away. [Skotlex]
- map_quit(tsd);
- }
- return 0;
- }
- int clif_GM_silence(struct map_session_data *sd, struct map_session_data *tsd, int type)
- {
- int fd;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, tsd);
- fd = tsd->fd;
- if (fd <= 0)
- return 0;
- WFIFOHEAD(fd,packet_len_table[0x14b]);
- WFIFOW(fd,0) = 0x14b;
- WFIFOB(fd,2) = 0;
- memcpy(WFIFOP(fd,3), sd->status.name, NAME_LENGTH);
- WFIFOSET(fd, packet_len_table[0x14b]);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int clif_timedout(struct map_session_data *sd)
- {
- nullpo_retr(0, sd);
- ShowInfo("%sCharacter with Account ID '"CL_WHITE"%d"CL_RESET"' timed out.\n", (pc_isGM(sd))?"GM ":"", sd->bl.id);
- clif_authfail_fd(sd->fd,3); // Even if player is not on we still send anyway
- clif_setwaitclose(sd->fd); // Set session to EOF
- return 0;
- }
- /*==========================================
- * Wis拒否許可応答
- *------------------------------------------
- */
- int clif_wisexin(struct map_session_data *sd,int type,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xd1]);
- WFIFOW(fd,0)=0xd1;
- WFIFOB(fd,2)=type;
- WFIFOB(fd,3)=flag;
- WFIFOSET(fd,packet_len_table[0xd1]);
- return 0;
- }
- /*==========================================
- * Wis全拒否許可応答
- *------------------------------------------
- */
- int clif_wisall(struct map_session_data *sd,int type,int flag)
- {
- int fd;
- nullpo_retr(0, sd);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xd2]);
- WFIFOW(fd,0)=0xd2;
- WFIFOB(fd,2)=type;
- WFIFOB(fd,3)=flag;
- WFIFOSET(fd,packet_len_table[0xd2]);
- return 0;
- }
- /*==========================================
- * サウンドエフェクト
- *------------------------------------------
- */
- void clif_soundeffect(struct map_session_data *sd,struct block_list *bl,char *name,int type)
- {
- int fd;
- nullpo_retv(sd);
- nullpo_retv(bl);
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1d3]);
- WFIFOW(fd,0)=0x1d3;
- memcpy(WFIFOP(fd,2),name,NAME_LENGTH);
- WFIFOB(fd,26)=type;
- WFIFOL(fd,27)=0;
- WFIFOL(fd,31)=bl->id;
- WFIFOSET(fd,packet_len_table[0x1d3]);
- return;
- }
- int clif_soundeffectall(struct block_list *bl, char *name, int type, int coverage)
- {
- unsigned char buf[40];
- malloc_set(buf, 0, packet_len_table[0x1d3]);
- if(coverage < 0 || coverage > 22){
- ShowError("clif_soundeffectall: undefined coverage.\n");
- return 0;
- }
- nullpo_retr(0, bl);
- WBUFW(buf,0)=0x1d3;
- memcpy(WBUFP(buf,2), name, NAME_LENGTH);
- WBUFB(buf,26)=type;
- WBUFL(buf,27)=0;
- WBUFL(buf,31)=bl->id;
- clif_send(buf, packet_len_table[0x1d3], bl, coverage);
- return 0;
- }
- // displaying special effects (npcs, weather, etc) [Valaris]
- int clif_specialeffect(struct block_list *bl, int type, int flag)
- {
- unsigned char buf[24];
- nullpo_retr(0, bl);
- malloc_set(buf, 0, packet_len_table[0x1f3]);
- WBUFW(buf,0) = 0x1f3;
- WBUFL(buf,2) = bl->id;
- WBUFL(buf,6) = type;
- clif_send(buf, packet_len_table[0x1f3], bl, flag);
- if (disguised(bl)) {
- WBUFL(buf,2) = -bl->id;
- clif_send(buf, packet_len_table[0x1f3], bl, SELF);
- }
- return 0;
- }
- // refresh the client's screen, getting rid of any effects
- int clif_refresh(struct map_session_data *sd) {
- nullpo_retr(-1, sd);
- clif_changemap(sd,sd->mapindex,sd->bl.x,sd->bl.y);
- clif_inventorylist(sd);
- if(pc_iscarton(sd)){
- clif_cartlist(sd);
- clif_updatestatus(sd,SP_CARTINFO);
- }
- clif_updatestatus(sd,SP_MAXWEIGHT);
- clif_updatestatus(sd,SP_WEIGHT);
- map_foreachinrange(clif_getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd);
- clif_weather_check(sd);
- return 0;
- }
- // updates the object's (bl) name on client
- int clif_charnameack (int fd, struct block_list *bl)
- {
- unsigned char buf[103];
- int cmd = 0x95;
- nullpo_retr(0, bl);
- WBUFW(buf,0) = cmd;
- WBUFL(buf,2) = bl->id;
- switch(bl->type) {
- case BL_PC:
- {
- struct map_session_data *ssd = (struct map_session_data *)bl;
- struct party_data *p = NULL;
- struct guild *g = NULL;
-
- //Requesting your own "shadow" name. [Skotlex]
- if (ssd->fd == fd && ssd->disguise)
- WBUFL(buf,2) = -bl->id;
- if (strlen(ssd->fakename)>1) {
- memcpy(WBUFP(buf,6), ssd->fakename, NAME_LENGTH);
- break;
- }
- memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH);
-
- if (ssd->status.party_id > 0)
- p = party_search(ssd->status.party_id);
- if (ssd->status.guild_id > 0)
- g = guild_search(ssd->status.guild_id);
- if (p == NULL && g == NULL)
- break;
-
- WBUFW(buf, 0) = cmd = 0x195;
- if (p)
- memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH);
- else
- WBUFB(buf,30) = 0;
-
- if (g)
- {
- int i, ps = -1;
- for(i = 0; i < g->max_member; i++) {
- if (g->member[i].account_id == ssd->status.account_id &&
- g->member[i].char_id == ssd->status.char_id )
- {
- ps = g->member[i].position;
- break;
- }
- }
- if (ps >= 0 && ps < MAX_GUILDPOSITION)
- {
- memcpy(WBUFP(buf,54), g->name,NAME_LENGTH);
- memcpy(WBUFP(buf,78), g->position[ps].name, NAME_LENGTH);
- } else { //Assume no guild.
- WBUFB(buf,54) = 0;
- WBUFB(buf,78) = 0;
- }
- } else {
- WBUFB(buf,54) = 0;
- WBUFB(buf,78) = 0;
- }
- }
- break;
- //[blackhole89]
- case BL_HOM:
- memcpy(WBUFP(buf,6), ((TBL_HOM*)bl)->homunculus.name, NAME_LENGTH);
- break;
- case BL_PET:
- memcpy(WBUFP(buf,6), ((TBL_PET*)bl)->pet.name, NAME_LENGTH);
- break;
- case BL_NPC:
- memcpy(WBUFP(buf,6), ((TBL_NPC*)bl)->name, NAME_LENGTH);
- break;
- case BL_MOB:
- {
- struct mob_data *md = (struct mob_data *)bl;
- nullpo_retr(0, md);
- memcpy(WBUFP(buf,6), md->name, NAME_LENGTH);
- if (md->guardian_data && md->guardian_data->guild_id) {
- WBUFW(buf, 0) = cmd = 0x195;
- WBUFB(buf,30) = 0;
- memcpy(WBUFP(buf,54), md->guardian_data->guild_name, NAME_LENGTH);
- memcpy(WBUFP(buf,78), md->guardian_data->castle->castle_name, NAME_LENGTH);
- } else if (battle_config.show_mob_info) {
- char mobhp[50], *str_p = mobhp;
- WBUFW(buf, 0) = cmd = 0x195;
- if (battle_config.show_mob_info&4)
- str_p += sprintf(str_p, "Lv. %d | ", md->level);
- if (battle_config.show_mob_info&1)
- str_p += sprintf(str_p, "HP: %u/%u | ", md->status.hp, md->status.max_hp);
- if (battle_config.show_mob_info&2)
- str_p += sprintf(str_p, "HP: %d%% | ",
- md->status.max_hp > 10000?
- md->status.hp/(md->status.max_hp/100):
- 100*md->status.hp/md->status.max_hp);
- //Even thought mobhp ain't a name, we send it as one so the client
- //can parse it. [Skotlex]
- if (str_p != mobhp) {
- *(str_p-3) = '\0'; //Remove trailing space + pipe.
- memcpy(WBUFP(buf,30), mobhp, NAME_LENGTH);
- WBUFB(buf,54) = 0;
- memcpy(WBUFP(buf,78), mobhp, NAME_LENGTH);
- }
- }
- }
- break;
- case BL_CHAT: //FIXME: Clients DO request this... what should be done about it? The chat's title may not fit... [Skotlex]
- // memcpy(WBUFP(buf,6), (struct chat*)->title, NAME_LENGTH);
- // break;
- return 0;
- default:
- if (battle_config.error_log)
- ShowError("clif_parse_GetCharNameRequest : bad type %d(%d)\n", bl->type, bl->id);
- return 0;
- }
- // if no receipient specified just update nearby clients
- if (fd == 0)
- clif_send(buf, packet_len_table[cmd], bl, AREA);
- else {
- WFIFOHEAD(fd, packet_len_table[cmd]);
- memcpy(WFIFOP(fd, 0), buf, packet_len_table[cmd]);
- WFIFOSET(fd, packet_len_table[cmd]);
- }
- return 0;
- }
- //Used to update when a char leaves a party/guild. [Skotlex]
- //Needed because when you send a 0x95 packet, the client will not remove the cached party/guild info that is not sent.
- int clif_charnameupdate (struct map_session_data *ssd)
- {
- unsigned char buf[103];
- int cmd = 0x195;
- struct party_data *p = NULL;
- struct guild *g = NULL;
- nullpo_retr(0, ssd);
- if (strlen(ssd->fakename)>1)
- return 0; //No need to update as the party/guild was not displayed anyway.
- WBUFW(buf,0) = cmd;
- WBUFL(buf,2) = ssd->bl.id;
- memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH);
-
- if (ssd->status.party_id > 0)
- p = party_search(ssd->status.party_id);
- if (ssd->status.guild_id > 0)
- g = guild_search(ssd->status.guild_id);
- if (p)
- memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH);
- else
- WBUFB(buf,30) = 0;
-
- if (g)
- {
- int i, ps = -1;
- for(i = 0; i < g->max_member; i++) {
- if (g->member[i].account_id == ssd->status.account_id &&
- g->member[i].char_id == ssd->status.char_id )
- {
- ps = g->member[i].position;
- break;
- }
- }
- if (ps >= 0 && ps < MAX_GUILDPOSITION)
- {
- memcpy(WBUFP(buf,54), g->name,NAME_LENGTH);
- memcpy(WBUFP(buf,78), g->position[ps].name, NAME_LENGTH);
- } else { //Assume no guild.
- WBUFB(buf,54) = 0;
- WBUFB(buf,78) = 0;
- }
- } else {
- WBUFB(buf,54) = 0;
- WBUFB(buf,78) = 0;
- }
- // Update nearby clients
- clif_send(buf, packet_len_table[cmd], &ssd->bl, AREA);
- return 0;
- }
- int clif_slide(struct block_list *bl, int x, int y){
- unsigned char buf[10];
- nullpo_retr(0, bl);
- WBUFW(buf, 0) = 0x01ff;
- WBUFL(buf, 2) = bl->id;
- WBUFW(buf, 6) = x;
- WBUFW(buf, 8) = y;
- clif_send(buf, packet_len_table[0x1ff], bl, AREA);
- return 0;
- }
- /*------------------------------------------
- * @me command by lordalfa, rewritten implementation by Skotlex
- *------------------------------------------
- */
- int clif_disp_overhead(struct map_session_data *sd, char* mes)
- {
- unsigned char buf[256]; //This should be more than sufficient, the theorical max is MESSAGE_SIZE+NAME_LENGTH + 8 (pads and extra inserted crap)
- int len_mes = strlen(mes)+1; //Account for \0
- if (len_mes + 8 >= 256) {
- if (battle_config.error_log)
- ShowError("clif_disp_overhead: Message too long (length %d)\n", len_mes);
- len_mes = 247; //Trunk it to avoid problems.
- }
- // send message to others
- WBUFW(buf,0) = 0x8d;
- WBUFW(buf,2) = len_mes + 8; // len of message + 8 (command+len+id)
- WBUFL(buf,4) = sd->bl.id;
- memcpy(WBUFP(buf,8), mes, len_mes);
- clif_send(buf, WBUFW(buf,2), &sd->bl, AREA_CHAT_WOC);
- // send back message to the speaker
- WBUFW(buf,0) = 0x8e;
- WBUFW(buf, 2) = len_mes + 4;
- memcpy(WBUFP(buf,4), mes, len_mes);
- clif_send(buf, WBUFW(buf,2), &sd->bl, SELF);
- return 0;
- }
- /*==========================
- * Minimap fix [Kevin]
- * Remove dot from minimap
- *--------------------------
- */
- int clif_party_xy_remove(struct map_session_data *sd)
- {
- unsigned char buf[16];
- nullpo_retr(0, sd);
- WBUFW(buf,0)=0x107;
- WBUFL(buf,2)=sd->status.account_id;
- WBUFW(buf,6)=-1;
- WBUFW(buf,8)=-1;
- clif_send(buf,packet_len_table[0x107],&sd->bl,PARTY_SAMEMAP_WOS);
- return 0;
- }
- /*==========================================
- * Info about Star Glaldiator save map [Komurka]
- * type: 1: Information, 0: Map registered
- *------------------------------------------
- */
- void clif_feel_info(struct map_session_data *sd, unsigned char feel_level, unsigned char type)
- {
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x20e]);
- WFIFOW(fd,0)=0x20e;
- memcpy(WFIFOP(fd,2),mapindex_id2name(sd->feel_map[feel_level].index), MAP_NAME_LENGTH);
- WFIFOL(fd,26)=sd->bl.id;
- WFIFOB(fd,30)=feel_level;
- WFIFOB(fd,31)=type?1:0;
- WFIFOSET(fd, packet_len_table[0x20e]);
- }
- /*==========================================
- * Info about Star Glaldiator hate mob [Komurka]
- * type: 1: Register mob, 0: Information.
- *------------------------------------------
- */
- void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int class_, unsigned char type)
- {
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x20e]);
- WFIFOW(fd,0)=0x20e;
- if (pcdb_checkid(class_))
- strncpy(WFIFOP(fd,2),job_name(class_), NAME_LENGTH);
- else if (mobdb_checkid(class_))
- strncpy(WFIFOP(fd,2),mob_db(class_)->jname, NAME_LENGTH);
- else //Really shouldn't happen...
- malloc_tsetdword(WFIFOP(fd,2), 0, NAME_LENGTH);
- WFIFOL(fd,26)=sd->bl.id;
- WFIFOB(fd,30)=hate_level;
- WFIFOB(fd,31)=type?10:11; //Register/Info
- WFIFOSET(fd, packet_len_table[0x20e]);
- }
- /*==========================================
- * Info about TaeKwon Do TK_MISSION mob [Skotlex]
- *------------------------------------------
- */
- void clif_mission_info(struct map_session_data *sd, int mob_id, unsigned char progress)
- {
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x20e]);
- WFIFOW(fd,0)=0x20e;
- strncpy(WFIFOP(fd,2),mob_db(mob_id)->jname, NAME_LENGTH);
- WFIFOL(fd,26)=mob_id;
- WFIFOB(fd,30)=progress; //Message to display
- WFIFOB(fd,31)=20;
- WFIFOSET(fd, packet_len_table[0x20e]);
- }
- /*==========================================
- * Feel/Hate reset (thanks to Rayce) [Skotlex]
- *------------------------------------------
- */
- void clif_feel_hate_reset(struct map_session_data *sd)
- {
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x20e]);
- WFIFOW(fd,0)=0x20e;
- malloc_tsetdword(WFIFOP(fd,2), 0, NAME_LENGTH); //Blank name as all was reset.
- WFIFOL(fd,26)=sd->bl.id;
- WFIFOB(fd,30)=0; //Feel/hate level: irrelevant
- WFIFOB(fd,31)=30;
- WFIFOSET(fd, packet_len_table[0x20e]);
- }
- // ---------------------
- // clif_guess_PacketVer
- // ---------------------
- // Parses a WantToConnection packet to try to identify which is the packet version used. [Skotlex]
- static int clif_guess_PacketVer(int fd, int get_previous)
- {
- static int packet_ver = -1;
- int cmd, packet_len, value; //Value is used to temporarily store account/char_id/sex
- RFIFOHEAD(fd);
-
- if (get_previous) //For quick reruns, since the normal code flow is to fetch this once to identify the packet version, then again in the wanttoconnect function. [Skotlex]
- return packet_ver;
- //By default, start searching on the default one.
- packet_ver = clif_config.packet_db_ver;
- cmd = RFIFOW(fd,0);
- packet_len = RFIFOREST(fd);
-
- if (
- cmd == clif_config.connect_cmd[packet_ver] &&
- packet_len == packet_db[packet_ver][cmd].len &&
- ((value = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4])) == 0 || value == 1) &&
- (value = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0])) > 700000 && //Account ID is valid
- value <= max_account_id &&
- (value = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1])) > 0 && //Char ID is valid
- value <= max_char_id &&
- (int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]) > 0 //Login 1 is a positive value (?)
- )
- return clif_config.packet_db_ver; //Default packet version found.
-
- for (packet_ver = MAX_PACKET_VER; packet_ver > 0; packet_ver--)
- { //Start guessing the version, giving priority to the newer ones. [Skotlex]
- if (cmd != clif_config.connect_cmd[packet_ver] || //it is not a wanttoconnection for this version.
- packet_len != packet_db[packet_ver][cmd].len) //The size of the wantoconnection packet does not matches.
- continue;
-
- if (
- (value = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0])) < 700000 || value > max_account_id
- || (value = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1])) < 1 || value > max_char_id
- //What is login 1? In my tests it is a very very high value.
- || (int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]) < 1
- //This check seems redundant, all wanttoconnection packets have the gender on the very
- //last byte of the packet.
- || (value = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4])) < 0 || value > 1
- )
- continue;
-
- return packet_ver; //This is our best guess.
- }
- packet_ver = -1;
- return -1;
- }
- // ------------
- // clif_parse_*
- // ------------
- // パケット読み取って色々操作
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
- {
- struct map_session_data *old_sd;
- int cmd, account_id, char_id, login_id1, sex;
- unsigned int client_tick; //The client tick is a tick, therefore it needs be unsigned. [Skotlex]
- int packet_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
- RFIFOHEAD(fd);
- if (sd) {
- if (battle_config.error_log)
- ShowError("clif_parse_WantToConnection : invalid request (character already logged in)?\n");
- return;
- }
- packet_ver = clif_guess_PacketVer(fd, 1);
- cmd = RFIFOW(fd,0);
-
- if (packet_ver > 0)
- {
- account_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0]);
- char_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1]);
- login_id1 = RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]);
- client_tick = RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]);
- sex = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4]);
-
- if ((old_sd = map_id2sd(account_id)) != NULL)
- { // if same account already connected, we disconnect the 2 sessions
- //Check for characters with no connection (includes those that are using autotrade) [durf],[Skotlex]
- if (old_sd->state.finalsave)
- ; //Ack has not arrived yet from char-server, be patient!
- else if (old_sd->fd)
- clif_authfail_fd(old_sd->fd, 2); // same id
- else
- map_quit(old_sd);
- clif_authfail_fd(fd, 8); // still recognizes last connection
- } else {
- sd = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data));
- sd->fd = fd;
- sd->packet_ver = packet_ver;
- session[fd]->session_data = sd;
- pc_setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd);
- WFIFOHEAD(fd,4);
- WFIFOL(fd,0) = sd->bl.id;
- WFIFOSET(fd,4);
- chrif_authreq(sd);
- }
- }
- return;
- }
- static int clif_nighttimer(int tid, unsigned int tick, int id, int data)
- {
- TBL_PC *sd;
- sd=map_id2sd(id);
- if (!sd) return 0;
- //Check if character didn't instant-warped after logging in.
- if (sd->bl.prev!=NULL) {
- sd->state.night = 1;
- clif_status_load(&sd->bl, SI_NIGHT, 1);
- }
- return 0;
- }
- /*==========================================
- * 007d クライアント側マップ読み込み完了
- * map侵入時に必要なデータを全て送りつける
- *------------------------------------------
- */
- void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
- {
- int i;
-
- if(sd->bl.prev != NULL)
- return;
-
- if (sd->state.rewarp)
- { //Rewarp player.
- sd->state.rewarp = 0;
- clif_changemap(sd,sd->mapindex,sd->bl.x,sd->bl.y);
- return;
- }
- if(sd->npc_id) npc_event_dequeue(sd);
- if(sd->state.connect_new) {
- if (sd->sc.option&OPTION_FALCON)
- clif_status_load(&sd->bl, SI_FALCON, 1);
- if (sd->sc.option&OPTION_RIDING)
- clif_status_load(&sd->bl, SI_RIDING, 1);
- //Auron reported that This skill only triggers when you logon on the map o.O [Skotlex]
- if ((i = pc_checkskill(sd,SG_KNOWLEDGE)) > 0) {
- if(sd->bl.m == sd->feel_map[0].m
- || sd->bl.m == sd->feel_map[1].m
- || sd->bl.m == sd->feel_map[2].m)
- sc_start(&sd->bl, SC_KNOWLEDGE, 100, i, skill_get_time(SG_KNOWLEDGE, i));
- }
- clif_skillinfoblock(sd);
- clif_updatestatus(sd,SP_NEXTBASEEXP);
- clif_updatestatus(sd,SP_NEXTJOBEXP);
- clif_updatestatus(sd,SP_SKILLPOINT);
- clif_initialstatus(sd);
- //Removed, for some reason chars get stuck on map-change when you send this packet!? [Skotlex]
- //[LuzZza]
- //clif_guild_send_onlineinfo(sd);
- } else {
- //For some reason the client "loses" these on map-change.
- clif_updatestatus(sd,SP_STR);
- clif_updatestatus(sd,SP_AGI);
- clif_updatestatus(sd,SP_VIT);
- clif_updatestatus(sd,SP_INT);
- clif_updatestatus(sd,SP_DEX);
- clif_updatestatus(sd,SP_LUK);
- }
- // item
- pc_checkitem(sd);
- clif_inventorylist(sd);
-
- // cart
- if(pc_iscarton(sd)){
- clif_cartlist(sd);
- clif_updatestatus(sd,SP_CARTINFO);
- }
- // weight max , now
- clif_updatestatus(sd,SP_MAXWEIGHT);
- clif_updatestatus(sd,SP_WEIGHT);
- if(battle_config.pc_invincible_time > 0) {
- if(map_flag_gvg(sd->bl.m))
- pc_setinvincibletimer(sd,battle_config.pc_invincible_time<<1);
- else
- pc_setinvincibletimer(sd,battle_config.pc_invincible_time);
- }
- map_addblock(&sd->bl); // ブロック登録
- clif_spawn(&sd->bl); // spawn
- // party
- party_send_movemap(sd);
- // guild
- guild_send_memberinfoshort(sd,1);
- // Show hp after displacement [LuzZza]
- if(sd->status.party_id)
- clif_party_hp(sd);
- sd->state.using_fake_npc = 0;
- // pvp
- //if(sd->pvp_timer!=-1 && !battle_config.pk_mode) /PVP Client crash fix* Removed timer deletion
- // delete_timer(sd->pvp_timer,pc_calc_pvprank_timer);
- if(map[sd->bl.m].flag.pvp){
- if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris]
- if (sd->pvp_timer == -1)
- sd->pvp_timer=add_timer(gettick()+200,pc_calc_pvprank_timer,sd->bl.id,0);
- sd->pvp_rank=0;
- sd->pvp_lastusers=0;
- sd->pvp_point=5;
- sd->pvp_won=0;
- sd->pvp_lost=0;
- }
- clif_set0199(fd,1);
- } else {
- sd->pvp_timer=-1;
- // set flag, if it's a duel [LuzZza]
- if(sd->duel_group)
- clif_set0199(fd, 1);
- }
- if(map_flag_gvg(sd->bl.m))
- clif_set0199(fd,3);
- // pet
- if(sd->status.pet_id > 0 && sd->pd) {
- map_addblock(&sd->pd->bl);
- clif_spawn(&sd->pd->bl);
- clif_send_petdata(sd,0,0);
- clif_send_petdata(sd,5,battle_config.pet_hair_style);
- clif_send_petstatus(sd);
- if(sd->state.connect_new && sd->pd->pet.intimate > 900)
- clif_pet_emotion(sd->pd,(sd->pd->pet.class_ - 100)*100 + 50 + pet_hungry_val(sd->pd));
- }
- //homunculus [blackhole89]
- if(merc_is_hom_active(sd->hd)) {
- map_addblock(&sd->hd->bl);
- clif_spawn(&sd->hd->bl);
- clif_hominfo(sd,sd->hd,1);
- clif_hominfo(sd,sd->hd,0); //for some reason, at least older clients want this sent twice
- clif_send_homdata(sd,0,0);
- clif_homskillinfoblock(sd);
- //Homunc mimic their master's speed on each map change. [Skotlex]
- if (battle_config.slaves_inherit_speed)
- status_calc_bl(&sd->hd->bl, SCB_SPEED);
- }
- // view equipment item
- #if PACKETVER < 4
- clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
- clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
- #else
- clif_changelook(&sd->bl,LOOK_WEAPON,0);
- #endif
- if(sd->vd.cloth_color)
- clif_refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF);
- if(sd->status.manner < 0)
- sc_start(&sd->bl,SC_NOCHAT,100,0,0);
- if(sd->state.connect_new) {
- sd->state.connect_new = 0;
- //Delayed night effect on log-on fix for the glow-issue. Thanks to Larry.
- if (night_flag) {
- char tmpstr[1024];
- strcpy(tmpstr, msg_txt(500)); // Actually, it's the night...
- clif_wis_message(sd->fd, wisp_server_name, tmpstr, strlen(tmpstr)+1);
-
- if (map[sd->bl.m].flag.nightenabled)
- add_timer(gettick()+1000,clif_nighttimer,sd->bl.id,0);
- }
- //On Login Script.
- npc_script_event(sd, NPCE_LOGIN);
- } else
- //New 'night' effect by dynamix [Skotlex]
- if (night_flag && map[sd->bl.m].flag.nightenabled)
- { //Display night.
- if (sd->state.night) //It must be resent because otherwise players get this annoying aura...
- clif_status_load(&sd->bl, SI_NIGHT, 0);
- else
- sd->state.night = 1;
- clif_status_load(&sd->bl, SI_NIGHT, 1);
- } else if (sd->state.night) { //Clear night display.
- sd->state.night = 0;
- clif_status_load(&sd->bl, SI_NIGHT, 0);
- }
- // Lance
- if(sd->state.event_loadmap && map[sd->bl.m].flag.loadevent){
- pc_setregstr(sd, add_str("@maploaded$"), map[sd->bl.m].name);
- npc_script_event(sd, NPCE_LOADMAP);
- }
- if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd))
- clif_status_load(&sd->bl, SI_DEVIL, 1); //blindness [Komurka]
- clif_weather_check(sd);
-
- map_foreachinarea(clif_getareachar,sd->bl.m,
- sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,sd->bl.x+AREA_SIZE,sd->bl.y+AREA_SIZE,
- BL_ALL,sd);
-
- // For automatic triggering of NPCs after map loading (so you don't need to walk 1 step first)
- if (map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC))
- npc_touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y);
- else
- sd->areanpc_id = 0;
- // If player is dead, and is spawned (such as @refresh) send death packet. [Valaris]
- if(pc_isdead(sd))
- clif_clearchar_area(&sd->bl,1);
- // Uncomment if you want to make player face in the same direction he was facing right before warping. [Skotlex]
- // else
- // clif_changed_dir(&sd->bl, SELF);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_TickSend(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- sd->client_tick=RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- WFIFOHEAD(fd, packet_len_table[0x7f]);
- WFIFOW(fd,0)=0x7f;
- WFIFOL(fd,2)=gettick();
- WFIFOSET(fd,packet_len_table[0x7f]);
- return;
- }
- static int clif_walktoxy_timer(int tid, unsigned int tick, int id, int data)
- {
- struct map_session_data *sd;
- short x,y;
- if (!session[id] || (sd = session[id]->session_data) == NULL)
- return 0;
-
- if (!unit_can_move(&sd->bl))
- return 0;
- x = data>>16;
- y = data&0xffff;
- unit_walktoxy(&sd->bl, x, y, 0);
- return 1;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_WalkToXY(int fd, struct map_session_data *sd) {
- int x, y;
- int cmd;
- unsigned int tick;
- RFIFOHEAD(fd);
- if (pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl, 1);
- return;
- }
- if (clif_cant_act(sd) && sd->sc.opt1 != OPT1_STONEWAIT)
- return;
- if(sd->sc.count && sd->sc.data[SC_RUN].timer != -1)
- return;
- pc_stop_attack(sd);
- if (sd->invincible_timer != -1)
- pc_delinvincibletimer(sd);
- cmd = RFIFOW(fd,0);
- x = RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]) * 4 +
- (RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0] + 1) >> 6);
- y = ((RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]+1) & 0x3f) << 4) +
- (RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0] + 2) >> 4);
- //Set last idle time... [Skotlex]
- sd->idletime = last_tick;
-
- tick = gettick();
- if (DIFF_TICK(sd->ud.canmove_tick, tick) > 0 &&
- DIFF_TICK(sd->ud.canmove_tick, tick) < 2000)
- { // Delay walking command. [Skotlex]
- add_timer(sd->ud.canmove_tick+1, clif_walktoxy_timer, fd, (x<<16)|y);
- return;
- }
- if (!unit_can_move(&sd->bl))
- return;
- unit_walktoxy(&sd->bl, x, y, 0);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_QuitGame(int fd, struct map_session_data *sd) {
- WFIFOHEAD(fd,packet_len_table[0x18b]);
- WFIFOW(fd,0) = 0x18b;
- /* Rovert's prevent logout option fixed [Valaris] */
- if (sd->sc.data[SC_CLOAKING].timer==-1 && sd->sc.data[SC_HIDING].timer==-1 &&
- (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
- ) {
- clif_setwaitclose(fd);
- WFIFOW(fd,2)=0;
- } else {
- WFIFOW(fd,2)=1;
- }
- WFIFOSET(fd,packet_len_table[0x18b]);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void check_fake_id(int fd, struct map_session_data *sd, int target_id) {
- // if player asks for the fake player (only bot and modified client can see a hiden player)
- /* if (target_id == server_char_id) {
- char message_to_gm[strlen(msg_txt(536)) + strlen(msg_txt(540)) + strlen(msg_txt(507)) + strlen(msg_txt(508))];
- sprintf(message_to_gm, msg_txt(536), sd->status.name, sd->status.account_id); // Character '%s' (account: %d) try to use a bot (it tries to detect a fake player).
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
- // if we block people
- if (battle_config.ban_bot < 0) {
- chrif_char_ask_name(-1, sd->status.name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
- clif_setwaitclose(sd->fd); // forced to disconnect because of the hack
- // message about the ban
- sprintf(message_to_gm, msg_txt(540)); // This player has been definitivly blocked.
- // if we ban people
- } else if (battle_config.ban_bot > 0) {
- chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_bot, 0); // type: 2 - ban (year, month, day, hour, minute, second)
- clif_setwaitclose(sd->fd); // forced to disconnect because of the hack
- // message about the ban
- sprintf(message_to_gm, msg_txt(507), battle_config.ban_bot); // This player has been banned for %d minute(s).
- } else { // impossible to display: we don't send fake player if battle_config.ban_bot is == 0
- // message about the ban
- sprintf(message_to_gm, msg_txt(508)); // This player hasn't been banned (Ban option is disabled).
- }
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
- // send this info cause the bot ask until get an answer, damn spam
- malloc_tsetdword(WPACKETP(0), 0, packet_len_table[0x95]);
- WPACKETW(0) = 0x95;
- WPACKETL(2) = server_char_id;
- strncpy(WPACKETP(6), sd->status.name, 24);
- SENDPACKET(fd, packet_len_table[0x95]);
- // take fake player out of screen
- WPACKETW(0) = 0x80;
- WPACKETL(2) = server_char_id;
- WPACKETB(6) = 0;
- SENDPACKET(fd, packet_len_table[0x80]);
- // take fake mob out of screen
- WPACKETW(0) = 0x80;
- WPACKETL(2) = server_fake_mob_id;
- WPACKETB(6) = 0;
- SENDPACKET(fd, packet_len_table[0x80]);
- }
- // if player asks for the fake mob (only bot and modified client can see a hiden mob)
- if (target_id == server_fake_mob_id) {
- int fake_mob;
- char message_to_gm[strlen(msg_txt(537)) + strlen(msg_txt(540)) + strlen(msg_txt(507)) + strlen(msg_txt(508))];
- sprintf(message_to_gm, msg_txt(537), sd->status.name, sd->status.account_id); // Character '%s' (account: %d) try to use a bot (it tries to detect a fake mob).
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
- // if we block people
- if (battle_config.ban_bot < 0) {
- chrif_char_ask_name(-1, sd->status.name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
- clif_setwaitclose(sd->fd); // forced to disconnect because of the hack
- // message about the ban
- sprintf(message_to_gm, msg_txt(540)); // This player has been definitivly blocked.
- // if we ban people
- } else if (battle_config.ban_bot > 0) {
- chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_bot, 0); // type: 2 - ban (year, month, day, hour, minute, second)
- clif_setwaitclose(sd->fd); // forced to disconnect because of the hack
- // message about the ban
- sprintf(message_to_gm, msg_txt(507), battle_config.ban_bot); // This player has been banned for %d minute(s).
- } else { // impossible to display: we don't send fake player if battle_config.ban_bot is == 0
- // message about the ban
- sprintf(message_to_gm, msg_txt(508)); // This player hasn't been banned (Ban option is disabled).
- }
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
- // send this info cause the bot ask until get an answer, damn spam
- malloc_tsetdword(WPACKETP(0), 0, packet_len_table[0x95]);
- WPACKETW(0) = 0x95;
- WPACKETL(2) = server_fake_mob_id;
- fake_mob = fake_mob_list[(sd->bl.m + sd->fd + sd->status.char_id) % (sizeof(fake_mob_list) / sizeof(fake_mob_list[0]))]; // never same mob
- if (!mobdb_checkid(fake_mob))
- fake_mob = 1002; // poring (default)
- strncpy(WPACKETP(6), mob_db[fake_mob].name, 24);
- SENDPACKET(fd, packet_len_table[0x95]);
- // take fake mob out of screen
- WPACKETW(0) = 0x80;
- WPACKETL(2) = server_fake_mob_id;
- WPACKETB(6) = 0;
- SENDPACKET(fd, packet_len_table[0x80]);
- // take fake player out of screen
- WPACKETW(0) = 0x80;
- WPACKETL(2) = server_char_id;
- WPACKETB(6) = 0;
- SENDPACKET(fd, packet_len_table[0x80]);
- }
- */
- return;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) {
- int account_id;
- struct block_list* bl;
- struct status_change *sc;
- RFIFOHEAD(fd);
-
- account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- if(account_id<0 && -account_id == sd->bl.id) // for disguises [Valaris]
- account_id= sd->bl.id;
- bl = map_id2bl(account_id);
- //Is this possible? Lagged clients could request names of already gone mobs/players. [Skotlex]
- if (!bl) return;
- sc = status_get_sc(bl);
- if (sc && sc->option&OPTION_INVISIBLE && !disguised(bl) && pc_isGM(sd) < battle_config.hack_info_GM_level)
- {
- //GM characters (with client side GM enabled are able to see invisible stuff) [Lance]
- //Asked name of invisible player, this shouldn't be possible!
- //Possible bot? Thanks to veider and qspirit
- //FIXME: Still isn't perfected as clients keep asking for this on legitimate situations.
- unsigned char gm_msg[256];
- sprintf(gm_msg, "Hack on NameRequest: character '%s' (account: %d) requests name of invisible chars.", sd->status.name, sd->status.account_id);
- ShowWarning(gm_msg);
- // information is sended to all online GM
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, gm_msg);
- return;
- }
- clif_charnameack(fd, bl);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c <len>.w <str>.?B
- char *message, *buf, buf2[128];
- RFIFOHEAD(fd);
- WFIFOHEAD(fd, RFIFOW(fd,2) + 4);
- message = (unsigned char*)RFIFOP(fd,4);
- if (strlen(message) < strlen(sd->status.name) || //If the incoming string is too short...
- strncmp(message, sd->status.name, strlen(sd->status.name)) != 0) //Or the name does not matches...
- {
- //Hacked message, or infamous "client desynch" issue where they pick
- //one char while loading another. Just kick them out to correct it.
- clif_setwaitclose(fd);
- return;
- }
-
- if ((is_atcommand(fd, sd, message, 0) != AtCommand_None) ||
- (is_charcommand(fd, sd, message,0) != CharCommand_None))
- return;
- if (sd->sc.count &&
- (sd->sc.data[SC_BERSERK].timer != -1 ||
- (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
- return;
- if (battle_config.min_chat_delay)
- { //[Skotlex]
- if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
- return;
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
- }
- if (RFIFOW(fd,2)+4 < 128)
- buf = buf2; //Use a static buffer.
- else
- buf = (unsigned char*)aMallocA((RFIFOW(fd,2) + 4)*sizeof(char));
- // send message to others
- WBUFW(buf,0) = 0x8d;
- WBUFW(buf,2) = RFIFOW(fd,2) + 4; // len of message - 4 + 8
- WBUFL(buf,4) = sd->bl.id;
- memcpy(WBUFP(buf,8), message, RFIFOW(fd,2) - 4);
- clif_send(buf, WBUFW(buf,2), &sd->bl, sd->chatID ? CHAT_WOS : AREA_CHAT_WOC);
- if(buf != buf2) aFree(buf);
- // send back message to the speaker
- memcpy(WFIFOP(fd,0), RFIFOP(fd,0), RFIFOW(fd,2));
- WFIFOW(fd,0) = 0x8e;
- WFIFOSET(fd, WFIFOW(fd,2));
- #ifdef PCRE_SUPPORT
- map_foreachinrange(npc_chat_sub, &sd->bl, AREA_SIZE, BL_NPC, message, strlen(message), &sd->bl);
- map_foreachinrange(mob_chat_sub, &sd->bl, AREA_SIZE, BL_MOB, message, strlen(message), &sd->bl);
- #endif
- // Celest
- if ((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE) { //Super Novice.
- int next = pc_nextbaseexp(sd);
- if (next > 0 && (sd->status.base_exp * 1000 / next)% 100 == 0) {
- switch (sd->state.snovice_flag) {
- case 0:
- if (strstr(message, msg_txt(504)))
- sd->state.snovice_flag++;
- break;
- case 1:
- sprintf(buf2, msg_txt(505), sd->status.name);
- if (strstr(message, buf2))
- sd->state.snovice_flag++;
- break;
- case 2:
- if (strstr(message, msg_txt(506)))
- sd->state.snovice_flag++;
- break;
- case 3:
- if (skillnotok(MO_EXPLOSIONSPIRITS,sd))
- break; //Do not override the noskill mapflag. [Skotlex]
- clif_skill_nodamage(&sd->bl,&sd->bl,MO_EXPLOSIONSPIRITS,-1,
- sc_start(&sd->bl,SkillStatusChangeTable(MO_EXPLOSIONSPIRITS),100,
- 17,skill_get_time(MO_EXPLOSIONSPIRITS,1))); //Lv17-> +50 critical (noted by Poki) [Skotlex]
- sd->state.snovice_flag = 0;
- break;
- }
- }
- }
- return;
- }
- int clif_message(struct block_list *bl, char* msg)
- {
- unsigned short msg_len = strlen(msg) + 1;
- unsigned char buf[256];
- nullpo_retr(0, bl);
- WBUFW(buf, 0) = 0x8d;
- WBUFW(buf, 2) = msg_len + 8;
- WBUFL(buf, 4) = bl->id;
- memcpy(WBUFP(buf, 8), msg, msg_len);
- clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC); // by Gengar
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_MapMove(int fd, struct map_session_data *sd) {
- // /m /mapmove (as @rura GM command)
- char output[30]; // 17+4+4=26, 30 max.
- char map_name[MAP_NAME_LENGTH]; //Err... map names are 15+'\0' in size, not 16+'\0' [Skotlex]
- RFIFOHEAD(fd);
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_MapMove))) {
- memcpy(map_name, RFIFOP(fd,2), MAP_NAME_LENGTH-1);
- map_name[MAP_NAME_LENGTH-1]='\0';
- sprintf(output, "%s %d %d", map_name, RFIFOW(fd,18), RFIFOW(fd,20));
- atcommand_rura(fd, sd, "@rura", output);
- }
- return;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_changed_dir(struct block_list *bl, int type) {
- unsigned char buf[64];
- WBUFW(buf,0) = 0x9c;
- WBUFL(buf,2) = bl->id;
- WBUFW(buf,6) = bl->type==BL_PC?((TBL_PC*)bl)->head_dir:0;
- WBUFB(buf,8) = unit_getdir(bl);
- clif_send(buf, packet_len_table[0x9c], bl, type);
- if (disguised(bl)) {
- WBUFL(buf,2) = -bl->id;
- WBUFW(buf,6) = 0;
- clif_send(buf, packet_len_table[0x9c], bl, SELF);
- }
- return;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_ChangeDir(int fd, struct map_session_data *sd) {
- unsigned char headdir, dir;
- RFIFOHEAD(fd);
- headdir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- dir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
- pc_setdir(sd, dir, headdir);
- clif_changed_dir(&sd->bl, AREA_WOS);
- return;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_Emotion(int fd, struct map_session_data *sd) {
- unsigned char buf[64];
- RFIFOHEAD(fd);
- if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, NV_BASIC) >= 2) {
- if (RFIFOB(fd,2) == 34) {// prevent use of the mute emote [Valaris]
- clif_skill_fail(sd, 1, 0, 1);
- return;
- }
- // fix flood of emotion icon (ro-proxy): flood only the hacker player
- if (sd->emotionlasttime >= time(NULL)) {
- sd->emotionlasttime = time(NULL) + 1; // not more than 1 per second (using /commands the client can spam it)
- clif_skill_fail(sd, 1, 0, 1);
- return;
- }
- sd->emotionlasttime = time(NULL) + 1; // not more than 1 per second (using /commands the client can spam it)
-
- WBUFW(buf,0) = 0xc0;
- WBUFL(buf,2) = sd->bl.id;
- WBUFB(buf,6) = RFIFOB(fd,2);
- clif_send(buf, packet_len_table[0xc0], &sd->bl, AREA);
- } else
- clif_skill_fail(sd, 1, 0, 1);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) {
- WFIFOHEAD(fd,packet_len_table[0xc2]);
- WFIFOW(fd,0) = 0xc2;
- WFIFOL(fd,2) = map_getusers();
- WFIFOSET(fd,packet_len_table[0xc2]);
- }
- void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, unsigned int tick)
- {
- unsigned char buf[64];
- if (pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl, 1);
- return;
- }
- if (sd->sc.count &&
- (sd->sc.data[SC_TRICKDEAD].timer != -1 ||
- sd->sc.data[SC_AUTOCOUNTER].timer != -1 ||
- sd->sc.data[SC_BLADESTOP].timer != -1))
- return;
- pc_stop_walking(sd, 1);
- pc_stop_attack(sd);
- if(target_id<0 && -target_id == sd->bl.id) // for disguises [Valaris]
- target_id = sd->bl.id;
-
- switch(action_type) {
- case 0x00: // once attack
- case 0x07: // continuous attack
- if (clif_cant_act(sd) || sd->sc.option&OPTION_HIDE)
- return;
- if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
- return;
- if (!battle_config.sdelay_attack_enable && pc_checkskill(sd, SA_FREECAST) <= 0) {
- if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) {
- clif_skill_fail(sd, 1, 4, 0);
- return;
- }
- }
- if (sd->invincible_timer != -1)
- pc_delinvincibletimer(sd);
- sd->idletime = last_tick;
- unit_attack(&sd->bl, target_id, action_type != 0);
- break;
- case 0x02: // sitdown
- if (battle_config.basic_skill_check && pc_checkskill(sd, NV_BASIC) < 3) {
- clif_skill_fail(sd, 1, 0, 2);
- break;
- }
- if(pc_issit(sd)) {
- //Bugged client? Just refresh them.
- WBUFW(buf, 0) = 0x8a;
- WBUFL(buf, 2) = sd->bl.id;
- WBUFB(buf,26) = 2;
- clif_send(buf, packet_len_table[0x8a], &sd->bl, SELF);
- return;
- }
- if (sd->ud.skilltimer != -1 || sd->sc.opt1)
- break;
- if (sd->sc.count && (
- sd->sc.data[SC_DANCING].timer != -1 ||
- (sd->sc.data[SC_GRAVITATION].timer != -1 && sd->sc.data[SC_GRAVITATION].val3 == BCT_SELF)
- )) //No sitting during these states neither.
- break;
- pc_setsit(sd);
- skill_sit(sd, 1);
- clif_sitting(sd);
- break;
- case 0x03: // standup
- if (!pc_issit(sd)) {
- //Bugged client? Just refresh them.
- WBUFW(buf, 0) = 0x8a;
- WBUFL(buf, 2) = sd->bl.id;
- WBUFB(buf,26) = 3;
- clif_send(buf, packet_len_table[0x8a], &sd->bl, SELF);
- return;
- }
- pc_setstand(sd);
- skill_sit(sd, 0);
- WBUFW(buf, 0) = 0x8a;
- WBUFL(buf, 2) = sd->bl.id;
- WBUFB(buf,26) = 3;
- clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
- break;
- }
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_ActionRequest(int fd, struct map_session_data *sd) {
- clif_parse_ActionRequest_sub(sd,
- RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]),
- RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
- gettick()
- );
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_Restart(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- switch(RFIFOB(fd,2)) {
- case 0x00:
- if (pc_isdead(sd)) {
- pc_setstand(sd);
- pc_setrestartvalue(sd, 3);
- if (sd->sc.count && battle_config.debuff_on_logout&2) {
- //For some reason food buffs are removed when you respawn.
- if(sd->sc.data[SC_STRFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_STRFOOD,-1);
- if(sd->sc.data[SC_AGIFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_AGIFOOD,-1);
- if(sd->sc.data[SC_VITFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_VITFOOD,-1);
- if(sd->sc.data[SC_INTFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_INTFOOD,-1);
- if(sd->sc.data[SC_DEXFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_DEXFOOD,-1);
- if(sd->sc.data[SC_LUKFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_LUKFOOD,-1);
- if(sd->sc.data[SC_HITFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_HITFOOD,-1);
- if(sd->sc.data[SC_FLEEFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_FLEEFOOD,-1);
- if(sd->sc.data[SC_BATKFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_BATKFOOD,-1);
- if(sd->sc.data[SC_WATKFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_WATKFOOD,-1);
- if(sd->sc.data[SC_MATKFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_MATKFOOD,-1);
- }
- pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 2);
- }
- // in case the player's status somehow wasn't updated yet [Celest]
- else if (sd->battle_status.hp <= 0)
- pc_setdead(sd);
- break;
- case 0x01:
- /* Rovert's Prevent logout option - Fixed [Valaris] */
- if (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
- { //Send to char-server for character selection.
- chrif_charselectreq(sd, session[fd]->client_addr.sin_addr.s_addr);
- } else {
- WFIFOHEAD(fd,packet_len_table[0x18b]);
- WFIFOW(fd,0)=0x18b;
- WFIFOW(fd,2)=1;
- WFIFOSET(fd,packet_len_table[0x018b]);
- }
- break;
- }
- }
- /*==========================================
- * Transmission of a wisp (S 0096 <len>.w <nick>.24B <message>.?B)
- *------------------------------------------
- */
- void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 <len>.w <nick>.24B <message>.?B // rewritten by [Yor]
- char *gm_command;
- struct map_session_data *dstsd;
- int i=0;
- struct npc_data *npc;
- char split_data[10][50];
- int j=0,k=0;
- char target[NAME_LENGTH+1];
- char output[256];
- RFIFOHEAD(fd);
- //printf("clif_parse_Wis: message: '%s'.\n", RFIFOP(fd,28));
- gm_command = (char*)aMallocA((strlen((const char*)RFIFOP(fd,28)) + 28)*sizeof(char)); // 24+3+(RFIFOW(fd,2)-28)+1 or 24+3+(strlen(RFIFOP(fd,28))+1 (size can be wrong with hacker)
- sprintf(gm_command, "%s : %s", sd->status.name, RFIFOP(fd,28));
- if ((is_charcommand(fd, sd, gm_command, 0) != CharCommand_None) ||
- (is_atcommand(fd, sd, gm_command, 0) != AtCommand_None)) {
- if(gm_command) aFree(gm_command);
- return;
- }
- if(gm_command) aFree(gm_command);
- if (sd->sc.count &&
- (sd->sc.data[SC_BERSERK].timer!=-1 ||
- (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
- return;
- if (battle_config.min_chat_delay)
- { //[Skotlex]
- if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
- return;
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
- }
- memcpy(&target,RFIFOP(fd, 4),NAME_LENGTH);
- target[NAME_LENGTH]='\0';
-
- //Chat Logging type 'W' / Whisper
- if(log_config.chat&1 //we log everything then
- || ( log_config.chat&2 //if Whisper bit is on
- && ( !agit_flag || !(log_config.chat&16) ))) //if WOE ONLY flag is off or AGIT is OFF
- log_chat("W", 0, sd->status.char_id, sd->status.account_id, (char*)mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, target, (char*)RFIFOP(fd, 28));
- //-------------------------------------------------------//
- // Lordalfa - Paperboy - To whisper NPC commands //
- //-------------------------------------------------------//
- if (target[0] && (strncasecmp(target,"NPC:",4) == 0) && (strlen(target) >4)) {
- char *whisper_tmp = target+4; //Skip the NPC: string part.
- if ((npc = npc_name2id(whisper_tmp)))
- {
- whisper_tmp=(char *)aMallocA((strlen((char *)(RFIFOP(fd,28)))+1)*sizeof(char));
-
- sprintf(whisper_tmp, "%s", (const char*)RFIFOP(fd,28));
- for( j=0;whisper_tmp[j]!='\0';j++)
- {
- if(whisper_tmp[j]!='#')
- {
- split_data[i][j-k]=whisper_tmp[j];
- }
- else
- {
- split_data[i][j-k]='\0';
- k=j+1;
- i++;
- }
- } // Splits the message using '#' as separators
- split_data[i][j-k]='\0';
-
- aFree(whisper_tmp);
- whisper_tmp=(char *)aMallocA(15*sizeof(char));
-
- for (j=0;j<=10;j++)
- {
- sprintf(whisper_tmp, "@whispervar%d$", j);
- set_var(sd,whisper_tmp,(char *) split_data[j]);
- }//You don't need to zero them, just reset them [Kevin]
-
- aFree(whisper_tmp);
- whisper_tmp=(char *)aMallocA((strlen(npc->name)+18)*sizeof(char));
-
- sprintf(whisper_tmp, "%s::OnWhisperGlobal", npc->name);
- npc_event(sd,whisper_tmp,0); // Calls the NPC label
- aFree(whisper_tmp); //I rewrote it a little to use memory allocation, a bit more stable =P [Kevin]
- return;
- } //should have just removed the one below that was a my bad =P
- }
-
- // Main chat [LuzZza]
- if(strcmpi(target, main_chat_nick) == 0) {
- if(!sd->state.mainchat) {
- clif_displaymessage(fd, msg_txt(388)); // You should enable main chat with "@main on" command.
- return;
- }
- sprintf(output, msg_txt(386), sd->status.name, (char *)RFIFOP(fd,28));
- intif_announce(output, strlen(output) + 1, 0xFE000000, 0);
- return;
- }
- // searching destination character
- dstsd = map_nick2sd(target);
- // player is not on this map-server
- if (dstsd == NULL ||
- // At this point, don't send wisp/page if it's not exactly the same name, because (example)
- // if there are 'Test' player on an other map-server and 'test' player on this map-server,
- // and if we ask for 'Test', we must not contact 'test' player
- // so, we send information to inter-server, which is the only one which decide (and copy correct name).
- strcmp(dstsd->status.name, target) != 0) // not exactly same name
- // send message to inter-server
- intif_wis_message(sd, target, (char*)RFIFOP(fd,28), RFIFOW(fd,2)-28);
- // player is on this map-server
- else {
- // if you send to your self, don't send anything to others
- if (dstsd->fd == fd) // but, normaly, it's impossible!
- clif_wis_message(fd, wisp_server_name, "You can not page yourself. Sorry.", strlen("You can not page yourself. Sorry.") + 1);
- // otherwise, send message and answer immediatly
- else {
- if (dstsd->ignoreAll == 1) {
- if (dstsd->sc.option & OPTION_INVISIBLE && pc_isGM(sd) < pc_isGM(dstsd))
- clif_wis_end(fd, 1); // 1: target character is not loged in
- else
- clif_wis_end(fd, 3); // 3: everyone ignored by target
- } else {
- // if player ignore the source character
- for(i = 0; i < MAX_IGNORE_LIST; i++)
- if (strcmp(dstsd->ignore[i].name, sd->status.name) == 0) {
- clif_wis_end(fd, 2); // 2: ignored by target
- break;
- }
- // if source player not found in ignore list
- if (i == MAX_IGNORE_LIST) {
- if(strlen(dstsd->away_message) > 0) { // Send away automessage [LuzZza]
- //(Automessage has been sent)
- sprintf(output, "%s %s", (char*)RFIFOP(fd,28),msg_txt(543));
- clif_wis_message(dstsd->fd, sd->status.name, output, strlen(output) + 1);
- clif_wis_end(fd, 0); // 0: success to send wisper
- if(dstsd->state.autotrade)
- //"Away [AT] - \"%s\""
- sprintf(output, msg_txt(544), dstsd->away_message);
- else
- //"Away - \"%s\""
- sprintf(output, msg_txt(545), dstsd->away_message);
- clif_wis_message(fd, dstsd->status.name, output, strlen(output) + 1);
- } else { // Normal message
- clif_wis_message(dstsd->fd, sd->status.name, (char*)RFIFOP(fd,28), RFIFOW(fd,2) - 28);
- clif_wis_end(fd, 0); // 0: success to send wisper
- }
- }
- }
- }
- }
- return;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_GMmessage(int fd, struct map_session_data *sd) {
- // /b
- RFIFOHEAD(fd);
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_Broadcast)))
- intif_GMmessage((char*)RFIFOP(fd,4), RFIFOW(fd,2)-4, 0);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_TakeItem(int fd, struct map_session_data *sd) {
- struct flooritem_data *fitem;
- int map_object_id;
- RFIFOHEAD(fd);
- map_object_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
-
- fitem = (struct flooritem_data*)map_id2bl(map_object_id);
- do {
- if (pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl, 1);
- break;
- }
- if (fitem == NULL || fitem->bl.type != BL_ITEM || fitem->bl.m != sd->bl.m)
- break;
-
- if (clif_cant_act(sd))
- break;
- //Disable cloaking/chasewalking characters from looting [Skotlex]
- if(pc_iscloaking(sd) || pc_ischasewalk(sd))
- break;
-
- if(sd->sc.count && (
- sd->sc.data[SC_TRICKDEAD].timer != -1 ||
- sd->sc.data[SC_BLADESTOP].timer != -1 ||
- (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOITEM))
- )
- break;
- if (!pc_takeitem(sd, fitem))
- break;
- return;
- } while (0);
- // Client REQUIRES a fail packet or you can no longer pick items.
- clif_additem(sd,0,0,6);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_DropItem(int fd, struct map_session_data *sd) {
- int item_index, item_amount;
- RFIFOHEAD(fd);
- if (pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl, 1);
- return;
- }
- if (clif_cant_act(sd))
- return;
- if (sd->sc.count && (
- sd->sc.data[SC_AUTOCOUNTER].timer != -1 ||
- sd->sc.data[SC_BLADESTOP].timer != -1 ||
- (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOITEM)
- ))
- return;
- item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
- item_amount = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
- if (!pc_dropitem(sd, item_index, item_amount))
- //Because the client does not likes being ignored.
- clif_delitem(sd, item_index,0);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_UseItem(int fd, struct map_session_data *sd) {
- int n;
- RFIFOHEAD(fd);
- if (pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl, 1);
- return;
- }
- if (sd->sc.opt1 > 0 && sd->sc.opt1 != OPT1_STONEWAIT)
- return;
-
- //This flag enables you to use items while in an NPC. [Skotlex]
- if (sd->npc_id) {
- if (sd->npc_id != sd->npc_item_flag)
- return;
- } else
- if (clif_trading(sd))
- return;
-
- if (sd->invincible_timer != -1)
- pc_delinvincibletimer(sd);
- //Whether the item is used or not is irrelevant, the char ain't idle. [Skotlex]
- sd->idletime = last_tick;
- n = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
-
- if(n <0 || n >= MAX_INVENTORY)
- return;
- if (!pc_useitem(sd,n))
- clif_useitemack(sd,n,0,0); //Send an empty ack packet or the client gets stuck.
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_EquipItem(int fd,struct map_session_data *sd)
- {
- int index;
- RFIFOHEAD(fd);
- if(pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl,1);
- return;
- }
- index = RFIFOW(fd,2)-2;
- if (index < 0 || index >= MAX_INVENTORY)
- return; //Out of bounds check.
-
- if(sd->npc_id) {
- if (sd->npc_id != sd->npc_item_flag)
- return;
- } else if (sd->state.storage_flag || sd->sc.opt1)
- ; //You can equip/unequip stuff while storage is open/under status changes
- else if (clif_cant_act(sd))
- return;
- if(sd->sc.data[SC_BLADESTOP].timer!=-1 || sd->sc.data[SC_BERSERK].timer!=-1 )
- return;
- if(!sd->status.inventory[index].identify) { // 未鑑定
- clif_equipitemack(sd,index,0,0); // fail
- return;
- }
- //ペット用装備であるかないか
- if(sd->inventory_data[index]) {
- if(sd->inventory_data[index]->type != IT_PETARMOR){
- if(sd->inventory_data[index]->type == IT_AMMO)
- pc_equipitem(sd,index,EQP_AMMO); //Client doesn't sends the position.
- else
- pc_equipitem(sd,index,RFIFOW(fd,4));
- } else
- pet_equipitem(sd,index);
- }
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_UnequipItem(int fd,struct map_session_data *sd)
- {
- int index;
- RFIFOHEAD(fd);
- if(pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl,1);
- return;
- }
- if (sd->state.storage_flag)
- ; //You can equip/unequip stuff while storage is open.
- else if (clif_cant_act(sd))
- return;
- index = RFIFOW(fd,2)-2;
- pc_unequipitem(sd,index,1);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
- {
- struct block_list *bl;
- RFIFOHEAD(fd);
- if(pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl,1);
- return;
- }
- if (clif_cant_act(sd))
- return;
- bl = map_id2bl(RFIFOL(fd,2));
- if (!bl) return;
- switch (bl->type) {
- case BL_MOB:
- if (!((TBL_MOB *)bl)->nd || !mob_script_callback((TBL_MOB *)bl, &sd->bl, CALLBACK_NPCCLICK))
- clif_parse_ActionRequest_sub(sd, 0x07, bl->id, gettick());
- break;
- case BL_PC:
- clif_parse_ActionRequest_sub(sd, 0x07, bl->id, gettick());
- break;
- case BL_NPC:
- npc_click(sd,(TBL_NPC*)bl);
- break;
- }
- return;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- if (sd->state.trading)
- return;
- npc_buysellsel(sd,RFIFOL(fd,2),RFIFOB(fd,6));
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd)
- {
- int fail=0,n;
- unsigned short *item_list;
- RFIFOHEAD(fd);
- n = (RFIFOW(fd,2)-4) /4;
- item_list = (unsigned short*)RFIFOP(fd,4);
- if (sd->state.trading|| !sd->npc_shopid)
- fail = 1;
- else
- fail = npc_buylist(sd,n,item_list);
- sd->npc_shopid = 0; //Clear shop data.
- WFIFOHEAD(fd,packet_len_table[0xca]);
- WFIFOW(fd,0)=0xca;
- WFIFOB(fd,2)=fail;
- WFIFOSET(fd,packet_len_table[0xca]);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd)
- {
- int fail=0,n;
- unsigned short *item_list;
- RFIFOHEAD(fd);
- n = (RFIFOW(fd,2)-4) /4;
- item_list = (unsigned short*)RFIFOP(fd,4);
- if (sd->state.trading || !sd->npc_shopid)
- fail = 1;
- else
- fail = npc_selllist(sd,n,item_list);
-
- sd->npc_shopid = 0; //Clear shop data.
- WFIFOHEAD(fd,packet_len_table[0xcb]);
- WFIFOW(fd,0)=0xcb;
- WFIFOB(fd,2)=fail;
- WFIFOSET(fd,packet_len_table[0xcb]);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_CreateChatRoom(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- if (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOROOM)
- return;
- if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 4){
- chat_createchat(sd,RFIFOW(fd,4),RFIFOB(fd,6),(char*)RFIFOP(fd,7),(char*)RFIFOP(fd,15),RFIFOW(fd,2)-15);
- } else
- clif_skill_fail(sd,1,0,3);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_ChatAddMember(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- chat_joinchat(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_ChatRoomStatusChange(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- chat_changechatstatus(sd,RFIFOW(fd,4),RFIFOB(fd,6),(char*)RFIFOP(fd,7),(char*)RFIFOP(fd,15),RFIFOW(fd,2)-15);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_ChangeChatOwner(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- chat_changechatowner(sd,(char*)RFIFOP(fd,6));
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_KickFromChat(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- chat_kickchat(sd,(char*)RFIFOP(fd,2));
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_ChatLeave(int fd,struct map_session_data *sd)
- {
- chat_leavechat(sd);
- }
- //Handles notifying asker and rejecter of what has just ocurred.
- //Type is used to determine the correct msg_txt to use:
- //0:
- static void clif_noask_sub(struct map_session_data *src, struct map_session_data *target, int type)
- {
- char *msg, output[256];
- // Your request has been rejected by autoreject option.
- msg = msg_txt(392);
- clif_disp_onlyself(src, msg, strlen(msg));
- //Notice that a request was rejected.
- snprintf(output, 256, msg_txt(393+type), src->status.name, 256);
- clif_disp_onlyself(target, output, strlen(output));
- }
- /*==========================================
- * 取引要請を相手に送る
- *------------------------------------------
- */
- void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
- {
- struct map_session_data *t_sd;
-
- RFIFOHEAD(fd);
- t_sd = map_id2sd(RFIFOL(sd->fd,2));
- if(!sd->chatID && clif_cant_act(sd))
- return; //You can trade while in a chatroom.
- // @noask [LuzZza]
- if(t_sd) {
- if (t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 0);
- return;
- }
- if(!t_sd->chatID && clif_cant_act(t_sd))
- return;
- }
- if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 1){
- trade_traderequest(sd,t_sd);
- } else
- clif_skill_fail(sd,1,0,0);
- }
- /*==========================================
- * 取引要請
- *------------------------------------------
- */
- void clif_parse_TradeAck(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- trade_tradeack(sd,RFIFOB(sd->fd,2));
- }
- /*==========================================
- * アイテム追加
- *------------------------------------------
- */
- void clif_parse_TradeAddItem(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- trade_tradeadditem(sd,RFIFOW(sd->fd,2),RFIFOL(sd->fd,4));
- }
- /*==========================================
- * アイテム追加完了(ok押し)
- *------------------------------------------
- */
- void clif_parse_TradeOk(int fd,struct map_session_data *sd)
- {
- trade_tradeok(sd);
- }
- /*==========================================
- * 取引キャンセル
- *------------------------------------------
- */
- void clif_parse_TradeCancel(int fd,struct map_session_data *sd)
- {
- trade_tradecancel(sd);
- }
- /*==========================================
- * 取引許諾(trade押し)
- *------------------------------------------
- */
- void clif_parse_TradeCommit(int fd,struct map_session_data *sd)
- {
- trade_tradecommit(sd);
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_StopAttack(int fd,struct map_session_data *sd)
- {
- pc_stop_attack(sd);
- }
- /*==========================================
- * カートへアイテムを移す
- *------------------------------------------
- */
- void clif_parse_PutItemToCart(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- if (clif_trading(sd))
- return;
- pc_putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
- }
- /*==========================================
- * カートからアイテムを出す
- *------------------------------------------
- */
- void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- pc_getitemfromcart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
- }
- /*==========================================
- * 付属品(鷹,ペコ,カート)をはずす
- *------------------------------------------
- */
- void clif_parse_RemoveOption(int fd,struct map_session_data *sd)
- {
- //Can only remove Cart/Riding/Falcon.
- pc_setoption(sd,sd->sc.option&~(OPTION_CART|OPTION_RIDING|OPTION_FALCON));
- }
- /*==========================================
- * チェンジカート
- *------------------------------------------
- */
- void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- pc_setcart(sd,RFIFOW(fd,2));
- }
- /*==========================================
- * ステータスアップ
- *------------------------------------------
- */
- void clif_parse_StatusUp(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- pc_statusup(sd,RFIFOW(fd,2));
- }
- /*==========================================
- * スキルレベルアップ
- *------------------------------------------
- */
- void clif_parse_SkillUp(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- pc_skillup(sd,RFIFOW(fd,2));
- }
- static void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, int skillnum, int skilllv, int target_id)
- {
- int lv;
- if (!hd)
- return;
- if (skillnotok_hom(skillnum, hd)) //[orn]
- return;
- if (hd->bl.id != target_id &&
- skill_get_inf(skillnum)&INF_SELF_SKILL)
- target_id = hd->bl.id; //What good is it to mess up the target in self skills? Wished I knew... [Skotlex]
-
- if (hd->ud.skilltimer != -1) {
- if (skillnum != SA_CASTCANCEL)
- return;
- } else if (DIFF_TICK(tick, hd->ud.canact_tick) < 0)
- return;
- lv = merc_hom_checkskill(hd, skillnum);
- if (skilllv > lv)
- skilllv = lv;
-
- if (skilllv)
- unit_skilluse_id(&hd->bl, target_id, skillnum, skilllv);
- }
- /*==========================================
- * スキル使用(ID指定)
- *------------------------------------------
- */
- void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) {
- int skillnum, skilllv, tmp, target_id;
- unsigned int tick = gettick();
- RFIFOHEAD(fd);
- if (clif_cant_act(sd))
- return;
- if (pc_issit(sd))
- return;
- skilllv = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- if (skilllv < 1) skilllv = 1; //No clue, I have seen the client do this with guild skills :/ [Skotlex]
- skillnum = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
- target_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
- //Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
- sd->idletime = last_tick;
- tmp = skill_get_inf(skillnum);
- if (tmp&INF_GROUND_SKILL)
- return; //Using a ground skill on a target? WRONG.
- if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL) {
- clif_parse_UseSkillToId_homun(sd->hd, sd, tick, skillnum, skilllv, target_id);
- return;
- }
- if (skillnotok(skillnum, sd))
- return;
- if (sd->bl.id != target_id && !sd->state.skill_flag && tmp&INF_SELF_SKILL)
- target_id = sd->bl.id; //What good is it to mess up the target in self skills? Wished I knew... [Skotlex]
-
- if (sd->ud.skilltimer != -1) {
- if (skillnum != SA_CASTCANCEL)
- return;
- } else if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) {
- clif_skill_fail(sd, skillnum, 4, 0);
- return;
- }
- if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
- return;
-
- if (sd->invincible_timer != -1)
- pc_delinvincibletimer(sd);
-
- if(target_id<0 && -target_id == sd->bl.id) // for disguises [Valaris]
- target_id = sd->bl.id;
-
- if (sd->skillitem >= 0 && sd->skillitem == skillnum) {
- if (skilllv != sd->skillitemlv)
- skilllv = sd->skillitemlv;
- unit_skilluse_id(&sd->bl, target_id, skillnum, skilllv);
- return;
- }
-
- sd->skillitem = sd->skillitemlv = -1;
- if (skillnum == MO_EXTREMITYFIST) {
- if ((sd->sc.data[SC_COMBO].timer == -1 ||
- (sd->sc.data[SC_COMBO].val1 != MO_COMBOFINISH &&
- sd->sc.data[SC_COMBO].val1 != CH_TIGERFIST &&
- sd->sc.data[SC_COMBO].val1 != CH_CHAINCRUSH))) {
- if (!sd->state.skill_flag ) {
- sd->state.skill_flag = 1;
- clif_skillinfo(sd, MO_EXTREMITYFIST, INF_ATTACK_SKILL, -1);
- return;
- } else if (sd->bl.id == target_id) {
- clif_skillinfo(sd, MO_EXTREMITYFIST, INF_ATTACK_SKILL, -1);
- return;
- }
- }
- }
- if (skillnum == TK_JUMPKICK) {
- if (sd->sc.data[SC_COMBO].timer == -1 ||
- sd->sc.data[SC_COMBO].val1 != TK_JUMPKICK) {
- if (!sd->state.skill_flag ) {
- sd->state.skill_flag = 1;
- clif_skillinfo(sd, TK_JUMPKICK, INF_ATTACK_SKILL, -1);
- return;
- } else if (sd->bl.id == target_id) {
- clif_skillinfo(sd, TK_JUMPKICK, INF_ATTACK_SKILL, -1);
- return;
- }
- }
- }
- if (skillnum >= GD_SKILLBASE) {
- if (sd->state.gmaster_flag)
- skilllv = guild_checkskill(sd->state.gmaster_flag, skillnum);
- else
- skilllv = 0;
- } else {
- tmp = pc_checkskill(sd, skillnum);
- if (skilllv > tmp)
- skilllv = tmp;
- }
- if (skilllv)
- unit_skilluse_id(&sd->bl, target_id, skillnum, skilllv);
- if (sd->state.skill_flag)
- sd->state.skill_flag = 0;
- }
- /*==========================================
- * スキル使用(場所指定)
- *------------------------------------------
- */
- void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, int skilllv, int skillnum, int x, int y, int skillmoreinfo)
- {
- int lv;
- unsigned int tick = gettick();
- RFIFOHEAD(fd);
- //Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
- sd->idletime = last_tick;
- if (skillnotok(skillnum, sd))
- return;
- if (!(skill_get_inf(skillnum)&INF_GROUND_SKILL))
- return; //Using a target skill on the ground? WRONG.
- if (skillmoreinfo != -1) {
- if (pc_issit(sd)) {
- clif_skill_fail(sd, skillnum, 0, 0);
- return;
- }
- memcpy(talkie_mes, RFIFOP(fd,skillmoreinfo), MESSAGE_SIZE);
- talkie_mes[MESSAGE_SIZE-1] = '\0'; //Overflow protection [Skotlex]
- }
- if (sd->ud.skilltimer != -1)
- return;
- if (DIFF_TICK(tick, sd->ud.canact_tick) < 0)
- {
- clif_skill_fail(sd, skillnum, 4, 0);
- return;
- }
- if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
- return;
-
- if (sd->invincible_timer != -1)
- pc_delinvincibletimer(sd);
- if (sd->skillitem >= 0 && sd->skillitem == skillnum) {
- if (skilllv != sd->skillitemlv)
- skilllv = sd->skillitemlv;
- unit_skilluse_pos(&sd->bl, x, y, skillnum, skilllv);
- } else {
- sd->skillitem = sd->skillitemlv = -1;
- if ((lv = pc_checkskill(sd, skillnum)) > 0) {
- if (skilllv > lv)
- skilllv = lv;
- unit_skilluse_pos(&sd->bl, x, y, skillnum,skilllv);
- }
- }
- }
- void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if (clif_cant_act(sd))
- return;
- if (pc_issit(sd))
- return;
- clif_parse_UseSkillToPosSub(fd, sd,
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), //skill lv
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), //skill num
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), //pos x
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]), //pos y
- -1 //Skill more info.
- );
- }
- void clif_parse_UseSkillToPosMoreInfo(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if (clif_cant_act(sd))
- return;
- if (pc_issit(sd))
- return;
-
- clif_parse_UseSkillToPosSub(fd, sd,
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), //Skill lv
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), //Skill num
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), //pos x
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]), //pos y
- packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[4] //skill more info
- );
- }
- /*==========================================
- * スキル使用(map指定)
- *------------------------------------------
- */
- void clif_parse_UseSkillMap(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- if (clif_cant_act(sd))
- return;
- if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
- return;
-
- if(sd->invincible_timer != -1)
- pc_delinvincibletimer(sd);
- skill_castend_map(sd,RFIFOW(fd,2),(char*)RFIFOP(fd,4));
- }
- /*==========================================
- * メモ要求
- *------------------------------------------
- */
- void clif_parse_RequestMemo(int fd,struct map_session_data *sd)
- {
- if (!pc_isdead(sd))
- pc_memo(sd,-1);
- }
- /*==========================================
- * アイテム合成
- *------------------------------------------
- */
- void clif_parse_ProduceMix(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- if (sd->menuskill_id != AM_PHARMACY)
- return;
- if (clif_trading(sd)) {
- //Make it fail to avoid shop exploits where you sell something different than you see.
- clif_skill_fail(sd,sd->ud.skillid,0,0);
- sd->menuskill_lv = sd->menuskill_id = 0;
- return;
- }
- skill_produce_mix(sd,0,RFIFOW(fd,2),RFIFOW(fd,4),RFIFOW(fd,6),RFIFOW(fd,8), 1);
- sd->menuskill_lv = sd->menuskill_id = 0;
- }
- /*==========================================
- * 武器修理
- *------------------------------------------
- */
- void clif_parse_RepairItem(int fd, struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- if (sd->menuskill_id != BS_REPAIRWEAPON)
- return;
- if (clif_trading(sd)) {
- //Make it fail to avoid shop exploits where you sell something different than you see.
- clif_skill_fail(sd,sd->ud.skillid,0,0);
- sd->menuskill_lv = sd->menuskill_id = 0;
- return;
- }
- skill_repairweapon(sd,RFIFOW(fd,2));
- sd->menuskill_lv = sd->menuskill_id = 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_WeaponRefine(int fd, struct map_session_data *sd) {
- int idx;
- RFIFOHEAD(fd);
- if (sd->menuskill_id != WS_WEAPONREFINE) //Packet exploit?
- return;
- if (clif_trading(sd)) {
- //Make it fail to avoid shop exploits where you sell something different than you see.
- clif_skill_fail(sd,sd->ud.skillid,0,0);
- sd->menuskill_lv = sd->menuskill_id = 0;
- return;
- }
- idx = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- skill_weaponrefine(sd, idx-2);
- sd->menuskill_lv = sd->menuskill_id = 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- sd->npc_menu=RFIFOB(fd,6);
- npc_scriptcont(sd,RFIFOL(fd,2));
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- #ifdef __WIN32
- //For some extraordinarily eerie reason that noone has figured out yet,
- //windows native compiles NEED this nullpo_retv or the function is not found!
- nullpo_retv(sd);
- #endif
- npc_scriptcont(sd,RFIFOL(fd,2));
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- #define RFIFOL_(fd,pos) (*(int*)(session[fd]->rdata+session[fd]->rdata_pos+(pos)))
- //Input Value overflow Exploit FIX
- sd->npc_amount=RFIFOL_(fd,6); //fixed by Lupus. npc_amount is (int) but was RFIFOL changing it to (unsigned int)
- #undef RFIFOL_
- npc_scriptcont(sd,RFIFOL(fd,2));
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_NpcStringInput(int fd,struct map_session_data *sd)
- {
- unsigned short message_len = RFIFOW(fd,2)-7;
- RFIFOHEAD(fd);
- if(message_len >= sizeof(sd->npc_str)){
- ShowWarning("clif: input string too long !\n");
- message_len = sizeof(sd->npc_str);
- }
- // Exploit prevention if crafted packets (without null) is being sent. [Lance]
- memcpy(sd->npc_str,RFIFOP(fd,8),message_len);
- sd->npc_str[message_len-1]=0;
- npc_scriptcont(sd,RFIFOL(fd,4));
- }
- /*==========================================
- *
- *------------------------------------------
- */
- void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- if (sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex]
- npc_scriptcont(sd,RFIFOL(fd,2));
- }
- /*==========================================
- * アイテム鑑定
- *------------------------------------------
- */
- void clif_parse_ItemIdentify(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- if (sd->menuskill_id != MC_IDENTIFY)
- return;
- skill_identify(sd,RFIFOW(fd,2)-2);
- sd->menuskill_lv = sd->menuskill_id = 0;
- }
- /*==========================================
- * 矢作成
- *------------------------------------------
- */
- void clif_parse_SelectArrow(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- if (sd->menuskill_id != AC_MAKINGARROW)
- return;
- if (clif_trading(sd)) {
- //Make it fail to avoid shop exploits where you sell something different than you see.
- clif_skill_fail(sd,sd->ud.skillid,0,0);
- sd->menuskill_lv = sd->menuskill_id = 0;
- return;
- }
- skill_arrow_create(sd,RFIFOW(fd,2));
- sd->menuskill_lv = sd->menuskill_id = 0;
- }
- /*==========================================
- * オートスペル受信
- *------------------------------------------
- */
- void clif_parse_AutoSpell(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- if (sd->menuskill_id != SA_AUTOSPELL)
- return;
- skill_autospell(sd,RFIFOW(fd,2));
- sd->menuskill_lv = sd->menuskill_id = 0;
- }
- /*==========================================
- * カード使用
- *------------------------------------------
- */
- void clif_parse_UseCard(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- if (sd->state.trading!= 0)
- return;
- clif_use_card(sd,RFIFOW(fd,2)-2);
- }
- /*==========================================
- * カード挿入装備選択
- *------------------------------------------
- */
- void clif_parse_InsertCard(int fd,struct map_session_data *sd)
- {
- RFIFOHEAD(fd);
- if (sd->state.trading!= 0)
- return;
- pc_insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2);
- }
- /*==========================================
- * 0193 キャラID名前引き
- *------------------------------------------
- */
- void clif_parse_SolveCharName(int fd, struct map_session_data *sd) {
- int char_id;
- RFIFOHEAD(fd);
- char_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- clif_solved_charname(sd, char_id);
- }
- /*==========================================
- * 0197 /resetskill /resetstate
- *------------------------------------------
- */
- void clif_parse_ResetChar(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- pc_isGM(sd) >= get_atcommand_level(AtCommand_ResetState)) {
- switch(RFIFOW(fd,2)){
- case 0:
- pc_resetstate(sd);
- break;
- case 1:
- pc_resetskill(sd,1);
- break;
- }
- }
- }
- /*==========================================
- * 019c /lb等
- *------------------------------------------
- */
- void clif_parse_LGMmessage(int fd, struct map_session_data *sd) {
- unsigned char buf[512];
- RFIFOHEAD(fd);
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_LocalBroadcast))) {
- WBUFW(buf,0) = 0x9a;
- WBUFW(buf,2) = RFIFOW(fd,2);
- memcpy(WBUFP(buf,4), RFIFOP(fd,4), RFIFOW(fd,2) - 4);
- clif_send(buf, RFIFOW(fd,2), &sd->bl, ALL_SAMEMAP);
- }
- }
- /*==========================================
- * カプラ倉庫へ入れる
- *------------------------------------------
- */
- void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) {
- int item_index, item_amount;
- RFIFOHEAD(fd);
- if (clif_trading(sd))
- return;
-
- item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
- item_amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
- if (item_index < 0 || item_index >= MAX_INVENTORY || item_amount < 1)
- return;
- if (sd->state.storage_flag == 1)
- storage_storageadd(sd, item_index, item_amount);
- else if (sd->state.storage_flag == 2)
- storage_guild_storageadd(sd, item_index, item_amount);
- }
- /*==========================================
- * カプラ倉庫から出す
- *------------------------------------------
- */
- void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd) {
- int item_index, item_amount;
- RFIFOHEAD(fd);
- item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-1;
- item_amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
- if (sd->state.storage_flag == 1)
- storage_storageget(sd, item_index, item_amount);
- else if(sd->state.storage_flag == 2)
- storage_guild_storageget(sd, item_index, item_amount);
- }
- /*==========================================
- * カプラ倉庫へカートから入れる
- *------------------------------------------
- */
- void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if(sd->vender_id)
- return;
- if (sd->state.storage_flag == 1)
- storage_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
- else if (sd->state.storage_flag == 2)
- storage_guild_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
- }
- /*==========================================
- * カプラ倉庫から出す
- *------------------------------------------
- */
- void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if (sd->vender_id)
- return;
- if (sd->state.storage_flag == 1)
- storage_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
- else if (sd->state.storage_flag == 2)
- storage_guild_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
- }
- /*==========================================
- * カプラ倉庫を閉じる
- *------------------------------------------
- */
- void clif_parse_CloseKafra(int fd, struct map_session_data *sd) {
- if (sd->state.storage_flag == 1)
- storage_storageclose(sd);
- else if (sd->state.storage_flag == 2)
- storage_guild_storageclose(sd);
- }
- /*==========================================
- * パーティを作る
- *------------------------------------------
- */
- void clif_parse_CreateParty(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7) {
- party_create(sd,(char*)RFIFOP(fd,2),0,0);
- } else
- clif_skill_fail(sd,1,0,4);
- }
- /*==========================================
- * パーティを作る
- *------------------------------------------
- */
- void clif_parse_CreateParty2(int fd, struct map_session_data *sd) {
- if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7){
- RFIFOHEAD(fd);
- party_create(sd,(char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27));
- } else
- clif_skill_fail(sd,1,0,4);
- }
- /*==========================================
- * パーティに勧誘
- *------------------------------------------
- */
- void clif_parse_PartyInvite(int fd, struct map_session_data *sd) {
-
- struct map_session_data *t_sd;
-
- RFIFOHEAD(fd);
- t_sd = map_id2sd(RFIFOL(sd->fd,2));
- // @noask [LuzZza]
- if(t_sd && t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 1);
- return;
- }
-
- party_invite(sd, t_sd);
- }
- /*==========================================
- * パーティ勧誘返答
- *------------------------------------------
- */
- void clif_parse_ReplyPartyInvite(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 5){
- party_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6));
- } else {
- party_reply_invite(sd,RFIFOL(fd,2),-1);
- clif_skill_fail(sd,1,0,4);
- }
- }
- /*==========================================
- * パーティ脱退要求
- *------------------------------------------
- */
- void clif_parse_LeaveParty(int fd, struct map_session_data *sd) {
- party_leave(sd);
- }
- /*==========================================
- * パーティ除名要求
- *------------------------------------------
- */
- void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- party_removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
- }
- /*==========================================
- * パーティ設定変更要求
- *------------------------------------------
- */
- void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) {
- struct party_data *p;
- RFIFOHEAD(fd);
- if(!sd->status.party_id)
- return;
- p = party_search(sd->status.party_id);
- if (!p) return;
- //The client no longer can change the item-field, therefore it always
- //comes as zero. Here, resend the item data as it is.
- // party_changeoption(sd, RFIFOW(fd,2), RFIFOW(fd,4));
- party_changeoption(sd, RFIFOW(fd,2), p->party.item);
- }
- /*==========================================
- * パーティメッセージ送信要求
- *------------------------------------------
- */
- void clif_parse_PartyMessage(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if (is_charcommand(fd, sd, (char*)RFIFOP(fd,4), 0) != CharCommand_None ||
- is_atcommand(fd, sd, (char*)RFIFOP(fd,4), 0) != AtCommand_None)
- return;
- if (sd->sc.count && (
- sd->sc.data[SC_BERSERK].timer!=-1 ||
- (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)
- ))
- return;
- if (battle_config.min_chat_delay)
- { //[Skotlex]
- if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
- return;
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
- }
- party_send_message(sd, (char*)RFIFOP(fd,4), RFIFOW(fd,2)-4);
- }
- /*==========================================
- * 露店閉鎖
- *------------------------------------------
- */
- void clif_parse_CloseVending(int fd, struct map_session_data *sd) {
- vending_closevending(sd);
- }
- /*==========================================
- * 露店アイテムリスト要求
- *------------------------------------------
- */
- void clif_parse_VendingListReq(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- vending_vendinglistreq(sd,RFIFOL(fd,2));
- if(sd->npc_id)
- npc_event_dequeue(sd);
- }
- /*==========================================
- * 露店アイテム購入
- *------------------------------------------
- */
- void clif_parse_PurchaseReq(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- vending_purchasereq(sd, RFIFOW(fd,2), RFIFOL(fd,4), RFIFOP(fd,8));
- }
- /*==========================================
- * 露店開設
- *------------------------------------------
- */
- void clif_parse_OpenVending(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if (clif_trading(sd))
- return;
- if (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOROOM)
- return;
- vending_openvending(sd, RFIFOW(fd,2), (char*)RFIFOP(fd,4), RFIFOB(fd,84), RFIFOP(fd,85));
- }
- /*==========================================
- * ギルドを作る
- *------------------------------------------
- */
- void clif_parse_CreateGuild(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- guild_create(sd, (char*)RFIFOP(fd,6));
- }
- /*==========================================
- * ギルドマスターかどうか確認
- *------------------------------------------
- */
- void clif_parse_GuildCheckMaster(int fd, struct map_session_data *sd) {
- clif_guild_masterormember(sd);
- }
- /*==========================================
- * ギルド情報要求
- *------------------------------------------
- */
- void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- switch(RFIFOL(fd,2)){
- case 0: // ギルド基本情報、同盟敵対情報
- clif_guild_basicinfo(sd);
- clif_guild_allianceinfo(sd);
- break;
- case 1: // メンバーリスト、役職名リスト
- clif_guild_positionnamelist(sd);
- clif_guild_memberlist(sd);
- break;
- case 2: // 役職名リスト、役職情報リスト
- clif_guild_positionnamelist(sd);
- clif_guild_positioninfolist(sd);
- break;
- case 3: // スキルリスト
- clif_guild_skillinfo(sd);
- break;
- case 4: // 追放リスト
- clif_guild_expulsionlist(sd);
- break;
- default:
- if (battle_config.error_log)
- ShowError("clif: guild request info: unknown type %d\n", RFIFOL(fd,2));
- break;
- }
- }
- /*==========================================
- * ギルド役職変更
- *------------------------------------------
- */
- void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) {
- int i;
- RFIFOHEAD(fd);
- for(i = 4; i < RFIFOW(fd,2); i += 40 ){
- guild_change_position(sd, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), (char*)RFIFOP(fd,i+16));
- }
- }
- /*==========================================
- * ギルドメンバ役職変更
- *------------------------------------------
- */
- void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd) {
- int i;
- RFIFOHEAD(fd);
- for(i=4;i<RFIFOW(fd,2);i+=12){
- guild_change_memberposition(sd->status.guild_id,
- RFIFOL(fd,i),RFIFOL(fd,i+4),RFIFOL(fd,i+8));
- }
- }
- /*==========================================
- * ギルドエンブレム要求
- *------------------------------------------
- */
- void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd) {
- struct guild *g;
- RFIFOHEAD(fd);
- g=guild_search(RFIFOL(fd,2));
- if(g!=NULL)
- clif_guild_emblem(sd,g);
- }
- /*==========================================
- * ギルドエンブレム変更
- *------------------------------------------
- */
- void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- guild_change_emblem(sd,RFIFOW(fd,2)-4,(char*)RFIFOP(fd,4));
- }
- /*==========================================
- * ギルド告知変更
- *------------------------------------------
- */
- void clif_parse_GuildChangeNotice(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- guild_change_notice(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6),(char*)RFIFOP(fd,66));
- }
- /*==========================================
- * ギルド勧誘
- *------------------------------------------
- */
- void clif_parse_GuildInvite(int fd,struct map_session_data *sd) {
- struct map_session_data *t_sd;
-
- RFIFOHEAD(fd);
- t_sd = map_id2sd(RFIFOL(sd->fd,2));
- // @noask [LuzZza]
- if(t_sd && t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 2);
- return;
- }
- guild_invite(sd,t_sd);
- }
- /*==========================================
- * ギルド勧誘返信
- *------------------------------------------
- */
- void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- guild_reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6));
- }
- /*==========================================
- * ギルド脱退
- *------------------------------------------
- */
- void clif_parse_GuildLeave(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- guild_leave(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
- }
- /*==========================================
- * ギルド追放
- *------------------------------------------
- */
- void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- guild_expulsion(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
- }
- /*==========================================
- * ギルド会話
- *------------------------------------------
- */
- void clif_parse_GuildMessage(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if (is_charcommand(fd, sd, (char*)RFIFOP(fd, 4), 0) != CharCommand_None ||
- is_atcommand(fd, sd, (char*)RFIFOP(fd, 4), 0) != AtCommand_None)
- return;
- if (sd->sc.count && (
- sd->sc.data[SC_BERSERK].timer!=-1 ||
- (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)
- ))
- return;
- if (battle_config.min_chat_delay)
- { //[Skotlex]
- if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
- return;
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
- }
- guild_send_message(sd, (char*)RFIFOP(fd,4), RFIFOW(fd,2)-4);
- }
- /*==========================================
- * ギルド同盟要求
- *------------------------------------------
- */
- void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) {
-
- struct map_session_data *t_sd;
-
- RFIFOHEAD(fd);
- t_sd = map_id2sd(RFIFOL(sd->fd,2));
- // @noask [LuzZza]
- if(t_sd && t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 3);
- return;
- }
-
- guild_reqalliance(sd,t_sd);
- }
- /*==========================================
- * ギルド同盟要求返信
- *------------------------------------------
- */
- void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- guild_reply_reqalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
- }
- /*==========================================
- * ギルド関係解消
- *------------------------------------------
- */
- void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- guild_delalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
- }
- /*==========================================
- * ギルド敵対
- *------------------------------------------
- */
- void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) {
-
- struct map_session_data *t_sd;
-
- RFIFOHEAD(fd);
- t_sd = map_id2sd(RFIFOL(sd->fd,2));
- // @noask [LuzZza]
- if(t_sd && t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 4);
- return;
- }
-
- guild_opposition(sd,t_sd);
- }
- /*==========================================
- * ギルド解散
- *------------------------------------------
- */
- void clif_parse_GuildBreak(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- guild_break(sd,(char*)RFIFOP(fd,2));
- }
- // pet
- void clif_parse_PetMenu(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- pet_menu(sd,RFIFOB(fd,2));
- }
- void clif_parse_CatchPet(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- pet_catch_process2(sd,RFIFOL(fd,2));
- }
- void clif_parse_SelectEgg(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if (sd->menuskill_id != SA_TAMINGMONSTER || sd->menuskill_lv != -1)
- return;
- pet_select_egg(sd,RFIFOW(fd,2)-2);
- sd->menuskill_lv = sd->menuskill_id = 0;
- }
- void clif_parse_SendEmotion(int fd, struct map_session_data *sd) {
- if(sd->pd) {
- RFIFOHEAD(fd);
- clif_pet_emotion(sd->pd,RFIFOL(fd,2));
- }
- }
- void clif_parse_ChangePetName(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- pet_change_name(sd,(char*)RFIFOP(fd,2), 0);
- }
- // Kick (right click menu for GM "(name) force to quit")
- void clif_parse_GMKick(int fd, struct map_session_data *sd) {
- struct block_list *target;
- int tid;
- RFIFOHEAD(fd);
- tid = RFIFOL(fd,2);
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_Kick))) {
- target = map_id2bl(tid);
- if (target) {
- if (target->type == BL_PC) {
- struct map_session_data *tsd = (struct map_session_data *)target;
- if (pc_isGM(sd) > pc_isGM(tsd))
- clif_GM_kick(sd, tsd, 1);
- else
- clif_GM_kickack(sd, 0);
- } else if (target->type == BL_MOB) {
- status_percent_damage(&sd->bl, target, 100, 0);
- } else
- clif_GM_kickack(sd, 0);
- } else
- clif_GM_kickack(sd, 0);
- }
- }
- /*==========================================
- * /shift
- *------------------------------------------
- */
- void clif_parse_Shift(int fd, struct map_session_data *sd) { // Rewriten by [Yor]
- char player_name[NAME_LENGTH];
- malloc_tsetdword(player_name, '\0', sizeof(player_name));
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_JumpTo))) {
- RFIFOHEAD(fd);
- memcpy(player_name, RFIFOP(fd,2), NAME_LENGTH);
- atcommand_jumpto(fd, sd, "@jumpto", player_name); // as @jumpto
- }
- return;
- }
- /*==========================================
- * /recall
- *------------------------------------------
- */
- void clif_parse_Recall(int fd, struct map_session_data *sd) { // Added by RoVeRT
- char player_name[NAME_LENGTH];
- malloc_tsetdword(player_name, '\0', sizeof(player_name));
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_Recall))) {
- RFIFOHEAD(fd);
- memcpy(player_name, RFIFOP(fd,2), NAME_LENGTH);
- atcommand_recall(fd, sd, "@recall", player_name); // as @recall
- }
- return;
- }
- /*==========================================
- * /monster /item rewriten by [Yor]
- *------------------------------------------
- */
- void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) {
- char monster_item_name[NAME_LENGTH+10]; //Additional space is for logging, eg: "@monster Poring"
- int level;
- malloc_tsetdword(monster_item_name, '\0', sizeof(monster_item_name));
- if (battle_config.atc_gmonly == 0 || pc_isGM(sd)) {
- RFIFOHEAD(fd);
- memcpy(monster_item_name, RFIFOP(fd,2), NAME_LENGTH);
- if (mobdb_searchname(monster_item_name) != 0) {
- if (pc_isGM(sd) >= (level =get_atcommand_level(AtCommand_Spawn))) // changed from AtCommand_Monster for Skots [Reddozen]
- {
- atcommand_monster(fd, sd, "@spawn", monster_item_name); // as @spawn
- if(log_config.gm && level >= log_config.gm)
- { //Log action. [Skotlex]
- snprintf(monster_item_name, sizeof(monster_item_name)-1, "@spawn %s", RFIFOP(fd,2));
- log_atcommand(sd, monster_item_name);
- }
- }
- } else if (itemdb_searchname(monster_item_name) != NULL) {
- if (pc_isGM(sd) >= (level = get_atcommand_level(AtCommand_Item)))
- {
- atcommand_item(fd, sd, "@item", monster_item_name); // as @item
- if(log_config.gm && level >= log_config.gm)
- { //Log action. [Skotlex]
- snprintf(monster_item_name, sizeof(monster_item_name)-1, "@item %s", RFIFOP(fd,2));
- log_atcommand(sd, monster_item_name);
- }
- }
- }
- }
- }
- void clif_parse_GMHide(int fd, struct map_session_data *sd) { // Modified by [Yor]
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_Hide))) {
- if (sd->sc.option & OPTION_INVISIBLE) {
- sd->sc.option &= ~OPTION_INVISIBLE;
- if (sd->disguise)
- status_set_viewdata(&sd->bl, sd->disguise);
- else
- status_set_viewdata(&sd->bl, sd->status.class_);
- clif_displaymessage(fd, "Invisible: Off.");
- } else {
- sd->sc.option |= OPTION_INVISIBLE;
- //Experimental hidden mode, changes your view class to invisible [Skotlex]
- sd->vd.class_ = INVISIBLE_CLASS;
- clif_displaymessage(fd, "Invisible: On.");
- }
- clif_changeoption(&sd->bl);
- }
- }
- /*==========================================
- * GMによるチャット禁止時間付与
- *------------------------------------------
- */
- void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd)
- {
- int type, limit, level;
- struct block_list *bl;
- struct map_session_data *dstsd;
- RFIFOHEAD(fd);
- bl = map_id2bl(RFIFOL(fd,2));
- if (!bl || bl->type != BL_PC)
- return;
- nullpo_retv(dstsd =(struct map_session_data *)bl);
- type = RFIFOB(fd,6);
- limit = RFIFOW(fd,7);
- if (type == 0)
- limit = 0 - limit;
- //If type is 2 and the ids don't match, this is a crafted hacked packet!
- //Disabled because clients keep self-muting when you give players public @ commands... [Skotlex]
- if (type == 2/* && sd->bl.id != dstsd->bl.id*/)
- return;
-
- if (
- ((level = pc_isGM(sd)) > pc_isGM(dstsd) && level >= get_atcommand_level(AtCommand_Mute))
- || (type == 2 && !level)) {
- clif_GM_silence(sd, dstsd, ((type == 2) ? 1 : type));
- dstsd->status.manner -= limit;
- if(dstsd->status.manner < 0)
- sc_start(bl,SC_NOCHAT,100,0,0);
- else
- {
- dstsd->status.manner = 0;
- status_change_end(bl,SC_NOCHAT,-1);
- }
- }
- return;
- }
- /*==========================================
- * GMによるチャット禁止時間参照(?)
- *------------------------------------------
- */
- void clif_parse_GMReqNoChatCount(int fd, struct map_session_data *sd)
- {
- int tid;
- RFIFOHEAD(fd);
- tid = RFIFOL(fd,2);
- WFIFOHEAD(fd,packet_len_table[0x1e0]);
- WFIFOW(fd,0) = 0x1e0;
- WFIFOL(fd,2) = tid;
- sprintf((char*)WFIFOP(fd,6),"%d",tid);
- // memcpy(WFIFOP(fd,6), "TESTNAME", 24);
- WFIFOSET(fd, packet_len_table[0x1e0]);
- return;
- }
- void clif_parse_PMIgnore(int fd, struct map_session_data *sd) { // Rewritten by [Yor]
- char output[512];
- char *nick; // S 00cf <nick>.24B <type>.B: 00 (/ex nick) deny speech from nick, 01 (/in nick) allow speech from nick
- int i, pos;
- RFIFOHEAD(fd);
- malloc_tsetdword(output, '\0', sizeof(output));
- nick = (char*)RFIFOP(fd,2); // speed up
- RFIFOB(fd,NAME_LENGTH+1) = '\0'; // to be sure that the player name have at maximum 23 characters (nick range: [2]->[26])
- //printf("Ignore: char '%s' state: %d\n", nick, RFIFOB(fd,26));
- WFIFOHEAD(fd,packet_len_table[0xd1]);
- WFIFOW(fd,0) = 0x0d1; // R 00d1 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
- WFIFOB(fd,2) = RFIFOB(fd,26);
- // do nothing only if nick can not exist
- if (strlen(nick) < 4) {
- WFIFOB(fd,3) = 1; // fail
- WFIFOSET(fd, packet_len_table[0x0d1]);
- if (RFIFOB(fd,26) == 0) // type
- clif_wis_message(fd, wisp_server_name, "It's impossible to block this player.", strlen("It's impossible to block this player.") + 1);
- else
- clif_wis_message(fd, wisp_server_name, "It's impossible to unblock this player.", strlen("It's impossible to unblock this player.") + 1);
- return;
- // name can exist
- } else {
- // deny action (we add nick only if it's not already exist
- if (RFIFOB(fd,26) == 0) { // type
- pos = -1;
- for(i = 0; i < MAX_IGNORE_LIST; i++) {
- if (strcmp(sd->ignore[i].name, nick) == 0) {
- WFIFOB(fd,3) = 1; // fail
- WFIFOSET(fd, packet_len_table[0x0d1]);
- clif_wis_message(fd, wisp_server_name, "This player is already blocked.", strlen("This player is already blocked.") + 1);
- if (strcmp(wisp_server_name, nick) == 0) { // to found possible bot users who automaticaly ignore people.
- sprintf(output, "Character '%s' (account: %d) has tried AGAIN to block wisps from '%s' (wisp name of the server). Bot user?", sd->status.name, sd->status.account_id, wisp_server_name);
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output);
- }
- return;
- } else if (pos == -1 && sd->ignore[i].name[0] == '\0')
- pos = i;
- }
- // if a position is found and name not found, we add it in the list
- if (pos != -1) {
- memcpy(sd->ignore[pos].name, nick, NAME_LENGTH-1);
- WFIFOB(fd,3) = 0; // success
- WFIFOSET(fd, packet_len_table[0x0d1]);
- if (strcmp(wisp_server_name, nick) == 0) { // to found possible bot users who automaticaly ignore people.
- sprintf(output, "Character '%s' (account: %d) has tried to block wisps from '%s' (wisp name of the server). Bot user?", sd->status.name, sd->status.account_id, wisp_server_name);
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output);
- // send something to be inform and force bot to ignore twice... If GM receiving block + block again, it's a bot :)
- clif_wis_message(fd, wisp_server_name, "Add me in your ignore list, doesn't block my wisps.", strlen("Add me in your ignore list, doesn't block my wisps.") + 1);
- }
- } else {
- WFIFOB(fd,3) = 1; // fail
- WFIFOSET(fd, packet_len_table[0x0d1]);
- clif_wis_message(fd, wisp_server_name, "You can not block more people.", strlen("You can not block more people.") + 1);
- if (strcmp(wisp_server_name, nick) == 0) { // to found possible bot users who automaticaly ignore people.
- sprintf(output, "Character '%s' (account: %d) has tried to block wisps from '%s' (wisp name of the server). Bot user?", sd->status.name, sd->status.account_id, wisp_server_name);
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output);
- }
- }
- // allow action (we remove all same nicks if they exist)
- } else {
- pos = -1;
- for(i = 0; i < MAX_IGNORE_LIST; i++)
- if (strcmp(sd->ignore[i].name, nick) == 0) {
- malloc_tsetdword(sd->ignore[i].name, 0, sizeof(sd->ignore[i].name));
- if (pos == -1) {
- WFIFOB(fd,3) = 0; // success
- WFIFOSET(fd, packet_len_table[0x0d1]);
- pos = i; // don't break, to remove ALL same nick
- }
- }
- if (pos == -1) {
- WFIFOB(fd,3) = 1; // fail
- WFIFOSET(fd, packet_len_table[0x0d1]);
- clif_wis_message(fd, wisp_server_name, "This player is not blocked by you.", strlen("This player is not blocked by you.") + 1);
- }
- }
- }
- // for(i = 0; i < MAX_IGNORE_LIST; i++) // for debug only
- // if (sd->ignore[i].name[0] != '\0')
- // printf("Ignored player: '%s'\n", sd->ignore[i].name);
- return;
- }
- void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd) { // Rewritten by [Yor]
- //printf("Ignore all: state: %d\n", RFIFOB(fd,2));
- RFIFOHEAD(fd);
- if (RFIFOB(fd,2) == 0) {// S 00d0 <type>len.B: 00 (/exall) deny all speech, 01 (/inall) allow all speech
- WFIFOHEAD(fd,packet_len_table[0xd2]);
- WFIFOW(fd,0) = 0x0d2; // R 00d2 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
- WFIFOB(fd,2) = 0;
- if (sd->ignoreAll == 0) {
- sd->ignoreAll = 1;
- WFIFOB(fd,3) = 0; // success
- WFIFOSET(fd, packet_len_table[0x0d2]);
- } else {
- WFIFOB(fd,3) = 1; // fail
- WFIFOSET(fd, packet_len_table[0x0d2]);
- clif_wis_message(fd, wisp_server_name, "You already block everyone.", strlen("You already block everyone.") + 1);
- }
- } else {
- WFIFOHEAD(fd,packet_len_table[0xd2]);
- WFIFOW(fd,0) = 0x0d2; // R 00d2 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
- WFIFOB(fd,2) = 1;
- if (sd->ignoreAll == 1) {
- sd->ignoreAll = 0;
- WFIFOB(fd,3) = 0; // success
- WFIFOSET(fd, packet_len_table[0x0d2]);
- } else {
- WFIFOB(fd,3) = 1; // fail
- WFIFOSET(fd, packet_len_table[0x0d2]);
- clif_wis_message(fd, wisp_server_name, "You already allow everyone.", strlen("You already allow everyone.") + 1);
- }
- }
- return;
- }
- /*==========================================
- * Wis拒否リスト
- *------------------------------------------
- */
- int pstrcmp(const void *a, const void *b)
- {
- return strcmp((char *)a, (char *)b);
- }
- void clif_parse_PMIgnoreList(int fd,struct map_session_data *sd)
- {
- int i,j=0,count=0;
- qsort (sd->ignore[0].name, MAX_IGNORE_LIST, sizeof(sd->ignore[0].name), pstrcmp);
- for(i = 0; i < MAX_IGNORE_LIST; i++){ //中身があるのを数える
- if(sd->ignore[i].name[0] != 0)
- count++;
- }
- WFIFOHEAD(fd, 4 + (NAME_LENGTH * count));
- WFIFOW(fd,0) = 0xd4;
- WFIFOW(fd,2) = 4 + (NAME_LENGTH * count);
- for(i = 0; i < MAX_IGNORE_LIST; i++){
- if(sd->ignore[i].name[0] != 0){
- memcpy(WFIFOP(fd, 4 + j * 24),sd->ignore[i].name, NAME_LENGTH);
- j++;
- }
- }
- WFIFOSET(fd, WFIFOW(fd,2));
- if(count >= MAX_IGNORE_LIST) //満タンなら最後の1個を消す
- sd->ignore[MAX_IGNORE_LIST - 1].name[0] = 0;
- return;
- }
- /*==========================================
- * スパノビの/doridoriによるSPR2倍
- *------------------------------------------
- */
- void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd) {
- if (sd->state.doridori) return;
- switch (sd->class_&MAPID_UPPERMASK)
- {
- case MAPID_SOUL_LINKER:
- case MAPID_STAR_GLADIATOR:
- case MAPID_TAEKWON:
- if (!sd->state.rest)
- break;
- case MAPID_SUPER_NOVICE:
- sd->state.doridori=1;
- break;
- }
- return;
- }
- /*==========================================
- * スパノビの爆裂波動
- *------------------------------------------
- */
- void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd)
- {
- if(sd){
- int nextbaseexp=pc_nextbaseexp(sd);
- if (battle_config.etc_log){
- if(nextbaseexp != 0)
- ShowInfo("SuperNovice explosionspirits!! %d %d %d %d\n",sd->bl.id,sd->status.class_,sd->status.base_exp,(int)((double)1000*sd->status.base_exp/nextbaseexp));
- else
- ShowInfo("SuperNovice explosionspirits!! %d %d %d 000\n",sd->bl.id,sd->status.class_,sd->status.base_exp);
- }
- if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->status.base_exp > 0 && nextbaseexp > 0 && (int)((double)1000*sd->status.base_exp/nextbaseexp)%100==0){
- clif_skill_nodamage(&sd->bl,&sd->bl,MO_EXPLOSIONSPIRITS,5,
- sc_start(&sd->bl,SkillStatusChangeTable(MO_EXPLOSIONSPIRITS),100,
- 5,skill_get_time(MO_EXPLOSIONSPIRITS,5)));
- }
- }
- return;
- }
- // random notes:
- // 0x214: monster/player info ?
- /*==========================================
- * Friends List
- *------------------------------------------
- */
- void clif_friendslist_toggle(struct map_session_data *sd,int account_id, int char_id, int online)
- { //Toggles a single friend online/offline [Skotlex]
- int i;
- //Seek friend.
- for (i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id &&
- (sd->status.friends[i].char_id != char_id || sd->status.friends[i].account_id != account_id); i++);
- if(i == MAX_FRIENDS || sd->status.friends[i].char_id == 0)
- return; //Not found
- WFIFOHEAD(sd->fd,packet_len_table[0x206]);
- WFIFOW(sd->fd, 0) = 0x206;
- WFIFOL(sd->fd, 2) = sd->status.friends[i].account_id;
- WFIFOL(sd->fd, 6) = sd->status.friends[i].char_id;
- WFIFOB(sd->fd,10) = !online; //Yeah, a 1 here means "logged off", go figure...
-
- WFIFOSET(sd->fd, packet_len_table[0x206]);
- }
- //Subfunction called from clif_foreachclient to toggle friends on/off [Skotlex]
- int clif_friendslist_toggle_sub(struct map_session_data *sd,va_list ap)
- {
- int account_id, char_id, online;
- account_id = va_arg(ap, int);
- char_id = va_arg(ap, int);
- online = va_arg(ap, int);
- clif_friendslist_toggle(sd, account_id, char_id, online);
- return 0;
- }
- //For sending the whole friends list.
- void clif_friendslist_send(struct map_session_data *sd) {
- int i = 0, n;
-
- // Send friends list
- WFIFOHEAD(sd->fd, MAX_FRIENDS * 32 + 4);
- WFIFOW(sd->fd, 0) = 0x201;
- for(i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id; i++)
- {
- WFIFOL(sd->fd, 4 + 32 * i + 0) = sd->status.friends[i].account_id;
- WFIFOL(sd->fd, 4 + 32 * i + 4) = sd->status.friends[i].char_id;
- memcpy(WFIFOP(sd->fd, 4 + 32 * i + 8), &sd->status.friends[i].name, NAME_LENGTH);
- }
- if (i) {
- WFIFOW(sd->fd,2) = 4 + 32 * i;
- WFIFOSET(sd->fd, WFIFOW(sd->fd,2));
- }
-
- for (n = 0; n < i; n++)
- { //Sending the online players
- if (map_charid2sd(sd->status.friends[n].char_id))
- clif_friendslist_toggle(sd, sd->status.friends[n].account_id, sd->status.friends[n].char_id, 1);
- }
- }
- // Status for adding friend - 0: successfull 1: not exist/rejected 2: over limit
- void clif_friendslist_reqack(struct map_session_data *sd, struct map_session_data *f_sd, int type)
- {
- int fd;
- nullpo_retv(sd);
- fd = sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x209]);
- WFIFOW(fd,0) = 0x209;
- WFIFOW(fd,2) = type;
- if (f_sd)
- {
- WFIFOW(fd,4) = f_sd->status.account_id;
- WFIFOW(fd,8) = f_sd->status.char_id;
- memcpy(WFIFOP(fd, 12), f_sd->status.name,NAME_LENGTH);
- }
- WFIFOSET(fd, packet_len_table[0x209]);
- }
- void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) {
- struct map_session_data *f_sd;
- int i, f_fd;
- RFIFOHEAD(fd);
- f_sd = map_nick2sd((char*)RFIFOP(fd,2));
- // Friend doesn't exist (no player with this name)
- if (f_sd == NULL) {
- clif_displaymessage(fd, msg_txt(3));
- return;
- }
- // @noask [LuzZza]
- if(f_sd->state.noask) {
- clif_noask_sub(sd, f_sd, 5);
- return;
- }
- // Friend already exists
- for (i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id != 0; i++) {
- if (sd->status.friends[i].char_id == f_sd->status.char_id) {
- clif_displaymessage(fd, "Friend already exists.");
- return;
- }
- }
- if (i == MAX_FRIENDS) {
- //No space, list full.
- clif_friendslist_reqack(sd, f_sd, 2);
- return;
- }
-
- f_fd = f_sd->fd;
- WFIFOHEAD(f_fd,packet_len_table[0x207]);
- WFIFOW(f_fd,0) = 0x207;
- WFIFOL(f_fd,2) = sd->status.account_id;
- WFIFOL(f_fd,6) = sd->status.char_id;
- memcpy(WFIFOP(f_fd,10), sd->status.name, NAME_LENGTH);
- WFIFOSET(f_fd, packet_len_table[0x207]);
- return;
- }
- void clif_parse_FriendsListReply(int fd, struct map_session_data *sd) {
- //<W: id> <L: Player 1 chara ID> <L: Player 1 AID> <B: Response>
- struct map_session_data *f_sd;
- int char_id, account_id;
- char reply;
- RFIFOHEAD(fd);
- account_id = RFIFOL(fd,2);
- char_id = RFIFOL(fd,6);
- reply = RFIFOB(fd,10);
- //printf ("reply: %d %d %d\n", char_id, id, reply);
- f_sd = map_id2sd(account_id); //The account id is the same as the bl.id of players.
- if (f_sd == NULL)
- return;
-
- if (reply == 0)
- clif_friendslist_reqack(f_sd, sd, 1);
- else {
- int i;
- // Find an empty slot
- for (i = 0; i < MAX_FRIENDS; i++)
- if (f_sd->status.friends[i].char_id == 0)
- break;
- if (i == MAX_FRIENDS) {
- clif_friendslist_reqack(f_sd, sd, 2);
- return;
- }
- f_sd->status.friends[i].account_id = sd->status.account_id;
- f_sd->status.friends[i].char_id = sd->status.char_id;
- memcpy(f_sd->status.friends[i].name, sd->status.name, NAME_LENGTH);
- clif_friendslist_reqack(f_sd, sd, 0);
- if (battle_config.friend_auto_add) {
- // Also add f_sd to sd's friendlist.
- for (i = 0; i < MAX_FRIENDS; i++) {
- if (sd->status.friends[i].char_id == f_sd->status.char_id)
- return; //No need to add anything.
- if (sd->status.friends[i].char_id == 0)
- break;
- }
- if (i == MAX_FRIENDS) {
- clif_friendslist_reqack(sd, f_sd, 2);
- return;
- }
- sd->status.friends[i].account_id = f_sd->status.account_id;
- sd->status.friends[i].char_id = f_sd->status.char_id;
- memcpy(sd->status.friends[i].name, f_sd->status.name, NAME_LENGTH);
- clif_friendslist_reqack(sd, f_sd, 0);
- }
- }
- return;
- }
- void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) {
- // 0x203 </o> <ID to be removed W 4B>
- int account_id, char_id;
- int i, j;
- RFIFOHEAD(fd);
- account_id = RFIFOL(fd,2);
- char_id = RFIFOL(fd,6);
- // Search friend
- for (i = 0; i < MAX_FRIENDS &&
- (sd->status.friends[i].char_id != char_id || sd->status.friends[i].account_id != account_id); i++);
- if (i == MAX_FRIENDS) {
- clif_displaymessage(fd, "Name not found in list.");
- return;
- }
-
- // move all chars down
- for(j = i + 1; j < MAX_FRIENDS; j++)
- memcpy(&sd->status.friends[j-1], &sd->status.friends[j], sizeof(sd->status.friends[0]));
- malloc_set(&sd->status.friends[MAX_FRIENDS-1], 0, sizeof(sd->status.friends[MAX_FRIENDS-1]));
- clif_displaymessage(fd, "Friend removed");
-
- WFIFOHEAD(fd,packet_len_table[0x20a]);
- WFIFOW(fd,0) = 0x20a;
- WFIFOL(fd,2) = account_id;
- WFIFOL(fd,6) = char_id;
- WFIFOSET(fd, packet_len_table[0x20a]);
- // clif_friendslist_send(sd); //This is not needed anymore.
- return;
- }
- /*==========================================
- * /killall
- *------------------------------------------
- */
- void clif_parse_GMKillAll(int fd,struct map_session_data *sd)
- {
- char message[50];
- strncpy(message,sd->status.name, NAME_LENGTH);
- is_atcommand(fd, sd, strcat(message," : @kickall"),0);
- return;
- }
- /*==========================================
- * /pvpinfo
- *------------------------------------------
- */
- void clif_parse_PVPInfo(int fd,struct map_session_data *sd)
- {
- WFIFOHEAD(fd,packet_len_table[0x210]);
- WFIFOW(fd,0) = 0x210;
- //WFIFOL(fd,2) = 0; // not sure what for yet
- //WFIFOL(fd,6) = 0;
- WFIFOL(fd,10) = sd->pvp_won; // times won
- WFIFOL(fd,14) = sd->pvp_lost; // times lost
- WFIFOL(fd,18) = sd->pvp_point;
- WFIFOSET(fd, packet_len_table[0x210]);
- return;
- }
- /*==========================================
- * /blacksmith
- *------------------------------------------
- */
- void clif_parse_Blacksmith(int fd,struct map_session_data *sd)
- {
- int i;
- char *name;
- WFIFOHEAD(fd,packet_len_table[0x219]);
- WFIFOW(fd,0) = 0x219;
- //Packet size limits this list to 10 elements. [Skotlex]
- for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
- if (smith_fame_list[i].id > 0) {
- if (strcmp(smith_fame_list[i].name, "-") == 0 &&
- (name = map_charid2nick(smith_fame_list[i].id)) != NULL)
- {
- strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), name, NAME_LENGTH);
- } else
- strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), smith_fame_list[i].name, NAME_LENGTH);
- } else
- strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), "None", 5);
- WFIFOL(fd, 242 + i * 4) = smith_fame_list[i].fame;
- }
- for(;i < 10; i++) { //In case the MAX is less than 10.
- strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), "Unavailable", 12);
- WFIFOL(fd, 242 + i * 4) = 0;
- }
- WFIFOSET(fd, packet_len_table[0x219]);
- }
- int clif_fame_blacksmith(struct map_session_data *sd, int points)
- {
- int fd = sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x21b]);
- WFIFOW(fd,0) = 0x21b;
- WFIFOL(fd,2) = points;
- WFIFOL(fd,6) = sd->status.fame;
- WFIFOSET(fd, packet_len_table[0x21b]);
- return 0;
- }
- /*==========================================
- * /alchemist
- *------------------------------------------
- */
- void clif_parse_Alchemist(int fd,struct map_session_data *sd)
- {
- int i;
- char *name;
- WFIFOHEAD(fd,packet_len_table[0x21a]);
- WFIFOW(fd,0) = 0x21a;
- //Packet size limits this list to 10 elements. [Skotlex]
- for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
- if (chemist_fame_list[i].id > 0) {
- if (strcmp(chemist_fame_list[i].name, "-") == 0 &&
- (name = map_charid2nick(chemist_fame_list[i].id)) != NULL)
- {
- memcpy(WFIFOP(fd, 2 + 24 * i), name, NAME_LENGTH);
- } else
- memcpy(WFIFOP(fd, 2 + 24 * i), chemist_fame_list[i].name, NAME_LENGTH);
- } else
- memcpy(WFIFOP(fd, 2 + 24 * i), "None", NAME_LENGTH);
- WFIFOL(fd, 242 + i * 4) = chemist_fame_list[i].fame;
- }
- for(;i < 10; i++) { //In case the MAX is less than 10.
- memcpy(WFIFOP(fd, 2 + 24 * i), "Unavailable", NAME_LENGTH);
- WFIFOL(fd, 242 + i * 4) = 0;
- }
- WFIFOSET(fd, packet_len_table[0x21a]);
- }
- int clif_fame_alchemist(struct map_session_data *sd, int points)
- {
- int fd = sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x21c]);
- WFIFOW(fd,0) = 0x21c;
- WFIFOL(fd,2) = points;
- WFIFOL(fd,6) = sd->status.fame;
- WFIFOSET(fd, packet_len_table[0x21c]);
-
- return 0;
- }
- /*==========================================
- * /taekwon
- *------------------------------------------
- */
- void clif_parse_Taekwon(int fd,struct map_session_data *sd)
- {
- int i;
- char *name;
- WFIFOHEAD(fd,packet_len_table[0x226]);
- WFIFOW(fd,0) = 0x226;
- //Packet size limits this list to 10 elements. [Skotlex]
- for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
- if (taekwon_fame_list[i].id > 0) {
- if (strcmp(taekwon_fame_list[i].name, "-") == 0 &&
- (name = map_charid2nick(taekwon_fame_list[i].id)) != NULL)
- {
- memcpy(WFIFOP(fd, 2 + 24 * i), name, NAME_LENGTH);
- } else
- memcpy(WFIFOP(fd, 2 + 24 * i), taekwon_fame_list[i].name, NAME_LENGTH);
- } else
- memcpy(WFIFOP(fd, 2 + 24 * i), "None", NAME_LENGTH);
- WFIFOL(fd, 242 + i * 4) = taekwon_fame_list[i].fame;
- }
- for(;i < 10; i++) { //In case the MAX is less than 10.
- memcpy(WFIFOP(fd, 2 + 24 * i), "Unavailable", NAME_LENGTH);
- WFIFOL(fd, 242 + i * 4) = 0;
- }
- WFIFOSET(fd, packet_len_table[0x226]);
- }
- int clif_fame_taekwon(struct map_session_data *sd, int points)
- {
- int fd = sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x224]);
- WFIFOW(fd,0) = 0x224;
- WFIFOL(fd,2) = points;
- WFIFOL(fd,6) = sd->status.fame;
- WFIFOSET(fd, packet_len_table[0x224]);
-
- return 0;
- }
- /*==========================================
- * PK Ranking table?
- *------------------------------------------
- */
- void clif_parse_RankingPk(int fd,struct map_session_data *sd)
- {
- int i;
- WFIFOHEAD(fd,packet_len_table[0x238]);
- WFIFOW(fd,0) = 0x238;
- for(i=0;i<10;i++){
- memcpy(WFIFOP(fd,i*24+2), "Unknown", NAME_LENGTH);
- WFIFOL(fd,i*4+242) = 0;
- }
- WFIFOSET(fd, packet_len_table[0x238]);
- return;
- }
- /*==========================================
- * SG Feel save OK [Komurka]
- *------------------------------------------
- */
- void clif_parse_FeelSaveOk(int fd,struct map_session_data *sd)
- {
- char feel_var[3][NAME_LENGTH] = {"PC_FEEL_SUN","PC_FEEL_MOON","PC_FEEL_STAR"};
- int i;
- if (sd->menuskill_id != SG_FEEL)
- return;
- i = sd->menuskill_lv-1;
- if (i<0 || i > 2) return; //Bug?
- sd->feel_map[i].index = map[sd->bl.m].index;
- sd->feel_map[i].m = sd->bl.m;
- pc_setglobalreg(sd,feel_var[i],map[sd->bl.m].index);
- //Are these really needed? Shouldn't they show up automatically from the feel save packet?
- // clif_misceffect2(&sd->bl, 0x1b0);
- // clif_misceffect2(&sd->bl, 0x21f);
- clif_feel_info(sd, i, 0);
- sd->menuskill_lv = sd->menuskill_id = 0;
- }
- /*==========================================
- * Question about Star Glaldiator save map [Komurka]
- *------------------------------------------
- */
- void clif_parse_ReqFeel(int fd, struct map_session_data *sd, int skilllv) {
- WFIFOHEAD(fd,packet_len_table[0x253]);
- WFIFOW(fd,0)=0x253;
- WFIFOSET(fd, packet_len_table[0x253]);
- sd->menuskill_id=SG_FEEL;
- sd->menuskill_lv=skilllv;
- }
- void clif_parse_AdoptRequest(int fd,struct map_session_data *sd) {
- //TODO: add somewhere the adopt code, checks for exploits, etc, etc.
- //Missing packets are the client's reply packets to the adopt request one.
- //[Skotlex]
- int account_id;
- struct map_session_data *sd2;
- RFIFOHEAD(fd);
-
- account_id = RFIFOL(fd,2);
- sd2 = map_id2sd(account_id);
- if(sd2 && sd2->fd && sd2 != sd && sd2->status.party_id == sd->status.party_id) { //FIXME: No checks whatsoever are in place yet!
- fd = sd2->fd;
- WFIFOHEAD(fd,packet_len_table[0x1f9]);
- WFIFOW(fd,0)=0x1f9;
- WFIFOSET(fd, packet_len_table[0x1f9]);
- }
- }
- /*==========================================
- * パケットデバッグ
- *------------------------------------------
- */
- void clif_parse_debug(int fd,struct map_session_data *sd)
- {
- int i, cmd, len;
- RFIFOHEAD(fd);
- cmd = RFIFOW(fd,0);
- len = sd?packet_db[sd->packet_ver][cmd].len:RFIFOREST(fd); //With no session, just read the remaining in the buffer.
- ShowDebug("packet debug 0x%4X\n",cmd);
- printf("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
- for(i=0;i<len;i++){
- if((i&15)==0)
- printf("\n%04X ",i);
- printf("%02X ",RFIFOB(fd,i));
- }
- printf("\n");
- }
- /*==========================================
- * クライアントからのパケット解析
- * socket.cのdo_parsepacketから呼び出される
- *------------------------------------------
- */
- int clif_parse(int fd) {
- int packet_len = 0, cmd, packet_ver, dump = 0;
- struct map_session_data *sd;
- RFIFOHEAD(fd);
- if (fd <= 0)
- { //Just in case, there are some checks for this later down below anyway which should be removed. [Skotlex]
- ShowError("clif_parse: Received invalid session %d\n", fd);
- return 0;
- }
- sd = (struct map_session_data*)session[fd]->session_data;
- /* This behaviour has been deprecated due to actually causing trouble instead
- * of helping against exploits ~.~ [Skotlex]
- if (!chrif_isconnect())
- {
- ShowInfo("Closing session #%d (Not connected to Char server)\n", fd);
- if (sd && sd->state.auth)
- clif_quitsave(fd, sd); // the function doesn't send to inter-server/char-server if it is not connected [Yor]
- do_close(fd);
- return 0;
- } else
- */
- if (session[fd]->eof) {
- if (sd && sd->state.autotrade) {
- //Disassociate character from the socket connection.
- session[fd]->session_data = NULL;
- sd->fd = 0;
- ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off (using @autotrade).\n", (pc_isGM(sd))?"GM ":"",sd->status.name); // Player logout display [Valaris]
- } else if (sd && sd->state.auth) {
- clif_quitsave(fd, sd); // the function doesn't send to inter-server/char-server if it is not connected [Yor]
- if (sd->status.name != NULL)
- ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off.\n", (pc_isGM(sd))?"GM ":"",sd->status.name); // Player logout display [Valaris]
- else
- ShowInfo("%sCharacter with Account ID '"CL_WHITE"%d"CL_RESET"' logged off.\n", (pc_isGM(sd))?"GM ":"", sd->bl.id); // Player logout display [Yor]
- } else {
- unsigned char *ip = (unsigned char *) &session[fd]->client_addr.sin_addr;
- ShowInfo("Player not identified with IP '"CL_WHITE"%d.%d.%d.%d"CL_RESET"' logged off.\n", ip[0],ip[1],ip[2],ip[3]);
- }
- do_close(fd);
- return 0;
- }
- if (RFIFOREST(fd) < 2)
- return 0;
- // printf("clif_parse: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
- cmd = RFIFOW(fd,0);
- // 管理用パケット処理
- if (cmd >= 30000) {
- switch(cmd) {
- case 0x7530: { //Why are we letting people know which version we are running?
- WFIFOHEAD(fd, 10);
- WFIFOW(fd,0) = 0x7531;
- WFIFOB(fd,2) = ATHENA_MAJOR_VERSION;
- WFIFOB(fd,3) = ATHENA_MINOR_VERSION;
- WFIFOB(fd,4) = ATHENA_REVISION;
- WFIFOB(fd,5) = ATHENA_RELEASE_FLAG;
- WFIFOB(fd,6) = ATHENA_OFFICIAL_FLAG;
- WFIFOB(fd,7) = ATHENA_SERVER_MAP;
- WFIFOW(fd,8) = ATHENA_MOD_VERSION;
- WFIFOSET(fd,10);
- RFIFOSKIP(fd,2);
- break;
- }
- case 0x7532: // 接続の切断
- ShowWarning("clif_parse: session #%d disconnected for sending packet 0x04%x\n", fd, cmd);
- session[fd]->eof=1;
- break;
- default:
- ShowWarning("Unknown incoming packet (command: 0x%04x, session: %d), disconnecting.\n", cmd, fd);
- session[fd]->eof=1;
- break;
- }
- return 0;
- }
- // get packet version before to parse
- packet_ver = 0;
- if (sd) {
- packet_ver = sd->packet_ver;
- if (packet_ver < 0 || packet_ver > MAX_PACKET_VER) { // This should never happen unless we have some corrupted memory issues :X [Skotlex]
- session[fd]->eof = 1;
- return 0;
- }
- } else {
- // check authentification packet to know packet version
- packet_ver = clif_guess_PacketVer(fd, 0);
- // check if version is accepted
- if (packet_ver < 5 || // reject really old client versions
- (packet_ver <= 9 && (battle_config.packet_ver_flag & 1) == 0) || // older than 6sept04
- (packet_ver > 9 && (battle_config.packet_ver_flag & 1<<(packet_ver-9)) == 0) ||
- packet_ver > MAX_PACKET_VER) // no packet version support yet
- {
- ShowInfo("clif_parse: Disconnecting session #%d for not having latest client version (has version %d).\n", fd, packet_ver);
- WFIFOHEAD(fd, 23);
- WFIFOW(fd,0) = 0x6a;
- WFIFOB(fd,2) = 5; // 05 = Game's EXE is not the latest version
- WFIFOSET(fd,23);
- packet_len = RFIFOREST(fd);
- RFIFOSKIP(fd, packet_len);
- clif_setwaitclose(fd);
- if (session[fd]->func_send) //socket.c doesn't wants to send the data when left on it's own... [Skotlex]
- session[fd]->func_send(fd);
- return 0;
- }
- }
- // ゲーム用以外パケットか、認証を終える前に0072以外が来たら、切断する
- if (cmd >= MAX_PACKET_DB || packet_db[packet_ver][cmd].len == 0) { // if packet is not inside these values: session is incorrect?? or auth packet is unknown
- ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x, %d bytes received), disconnecting session #%d.\n", cmd, RFIFOREST(fd), fd);
- session[fd]->eof = 1;
- return 0;
- }
- // パケット長を計算
- packet_len = packet_db[packet_ver][cmd].len;
- if (packet_len == -1) {
- if (RFIFOREST(fd) < 4)
- return 0; // 可変長パケットで長さの所までデータが来てない
- packet_len = RFIFOW(fd,2);
- if (packet_len < 4 || packet_len > 32768) {
- ShowWarning("clif_parse: Packet 0x%04x specifies invalid packet_len (%d), disconnecting session #%d.\n", cmd, packet_len, fd);
- session[fd]->eof =1;
- return 0;
- }
- }
- if ((int)RFIFOREST(fd) < packet_len)
- return 0; // まだ1パケット分データが揃ってない
- #if DUMP_ALL_PACKETS
- {
- int i;
- FILE *fp;
- char packet_txt[256] = "save/packet.txt";
- time_t now;
- dump = 1;
- if ((fp = fopen(packet_txt, "a")) == NULL) {
- ShowError("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt);
- return 1;
- } else {
- time(&now);
- if (sd && sd->state.auth) {
- if (sd->status.name != NULL)
- fprintf(fp, "%sPlayer with account ID %d (character ID %d, player name %s) sent packet:\n",
- asctime(localtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name);
- else
- fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
- } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
- fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
- fprintf(fp, "\tsession #%d, packet 0x%04x, length %d, version %d\n", fd, cmd, packet_len, packet_ver);
- fprintf(fp, "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
- for(i = 0; i < packet_len; i++) {
- if ((i & 15) == 0)
- fprintf(fp, "\n\t%04X ", i);
- fprintf(fp, "%02X ", RFIFOB(fd,i));
- }
- fprintf(fp, "\n\n");
- fclose(fp);
- }
- }
- #endif
- if (sd && sd->state.auth == 1 && sd->state.waitingdisconnect == 1) { // 切断待ちの場合パケットを処理しない
- } else if (packet_db[packet_ver][cmd].func) {
- if (sd && sd->bl.prev == NULL &&
- packet_db[packet_ver][cmd].func != clif_parse_LoadEndAck)
- ; //Only valid packet when player is not on a map is the finish-loading packet.
- else
- if (sd
- || packet_db[packet_ver][cmd].func == clif_parse_WantToConnection
- || packet_db[packet_ver][cmd].func == clif_parse_debug
- ) //Only execute the function when there's an sd (except for debug/wanttoconnect packets)
- packet_db[packet_ver][cmd].func(fd, sd);
- } else {
- // 不明なパケット
- if (battle_config.error_log) {
- #if DUMP_UNKNOWN_PACKET
- {
- int i;
- FILE *fp;
- char packet_txt[256] = "save/packet.txt";
- time_t now;
- dump = 1;
- if ((fp = fopen(packet_txt, "a")) == NULL) {
- ShowError("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt);
- return 1;
- } else {
- time(&now);
- if (sd && sd->state.auth) {
- if (sd->status.name != NULL)
- fprintf(fp, "%sPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n",
- asctime(localtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name);
- else
- fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
- } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
- fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
- fprintf(fp, "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
- for(i = 0; i < packet_len; i++) {
- if ((i & 15) == 0)
- fprintf(fp, "\n\t%04X ", i);
- fprintf(fp, "%02X ", RFIFOB(fd,i));
- }
- fprintf(fp, "\n\n");
- fclose(fp);
- }
- }
- #endif
- }
- }
- if (dump) {
- int i;
- if (fd)
- ShowDebug("\nclif_parse: session #%d, packet 0x%04x, length %d, version %d\n", fd, cmd, packet_len, packet_ver);
- printf("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
- for(i = 0; i < packet_len; i++) {
- if ((i & 15) == 0)
- printf("\n%04X ",i);
- printf("%02X ", RFIFOB(fd,i));
- }
- printf("\n");
- if (sd && sd->state.auth) {
- if (sd->status.name != NULL)
- printf("\nAccount ID %d, character ID %d, player name %s.\n",
- sd->status.account_id, sd->status.char_id, sd->status.name);
- else
- printf("\nAccount ID %d.\n", sd->bl.id);
- } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
- printf("\nAccount ID %d.\n", sd->bl.id);
- }
- RFIFOSKIP(fd, packet_len);
- return 0;
- }
- /*==========================================
- * パケットデータベース読み込み
- *------------------------------------------
- */
- static int packetdb_readdb(void)
- {
- FILE *fp;
- char line[1024];
- int ln=0;
- int cmd,i,j,k,packet_ver;
- char *str[64],*p,*str2[64],*p2,w1[64],w2[64];
- struct {
- void (*func)(int, struct map_session_data *);
- char *name;
- } clif_parse_func[]={
- {clif_parse_WantToConnection,"wanttoconnection"},
- {clif_parse_LoadEndAck,"loadendack"},
- {clif_parse_TickSend,"ticksend"},
- {clif_parse_WalkToXY,"walktoxy"},
- {clif_parse_QuitGame,"quitgame"},
- {clif_parse_GetCharNameRequest,"getcharnamerequest"},
- {clif_parse_GlobalMessage,"globalmessage"},
- {clif_parse_MapMove,"mapmove"},
- {clif_parse_ChangeDir,"changedir"},
- {clif_parse_Emotion,"emotion"},
- {clif_parse_HowManyConnections,"howmanyconnections"},
- {clif_parse_ActionRequest,"actionrequest"},
- {clif_parse_Restart,"restart"},
- {clif_parse_Wis,"wis"},
- {clif_parse_GMmessage,"gmmessage"},
- {clif_parse_TakeItem,"takeitem"},
- {clif_parse_DropItem,"dropitem"},
- {clif_parse_UseItem,"useitem"},
- {clif_parse_EquipItem,"equipitem"},
- {clif_parse_UnequipItem,"unequipitem"},
- {clif_parse_NpcClicked,"npcclicked"},
- {clif_parse_NpcBuySellSelected,"npcbuysellselected"},
- {clif_parse_NpcBuyListSend,"npcbuylistsend"},
- {clif_parse_NpcSellListSend,"npcselllistsend"},
- {clif_parse_CreateChatRoom,"createchatroom"},
- {clif_parse_ChatAddMember,"chataddmember"},
- {clif_parse_ChatRoomStatusChange,"chatroomstatuschange"},
- {clif_parse_ChangeChatOwner,"changechatowner"},
- {clif_parse_KickFromChat,"kickfromchat"},
- {clif_parse_ChatLeave,"chatleave"},
- {clif_parse_TradeRequest,"traderequest"},
- {clif_parse_TradeAck,"tradeack"},
- {clif_parse_TradeAddItem,"tradeadditem"},
- {clif_parse_TradeOk,"tradeok"},
- {clif_parse_TradeCancel,"tradecancel"},
- {clif_parse_TradeCommit,"tradecommit"},
- {clif_parse_StopAttack,"stopattack"},
- {clif_parse_PutItemToCart,"putitemtocart"},
- {clif_parse_GetItemFromCart,"getitemfromcart"},
- {clif_parse_RemoveOption,"removeoption"},
- {clif_parse_ChangeCart,"changecart"},
- {clif_parse_StatusUp,"statusup"},
- {clif_parse_SkillUp,"skillup"},
- {clif_parse_UseSkillToId,"useskilltoid"},
- {clif_parse_UseSkillToPos,"useskilltopos"},
- {clif_parse_UseSkillToPosMoreInfo,"useskilltoposinfo"},
- {clif_parse_UseSkillMap,"useskillmap"},
- {clif_parse_RequestMemo,"requestmemo"},
- {clif_parse_ProduceMix,"producemix"},
- {clif_parse_NpcSelectMenu,"npcselectmenu"},
- {clif_parse_NpcNextClicked,"npcnextclicked"},
- {clif_parse_NpcAmountInput,"npcamountinput"},
- {clif_parse_NpcStringInput,"npcstringinput"},
- {clif_parse_NpcCloseClicked,"npccloseclicked"},
- {clif_parse_ItemIdentify,"itemidentify"},
- {clif_parse_SelectArrow,"selectarrow"},
- {clif_parse_AutoSpell,"autospell"},
- {clif_parse_UseCard,"usecard"},
- {clif_parse_InsertCard,"insertcard"},
- {clif_parse_RepairItem,"repairitem"},
- {clif_parse_WeaponRefine,"weaponrefine"},
- {clif_parse_SolveCharName,"solvecharname"},
- {clif_parse_ResetChar,"resetchar"},
- {clif_parse_LGMmessage,"lgmmessage"},
- {clif_parse_MoveToKafra,"movetokafra"},
- {clif_parse_MoveFromKafra,"movefromkafra"},
- {clif_parse_MoveToKafraFromCart,"movetokafrafromcart"},
- {clif_parse_MoveFromKafraToCart,"movefromkafratocart"},
- {clif_parse_CloseKafra,"closekafra"},
- {clif_parse_CreateParty,"createparty"},
- {clif_parse_CreateParty2,"createparty2"},
- {clif_parse_PartyInvite,"partyinvite"},
- {clif_parse_ReplyPartyInvite,"replypartyinvite"},
- {clif_parse_LeaveParty,"leaveparty"},
- {clif_parse_RemovePartyMember,"removepartymember"},
- {clif_parse_PartyChangeOption,"partychangeoption"},
- {clif_parse_PartyMessage,"partymessage"},
- {clif_parse_CloseVending,"closevending"},
- {clif_parse_VendingListReq,"vendinglistreq"},
- {clif_parse_PurchaseReq,"purchasereq"},
- {clif_parse_OpenVending,"openvending"},
- {clif_parse_CreateGuild,"createguild"},
- {clif_parse_GuildCheckMaster,"guildcheckmaster"},
- {clif_parse_GuildRequestInfo,"guildrequestinfo"},
- {clif_parse_GuildChangePositionInfo,"guildchangepositioninfo"},
- {clif_parse_GuildChangeMemberPosition,"guildchangememberposition"},
- {clif_parse_GuildRequestEmblem,"guildrequestemblem"},
- {clif_parse_GuildChangeEmblem,"guildchangeemblem"},
- {clif_parse_GuildChangeNotice,"guildchangenotice"},
- {clif_parse_GuildInvite,"guildinvite"},
- {clif_parse_GuildReplyInvite,"guildreplyinvite"},
- {clif_parse_GuildLeave,"guildleave"},
- {clif_parse_GuildExpulsion,"guildexplusion"},
- {clif_parse_GuildMessage,"guildmessage"},
- {clif_parse_GuildRequestAlliance,"guildrequestalliance"},
- {clif_parse_GuildReplyAlliance,"guildreplyalliance"},
- {clif_parse_GuildDelAlliance,"guilddelalliance"},
- {clif_parse_GuildOpposition,"guildopposition"},
- {clif_parse_GuildBreak,"guildbreak"},
- {clif_parse_PetMenu,"petmenu"},
- {clif_parse_CatchPet,"catchpet"},
- {clif_parse_SelectEgg,"selectegg"},
- {clif_parse_SendEmotion,"sendemotion"},
- {clif_parse_ChangePetName,"changepetname"},
- {clif_parse_GMKick,"gmkick"},
- {clif_parse_GMHide,"gmhide"},
- {clif_parse_GMReqNoChat,"gmreqnochat"},
- {clif_parse_GMReqNoChatCount,"gmreqnochatcount"},
- {clif_parse_NoviceDoriDori,"sndoridori"},
- {clif_parse_NoviceExplosionSpirits,"snexplosionspirits"},
- {clif_parse_PMIgnore,"wisexin"},
- {clif_parse_PMIgnoreList,"wisexlist"},
- {clif_parse_PMIgnoreAll,"wisall"},
- {clif_parse_FriendsListAdd,"friendslistadd"},
- {clif_parse_FriendsListRemove,"friendslistremove"},
- {clif_parse_FriendsListReply,"friendslistreply"},
- {clif_parse_GMKillAll,"killall"},
- {clif_parse_Recall,"summon"},
- {clif_parse_GM_Monster_Item,"itemmonster"},
- {clif_parse_Shift,"shift"},
- {clif_parse_Blacksmith,"blacksmith"},
- {clif_parse_Alchemist,"alchemist"},
- {clif_parse_Taekwon,"taekwon"},
- {clif_parse_RankingPk,"rankingpk"},
- {clif_parse_FeelSaveOk,"feelsaveok"},
- {clif_parse_AdoptRequest,"adopt"},
- {clif_parse_debug,"debug"},
- //[blackhole89] //[orn]
- {clif_parse_ChangeHomunculusName,"changehomunculusname"},
- {clif_parse_HomMoveToMaster,"hommovetomaster"},
- {clif_parse_HomMoveTo,"hommoveto"},
- {clif_parse_HomAttack,"homattack"},
- {clif_parse_HomMenu,"hommenu"},
- {NULL,NULL}
- };
- sprintf(line, "%s/packet_db.txt", db_path);
- if( (fp=fopen(line,"r"))==NULL ){
- ShowFatalError("can't read %s\n", line);
- exit(1);
- }
- clif_config.packet_db_ver = MAX_PACKET_VER;
- packet_ver = MAX_PACKET_VER; // read into packet_db's version by default
- while(fgets(line,1020,fp)){
- if(line[0]=='/' && line[1]=='/')
- continue;
- if (sscanf(line,"%[^:]: %[^\r\n]",w1,w2) == 2) {
- if(strcmpi(w1,"packet_ver")==0) {
- int prev_ver = packet_ver;
- packet_ver = atoi(w2);
- if (packet_ver > MAX_PACKET_VER)
- { //Check to avoid overflowing. [Skotlex]
- ShowWarning("The packet_db table only has support up to version %d\n", MAX_PACKET_VER);
- break;
- }
- // copy from previous version into new version and continue
- // - indicating all following packets should be read into the newer version
- memcpy(&packet_db[packet_ver], &packet_db[prev_ver], sizeof(packet_db[0]));
- continue;
- } else if(strcmpi(w1,"packet_db_ver")==0) {
- //This is the preferred version.
- if(strcmpi(w2,"default")==0)
- clif_config.packet_db_ver = MAX_PACKET_VER;
- else {
- // to manually set the packet DB version
- clif_config.packet_db_ver = atoi(w2);
- // check for invalid version
- if (clif_config.packet_db_ver > MAX_PACKET_VER ||
- clif_config.packet_db_ver < 0)
- clif_config.packet_db_ver = MAX_PACKET_VER;
- }
- continue;
- }
- }
- malloc_tsetdword(str,0,sizeof(str));
- for(j=0,p=line;j<4 && p;j++){
- str[j]=p;
- p=strchr(p,',');
- if(p) *p++=0;
- }
- if(str[0]==NULL)
- continue;
- cmd=strtol(str[0],(char **)NULL,0);
- if(cmd<=0 || cmd>=MAX_PACKET_DB)
- continue;
- if(str[1]==NULL){
- ShowError("packet_db: packet len error\n");
- continue;
- }
- k = atoi(str[1]);
- packet_db[packet_ver][cmd].len = k;
- if(str[2]==NULL){
- packet_db[packet_ver][cmd].func = NULL;
- ln++;
- continue;
- }
- for(j=0;j<sizeof(clif_parse_func)/sizeof(clif_parse_func[0]);j++){
- if(clif_parse_func[j].name != NULL &&
- strcmp(str[2],clif_parse_func[j].name)==0)
- {
- if (packet_db[packet_ver][cmd].func != clif_parse_func[j].func)
- { //If we are updating a function, we need to zero up the previous one. [Skotlex]
- for(i=0;i<MAX_PACKET_DB;i++){
- if (packet_db[packet_ver][i].func == clif_parse_func[j].func)
- {
- malloc_tsetword(&packet_db[packet_ver][i], 0, sizeof(struct packet_db));
- break;
- }
- }
- }
- packet_db[packet_ver][cmd].func = clif_parse_func[j].func;
- break;
- }
- }
- // set the identifying cmd for the packet_db version
- if (strcmp(str[2],"wanttoconnection")==0)
- clif_config.connect_cmd[packet_ver] = cmd;
-
- if(str[3]==NULL){
- ShowError("packet_db: packet error\n");
- exit(1);
- }
- for(j=0,p2=str[3];p2;j++){
- str2[j]=p2;
- p2=strchr(p2,':');
- if(p2) *p2++=0;
- k = atoi(str2[j]);
- // if (packet_db[packet_ver][cmd].pos[j] != k && clif_config.prefer_packet_db) // not used for now
- packet_db[packet_ver][cmd].pos[j] = k;
- }
- ln++;
- // if(packet_db[clif_config.packet_db_ver][cmd].len > 2 /* && packet_db[cmd].pos[0] == 0 */)
- // printf("packet_db ver %d: %d 0x%x %d %s %p\n",packet_ver,ln,cmd,packet_db[packet_ver][cmd].len,str[2],packet_db[packet_ver][cmd].func);
- }
- fclose(fp);
- if (!clif_config.connect_cmd[clif_config.packet_db_ver])
- { //Locate the nearest version that we still support. [Skotlex]
- for(j = clif_config.packet_db_ver; j >= 0 && !clif_config.connect_cmd[j]; j--);
-
- clif_config.packet_db_ver = j?j:MAX_PACKET_VER;
- }
- ShowStatus("Done reading packet database from '"CL_WHITE"%s"CL_RESET"'. Using default packet version: "CL_WHITE"%d"CL_RESET".\n", "packet_db.txt", clif_config.packet_db_ver);
- return 0;
- }
- /*==========================================
- *
- *------------------------------------------
- */
- int do_init_clif(void) {
-
- clif_config.packet_db_ver = -1; // the main packet version of the DB
- malloc_tsetdword(clif_config.connect_cmd, 0, sizeof(clif_config.connect_cmd)); //The default connect command will be determined after reading the packet_db [Skotlex]
- malloc_tsetword(packet_db,0,sizeof(packet_db));
- //Using the packet_db file is the only way to set up packets now [Skotlex]
- packetdb_readdb();
- set_defaultparse(clif_parse);
- if (!make_listen_bind(bind_ip,map_port)) {
- ShowFatalError("cant bind game port\n");
- exit(1);
- }
- add_timer_func_list(clif_waitclose, "clif_waitclose");
- add_timer_func_list(clif_clearchar_delay_sub, "clif_clearchar_delay_sub");
- add_timer_func_list(clif_delayquit, "clif_delayquit");
- add_timer_func_list(clif_nighttimer, "clif_nighttimer");
- add_timer_func_list(clif_walktoxy_timer, "clif_walktoxy_timer");
- return 0;
- }
|