clif.c 303 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332
  1. // $Id: clif.c 2200 2004-11-07 11:49:58Z Yor $
  2. #define DUMP_UNKNOWN_PACKET 1
  3. #include <stdio.h>
  4. #include <ctype.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <stdarg.h>
  8. #ifdef __WIN32
  9. #define __USE_W32_SOCKETS
  10. #include <windows.h>
  11. #else
  12. #include <unistd.h>
  13. #include <sys/types.h>
  14. #include <sys/socket.h>
  15. #include <netinet/in.h>
  16. #include <arpa/inet.h>
  17. #endif
  18. #include <time.h>
  19. #include "../common/socket.h"
  20. #include "../common/timer.h"
  21. #include "../common/malloc.h"
  22. #include "../common/version.h"
  23. #include "../common/nullpo.h"
  24. #include "../common/showmsg.h"
  25. #include "map.h"
  26. #include "chrif.h"
  27. #include "clif.h"
  28. #include "pc.h"
  29. #include "npc.h"
  30. #include "itemdb.h"
  31. #include "chat.h"
  32. #include "trade.h"
  33. #include "storage.h"
  34. #include "script.h"
  35. #include "skill.h"
  36. #include "atcommand.h"
  37. #include "charcommand.h"
  38. #include "intif.h"
  39. #include "battle.h"
  40. #include "mob.h"
  41. #include "party.h"
  42. #include "guild.h"
  43. #include "vending.h"
  44. #include "pet.h"
  45. #ifdef MEMWATCH
  46. #include "memwatch.h"
  47. #endif
  48. #define STATE_BLIND 0x10
  49. struct Clif_Config clif_config;
  50. struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB];
  51. #define USE_PACKET_DB(sd) \
  52. clif_config.enable_packet_db && sd->packet_ver == clif_config.packet_db_ver
  53. #define IS_PACKET_DB_VER(cmd) \
  54. cmd == clif_config.connect_cmd
  55. static const int packet_len_table[MAX_PACKET_DB] = {
  56. 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  57. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  58. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  59. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  60. //#0x0040
  61. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  62. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  63. 0, 0, 0, 0, 55, 17, 3, 37, 46, -1, 23, -1, 3,108, 3, 2,
  64. #if PACKETVER < 2
  65. 3, 28, 19, 11, 3, -1, 9, 5, 52, 51, 56, 58, 41, 2, 6, 6,
  66. #else // 78-7b 亀島以降 lv99エフェクト用
  67. 3, 28, 19, 11, 3, -1, 9, 5, 54, 53, 58, 60, 41, 2, 6, 6,
  68. #endif
  69. //#0x0080
  70. 7, 3, 2, 2, 2, 5, 16, 12, 10, 7, 29, 2, -1, -1, -1, 0, // 0x8b changed to 2 (was 23)
  71. 7, 22, 28, 2, 6, 30, -1, -1, 3, -1, -1, 5, 9, 17, 17, 6,
  72. 23, 6, 6, -1, -1, -1, -1, 8, 7, 6, 7, 4, 7, 0, -1, 6,
  73. 8, 8, 3, 3, -1, 6, 6, -1, 7, 6, 2, 5, 6, 44, 5, 3,
  74. //#0x00C0
  75. 7, 2, 6, 8, 6, 7, -1, -1, -1, -1, 3, 3, 6, 3, 2, 27, // 0xcd change to 3 (was 6)
  76. 3, 4, 4, 2, -1, -1, 3, -1, 6, 14, 3, -1, 28, 29, -1, -1,
  77. 30, 30, 26, 2, 6, 26, 3, 3, 8, 19, 5, 2, 3, 2, 2, 2,
  78. 3, 2, 6, 8, 21, 8, 8, 2, 2, 26, 3, -1, 6, 27, 30, 10,
  79. //#0x0100
  80. 2, 6, 6, 30, 79, 31, 10, 10, -1, -1, 4, 6, 6, 2, 11, -1,
  81. 10, 39, 4, 10, 31, 35, 10, 18, 2, 13, 15, 20, 68, 2, 3, 16,
  82. 6, 14, -1, -1, 21, 8, 8, 8, 8, 8, 2, 2, 3, 4, 2, -1,
  83. 6, 86, 6, -1, -1, 7, -1, 6, 3, 16, 4, 4, 4, 6, 24, 26,
  84. //#0x0140
  85. 22, 14, 6, 10, 23, 19, 6, 39, 8, 9, 6, 27, -1, 2, 6, 6,
  86. 110, 6, -1, -1, -1, -1, -1, 6, -1, 54, 66, 54, 90, 42, 6, 42,
  87. -1, -1, -1, -1, -1, 30, -1, 3, 14, 3, 30, 10, 43, 14,186,182,
  88. 14, 30, 10, 3, -1, 6,106, -1, 4, 5, 4, -1, 6, 7, -1, -1,
  89. //#0x0180
  90. 6, 3,106, 10, 10, 34, 0, 6, 8, 4, 4, 4, 29, -1, 10, 6,
  91. #if PACKETVER < 1
  92. 90, 86, 24, 6, 30,102, 8, 4, 8, 4, 14, 10, -1, 6, 2, 6,
  93. #else // 196 comodo以降 状態表示アイコン用
  94. 90, 86, 24, 6, 30,102, 9, 4, 8, 4, 14, 10, -1, 6, 2, 6,
  95. #endif
  96. 3, 3, 35, 5, 11, 26, -1, 4, 4, 6, 10, 12, 6, -1, 4, 4,
  97. 11, 7, -1, 67, 12, 18,114, 6, 3, 6, 26, 26, 26, 26, 2, 3,
  98. //#0x01C0, Set 0x1d5=-1
  99. 2, 14, 10, -1, 22, 22, 4, 2, 13, 97, 0, 9, 9, 30, 6, 28,
  100. 8, 14, 10, 35, 6, -1, 4, 11, 54, 53, 60, 2, -1, 47, 33, 6,
  101. 30, 8, 34, 14, 2, 6, 26, 2, 28, 81, 6, 10, 26, 2, -1, -1,
  102. -1, -1, 20, 10, 32, 9, 34, 14, 2, 6, 48, 56, -1, 4, 5, 10,
  103. //#0x200
  104. 26, -1, 26, 10, 18, 26, 11, 34, 14, 36, 10, 0, 0, -1, 24, 0, // 0x20c change to 0 (was 19)
  105. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  106. 0, 0, 0, 0
  107. };
  108. // local define
  109. enum {
  110. ALL_CLIENT,
  111. ALL_SAMEMAP,
  112. AREA,
  113. AREA_WOS,
  114. AREA_WOC,
  115. AREA_WOSC,
  116. AREA_CHAT_WOC,
  117. CHAT,
  118. CHAT_WOS,
  119. PARTY,
  120. PARTY_WOS,
  121. PARTY_SAMEMAP,
  122. PARTY_SAMEMAP_WOS,
  123. PARTY_AREA,
  124. PARTY_AREA_WOS,
  125. GUILD,
  126. GUILD_WOS,
  127. GUILD_SAMEMAP, // [Valaris]
  128. GUILD_SAMEMAP_WOS,
  129. GUILD_AREA,
  130. GUILD_AREA_WOS, // end additions [Valaris]
  131. SELF
  132. };
  133. #define WBUFPOS(p,pos,x,y) { unsigned char *__p = (p); __p+=(pos); __p[0] = (x)>>2; __p[1] = ((x)<<6) | (((y)>>4)&0x3f); __p[2] = (y)<<4; }
  134. #define WBUFPOS2(p,pos,x0,y0,x1,y1) { unsigned char *__p = (p); __p+=(pos); __p[0] = (x0)>>2; __p[1] = ((x0)<<6) | (((y0)>>4)&0x3f); __p[2] = ((y0)<<4) | (((x1)>>6)&0x0f); __p[3]=((x1)<<2) | (((y1)>>8)&0x03); __p[4]=(y1); }
  135. #define WFIFOPOS(fd,pos,x,y) { WBUFPOS (WFIFOP(fd,pos),0,x,y); }
  136. #define WFIFOPOS2(fd,pos,x0,y0,x1,y1) { WBUFPOS2(WFIFOP(fd,pos),0,x0,y0,x1,y1); }
  137. static char map_ip_str[16];
  138. static in_addr_t map_ip;
  139. static int map_port = 5121;
  140. int map_fd;
  141. char talkie_mes[80];
  142. /*==========================================
  143. * map鯖のip設定
  144. *------------------------------------------
  145. */
  146. void clif_setip(char *ip)
  147. {
  148. memcpy(map_ip_str, ip, 16);
  149. map_ip = inet_addr(map_ip_str);
  150. }
  151. /*==========================================
  152. * map鯖のport設定
  153. *------------------------------------------
  154. */
  155. void clif_setport(int port)
  156. {
  157. map_port = port;
  158. }
  159. /*==========================================
  160. * map鯖のip読み出し
  161. *------------------------------------------
  162. */
  163. in_addr_t clif_getip(void)
  164. {
  165. return map_ip;
  166. }
  167. /*==========================================
  168. * map鯖のport読み出し
  169. *------------------------------------------
  170. */
  171. int clif_getport(void)
  172. {
  173. return map_port;
  174. }
  175. /*==========================================
  176. *
  177. *------------------------------------------
  178. */
  179. int clif_countusers(void)
  180. {
  181. int users = 0, i;
  182. struct map_session_data *sd;
  183. for(i = 0; i < fd_max; i++) {
  184. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd && sd->state.auth &&
  185. !(battle_config.hide_GM_session && pc_isGM(sd)))
  186. users++;
  187. }
  188. return users;
  189. }
  190. /*==========================================
  191. * 全てのclientに対してfunc()実行
  192. *------------------------------------------
  193. */
  194. int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...)
  195. {
  196. int i;
  197. va_list ap;
  198. struct map_session_data *sd;
  199. va_start(ap,func);
  200. for(i = 0; i < fd_max; i++) {
  201. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd && sd->state.auth)
  202. func(sd, ap);
  203. }
  204. va_end(ap);
  205. return 0;
  206. }
  207. /*==========================================
  208. * clif_sendでAREA*指定時用
  209. *------------------------------------------
  210. */
  211. int clif_send_sub(struct block_list *bl, va_list ap)
  212. {
  213. unsigned char *buf;
  214. int len;
  215. struct block_list *src_bl;
  216. int type;
  217. struct map_session_data *sd;
  218. nullpo_retr(0, bl);
  219. nullpo_retr(0, ap);
  220. nullpo_retr(0, sd = (struct map_session_data *)bl);
  221. buf = va_arg(ap,unsigned char*);
  222. len = va_arg(ap,int);
  223. nullpo_retr(0, src_bl = va_arg(ap,struct block_list*));
  224. type = va_arg(ap,int);
  225. switch(type) {
  226. case AREA_WOS:
  227. if (bl && bl == src_bl)
  228. return 0;
  229. break;
  230. case AREA_WOC:
  231. if ((sd && sd->chatID) || (bl && bl == src_bl))
  232. return 0;
  233. break;
  234. case AREA_WOSC:
  235. if ((sd) && sd->chatID && sd->chatID == ((struct map_session_data*)src_bl)->chatID)
  236. return 0;
  237. break;
  238. }
  239. if ((sd != NULL) && (session[sd->fd] != NULL)) {
  240. if (WFIFOP(sd->fd,0) == buf) {
  241. printf("WARNING: Invalid use of clif_send function\n");
  242. printf(" Packet x%4x use a WFIFO of a player instead of to use a buffer.\n", WBUFW(buf,0));
  243. printf(" Please correct your code.\n");
  244. // don't send to not move the pointer of the packet for next sessions in the loop
  245. } else {
  246. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  247. memcpy(WFIFOP(sd->fd,0), buf, len);
  248. WFIFOSET(sd->fd,len);
  249. }
  250. }
  251. }
  252. return 0;
  253. }
  254. /*==========================================
  255. *
  256. *------------------------------------------
  257. */
  258. int clif_send(unsigned char *buf, int len, struct block_list *bl, int type) {
  259. int i;
  260. struct map_session_data *sd;
  261. struct chat_data *cd;
  262. struct party *p = NULL;
  263. struct guild *g = NULL;
  264. int x0 = 0, x1 = 0, y0 = 0, y1 = 0;
  265. if (type != ALL_CLIENT) {
  266. nullpo_retr(0, bl);
  267. }
  268. switch(type) {
  269. case ALL_CLIENT: // 全クライアントに送信
  270. for(i = 0; i < fd_max; i++) {
  271. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth) {
  272. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  273. memcpy(WFIFOP(i,0), buf, len);
  274. WFIFOSET(i,len);
  275. }
  276. }
  277. }
  278. break;
  279. case ALL_SAMEMAP: // 同じマップの全クライアントに送信
  280. for(i = 0; i < fd_max; i++) {
  281. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth && sd->bl.m == bl->m) {
  282. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  283. memcpy(WFIFOP(i,0), buf, len);
  284. WFIFOSET(i,len);
  285. }
  286. }
  287. }
  288. break;
  289. case AREA:
  290. case AREA_WOS:
  291. case AREA_WOC:
  292. case AREA_WOSC:
  293. 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);
  294. break;
  295. case AREA_CHAT_WOC:
  296. 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);
  297. break;
  298. case CHAT:
  299. case CHAT_WOS:
  300. cd = (struct chat_data*)bl;
  301. if (bl->type == BL_PC) {
  302. sd = (struct map_session_data*)bl;
  303. cd = (struct chat_data*)map_id2bl(sd->chatID);
  304. } else if (bl->type != BL_CHAT)
  305. break;
  306. if (cd == NULL)
  307. break;
  308. for(i = 0; i < cd->users; i++) {
  309. if (type == CHAT_WOS && cd->usersd[i] == (struct map_session_data*)bl)
  310. continue;
  311. if (packet_db[cd->usersd[i]->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  312. if (cd->usersd[i]->fd >=0 && session[cd->usersd[i]->fd]) // Added check to see if session exists [PoW]
  313. memcpy(WFIFOP(cd->usersd[i]->fd,0), buf, len);
  314. WFIFOSET(cd->usersd[i]->fd,len);
  315. }
  316. }
  317. break;
  318. case PARTY_AREA: // 同じ画面内の全パーティーメンバに送信
  319. case PARTY_AREA_WOS: // 自分以外の同じ画面内の全パーティーメンバに送信
  320. x0 = bl->x - AREA_SIZE;
  321. y0 = bl->y - AREA_SIZE;
  322. x1 = bl->x + AREA_SIZE;
  323. y1 = bl->y + AREA_SIZE;
  324. case PARTY: // 全パーティーメンバに送信
  325. case PARTY_WOS: // 自分以外の全パーティーメンバに送信
  326. case PARTY_SAMEMAP: // 同じマップの全パーティーメンバに送信
  327. case PARTY_SAMEMAP_WOS: // 自分以外の同じマップの全パーティーメンバに送信
  328. if (bl->type == BL_PC) {
  329. sd = (struct map_session_data *)bl;
  330. if (sd->partyspy > 0) {
  331. p = party_search(sd->partyspy);
  332. } else {
  333. if (sd->status.party_id > 0)
  334. p = party_search(sd->status.party_id);
  335. }
  336. }
  337. if (p) {
  338. for(i=0;i<MAX_PARTY;i++){
  339. if ((sd = p->member[i].sd) != NULL) {
  340. if ((session[sd->fd] == NULL) || (session[sd->fd]->session_data == NULL))
  341. continue;
  342. if (sd->bl.id == bl->id && (type == PARTY_WOS ||
  343. type == PARTY_SAMEMAP_WOS || type == PARTY_AREA_WOS))
  344. continue;
  345. if (type != PARTY && type != PARTY_WOS && bl->m != sd->bl.m) // マップチェック
  346. continue;
  347. if ((type == PARTY_AREA || type == PARTY_AREA_WOS) &&
  348. (sd->bl.x < x0 || sd->bl.y < y0 ||
  349. sd->bl.x > x1 || sd->bl.y > y1))
  350. continue;
  351. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  352. memcpy(WFIFOP(sd->fd,0), buf, len);
  353. WFIFOSET(sd->fd,len);
  354. }
  355. // if(battle_config.etc_log)
  356. // printf("send party %d %d %d\n",p->party_id,i,flag)
  357. }
  358. }
  359. for (i = 0; i < fd_max; i++){
  360. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth) {
  361. if (sd->partyspy == p->party_id) {
  362. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  363. memcpy(WFIFOP(sd->fd,0), buf, len);
  364. WFIFOSET(sd->fd,len);
  365. }
  366. }
  367. }
  368. }
  369. }
  370. break;
  371. case SELF:
  372. sd = (struct map_session_data *)bl;
  373. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  374. memcpy(WFIFOP(sd->fd,0), buf, len);
  375. WFIFOSET(sd->fd,len);
  376. }
  377. break;
  378. /* New definitions for guilds [Valaris] */
  379. case GUILD_AREA:
  380. case GUILD_AREA_WOS:
  381. x0 = bl->x - AREA_SIZE;
  382. y0 = bl->y - AREA_SIZE;
  383. x1 = bl->x + AREA_SIZE;
  384. y1 = bl->y + AREA_SIZE;
  385. case GUILD:
  386. case GUILD_WOS:
  387. if (bl && bl->type == BL_PC) { // guildspy [Syrus22]
  388. sd = (struct map_session_data *)bl;
  389. if (sd->guildspy > 0) {
  390. g = guild_search(sd->guildspy);
  391. } else {
  392. if (sd->status.guild_id > 0)
  393. g = guild_search(sd->status.guild_id);
  394. }
  395. }
  396. if (g) {
  397. for(i = 0; i < g->max_member; i++) {
  398. if ((sd = g->member[i].sd) != NULL) {
  399. if (type == GUILD_WOS && sd->bl.id == bl->id)
  400. continue;
  401. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  402. memcpy(WFIFOP(sd->fd,0), buf, len);
  403. WFIFOSET(sd->fd,len);
  404. }
  405. }
  406. }
  407. for (i = 0; i < fd_max; i++){
  408. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth) {
  409. if (sd->guildspy == g->guild_id) {
  410. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  411. memcpy(WFIFOP(sd->fd,0), buf, len);
  412. WFIFOSET(sd->fd,len);
  413. }
  414. }
  415. }
  416. }
  417. }
  418. break;
  419. case GUILD_SAMEMAP:
  420. case GUILD_SAMEMAP_WOS:
  421. if (bl->type == BL_PC) {
  422. sd = (struct map_session_data *)bl;
  423. if (sd->status.guild_id > 0)
  424. g = guild_search(sd->status.guild_id);
  425. }
  426. if (g) {
  427. for(i = 0; i < g->max_member; i++) {
  428. if ((sd = g->member[i].sd) != NULL) {
  429. if (sd->bl.id == bl->id && (type == GUILD_WOS ||
  430. type == GUILD_SAMEMAP_WOS || type == GUILD_AREA_WOS))
  431. continue;
  432. if (type != GUILD && type != GUILD_WOS && bl->m != sd->bl.m) // マップチェック
  433. continue;
  434. if ((type == GUILD_AREA || type == GUILD_AREA_WOS) &&
  435. (sd->bl.x < x0 || sd->bl.y < y0 ||
  436. sd->bl.x > x1 || sd->bl.y > y1))
  437. continue;
  438. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  439. memcpy(WFIFOP(sd->fd,0), buf, len);
  440. WFIFOSET(sd->fd,len);
  441. }
  442. }
  443. }
  444. }
  445. break;
  446. /* End [Valaris] */
  447. default:
  448. if (battle_config.error_log)
  449. printf("clif_send まだ作ってないよー\n");
  450. return -1;
  451. }
  452. return 0;
  453. }
  454. //
  455. // パケット作って送信
  456. //
  457. /*==========================================
  458. *
  459. *------------------------------------------
  460. */
  461. int clif_authok(struct map_session_data *sd) {
  462. int fd;
  463. nullpo_retr(0, sd);
  464. if (!sd)
  465. return 0;
  466. if (!sd->fd)
  467. return 0;
  468. fd = sd->fd;
  469. WFIFOW(fd, 0) = 0x73;
  470. WFIFOL(fd, 2) = gettick();
  471. WFIFOPOS(fd, 6, sd->bl.x, sd->bl.y);
  472. WFIFOB(fd, 9) = 5;
  473. WFIFOB(fd,10) = 5;
  474. WFIFOSET(fd,packet_len_table[0x73]);
  475. return 0;
  476. }
  477. /*==========================================
  478. *
  479. *------------------------------------------
  480. */
  481. int clif_authfail_fd(int fd, int type) {
  482. if (!fd || !session[fd])
  483. return 0;
  484. WFIFOW(fd,0) = 0x81;
  485. WFIFOL(fd,2) = type;
  486. WFIFOSET(fd,packet_len_table[0x81]);
  487. clif_setwaitclose(fd);
  488. return 0;
  489. }
  490. /*==========================================
  491. *
  492. *------------------------------------------
  493. */
  494. int clif_charselectok(int id) {
  495. struct map_session_data *sd;
  496. int fd;
  497. if ((sd = map_id2sd(id)) == NULL)
  498. return 1;
  499. if (!sd->fd)
  500. return 1;
  501. fd = sd->fd;
  502. WFIFOW(fd,0) = 0xb3;
  503. WFIFOB(fd,2) = 1;
  504. WFIFOSET(fd,packet_len_table[0xb3]);
  505. return 0;
  506. }
  507. /*==========================================
  508. *
  509. *------------------------------------------
  510. */
  511. static int clif_set009e(struct flooritem_data *fitem,unsigned char *buf) {
  512. int view;
  513. nullpo_retr(0, fitem);
  514. //009e <ID>.l <name ID>.w <identify flag>.B <X>.w <Y>.w <subX>.B <subY>.B <amount>.w
  515. WBUFW(buf, 0) = 0x9e;
  516. WBUFL(buf, 2) = fitem->bl.id;
  517. if ((view = itemdb_viewid(fitem->item_data.nameid)) > 0)
  518. WBUFW(buf, 6) = view;
  519. else
  520. WBUFW(buf, 6) = fitem->item_data.nameid;
  521. WBUFB(buf, 8) = fitem->item_data.identify;
  522. WBUFW(buf, 9) = fitem->bl.x;
  523. WBUFW(buf,11) = fitem->bl.y;
  524. WBUFB(buf,13) = fitem->subx;
  525. WBUFB(buf,14) = fitem->suby;
  526. WBUFW(buf,15) = fitem->item_data.amount;
  527. return packet_len_table[0x9e];
  528. }
  529. /*==========================================
  530. *
  531. *------------------------------------------
  532. */
  533. int clif_dropflooritem(struct flooritem_data *fitem) {
  534. unsigned char buf[64];
  535. nullpo_retr(0, fitem);
  536. if (fitem->item_data.nameid <= 0)
  537. return 0;
  538. clif_set009e(fitem, buf);
  539. clif_send(buf, packet_len_table[0x9e], &fitem->bl, AREA);
  540. return 0;
  541. }
  542. /*==========================================
  543. *
  544. *------------------------------------------
  545. */
  546. int clif_clearflooritem(struct flooritem_data *fitem, int fd) {
  547. unsigned char buf[16];
  548. nullpo_retr(0, fitem);
  549. WBUFW(buf,0) = 0xa1;
  550. WBUFL(buf,2) = fitem->bl.id;
  551. if (fd == 0) {
  552. clif_send(buf, packet_len_table[0xa1], &fitem->bl, AREA);
  553. } else {
  554. memcpy(WFIFOP(fd,0), buf, 6);
  555. WFIFOSET(fd,packet_len_table[0xa1]);
  556. }
  557. return 0;
  558. }
  559. /*==========================================
  560. *
  561. *------------------------------------------
  562. */
  563. int clif_clearchar(struct block_list *bl, int type) {
  564. unsigned char buf[16];
  565. nullpo_retr(0, bl);
  566. WBUFW(buf,0) = 0x80;
  567. WBUFL(buf,2) = bl->id;
  568. if (type == 9) {
  569. WBUFB(buf,6) = 0;
  570. clif_send(buf, packet_len_table[0x80], bl, AREA);
  571. } else {
  572. WBUFB(buf,6) = type;
  573. clif_send(buf, packet_len_table[0x80], bl, type == 1 ? AREA : AREA_WOS);
  574. }
  575. return 0;
  576. }
  577. static int clif_clearchar_delay_sub(int tid, unsigned int tick, int id, int data) {
  578. struct block_list *bl = (struct block_list *)id;
  579. clif_clearchar(bl,data);
  580. map_freeblock(bl);
  581. return 0;
  582. }
  583. int clif_clearchar_delay(unsigned int tick, struct block_list *bl, int type) {
  584. struct block_list *tmpbl;
  585. tmpbl = (struct block_list*)aCalloc(1, sizeof(struct block_list));
  586. memcpy(tmpbl, bl, sizeof(struct block_list));
  587. add_timer(tick, clif_clearchar_delay_sub, (int)tmpbl, type);
  588. return 0;
  589. }
  590. /*==========================================
  591. *
  592. *------------------------------------------
  593. */
  594. int clif_clearchar_id(int id, int type, int fd) {
  595. unsigned char buf[16];
  596. WBUFW(buf,0) = 0x80;
  597. WBUFL(buf,2) = id;
  598. WBUFB(buf,6) = type;
  599. memcpy(WFIFOP(fd,0), buf, 7);
  600. WFIFOSET(fd, packet_len_table[0x80]);
  601. return 0;
  602. }
  603. /*==========================================
  604. *
  605. *------------------------------------------
  606. */
  607. static int clif_set0078(struct map_session_data *sd, unsigned char *buf) {
  608. int level;
  609. nullpo_retr(0, sd);
  610. if (sd->disguise > 23 && sd->disguise < 4001) { // mob disguises [Valaris]
  611. WBUFW(buf,0) = 0x78;
  612. WBUFL(buf,2) = sd->bl.id;
  613. WBUFW(buf,6) = battle_get_speed(&sd->bl);
  614. WBUFW(buf,8) = sd->opt1;
  615. WBUFW(buf,10) = sd->opt2;
  616. WBUFW(buf,12) = sd->status.option;
  617. WBUFW(buf,14) = sd->disguise;
  618. WBUFW(buf,42) = 0;
  619. WBUFB(buf,44) = 0;
  620. WBUFPOS(buf, 46, sd->bl.x, sd->bl.y);
  621. WBUFB(buf,48) |= sd->dir & 0x0f;
  622. WBUFB(buf,49) = 5;
  623. WBUFB(buf,50) = 5;
  624. WBUFB(buf,51) = 0;
  625. WBUFW(buf,52) = ((level = battle_get_lv(&sd->bl)) > battle_config.max_lv) ? battle_config.max_lv : level;
  626. return packet_len_table[0x78];
  627. }
  628. #if PACKETVER < 4
  629. WBUFW(buf,0)= 0x78;
  630. WBUFL(buf,2)= sd->bl.id;
  631. WBUFW(buf,6)= sd->speed;
  632. WBUFW(buf,8)= sd->opt1;
  633. WBUFW(buf,10)= sd->opt2;
  634. WBUFW(buf,12)= sd->status.option;
  635. WBUFW(buf,14)= sd->view_class;
  636. WBUFW(buf,16)= sd->status.hair;
  637. if (sd->view_class != 22)
  638. WBUFW(buf,18) = sd->status.weapon;
  639. else
  640. WBUFW(buf,18)=0;
  641. WBUFW(buf,20)=sd->status.head_bottom;
  642. WBUFW(buf,22)=sd->status.shield;
  643. WBUFW(buf,24)=sd->status.head_top;
  644. WBUFW(buf,26)=sd->status.head_mid;
  645. WBUFW(buf,28)=sd->status.hair_color;
  646. WBUFW(buf,30)=sd->status.clothes_color;
  647. WBUFW(buf,32)=sd->head_dir;
  648. WBUFL(buf,34)=sd->status.guild_id;
  649. WBUFL(buf,38)=sd->guild_emblem_id;
  650. WBUFW(buf,42)=sd->status.manner;
  651. WBUFB(buf,44)=sd->status.karma;
  652. WBUFB(buf,45)=sd->sex;
  653. WBUFPOS(buf,46,sd->bl.x,sd->bl.y);
  654. WBUFB(buf,48)|=sd->dir&0x0f;
  655. WBUFB(buf,49)=5;
  656. WBUFB(buf,50)=5;
  657. WBUFB(buf,51)=sd->state.dead_sit;
  658. WBUFW(buf,52)=(sd->status.base_level>battle_config.max_lv)?battle_config.max_lv:sd->status.base_level;
  659. return packet_len_table[0x78];
  660. #else
  661. WBUFW(buf,0) = 0x1d8;
  662. WBUFL(buf,2) = sd->bl.id;
  663. WBUFW(buf,6) = sd->speed;
  664. WBUFW(buf,8) = sd->opt1;
  665. WBUFW(buf,10) = sd->opt2;
  666. WBUFW(buf,12) = sd->status.option;
  667. WBUFW(buf,14) = sd->view_class;
  668. WBUFW(buf,16) = sd->status.hair;
  669. if (sd->equip_index[9] >= 0 && sd->inventory_data[sd->equip_index[9]] && sd->view_class != 22) {
  670. if (sd->inventory_data[sd->equip_index[9]]->view_id > 0)
  671. WBUFW(buf,18) = sd->inventory_data[sd->equip_index[9]]->view_id;
  672. else
  673. WBUFW(buf,18) = sd->status.inventory[sd->equip_index[9]].nameid;
  674. } else
  675. WBUFW(buf,18) = 0;
  676. if (sd->equip_index[8] >= 0 && sd->equip_index[8] != sd->equip_index[9] && sd->inventory_data[sd->equip_index[8]] && sd->view_class != 22) {
  677. if (sd->inventory_data[sd->equip_index[8]]->view_id > 0)
  678. WBUFW(buf,20) = sd->inventory_data[sd->equip_index[8]]->view_id;
  679. else
  680. WBUFW(buf,20) = sd->status.inventory[sd->equip_index[8]].nameid;
  681. } else
  682. WBUFW(buf,20) = 0;
  683. WBUFW(buf,22) = sd->status.head_bottom;
  684. WBUFW(buf,24) = sd->status.head_top;
  685. WBUFW(buf,26) = sd->status.head_mid;
  686. WBUFW(buf,28) = sd->status.hair_color;
  687. WBUFW(buf,30) = sd->status.clothes_color;
  688. WBUFW(buf,32) = sd->head_dir;
  689. WBUFL(buf,34) = sd->status.guild_id;
  690. WBUFW(buf,38) = sd->guild_emblem_id;
  691. WBUFW(buf,40) = sd->status.manner;
  692. WBUFW(buf,42)=sd->opt3;
  693. WBUFB(buf,44) = sd->status.karma;
  694. WBUFB(buf,45) = sd->sex;
  695. WBUFPOS(buf, 46, sd->bl.x, sd->bl.y);
  696. WBUFB(buf,48) |= sd->dir & 0x0f;
  697. WBUFB(buf,49) = 5;
  698. WBUFB(buf,50) = 5;
  699. WBUFB(buf,51) = sd->state.dead_sit;
  700. WBUFW(buf,52) = ((level = battle_get_lv(&sd->bl)) > battle_config.max_lv) ? battle_config.max_lv : level;
  701. return packet_len_table[0x1d8];
  702. #endif
  703. }
  704. /*==========================================
  705. *
  706. *------------------------------------------
  707. */
  708. static int clif_set007b(struct map_session_data *sd,unsigned char *buf) {
  709. int level;
  710. nullpo_retr(0, sd);
  711. if (sd->disguise > 23 && sd->disguise < 4001) { // mob disguises [Valaris]
  712. WBUFW(buf,0)=0x7b;
  713. WBUFL(buf,2)=sd->bl.id;
  714. WBUFW(buf,6)=battle_get_speed(&sd->bl);
  715. WBUFW(buf,8)=sd->opt1;
  716. WBUFW(buf,10)=sd->opt2;
  717. WBUFW(buf,12)=sd->status.option;
  718. WBUFW(buf,14)=sd->disguise;
  719. WBUFL(buf,22)=gettick();
  720. WBUFW(buf,46)=0;
  721. WBUFB(buf,48)=0;
  722. WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->to_x,sd->to_y);
  723. WBUFB(buf,55)=0;
  724. WBUFB(buf,56)=5;
  725. WBUFB(buf,57)=5;
  726. WBUFW(buf,58)=((level = battle_get_lv(&sd->bl))>battle_config.max_lv)? battle_config.max_lv:level;
  727. return packet_len_table[0x7b];
  728. }
  729. #if PACKETVER < 4
  730. WBUFW(buf,0)=0x7b;
  731. WBUFL(buf,2)=sd->bl.id;
  732. WBUFW(buf,6)=sd->speed;
  733. WBUFW(buf,8)=sd->opt1;
  734. WBUFW(buf,10)=sd->opt2;
  735. WBUFW(buf,12)=sd->status.option;
  736. WBUFW(buf,14)=sd->view_class;
  737. WBUFW(buf,16)=sd->status.hair;
  738. if(sd->view_class != 22)
  739. WBUFW(buf,18)=sd->status.weapon;
  740. else
  741. WBUFW(buf,18)=0;
  742. WBUFW(buf,20)=sd->status.head_bottom;
  743. WBUFL(buf,22)=gettick();
  744. WBUFW(buf,26)=sd->status.shield;
  745. WBUFW(buf,28)=sd->status.head_top;
  746. WBUFW(buf,30)=sd->status.head_mid;
  747. WBUFW(buf,32)=sd->status.hair_color;
  748. WBUFW(buf,34)=sd->status.clothes_color;
  749. WBUFW(buf,36)=sd->head_dir;
  750. WBUFL(buf,38)=sd->status.guild_id;
  751. WBUFL(buf,42)=sd->guild_emblem_id;
  752. WBUFW(buf,46)=sd->status.manner;
  753. WBUFB(buf,48)=sd->status.karma;
  754. WBUFB(buf,49)=sd->sex;
  755. WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->to_x,sd->to_y);
  756. WBUFB(buf,55)=0;
  757. WBUFB(buf,56)=5;
  758. WBUFB(buf,57)=5;
  759. WBUFW(buf,58)=(sd->status.base_level>battle_config.max_lv)?battle_config.max_lv:sd->status.base_level;
  760. return packet_len_table[0x7b];
  761. #else
  762. WBUFW(buf,0)=0x1da;
  763. WBUFL(buf,2)=sd->bl.id;
  764. WBUFW(buf,6)=sd->speed;
  765. WBUFW(buf,8)=sd->opt1;
  766. WBUFW(buf,10)=sd->opt2;
  767. WBUFW(buf,12)=sd->status.option;
  768. WBUFW(buf,14)=sd->view_class;
  769. WBUFW(buf,16)=sd->status.hair;
  770. if(sd->equip_index[9] >= 0 && sd->inventory_data[sd->equip_index[9]] && sd->view_class != 22) {
  771. if(sd->inventory_data[sd->equip_index[9]]->view_id > 0)
  772. WBUFW(buf,18)=sd->inventory_data[sd->equip_index[9]]->view_id;
  773. else
  774. WBUFW(buf,18)=sd->status.inventory[sd->equip_index[9]].nameid;
  775. }
  776. else
  777. WBUFW(buf,18)=0;
  778. if(sd->equip_index[8] >= 0 && sd->equip_index[8] != sd->equip_index[9] && sd->inventory_data[sd->equip_index[8]] && sd->view_class != 22) {
  779. if(sd->inventory_data[sd->equip_index[8]]->view_id > 0)
  780. WBUFW(buf,20)=sd->inventory_data[sd->equip_index[8]]->view_id;
  781. else
  782. WBUFW(buf,20)=sd->status.inventory[sd->equip_index[8]].nameid;
  783. }
  784. else
  785. WBUFW(buf,20)=0;
  786. WBUFW(buf,22)=sd->status.head_bottom;
  787. WBUFL(buf,24)=gettick();
  788. WBUFW(buf,28)=sd->status.head_top;
  789. WBUFW(buf,30)=sd->status.head_mid;
  790. WBUFW(buf,32)=sd->status.hair_color;
  791. WBUFW(buf,34)=sd->status.clothes_color;
  792. WBUFW(buf,36)=sd->head_dir;
  793. WBUFL(buf,38)=sd->status.guild_id;
  794. WBUFW(buf,42)=sd->guild_emblem_id;
  795. WBUFW(buf,44)=sd->status.manner;
  796. WBUFW(buf,46)=sd->opt3;
  797. WBUFB(buf,48)=sd->status.karma;
  798. WBUFB(buf,49)=sd->sex;
  799. WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->to_x,sd->to_y);
  800. WBUFB(buf,55)=0;
  801. WBUFB(buf,56)=5;
  802. WBUFB(buf,57)=5;
  803. WBUFW(buf,58)=(sd->status.base_level>battle_config.max_lv)?battle_config.max_lv:sd->status.base_level;
  804. return packet_len_table[0x1da];
  805. #endif
  806. }
  807. /*==========================================
  808. * クラスチェンジ typeはMobの場合は1で他は0?
  809. *------------------------------------------
  810. */
  811. int clif_class_change(struct block_list *bl,int class_,int type)
  812. {
  813. unsigned char buf[16];
  814. nullpo_retr(0, bl);
  815. if(class_ >= MAX_PC_CLASS) {
  816. WBUFW(buf,0)=0x1b0;
  817. WBUFL(buf,2)=bl->id;
  818. WBUFB(buf,6)=type;
  819. WBUFL(buf,7)=class_;
  820. clif_send(buf,packet_len_table[0x1b0],bl,AREA);
  821. }
  822. return 0;
  823. }
  824. /*==========================================
  825. *
  826. *------------------------------------------
  827. */
  828. int clif_mob_class_change(struct mob_data *md, int class_) {
  829. unsigned char buf[16];
  830. int view = mob_get_viewclass(class_);
  831. nullpo_retr(0, md);
  832. if(view >= MAX_PC_CLASS) {
  833. WBUFW(buf,0)=0x1b0;
  834. WBUFL(buf,2)=md->bl.id;
  835. WBUFB(buf,6)=1;
  836. WBUFL(buf,7)=view;
  837. clif_send(buf,packet_len_table[0x1b0],&md->bl,AREA);
  838. }
  839. return 0;
  840. }
  841. // mob equipment [Valaris]
  842. int clif_mob_equip(struct mob_data *md, int nameid) {
  843. unsigned char buf[16];
  844. nullpo_retr(0, md);
  845. memset(buf,0,packet_len_table[0x1a4]);
  846. WBUFW(buf,0)=0x1a4;
  847. WBUFB(buf,2)=3;
  848. WBUFL(buf,3)=md->bl.id;
  849. WBUFL(buf,7)=nameid;
  850. clif_send(buf,packet_len_table[0x1a4],&md->bl,AREA);
  851. return 0;
  852. }
  853. /*==========================================
  854. * MOB表示1
  855. *------------------------------------------
  856. */
  857. static int clif_mob0078(struct mob_data *md, unsigned char *buf)
  858. {
  859. int level;
  860. memset(buf,0,packet_len_table[0x78]);
  861. nullpo_retr(0, md);
  862. WBUFW(buf,0)=0x78;
  863. WBUFL(buf,2)=md->bl.id;
  864. WBUFW(buf,6)=battle_get_speed(&md->bl);
  865. WBUFW(buf,8)=md->opt1;
  866. WBUFW(buf,10)=md->opt2;
  867. WBUFW(buf,12)=md->option;
  868. WBUFW(buf,14)=mob_get_viewclass(md->class_);
  869. if((mob_get_viewclass(md->class_) <= 23) || (mob_get_viewclass(md->class_) == 812) || (mob_get_viewclass(md->class_) >= 4001)) {
  870. WBUFW(buf,12)|=mob_db[md->class_].option;
  871. WBUFW(buf,16)=mob_get_hair(md->class_);
  872. WBUFW(buf,18)=mob_get_weapon(md->class_);
  873. WBUFW(buf,20)=mob_get_head_buttom(md->class_);
  874. WBUFW(buf,22)=mob_get_shield(md->class_);
  875. WBUFW(buf,24)=mob_get_head_top(md->class_);
  876. WBUFW(buf,26)=mob_get_head_mid(md->class_);
  877. WBUFW(buf,28)=mob_get_hair_color(md->class_);
  878. WBUFW(buf,30)=mob_get_clothes_color(md->class_); //Add for player monster dye - Valaris
  879. WBUFB(buf,45)=mob_get_sex(md->class_);
  880. }
  881. if (md->class_ >= 1285 && md->class_ <= 1287 && md->guild_id) { // Added guardian emblems [Valaris]
  882. struct guild *g;
  883. struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name);
  884. if (gc && gc->guild_id > 0) {
  885. g=guild_search(gc->guild_id);
  886. if (g) {
  887. WBUFL(buf,22)=g->emblem_id;
  888. WBUFL(buf,26)=gc->guild_id;
  889. }
  890. }
  891. } // End addition
  892. WBUFPOS(buf,46,md->bl.x,md->bl.y);
  893. WBUFB(buf,48)|=md->dir&0x0f;
  894. WBUFB(buf,49)=5;
  895. WBUFB(buf,50)=5;
  896. WBUFW(buf,52)=((level = battle_get_lv(&md->bl))>battle_config.max_lv)? battle_config.max_lv:level;
  897. return packet_len_table[0x78];
  898. }
  899. /*==========================================
  900. * MOB表示2
  901. *------------------------------------------
  902. */
  903. static int clif_mob007b(struct mob_data *md, unsigned char *buf) {
  904. int level;
  905. memset(buf,0,packet_len_table[0x7b]);
  906. nullpo_retr(0, md);
  907. WBUFW(buf,0)=0x7b;
  908. WBUFL(buf,2)=md->bl.id;
  909. WBUFW(buf,6)=battle_get_speed(&md->bl);
  910. WBUFW(buf,8)=md->opt1;
  911. WBUFW(buf,10)=md->opt2;
  912. WBUFW(buf,12)=md->option;
  913. WBUFW(buf,14)=mob_get_viewclass(md->class_);
  914. if ((mob_get_viewclass(md->class_) < 24) || (mob_get_viewclass(md->class_) > 4000)) {
  915. WBUFW(buf,12)|=mob_db[md->class_].option;
  916. WBUFW(buf,16)=mob_get_hair(md->class_);
  917. WBUFW(buf,18)=mob_get_weapon(md->class_);
  918. WBUFW(buf,20)=mob_get_head_buttom(md->class_);
  919. WBUFL(buf,22)=gettick();
  920. WBUFW(buf,26)=mob_get_shield(md->class_);
  921. WBUFW(buf,28)=mob_get_head_top(md->class_);
  922. WBUFW(buf,30)=mob_get_head_mid(md->class_);
  923. WBUFW(buf,32)=mob_get_hair_color(md->class_);
  924. WBUFW(buf,34)=mob_get_clothes_color(md->class_); //Add for player monster dye - Valaris
  925. WBUFB(buf,49)=mob_get_sex(md->class_);
  926. } else
  927. WBUFL(buf,22)=gettick();
  928. if(md->class_ >= 1285 && md->class_ <= 1287 && md->guild_id) { // Added guardian emblems [Valaris]
  929. struct guild *g;
  930. struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name);
  931. if(gc && gc->guild_id > 0){
  932. g=guild_search(gc->guild_id);
  933. if(g) {
  934. WBUFL(buf,28)=gc->guild_id;
  935. WBUFL(buf,24)=g->emblem_id;
  936. }
  937. }
  938. } // End addition
  939. WBUFPOS2(buf,50,md->bl.x,md->bl.y,md->to_x,md->to_y);
  940. WBUFB(buf,56)=5;
  941. WBUFB(buf,57)=5;
  942. WBUFW(buf,58)=((level = battle_get_lv(&md->bl))>battle_config.max_lv)? battle_config.max_lv:level;
  943. return packet_len_table[0x7b];
  944. }
  945. /*==========================================
  946. *
  947. *------------------------------------------
  948. */
  949. static int clif_npc0078(struct npc_data *nd, unsigned char *buf) {
  950. struct guild *g;
  951. nullpo_retr(0, nd);
  952. memset(buf,0,packet_len_table[0x78]);
  953. WBUFW(buf,0)=0x78;
  954. WBUFL(buf,2)=nd->bl.id;
  955. WBUFW(buf,6)=nd->speed;
  956. WBUFW(buf,14)=nd->class_;
  957. if ((nd->class_ == 722) && (nd->u.scr.guild_id > 0) && ((g=guild_search(nd->u.scr.guild_id)) != NULL)) {
  958. WBUFL(buf,22)=g->emblem_id;
  959. WBUFL(buf,26)=g->guild_id;
  960. }
  961. WBUFPOS(buf,46,nd->bl.x,nd->bl.y);
  962. WBUFB(buf,48)|=nd->dir&0x0f;
  963. WBUFB(buf,49)=5;
  964. WBUFB(buf,50)=5;
  965. return packet_len_table[0x78];
  966. }
  967. // NPC Walking [Valaris]
  968. static int clif_npc007b(struct npc_data *nd, unsigned char *buf) {
  969. struct guild *g;
  970. nullpo_retr(0, nd);
  971. memset(buf,0,packet_len_table[0x7b]);
  972. WBUFW(buf,0)=0x7b;
  973. WBUFL(buf,2)=nd->bl.id;
  974. WBUFW(buf,6)=nd->speed;
  975. WBUFW(buf,14)=nd->class_;
  976. if ((nd->class_ == 722) && (nd->u.scr.guild_id > 0) && ((g=guild_search(nd->u.scr.guild_id)) != NULL)) {
  977. WBUFL(buf,22)=g->emblem_id;
  978. WBUFL(buf,26)=g->guild_id;
  979. }
  980. WBUFL(buf,22)=gettick();
  981. WBUFPOS2(buf,50,nd->bl.x,nd->bl.y,nd->to_x,nd->to_y);
  982. WBUFB(buf,56)=5;
  983. WBUFB(buf,57)=5;
  984. return packet_len_table[0x7b];
  985. }
  986. /*==========================================
  987. *
  988. *------------------------------------------
  989. */
  990. static int clif_pet0078(struct pet_data *pd, unsigned char *buf) {
  991. int view,level;
  992. nullpo_retr(0, pd);
  993. memset(buf,0,packet_len_table[0x78]);
  994. WBUFW(buf,0)=0x78;
  995. WBUFL(buf,2)=pd->bl.id;
  996. WBUFW(buf,6)=pd->speed;
  997. WBUFW(buf,14)=mob_get_viewclass(pd->class_);
  998. if((mob_get_viewclass(pd->class_) < 24) || (mob_get_viewclass(pd->class_) > 4000)) {
  999. WBUFW(buf,12)=mob_db[pd->class_].option;
  1000. WBUFW(buf,16)=mob_get_hair(pd->class_);
  1001. WBUFW(buf,18)=mob_get_weapon(pd->class_);
  1002. WBUFW(buf,20)=mob_get_head_buttom(pd->class_);
  1003. WBUFW(buf,22)=mob_get_shield(pd->class_);
  1004. WBUFW(buf,24)=mob_get_head_top(pd->class_);
  1005. WBUFW(buf,26)=mob_get_head_mid(pd->class_);
  1006. WBUFW(buf,28)=mob_get_hair_color(pd->class_);
  1007. WBUFW(buf,30)=mob_get_clothes_color(pd->class_); //Add for player pet dye - Valaris
  1008. WBUFB(buf,45)=mob_get_sex(pd->class_);
  1009. } else {
  1010. WBUFW(buf,16)=0x14;
  1011. if((view = itemdb_viewid(pd->equip)) > 0)
  1012. WBUFW(buf,20)=view;
  1013. else
  1014. WBUFW(buf,20)=pd->equip;
  1015. }
  1016. WBUFPOS(buf,46,pd->bl.x,pd->bl.y);
  1017. WBUFB(buf,48)|=pd->dir&0x0f;
  1018. WBUFB(buf,49)=0;
  1019. WBUFB(buf,50)=0;
  1020. WBUFW(buf,52)=((level = battle_get_lv(&pd->bl))>battle_config.max_lv)? battle_config.max_lv:level;
  1021. return packet_len_table[0x78];
  1022. }
  1023. /*==========================================
  1024. *
  1025. *------------------------------------------
  1026. */
  1027. static int clif_pet007b(struct pet_data *pd, unsigned char *buf) {
  1028. int view,level;
  1029. nullpo_retr(0, pd);
  1030. memset(buf,0,packet_len_table[0x7b]);
  1031. WBUFW(buf,0)=0x7b;
  1032. WBUFL(buf,2)=pd->bl.id;
  1033. WBUFW(buf,6)=pd->speed;
  1034. WBUFW(buf,14)=mob_get_viewclass(pd->class_);
  1035. if((mob_get_viewclass(pd->class_) < 24) || (mob_get_viewclass(pd->class_) > 4000)) {
  1036. WBUFW(buf,12)=mob_db[pd->class_].option;
  1037. WBUFW(buf,16)=mob_get_hair(pd->class_);
  1038. WBUFW(buf,18)=mob_get_weapon(pd->class_);
  1039. WBUFW(buf,20)=mob_get_head_buttom(pd->class_);
  1040. WBUFL(buf,22)=gettick();
  1041. WBUFW(buf,26)=mob_get_shield(pd->class_);
  1042. WBUFW(buf,28)=mob_get_head_top(pd->class_);
  1043. WBUFW(buf,30)=mob_get_head_mid(pd->class_);
  1044. WBUFW(buf,32)=mob_get_hair_color(pd->class_);
  1045. WBUFW(buf,34)=mob_get_clothes_color(pd->class_); //Add for player pet dye - Valaris
  1046. WBUFB(buf,49)=mob_get_sex(pd->class_);
  1047. } else {
  1048. WBUFW(buf,16)=0x14;
  1049. if ((view = itemdb_viewid(pd->equip)) > 0)
  1050. WBUFW(buf,20)=view;
  1051. else
  1052. WBUFW(buf,20)=pd->equip;
  1053. WBUFL(buf,22)=gettick();
  1054. }
  1055. WBUFPOS2(buf,50,pd->bl.x,pd->bl.y,pd->to_x,pd->to_y);
  1056. WBUFB(buf,56)=0;
  1057. WBUFB(buf,57)=0;
  1058. WBUFW(buf,58)=((level = battle_get_lv(&pd->bl))>battle_config.max_lv)? battle_config.max_lv:level;
  1059. return packet_len_table[0x7b];
  1060. }
  1061. /*==========================================
  1062. *
  1063. *------------------------------------------
  1064. */
  1065. static int clif_set01e1(struct map_session_data *sd, unsigned char *buf) {
  1066. nullpo_retr(0, sd);
  1067. WBUFW(buf,0)=0x1e1;
  1068. WBUFL(buf,2)=sd->bl.id;
  1069. WBUFW(buf,6)=sd->spiritball;
  1070. return packet_len_table[0x1e1];
  1071. }
  1072. /*==========================================
  1073. *
  1074. *------------------------------------------
  1075. */
  1076. static int clif_set0192(int fd, int m, int x, int y, int type) {
  1077. WFIFOW(fd,0) = 0x192;
  1078. WFIFOW(fd,2) = x;
  1079. WFIFOW(fd,4) = y;
  1080. WFIFOW(fd,6) = type;
  1081. memcpy(WFIFOP(fd,8),map[m].name,16);
  1082. WFIFOSET(fd,packet_len_table[0x192]);
  1083. return 0;
  1084. }
  1085. /*==========================================
  1086. *
  1087. *------------------------------------------
  1088. */
  1089. int clif_spawnpc(struct map_session_data *sd) {
  1090. unsigned char buf[128];
  1091. nullpo_retr(0, sd);
  1092. if (sd->disguise > 23 && sd->disguise < 4001) { // mob disguises [Valaris]
  1093. clif_clearchar(&sd->bl, 9);
  1094. memset(buf, 0, packet_len_table[0x119]);
  1095. WBUFW(buf, 0) = 0x119;
  1096. WBUFL(buf, 2) = sd->bl.id;
  1097. WBUFW(buf, 6) = 0;
  1098. WBUFW(buf, 8) = 0;
  1099. WBUFW(buf,10) = 0x40;
  1100. WBUFB(buf,12) = 0;
  1101. clif_send(buf, packet_len_table[0x119], &sd->bl, SELF);
  1102. memset(buf, 0, packet_len_table[0x7c]);
  1103. WBUFW(buf, 0) = 0x7c;
  1104. WBUFL(buf, 2) = sd->bl.id;
  1105. WBUFW(buf, 6) = sd->speed;
  1106. WBUFW(buf, 8) = sd->opt1;
  1107. WBUFW(buf,10) = sd->opt2;
  1108. WBUFW(buf,12) = sd->status.option;
  1109. WBUFW(buf,20) = sd->disguise;
  1110. WBUFPOS(buf, 36, sd->bl.x, sd->bl.y);
  1111. clif_send(buf, packet_len_table[0x7c], &sd->bl, AREA);
  1112. }
  1113. clif_set0078(sd, buf);
  1114. #if PACKETVER < 4
  1115. WBUFW(buf, 0) = 0x79;
  1116. WBUFW(buf,51) = (sd->status.base_level > battle_config.max_lv) ? battle_config.max_lv : sd->status.base_level;
  1117. clif_send(buf, packet_len_table[0x79], &sd->bl, AREA_WOS);
  1118. #else
  1119. WBUFW(buf, 0) = 0x1d9;
  1120. WBUFW(buf,51) = (sd->status.base_level > battle_config.max_lv) ? battle_config.max_lv : sd->status.base_level;
  1121. clif_send(buf, packet_len_table[0x1d9], &sd->bl, AREA_WOS);
  1122. #endif
  1123. if (sd->spiritball > 0)
  1124. clif_spiritball(sd);
  1125. if (sd->status.guild_id > 0) { // force display of guild emblem [Valaris]
  1126. struct guild *g = guild_search(sd->status.guild_id);
  1127. if (g)
  1128. clif_guild_emblem(sd,g);
  1129. } // end addition [Valaris]
  1130. if (sd->status.class_==13 || sd->status.class_==21 || sd->status.class_==4014 || sd->status.class_==4022)
  1131. pc_setoption(sd,sd->status.option|0x0020); // [Valaris]
  1132. if ((pc_isriding(sd) && pc_checkskill(sd,KN_RIDING)>0) && (sd->status.class_==7 ||
  1133. sd->status.class_==14 || sd->status.class_==4008 || sd->status.class_==4015))
  1134. pc_setriding(sd); // update peco riders for people upgrading athena [Valaris]
  1135. if (map[sd->bl.m].flag.snow)
  1136. clif_specialeffect(&sd->bl, 162, 1);
  1137. if (map[sd->bl.m].flag.fog)
  1138. clif_specialeffect(&sd->bl, 233, 1);
  1139. if (map[sd->bl.m].flag.sakura)
  1140. clif_specialeffect(&sd->bl, 163, 1);
  1141. if (map[sd->bl.m].flag.leaves)
  1142. clif_specialeffect(&sd->bl, 333, 1);
  1143. if (map[sd->bl.m].flag.rain)
  1144. clif_specialeffect(&sd->bl, 161, 1);
  1145. return 0;
  1146. }
  1147. /*==========================================
  1148. *
  1149. *------------------------------------------
  1150. */
  1151. int clif_spawnnpc(struct npc_data *nd)
  1152. {
  1153. unsigned char buf[64];
  1154. int len;
  1155. nullpo_retr(0, nd);
  1156. if(nd->class_ < 0 || nd->flag&1 || nd->class_ == INVISIBLE_CLASS)
  1157. return 0;
  1158. memset(buf,0,packet_len_table[0x7c]);
  1159. WBUFW(buf,0)=0x7c;
  1160. WBUFL(buf,2)=nd->bl.id;
  1161. WBUFW(buf,6)=nd->speed;
  1162. WBUFW(buf,20)=nd->class_;
  1163. WBUFPOS(buf,36,nd->bl.x,nd->bl.y);
  1164. clif_send(buf,packet_len_table[0x7c],&nd->bl,AREA);
  1165. len = clif_npc0078(nd,buf);
  1166. clif_send(buf,len,&nd->bl,AREA);
  1167. return 0;
  1168. }
  1169. /*==========================================
  1170. *
  1171. *------------------------------------------
  1172. */
  1173. int clif_spawnmob(struct mob_data *md)
  1174. {
  1175. unsigned char buf[64];
  1176. int len;
  1177. nullpo_retr(0, md);
  1178. if (mob_get_viewclass(md->class_) > 23 ) {
  1179. memset(buf,0,packet_len_table[0x7c]);
  1180. WBUFW(buf,0)=0x7c;
  1181. WBUFL(buf,2)=md->bl.id;
  1182. WBUFW(buf,6)=md->speed;
  1183. WBUFW(buf,8)=md->opt1;
  1184. WBUFW(buf,10)=md->opt2;
  1185. WBUFW(buf,12)=md->option;
  1186. WBUFW(buf,20)=mob_get_viewclass(md->class_);
  1187. WBUFPOS(buf,36,md->bl.x,md->bl.y);
  1188. clif_send(buf,packet_len_table[0x7c],&md->bl,AREA);
  1189. }
  1190. len = clif_mob0078(md,buf);
  1191. clif_send(buf,len,&md->bl,AREA);
  1192. if (mob_get_equip(md->class_) > 0) // mob equipment [Valaris]
  1193. clif_mob_equip(md,mob_get_equip(md->class_));
  1194. if(md->size==2) // tiny/big mobs [Valaris]
  1195. clif_specialeffect(&md->bl,423,0);
  1196. else if(md->size==1)
  1197. clif_specialeffect(&md->bl,421,0);
  1198. return 0;
  1199. }
  1200. // pet
  1201. /*==========================================
  1202. *
  1203. *------------------------------------------
  1204. */
  1205. int clif_spawnpet(struct pet_data *pd)
  1206. {
  1207. unsigned char buf[64];
  1208. int len;
  1209. nullpo_retr(0, pd);
  1210. if (mob_get_viewclass(pd->class_) >= MAX_PC_CLASS) {
  1211. memset(buf,0,packet_len_table[0x7c]);
  1212. WBUFW(buf,0)=0x7c;
  1213. WBUFL(buf,2)=pd->bl.id;
  1214. WBUFW(buf,6)=pd->speed;
  1215. WBUFW(buf,20)=mob_get_viewclass(pd->class_);
  1216. WBUFPOS(buf,36,pd->bl.x,pd->bl.y);
  1217. clif_send(buf,packet_len_table[0x7c],&pd->bl,AREA);
  1218. }
  1219. len = clif_pet0078(pd,buf);
  1220. clif_send(buf,len,&pd->bl,AREA);
  1221. return 0;
  1222. }
  1223. /*==========================================
  1224. *
  1225. *------------------------------------------
  1226. */
  1227. int clif_movepet(struct pet_data *pd) {
  1228. unsigned char buf[256];
  1229. int len;
  1230. nullpo_retr(0, pd);
  1231. len = clif_pet007b(pd,buf);
  1232. clif_send(buf,len,&pd->bl,AREA);
  1233. return 0;
  1234. }
  1235. /*==========================================
  1236. * npc walking [Valaris]
  1237. *------------------------------------------
  1238. */
  1239. int clif_movenpc(struct npc_data *nd) {
  1240. unsigned char buf[256];
  1241. int len;
  1242. nullpo_retr(0, nd);
  1243. len = clif_npc007b(nd,buf);
  1244. clif_send(buf,len,&nd->bl,AREA);
  1245. return 0;
  1246. }
  1247. /*==========================================
  1248. *
  1249. *------------------------------------------
  1250. */
  1251. int clif_servertick(struct map_session_data *sd)
  1252. {
  1253. int fd;
  1254. nullpo_retr(0, sd);
  1255. fd=sd->fd;
  1256. WFIFOW(fd,0)=0x7f;
  1257. WFIFOL(fd,2)=sd->server_tick;
  1258. WFIFOSET(fd,packet_len_table[0x7f]);
  1259. return 0;
  1260. }
  1261. /*==========================================
  1262. *
  1263. *------------------------------------------
  1264. */
  1265. int clif_walkok(struct map_session_data *sd)
  1266. {
  1267. int fd;
  1268. nullpo_retr(0, sd);
  1269. fd=sd->fd;
  1270. WFIFOW(fd,0)=0x87;
  1271. WFIFOL(fd,2)=gettick();;
  1272. WFIFOPOS2(fd,6,sd->bl.x,sd->bl.y,sd->to_x,sd->to_y);
  1273. WFIFOB(fd,11)=0;
  1274. WFIFOSET(fd,packet_len_table[0x87]);
  1275. return 0;
  1276. }
  1277. /*==========================================
  1278. *
  1279. *------------------------------------------
  1280. */
  1281. int clif_movechar(struct map_session_data *sd) {
  1282. int fd;
  1283. int len;
  1284. unsigned char buf[256];
  1285. nullpo_retr(0, sd);
  1286. fd = sd->fd;
  1287. len = clif_set007b(sd, buf);
  1288. if (sd->disguise > 23 && sd->disguise < 4001) {
  1289. clif_send(buf, len, &sd->bl, AREA);
  1290. return 0;
  1291. } else
  1292. clif_send(buf, len, &sd->bl, AREA_WOS);
  1293. if (battle_config.save_clothcolor == 1 && sd->status.clothes_color > 0)
  1294. clif_changelook(&sd->bl, LOOK_CLOTHES_COLOR, sd->status.clothes_color);
  1295. return 0;
  1296. }
  1297. /*==========================================
  1298. *
  1299. *------------------------------------------
  1300. */
  1301. void clif_quitsave(int fd,struct map_session_data *sd)
  1302. {
  1303. map_quit(sd);
  1304. }
  1305. /*==========================================
  1306. *
  1307. *------------------------------------------
  1308. */
  1309. static int clif_waitclose(int tid, unsigned int tick, int id, int data) {
  1310. if (session[id])
  1311. session[id]->eof = 1;
  1312. close(id);
  1313. return 0;
  1314. }
  1315. /*==========================================
  1316. *
  1317. *------------------------------------------
  1318. */
  1319. void clif_setwaitclose(int fd) {
  1320. struct map_session_data *sd;
  1321. // if player is not already in the game (double connection probably)
  1322. if ((sd = (struct map_session_data*)session[fd]->session_data) == NULL) {
  1323. // limited timer, just to send information.
  1324. add_timer(gettick() + 1000, clif_waitclose, fd, 0);
  1325. } else
  1326. add_timer(gettick() + 5000, clif_waitclose, fd, 0);
  1327. }
  1328. /*==========================================
  1329. *
  1330. *------------------------------------------
  1331. */
  1332. int clif_changemap(struct map_session_data *sd, char *mapname, int x, int y) {
  1333. int fd;
  1334. nullpo_retr(0, sd);
  1335. fd = sd->fd;
  1336. WFIFOW(fd,0) = 0x91;
  1337. memcpy(WFIFOP(fd,2), mapname, 16);
  1338. WFIFOW(fd,18) = x;
  1339. WFIFOW(fd,20) = y;
  1340. WFIFOSET(fd, packet_len_table[0x91]);
  1341. if (sd->disguise > 23 && sd->disguise < 4001) // mob disguises [Valaris]
  1342. clif_spawnpc(sd);
  1343. return 0;
  1344. }
  1345. /*==========================================
  1346. *
  1347. *------------------------------------------
  1348. */
  1349. int clif_changemapserver(struct map_session_data *sd, char *mapname, int x, int y, int ip, int port) {
  1350. int fd;
  1351. nullpo_retr(0, sd);
  1352. fd = sd->fd;
  1353. WFIFOW(fd,0) = 0x92;
  1354. memcpy(WFIFOP(fd,2), mapname, 16);
  1355. WFIFOW(fd,18) = x;
  1356. WFIFOW(fd,20) = y;
  1357. WFIFOL(fd,22) = ip;
  1358. WFIFOW(fd,26) = port;
  1359. WFIFOSET(fd, packet_len_table[0x92]);
  1360. return 0;
  1361. }
  1362. /*==========================================
  1363. *
  1364. *------------------------------------------
  1365. */
  1366. int clif_fixpos(struct block_list *bl) {
  1367. unsigned char buf[16];
  1368. nullpo_retr(0, bl);
  1369. WBUFW(buf,0)=0x88;
  1370. WBUFL(buf,2)=bl->id;
  1371. WBUFW(buf,6)=bl->x;
  1372. WBUFW(buf,8)=bl->y;
  1373. clif_send(buf, packet_len_table[0x88], bl, AREA);
  1374. return 0;
  1375. }
  1376. /*==========================================
  1377. *
  1378. *------------------------------------------
  1379. */
  1380. int clif_npcbuysell(struct map_session_data* sd, int id) {
  1381. int fd;
  1382. nullpo_retr(0, sd);
  1383. fd=sd->fd;
  1384. WFIFOW(fd,0)=0xc4;
  1385. WFIFOL(fd,2)=id;
  1386. WFIFOSET(fd,packet_len_table[0xc4]);
  1387. return 0;
  1388. }
  1389. /*==========================================
  1390. *
  1391. *------------------------------------------
  1392. */
  1393. int clif_buylist(struct map_session_data *sd, struct npc_data *nd) {
  1394. struct item_data *id;
  1395. int fd,i,val;
  1396. nullpo_retr(0, sd);
  1397. nullpo_retr(0, nd);
  1398. fd=sd->fd;
  1399. WFIFOW(fd,0)=0xc6;
  1400. for(i=0;nd->u.shop_item[i].nameid > 0;i++){
  1401. id = itemdb_search(nd->u.shop_item[i].nameid);
  1402. val=nd->u.shop_item[i].value;
  1403. WFIFOL(fd,4+i*11)=val;
  1404. if (!id->flag.value_notdc)
  1405. val=pc_modifybuyvalue(sd,val);
  1406. WFIFOL(fd,8+i*11)=val;
  1407. WFIFOB(fd,12+i*11)=id->type;
  1408. if (id->view_id > 0)
  1409. WFIFOW(fd,13+i*11)=id->view_id;
  1410. else
  1411. WFIFOW(fd,13+i*11)=nd->u.shop_item[i].nameid;
  1412. }
  1413. WFIFOW(fd,2)=i*11+4;
  1414. WFIFOSET(fd,WFIFOW(fd,2));
  1415. return 0;
  1416. }
  1417. /*==========================================
  1418. *
  1419. *------------------------------------------
  1420. */
  1421. int clif_selllist(struct map_session_data *sd) {
  1422. int fd,i,c=0,val;
  1423. nullpo_retr(0, sd);
  1424. fd=sd->fd;
  1425. WFIFOW(fd,0)=0xc7;
  1426. for(i=0;i<MAX_INVENTORY;i++) {
  1427. if(sd->status.inventory[i].nameid > 0 && sd->inventory_data[i]) {
  1428. val=sd->inventory_data[i]->value_sell;
  1429. if (val < 0)
  1430. continue;
  1431. WFIFOW(fd,4+c*10)=i+2;
  1432. WFIFOL(fd,6+c*10)=val;
  1433. if (!sd->inventory_data[i]->flag.value_notoc)
  1434. val=pc_modifysellvalue(sd,val);
  1435. WFIFOL(fd,10+c*10)=val;
  1436. c++;
  1437. }
  1438. }
  1439. WFIFOW(fd,2)=c*10+4;
  1440. WFIFOSET(fd,WFIFOW(fd,2));
  1441. return 0;
  1442. }
  1443. /*==========================================
  1444. *
  1445. *------------------------------------------
  1446. */
  1447. int clif_scriptmes(struct map_session_data *sd, int npcid, char *mes) {
  1448. int fd;
  1449. nullpo_retr(0, sd);
  1450. fd=sd->fd;
  1451. WFIFOW(fd,0)=0xb4;
  1452. WFIFOW(fd,2)=strlen(mes)+9;
  1453. WFIFOL(fd,4)=npcid;
  1454. strcpy((char*)WFIFOP(fd,8),mes);
  1455. WFIFOSET(fd,WFIFOW(fd,2));
  1456. return 0;
  1457. }
  1458. /*==========================================
  1459. *
  1460. *------------------------------------------
  1461. */
  1462. int clif_scriptnext(struct map_session_data *sd,int npcid) {
  1463. int fd;
  1464. nullpo_retr(0, sd);
  1465. fd=sd->fd;
  1466. WFIFOW(fd,0)=0xb5;
  1467. WFIFOL(fd,2)=npcid;
  1468. WFIFOSET(fd,packet_len_table[0xb5]);
  1469. return 0;
  1470. }
  1471. /*==========================================
  1472. *
  1473. *------------------------------------------
  1474. */
  1475. int clif_scriptclose(struct map_session_data *sd, int npcid) {
  1476. int fd;
  1477. nullpo_retr(0, sd);
  1478. fd=sd->fd;
  1479. WFIFOW(fd,0)=0xb6;
  1480. WFIFOL(fd,2)=npcid;
  1481. WFIFOSET(fd,packet_len_table[0xb6]);
  1482. return 0;
  1483. }
  1484. /*==========================================
  1485. *
  1486. *------------------------------------------
  1487. */
  1488. int clif_scriptmenu(struct map_session_data *sd, int npcid, char *mes) {
  1489. int fd;
  1490. nullpo_retr(0, sd);
  1491. fd=sd->fd;
  1492. WFIFOW(fd,0)=0xb7;
  1493. WFIFOW(fd,2)=strlen(mes)+8;
  1494. WFIFOL(fd,4)=npcid;
  1495. strcpy((char*)WFIFOP(fd,8),mes);
  1496. WFIFOSET(fd,WFIFOW(fd,2));
  1497. return 0;
  1498. }
  1499. /*==========================================
  1500. *
  1501. *------------------------------------------
  1502. */
  1503. int clif_scriptinput(struct map_session_data *sd, int npcid) {
  1504. int fd;
  1505. nullpo_retr(0, sd);
  1506. fd=sd->fd;
  1507. WFIFOW(fd,0)=0x142;
  1508. WFIFOL(fd,2)=npcid;
  1509. WFIFOSET(fd,packet_len_table[0x142]);
  1510. return 0;
  1511. }
  1512. /*==========================================
  1513. *
  1514. *------------------------------------------
  1515. */
  1516. int clif_scriptinputstr(struct map_session_data *sd, int npcid) {
  1517. int fd;
  1518. nullpo_retr(0, sd);
  1519. fd=sd->fd;
  1520. WFIFOW(fd,0)=0x1d4;
  1521. WFIFOL(fd,2)=npcid;
  1522. WFIFOSET(fd,packet_len_table[0x1d4]);
  1523. return 0;
  1524. }
  1525. /*==========================================
  1526. *
  1527. *------------------------------------------
  1528. */
  1529. int clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, int y, int id, int color) {
  1530. int fd;
  1531. nullpo_retr(0, sd);
  1532. fd=sd->fd;
  1533. WFIFOW(fd,0)=0x144;
  1534. WFIFOL(fd,2)=npc_id;
  1535. WFIFOL(fd,6)=type;
  1536. WFIFOL(fd,10)=x;
  1537. WFIFOL(fd,14)=y;
  1538. WFIFOB(fd,18)=id;
  1539. WFIFOL(fd,19)=color;
  1540. WFIFOSET(fd,packet_len_table[0x144]);
  1541. return 0;
  1542. }
  1543. /*==========================================
  1544. *
  1545. *------------------------------------------
  1546. */
  1547. int clif_cutin(struct map_session_data *sd, char *image, int type) {
  1548. int fd;
  1549. nullpo_retr(0, sd);
  1550. fd=sd->fd;
  1551. WFIFOW(fd,0)=0x1b3;
  1552. strncpy((char*)WFIFOP(fd,2),image,64);
  1553. WFIFOB(fd,66)=type;
  1554. WFIFOSET(fd,packet_len_table[0x1b3]);
  1555. return 0;
  1556. }
  1557. /*==========================================
  1558. *
  1559. *------------------------------------------
  1560. */
  1561. int clif_additem(struct map_session_data *sd, int n, int amount, int fail) {
  1562. int fd,j;
  1563. unsigned char *buf;
  1564. nullpo_retr(0, sd);
  1565. fd=sd->fd;
  1566. buf=WFIFOP(fd,0);
  1567. if(fail) {
  1568. WBUFW(buf,0)=0xa0;
  1569. WBUFW(buf,2)=n+2;
  1570. WBUFW(buf,4)=amount;
  1571. WBUFW(buf,6)=0;
  1572. WBUFB(buf,8)=0;
  1573. WBUFB(buf,9)=0;
  1574. WBUFB(buf,10)=0;
  1575. WBUFW(buf,11)=0;
  1576. WBUFW(buf,13)=0;
  1577. WBUFW(buf,15)=0;
  1578. WBUFW(buf,17)=0;
  1579. WBUFW(buf,19)=0;
  1580. WBUFB(buf,21)=0;
  1581. WBUFB(buf,22)=fail;
  1582. } else {
  1583. if (n<0 || n>=MAX_INVENTORY || sd->status.inventory[n].nameid <=0 || sd->inventory_data[n] == NULL)
  1584. return 1;
  1585. WBUFW(buf,0)=0xa0;
  1586. WBUFW(buf,2)=n+2;
  1587. WBUFW(buf,4)=amount;
  1588. if (sd->inventory_data[n]->view_id > 0)
  1589. WBUFW(buf,6)=sd->inventory_data[n]->view_id;
  1590. else
  1591. WBUFW(buf,6)=sd->status.inventory[n].nameid;
  1592. WBUFB(buf,8)=sd->status.inventory[n].identify;
  1593. WBUFB(buf,9)=sd->status.inventory[n].attribute;
  1594. WBUFB(buf,10)=sd->status.inventory[n].refine;
  1595. if(sd->status.inventory[n].card[0]==0x00ff || sd->status.inventory[n].card[0]==0x00fe || sd->status.inventory[n].card[0]==(short)0xff00) {
  1596. WBUFW(buf,11)=sd->status.inventory[n].card[0];
  1597. WBUFW(buf,13)=sd->status.inventory[n].card[1];
  1598. WBUFW(buf,15)=sd->status.inventory[n].card[2];
  1599. WBUFW(buf,17)=sd->status.inventory[n].card[3];
  1600. } else {
  1601. if (sd->status.inventory[n].card[0] > 0 && (j=itemdb_viewid(sd->status.inventory[n].card[0])) > 0)
  1602. WBUFW(buf,11)=j;
  1603. else
  1604. WBUFW(buf,11)=sd->status.inventory[n].card[0];
  1605. if (sd->status.inventory[n].card[1] > 0 && (j=itemdb_viewid(sd->status.inventory[n].card[1])) > 0)
  1606. WBUFW(buf,13)=j;
  1607. else
  1608. WBUFW(buf,13)=sd->status.inventory[n].card[1];
  1609. if (sd->status.inventory[n].card[2] > 0 && (j=itemdb_viewid(sd->status.inventory[n].card[2])) > 0)
  1610. WBUFW(buf,15)=j;
  1611. else
  1612. WBUFW(buf,15)=sd->status.inventory[n].card[2];
  1613. if (sd->status.inventory[n].card[3] > 0 && (j=itemdb_viewid(sd->status.inventory[n].card[3])) > 0)
  1614. WBUFW(buf,17)=j;
  1615. else
  1616. WBUFW(buf,17)=sd->status.inventory[n].card[3];
  1617. }
  1618. WBUFW(buf,19)=pc_equippoint(sd,n);
  1619. WBUFB(buf,21)=(sd->inventory_data[n]->type == 7)? 4:sd->inventory_data[n]->type;
  1620. WBUFB(buf,22)=fail;
  1621. }
  1622. WFIFOSET(fd,packet_len_table[0xa0]);
  1623. return 0;
  1624. }
  1625. /*==========================================
  1626. *
  1627. *------------------------------------------
  1628. */
  1629. int clif_delitem(struct map_session_data *sd,int n,int amount)
  1630. {
  1631. int fd;
  1632. nullpo_retr(0, sd);
  1633. fd=sd->fd;
  1634. WFIFOW(fd,0)=0xaf;
  1635. WFIFOW(fd,2)=n+2;
  1636. WFIFOW(fd,4)=amount;
  1637. WFIFOSET(fd,packet_len_table[0xaf]);
  1638. return 0;
  1639. }
  1640. /*==========================================
  1641. *
  1642. *------------------------------------------
  1643. */
  1644. int clif_itemlist(struct map_session_data *sd)
  1645. {
  1646. int i,n,fd,arrow=-1;
  1647. unsigned char *buf;
  1648. nullpo_retr(0, sd);
  1649. fd=sd->fd;
  1650. buf = WFIFOP(fd,0);
  1651. #if PACKETVER < 5
  1652. WBUFW(buf,0)=0xa3;
  1653. for(i=0,n=0;i<MAX_INVENTORY;i++){
  1654. if (sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL || itemdb_isequip2(sd->inventory_data[i]))
  1655. continue;
  1656. WBUFW(buf,n*10+4)=i+2;
  1657. if (sd->inventory_data[i]->view_id > 0)
  1658. WBUFW(buf,n*10+6)=sd->inventory_data[i]->view_id;
  1659. else
  1660. WBUFW(buf,n*10+6)=sd->status.inventory[i].nameid;
  1661. WBUFB(buf,n*10+8)=sd->inventory_data[i]->type;
  1662. WBUFB(buf,n*10+9)=sd->status.inventory[i].identify;
  1663. WBUFW(buf,n*10+10)=sd->status.inventory[i].amount;
  1664. if (sd->inventory_data[i]->equip == 0x8000) {
  1665. WBUFW(buf,n*10+12)=0x8000;
  1666. if (sd->status.inventory[i].equip)
  1667. arrow=i; // ついでに矢装備チェック
  1668. } else
  1669. WBUFW(buf,n*10+12)=0;
  1670. n++;
  1671. }
  1672. if (n) {
  1673. WBUFW(buf,2)=4+n*10;
  1674. WFIFOSET(fd,WFIFOW(fd,2));
  1675. }
  1676. #else
  1677. WBUFW(buf,0)=0x1ee;
  1678. for(i=0,n=0;i<MAX_INVENTORY;i++){
  1679. if(sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL || itemdb_isequip2(sd->inventory_data[i]))
  1680. continue;
  1681. WBUFW(buf,n*18+4)=i+2;
  1682. if(sd->inventory_data[i]->view_id > 0)
  1683. WBUFW(buf,n*18+6)=sd->inventory_data[i]->view_id;
  1684. else
  1685. WBUFW(buf,n*18+6)=sd->status.inventory[i].nameid;
  1686. WBUFB(buf,n*18+8)=sd->inventory_data[i]->type;
  1687. WBUFB(buf,n*18+9)=sd->status.inventory[i].identify;
  1688. WBUFW(buf,n*18+10)=sd->status.inventory[i].amount;
  1689. if (sd->inventory_data[i]->equip == 0x8000) {
  1690. WBUFW(buf,n*18+12)=0x8000;
  1691. if(sd->status.inventory[i].equip)
  1692. arrow=i; // ついでに矢装備チェック
  1693. } else
  1694. WBUFW(buf,n*18+12)=0;
  1695. WBUFW(buf,n*18+14)=sd->status.inventory[i].card[0];
  1696. WBUFW(buf,n*18+16)=sd->status.inventory[i].card[1];
  1697. WBUFW(buf,n*18+18)=sd->status.inventory[i].card[2];
  1698. WBUFW(buf,n*18+20)=sd->status.inventory[i].card[3];
  1699. n++;
  1700. }
  1701. if (n) {
  1702. WBUFW(buf,2)=4+n*18;
  1703. WFIFOSET(fd,WFIFOW(fd,2));
  1704. }
  1705. #endif
  1706. if(arrow >= 0)
  1707. clif_arrowequip(sd,arrow);
  1708. return 0;
  1709. }
  1710. /*==========================================
  1711. *
  1712. *------------------------------------------
  1713. */
  1714. int clif_equiplist(struct map_session_data *sd)
  1715. {
  1716. int i,j,n,fd;
  1717. unsigned char *buf;
  1718. nullpo_retr(0, sd);
  1719. fd=sd->fd;
  1720. buf = WFIFOP(fd,0);
  1721. WBUFW(buf,0)=0xa4;
  1722. for(i=0,n=0;i<MAX_INVENTORY;i++){
  1723. if(sd->status.inventory[i].nameid<=0 || sd->inventory_data[i] == NULL || !itemdb_isequip2(sd->inventory_data[i]))
  1724. continue;
  1725. WBUFW(buf,n*20+4)=i+2;
  1726. if(sd->inventory_data[i]->view_id > 0)
  1727. WBUFW(buf,n*20+6)=sd->inventory_data[i]->view_id;
  1728. else
  1729. WBUFW(buf,n*20+6)=sd->status.inventory[i].nameid;
  1730. WBUFB(buf,n*20+8)=(sd->inventory_data[i]->type == 7)? 4:sd->inventory_data[i]->type;
  1731. WBUFB(buf,n*20+9)=sd->status.inventory[i].identify;
  1732. WBUFW(buf,n*20+10)=pc_equippoint(sd,i);
  1733. WBUFW(buf,n*20+12)=sd->status.inventory[i].equip;
  1734. WBUFB(buf,n*20+14)=sd->status.inventory[i].attribute;
  1735. WBUFB(buf,n*20+15)=sd->status.inventory[i].refine;
  1736. if(sd->status.inventory[i].card[0]==0x00ff || sd->status.inventory[i].card[0]==0x00fe || sd->status.inventory[i].card[0]==(short)0xff00) {
  1737. WBUFW(buf,n*20+16)=sd->status.inventory[i].card[0];
  1738. WBUFW(buf,n*20+18)=sd->status.inventory[i].card[1];
  1739. WBUFW(buf,n*20+20)=sd->status.inventory[i].card[2];
  1740. WBUFW(buf,n*20+22)=sd->status.inventory[i].card[3];
  1741. } else {
  1742. if(sd->status.inventory[i].card[0] > 0 && (j=itemdb_viewid(sd->status.inventory[i].card[0])) > 0)
  1743. WBUFW(buf,n*20+16)=j;
  1744. else
  1745. WBUFW(buf,n*20+16)=sd->status.inventory[i].card[0];
  1746. if(sd->status.inventory[i].card[1] > 0 && (j=itemdb_viewid(sd->status.inventory[i].card[1])) > 0)
  1747. WBUFW(buf,n*20+18)=j;
  1748. else
  1749. WBUFW(buf,n*20+18)=sd->status.inventory[i].card[1];
  1750. if(sd->status.inventory[i].card[2] > 0 && (j=itemdb_viewid(sd->status.inventory[i].card[2])) > 0)
  1751. WBUFW(buf,n*20+20)=j;
  1752. else
  1753. WBUFW(buf,n*20+20)=sd->status.inventory[i].card[2];
  1754. if(sd->status.inventory[i].card[3] > 0 && (j=itemdb_viewid(sd->status.inventory[i].card[3])) > 0)
  1755. WBUFW(buf,n*20+22)=j;
  1756. else
  1757. WBUFW(buf,n*20+22)=sd->status.inventory[i].card[3];
  1758. }
  1759. n++;
  1760. }
  1761. if(n){
  1762. WBUFW(buf,2)=4+n*20;
  1763. WFIFOSET(fd,WFIFOW(fd,2));
  1764. }
  1765. return 0;
  1766. }
  1767. /*==========================================
  1768. * カプラさんに預けてある消耗品&収集品リスト
  1769. *------------------------------------------
  1770. */
  1771. int clif_storageitemlist(struct map_session_data *sd,struct storage *stor)
  1772. {
  1773. struct item_data *id;
  1774. int i,n,fd;
  1775. unsigned char *buf;
  1776. nullpo_retr(0, sd);
  1777. nullpo_retr(0, stor);
  1778. fd=sd->fd;
  1779. buf = WFIFOP(fd,0);
  1780. #if PACKETVER < 5
  1781. WBUFW(buf,0)=0xa5;
  1782. for(i=0,n=0;i<MAX_STORAGE;i++){
  1783. if(stor->storage[i].nameid<=0)
  1784. continue;
  1785. nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
  1786. if(itemdb_isequip2(id))
  1787. continue;
  1788. WBUFW(buf,n*10+4)=i+1;
  1789. if(id->view_id > 0)
  1790. WBUFW(buf,n*10+6)=id->view_id;
  1791. else
  1792. WBUFW(buf,n*10+6)=stor->storage[i].nameid;
  1793. WBUFB(buf,n*10+8)=id->type;;
  1794. WBUFB(buf,n*10+9)=stor->storage[i].identify;
  1795. WBUFW(buf,n*10+10)=stor->storage[i].amount;
  1796. WBUFW(buf,n*10+12)=0;
  1797. n++;
  1798. }
  1799. if(n){
  1800. WBUFW(buf,2)=4+n*10;
  1801. WFIFOSET(fd,WFIFOW(fd,2));
  1802. }
  1803. #else
  1804. WBUFW(buf,0)=0x1f0;
  1805. for(i=0,n=0;i<MAX_STORAGE;i++){
  1806. if(stor->storage[i].nameid<=0)
  1807. continue;
  1808. nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
  1809. if(itemdb_isequip2(id))
  1810. continue;
  1811. WBUFW(buf,n*18+4)=i+1;
  1812. if(id->view_id > 0)
  1813. WBUFW(buf,n*18+6)=id->view_id;
  1814. else
  1815. WBUFW(buf,n*18+6)=stor->storage[i].nameid;
  1816. WBUFB(buf,n*18+8)=id->type;;
  1817. WBUFB(buf,n*18+9)=stor->storage[i].identify;
  1818. WBUFW(buf,n*18+10)=stor->storage[i].amount;
  1819. WBUFW(buf,n*18+12)=0;
  1820. WBUFW(buf,n*18+14)=stor->storage[i].card[0];
  1821. WBUFW(buf,n*18+16)=stor->storage[i].card[1];
  1822. WBUFW(buf,n*18+18)=stor->storage[i].card[2];
  1823. WBUFW(buf,n*18+20)=stor->storage[i].card[3];
  1824. n++;
  1825. }
  1826. if(n){
  1827. WBUFW(buf,2)=4+n*18;
  1828. WFIFOSET(fd,WFIFOW(fd,2));
  1829. }
  1830. #endif
  1831. return 0;
  1832. }
  1833. /*==========================================
  1834. * カプラさんに預けてある装備リスト
  1835. *------------------------------------------
  1836. */
  1837. int clif_storageequiplist(struct map_session_data *sd,struct storage *stor)
  1838. {
  1839. struct item_data *id;
  1840. int i,j,n,fd;
  1841. unsigned char *buf;
  1842. nullpo_retr(0, sd);
  1843. nullpo_retr(0, stor);
  1844. fd=sd->fd;
  1845. buf = WFIFOP(fd,0);
  1846. WBUFW(buf,0)=0xa6;
  1847. for(i=0,n=0;i<MAX_STORAGE;i++){
  1848. if(stor->storage[i].nameid<=0)
  1849. continue;
  1850. nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
  1851. if(!itemdb_isequip2(id))
  1852. continue;
  1853. WBUFW(buf,n*20+4)=i+1;
  1854. if(id->view_id > 0)
  1855. WBUFW(buf,n*20+6)=id->view_id;
  1856. else
  1857. WBUFW(buf,n*20+6)=stor->storage[i].nameid;
  1858. WBUFB(buf,n*20+8)=id->type;
  1859. WBUFB(buf,n*20+9)=stor->storage[i].identify;
  1860. WBUFW(buf,n*20+10)=id->equip;
  1861. WBUFW(buf,n*20+12)=stor->storage[i].equip;
  1862. WBUFB(buf,n*20+14)=stor->storage[i].attribute;
  1863. WBUFB(buf,n*20+15)=stor->storage[i].refine;
  1864. if(stor->storage[i].card[0]==0x00ff || stor->storage[i].card[0]==0x00fe || stor->storage[i].card[0]==(short)0xff00) {
  1865. WBUFW(buf,n*20+16)=stor->storage[i].card[0];
  1866. WBUFW(buf,n*20+18)=stor->storage[i].card[1];
  1867. WBUFW(buf,n*20+20)=stor->storage[i].card[2];
  1868. WBUFW(buf,n*20+22)=stor->storage[i].card[3];
  1869. } else {
  1870. if(stor->storage[i].card[0] > 0 && (j=itemdb_viewid(stor->storage[i].card[0])) > 0)
  1871. WBUFW(buf,n*20+16)=j;
  1872. else
  1873. WBUFW(buf,n*20+16)=stor->storage[i].card[0];
  1874. if(stor->storage[i].card[1] > 0 && (j=itemdb_viewid(stor->storage[i].card[1])) > 0)
  1875. WBUFW(buf,n*20+18)=j;
  1876. else
  1877. WBUFW(buf,n*20+18)=stor->storage[i].card[1];
  1878. if(stor->storage[i].card[2] > 0 && (j=itemdb_viewid(stor->storage[i].card[2])) > 0)
  1879. WBUFW(buf,n*20+20)=j;
  1880. else
  1881. WBUFW(buf,n*20+20)=stor->storage[i].card[2];
  1882. if(stor->storage[i].card[3] > 0 && (j=itemdb_viewid(stor->storage[i].card[3])) > 0)
  1883. WBUFW(buf,n*20+22)=j;
  1884. else
  1885. WBUFW(buf,n*20+22)=stor->storage[i].card[3];
  1886. }
  1887. n++;
  1888. }
  1889. if(n){
  1890. WBUFW(buf,2)=4+n*20;
  1891. WFIFOSET(fd,WFIFOW(fd,2));
  1892. }
  1893. return 0;
  1894. }
  1895. /*==========================================
  1896. *
  1897. *------------------------------------------
  1898. */
  1899. int clif_guildstorageitemlist(struct map_session_data *sd,struct guild_storage *stor)
  1900. {
  1901. struct item_data *id;
  1902. int i,n,fd;
  1903. unsigned char *buf;
  1904. nullpo_retr(0, sd);
  1905. nullpo_retr(0, stor);
  1906. fd=sd->fd;
  1907. buf=WFIFOP(fd,0);
  1908. #if PACKETVER < 5
  1909. WBUFW(buf,0)=0xa5;
  1910. for(i=0,n=0;i<MAX_GUILD_STORAGE;i++){
  1911. if(stor->storage[i].nameid<=0)
  1912. continue;
  1913. nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
  1914. if(itemdb_isequip2(id))
  1915. continue;
  1916. WBUFW(buf,n*10+4)=i+1;
  1917. if(id->view_id > 0)
  1918. WBUFW(buf,n*10+6)=id->view_id;
  1919. else
  1920. WBUFW(buf,n*10+6)=stor->storage[i].nameid;
  1921. WBUFB(buf,n*10+8)=id->type;;
  1922. WBUFB(buf,n*10+9)=stor->storage[i].identify;
  1923. WBUFW(buf,n*10+10)=stor->storage[i].amount;
  1924. WBUFW(buf,n*10+12)=0;
  1925. n++;
  1926. }
  1927. if(n){
  1928. WBUFW(buf,2)=4+n*10;
  1929. WFIFOSET(fd,WFIFOW(fd,2));
  1930. }
  1931. #else
  1932. WBUFW(buf,0)=0x1f0;
  1933. for(i=0,n=0;i<MAX_GUILD_STORAGE;i++){
  1934. if(stor->storage[i].nameid<=0)
  1935. continue;
  1936. nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
  1937. if(itemdb_isequip2(id))
  1938. continue;
  1939. WBUFW(buf,n*18+4)=i+1;
  1940. if(id->view_id > 0)
  1941. WBUFW(buf,n*18+6)=id->view_id;
  1942. else
  1943. WBUFW(buf,n*18+6)=stor->storage[i].nameid;
  1944. WBUFB(buf,n*18+8)=id->type;;
  1945. WBUFB(buf,n*18+9)=stor->storage[i].identify;
  1946. WBUFW(buf,n*18+10)=stor->storage[i].amount;
  1947. WBUFW(buf,n*18+12)=0;
  1948. WBUFW(buf,n*18+14)=stor->storage[i].card[0];
  1949. WBUFW(buf,n*18+16)=stor->storage[i].card[1];
  1950. WBUFW(buf,n*18+18)=stor->storage[i].card[2];
  1951. WBUFW(buf,n*18+20)=stor->storage[i].card[3];
  1952. n++;
  1953. }
  1954. if(n){
  1955. WBUFW(buf,2)=4+n*18;
  1956. WFIFOSET(fd,WFIFOW(fd,2));
  1957. }
  1958. #endif
  1959. return 0;
  1960. }
  1961. /*==========================================
  1962. *
  1963. *------------------------------------------
  1964. */
  1965. int clif_guildstorageequiplist(struct map_session_data *sd,struct guild_storage *stor)
  1966. {
  1967. struct item_data *id;
  1968. int i,j,n,fd;
  1969. unsigned char *buf;
  1970. nullpo_retr(0, sd);
  1971. fd=sd->fd;
  1972. buf=WFIFOP(fd,0);
  1973. WBUFW(buf,0)=0xa6;
  1974. for(i=0,n=0;i<MAX_GUILD_STORAGE;i++){
  1975. if(stor->storage[i].nameid<=0)
  1976. continue;
  1977. nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
  1978. if(!itemdb_isequip2(id))
  1979. continue;
  1980. WBUFW(buf,n*20+4)=i+1;
  1981. if(id->view_id > 0)
  1982. WBUFW(buf,n*20+6)=id->view_id;
  1983. else
  1984. WBUFW(buf,n*20+6)=stor->storage[i].nameid;
  1985. WBUFB(buf,n*20+8)=id->type;
  1986. WBUFB(buf,n*20+9)=stor->storage[i].identify;
  1987. WBUFW(buf,n*20+10)=id->equip;
  1988. WBUFW(buf,n*20+12)=stor->storage[i].equip;
  1989. WBUFB(buf,n*20+14)=stor->storage[i].attribute;
  1990. WBUFB(buf,n*20+15)=stor->storage[i].refine;
  1991. if(stor->storage[i].card[0]==0x00ff || stor->storage[i].card[0]==0x00fe || stor->storage[i].card[0]==(short)0xff00) {
  1992. WBUFW(buf,n*20+16)=stor->storage[i].card[0];
  1993. WBUFW(buf,n*20+18)=stor->storage[i].card[1];
  1994. WBUFW(buf,n*20+20)=stor->storage[i].card[2];
  1995. WBUFW(buf,n*20+22)=stor->storage[i].card[3];
  1996. } else {
  1997. if(stor->storage[i].card[0] > 0 && (j=itemdb_viewid(stor->storage[i].card[0])) > 0)
  1998. WBUFW(buf,n*20+16)=j;
  1999. else
  2000. WBUFW(buf,n*20+16)=stor->storage[i].card[0];
  2001. if(stor->storage[i].card[1] > 0 && (j=itemdb_viewid(stor->storage[i].card[1])) > 0)
  2002. WBUFW(buf,n*20+18)=j;
  2003. else
  2004. WBUFW(buf,n*20+18)=stor->storage[i].card[1];
  2005. if(stor->storage[i].card[2] > 0 && (j=itemdb_viewid(stor->storage[i].card[2])) > 0)
  2006. WBUFW(buf,n*20+20)=j;
  2007. else
  2008. WBUFW(buf,n*20+20)=stor->storage[i].card[2];
  2009. if(stor->storage[i].card[3] > 0 && (j=itemdb_viewid(stor->storage[i].card[3])) > 0)
  2010. WBUFW(buf,n*20+22)=j;
  2011. else
  2012. WBUFW(buf,n*20+22)=stor->storage[i].card[3];
  2013. }
  2014. n++;
  2015. }
  2016. if(n){
  2017. WBUFW(buf,2)=4+n*20;
  2018. WFIFOSET(fd,WFIFOW(fd,2));
  2019. }
  2020. return 0;
  2021. }
  2022. /*==========================================
  2023. * ステータスを送りつける
  2024. * 表示専用数字はこの中で計算して送る
  2025. *------------------------------------------
  2026. */
  2027. int clif_updatestatus(struct map_session_data *sd,int type)
  2028. {
  2029. int fd,len=8;
  2030. nullpo_retr(0, sd);
  2031. fd=sd->fd;
  2032. WFIFOW(fd,0)=0xb0;
  2033. WFIFOW(fd,2)=type;
  2034. switch(type){
  2035. // 00b0
  2036. case SP_WEIGHT:
  2037. pc_checkweighticon(sd);
  2038. WFIFOW(fd,0)=0xb0;
  2039. WFIFOW(fd,2)=type;
  2040. WFIFOL(fd,4)=sd->weight;
  2041. break;
  2042. case SP_MAXWEIGHT:
  2043. WFIFOL(fd,4)=sd->max_weight;
  2044. break;
  2045. case SP_SPEED:
  2046. WFIFOL(fd,4)=sd->speed;
  2047. break;
  2048. case SP_BASELEVEL:
  2049. WFIFOL(fd,4)=sd->status.base_level;
  2050. break;
  2051. case SP_JOBLEVEL:
  2052. WFIFOL(fd,4)=sd->status.job_level;
  2053. break;
  2054. case SP_MANNER:
  2055. WFIFOL(fd,4)=sd->status.manner;
  2056. clif_changestatus(&sd->bl,SP_MANNER,sd->status.manner);
  2057. break;
  2058. case SP_STATUSPOINT:
  2059. WFIFOL(fd,4)=sd->status.status_point;
  2060. break;
  2061. case SP_SKILLPOINT:
  2062. WFIFOL(fd,4)=sd->status.skill_point;
  2063. break;
  2064. case SP_HIT:
  2065. WFIFOL(fd,4)=sd->hit;
  2066. break;
  2067. case SP_FLEE1:
  2068. WFIFOL(fd,4)=sd->flee;
  2069. break;
  2070. case SP_FLEE2:
  2071. WFIFOL(fd,4)=sd->flee2/10;
  2072. break;
  2073. case SP_MAXHP:
  2074. WFIFOL(fd,4)=sd->status.max_hp;
  2075. break;
  2076. case SP_MAXSP:
  2077. WFIFOL(fd,4)=sd->status.max_sp;
  2078. break;
  2079. case SP_HP:
  2080. WFIFOL(fd,4)=sd->status.hp;
  2081. if(battle_config.disp_hpmeter)
  2082. clif_hpmeter(sd);
  2083. break;
  2084. case SP_SP:
  2085. WFIFOL(fd,4)=sd->status.sp;
  2086. break;
  2087. case SP_ASPD:
  2088. WFIFOL(fd,4)=sd->aspd;
  2089. break;
  2090. case SP_ATK1:
  2091. WFIFOL(fd,4)=sd->base_atk+sd->watk;
  2092. break;
  2093. case SP_DEF1:
  2094. WFIFOL(fd,4)=sd->def;
  2095. break;
  2096. case SP_MDEF1:
  2097. WFIFOL(fd,4)=sd->mdef;
  2098. break;
  2099. case SP_ATK2:
  2100. WFIFOL(fd,4)=sd->watk2;
  2101. break;
  2102. case SP_DEF2:
  2103. WFIFOL(fd,4)=sd->def2;
  2104. break;
  2105. case SP_MDEF2:
  2106. WFIFOL(fd,4)=sd->mdef2;
  2107. break;
  2108. case SP_CRITICAL:
  2109. WFIFOL(fd,4)=sd->critical/10;
  2110. break;
  2111. case SP_MATK1:
  2112. WFIFOL(fd,4)=sd->matk1;
  2113. break;
  2114. case SP_MATK2:
  2115. WFIFOL(fd,4)=sd->matk2;
  2116. break;
  2117. case SP_ZENY:
  2118. WFIFOW(fd,0)=0xb1;
  2119. if(sd->status.zeny < 0)
  2120. sd->status.zeny = 0;
  2121. WFIFOL(fd,4)=sd->status.zeny;
  2122. break;
  2123. case SP_BASEEXP:
  2124. WFIFOW(fd,0)=0xb1;
  2125. WFIFOL(fd,4)=sd->status.base_exp;
  2126. break;
  2127. case SP_JOBEXP:
  2128. WFIFOW(fd,0)=0xb1;
  2129. WFIFOL(fd,4)=sd->status.job_exp;
  2130. break;
  2131. case SP_NEXTBASEEXP:
  2132. WFIFOW(fd,0)=0xb1;
  2133. WFIFOL(fd,4)=pc_nextbaseexp(sd);
  2134. break;
  2135. case SP_NEXTJOBEXP:
  2136. WFIFOW(fd,0)=0xb1;
  2137. WFIFOL(fd,4)=pc_nextjobexp(sd);
  2138. break;
  2139. // 00be 終了
  2140. case SP_USTR:
  2141. case SP_UAGI:
  2142. case SP_UVIT:
  2143. case SP_UINT:
  2144. case SP_UDEX:
  2145. case SP_ULUK:
  2146. WFIFOW(fd,0)=0xbe;
  2147. WFIFOB(fd,4)=pc_need_status_point(sd,type-SP_USTR+SP_STR);
  2148. len=5;
  2149. break;
  2150. // 013a 終了
  2151. case SP_ATTACKRANGE:
  2152. WFIFOW(fd,0)=0x13a;
  2153. WFIFOW(fd,2)=sd->attackrange;
  2154. len=4;
  2155. break;
  2156. // 0141 終了
  2157. case SP_STR:
  2158. WFIFOW(fd,0)=0x141;
  2159. WFIFOL(fd,2)=type;
  2160. WFIFOL(fd,6)=sd->status.str;
  2161. WFIFOL(fd,10)=sd->paramb[0] + sd->parame[0];
  2162. len=14;
  2163. break;
  2164. case SP_AGI:
  2165. WFIFOW(fd,0)=0x141;
  2166. WFIFOL(fd,2)=type;
  2167. WFIFOL(fd,6)=sd->status.agi;
  2168. WFIFOL(fd,10)=sd->paramb[1] + sd->parame[1];
  2169. len=14;
  2170. break;
  2171. case SP_VIT:
  2172. WFIFOW(fd,0)=0x141;
  2173. WFIFOL(fd,2)=type;
  2174. WFIFOL(fd,6)=sd->status.vit;
  2175. WFIFOL(fd,10)=sd->paramb[2] + sd->parame[2];
  2176. len=14;
  2177. break;
  2178. case SP_INT:
  2179. WFIFOW(fd,0)=0x141;
  2180. WFIFOL(fd,2)=type;
  2181. WFIFOL(fd,6)=sd->status.int_;
  2182. WFIFOL(fd,10)=sd->paramb[3] + sd->parame[3];
  2183. len=14;
  2184. break;
  2185. case SP_DEX:
  2186. WFIFOW(fd,0)=0x141;
  2187. WFIFOL(fd,2)=type;
  2188. WFIFOL(fd,6)=sd->status.dex;
  2189. WFIFOL(fd,10)=sd->paramb[4] + sd->parame[4];
  2190. len=14;
  2191. break;
  2192. case SP_LUK:
  2193. WFIFOW(fd,0)=0x141;
  2194. WFIFOL(fd,2)=type;
  2195. WFIFOL(fd,6)=sd->status.luk;
  2196. WFIFOL(fd,10)=sd->paramb[5] + sd->parame[5];
  2197. len=14;
  2198. break;
  2199. case SP_CARTINFO:
  2200. WFIFOW(fd,0)=0x121;
  2201. WFIFOW(fd,2)=sd->cart_num;
  2202. WFIFOW(fd,4)=sd->cart_max_num;
  2203. WFIFOL(fd,6)=sd->cart_weight;
  2204. WFIFOL(fd,10)=sd->cart_max_weight;
  2205. len=14;
  2206. break;
  2207. default:
  2208. if(battle_config.error_log)
  2209. printf("clif_updatestatus : make %d routine\n",type);
  2210. return 1;
  2211. }
  2212. WFIFOSET(fd,len);
  2213. return 0;
  2214. }
  2215. int clif_changestatus(struct block_list *bl,int type,int val)
  2216. {
  2217. unsigned char buf[12];
  2218. struct map_session_data *sd = NULL;
  2219. nullpo_retr(0, bl);
  2220. if(bl->type == BL_PC)
  2221. sd = (struct map_session_data *)bl;
  2222. //printf("clif_changestatus id:%d type:%d val:%d\n",bl->id,type,val);
  2223. if(sd){
  2224. WBUFW(buf,0)=0x1ab;
  2225. WBUFL(buf,2)=bl->id;
  2226. WBUFW(buf,6)=type;
  2227. switch(type){
  2228. case SP_MANNER:
  2229. WBUFL(buf,8)=val;
  2230. break;
  2231. default:
  2232. if(battle_config.error_log)
  2233. printf("clif_changestatus : make %d routine\n",type);
  2234. return 1;
  2235. }
  2236. clif_send(buf,packet_len_table[0x1ab],bl,AREA_WOS);
  2237. }
  2238. return 0;
  2239. }
  2240. /*==========================================
  2241. *
  2242. *------------------------------------------
  2243. */
  2244. int clif_changelook(struct block_list *bl,int type,int val)
  2245. {
  2246. unsigned char buf[32];
  2247. struct map_session_data *sd = NULL;
  2248. nullpo_retr(0, bl);
  2249. if(bl->type == BL_PC)
  2250. sd = (struct map_session_data *)bl;
  2251. if(sd && sd->disguise > 23 && sd->disguise < 4001) // mob disguises [Valaris]
  2252. return 0;
  2253. #if PACKETVER < 4
  2254. if(sd && (type == LOOK_WEAPON || type == LOOK_SHIELD) && sd->view_class == 22)
  2255. val =0;
  2256. WBUFW(buf,0)=0xc3;
  2257. WBUFL(buf,2)=bl->id;
  2258. WBUFB(buf,6)=type;
  2259. WBUFB(buf,7)=val;
  2260. clif_send(buf,packet_len_table[0xc3],bl,AREA);
  2261. #else
  2262. if(sd && (type == LOOK_WEAPON || type == LOOK_SHIELD || type == LOOK_SHOES)) {
  2263. WBUFW(buf,0)=0x1d7;
  2264. WBUFL(buf,2)=bl->id;
  2265. if(type == LOOK_SHOES) {
  2266. WBUFB(buf,6)=9;
  2267. if(sd->equip_index[2] >= 0 && sd->inventory_data[sd->equip_index[2]]) {
  2268. if(sd->inventory_data[sd->equip_index[2]]->view_id > 0)
  2269. WBUFW(buf,7)=sd->inventory_data[sd->equip_index[2]]->view_id;
  2270. else
  2271. WBUFW(buf,7)=sd->status.inventory[sd->equip_index[2]].nameid;
  2272. } else
  2273. WBUFW(buf,7)=0;
  2274. WBUFW(buf,9)=0;
  2275. }
  2276. else {
  2277. WBUFB(buf,6)=2;
  2278. if(sd->equip_index[9] >= 0 && sd->inventory_data[sd->equip_index[9]] && sd->view_class != 22) {
  2279. if(sd->inventory_data[sd->equip_index[9]]->view_id > 0)
  2280. WBUFW(buf,7)=sd->inventory_data[sd->equip_index[9]]->view_id;
  2281. else
  2282. WBUFW(buf,7)=sd->status.inventory[sd->equip_index[9]].nameid;
  2283. } else
  2284. WBUFW(buf,7)=0;
  2285. if(sd->equip_index[8] >= 0 && sd->equip_index[8] != sd->equip_index[9] && sd->inventory_data[sd->equip_index[8]] &&
  2286. sd->view_class != 22) {
  2287. if(sd->inventory_data[sd->equip_index[8]]->view_id > 0)
  2288. WBUFW(buf,9)=sd->inventory_data[sd->equip_index[8]]->view_id;
  2289. else
  2290. WBUFW(buf,9)=sd->status.inventory[sd->equip_index[8]].nameid;
  2291. } else
  2292. WBUFW(buf,9)=0;
  2293. }
  2294. clif_send(buf,packet_len_table[0x1d7],bl,AREA);
  2295. }
  2296. else if(sd && (type == LOOK_BASE) && (val > 255))
  2297. {
  2298. WBUFW(buf,0)=0x1d7;
  2299. WBUFL(buf,2)=bl->id;
  2300. WBUFB(buf,6)=type;
  2301. WBUFW(buf,7)=val;
  2302. WBUFW(buf,9)=0;
  2303. clif_send(buf,packet_len_table[0x1d7],bl,AREA);
  2304. } else {
  2305. WBUFW(buf,0)=0xc3;
  2306. WBUFL(buf,2)=bl->id;
  2307. WBUFB(buf,6)=type;
  2308. WBUFB(buf,7)=val;
  2309. clif_send(buf,packet_len_table[0xc3],bl,AREA);
  2310. }
  2311. #endif
  2312. return 0;
  2313. }
  2314. /*==========================================
  2315. *
  2316. *------------------------------------------
  2317. */
  2318. int clif_initialstatus(struct map_session_data *sd)
  2319. {
  2320. int fd;
  2321. unsigned char *buf;
  2322. nullpo_retr(0, sd);
  2323. fd=sd->fd;
  2324. buf=WFIFOP(fd,0);
  2325. WBUFW(buf,0)=0xbd;
  2326. WBUFW(buf,2)=sd->status.status_point;
  2327. WBUFB(buf,4)=(sd->status.str > 255)? 255:sd->status.str;
  2328. WBUFB(buf,5)=pc_need_status_point(sd,SP_STR);
  2329. WBUFB(buf,6)=(sd->status.agi > 255)? 255:sd->status.agi;
  2330. WBUFB(buf,7)=pc_need_status_point(sd,SP_AGI);
  2331. WBUFB(buf,8)=(sd->status.vit > 255)? 255:sd->status.vit;
  2332. WBUFB(buf,9)=pc_need_status_point(sd,SP_VIT);
  2333. WBUFB(buf,10)=(sd->status.int_ > 255)? 255:sd->status.int_;
  2334. WBUFB(buf,11)=pc_need_status_point(sd,SP_INT);
  2335. WBUFB(buf,12)=(sd->status.dex > 255)? 255:sd->status.dex;
  2336. WBUFB(buf,13)=pc_need_status_point(sd,SP_DEX);
  2337. WBUFB(buf,14)=(sd->status.luk > 255)? 255:sd->status.luk;
  2338. WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK);
  2339. WBUFW(buf,16) = sd->base_atk + sd->watk;
  2340. WBUFW(buf,18) = sd->watk2; //atk bonus
  2341. WBUFW(buf,20) = sd->matk1;
  2342. WBUFW(buf,22) = sd->matk2;
  2343. WBUFW(buf,24) = sd->def; // def
  2344. WBUFW(buf,26) = sd->def2;
  2345. WBUFW(buf,28) = sd->mdef; // mdef
  2346. WBUFW(buf,30) = sd->mdef2;
  2347. WBUFW(buf,32) = sd->hit;
  2348. WBUFW(buf,34) = sd->flee;
  2349. WBUFW(buf,36) = sd->flee2/10;
  2350. WBUFW(buf,38) = sd->critical/10;
  2351. WBUFW(buf,40) = sd->status.karma;
  2352. WBUFW(buf,42) = sd->status.manner;
  2353. WFIFOSET(fd,packet_len_table[0xbd]);
  2354. clif_updatestatus(sd,SP_STR);
  2355. clif_updatestatus(sd,SP_AGI);
  2356. clif_updatestatus(sd,SP_VIT);
  2357. clif_updatestatus(sd,SP_INT);
  2358. clif_updatestatus(sd,SP_DEX);
  2359. clif_updatestatus(sd,SP_LUK);
  2360. clif_updatestatus(sd,SP_ATTACKRANGE);
  2361. clif_updatestatus(sd,SP_ASPD);
  2362. return 0;
  2363. }
  2364. /*==========================================
  2365. *矢装備
  2366. *------------------------------------------
  2367. */
  2368. int clif_arrowequip(struct map_session_data *sd,int val)
  2369. {
  2370. int fd;
  2371. nullpo_retr(0, sd);
  2372. if(sd->attacktarget && sd->attacktarget > 0) // [Valaris]
  2373. sd->attacktarget = 0;
  2374. fd=sd->fd;
  2375. WFIFOW(fd,0)=0x013c;
  2376. WFIFOW(fd,2)=val+2;//矢のアイテムID
  2377. WFIFOSET(fd,packet_len_table[0x013c]);
  2378. return 0;
  2379. }
  2380. /*==========================================
  2381. *
  2382. *------------------------------------------
  2383. */
  2384. int clif_arrow_fail(struct map_session_data *sd,int type)
  2385. {
  2386. int fd;
  2387. nullpo_retr(0, sd);
  2388. fd=sd->fd;
  2389. WFIFOW(fd,0)=0x013b;
  2390. WFIFOW(fd,2)=type;
  2391. WFIFOSET(fd,packet_len_table[0x013b]);
  2392. return 0;
  2393. }
  2394. /*==========================================
  2395. * 作成可能 矢リスト送信
  2396. *------------------------------------------
  2397. */
  2398. int clif_arrow_create_list(struct map_session_data *sd)
  2399. {
  2400. int i,c,view;
  2401. int fd;
  2402. nullpo_retr(0, sd);
  2403. fd=sd->fd;
  2404. WFIFOW(fd,0)=0x1ad;
  2405. for(i=0,c=0;i<MAX_SKILL_ARROW_DB;i++){
  2406. if(skill_arrow_db[i].nameid > 0 && pc_search_inventory(sd,skill_arrow_db[i].nameid)>=0){
  2407. if((view = itemdb_viewid(skill_arrow_db[i].nameid)) > 0)
  2408. WFIFOW(fd,c*2+4) = view;
  2409. else
  2410. WFIFOW(fd,c*2+4) = skill_arrow_db[i].nameid;
  2411. c++;
  2412. }
  2413. }
  2414. WFIFOW(fd,2)=c*2+4;
  2415. WFIFOSET(fd,WFIFOW(fd,2));
  2416. if(c > 0) sd->state.make_arrow_flag = 1;
  2417. return 0;
  2418. }
  2419. /*==========================================
  2420. *
  2421. *------------------------------------------
  2422. */
  2423. int clif_statusupack(struct map_session_data *sd,int type,int ok,int val)
  2424. {
  2425. int fd;
  2426. nullpo_retr(0, sd);
  2427. fd=sd->fd;
  2428. WFIFOW(fd,0)=0xbc;
  2429. WFIFOW(fd,2)=type;
  2430. WFIFOB(fd,4)=ok;
  2431. WFIFOB(fd,5)=val;
  2432. WFIFOSET(fd,packet_len_table[0xbc]);
  2433. return 0;
  2434. }
  2435. /*==========================================
  2436. *
  2437. *------------------------------------------
  2438. */
  2439. int clif_equipitemack(struct map_session_data *sd,int n,int pos,int ok)
  2440. {
  2441. int fd;
  2442. nullpo_retr(0, sd);
  2443. fd=sd->fd;
  2444. WFIFOW(fd,0)=0xaa;
  2445. WFIFOW(fd,2)=n+2;
  2446. WFIFOW(fd,4)=pos;
  2447. WFIFOB(fd,6)=ok;
  2448. WFIFOSET(fd,packet_len_table[0xaa]);
  2449. return 0;
  2450. }
  2451. /*==========================================
  2452. *
  2453. *------------------------------------------
  2454. */
  2455. int clif_unequipitemack(struct map_session_data *sd,int n,int pos,int ok)
  2456. {
  2457. int fd;
  2458. nullpo_retr(0, sd);
  2459. fd=sd->fd;
  2460. WFIFOW(fd,0)=0xac;
  2461. WFIFOW(fd,2)=n+2;
  2462. WFIFOW(fd,4)=pos;
  2463. WFIFOB(fd,6)=ok;
  2464. WFIFOSET(fd,packet_len_table[0xac]);
  2465. return 0;
  2466. }
  2467. /*==========================================
  2468. *
  2469. *------------------------------------------
  2470. */
  2471. int clif_misceffect(struct block_list* bl,int type)
  2472. {
  2473. unsigned char buf[32];
  2474. nullpo_retr(0, bl);
  2475. WBUFW(buf,0) = 0x19b;
  2476. WBUFL(buf,2) = bl->id;
  2477. WBUFL(buf,6) = type;
  2478. clif_send(buf,packet_len_table[0x19b],bl,AREA);
  2479. return 0;
  2480. }
  2481. int clif_misceffect2(struct block_list *bl, int type) {
  2482. unsigned char buf[24];
  2483. nullpo_retr(0, bl);
  2484. memset(buf, 0, packet_len_table[0x1f3]);
  2485. WBUFW(buf,0) = 0x1f3;
  2486. WBUFL(buf,2) = bl->id;
  2487. WBUFL(buf,6) = type;
  2488. clif_send(buf, packet_len_table[0x1f3], bl, AREA);
  2489. return 0;
  2490. }
  2491. /*==========================================
  2492. * 表示オプション変更
  2493. *------------------------------------------
  2494. */
  2495. int clif_changeoption(struct block_list* bl)
  2496. {
  2497. unsigned char buf[32];
  2498. short option;
  2499. struct status_change *sc_data;
  2500. static const int omask[]={ 0x10,0x20 };
  2501. static const int scnum[]={ SC_FALCON, SC_RIDING };
  2502. int i;
  2503. nullpo_retr(0, bl);
  2504. option = *battle_get_option(bl);
  2505. sc_data = battle_get_sc_data(bl);
  2506. WBUFW(buf,0) = 0x119;
  2507. WBUFL(buf,2) = bl->id;
  2508. WBUFW(buf,6) = *battle_get_opt1(bl);
  2509. WBUFW(buf,8) = *battle_get_opt2(bl);
  2510. WBUFW(buf,10) = option;
  2511. WBUFB(buf,12) = 0; // ??
  2512. if(bl->type==BL_PC) { // disguises [Valaris]
  2513. struct map_session_data *sd=(struct map_session_data *)bl;
  2514. if(sd && sd->disguise > 23 && sd->disguise < 4001) {
  2515. clif_send(buf,packet_len_table[0x119],bl,AREA_WOS);
  2516. clif_spawnpc(sd);
  2517. } else
  2518. clif_send(buf,packet_len_table[0x119],bl,AREA);
  2519. } else
  2520. clif_send(buf,packet_len_table[0x119],bl,AREA);
  2521. // アイコンの表示
  2522. for(i=0;i<sizeof(omask)/sizeof(omask[0]);i++){
  2523. if( option&omask[i] ){
  2524. if( sc_data[scnum[i]].timer==-1)
  2525. skill_status_change_start(bl,scnum[i],0,0,0,0,0,0);
  2526. } else {
  2527. skill_status_change_end(bl,scnum[i],-1);
  2528. }
  2529. }
  2530. return 0;
  2531. }
  2532. /*==========================================
  2533. *
  2534. *------------------------------------------
  2535. */
  2536. int clif_useitemack(struct map_session_data *sd,int index,int amount,int ok)
  2537. {
  2538. nullpo_retr(0, sd);
  2539. if(!ok) {
  2540. int fd=sd->fd;
  2541. WFIFOW(fd,0)=0xa8;
  2542. WFIFOW(fd,2)=index+2;
  2543. WFIFOW(fd,4)=amount;
  2544. WFIFOB(fd,6)=ok;
  2545. WFIFOSET(fd,packet_len_table[0xa8]);
  2546. }
  2547. else {
  2548. #if PACKETVER < 3
  2549. int fd=sd->fd;
  2550. WFIFOW(fd,0)=0xa8;
  2551. WFIFOW(fd,2)=index+2;
  2552. WFIFOW(fd,4)=amount;
  2553. WFIFOB(fd,6)=ok;
  2554. WFIFOSET(fd,packet_len_table[0xa8]);
  2555. #else
  2556. unsigned char buf[32];
  2557. WBUFW(buf,0)=0x1c8;
  2558. WBUFW(buf,2)=index+2;
  2559. if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0)
  2560. WBUFW(buf,4)=sd->inventory_data[index]->view_id;
  2561. else
  2562. WBUFW(buf,4)=sd->status.inventory[index].nameid;
  2563. WBUFL(buf,6)=sd->bl.id;
  2564. WBUFW(buf,10)=amount;
  2565. WBUFB(buf,12)=ok;
  2566. clif_send(buf,packet_len_table[0x1c8],&sd->bl,AREA);
  2567. #endif
  2568. }
  2569. return 0;
  2570. }
  2571. /*==========================================
  2572. *
  2573. *------------------------------------------
  2574. */
  2575. int clif_createchat(struct map_session_data *sd,int fail)
  2576. {
  2577. int fd;
  2578. nullpo_retr(0, sd);
  2579. fd=sd->fd;
  2580. WFIFOW(fd,0)=0xd6;
  2581. WFIFOB(fd,2)=fail;
  2582. WFIFOSET(fd,packet_len_table[0xd6]);
  2583. return 0;
  2584. }
  2585. /*==========================================
  2586. *
  2587. *------------------------------------------
  2588. */
  2589. int clif_dispchat(struct chat_data *cd,int fd)
  2590. {
  2591. unsigned char buf[128]; // 最大title(60バイト)+17
  2592. if(cd==NULL || *cd->owner==NULL)
  2593. return 1;
  2594. WBUFW(buf,0)=0xd7;
  2595. WBUFW(buf,2)=strlen((const char*)cd->title)+17;
  2596. WBUFL(buf,4)=(*cd->owner)->id;
  2597. WBUFL(buf,8)=cd->bl.id;
  2598. WBUFW(buf,12)=cd->limit;
  2599. WBUFW(buf,14)=cd->users;
  2600. WBUFB(buf,16)=cd->pub;
  2601. strcpy((char*)WBUFP(buf,17),(const char*)cd->title);
  2602. if(fd){
  2603. memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2));
  2604. WFIFOSET(fd,WBUFW(buf,2));
  2605. } else {
  2606. clif_send(buf,WBUFW(buf,2),*cd->owner,AREA_WOSC);
  2607. }
  2608. return 0;
  2609. }
  2610. /*==========================================
  2611. * chatの状態変更成功
  2612. * 外部の人用と命令コード(d7->df)が違うだけ
  2613. *------------------------------------------
  2614. */
  2615. int clif_changechatstatus(struct chat_data *cd)
  2616. {
  2617. unsigned char buf[128]; // 最大title(60バイト)+17
  2618. if(cd==NULL || cd->usersd[0]==NULL)
  2619. return 1;
  2620. WBUFW(buf,0)=0xdf;
  2621. WBUFW(buf,2)=strlen((char*)cd->title)+17;
  2622. WBUFL(buf,4)=cd->usersd[0]->bl.id;
  2623. WBUFL(buf,8)=cd->bl.id;
  2624. WBUFW(buf,12)=cd->limit;
  2625. WBUFW(buf,14)=cd->users;
  2626. WBUFB(buf,16)=cd->pub;
  2627. strcpy((char*)WBUFP(buf,17),(const char*)cd->title);
  2628. clif_send(buf,WBUFW(buf,2),&cd->usersd[0]->bl,CHAT);
  2629. return 0;
  2630. }
  2631. /*==========================================
  2632. *
  2633. *------------------------------------------
  2634. */
  2635. int clif_clearchat(struct chat_data *cd,int fd)
  2636. {
  2637. unsigned char buf[32];
  2638. nullpo_retr(0, cd);
  2639. WBUFW(buf,0)=0xd8;
  2640. WBUFL(buf,2)=cd->bl.id;
  2641. if(fd){
  2642. memcpy(WFIFOP(fd,0),buf,packet_len_table[0xd8]);
  2643. WFIFOSET(fd,packet_len_table[0xd8]);
  2644. } else {
  2645. clif_send(buf,packet_len_table[0xd8],*cd->owner,AREA_WOSC);
  2646. }
  2647. return 0;
  2648. }
  2649. /*==========================================
  2650. *
  2651. *------------------------------------------
  2652. */
  2653. int clif_joinchatfail(struct map_session_data *sd,int fail)
  2654. {
  2655. int fd;
  2656. nullpo_retr(0, sd);
  2657. fd=sd->fd;
  2658. WFIFOW(fd,0)=0xda;
  2659. WFIFOB(fd,2)=fail;
  2660. WFIFOSET(fd,packet_len_table[0xda]);
  2661. return 0;
  2662. }
  2663. /*==========================================
  2664. *
  2665. *------------------------------------------
  2666. */
  2667. int clif_joinchatok(struct map_session_data *sd,struct chat_data* cd)
  2668. {
  2669. int fd;
  2670. int i;
  2671. nullpo_retr(0, sd);
  2672. nullpo_retr(0, cd);
  2673. fd=sd->fd;
  2674. WFIFOW(fd,0)=0xdb;
  2675. WFIFOW(fd,2)=8+(28*cd->users);
  2676. WFIFOL(fd,4)=cd->bl.id;
  2677. for(i = 0;i < cd->users;i++){
  2678. WFIFOL(fd,8+i*28) = (i!=0)||((*cd->owner)->type==BL_NPC);
  2679. memcpy(WFIFOP(fd,8+i*28+4),cd->usersd[i]->status.name,24);
  2680. }
  2681. WFIFOSET(fd,WFIFOW(fd,2));
  2682. return 0;
  2683. }
  2684. /*==========================================
  2685. *
  2686. *------------------------------------------
  2687. */
  2688. int clif_addchat(struct chat_data* cd,struct map_session_data *sd)
  2689. {
  2690. unsigned char buf[32];
  2691. nullpo_retr(0, sd);
  2692. nullpo_retr(0, cd);
  2693. WBUFW(buf, 0) = 0x0dc;
  2694. WBUFW(buf, 2) = cd->users;
  2695. memcpy(WBUFP(buf, 4),sd->status.name,24);
  2696. clif_send(buf,packet_len_table[0xdc],&sd->bl,CHAT_WOS);
  2697. return 0;
  2698. }
  2699. /*==========================================
  2700. *
  2701. *------------------------------------------
  2702. */
  2703. int clif_changechatowner(struct chat_data* cd,struct map_session_data *sd)
  2704. {
  2705. unsigned char buf[64];
  2706. nullpo_retr(0, sd);
  2707. nullpo_retr(0, cd);
  2708. WBUFW(buf, 0) = 0xe1;
  2709. WBUFL(buf, 2) = 1;
  2710. memcpy(WBUFP(buf,6),cd->usersd[0]->status.name,24);
  2711. WBUFW(buf,30) = 0xe1;
  2712. WBUFL(buf,32) = 0;
  2713. memcpy(WBUFP(buf,36),sd->status.name,24);
  2714. clif_send(buf,packet_len_table[0xe1]*2,&sd->bl,CHAT);
  2715. return 0;
  2716. }
  2717. /*==========================================
  2718. *
  2719. *------------------------------------------
  2720. */
  2721. int clif_leavechat(struct chat_data* cd,struct map_session_data *sd)
  2722. {
  2723. unsigned char buf[32];
  2724. nullpo_retr(0, sd);
  2725. nullpo_retr(0, cd);
  2726. WBUFW(buf, 0) = 0xdd;
  2727. WBUFW(buf, 2) = cd->users-1;
  2728. memcpy(WBUFP(buf,4),sd->status.name,24);
  2729. WBUFB(buf,28) = 0;
  2730. clif_send(buf,packet_len_table[0xdd],&sd->bl,CHAT);
  2731. return 0;
  2732. }
  2733. /*==========================================
  2734. * 取り引き要請受け
  2735. *------------------------------------------
  2736. */
  2737. int clif_traderequest(struct map_session_data *sd,char *name)
  2738. {
  2739. int fd;
  2740. nullpo_retr(0, sd);
  2741. fd=sd->fd;
  2742. WFIFOW(fd,0)=0xe5;
  2743. strcpy((char*)WFIFOP(fd,2),name);
  2744. WFIFOSET(fd,packet_len_table[0xe5]);
  2745. return 0;
  2746. }
  2747. /*==========================================
  2748. * 取り引き要求応答
  2749. *------------------------------------------
  2750. */
  2751. int clif_tradestart(struct map_session_data *sd,int type)
  2752. {
  2753. int fd;
  2754. nullpo_retr(0, sd);
  2755. fd=sd->fd;
  2756. WFIFOW(fd,0)=0xe7;
  2757. WFIFOB(fd,2)=type;
  2758. WFIFOSET(fd,packet_len_table[0xe7]);
  2759. return 0;
  2760. }
  2761. /*==========================================
  2762. * 相手方からのアイテム追加
  2763. *------------------------------------------
  2764. */
  2765. int clif_tradeadditem(struct map_session_data *sd,struct map_session_data *tsd,int index,int amount)
  2766. {
  2767. int fd,j;
  2768. nullpo_retr(0, sd);
  2769. nullpo_retr(0, tsd);
  2770. fd=tsd->fd;
  2771. WFIFOW(fd,0)=0xe9;
  2772. WFIFOL(fd,2)=amount;
  2773. if(index==0){
  2774. WFIFOW(fd,6) = 0; // type id
  2775. WFIFOB(fd,8) = 0; //identify flag
  2776. WFIFOB(fd,9) = 0; // attribute
  2777. WFIFOB(fd,10)= 0; //refine
  2778. WFIFOW(fd,11)= 0; //card (4w)
  2779. WFIFOW(fd,13)= 0; //card (4w)
  2780. WFIFOW(fd,15)= 0; //card (4w)
  2781. WFIFOW(fd,17)= 0; //card (4w)
  2782. }
  2783. else{
  2784. index -= 2;
  2785. if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0)
  2786. WFIFOW(fd,6) = sd->inventory_data[index]->view_id;
  2787. else
  2788. WFIFOW(fd,6) = sd->status.inventory[index].nameid; // type id
  2789. WFIFOB(fd,8) = sd->status.inventory[index].identify; //identify flag
  2790. WFIFOB(fd,9) = sd->status.inventory[index].attribute; // attribute
  2791. WFIFOB(fd,10)= sd->status.inventory[index].refine; //refine
  2792. if(sd->status.inventory[index].card[0]==0x00ff || sd->status.inventory[index].card[0]==0x00fe || sd->status.inventory[index].card[0]==(short)0xff00) {
  2793. WFIFOW(fd,11)= sd->status.inventory[index].card[0]; //card (4w)
  2794. WFIFOW(fd,13)= sd->status.inventory[index].card[1]; //card (4w)
  2795. WFIFOW(fd,15)= sd->status.inventory[index].card[2]; //card (4w)
  2796. WFIFOW(fd,17)= sd->status.inventory[index].card[3]; //card (4w)
  2797. } else {
  2798. if(sd->status.inventory[index].card[0] > 0 && (j=itemdb_viewid(sd->status.inventory[index].card[0])) > 0)
  2799. WFIFOW(fd,11)= j;
  2800. else
  2801. WFIFOW(fd,11)= sd->status.inventory[index].card[0];
  2802. if(sd->status.inventory[index].card[1] > 0 && (j=itemdb_viewid(sd->status.inventory[index].card[1])) > 0)
  2803. WFIFOW(fd,13)= j;
  2804. else
  2805. WFIFOW(fd,13)= sd->status.inventory[index].card[1];
  2806. if(sd->status.inventory[index].card[2] > 0 && (j=itemdb_viewid(sd->status.inventory[index].card[2])) > 0)
  2807. WFIFOW(fd,15)= j;
  2808. else
  2809. WFIFOW(fd,15)= sd->status.inventory[index].card[2];
  2810. if(sd->status.inventory[index].card[3] > 0 && (j=itemdb_viewid(sd->status.inventory[index].card[3])) > 0)
  2811. WFIFOW(fd,17)= j;
  2812. else
  2813. WFIFOW(fd,17)= sd->status.inventory[index].card[3];
  2814. }
  2815. }
  2816. WFIFOSET(fd,packet_len_table[0xe9]);
  2817. return 0;
  2818. }
  2819. /*==========================================
  2820. * アイテム追加成功/失敗
  2821. *------------------------------------------
  2822. */
  2823. int clif_tradeitemok(struct map_session_data *sd,int index,int fail)
  2824. {
  2825. int fd;
  2826. nullpo_retr(0, sd);
  2827. fd=sd->fd;
  2828. WFIFOW(fd,0)=0xea;
  2829. WFIFOW(fd,2)=index;
  2830. WFIFOB(fd,4)=fail;
  2831. WFIFOSET(fd,packet_len_table[0xea]);
  2832. return 0;
  2833. }
  2834. /*==========================================
  2835. * 取り引きok押し
  2836. *------------------------------------------
  2837. */
  2838. int clif_tradedeal_lock(struct map_session_data *sd,int fail)
  2839. {
  2840. int fd;
  2841. nullpo_retr(0, sd);
  2842. fd=sd->fd;
  2843. WFIFOW(fd,0)=0xec;
  2844. WFIFOB(fd,2)=fail; // 0=you 1=the other person
  2845. WFIFOSET(fd,packet_len_table[0xec]);
  2846. return 0;
  2847. }
  2848. /*==========================================
  2849. * 取り引きがキャンセルされました
  2850. *------------------------------------------
  2851. */
  2852. int clif_tradecancelled(struct map_session_data *sd)
  2853. {
  2854. int fd;
  2855. nullpo_retr(0, sd);
  2856. fd=sd->fd;
  2857. WFIFOW(fd,0)=0xee;
  2858. WFIFOSET(fd,packet_len_table[0xee]);
  2859. return 0;
  2860. }
  2861. /*==========================================
  2862. * 取り引き完了
  2863. *------------------------------------------
  2864. */
  2865. int clif_tradecompleted(struct map_session_data *sd,int fail)
  2866. {
  2867. int fd;
  2868. nullpo_retr(0, sd);
  2869. fd=sd->fd;
  2870. WFIFOW(fd,0)=0xf0;
  2871. WFIFOB(fd,2)=fail;
  2872. WFIFOSET(fd,packet_len_table[0xf0]);
  2873. return 0;
  2874. }
  2875. /*==========================================
  2876. * カプラ倉庫のアイテム数を更新
  2877. *------------------------------------------
  2878. */
  2879. int clif_updatestorageamount(struct map_session_data *sd,struct storage *stor)
  2880. {
  2881. int fd;
  2882. nullpo_retr(0, sd);
  2883. nullpo_retr(0, stor);
  2884. fd=sd->fd;
  2885. WFIFOW(fd,0) = 0xf2; // update storage amount
  2886. WFIFOW(fd,2) = stor->storage_amount; //items
  2887. WFIFOW(fd,4) = MAX_STORAGE; //items max
  2888. WFIFOSET(fd,packet_len_table[0xf2]);
  2889. return 0;
  2890. }
  2891. /*==========================================
  2892. * カプラ倉庫にアイテムを追加する
  2893. *------------------------------------------
  2894. */
  2895. int clif_storageitemadded(struct map_session_data *sd,struct storage *stor,int index,int amount)
  2896. {
  2897. int view,fd,j;
  2898. nullpo_retr(0, sd);
  2899. nullpo_retr(0, stor);
  2900. fd=sd->fd;
  2901. WFIFOW(fd,0) =0xf4; // Storage item added
  2902. WFIFOW(fd,2) =index+1; // index
  2903. WFIFOL(fd,4) =amount; // amount
  2904. if((view = itemdb_viewid(stor->storage[index].nameid)) > 0)
  2905. WFIFOW(fd,8) =view;
  2906. else
  2907. WFIFOW(fd,8) =stor->storage[index].nameid; // id
  2908. WFIFOB(fd,10)=stor->storage[index].identify; //identify flag
  2909. WFIFOB(fd,11)=stor->storage[index].attribute; // attribute
  2910. WFIFOB(fd,12)=stor->storage[index].refine; //refine
  2911. if(stor->storage[index].card[0]==0x00ff || stor->storage[index].card[0]==0x00fe || stor->storage[index].card[0]==(short)0xff00) {
  2912. WFIFOW(fd,13)=stor->storage[index].card[0]; //card (4w)
  2913. WFIFOW(fd,15)=stor->storage[index].card[1]; //card (4w)
  2914. WFIFOW(fd,17)=stor->storage[index].card[2]; //card (4w)
  2915. WFIFOW(fd,19)=stor->storage[index].card[3]; //card (4w)
  2916. } else {
  2917. if(stor->storage[index].card[0] > 0 && (j=itemdb_viewid(stor->storage[index].card[0])) > 0)
  2918. WFIFOW(fd,13)= j;
  2919. else
  2920. WFIFOW(fd,13)= stor->storage[index].card[0];
  2921. if(stor->storage[index].card[1] > 0 && (j=itemdb_viewid(stor->storage[index].card[1])) > 0)
  2922. WFIFOW(fd,15)= j;
  2923. else
  2924. WFIFOW(fd,15)= stor->storage[index].card[1];
  2925. if(stor->storage[index].card[2] > 0 && (j=itemdb_viewid(stor->storage[index].card[2])) > 0)
  2926. WFIFOW(fd,17)= j;
  2927. else
  2928. WFIFOW(fd,17)= stor->storage[index].card[2];
  2929. if(stor->storage[index].card[3] > 0 && (j=itemdb_viewid(stor->storage[index].card[3])) > 0)
  2930. WFIFOW(fd,19)= j;
  2931. else
  2932. WFIFOW(fd,19)= stor->storage[index].card[3];
  2933. }
  2934. WFIFOSET(fd,packet_len_table[0xf4]);
  2935. return 0;
  2936. }
  2937. /*==========================================
  2938. *
  2939. *------------------------------------------
  2940. */
  2941. int clif_updateguildstorageamount(struct map_session_data *sd,struct guild_storage *stor)
  2942. {
  2943. int fd;
  2944. nullpo_retr(0, sd);
  2945. nullpo_retr(0, stor);
  2946. fd=sd->fd;
  2947. WFIFOW(fd,0) = 0xf2; // update storage amount
  2948. WFIFOW(fd,2) = stor->storage_amount; //items
  2949. WFIFOW(fd,4) = MAX_GUILD_STORAGE; //items max
  2950. WFIFOSET(fd,packet_len_table[0xf2]);
  2951. return 0;
  2952. }
  2953. /*==========================================
  2954. *
  2955. *------------------------------------------
  2956. */
  2957. int clif_guildstorageitemadded(struct map_session_data *sd,struct guild_storage *stor,int index,int amount)
  2958. {
  2959. int view,fd,j;
  2960. nullpo_retr(0, sd);
  2961. nullpo_retr(0, stor);
  2962. fd=sd->fd;
  2963. WFIFOW(fd,0) =0xf4; // Storage item added
  2964. WFIFOW(fd,2) =index+1; // index
  2965. WFIFOL(fd,4) =amount; // amount
  2966. if((view = itemdb_viewid(stor->storage[index].nameid)) > 0)
  2967. WFIFOW(fd,8) =view;
  2968. else
  2969. WFIFOW(fd,8) =stor->storage[index].nameid; // id
  2970. WFIFOB(fd,10)=stor->storage[index].identify; //identify flag
  2971. WFIFOB(fd,11)=stor->storage[index].attribute; // attribute
  2972. WFIFOB(fd,12)=stor->storage[index].refine; //refine
  2973. if(stor->storage[index].card[0]==0x00ff || stor->storage[index].card[0]==0x00fe || stor->storage[index].card[0]==(short)0xff00) {
  2974. WFIFOW(fd,13)=stor->storage[index].card[0]; //card (4w)
  2975. WFIFOW(fd,15)=stor->storage[index].card[1]; //card (4w)
  2976. WFIFOW(fd,17)=stor->storage[index].card[2]; //card (4w)
  2977. WFIFOW(fd,19)=stor->storage[index].card[3]; //card (4w)
  2978. } else {
  2979. if(stor->storage[index].card[0] > 0 && (j=itemdb_viewid(stor->storage[index].card[0])) > 0)
  2980. WFIFOW(fd,13)= j;
  2981. else
  2982. WFIFOW(fd,13)= stor->storage[index].card[0];
  2983. if(stor->storage[index].card[1] > 0 && (j=itemdb_viewid(stor->storage[index].card[1])) > 0)
  2984. WFIFOW(fd,15)= j;
  2985. else
  2986. WFIFOW(fd,15)= stor->storage[index].card[1];
  2987. if(stor->storage[index].card[2] > 0 && (j=itemdb_viewid(stor->storage[index].card[2])) > 0)
  2988. WFIFOW(fd,17)= j;
  2989. else
  2990. WFIFOW(fd,17)= stor->storage[index].card[2];
  2991. if(stor->storage[index].card[3] > 0 && (j=itemdb_viewid(stor->storage[index].card[3])) > 0)
  2992. WFIFOW(fd,19)= j;
  2993. else
  2994. WFIFOW(fd,19)= stor->storage[index].card[3];
  2995. }
  2996. WFIFOSET(fd,packet_len_table[0xf4]);
  2997. return 0;
  2998. }
  2999. /*==========================================
  3000. * カプラ倉庫からアイテムを取り去る
  3001. *------------------------------------------
  3002. */
  3003. int clif_storageitemremoved(struct map_session_data *sd,int index,int amount)
  3004. {
  3005. int fd;
  3006. nullpo_retr(0, sd);
  3007. fd=sd->fd;
  3008. WFIFOW(fd,0)=0xf6; // Storage item removed
  3009. WFIFOW(fd,2)=index+1;
  3010. WFIFOL(fd,4)=amount;
  3011. WFIFOSET(fd,packet_len_table[0xf6]);
  3012. return 0;
  3013. }
  3014. /*==========================================
  3015. * カプラ倉庫を閉じる
  3016. *------------------------------------------
  3017. */
  3018. int clif_storageclose(struct map_session_data *sd)
  3019. {
  3020. int fd;
  3021. nullpo_retr(0, sd);
  3022. fd=sd->fd;
  3023. WFIFOW(fd,0)=0xf8; // Storage Closed
  3024. WFIFOSET(fd,packet_len_table[0xf8]);
  3025. return 0;
  3026. }
  3027. //
  3028. // callback系 ?
  3029. //
  3030. /*==========================================
  3031. * PC表示
  3032. *------------------------------------------
  3033. */
  3034. void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* dstsd)
  3035. {
  3036. int len;
  3037. nullpo_retv(sd);
  3038. nullpo_retv(dstsd);
  3039. if(dstsd->walktimer != -1){
  3040. len = clif_set007b(dstsd,WFIFOP(sd->fd,0));
  3041. WFIFOSET(sd->fd,len);
  3042. } else {
  3043. len = clif_set0078(dstsd,WFIFOP(sd->fd,0));
  3044. WFIFOSET(sd->fd,len);
  3045. }
  3046. if(dstsd->chatID){
  3047. struct chat_data *cd;
  3048. cd=(struct chat_data*)map_id2bl(dstsd->chatID);
  3049. if(cd->usersd[0]==dstsd)
  3050. clif_dispchat(cd,sd->fd);
  3051. }
  3052. if(dstsd->vender_id){
  3053. clif_showvendingboard(&dstsd->bl,dstsd->message,sd->fd);
  3054. }
  3055. if(dstsd->spiritball > 0) {
  3056. clif_set01e1(dstsd,WFIFOP(sd->fd,0));
  3057. WFIFOSET(sd->fd,packet_len_table[0x1e1]);
  3058. }
  3059. if(battle_config.save_clothcolor==1 && dstsd->status.clothes_color > 0)
  3060. clif_changelook(&dstsd->bl,LOOK_CLOTHES_COLOR,dstsd->status.clothes_color);
  3061. if(sd->status.manner < 0)
  3062. clif_changestatus(&sd->bl,SP_MANNER,sd->status.manner);
  3063. }
  3064. /*==========================================
  3065. * NPC表示
  3066. *------------------------------------------
  3067. */
  3068. //fixed by Valaris
  3069. void clif_getareachar_npc(struct map_session_data* sd,struct npc_data* nd)
  3070. {
  3071. int len;
  3072. nullpo_retv(sd);
  3073. nullpo_retv(nd);
  3074. if(nd->class_ < 0 || nd->flag&1 || nd->class_ == INVISIBLE_CLASS)
  3075. return;
  3076. if(nd->state.state == MS_WALK){
  3077. len = clif_npc007b(nd,WFIFOP(sd->fd,0));
  3078. WFIFOSET(sd->fd,len);
  3079. } else {
  3080. len = clif_npc0078(nd,WFIFOP(sd->fd,0));
  3081. WFIFOSET(sd->fd,len);
  3082. }
  3083. if(nd->chat_id){
  3084. clif_dispchat((struct chat_data*)map_id2bl(nd->chat_id),sd->fd);
  3085. }
  3086. }
  3087. /*==========================================
  3088. * 移動停止
  3089. *------------------------------------------
  3090. */
  3091. int clif_movemob(struct mob_data *md)
  3092. {
  3093. unsigned char buf[256];
  3094. int len;
  3095. nullpo_retr(0, md);
  3096. len = clif_mob007b(md,buf);
  3097. clif_send(buf,len,&md->bl,AREA);
  3098. if(mob_get_equip(md->class_) > 0) // mob equipment [Valaris]
  3099. clif_mob_equip(md,mob_get_equip(md->class_));
  3100. if(md->size==2) // tiny/big mobs [Valaris]
  3101. clif_specialeffect(&md->bl,423,0);
  3102. else if(md->size==1)
  3103. clif_specialeffect(&md->bl,421,0);
  3104. return 0;
  3105. }
  3106. /*==========================================
  3107. * モンスターの位置修正
  3108. *------------------------------------------
  3109. */
  3110. int clif_fixmobpos(struct mob_data *md)
  3111. {
  3112. unsigned char buf[256];
  3113. int len;
  3114. nullpo_retr(0, md);
  3115. if(md->state.state == MS_WALK){
  3116. len = clif_mob007b(md,buf);
  3117. clif_send(buf,len,&md->bl,AREA);
  3118. } else {
  3119. len = clif_mob0078(md,buf);
  3120. clif_send(buf,len,&md->bl,AREA);
  3121. }
  3122. return 0;
  3123. }
  3124. /*==========================================
  3125. * PCの位置修正
  3126. *------------------------------------------
  3127. */
  3128. int clif_fixpcpos(struct map_session_data *sd)
  3129. {
  3130. unsigned char buf[256];
  3131. int len;
  3132. nullpo_retr(0, sd);
  3133. if(sd->walktimer != -1){
  3134. len = clif_set007b(sd,buf);
  3135. clif_send(buf,len,&sd->bl,AREA);
  3136. } else {
  3137. len = clif_set0078(sd,buf);
  3138. clif_send(buf,len,&sd->bl,AREA);
  3139. }
  3140. return 0;
  3141. }
  3142. /*==========================================
  3143. *
  3144. *------------------------------------------
  3145. */
  3146. int clif_fixpetpos(struct pet_data *pd)
  3147. {
  3148. unsigned char buf[256];
  3149. int len;
  3150. nullpo_retr(0, pd);
  3151. if(pd->state.state == MS_WALK){
  3152. len = clif_pet007b(pd,buf);
  3153. clif_send(buf,len,&pd->bl,AREA);
  3154. } else {
  3155. len = clif_pet0078(pd,buf);
  3156. clif_send(buf,len,&pd->bl,AREA);
  3157. }
  3158. return 0;
  3159. }
  3160. // npc walking [Valaris]
  3161. int clif_fixnpcpos(struct npc_data *nd)
  3162. {
  3163. unsigned char buf[256];
  3164. int len;
  3165. nullpo_retr(0, nd);
  3166. if(nd->state.state == MS_WALK){
  3167. len = clif_npc007b(nd,buf);
  3168. clif_send(buf,len,&nd->bl,AREA);
  3169. } else {
  3170. len = clif_npc0078(nd,buf);
  3171. clif_send(buf,len,&nd->bl,AREA);
  3172. }
  3173. return 0;
  3174. }
  3175. /*==========================================
  3176. * 通常攻撃エフェクト&ダメージ
  3177. *------------------------------------------
  3178. */
  3179. 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)
  3180. {
  3181. unsigned char buf[256];
  3182. struct status_change *sc_data;
  3183. nullpo_retr(0, src);
  3184. nullpo_retr(0, dst);
  3185. sc_data = battle_get_sc_data(dst);
  3186. if(type != 4 && dst->type == BL_PC && ((struct map_session_data *)dst)->special_state.infinite_endure)
  3187. type = 9;
  3188. if(sc_data) {
  3189. if(type != 4 && sc_data[SC_ENDURE].timer != -1)
  3190. type = 9;
  3191. if(sc_data[SC_HALLUCINATION].timer != -1) {
  3192. if(damage > 0)
  3193. damage = damage*(5+sc_data[SC_HALLUCINATION].val1) + rand()%100;
  3194. if(damage2 > 0)
  3195. damage2 = damage2*(5+sc_data[SC_HALLUCINATION].val1) + rand()%100;
  3196. }
  3197. }
  3198. WBUFW(buf,0)=0x8a;
  3199. WBUFL(buf,2)=src->id;
  3200. WBUFL(buf,6)=dst->id;
  3201. WBUFL(buf,10)=tick;
  3202. WBUFL(buf,14)=sdelay;
  3203. WBUFL(buf,18)=ddelay;
  3204. WBUFW(buf,22)=(damage > 0x7fff)? 0x7fff:damage;
  3205. WBUFW(buf,24)=div;
  3206. WBUFB(buf,26)=type;
  3207. WBUFW(buf,27)=damage2;
  3208. clif_send(buf,packet_len_table[0x8a],src,AREA);
  3209. return 0;
  3210. }
  3211. /*==========================================
  3212. *
  3213. *------------------------------------------
  3214. */
  3215. void clif_getareachar_mob(struct map_session_data* sd,struct mob_data* md)
  3216. {
  3217. int len;
  3218. nullpo_retv(sd);
  3219. nullpo_retv(md);
  3220. if (session[sd->fd] == NULL)
  3221. return;
  3222. if(md->state.state == MS_WALK){
  3223. len = clif_mob007b(md,WFIFOP(sd->fd,0));
  3224. WFIFOSET(sd->fd,len);
  3225. } else {
  3226. len = clif_mob0078(md,WFIFOP(sd->fd,0));
  3227. WFIFOSET(sd->fd,len);
  3228. }
  3229. if(mob_get_equip(md->class_) > 0) // mob equipment [Valaris]
  3230. clif_mob_equip(md,mob_get_equip(md->class_));
  3231. if(md->size==2) // tiny/big mobs [Valaris]
  3232. clif_specialeffect(&md->bl,423,0);
  3233. else if(md->size==1)
  3234. clif_specialeffect(&md->bl,421,0);
  3235. }
  3236. /*==========================================
  3237. *
  3238. *------------------------------------------
  3239. */
  3240. void clif_getareachar_pet(struct map_session_data* sd,struct pet_data* pd)
  3241. {
  3242. int len;
  3243. nullpo_retv(sd);
  3244. nullpo_retv(pd);
  3245. if(pd->state.state == MS_WALK){
  3246. len = clif_pet007b(pd,WFIFOP(sd->fd,0));
  3247. WFIFOSET(sd->fd,len);
  3248. } else {
  3249. len = clif_pet0078(pd,WFIFOP(sd->fd,0));
  3250. WFIFOSET(sd->fd,len);
  3251. }
  3252. }
  3253. /*==========================================
  3254. *
  3255. *------------------------------------------
  3256. */
  3257. void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fitem)
  3258. {
  3259. int view,fd;
  3260. nullpo_retv(sd);
  3261. nullpo_retv(fitem);
  3262. fd=sd->fd;
  3263. //009d <ID>.l <item ID>.w <identify flag>.B <X>.w <Y>.w <amount>.w <subX>.B <subY>.B
  3264. WFIFOW(fd,0)=0x9d;
  3265. WFIFOL(fd,2)=fitem->bl.id;
  3266. if((view = itemdb_viewid(fitem->item_data.nameid)) > 0)
  3267. WFIFOW(fd,6)=view;
  3268. else
  3269. WFIFOW(fd,6)=fitem->item_data.nameid;
  3270. WFIFOB(fd,8)=fitem->item_data.identify;
  3271. WFIFOW(fd,9)=fitem->bl.x;
  3272. WFIFOW(fd,11)=fitem->bl.y;
  3273. WFIFOW(fd,13)=fitem->item_data.amount;
  3274. WFIFOB(fd,15)=fitem->subx;
  3275. WFIFOB(fd,16)=fitem->suby;
  3276. WFIFOSET(fd,packet_len_table[0x9d]);
  3277. }
  3278. /*==========================================
  3279. * 場所スキルエフェクトが視界に入る
  3280. *------------------------------------------
  3281. */
  3282. int clif_getareachar_skillunit(struct map_session_data *sd,struct skill_unit *unit)
  3283. {
  3284. int fd;
  3285. struct block_list *bl;
  3286. nullpo_retr(0, unit);
  3287. fd=sd->fd;
  3288. bl=map_id2bl(unit->group->src_id);
  3289. #if PACKETVER < 3
  3290. memset(WFIFOP(fd,0),0,packet_len_table[0x11f]);
  3291. WFIFOW(fd, 0)=0x11f;
  3292. WFIFOL(fd, 2)=unit->bl.id;
  3293. WFIFOL(fd, 6)=unit->group->src_id;
  3294. WFIFOW(fd,10)=unit->bl.x;
  3295. WFIFOW(fd,12)=unit->bl.y;
  3296. WFIFOB(fd,14)=unit->group->unit_id;
  3297. WFIFOB(fd,15)=0;
  3298. WFIFOSET(fd,packet_len_table[0x11f]);
  3299. #else
  3300. memset(WFIFOP(fd,0),0,packet_len_table[0x1c9]);
  3301. WFIFOW(fd, 0)=0x1c9;
  3302. WFIFOL(fd, 2)=unit->bl.id;
  3303. WFIFOL(fd, 6)=unit->group->src_id;
  3304. WFIFOW(fd,10)=unit->bl.x;
  3305. WFIFOW(fd,12)=unit->bl.y;
  3306. WFIFOB(fd,14)=unit->group->unit_id;
  3307. WFIFOB(fd,15)=1;
  3308. WFIFOL(fd,15+1)=0; //1-4調べた限り固定
  3309. WFIFOL(fd,15+5)=0; //5-8調べた限り固定
  3310. //9-12マップごとで一定の77-80とはまた違う4バイトのかなり大きな数字
  3311. WFIFOL(fd,15+13)=unit->bl.y - 0x12; //13-16ユニットのY座標-18っぽい(Y:17でFF FF FF FF)
  3312. WFIFOL(fd,15+17)=0x004f37dd; //17-20調べた限り固定
  3313. WFIFOL(fd,15+21)=0x0012f674; //21-24調べた限り固定
  3314. WFIFOL(fd,15+25)=0x0012f664; //25-28調べた限り固定
  3315. WFIFOL(fd,15+29)=0x0012f654; //29-32調べた限り固定
  3316. WFIFOL(fd,15+33)=0x77527bbc; //33-36調べた限り固定
  3317. //37-39
  3318. WFIFOB(fd,15+40)=0x2d; //40調べた限り固定
  3319. WFIFOL(fd,15+41)=0; //41-44調べた限り0固定
  3320. WFIFOL(fd,15+45)=0; //45-48調べた限り0固定
  3321. WFIFOL(fd,15+49)=0; //49-52調べた限り0固定
  3322. WFIFOL(fd,15+53)=0x0048d919; //53-56調べた限り固定
  3323. WFIFOL(fd,15+57)=0x0000003e; //57-60調べた限り固定
  3324. WFIFOL(fd,15+61)=0x0012f66c; //61-64調べた限り固定
  3325. //65-68
  3326. //69-72
  3327. if(bl) WFIFOL(fd,15+73)=bl->y; //73-76術者のY座標
  3328. WFIFOL(fd,15+77)=unit->bl.m; //77-80マップIDかなぁ?かなり2バイトで足りそうな数字
  3329. WFIFOB(fd,15+81)=0xaa; //81終端文字0xaa
  3330. /* Graffiti [Valaris] */
  3331. if(unit->group->unit_id==0xb0) {
  3332. WFIFOL(fd,15)=1;
  3333. WFIFOL(fd,16)=1;
  3334. memcpy(WFIFOP(fd,17),unit->group->valstr,80);
  3335. }
  3336. WFIFOSET(fd,packet_len_table[0x1c9]);
  3337. #endif
  3338. if(unit->group->skill_id == WZ_ICEWALL)
  3339. clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,5);
  3340. return 0;
  3341. }
  3342. /*==========================================
  3343. * 場所スキルエフェクトが視界から消える
  3344. *------------------------------------------
  3345. */
  3346. int clif_clearchar_skillunit(struct skill_unit *unit,int fd)
  3347. {
  3348. nullpo_retr(0, unit);
  3349. WFIFOW(fd, 0)=0x120;
  3350. WFIFOL(fd, 2)=unit->bl.id;
  3351. WFIFOSET(fd,packet_len_table[0x120]);
  3352. if(unit->group->skill_id == WZ_ICEWALL)
  3353. clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2);
  3354. return 0;
  3355. }
  3356. /*==========================================
  3357. *
  3358. *------------------------------------------
  3359. */
  3360. int clif_01ac(struct block_list *bl)
  3361. {
  3362. unsigned char buf[32];
  3363. nullpo_retr(0, bl);
  3364. WBUFW(buf, 0) = 0x1ac;
  3365. WBUFL(buf, 2) = bl->id;
  3366. clif_send(buf,packet_len_table[0x1ac],bl,AREA);
  3367. return 0;
  3368. }
  3369. /*==========================================
  3370. *
  3371. *------------------------------------------
  3372. */
  3373. int clif_getareachar(struct block_list* bl,va_list ap)
  3374. {
  3375. struct map_session_data *sd;
  3376. nullpo_retr(0, bl);
  3377. nullpo_retr(0, ap);
  3378. sd=va_arg(ap,struct map_session_data*);
  3379. if (sd == NULL || session[sd->fd] == NULL)
  3380. return 0;
  3381. switch(bl->type){
  3382. case BL_PC:
  3383. if(sd==(struct map_session_data*)bl)
  3384. break;
  3385. clif_getareachar_pc(sd,(struct map_session_data*) bl);
  3386. break;
  3387. case BL_NPC:
  3388. clif_getareachar_npc(sd,(struct npc_data*) bl);
  3389. break;
  3390. case BL_MOB:
  3391. clif_getareachar_mob(sd,(struct mob_data*) bl);
  3392. break;
  3393. case BL_PET:
  3394. clif_getareachar_pet(sd,(struct pet_data*) bl);
  3395. break;
  3396. case BL_ITEM:
  3397. clif_getareachar_item(sd,(struct flooritem_data*) bl);
  3398. break;
  3399. case BL_SKILL:
  3400. clif_getareachar_skillunit(sd,(struct skill_unit *)bl);
  3401. break;
  3402. default:
  3403. if(battle_config.error_log)
  3404. printf("get area char ??? %d\n",bl->type);
  3405. break;
  3406. }
  3407. return 0;
  3408. }
  3409. /*==========================================
  3410. *
  3411. *------------------------------------------
  3412. */
  3413. int clif_pcoutsight(struct block_list *bl,va_list ap)
  3414. {
  3415. struct map_session_data *sd,*dstsd;
  3416. nullpo_retr(0, bl);
  3417. nullpo_retr(0, ap);
  3418. nullpo_retr(0, sd=va_arg(ap,struct map_session_data*));
  3419. switch(bl->type){
  3420. case BL_PC:
  3421. dstsd = (struct map_session_data*) bl;
  3422. if(sd != dstsd) {
  3423. clif_clearchar_id(dstsd->bl.id,0,sd->fd);
  3424. clif_clearchar_id(sd->bl.id,0,dstsd->fd);
  3425. if(dstsd->chatID){
  3426. struct chat_data *cd;
  3427. cd=(struct chat_data*)map_id2bl(dstsd->chatID);
  3428. if(cd->usersd[0]==dstsd)
  3429. clif_dispchat(cd,sd->fd);
  3430. }
  3431. if(dstsd->vender_id){
  3432. clif_closevendingboard(&dstsd->bl,sd->fd);
  3433. }
  3434. }
  3435. break;
  3436. case BL_NPC:
  3437. if( ((struct npc_data *)bl)->class_ != INVISIBLE_CLASS )
  3438. clif_clearchar_id(bl->id,0,sd->fd);
  3439. break;
  3440. case BL_MOB:
  3441. case BL_PET:
  3442. clif_clearchar_id(bl->id,0,sd->fd);
  3443. break;
  3444. case BL_ITEM:
  3445. clif_clearflooritem((struct flooritem_data*)bl,sd->fd);
  3446. break;
  3447. case BL_SKILL:
  3448. clif_clearchar_skillunit((struct skill_unit *)bl,sd->fd);
  3449. break;
  3450. }
  3451. return 0;
  3452. }
  3453. /*==========================================
  3454. *
  3455. *------------------------------------------
  3456. */
  3457. int clif_pcinsight(struct block_list *bl,va_list ap)
  3458. {
  3459. struct map_session_data *sd,*dstsd;
  3460. nullpo_retr(0, bl);
  3461. nullpo_retr(0, ap);
  3462. nullpo_retr(0, sd=va_arg(ap,struct map_session_data*));
  3463. switch(bl->type){
  3464. case BL_PC:
  3465. dstsd = (struct map_session_data *)bl;
  3466. if(sd != dstsd) {
  3467. clif_getareachar_pc(sd,dstsd);
  3468. clif_getareachar_pc(dstsd,sd);
  3469. }
  3470. break;
  3471. case BL_NPC:
  3472. clif_getareachar_npc(sd,(struct npc_data*)bl);
  3473. break;
  3474. case BL_MOB:
  3475. clif_getareachar_mob(sd,(struct mob_data*)bl);
  3476. break;
  3477. case BL_PET:
  3478. clif_getareachar_pet(sd,(struct pet_data*)bl);
  3479. break;
  3480. case BL_ITEM:
  3481. clif_getareachar_item(sd,(struct flooritem_data*)bl);
  3482. break;
  3483. case BL_SKILL:
  3484. clif_getareachar_skillunit(sd,(struct skill_unit *)bl);
  3485. break;
  3486. }
  3487. return 0;
  3488. }
  3489. /*==========================================
  3490. *
  3491. *------------------------------------------
  3492. */
  3493. int clif_moboutsight(struct block_list *bl,va_list ap)
  3494. {
  3495. struct map_session_data *sd;
  3496. struct mob_data *md;
  3497. nullpo_retr(0, bl);
  3498. nullpo_retr(0, ap);
  3499. nullpo_retr(0, md=va_arg(ap,struct mob_data*));
  3500. if(bl->type==BL_PC
  3501. && ((sd = (struct map_session_data*) bl) != NULL)
  3502. && session[sd->fd] != NULL) {
  3503. clif_clearchar_id(md->bl.id,0,sd->fd);
  3504. }
  3505. return 0;
  3506. }
  3507. /*==========================================
  3508. *
  3509. *------------------------------------------
  3510. */
  3511. int clif_mobinsight(struct block_list *bl,va_list ap)
  3512. {
  3513. struct map_session_data *sd;
  3514. struct mob_data *md;
  3515. nullpo_retr(0, bl);
  3516. nullpo_retr(0, ap);
  3517. md=va_arg(ap,struct mob_data*);
  3518. if(bl->type==BL_PC
  3519. && ((sd = (struct map_session_data*) bl) != NULL)
  3520. && session[sd->fd] != NULL) {
  3521. clif_getareachar_mob(sd,md);
  3522. }
  3523. return 0;
  3524. }
  3525. /*==========================================
  3526. *
  3527. *------------------------------------------
  3528. */
  3529. int clif_petoutsight(struct block_list *bl,va_list ap)
  3530. {
  3531. struct map_session_data *sd;
  3532. struct pet_data *pd;
  3533. nullpo_retr(0, bl);
  3534. nullpo_retr(0, ap);
  3535. nullpo_retr(0, pd=va_arg(ap,struct pet_data*));
  3536. if(bl->type==BL_PC
  3537. && ((sd = (struct map_session_data*) bl) != NULL)
  3538. && session[sd->fd] != NULL) {
  3539. clif_clearchar_id(pd->bl.id,0,sd->fd);
  3540. }
  3541. return 0;
  3542. }
  3543. // npc walking [Valaris]
  3544. int clif_npcoutsight(struct block_list *bl,va_list ap)
  3545. {
  3546. struct map_session_data *sd;
  3547. struct npc_data *nd;
  3548. nullpo_retr(0, bl);
  3549. nullpo_retr(0, ap);
  3550. nullpo_retr(0, nd=va_arg(ap,struct npc_data*));
  3551. if(bl->type==BL_PC
  3552. && ((sd = (struct map_session_data*) bl) != NULL)
  3553. && session[sd->fd] != NULL) {
  3554. clif_clearchar_id(nd->bl.id,0,sd->fd);
  3555. }
  3556. return 0;
  3557. }
  3558. /*==========================================
  3559. *
  3560. *------------------------------------------
  3561. */
  3562. int clif_petinsight(struct block_list *bl,va_list ap)
  3563. {
  3564. struct map_session_data *sd;
  3565. struct pet_data *pd;
  3566. nullpo_retr(0, bl);
  3567. nullpo_retr(0, ap);
  3568. pd=va_arg(ap,struct pet_data*);
  3569. if(bl->type==BL_PC
  3570. && ((sd = (struct map_session_data*) bl) != NULL)
  3571. && session[sd->fd] != NULL) {
  3572. clif_getareachar_pet(sd,pd);
  3573. }
  3574. return 0;
  3575. }
  3576. // npc walking [Valaris]
  3577. int clif_npcinsight(struct block_list *bl,va_list ap)
  3578. {
  3579. struct map_session_data *sd;
  3580. struct npc_data *nd;
  3581. nullpo_retr(0, bl);
  3582. nullpo_retr(0, ap);
  3583. nd=va_arg(ap,struct npc_data*);
  3584. if(bl->type==BL_PC
  3585. && ((sd = (struct map_session_data*) bl) != NULL)
  3586. && session[sd->fd] != NULL) {
  3587. clif_getareachar_npc(sd,nd);
  3588. }
  3589. return 0;
  3590. }
  3591. /*==========================================
  3592. *
  3593. *------------------------------------------
  3594. */
  3595. int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range)
  3596. {
  3597. int fd,id;
  3598. nullpo_retr(0, sd);
  3599. fd=sd->fd;
  3600. if( (id=sd->status.skill[skillid].id) <= 0 )
  3601. return 0;
  3602. WFIFOW(fd,0)=0x147;
  3603. WFIFOW(fd,2) = id;
  3604. if(type < 0)
  3605. WFIFOW(fd,4) = skill_get_inf(id);
  3606. else
  3607. WFIFOW(fd,4) = type;
  3608. WFIFOW(fd,6) = 0;
  3609. WFIFOW(fd,8) = sd->status.skill[skillid].lv;
  3610. WFIFOW(fd,10) = skill_get_sp(id,sd->status.skill[skillid].lv);
  3611. if(range < 0) {
  3612. range = skill_get_range(id,sd->status.skill[skillid].lv);
  3613. if(range < 0)
  3614. range = battle_get_range(&sd->bl) - (range + 1);
  3615. WFIFOW(fd,12)= range;
  3616. } else
  3617. WFIFOW(fd,12)= range;
  3618. memset(WFIFOP(fd,14),0,24);
  3619. if(!(skill_get_inf2(id)&0x01) || battle_config.quest_skill_learn == 1 || (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill) )
  3620. //WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_get_max(id) && sd->status.skill[skillid].flag ==0 )? 1:0;
  3621. WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_tree_get_max(id, sd->status.class_) && sd->status.skill[skillid].flag ==0 )? 1:0;
  3622. else
  3623. WFIFOB(fd,38) = 0;
  3624. WFIFOSET(fd,packet_len_table[0x147]);
  3625. return 0;
  3626. }
  3627. /*==========================================
  3628. * スキルリストを送信する
  3629. *------------------------------------------
  3630. */
  3631. int clif_skillinfoblock(struct map_session_data *sd)
  3632. {
  3633. int fd;
  3634. int i,c,len=4,id,range;
  3635. nullpo_retr(0, sd);
  3636. fd=sd->fd;
  3637. WFIFOW(fd,0)=0x10f;
  3638. for ( i = c = 0; i < MAX_SKILL; i++){
  3639. if( (id=sd->status.skill[i].id)!=0 ){
  3640. WFIFOW(fd,len ) = id;
  3641. WFIFOW(fd,len+2) = skill_get_inf(id);
  3642. WFIFOW(fd,len+4) = 0;
  3643. WFIFOW(fd,len+6) = sd->status.skill[i].lv;
  3644. WFIFOW(fd,len+8) = skill_get_sp(id,sd->status.skill[i].lv);
  3645. range = skill_get_range(id,sd->status.skill[i].lv);
  3646. if(range < 0)
  3647. range = battle_get_range(&sd->bl) - (range + 1);
  3648. WFIFOW(fd,len+10)= range;
  3649. memset(WFIFOP(fd,len+12),0,24);
  3650. if(!(skill_get_inf2(id)&0x01) || battle_config.quest_skill_learn == 1 || (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill) )
  3651. //WFIFOB(fd,len+36)= (sd->status.skill[i].lv < skill_get_max(id) && sd->status.skill[i].flag ==0 )? 1:0;
  3652. 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;
  3653. else
  3654. WFIFOB(fd,len+36) = 0;
  3655. len+=37;
  3656. c++;
  3657. }
  3658. }
  3659. WFIFOW(fd,2)=len;
  3660. WFIFOSET(fd,len);
  3661. return 0;
  3662. }
  3663. /*==========================================
  3664. * スキル割り振り通知
  3665. *------------------------------------------
  3666. */
  3667. int clif_skillup(struct map_session_data *sd,int skill_num)
  3668. {
  3669. int range,fd;
  3670. nullpo_retr(0, sd);
  3671. fd=sd->fd;
  3672. WFIFOW(fd,0) = 0x10e;
  3673. WFIFOW(fd,2) = skill_num;
  3674. WFIFOW(fd,4) = sd->status.skill[skill_num].lv;
  3675. WFIFOW(fd,6) = skill_get_sp(skill_num,sd->status.skill[skill_num].lv);
  3676. range = skill_get_range(skill_num,sd->status.skill[skill_num].lv);
  3677. if(range < 0)
  3678. range = battle_get_range(&sd->bl) - (range + 1);
  3679. WFIFOW(fd,8) = range;
  3680. //WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_get_max(sd->status.skill[skill_num].id)) ? 1 : 0;
  3681. WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_tree_get_max(sd->status.skill[skill_num].id, sd->status.class_)) ? 1 : 0;
  3682. WFIFOSET(fd,packet_len_table[0x10e]);
  3683. return 0;
  3684. }
  3685. /*==========================================
  3686. * スキル詠唱エフェクトを送信する
  3687. *------------------------------------------
  3688. */
  3689. int clif_skillcasting(struct block_list* bl,
  3690. int src_id,int dst_id,int dst_x,int dst_y,int skill_num,int casttime)
  3691. {
  3692. unsigned char buf[32];
  3693. WBUFW(buf,0) = 0x13e;
  3694. WBUFL(buf,2) = src_id;
  3695. WBUFL(buf,6) = dst_id;
  3696. WBUFW(buf,10) = dst_x;
  3697. WBUFW(buf,12) = dst_y;
  3698. WBUFW(buf,14) = skill_num;//魔法詠唱スキル
  3699. WBUFL(buf,16) = skill_get_pl(skill_num);//属性
  3700. WBUFL(buf,20) = casttime;//skill詠唱時間
  3701. clif_send(buf,packet_len_table[0x13e], bl, AREA);
  3702. return 0;
  3703. }
  3704. /*==========================================
  3705. *
  3706. *------------------------------------------
  3707. */
  3708. int clif_skillcastcancel(struct block_list* bl)
  3709. {
  3710. unsigned char buf[16];
  3711. nullpo_retr(0, bl);
  3712. WBUFW(buf,0) = 0x1b9;
  3713. WBUFL(buf,2) = bl->id;
  3714. clif_send(buf,packet_len_table[0x1b9], bl, AREA);
  3715. return 0;
  3716. }
  3717. /*==========================================
  3718. * スキル詠唱失敗
  3719. *------------------------------------------
  3720. */
  3721. int clif_skill_fail(struct map_session_data *sd,int skill_id,int type,int btype)
  3722. {
  3723. int fd;
  3724. nullpo_retr(0, sd);
  3725. fd=sd->fd;
  3726. // reset all variables [celest]
  3727. sd->skillx = sd->skilly = -1;
  3728. sd->skillid = sd->skilllv = -1;
  3729. sd->skillitem = sd->skillitemlv = -1;
  3730. if(type==0x4 && battle_config.display_delay_skill_fail==0){
  3731. return 0;
  3732. }
  3733. WFIFOW(fd,0) = 0x110;
  3734. WFIFOW(fd,2) = skill_id;
  3735. WFIFOW(fd,4) = btype;
  3736. WFIFOW(fd,6) = 0;
  3737. WFIFOB(fd,8) = 0;
  3738. WFIFOB(fd,9) = type;
  3739. WFIFOSET(fd,packet_len_table[0x110]);
  3740. return 0;
  3741. }
  3742. /*==========================================
  3743. * スキル攻撃エフェクト&ダメージ
  3744. *------------------------------------------
  3745. */
  3746. int clif_skill_damage(struct block_list *src,struct block_list *dst,
  3747. unsigned int tick,int sdelay,int ddelay,int damage,int div,int skill_id,int skill_lv,int type)
  3748. {
  3749. unsigned char buf[64];
  3750. struct status_change *sc_data;
  3751. nullpo_retr(0, src);
  3752. nullpo_retr(0, dst);
  3753. sc_data = battle_get_sc_data(dst);
  3754. if(type != 5 && dst->type == BL_PC && ((struct map_session_data *)dst)->special_state.infinite_endure)
  3755. type = 9;
  3756. if(sc_data) {
  3757. if(type != 5 && sc_data[SC_ENDURE].timer != -1)
  3758. type = 9;
  3759. if(sc_data[SC_HALLUCINATION].timer != -1 && damage > 0)
  3760. damage = damage*(5+sc_data[SC_HALLUCINATION].val1) + rand()%100;
  3761. }
  3762. #if PACKETVER < 3
  3763. WBUFW(buf,0)=0x114;
  3764. WBUFW(buf,2)=skill_id;
  3765. WBUFL(buf,4)=src->id;
  3766. WBUFL(buf,8)=dst->id;
  3767. WBUFL(buf,12)=tick;
  3768. WBUFL(buf,16)=sdelay;
  3769. WBUFL(buf,20)=ddelay;
  3770. WBUFW(buf,24)=damage;
  3771. WBUFW(buf,26)=skill_lv;
  3772. WBUFW(buf,28)=div;
  3773. WBUFB(buf,30)=(type>0)?type:skill_get_hit(skill_id);
  3774. clif_send(buf,packet_len_table[0x114],src,AREA);
  3775. #else
  3776. WBUFW(buf,0)=0x1de;
  3777. WBUFW(buf,2)=skill_id;
  3778. WBUFL(buf,4)=src->id;
  3779. WBUFL(buf,8)=dst->id;
  3780. WBUFL(buf,12)=tick;
  3781. WBUFL(buf,16)=sdelay;
  3782. WBUFL(buf,20)=ddelay;
  3783. WBUFL(buf,24)=damage;
  3784. WBUFW(buf,28)=skill_lv;
  3785. WBUFW(buf,30)=div;
  3786. WBUFB(buf,32)=(type>0)?type:skill_get_hit(skill_id);
  3787. clif_send(buf,packet_len_table[0x1de],src,AREA);
  3788. #endif
  3789. return 0;
  3790. }
  3791. /*==========================================
  3792. * 吹き飛ばしスキル攻撃エフェクト&ダメージ
  3793. *------------------------------------------
  3794. */
  3795. int clif_skill_damage2(struct block_list *src,struct block_list *dst,
  3796. unsigned int tick,int sdelay,int ddelay,int damage,int div,int skill_id,int skill_lv,int type)
  3797. {
  3798. unsigned char buf[64];
  3799. struct status_change *sc_data;
  3800. nullpo_retr(0, src);
  3801. nullpo_retr(0, dst);
  3802. sc_data = battle_get_sc_data(dst);
  3803. if(type != 5 && dst->type == BL_PC && ((struct map_session_data *)dst)->special_state.infinite_endure)
  3804. type = 9;
  3805. if(sc_data) {
  3806. if(type != 5 && sc_data[SC_ENDURE].timer != -1)
  3807. type = 9;
  3808. if(sc_data[SC_HALLUCINATION].timer != -1 && damage > 0)
  3809. damage = damage*(5+sc_data[SC_HALLUCINATION].val1) + rand()%100;
  3810. }
  3811. WBUFW(buf,0)=0x115;
  3812. WBUFW(buf,2)=skill_id;
  3813. WBUFL(buf,4)=src->id;
  3814. WBUFL(buf,8)=dst->id;
  3815. WBUFL(buf,12)=tick;
  3816. WBUFL(buf,16)=sdelay;
  3817. WBUFL(buf,20)=ddelay;
  3818. WBUFW(buf,24)=dst->x;
  3819. WBUFW(buf,26)=dst->y;
  3820. WBUFW(buf,28)=damage;
  3821. WBUFW(buf,30)=skill_lv;
  3822. WBUFW(buf,32)=div;
  3823. WBUFB(buf,34)=(type>0)?type:skill_get_hit(skill_id);
  3824. clif_send(buf,packet_len_table[0x115],src,AREA);
  3825. return 0;
  3826. }
  3827. /*==========================================
  3828. * 支援/回復スキルエフェクト
  3829. *------------------------------------------
  3830. */
  3831. int clif_skill_nodamage(struct block_list *src,struct block_list *dst,
  3832. int skill_id,int heal,int fail)
  3833. {
  3834. unsigned char buf[32];
  3835. nullpo_retr(0, src);
  3836. nullpo_retr(0, dst);
  3837. WBUFW(buf,0)=0x11a;
  3838. WBUFW(buf,2)=skill_id;
  3839. WBUFW(buf,4)=(heal > 0x7fff)? 0x7fff:heal;
  3840. WBUFL(buf,6)=dst->id;
  3841. WBUFL(buf,10)=src->id;
  3842. WBUFB(buf,14)=fail;
  3843. clif_send(buf,packet_len_table[0x11a],src,AREA);
  3844. return 0;
  3845. }
  3846. /*==========================================
  3847. * 場所スキルエフェクト
  3848. *------------------------------------------
  3849. */
  3850. int clif_skill_poseffect(struct block_list *src,int skill_id,int val,int x,int y,int tick)
  3851. {
  3852. unsigned char buf[32];
  3853. nullpo_retr(0, src);
  3854. WBUFW(buf,0)=0x117;
  3855. WBUFW(buf,2)=skill_id;
  3856. WBUFL(buf,4)=src->id;
  3857. WBUFW(buf,8)=val;
  3858. WBUFW(buf,10)=x;
  3859. WBUFW(buf,12)=y;
  3860. WBUFL(buf,14)=tick;
  3861. clif_send(buf,packet_len_table[0x117],src,AREA);
  3862. return 0;
  3863. }
  3864. /*==========================================
  3865. * 場所スキルエフェクト表示
  3866. *------------------------------------------
  3867. */
  3868. int clif_skill_setunit(struct skill_unit *unit)
  3869. {
  3870. unsigned char buf[128];
  3871. struct block_list *bl;
  3872. nullpo_retr(0, unit);
  3873. bl=map_id2bl(unit->group->src_id);
  3874. #if PACKETVER < 3
  3875. memset(WBUFP(buf, 0),0,packet_len_table[0x11f]);
  3876. WBUFW(buf, 0)=0x11f;
  3877. WBUFL(buf, 2)=unit->bl.id;
  3878. WBUFL(buf, 6)=unit->group->src_id;
  3879. WBUFW(buf,10)=unit->bl.x;
  3880. WBUFW(buf,12)=unit->bl.y;
  3881. WBUFB(buf,14)=unit->group->unit_id;
  3882. WBUFB(buf,15)=0;
  3883. clif_send(buf,packet_len_table[0x11f],&unit->bl,AREA);
  3884. #else
  3885. memset(WBUFP(buf, 0),0,packet_len_table[0x1c9]);
  3886. WBUFW(buf, 0)=0x1c9;
  3887. WBUFL(buf, 2)=unit->bl.id;
  3888. WBUFL(buf, 6)=unit->group->src_id;
  3889. WBUFW(buf,10)=unit->bl.x;
  3890. WBUFW(buf,12)=unit->bl.y;
  3891. WBUFB(buf,14)=unit->group->unit_id;
  3892. WBUFB(buf,15)=1;
  3893. WBUFL(buf,15+1)=0; //1-4調べた限り固定
  3894. WBUFL(buf,15+5)=0; //5-8調べた限り固定
  3895. //9-12マップごとで一定の77-80とはまた違う4バイトのかなり大きな数字
  3896. WBUFL(buf,15+13)=unit->bl.y - 0x12; //13-16ユニットのY座標-18っぽい(Y:17でFF FF FF FF)
  3897. WBUFL(buf,15+17)=0x004f37dd; //17-20調べた限り固定(0x1b2で0x004fdbddだった)
  3898. WBUFL(buf,15+21)=0x0012f674; //21-24調べた限り固定
  3899. WBUFL(buf,15+25)=0x0012f664; //25-28調べた限り固定
  3900. WBUFL(buf,15+29)=0x0012f654; //29-32調べた限り固定
  3901. WBUFL(buf,15+33)=0x77527bbc; //33-36調べた限り固定
  3902. //37-39
  3903. WBUFB(buf,15+40)=0x2d; //40調べた限り固定
  3904. WBUFL(buf,15+41)=0; //41-44調べた限り0固定
  3905. WBUFL(buf,15+45)=0; //45-48調べた限り0固定
  3906. WBUFL(buf,15+49)=0; //49-52調べた限り0固定
  3907. WBUFL(buf,15+53)=0x0048d919; //53-56調べた限り固定(0x01b2で0x00495119だった)
  3908. WBUFL(buf,15+57)=0x0000003e; //57-60調べた限り固定
  3909. WBUFL(buf,15+61)=0x0012f66c; //61-64調べた限り固定
  3910. //65-68
  3911. //69-72
  3912. if(bl) WBUFL(buf,15+73)=bl->y; //73-76術者のY座標
  3913. WBUFL(buf,15+77)=unit->bl.m; //77-80マップIDかなぁ?かなり2バイトで足りそうな数字
  3914. WBUFB(buf,15+81)=0xaa; //81終端文字0xaa
  3915. /* Graffiti [Valaris] */
  3916. if(unit->group->unit_id==0xb0) {
  3917. WBUFL(buf,15)=1;
  3918. WBUFL(buf,16)=1;
  3919. memcpy(WBUFP(buf,17),unit->group->valstr,80);
  3920. }
  3921. clif_send(buf,packet_len_table[0x1c9],&unit->bl,AREA);
  3922. #endif
  3923. return 0;
  3924. }
  3925. /*==========================================
  3926. * 場所スキルエフェクト削除
  3927. *------------------------------------------
  3928. */
  3929. int clif_skill_delunit(struct skill_unit *unit)
  3930. {
  3931. unsigned char buf[16];
  3932. nullpo_retr(0, unit);
  3933. WBUFW(buf, 0)=0x120;
  3934. WBUFL(buf, 2)=unit->bl.id;
  3935. clif_send(buf,packet_len_table[0x120],&unit->bl,AREA);
  3936. return 0;
  3937. }
  3938. /*==========================================
  3939. * ワープ場所選択
  3940. *------------------------------------------
  3941. */
  3942. int clif_skill_warppoint(struct map_session_data *sd,int skill_num,
  3943. const char *map1,const char *map2,const char *map3,const char *map4)
  3944. {
  3945. int fd;
  3946. nullpo_retr(0, sd);
  3947. fd=sd->fd;
  3948. WFIFOW(fd,0)=0x11c;
  3949. WFIFOW(fd,2)=skill_num;
  3950. strncpy((char*)WFIFOP(fd, 4),map1,16);
  3951. strncpy((char*)WFIFOP(fd,20),map2,16);
  3952. strncpy((char*)WFIFOP(fd,36),map3,16);
  3953. strncpy((char*)WFIFOP(fd,52),map4,16);
  3954. WFIFOSET(fd,packet_len_table[0x11c]);
  3955. return 0;
  3956. }
  3957. /*==========================================
  3958. * メモ応答
  3959. *------------------------------------------
  3960. */
  3961. int clif_skill_memo(struct map_session_data *sd,int flag)
  3962. {
  3963. int fd;
  3964. nullpo_retr(0, sd);
  3965. fd=sd->fd;
  3966. WFIFOW(fd,0)=0x11e;
  3967. WFIFOB(fd,2)=flag;
  3968. WFIFOSET(fd,packet_len_table[0x11e]);
  3969. return 0;
  3970. }
  3971. int clif_skill_teleportmessage(struct map_session_data *sd,int flag)
  3972. {
  3973. int fd;
  3974. nullpo_retr(0, sd);
  3975. fd=sd->fd;
  3976. WFIFOW(fd,0)=0x189;
  3977. WFIFOW(fd,2)=flag;
  3978. WFIFOSET(fd,packet_len_table[0x189]);
  3979. return 0;
  3980. }
  3981. /*==========================================
  3982. * モンスター情報
  3983. *------------------------------------------
  3984. */
  3985. int clif_skill_estimation(struct map_session_data *sd,struct block_list *dst)
  3986. {
  3987. struct mob_data *md;
  3988. unsigned char buf[64];
  3989. int i;
  3990. nullpo_retr(0, sd);
  3991. nullpo_retr(0, dst);
  3992. if(dst->type!=BL_MOB )
  3993. return 0;
  3994. if((md=(struct mob_data *)dst) == NULL)
  3995. return 0;
  3996. WBUFW(buf, 0)=0x18c;
  3997. WBUFW(buf, 2)=mob_get_viewclass(md->class_);
  3998. WBUFW(buf, 4)=md->level;
  3999. WBUFW(buf, 6)=mob_db[md->class_].size;
  4000. WBUFL(buf, 8)=md->hp;
  4001. WBUFW(buf,12)=battle_get_def2(&md->bl);
  4002. WBUFW(buf,14)=mob_db[md->class_].race;
  4003. WBUFW(buf,16)=battle_get_mdef2(&md->bl) - (mob_db[md->class_].vit>>1);
  4004. WBUFW(buf,18)=battle_get_elem_type(&md->bl);
  4005. for(i=0;i<9;i++)
  4006. WBUFB(buf,20+i)= battle_attr_fix(100,i+1,md->def_ele);
  4007. if(sd->status.party_id>0)
  4008. clif_send(buf,packet_len_table[0x18c],&sd->bl,PARTY_AREA);
  4009. else{
  4010. memcpy(WFIFOP(sd->fd,0),buf,packet_len_table[0x18c]);
  4011. WFIFOSET(sd->fd,packet_len_table[0x18c]);
  4012. }
  4013. return 0;
  4014. }
  4015. /*==========================================
  4016. * アイテム合成可能リスト
  4017. *------------------------------------------
  4018. */
  4019. int clif_skill_produce_mix_list(struct map_session_data *sd,int trigger)
  4020. {
  4021. int i,c,view,fd;
  4022. nullpo_retr(0, sd);
  4023. fd=sd->fd;
  4024. WFIFOW(fd, 0)=0x18d;
  4025. for(i=0,c=0;i<MAX_SKILL_PRODUCE_DB;i++){
  4026. if( skill_can_produce_mix(sd,skill_produce_db[i].nameid,trigger) ){
  4027. if((view = itemdb_viewid(skill_produce_db[i].nameid)) > 0)
  4028. WFIFOW(fd,c*8+ 4)= view;
  4029. else
  4030. WFIFOW(fd,c*8+ 4)= skill_produce_db[i].nameid;
  4031. WFIFOW(fd,c*8+ 6)= 0x0012;
  4032. WFIFOL(fd,c*8+ 8)= sd->status.char_id;
  4033. c++;
  4034. }
  4035. }
  4036. WFIFOW(fd, 2)=c*8+8;
  4037. WFIFOSET(fd,WFIFOW(fd,2));
  4038. if(c > 0) sd->state.produce_flag = 1;
  4039. return 0;
  4040. }
  4041. /*==========================================
  4042. * 状態異常アイコン/メッセージ表示
  4043. *------------------------------------------
  4044. */
  4045. int clif_status_change(struct block_list *bl,int type,int flag)
  4046. {
  4047. unsigned char buf[16];
  4048. nullpo_retr(0, bl);
  4049. WBUFW(buf,0)=0x0196;
  4050. WBUFW(buf,2)=type;
  4051. WBUFL(buf,4)=bl->id;
  4052. WBUFB(buf,8)=flag;
  4053. clif_send(buf,packet_len_table[0x196],bl,AREA);
  4054. return 0;
  4055. }
  4056. /*==========================================
  4057. * Send message (modified by [Yor])
  4058. *------------------------------------------
  4059. */
  4060. int clif_displaymessage(const int fd, char* mes)
  4061. {
  4062. //Console [Wizputer]
  4063. if (fd == 0)
  4064. printf("\033[0;36mConsole: \033[0m\033[1m%s\033[0m\n", mes);
  4065. else {
  4066. int len_mes = strlen(mes);
  4067. if (len_mes > 0) { // don't send a void message (it's not displaying on the client chat). @help can send void line.
  4068. WFIFOW(fd,0) = 0x8e;
  4069. WFIFOW(fd,2) = 5 + len_mes; // 4 + len + NULL teminate
  4070. memcpy(WFIFOP(fd,4), mes, len_mes + 1);
  4071. WFIFOSET(fd, 5 + len_mes);
  4072. }
  4073. }
  4074. return 0;
  4075. }
  4076. /*==========================================
  4077. * 天の声を送信する
  4078. *------------------------------------------
  4079. */
  4080. int clif_GMmessage(struct block_list *bl, char* mes, int len, int flag)
  4081. {
  4082. unsigned char *buf;
  4083. int lp;
  4084. lp = (flag & 0x10) ? 8 : 4;
  4085. buf = (unsigned char*)aCallocA(len + lp, sizeof(unsigned char));
  4086. WBUFW(buf,0) = 0x9a;
  4087. WBUFW(buf,2) = len + lp;
  4088. WBUFL(buf,4) = 0x65756c62;
  4089. memcpy(WBUFP(buf,lp), mes, len);
  4090. flag &= 0x07;
  4091. clif_send(buf, WBUFW(buf,2), bl,
  4092. (flag == 1) ? ALL_SAMEMAP :
  4093. (flag == 2) ? AREA :
  4094. (flag == 3) ? SELF :
  4095. ALL_CLIENT);
  4096. if(buf) aFree(buf);
  4097. return 0;
  4098. }
  4099. /*==========================================
  4100. * HPSP回復エフェクトを送信する
  4101. *------------------------------------------
  4102. */
  4103. int clif_heal(int fd,int type,int val)
  4104. {
  4105. WFIFOW(fd,0)=0x13d;
  4106. WFIFOW(fd,2)=type;
  4107. WFIFOW(fd,4)=val;
  4108. WFIFOSET(fd,packet_len_table[0x13d]);
  4109. return 0;
  4110. }
  4111. /*==========================================
  4112. * 復活する
  4113. *------------------------------------------
  4114. */
  4115. int clif_resurrection(struct block_list *bl,int type)
  4116. {
  4117. unsigned char buf[16];
  4118. nullpo_retr(0, bl);
  4119. if(bl->type==BL_PC) { // disguises [Valaris]
  4120. struct map_session_data *sd=((struct map_session_data *)bl);
  4121. if(sd && sd->disguise > 23 && sd->disguise < 4001)
  4122. clif_spawnpc(sd);
  4123. }
  4124. WBUFW(buf,0)=0x148;
  4125. WBUFL(buf,2)=bl->id;
  4126. WBUFW(buf,6)=type;
  4127. clif_send(buf,packet_len_table[0x148],bl,type==1 ? AREA : AREA_WOS);
  4128. return 0;
  4129. }
  4130. /*==========================================
  4131. * PVP実装?(仮)
  4132. *------------------------------------------
  4133. */
  4134. int clif_set0199(int fd,int type)
  4135. {
  4136. WFIFOW(fd,0)=0x199;
  4137. WFIFOW(fd,2)=type;
  4138. WFIFOSET(fd,packet_len_table[0x199]);
  4139. return 0;
  4140. }
  4141. /*==========================================
  4142. * PVP実装?(仮)
  4143. *------------------------------------------
  4144. */
  4145. int clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type)
  4146. {
  4147. nullpo_retr(0, sd);
  4148. if(map[sd->bl.m].flag.nopvp)
  4149. return 0;
  4150. if(type == 2) {
  4151. WFIFOW(sd->fd,0) = 0x19a;
  4152. WFIFOL(sd->fd,2) = sd->bl.id;
  4153. if(pvprank<=0)
  4154. pc_calc_pvprank(sd);
  4155. WFIFOL(sd->fd,6) = pvprank;
  4156. WFIFOL(sd->fd,10) = pvpnum;
  4157. WFIFOSET(sd->fd,packet_len_table[0x19a]);
  4158. } else {
  4159. unsigned char buf[32];
  4160. WBUFW(buf,0) = 0x19a;
  4161. WBUFL(buf,2) = sd->bl.id;
  4162. if(sd->status.option&0x46)
  4163. // WTF? a -1 to an unsigned value...
  4164. WBUFL(buf,6) = -1;
  4165. else
  4166. if(pvprank<=0)
  4167. pc_calc_pvprank(sd);
  4168. WBUFL(buf,6) = pvprank;
  4169. WBUFL(buf,10) = pvpnum;
  4170. if(!type)
  4171. clif_send(buf,packet_len_table[0x19a],&sd->bl,AREA);
  4172. else
  4173. clif_send(buf,packet_len_table[0x19a],&sd->bl,ALL_SAMEMAP);
  4174. }
  4175. return 0;
  4176. }
  4177. /*==========================================
  4178. *
  4179. *------------------------------------------
  4180. */
  4181. int clif_send0199(int map,int type)
  4182. {
  4183. struct block_list bl;
  4184. unsigned char buf[16];
  4185. bl.m = map;
  4186. WBUFW(buf,0)=0x199;
  4187. WBUFW(buf,2)=type;
  4188. clif_send(buf,packet_len_table[0x199],&bl,ALL_SAMEMAP);
  4189. return 0;
  4190. }
  4191. /*==========================================
  4192. * 精錬エフェクトを送信する
  4193. *------------------------------------------
  4194. */
  4195. int clif_refine(int fd,struct map_session_data *sd,int fail,int index,int val)
  4196. {
  4197. WFIFOW(fd,0)=0x188;
  4198. WFIFOW(fd,2)=fail;
  4199. WFIFOW(fd,4)=index+2;
  4200. WFIFOW(fd,6)=val;
  4201. WFIFOSET(fd,packet_len_table[0x188]);
  4202. return 0;
  4203. }
  4204. /*==========================================
  4205. * Wisp/page is transmitted to the destination player
  4206. *------------------------------------------
  4207. */
  4208. int clif_wis_message(int fd, char *nick, char *mes, int mes_len) // R 0097 <len>.w <nick>.24B <message>.?B
  4209. {
  4210. // printf("clif_wis_message(%d, %s, %s)\n", fd, nick, mes);
  4211. WFIFOW(fd,0) = 0x97;
  4212. WFIFOW(fd,2) = mes_len + 24 + 4;
  4213. memcpy(WFIFOP(fd,4), nick, 24);
  4214. memcpy(WFIFOP(fd,28), mes, mes_len);
  4215. WFIFOSET(fd,WFIFOW(fd,2));
  4216. return 0;
  4217. }
  4218. /*==========================================
  4219. * The transmission result of Wisp/page is transmitted to the source player
  4220. *------------------------------------------
  4221. */
  4222. 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
  4223. {
  4224. WFIFOW(fd,0) = 0x98;
  4225. WFIFOW(fd,2) = flag;
  4226. WFIFOSET(fd,packet_len_table[0x98]);
  4227. return 0;
  4228. }
  4229. /*==========================================
  4230. * キャラID名前引き結果を送信する
  4231. *------------------------------------------
  4232. */
  4233. int clif_solved_charname(struct map_session_data *sd,int char_id)
  4234. {
  4235. char *p= map_charid2nick(char_id);
  4236. int fd;
  4237. nullpo_retr(0, sd);
  4238. fd=sd->fd;
  4239. if(p!=NULL){
  4240. WFIFOW(fd,0)=0x194;
  4241. WFIFOL(fd,2)=char_id;
  4242. memcpy(WFIFOP(fd,6), p,24 );
  4243. WFIFOSET(fd,packet_len_table[0x194]);
  4244. }else{
  4245. map_reqchariddb(sd,char_id);
  4246. chrif_searchcharid(char_id);
  4247. }
  4248. return 0;
  4249. }
  4250. /*==========================================
  4251. * カードの挿入可能リストを返す
  4252. *------------------------------------------
  4253. */
  4254. int clif_use_card(struct map_session_data *sd,int idx)
  4255. {
  4256. nullpo_retr(0, sd);
  4257. if(sd->inventory_data[idx]) {
  4258. int i,c;
  4259. int ep=sd->inventory_data[idx]->equip;
  4260. int fd=sd->fd;
  4261. WFIFOW(fd,0)=0x017b;
  4262. for(i=c=0;i<MAX_INVENTORY;i++){
  4263. int j;
  4264. if(sd->inventory_data[i] == NULL)
  4265. continue;
  4266. if(sd->inventory_data[i]->type!=4 && sd->inventory_data[i]->type!=5) // 武器防具じゃない
  4267. continue;
  4268. if(sd->status.inventory[i].card[0]==0x00ff) // 製造武器
  4269. continue;
  4270. if(sd->status.inventory[i].card[0]==(short)0xff00 || sd->status.inventory[i].card[0]==0x00fe)
  4271. continue;
  4272. if(sd->status.inventory[i].identify==0 ) // 未鑑定
  4273. continue;
  4274. if((sd->inventory_data[i]->equip&ep)==0) // 装備個所が違う
  4275. continue;
  4276. if(sd->inventory_data[i]->type==4 && ep==32) // 盾カードと両手武器
  4277. continue;
  4278. for(j=0;j<sd->inventory_data[i]->slot;j++){
  4279. if( sd->status.inventory[i].card[j]==0 )
  4280. break;
  4281. }
  4282. if(j==sd->inventory_data[i]->slot) // すでにカードが一杯
  4283. continue;
  4284. WFIFOW(fd,4+c*2)=i+2;
  4285. c++;
  4286. }
  4287. WFIFOW(fd,2)=4+c*2;
  4288. WFIFOSET(fd,WFIFOW(fd,2));
  4289. }
  4290. return 0;
  4291. }
  4292. /*==========================================
  4293. * カードの挿入終了
  4294. *------------------------------------------
  4295. */
  4296. int clif_insert_card(struct map_session_data *sd,int idx_equip,int idx_card,int flag)
  4297. {
  4298. int fd;
  4299. nullpo_retr(0, sd);
  4300. fd=sd->fd;
  4301. WFIFOW(fd,0)=0x17d;
  4302. WFIFOW(fd,2)=idx_equip+2;
  4303. WFIFOW(fd,4)=idx_card+2;
  4304. WFIFOB(fd,6)=flag;
  4305. WFIFOSET(fd,packet_len_table[0x17d]);
  4306. return 0;
  4307. }
  4308. /*==========================================
  4309. * 鑑定可能アイテムリスト送信
  4310. *------------------------------------------
  4311. */
  4312. int clif_item_identify_list(struct map_session_data *sd)
  4313. {
  4314. int i,c;
  4315. int fd;
  4316. nullpo_retr(0, sd);
  4317. fd=sd->fd;
  4318. WFIFOW(fd,0)=0x177;
  4319. for(i=c=0;i<MAX_INVENTORY;i++){
  4320. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  4321. WFIFOW(fd,c*2+4)=i+2;
  4322. c++;
  4323. }
  4324. }
  4325. if(c > 0) {
  4326. WFIFOW(fd,2)=c*2+4;
  4327. WFIFOSET(fd,WFIFOW(fd,2));
  4328. }
  4329. return 0;
  4330. }
  4331. /*==========================================
  4332. * 鑑定結果
  4333. *------------------------------------------
  4334. */
  4335. int clif_item_identified(struct map_session_data *sd,int idx,int flag)
  4336. {
  4337. int fd;
  4338. nullpo_retr(0, sd);
  4339. fd=sd->fd;
  4340. WFIFOW(fd, 0)=0x179;
  4341. WFIFOW(fd, 2)=idx+2;
  4342. WFIFOB(fd, 4)=flag;
  4343. WFIFOSET(fd,packet_len_table[0x179]);
  4344. return 0;
  4345. }
  4346. /*==========================================
  4347. * 修理可能アイテムリスト送信
  4348. * ※実際のパケットがわからないので動作しません
  4349. *------------------------------------------
  4350. */
  4351. int clif_item_repair_list(struct map_session_data *sd)
  4352. {
  4353. int i,c;
  4354. int fd;
  4355. nullpo_retr(0, sd);
  4356. fd=sd->fd;
  4357. WFIFOW(fd,0)=0x177; // temporarily use same packet as clif_item_identify
  4358. for(i=c=0;i<MAX_INVENTORY;i++){
  4359. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].attribute==1){
  4360. WFIFOW(fd,c*2+4)=i+2;
  4361. c++;
  4362. }
  4363. }
  4364. if(c > 0) {
  4365. WFIFOW(fd,2)=c*2+4;
  4366. WFIFOSET(fd,WFIFOW(fd,2));
  4367. }
  4368. return 0;
  4369. }
  4370. /*==========================================
  4371. * Weapon Refining [Celest]
  4372. *------------------------------------------
  4373. */
  4374. int clif_item_refine_list(struct map_session_data *sd)
  4375. {
  4376. int i,c;
  4377. int fd;
  4378. nullpo_retr(0, sd);
  4379. fd=sd->fd;
  4380. WFIFOW(fd,0)=0x177; // temporarily use same packet as clif_item_identify
  4381. for(i=c=0;i<MAX_INVENTORY;i++){
  4382. if(sd->status.inventory[i].nameid > 0 && itemdb_type(sd->status.inventory[i].nameid)==4){
  4383. WFIFOW(fd,c*2+4)=i+2;
  4384. c++;
  4385. }
  4386. }
  4387. if(c > 0) {
  4388. WFIFOW(fd,2)=c*2+4;
  4389. WFIFOSET(fd,WFIFOW(fd,2));
  4390. }
  4391. return 0;
  4392. }
  4393. /*==========================================
  4394. * アイテムによる一時的なスキル効果
  4395. *------------------------------------------
  4396. */
  4397. int clif_item_skill(struct map_session_data *sd,int skillid,int skilllv,const char *name)
  4398. {
  4399. int range,fd;
  4400. nullpo_retr(0, sd);
  4401. fd=sd->fd;
  4402. WFIFOW(fd, 0)=0x147;
  4403. WFIFOW(fd, 2)=skillid;
  4404. WFIFOW(fd, 4)=skill_get_inf(skillid);
  4405. WFIFOW(fd, 6)=0;
  4406. WFIFOW(fd, 8)=skilllv;
  4407. WFIFOW(fd,10)=skill_get_sp(skillid,skilllv);
  4408. range = skill_get_range(skillid,skilllv);
  4409. if(range < 0)
  4410. range = battle_get_range(&sd->bl) - (range + 1);
  4411. WFIFOW(fd,12)=range;
  4412. strncpy((char*)WFIFOP(fd,14),name,24);
  4413. WFIFOB(fd,38)=0;
  4414. WFIFOSET(fd,packet_len_table[0x147]);
  4415. return 0;
  4416. }
  4417. /*==========================================
  4418. * カートにアイテム追加
  4419. *------------------------------------------
  4420. */
  4421. int clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail)
  4422. {
  4423. int view,j,fd;
  4424. unsigned char *buf;
  4425. nullpo_retr(0, sd);
  4426. fd=sd->fd;
  4427. buf=WFIFOP(fd,0);
  4428. if(n<0 || n>=MAX_CART || sd->status.cart[n].nameid<=0)
  4429. return 1;
  4430. WBUFW(buf,0)=0x124;
  4431. WBUFW(buf,2)=n+2;
  4432. WBUFL(buf,4)=amount;
  4433. if((view = itemdb_viewid(sd->status.cart[n].nameid)) > 0)
  4434. WBUFW(buf,8)=view;
  4435. else
  4436. WBUFW(buf,8)=sd->status.cart[n].nameid;
  4437. WBUFB(buf,10)=sd->status.cart[n].identify;
  4438. WBUFB(buf,11)=sd->status.cart[n].attribute;
  4439. WBUFB(buf,12)=sd->status.cart[n].refine;
  4440. if(sd->status.cart[n].card[0]==0x00ff || sd->status.cart[n].card[0]==0x00fe || sd->status.cart[n].card[0]==(short)0xff00) {
  4441. WBUFW(buf,13)=sd->status.cart[n].card[0];
  4442. WBUFW(buf,15)=sd->status.cart[n].card[1];
  4443. WBUFW(buf,17)=sd->status.cart[n].card[2];
  4444. WBUFW(buf,19)=sd->status.cart[n].card[3];
  4445. } else {
  4446. if(sd->status.cart[n].card[0] > 0 && (j=itemdb_viewid(sd->status.cart[n].card[0])) > 0)
  4447. WBUFW(buf,13)= j;
  4448. else
  4449. WBUFW(buf,13)= sd->status.cart[n].card[0];
  4450. if(sd->status.cart[n].card[1] > 0 && (j=itemdb_viewid(sd->status.cart[n].card[1])) > 0)
  4451. WBUFW(buf,15)= j;
  4452. else
  4453. WBUFW(buf,15)= sd->status.cart[n].card[1];
  4454. if(sd->status.cart[n].card[2] > 0 && (j=itemdb_viewid(sd->status.cart[n].card[2])) > 0)
  4455. WBUFW(buf,17)= j;
  4456. else
  4457. WBUFW(buf,17)= sd->status.cart[n].card[2];
  4458. if(sd->status.cart[n].card[3] > 0 && (j=itemdb_viewid(sd->status.cart[n].card[3])) > 0)
  4459. WBUFW(buf,19)= j;
  4460. else
  4461. WBUFW(buf,19)= sd->status.cart[n].card[3];
  4462. }
  4463. WFIFOSET(fd,packet_len_table[0x124]);
  4464. return 0;
  4465. }
  4466. /*==========================================
  4467. * カートからアイテム削除
  4468. *------------------------------------------
  4469. */
  4470. int clif_cart_delitem(struct map_session_data *sd,int n,int amount)
  4471. {
  4472. int fd;
  4473. nullpo_retr(0, sd);
  4474. fd=sd->fd;
  4475. WFIFOW(fd,0)=0x125;
  4476. WFIFOW(fd,2)=n+2;
  4477. WFIFOL(fd,4)=amount;
  4478. WFIFOSET(fd,packet_len_table[0x125]);
  4479. return 0;
  4480. }
  4481. /*==========================================
  4482. * カートのアイテムリスト
  4483. *------------------------------------------
  4484. */
  4485. int clif_cart_itemlist(struct map_session_data *sd)
  4486. {
  4487. struct item_data *id;
  4488. int i,n,fd;
  4489. unsigned char *buf;
  4490. nullpo_retr(0, sd);
  4491. fd=sd->fd;
  4492. buf = WFIFOP(fd,0);
  4493. #if PACKETVER < 5
  4494. WBUFW(buf,0)=0x123;
  4495. for(i=0,n=0;i<MAX_CART;i++){
  4496. if(sd->status.cart[i].nameid<=0)
  4497. continue;
  4498. id = itemdb_search(sd->status.cart[i].nameid);
  4499. if(itemdb_isequip2(id))
  4500. continue;
  4501. WBUFW(buf,n*10+4)=i+2;
  4502. if(id->view_id > 0)
  4503. WBUFW(buf,n*10+6)=id->view_id;
  4504. else
  4505. WBUFW(buf,n*10+6)=sd->status.cart[i].nameid;
  4506. WBUFB(buf,n*10+8)=id->type;
  4507. WBUFB(buf,n*10+9)=sd->status.cart[i].identify;
  4508. WBUFW(buf,n*10+10)=sd->status.cart[i].amount;
  4509. WBUFW(buf,n*10+12)=0;
  4510. n++;
  4511. }
  4512. if(n){
  4513. WBUFW(buf,2)=4+n*10;
  4514. WFIFOSET(fd,WFIFOW(fd,2));
  4515. }
  4516. #else
  4517. WBUFW(buf,0)=0x1ef;
  4518. for(i=0,n=0;i<MAX_CART;i++){
  4519. if(sd->status.cart[i].nameid<=0)
  4520. continue;
  4521. id = itemdb_search(sd->status.cart[i].nameid);
  4522. if(itemdb_isequip2(id))
  4523. continue;
  4524. WBUFW(buf,n*18+4)=i+2;
  4525. if(id->view_id > 0)
  4526. WBUFW(buf,n*18+6)=id->view_id;
  4527. else
  4528. WBUFW(buf,n*18+6)=sd->status.cart[i].nameid;
  4529. WBUFB(buf,n*18+8)=id->type;
  4530. WBUFB(buf,n*18+9)=sd->status.cart[i].identify;
  4531. WBUFW(buf,n*18+10)=sd->status.cart[i].amount;
  4532. WBUFW(buf,n*18+12)=0;
  4533. WBUFW(buf,n*18+14)=sd->status.cart[i].card[0];
  4534. WBUFW(buf,n*18+16)=sd->status.cart[i].card[1];
  4535. WBUFW(buf,n*18+18)=sd->status.cart[i].card[2];
  4536. WBUFW(buf,n*18+20)=sd->status.cart[i].card[3];
  4537. n++;
  4538. }
  4539. if(n){
  4540. WBUFW(buf,2)=4+n*18;
  4541. WFIFOSET(fd,WFIFOW(fd,2));
  4542. }
  4543. #endif
  4544. return 0;
  4545. }
  4546. /*==========================================
  4547. * カートの装備品リスト
  4548. *------------------------------------------
  4549. */
  4550. int clif_cart_equiplist(struct map_session_data *sd)
  4551. {
  4552. struct item_data *id;
  4553. int i,j,n,fd;
  4554. unsigned char *buf;
  4555. nullpo_retr(0, sd);
  4556. fd=sd->fd;
  4557. buf = WFIFOP(fd,0);
  4558. WBUFW(buf,0)=0x122;
  4559. for(i=0,n=0;i<MAX_INVENTORY;i++){
  4560. if(sd->status.cart[i].nameid<=0)
  4561. continue;
  4562. id = itemdb_search(sd->status.cart[i].nameid);
  4563. if(!itemdb_isequip2(id))
  4564. continue;
  4565. WBUFW(buf,n*20+4)=i+2;
  4566. if(id->view_id > 0)
  4567. WBUFW(buf,n*20+6)=id->view_id;
  4568. else
  4569. WBUFW(buf,n*20+6)=sd->status.cart[i].nameid;
  4570. WBUFB(buf,n*20+8)=id->type;
  4571. WBUFB(buf,n*20+9)=sd->status.cart[i].identify;
  4572. WBUFW(buf,n*20+10)=id->equip;
  4573. WBUFW(buf,n*20+12)=sd->status.cart[i].equip;
  4574. WBUFB(buf,n*20+14)=sd->status.cart[i].attribute;
  4575. WBUFB(buf,n*20+15)=sd->status.cart[i].refine;
  4576. if(sd->status.cart[i].card[0]==0x00ff || sd->status.cart[i].card[0]==0x00fe || sd->status.cart[i].card[0]==(short)0xff00) {
  4577. WBUFW(buf,n*20+16)=sd->status.cart[i].card[0];
  4578. WBUFW(buf,n*20+18)=sd->status.cart[i].card[1];
  4579. WBUFW(buf,n*20+20)=sd->status.cart[i].card[2];
  4580. WBUFW(buf,n*20+22)=sd->status.cart[i].card[3];
  4581. } else {
  4582. if(sd->status.cart[i].card[0] > 0 && (j=itemdb_viewid(sd->status.cart[i].card[0])) > 0)
  4583. WBUFW(buf,n*20+16)= j;
  4584. else
  4585. WBUFW(buf,n*20+16)= sd->status.cart[i].card[0];
  4586. if(sd->status.cart[i].card[1] > 0 && (j=itemdb_viewid(sd->status.cart[i].card[1])) > 0)
  4587. WBUFW(buf,n*20+18)= j;
  4588. else
  4589. WBUFW(buf,n*20+18)= sd->status.cart[i].card[1];
  4590. if(sd->status.cart[i].card[2] > 0 && (j=itemdb_viewid(sd->status.cart[i].card[2])) > 0)
  4591. WBUFW(buf,n*20+20)= j;
  4592. else
  4593. WBUFW(buf,n*20+20)= sd->status.cart[i].card[2];
  4594. if(sd->status.cart[i].card[3] > 0 && (j=itemdb_viewid(sd->status.cart[i].card[3])) > 0)
  4595. WBUFW(buf,n*20+22)= j;
  4596. else
  4597. WBUFW(buf,n*20+22)= sd->status.cart[i].card[3];
  4598. }
  4599. n++;
  4600. }
  4601. if(n){
  4602. WBUFW(buf,2)=4+n*20;
  4603. WFIFOSET(fd,WFIFOW(fd,2));
  4604. }
  4605. return 0;
  4606. }
  4607. /*==========================================
  4608. * 露店開設
  4609. *------------------------------------------
  4610. */
  4611. int clif_openvendingreq(struct map_session_data *sd,int num)
  4612. {
  4613. int fd;
  4614. nullpo_retr(0, sd);
  4615. fd=sd->fd;
  4616. WFIFOW(fd,0)=0x12d;
  4617. WFIFOW(fd,2)=num;
  4618. WFIFOSET(fd,packet_len_table[0x12d]);
  4619. return 0;
  4620. }
  4621. /*==========================================
  4622. * 露店看板表示
  4623. *------------------------------------------
  4624. */
  4625. int clif_showvendingboard(struct block_list* bl,char *message,int fd)
  4626. {
  4627. unsigned char buf[128];
  4628. nullpo_retr(0, bl);
  4629. WBUFW(buf,0)=0x131;
  4630. WBUFL(buf,2)=bl->id;
  4631. strncpy((char*)WBUFP(buf,6),message,80);
  4632. if(fd){
  4633. memcpy(WFIFOP(fd,0),buf,packet_len_table[0x131]);
  4634. WFIFOSET(fd,packet_len_table[0x131]);
  4635. }else{
  4636. clif_send(buf,packet_len_table[0x131],bl,AREA_WOS);
  4637. }
  4638. return 0;
  4639. }
  4640. /*==========================================
  4641. * 露店看板消去
  4642. *------------------------------------------
  4643. */
  4644. int clif_closevendingboard(struct block_list* bl,int fd)
  4645. {
  4646. unsigned char buf[16];
  4647. nullpo_retr(0, bl);
  4648. WBUFW(buf,0)=0x132;
  4649. WBUFL(buf,2)=bl->id;
  4650. if(fd){
  4651. memcpy(WFIFOP(fd,0),buf,packet_len_table[0x132]);
  4652. WFIFOSET(fd,packet_len_table[0x132]);
  4653. }else{
  4654. clif_send(buf,packet_len_table[0x132],bl,AREA_WOS);
  4655. }
  4656. return 0;
  4657. }
  4658. /*==========================================
  4659. * 露店アイテムリスト
  4660. *------------------------------------------
  4661. */
  4662. int clif_vendinglist(struct map_session_data *sd,int id,struct vending *vending)
  4663. {
  4664. struct item_data *data;
  4665. int i,j,n,index,fd;
  4666. struct map_session_data *vsd;
  4667. unsigned char *buf;
  4668. nullpo_retr(0, sd);
  4669. nullpo_retr(0, vending);
  4670. nullpo_retr(0, vsd=map_id2sd(id));
  4671. fd=sd->fd;
  4672. buf = WFIFOP(fd,0);
  4673. WBUFW(buf,0)=0x133;
  4674. WBUFL(buf,4)=id;
  4675. for(i=0,n=0;i<vsd->vend_num;i++){
  4676. if(vending[i].amount<=0)
  4677. continue;
  4678. WBUFL(buf,8+n*22)=vending[i].value;
  4679. WBUFW(buf,12+n*22)=vending[i].amount;
  4680. WBUFW(buf,14+n*22)=(index=vending[i].index)+2;
  4681. if(vsd->status.cart[index].nameid <= 0 || vsd->status.cart[index].amount <= 0)
  4682. continue;
  4683. data = itemdb_search(vsd->status.cart[index].nameid);
  4684. WBUFB(buf,16+n*22)=data->type;
  4685. if(data->view_id > 0)
  4686. WBUFW(buf,17+n*22)=data->view_id;
  4687. else
  4688. WBUFW(buf,17+n*22)=vsd->status.cart[index].nameid;
  4689. WBUFB(buf,19+n*22)=vsd->status.cart[index].identify;
  4690. WBUFB(buf,20+n*22)=vsd->status.cart[index].attribute;
  4691. WBUFB(buf,21+n*22)=vsd->status.cart[index].refine;
  4692. if(vsd->status.cart[index].card[0]==0x00ff || vsd->status.cart[index].card[0]==0x00fe || vsd->status.cart[index].card[0]==(short)0xff00) {
  4693. WBUFW(buf,22+n*22)=vsd->status.cart[index].card[0];
  4694. WBUFW(buf,24+n*22)=vsd->status.cart[index].card[1];
  4695. WBUFW(buf,26+n*22)=vsd->status.cart[index].card[2];
  4696. WBUFW(buf,28+n*22)=vsd->status.cart[index].card[3];
  4697. } else {
  4698. if(vsd->status.cart[index].card[0] > 0 && (j=itemdb_viewid(vsd->status.cart[index].card[0])) > 0)
  4699. WBUFW(buf,22+n*22)= j;
  4700. else
  4701. WBUFW(buf,22+n*22)= vsd->status.cart[index].card[0];
  4702. if(vsd->status.cart[index].card[1] > 0 && (j=itemdb_viewid(vsd->status.cart[index].card[1])) > 0)
  4703. WBUFW(buf,24+n*22)= j;
  4704. else
  4705. WBUFW(buf,24+n*22)= vsd->status.cart[index].card[1];
  4706. if(vsd->status.cart[index].card[2] > 0 && (j=itemdb_viewid(vsd->status.cart[index].card[2])) > 0)
  4707. WBUFW(buf,26+n*22)= j;
  4708. else
  4709. WBUFW(buf,26+n*22)= vsd->status.cart[index].card[2];
  4710. if(vsd->status.cart[index].card[3] > 0 && (j=itemdb_viewid(vsd->status.cart[index].card[3])) > 0)
  4711. WBUFW(buf,28+n*22)= j;
  4712. else
  4713. WBUFW(buf,28+n*22)= vsd->status.cart[index].card[3];
  4714. }
  4715. n++;
  4716. }
  4717. if(n > 0){
  4718. WBUFW(buf,2)=8+n*22;
  4719. WFIFOSET(fd,WFIFOW(fd,2));
  4720. }
  4721. return 0;
  4722. }
  4723. /*==========================================
  4724. * 露店アイテム購入失敗
  4725. *------------------------------------------
  4726. */
  4727. int clif_buyvending(struct map_session_data *sd,int index,int amount,int fail)
  4728. {
  4729. int fd;
  4730. nullpo_retr(0, sd);
  4731. fd=sd->fd;
  4732. WFIFOW(fd,0)=0x135;
  4733. WFIFOW(fd,2)=index+2;
  4734. WFIFOW(fd,4)=amount;
  4735. WFIFOB(fd,6)=fail;
  4736. WFIFOSET(fd,packet_len_table[0x135]);
  4737. return 0;
  4738. }
  4739. /*==========================================
  4740. * 露店開設成功
  4741. *------------------------------------------
  4742. */
  4743. int clif_openvending(struct map_session_data *sd,int id,struct vending *vending)
  4744. {
  4745. struct item_data *data;
  4746. int i,j,n,index,fd;
  4747. unsigned char *buf;
  4748. nullpo_retr(0, sd);
  4749. fd=sd->fd;
  4750. buf = WFIFOP(fd,0);
  4751. WBUFW(buf,0)=0x136;
  4752. WBUFL(buf,4)=id;
  4753. for(i=0,n=0;i<sd->vend_num;i++){
  4754. if (sd->vend_num > 2+pc_checkskill(sd,MC_VENDING)) return 0;
  4755. WBUFL(buf,8+n*22)=vending[i].value;
  4756. WBUFW(buf,12+n*22)=(index=vending[i].index)+2;
  4757. WBUFW(buf,14+n*22)=vending[i].amount;
  4758. if(sd->status.cart[index].nameid <= 0 || sd->status.cart[index].amount <= 0 || sd->status.cart[index].identify==0 ||
  4759. sd->status.cart[index].attribute==1) // Prevent unidentified and broken items from being sold [Valaris]
  4760. continue;
  4761. data = itemdb_search(sd->status.cart[index].nameid);
  4762. WBUFB(buf,16+n*22)=data->type;
  4763. if(data->view_id > 0)
  4764. WBUFW(buf,17+n*22)=data->view_id;
  4765. else
  4766. WBUFW(buf,17+n*22)=sd->status.cart[index].nameid;
  4767. WBUFB(buf,19+n*22)=sd->status.cart[index].identify;
  4768. WBUFB(buf,20+n*22)=sd->status.cart[index].attribute;
  4769. WBUFB(buf,21+n*22)=sd->status.cart[index].refine;
  4770. if(sd->status.cart[index].card[0]==0x00ff || sd->status.cart[index].card[0]==0x00fe || sd->status.cart[index].card[0]==(short)0xff00) {
  4771. WBUFW(buf,22+n*22)=sd->status.cart[index].card[0];
  4772. WBUFW(buf,24+n*22)=sd->status.cart[index].card[1];
  4773. WBUFW(buf,26+n*22)=sd->status.cart[index].card[2];
  4774. WBUFW(buf,28+n*22)=sd->status.cart[index].card[3];
  4775. } else {
  4776. if(sd->status.cart[index].card[0] > 0 && (j=itemdb_viewid(sd->status.cart[index].card[0])) > 0)
  4777. WBUFW(buf,22+n*22)= j;
  4778. else
  4779. WBUFW(buf,22+n*22)= sd->status.cart[index].card[0];
  4780. if(sd->status.cart[index].card[1] > 0 && (j=itemdb_viewid(sd->status.cart[index].card[1])) > 0)
  4781. WBUFW(buf,24+n*22)= j;
  4782. else
  4783. WBUFW(buf,24+n*22)= sd->status.cart[index].card[1];
  4784. if(sd->status.cart[index].card[2] > 0 && (j=itemdb_viewid(sd->status.cart[index].card[2])) > 0)
  4785. WBUFW(buf,26+n*22)= j;
  4786. else
  4787. WBUFW(buf,26+n*22)= sd->status.cart[index].card[2];
  4788. if(sd->status.cart[index].card[3] > 0 && (j=itemdb_viewid(sd->status.cart[index].card[3])) > 0)
  4789. WBUFW(buf,28+n*22)= j;
  4790. else
  4791. WBUFW(buf,28+n*22)= sd->status.cart[index].card[3];
  4792. }
  4793. n++;
  4794. }
  4795. if(n > 0){
  4796. WBUFW(buf,2)=8+n*22;
  4797. WFIFOSET(fd,WFIFOW(fd,2));
  4798. }
  4799. return n;
  4800. }
  4801. /*==========================================
  4802. * 露店アイテム販売報告
  4803. *------------------------------------------
  4804. */
  4805. int clif_vendingreport(struct map_session_data *sd,int index,int amount)
  4806. {
  4807. int fd;
  4808. nullpo_retr(0, sd);
  4809. fd=sd->fd;
  4810. WFIFOW(fd,0)=0x137;
  4811. WFIFOW(fd,2)=index+2;
  4812. WFIFOW(fd,4)=amount;
  4813. WFIFOSET(fd,packet_len_table[0x137]);
  4814. return 0;
  4815. }
  4816. /*==========================================
  4817. * パーティ作成完了
  4818. *------------------------------------------
  4819. */
  4820. int clif_party_created(struct map_session_data *sd,int flag)
  4821. {
  4822. int fd;
  4823. // printf("clif_party_message(%s, %d, %s)\n", p->name, account_id, mes);
  4824. nullpo_retr(0, sd);
  4825. fd=sd->fd;
  4826. WFIFOW(fd,0)=0xfa;
  4827. WFIFOB(fd,2)=flag;
  4828. WFIFOSET(fd,packet_len_table[0xfa]);
  4829. return 0;
  4830. }
  4831. /*==========================================
  4832. * パーティ情報送信
  4833. *------------------------------------------
  4834. */
  4835. int clif_party_info(struct party *p,int fd)
  4836. {
  4837. unsigned char buf[1024];
  4838. int i,c;
  4839. struct map_session_data *sd=NULL;
  4840. nullpo_retr(0, p);
  4841. WBUFW(buf,0)=0xfb;
  4842. memcpy(WBUFP(buf,4),p->name,24);
  4843. for(i=c=0;i<MAX_PARTY;i++){
  4844. struct party_member *m=&p->member[i];
  4845. if(m->account_id>0){
  4846. if(sd==NULL) sd=m->sd;
  4847. WBUFL(buf,28+c*46)=m->account_id;
  4848. memcpy(WBUFP(buf,28+c*46+ 4),m->name,24);
  4849. memcpy(WBUFP(buf,28+c*46+28),m->map,16);
  4850. WBUFB(buf,28+c*46+44)=(m->leader)?0:1;
  4851. WBUFB(buf,28+c*46+45)=(m->online)?0:1;
  4852. c++;
  4853. }
  4854. }
  4855. WBUFW(buf,2)=28+c*46;
  4856. if(fd>=0){ // fdが設定されてるならそれに送る
  4857. memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2));
  4858. WFIFOSET(fd,WFIFOW(fd,2));
  4859. return 9;
  4860. }
  4861. if(sd!=NULL)
  4862. clif_send(buf,WBUFW(buf,2),&sd->bl,PARTY);
  4863. return 0;
  4864. }
  4865. /*==========================================
  4866. * パーティ勧誘
  4867. *------------------------------------------
  4868. */
  4869. int clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd)
  4870. {
  4871. int fd;
  4872. struct party *p;
  4873. nullpo_retr(0, sd);
  4874. nullpo_retr(0, tsd);
  4875. fd=tsd->fd;
  4876. if( (p=party_search(sd->status.party_id))==NULL )
  4877. return 0;
  4878. WFIFOW(fd,0)=0xfe;
  4879. WFIFOL(fd,2)=sd->status.account_id;
  4880. memcpy(WFIFOP(fd,6),p->name,24);
  4881. WFIFOSET(fd,packet_len_table[0xfe]);
  4882. return 0;
  4883. }
  4884. /*==========================================
  4885. * パーティ勧誘結果
  4886. *------------------------------------------
  4887. */
  4888. int clif_party_inviteack(struct map_session_data *sd,char *nick,int flag)
  4889. {
  4890. int fd;
  4891. nullpo_retr(0, sd);
  4892. fd=sd->fd;
  4893. WFIFOW(fd,0)=0xfd;
  4894. memcpy(WFIFOP(fd,2),nick,24);
  4895. WFIFOB(fd,26)=flag;
  4896. WFIFOSET(fd,packet_len_table[0xfd]);
  4897. return 0;
  4898. }
  4899. /*==========================================
  4900. * パーティ設定送信
  4901. * flag & 0x001=exp変更ミス
  4902. * 0x010=item変更ミス
  4903. * 0x100=一人にのみ送信
  4904. *------------------------------------------
  4905. */
  4906. int clif_party_option(struct party *p,struct map_session_data *sd,int flag)
  4907. {
  4908. unsigned char buf[16];
  4909. nullpo_retr(0, p);
  4910. // if(battle_config.etc_log)
  4911. // printf("clif_party_option: %d %d %d\n",p->exp,p->item,flag);
  4912. if(sd==NULL && flag==0){
  4913. int i;
  4914. for(i=0;i<MAX_PARTY;i++)
  4915. if((sd=map_id2sd(p->member[i].account_id))!=NULL)
  4916. break;
  4917. }
  4918. if(sd==NULL)
  4919. return 0;
  4920. WBUFW(buf,0)=0x101;
  4921. WBUFW(buf,2)=((flag&0x01)?2:p->exp);
  4922. WBUFW(buf,4)=((flag&0x10)?2:p->item);
  4923. if(flag==0)
  4924. clif_send(buf,packet_len_table[0x101],&sd->bl,PARTY);
  4925. else {
  4926. memcpy(WFIFOP(sd->fd,0),buf,packet_len_table[0x101]);
  4927. WFIFOSET(sd->fd,packet_len_table[0x101]);
  4928. }
  4929. return 0;
  4930. }
  4931. /*==========================================
  4932. * パーティ脱退(脱退前に呼ぶこと)
  4933. *------------------------------------------
  4934. */
  4935. int clif_party_leaved(struct party *p,struct map_session_data *sd,int account_id,char *name,int flag)
  4936. {
  4937. unsigned char buf[64];
  4938. int i;
  4939. nullpo_retr(0, p);
  4940. WBUFW(buf,0)=0x105;
  4941. WBUFL(buf,2)=account_id;
  4942. memcpy(WBUFP(buf,6),name,24);
  4943. WBUFB(buf,30)=flag&0x0f;
  4944. if((flag&0xf0)==0){
  4945. if(sd==NULL)
  4946. for(i=0;i<MAX_PARTY;i++)
  4947. if((sd=p->member[i].sd)!=NULL)
  4948. break;
  4949. if (sd!=NULL)
  4950. clif_send(buf,packet_len_table[0x105],&sd->bl,PARTY);
  4951. } else if (sd!=NULL) {
  4952. memcpy(WFIFOP(sd->fd,0),buf,packet_len_table[0x105]);
  4953. WFIFOSET(sd->fd,packet_len_table[0x105]);
  4954. }
  4955. return 0;
  4956. }
  4957. /*==========================================
  4958. * パーティメッセージ送信
  4959. *------------------------------------------
  4960. */
  4961. int clif_party_message(struct party *p,int account_id,char *mes,int len)
  4962. {
  4963. struct map_session_data *sd;
  4964. int i;
  4965. nullpo_retr(0, p);
  4966. for(i=0;i<MAX_PARTY;i++){
  4967. if((sd=p->member[i].sd)!=NULL)
  4968. break;
  4969. }
  4970. if(sd!=NULL){
  4971. unsigned char buf[1024];
  4972. WBUFW(buf,0)=0x109;
  4973. WBUFW(buf,2)=len+8;
  4974. WBUFL(buf,4)=account_id;
  4975. memcpy(WBUFP(buf,8),mes,len);
  4976. clif_send(buf,len+8,&sd->bl,PARTY);
  4977. }
  4978. return 0;
  4979. }
  4980. /*==========================================
  4981. * パーティ座標通知
  4982. *------------------------------------------
  4983. */
  4984. int clif_party_xy(struct party *p,struct map_session_data *sd)
  4985. {
  4986. unsigned char buf[16];
  4987. nullpo_retr(0, sd);
  4988. WBUFW(buf,0)=0x107;
  4989. WBUFL(buf,2)=sd->status.account_id;
  4990. WBUFW(buf,6)=sd->bl.x;
  4991. WBUFW(buf,8)=sd->bl.y;
  4992. clif_send(buf,packet_len_table[0x107],&sd->bl,PARTY_SAMEMAP_WOS);
  4993. // if(battle_config.etc_log)
  4994. // printf("clif_party_xy %d\n",sd->status.account_id);
  4995. return 0;
  4996. }
  4997. /*==========================================
  4998. * パーティHP通知
  4999. *------------------------------------------
  5000. */
  5001. int clif_party_hp(struct party *p,struct map_session_data *sd)
  5002. {
  5003. unsigned char buf[16];
  5004. nullpo_retr(0, sd);
  5005. WBUFW(buf,0)=0x106;
  5006. WBUFL(buf,2)=sd->status.account_id;
  5007. WBUFW(buf,6)=(sd->status.hp > 0x7fff)? 0x7fff:sd->status.hp;
  5008. WBUFW(buf,8)=(sd->status.max_hp > 0x7fff)? 0x7fff:sd->status.max_hp;
  5009. clif_send(buf,packet_len_table[0x106],&sd->bl,PARTY_AREA_WOS);
  5010. // if(battle_config.etc_log)
  5011. // printf("clif_party_hp %d\n",sd->status.account_id);
  5012. return 0;
  5013. }
  5014. /*==========================================
  5015. * GMへ場所とHP通知
  5016. *------------------------------------------
  5017. */
  5018. int clif_hpmeter(struct map_session_data *sd)
  5019. {
  5020. struct map_session_data *md;
  5021. unsigned char buf[16];
  5022. unsigned char buf2[16];
  5023. int i;
  5024. nullpo_retr(0, sd);
  5025. WBUFW(buf,0)=0x107;
  5026. WBUFL(buf,2)=sd->bl.id;
  5027. WBUFW(buf,6)=sd->bl.x;
  5028. WBUFW(buf,8)=sd->bl.y;
  5029. for(i=0;i<fd_max;i++){
  5030. if(session[i] && (md = (struct map_session_data*)session[i]->session_data) && md->state.auth &&
  5031. md->bl.m == sd->bl.m && pc_isGM(md) && sd != md){
  5032. memcpy(WFIFOP(i,0),buf,packet_len_table[0x107]);
  5033. WFIFOSET(i,packet_len_table[0x107]);
  5034. }
  5035. }
  5036. WBUFW(buf2,0)=0x106;
  5037. WBUFL(buf2,2)=sd->status.account_id;
  5038. WBUFW(buf2,6)=(sd->status.hp > 0x7fff)? 0x7fff:sd->status.hp;
  5039. WBUFW(buf2,8)=(sd->status.max_hp > 0x7fff)? 0x7fff:sd->status.max_hp;
  5040. for(i=0;i<fd_max;i++){
  5041. if(session[i] && (md = (struct map_session_data*)session[i]->session_data) && md->state.auth &&
  5042. md->bl.m == sd->bl.m && pc_isGM(md) && sd != md){
  5043. memcpy(WFIFOP(i,0),buf2,packet_len_table[0x106]);
  5044. WFIFOSET(i,packet_len_table[0x106]);
  5045. }
  5046. }
  5047. return 0;
  5048. }
  5049. /*==================================================
  5050. * Update monster hp view if it has changed [Celest]
  5051. *--------------------------------------------------
  5052. */
  5053. int clif_update_mobhp(struct mob_data *md)
  5054. {
  5055. unsigned char buf[102];
  5056. char mobhp[50];
  5057. nullpo_retr(0, md);
  5058. WBUFW(buf,0) = 0x95;
  5059. WBUFL(buf,2) = md->bl.id;
  5060. memcpy(WBUFP(buf,6), md->name, 24);
  5061. sprintf(mobhp, "hp: %d/%d", md->hp, mob_db[md->class_].max_hp);
  5062. WBUFW(buf, 0) = 0x195;
  5063. memcpy(WBUFP(buf,30), mobhp, 24);
  5064. WBUFL(buf,54) = 0;
  5065. WBUFL(buf,78) = 0;
  5066. clif_send(buf,packet_len_table[0x195],&md->bl,AREA);
  5067. return 0;
  5068. }
  5069. /*==========================================
  5070. * パーティ場所移動(未使用)
  5071. *------------------------------------------
  5072. */
  5073. int clif_party_move(struct party *p,struct map_session_data *sd,int online)
  5074. {
  5075. unsigned char buf[128];
  5076. nullpo_retr(0, sd);
  5077. nullpo_retr(0, p);
  5078. WBUFW(buf, 0)=0x104;
  5079. WBUFL(buf, 2)=sd->status.account_id;
  5080. WBUFL(buf, 6)=0;
  5081. WBUFW(buf,10)=sd->bl.x;
  5082. WBUFW(buf,12)=sd->bl.y;
  5083. WBUFB(buf,14)=!online;
  5084. memcpy(WBUFP(buf,15),p->name,24);
  5085. memcpy(WBUFP(buf,39),sd->status.name,24);
  5086. memcpy(WBUFP(buf,63),map[sd->bl.m].name,16);
  5087. clif_send(buf,packet_len_table[0x104],&sd->bl,PARTY);
  5088. return 0;
  5089. }
  5090. /*==========================================
  5091. * 攻撃するために移動が必要
  5092. *------------------------------------------
  5093. */
  5094. int clif_movetoattack(struct map_session_data *sd,struct block_list *bl)
  5095. {
  5096. int fd;
  5097. nullpo_retr(0, sd);
  5098. nullpo_retr(0, bl);
  5099. fd=sd->fd;
  5100. WFIFOW(fd, 0)=0x139;
  5101. WFIFOL(fd, 2)=bl->id;
  5102. WFIFOW(fd, 6)=bl->x;
  5103. WFIFOW(fd, 8)=bl->y;
  5104. WFIFOW(fd,10)=sd->bl.x;
  5105. WFIFOW(fd,12)=sd->bl.y;
  5106. WFIFOW(fd,14)=sd->attackrange;
  5107. WFIFOSET(fd,packet_len_table[0x139]);
  5108. return 0;
  5109. }
  5110. /*==========================================
  5111. * 製造エフェクト
  5112. *------------------------------------------
  5113. */
  5114. int clif_produceeffect(struct map_session_data *sd,int flag,int nameid)
  5115. {
  5116. int view,fd;
  5117. nullpo_retr(0, sd);
  5118. fd=sd->fd;
  5119. // 名前の登録と送信を先にしておく
  5120. if( map_charid2nick(sd->status.char_id)==NULL )
  5121. map_addchariddb(sd->status.char_id,sd->status.name);
  5122. clif_solved_charname(sd,sd->status.char_id);
  5123. WFIFOW(fd, 0)=0x18f;
  5124. WFIFOW(fd, 2)=flag;
  5125. if((view = itemdb_viewid(nameid)) > 0)
  5126. WFIFOW(fd, 4)=view;
  5127. else
  5128. WFIFOW(fd, 4)=nameid;
  5129. WFIFOSET(fd,packet_len_table[0x18f]);
  5130. return 0;
  5131. }
  5132. // pet
  5133. int clif_catch_process(struct map_session_data *sd)
  5134. {
  5135. int fd;
  5136. nullpo_retr(0, sd);
  5137. fd=sd->fd;
  5138. WFIFOW(fd,0)=0x19e;
  5139. WFIFOSET(fd,packet_len_table[0x19e]);
  5140. return 0;
  5141. }
  5142. int clif_pet_rulet(struct map_session_data *sd,int data)
  5143. {
  5144. int fd;
  5145. nullpo_retr(0, sd);
  5146. fd=sd->fd;
  5147. WFIFOW(fd,0)=0x1a0;
  5148. WFIFOB(fd,2)=data;
  5149. WFIFOSET(fd,packet_len_table[0x1a0]);
  5150. return 0;
  5151. }
  5152. /*==========================================
  5153. * pet卵リスト作成
  5154. *------------------------------------------
  5155. */
  5156. int clif_sendegg(struct map_session_data *sd)
  5157. {
  5158. //R 01a6 <len>.w <index>.w*
  5159. int i,n=0,fd;
  5160. nullpo_retr(0, sd);
  5161. fd=sd->fd;
  5162. WFIFOW(fd,0)=0x1a6;
  5163. if(sd->status.pet_id <= 0) {
  5164. for(i=0,n=0;i<MAX_INVENTORY;i++){
  5165. if(sd->status.inventory[i].nameid<=0 || sd->inventory_data[i] == NULL ||
  5166. sd->inventory_data[i]->type!=7 ||
  5167. sd->status.inventory[i].amount<=0)
  5168. continue;
  5169. WFIFOW(fd,n*2+4)=i+2;
  5170. n++;
  5171. }
  5172. }
  5173. WFIFOW(fd,2)=4+n*2;
  5174. WFIFOSET(fd,WFIFOW(fd,2));
  5175. return 0;
  5176. }
  5177. int clif_send_petdata(struct map_session_data *sd,int type,int param)
  5178. {
  5179. int fd;
  5180. nullpo_retr(0, sd);
  5181. fd=sd->fd;
  5182. WFIFOW(fd,0)=0x1a4;
  5183. WFIFOB(fd,2)=type;
  5184. WFIFOL(fd,3)=sd->pd->bl.id;
  5185. WFIFOL(fd,7)=param;
  5186. WFIFOSET(fd,packet_len_table[0x1a4]);
  5187. return 0;
  5188. }
  5189. int clif_send_petstatus(struct map_session_data *sd)
  5190. {
  5191. int fd;
  5192. nullpo_retr(0, sd);
  5193. fd=sd->fd;
  5194. WFIFOW(fd,0)=0x1a2;
  5195. memcpy(WFIFOP(fd,2),sd->pet.name,24);
  5196. WFIFOB(fd,26)=(battle_config.pet_rename == 1)? 0:sd->pet.rename_flag;
  5197. WFIFOW(fd,27)=sd->pet.level;
  5198. WFIFOW(fd,29)=sd->pet.hungry;
  5199. WFIFOW(fd,31)=sd->pet.intimate;
  5200. WFIFOW(fd,33)=sd->pet.equip;
  5201. WFIFOSET(fd,packet_len_table[0x1a2]);
  5202. return 0;
  5203. }
  5204. /*==========================================
  5205. *
  5206. *------------------------------------------
  5207. */
  5208. int clif_pet_emotion(struct pet_data *pd,int param)
  5209. {
  5210. unsigned char buf[16];
  5211. struct map_session_data *sd;
  5212. nullpo_retr(0, pd);
  5213. nullpo_retr(0, sd = pd->msd);
  5214. memset(buf,0,packet_len_table[0x1aa]);
  5215. WBUFW(buf,0)=0x1aa;
  5216. WBUFL(buf,2)=pd->bl.id;
  5217. if(param >= 100 && sd->petDB->talk_convert_class) {
  5218. if(sd->petDB->talk_convert_class < 0)
  5219. return 0;
  5220. else if(sd->petDB->talk_convert_class > 0) {
  5221. param -= (pd->class_ - 100)*100;
  5222. param += (sd->petDB->talk_convert_class - 100)*100;
  5223. }
  5224. }
  5225. WBUFL(buf,6)=param;
  5226. clif_send(buf,packet_len_table[0x1aa],&pd->bl,AREA);
  5227. return 0;
  5228. }
  5229. int clif_pet_performance(struct block_list *bl,int param)
  5230. {
  5231. unsigned char buf[16];
  5232. nullpo_retr(0, bl);
  5233. memset(buf,0,packet_len_table[0x1a4]);
  5234. WBUFW(buf,0)=0x1a4;
  5235. WBUFB(buf,2)=4;
  5236. WBUFL(buf,3)=bl->id;
  5237. WBUFL(buf,7)=param;
  5238. clif_send(buf,packet_len_table[0x1a4],bl,AREA);
  5239. return 0;
  5240. }
  5241. int clif_pet_equip(struct pet_data *pd,int nameid)
  5242. {
  5243. unsigned char buf[16];
  5244. int view;
  5245. nullpo_retr(0, pd);
  5246. memset(buf,0,packet_len_table[0x1a4]);
  5247. WBUFW(buf,0)=0x1a4;
  5248. WBUFB(buf,2)=3;
  5249. WBUFL(buf,3)=pd->bl.id;
  5250. if((view = itemdb_viewid(nameid)) > 0)
  5251. WBUFL(buf,7)=view;
  5252. else
  5253. WBUFL(buf,7)=nameid;
  5254. clif_send(buf,packet_len_table[0x1a4],&pd->bl,AREA);
  5255. return 0;
  5256. }
  5257. int clif_pet_food(struct map_session_data *sd,int foodid,int fail)
  5258. {
  5259. int fd;
  5260. nullpo_retr(0, sd);
  5261. fd=sd->fd;
  5262. WFIFOW(fd,0)=0x1a3;
  5263. WFIFOB(fd,2)=fail;
  5264. WFIFOW(fd,3)=foodid;
  5265. WFIFOSET(fd,packet_len_table[0x1a3]);
  5266. return 0;
  5267. }
  5268. /*==========================================
  5269. * オートスペル リスト送信
  5270. *------------------------------------------
  5271. */
  5272. int clif_autospell(struct map_session_data *sd,int skilllv)
  5273. {
  5274. int fd;
  5275. nullpo_retr(0, sd);
  5276. fd=sd->fd;
  5277. WFIFOW(fd, 0)=0x1cd;
  5278. if(skilllv>0 && pc_checkskill(sd,MG_NAPALMBEAT)>0)
  5279. WFIFOL(fd,2)= MG_NAPALMBEAT;
  5280. else
  5281. WFIFOL(fd,2)= 0x00000000;
  5282. if(skilllv>1 && pc_checkskill(sd,MG_COLDBOLT)>0)
  5283. WFIFOL(fd,6)= MG_COLDBOLT;
  5284. else
  5285. WFIFOL(fd,6)= 0x00000000;
  5286. if(skilllv>1 && pc_checkskill(sd,MG_FIREBOLT)>0)
  5287. WFIFOL(fd,10)= MG_FIREBOLT;
  5288. else
  5289. WFIFOL(fd,10)= 0x00000000;
  5290. if(skilllv>1 && pc_checkskill(sd,MG_LIGHTNINGBOLT)>0)
  5291. WFIFOL(fd,14)= MG_LIGHTNINGBOLT;
  5292. else
  5293. WFIFOL(fd,14)= 0x00000000;
  5294. if(skilllv>4 && pc_checkskill(sd,MG_SOULSTRIKE)>0)
  5295. WFIFOL(fd,18)= MG_SOULSTRIKE;
  5296. else
  5297. WFIFOL(fd,18)= 0x00000000;
  5298. if(skilllv>7 && pc_checkskill(sd,MG_FIREBALL)>0)
  5299. WFIFOL(fd,22)= MG_FIREBALL;
  5300. else
  5301. WFIFOL(fd,22)= 0x00000000;
  5302. if(skilllv>9 && pc_checkskill(sd,MG_FROSTDIVER)>0)
  5303. WFIFOL(fd,26)= MG_FROSTDIVER;
  5304. else
  5305. WFIFOL(fd,26)= 0x00000000;
  5306. WFIFOSET(fd,packet_len_table[0x1cd]);
  5307. return 0;
  5308. }
  5309. /*==========================================
  5310. * ディボーションの青い糸
  5311. *------------------------------------------
  5312. */
  5313. int clif_devotion(struct map_session_data *sd,int target)
  5314. {
  5315. unsigned char buf[56];
  5316. int n;
  5317. nullpo_retr(0, sd);
  5318. WBUFW(buf,0)=0x1cf;
  5319. WBUFL(buf,2)=sd->bl.id;
  5320. // WBUFL(buf,6)=target;
  5321. for(n=0;n<5;n++)
  5322. WBUFL(buf,6+4*n)=sd->dev.val2[n];
  5323. // WBUFL(buf,10+4*n)=0;
  5324. WBUFB(buf,26)=8;
  5325. WBUFB(buf,27)=0;
  5326. clif_send(buf,packet_len_table[0x1cf],&sd->bl,AREA);
  5327. return 0;
  5328. }
  5329. /*==========================================
  5330. * 氣球
  5331. *------------------------------------------
  5332. */
  5333. int clif_spiritball(struct map_session_data *sd)
  5334. {
  5335. unsigned char buf[16];
  5336. nullpo_retr(0, sd);
  5337. WBUFW(buf,0)=0x1d0;
  5338. WBUFL(buf,2)=sd->bl.id;
  5339. WBUFW(buf,6)=sd->spiritball;
  5340. clif_send(buf,packet_len_table[0x1d0],&sd->bl,AREA);
  5341. return 0;
  5342. }
  5343. /*==========================================
  5344. *
  5345. *------------------------------------------
  5346. */
  5347. int clif_combo_delay(struct block_list *bl,int wait)
  5348. {
  5349. unsigned char buf[32];
  5350. nullpo_retr(0, bl);
  5351. WBUFW(buf,0)=0x1d2;
  5352. WBUFL(buf,2)=bl->id;
  5353. WBUFL(buf,6)=wait;
  5354. clif_send(buf,packet_len_table[0x1d2],bl,AREA);
  5355. return 0;
  5356. }
  5357. /*==========================================
  5358. *白刃取り
  5359. *------------------------------------------
  5360. */
  5361. int clif_bladestop(struct block_list *src,struct block_list *dst,
  5362. int _bool)
  5363. {
  5364. unsigned char buf[32];
  5365. nullpo_retr(0, src);
  5366. nullpo_retr(0, dst);
  5367. WBUFW(buf,0)=0x1d1;
  5368. WBUFL(buf,2)=src->id;
  5369. WBUFL(buf,6)=dst->id;
  5370. WBUFL(buf,10)=_bool;
  5371. clif_send(buf,packet_len_table[0x1d1],src,AREA);
  5372. return 0;
  5373. }
  5374. /*==========================================
  5375. *
  5376. *------------------------------------------
  5377. */
  5378. int clif_changemapcell(int m,int x,int y,int cell_type,int type)
  5379. {
  5380. struct block_list bl;
  5381. unsigned char buf[32];
  5382. bl.m = m;
  5383. bl.x = x;
  5384. bl.y = y;
  5385. WBUFW(buf,0) = 0x192;
  5386. WBUFW(buf,2) = x;
  5387. WBUFW(buf,4) = y;
  5388. WBUFW(buf,6) = cell_type;
  5389. memcpy(WBUFP(buf,8),map[m].name,16);
  5390. if(!type)
  5391. clif_send(buf,packet_len_table[0x192],&bl,AREA);
  5392. else
  5393. clif_send(buf,packet_len_table[0x192],&bl,ALL_SAMEMAP);
  5394. return 0;
  5395. }
  5396. /*==========================================
  5397. * MVPエフェクト
  5398. *------------------------------------------
  5399. */
  5400. int clif_mvp_effect(struct map_session_data *sd)
  5401. {
  5402. unsigned char buf[16];
  5403. nullpo_retr(0, sd);
  5404. WBUFW(buf,0)=0x10c;
  5405. WBUFL(buf,2)=sd->bl.id;
  5406. clif_send(buf,packet_len_table[0x10c],&sd->bl,AREA);
  5407. return 0;
  5408. }
  5409. /*==========================================
  5410. * MVPアイテム所得
  5411. *------------------------------------------
  5412. */
  5413. int clif_mvp_item(struct map_session_data *sd,int nameid)
  5414. {
  5415. int view,fd;
  5416. nullpo_retr(0, sd);
  5417. fd=sd->fd;
  5418. WFIFOW(fd,0)=0x10a;
  5419. if((view = itemdb_viewid(nameid)) > 0)
  5420. WFIFOW(fd,2)=view;
  5421. else
  5422. WFIFOW(fd,2)=nameid;
  5423. WFIFOSET(fd,packet_len_table[0x10a]);
  5424. return 0;
  5425. }
  5426. /*==========================================
  5427. * MVP経験値所得
  5428. *------------------------------------------
  5429. */
  5430. int clif_mvp_exp(struct map_session_data *sd,int exp)
  5431. {
  5432. int fd;
  5433. nullpo_retr(0, sd);
  5434. fd=sd->fd;
  5435. WFIFOW(fd,0)=0x10b;
  5436. WFIFOL(fd,2)=exp;
  5437. WFIFOSET(fd,packet_len_table[0x10b]);
  5438. return 0;
  5439. }
  5440. /*==========================================
  5441. * ギルド作成可否通知
  5442. *------------------------------------------
  5443. */
  5444. int clif_guild_created(struct map_session_data *sd,int flag)
  5445. {
  5446. int fd;
  5447. nullpo_retr(0, sd);
  5448. fd=sd->fd;
  5449. WFIFOW(fd,0)=0x167;
  5450. WFIFOB(fd,2)=flag;
  5451. WFIFOSET(fd,packet_len_table[0x167]);
  5452. return 0;
  5453. }
  5454. /*==========================================
  5455. * ギルド所属通知
  5456. *------------------------------------------
  5457. */
  5458. int clif_guild_belonginfo(struct map_session_data *sd,struct guild *g)
  5459. {
  5460. int ps,fd;
  5461. nullpo_retr(0, sd);
  5462. nullpo_retr(0, g);
  5463. fd=sd->fd;
  5464. ps=guild_getposition(sd,g);
  5465. memset(WFIFOP(fd,0),0,packet_len_table[0x16c]);
  5466. WFIFOW(fd,0)=0x16c;
  5467. WFIFOL(fd,2)=g->guild_id;
  5468. WFIFOL(fd,6)=g->emblem_id;
  5469. WFIFOL(fd,10)=g->position[ps].mode;
  5470. memcpy(WFIFOP(fd,19),g->name,24);
  5471. WFIFOSET(fd,packet_len_table[0x16c]);
  5472. return 0;
  5473. }
  5474. /*==========================================
  5475. * ギルドメンバログイン通知
  5476. *------------------------------------------
  5477. */
  5478. int clif_guild_memberlogin_notice(struct guild *g,int idx,int flag)
  5479. {
  5480. unsigned char buf[64];
  5481. nullpo_retr(0, g);
  5482. // printf("clif_guild_message(%s, %d, %s)\n", g->name, account_id, mes);
  5483. WBUFW(buf, 0)=0x16d;
  5484. WBUFL(buf, 2)=g->member[idx].account_id;
  5485. WBUFL(buf, 6)=g->member[idx].char_id;
  5486. WBUFL(buf,10)=flag;
  5487. if(g->member[idx].sd==NULL){
  5488. struct map_session_data *sd=guild_getavailablesd(g);
  5489. if(sd!=NULL)
  5490. clif_send(buf,packet_len_table[0x16d],&sd->bl,GUILD);
  5491. }else
  5492. clif_send(buf,packet_len_table[0x16d],&g->member[idx].sd->bl,GUILD_WOS);
  5493. return 0;
  5494. }
  5495. /*==========================================
  5496. * ギルドマスター通知(14dへの応答)
  5497. *------------------------------------------
  5498. */
  5499. int clif_guild_masterormember(struct map_session_data *sd)
  5500. {
  5501. int type=0x57,fd;
  5502. struct guild *g;
  5503. nullpo_retr(0, sd);
  5504. fd=sd->fd;
  5505. g=guild_search(sd->status.guild_id);
  5506. if(g!=NULL && strcmp(g->master,sd->status.name)==0)
  5507. type=0xd7;
  5508. WFIFOW(fd,0)=0x14e;
  5509. WFIFOL(fd,2)=type;
  5510. WFIFOSET(fd,packet_len_table[0x14e]);
  5511. return 0;
  5512. }
  5513. /*==========================================
  5514. * Basic Info (Territories [Valaris])
  5515. *------------------------------------------
  5516. */
  5517. int clif_guild_basicinfo(struct map_session_data *sd)
  5518. {
  5519. int fd,i,t=0;
  5520. struct guild *g;
  5521. struct guild_castle *gc=NULL;
  5522. nullpo_retr(0, sd);
  5523. fd=sd->fd;
  5524. g=guild_search(sd->status.guild_id);
  5525. if(g==NULL)
  5526. return 0;
  5527. WFIFOW(fd, 0)=0x1b6;//0x150;
  5528. WFIFOL(fd, 2)=g->guild_id;
  5529. WFIFOL(fd, 6)=g->guild_lv;
  5530. WFIFOL(fd,10)=g->connect_member;
  5531. WFIFOL(fd,14)=g->max_member;
  5532. WFIFOL(fd,18)=g->average_lv;
  5533. WFIFOL(fd,22)=g->exp;
  5534. WFIFOL(fd,26)=g->next_exp;
  5535. WFIFOL(fd,30)=0; // 上納
  5536. WFIFOL(fd,34)=0; // VW(性格の悪さ?:性向グラフ左右)
  5537. WFIFOL(fd,38)=0; // RF(正義の度合い?:性向グラフ上下)
  5538. WFIFOL(fd,42)=0; // 人数?
  5539. memcpy(WFIFOP(fd,46),g->name,24);
  5540. memcpy(WFIFOP(fd,70),g->master,24);
  5541. for(i=0;i<MAX_GUILDCASTLE;i++){
  5542. gc=guild_castle_search(i);
  5543. if(!gc) continue;
  5544. if(g->guild_id == gc->guild_id) t++;
  5545. }
  5546. if (t==1) strncpy((char*)WFIFOP(fd,94),"One Castle",20);
  5547. else if (t==2) strncpy((char*)WFIFOP(fd,94),"Two Castles",20);
  5548. else if (t==3) strncpy((char*)WFIFOP(fd,94),"Three Castles",20);
  5549. else if (t==4) strncpy((char*)WFIFOP(fd,94),"Four Castles",20);
  5550. else if (t==5) strncpy((char*)WFIFOP(fd,94),"Five Castles",20);
  5551. else if (t==6) strncpy((char*)WFIFOP(fd,94),"Six Castles",20);
  5552. else if (t==7) strncpy((char*)WFIFOP(fd,94),"Seven Castles",20);
  5553. else if (t==8) strncpy((char*)WFIFOP(fd,94),"Eight Castles",20);
  5554. else if (t==9) strncpy((char*)WFIFOP(fd,94),"Nine Castles",20);
  5555. else if (t==10) strncpy((char*)WFIFOP(fd,94),"Ten Castles",20);
  5556. else if (t==11) strncpy((char*)WFIFOP(fd,94),"Eleven Castles",20);
  5557. else if (t==12) strncpy((char*)WFIFOP(fd,94),"Twelve Castles",20);
  5558. else if (t==13) strncpy((char*)WFIFOP(fd,94),"Thirteen Castles",20);
  5559. else if (t==14) strncpy((char*)WFIFOP(fd,94),"Fourteen Castles",20);
  5560. else if (t==15) strncpy((char*)WFIFOP(fd,94),"Fifteen Castles",20);
  5561. else if (t==16) strncpy((char*)WFIFOP(fd,94),"Sixteen Castles",20);
  5562. else if (t==17) strncpy((char*)WFIFOP(fd,94),"Seventeen Castles",20);
  5563. else if (t==18) strncpy((char*)WFIFOP(fd,94),"Eighteen Castles",20);
  5564. else if (t==19) strncpy((char*)WFIFOP(fd,94),"Nineteen Castles",20);
  5565. else if (t==20) strncpy((char*)WFIFOP(fd,94),"Twenty Castles",20);
  5566. else if (t==21) strncpy((char*)WFIFOP(fd,94),"Twenty One Castles",20);
  5567. else if (t==22) strncpy((char*)WFIFOP(fd,94),"Twenty Two Castles",20);
  5568. else if (t==23) strncpy((char*)WFIFOP(fd,94),"Twenty Three Castles",20);
  5569. else if (t==24) strncpy((char*)WFIFOP(fd,94),"Twenty Four Castles",20);
  5570. else if (t==MAX_GUILDCASTLE) strncpy((char*)WFIFOP(fd,94),"Total Domination",20);
  5571. else strncpy((char*)WFIFOP(fd,94),"None Taken",20);
  5572. WFIFOSET(fd,packet_len_table[WFIFOW(fd,0)]);
  5573. clif_guild_emblem(sd,g); // Guild emblem vanish fix [Valaris]
  5574. return 0;
  5575. }
  5576. /*==========================================
  5577. * ギルド同盟/敵対情報
  5578. *------------------------------------------
  5579. */
  5580. int clif_guild_allianceinfo(struct map_session_data *sd)
  5581. {
  5582. int fd,i,c;
  5583. struct guild *g;
  5584. nullpo_retr(0, sd);
  5585. fd=sd->fd;
  5586. g=guild_search(sd->status.guild_id);
  5587. if(g==NULL)
  5588. return 0;
  5589. WFIFOW(fd, 0)=0x14c;
  5590. for(i=c=0;i<MAX_GUILDALLIANCE;i++){
  5591. struct guild_alliance *a=&g->alliance[i];
  5592. if(a->guild_id>0){
  5593. WFIFOL(fd,c*32+4)=a->opposition;
  5594. WFIFOL(fd,c*32+8)=a->guild_id;
  5595. memcpy(WFIFOP(fd,c*32+12),a->name,24);
  5596. c++;
  5597. }
  5598. }
  5599. WFIFOW(fd, 2)=c*32+4;
  5600. WFIFOSET(fd,WFIFOW(fd,2));
  5601. return 0;
  5602. }
  5603. /*==========================================
  5604. * ギルドメンバーリスト
  5605. *------------------------------------------
  5606. */
  5607. int clif_guild_memberlist(struct map_session_data *sd)
  5608. {
  5609. int fd;
  5610. int i,c;
  5611. struct guild *g;
  5612. nullpo_retr(0, sd);
  5613. fd=sd->fd;
  5614. g=guild_search(sd->status.guild_id);
  5615. if(g==NULL)
  5616. return 0;
  5617. WFIFOW(fd, 0)=0x154;
  5618. for(i=0,c=0;i<g->max_member;i++){
  5619. struct guild_member *m=&g->member[i];
  5620. if(m->account_id==0)
  5621. continue;
  5622. WFIFOL(fd,c*104+ 4)=m->account_id;
  5623. WFIFOL(fd,c*104+ 8)=m->char_id;
  5624. WFIFOW(fd,c*104+12)=m->hair;
  5625. WFIFOW(fd,c*104+14)=m->hair_color;
  5626. WFIFOW(fd,c*104+16)=m->gender;
  5627. WFIFOW(fd,c*104+18)=m->class_;
  5628. WFIFOW(fd,c*104+20)=m->lv;
  5629. WFIFOL(fd,c*104+22)=m->exp;
  5630. WFIFOL(fd,c*104+26)=m->online;
  5631. WFIFOL(fd,c*104+30)=m->position;
  5632. memset(WFIFOP(fd,c*104+34),0,50); // メモ?
  5633. memcpy(WFIFOP(fd,c*104+84),m->name,24);
  5634. c++;
  5635. }
  5636. WFIFOW(fd, 2)=c*104+4;
  5637. WFIFOSET(fd,WFIFOW(fd,2));
  5638. return 0;
  5639. }
  5640. /*==========================================
  5641. * ギルド役職名リスト
  5642. *------------------------------------------
  5643. */
  5644. int clif_guild_positionnamelist(struct map_session_data *sd)
  5645. {
  5646. int i,fd;
  5647. struct guild *g;
  5648. nullpo_retr(0, sd);
  5649. fd=sd->fd;
  5650. g=guild_search(sd->status.guild_id);
  5651. if(g==NULL)
  5652. return 0;
  5653. WFIFOW(fd, 0)=0x166;
  5654. for(i=0;i<MAX_GUILDPOSITION;i++){
  5655. WFIFOL(fd,i*28+4)=i;
  5656. memcpy(WFIFOP(fd,i*28+8),g->position[i].name,24);
  5657. }
  5658. WFIFOW(fd,2)=i*28+4;
  5659. WFIFOSET(fd,WFIFOW(fd,2));
  5660. return 0;
  5661. }
  5662. /*==========================================
  5663. * ギルド役職情報リスト
  5664. *------------------------------------------
  5665. */
  5666. int clif_guild_positioninfolist(struct map_session_data *sd)
  5667. {
  5668. int i,fd;
  5669. struct guild *g;
  5670. nullpo_retr(0, sd);
  5671. fd=sd->fd;
  5672. g=guild_search(sd->status.guild_id);
  5673. if(g==NULL)
  5674. return 0;
  5675. WFIFOW(fd, 0)=0x160;
  5676. for(i=0;i<MAX_GUILDPOSITION;i++){
  5677. struct guild_position *p=&g->position[i];
  5678. WFIFOL(fd,i*16+ 4)=i;
  5679. WFIFOL(fd,i*16+ 8)=p->mode;
  5680. WFIFOL(fd,i*16+12)=i;
  5681. WFIFOL(fd,i*16+16)=p->exp_mode;
  5682. }
  5683. WFIFOW(fd, 2)=i*16+4;
  5684. WFIFOSET(fd,WFIFOW(fd,2));
  5685. return 0;
  5686. }
  5687. /*==========================================
  5688. * ギルド役職変更通知
  5689. *------------------------------------------
  5690. */
  5691. int clif_guild_positionchanged(struct guild *g,int idx)
  5692. {
  5693. struct map_session_data *sd;
  5694. unsigned char buf[128];
  5695. nullpo_retr(0, g);
  5696. WBUFW(buf, 0)=0x174;
  5697. WBUFW(buf, 2)=44;
  5698. WBUFL(buf, 4)=idx;
  5699. WBUFL(buf, 8)=g->position[idx].mode;
  5700. WBUFL(buf,12)=idx;
  5701. WBUFL(buf,16)=g->position[idx].exp_mode;
  5702. memcpy(WBUFP(buf,20),g->position[idx].name,24);
  5703. if( (sd=guild_getavailablesd(g))!=NULL )
  5704. clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
  5705. return 0;
  5706. }
  5707. /*==========================================
  5708. * ギルドメンバ変更通知
  5709. *------------------------------------------
  5710. */
  5711. int clif_guild_memberpositionchanged(struct guild *g,int idx)
  5712. {
  5713. struct map_session_data *sd;
  5714. unsigned char buf[64];
  5715. nullpo_retr(0, g);
  5716. WBUFW(buf, 0)=0x156;
  5717. WBUFW(buf, 2)=16;
  5718. WBUFL(buf, 4)=g->member[idx].account_id;
  5719. WBUFL(buf, 8)=g->member[idx].char_id;
  5720. WBUFL(buf,12)=g->member[idx].position;
  5721. if( (sd=guild_getavailablesd(g))!=NULL )
  5722. clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
  5723. return 0;
  5724. }
  5725. /*==========================================
  5726. * ギルドエンブレム送信
  5727. *------------------------------------------
  5728. */
  5729. int clif_guild_emblem(struct map_session_data *sd,struct guild *g)
  5730. {
  5731. int fd;
  5732. nullpo_retr(0, sd);
  5733. nullpo_retr(0, g);
  5734. fd=sd->fd;
  5735. if(g->emblem_len<=0)
  5736. return 0;
  5737. WFIFOW(fd,0)=0x152;
  5738. WFIFOW(fd,2)=g->emblem_len+12;
  5739. WFIFOL(fd,4)=g->guild_id;
  5740. WFIFOL(fd,8)=g->emblem_id;
  5741. memcpy(WFIFOP(fd,12),g->emblem_data,g->emblem_len);
  5742. WFIFOSET(fd,WFIFOW(fd,2));
  5743. return 0;
  5744. }
  5745. /*==========================================
  5746. * ギルドスキル送信
  5747. *------------------------------------------
  5748. */
  5749. int clif_guild_skillinfo(struct map_session_data *sd)
  5750. {
  5751. int fd;
  5752. int i,id,c,up=1;
  5753. struct guild *g;
  5754. nullpo_retr(0, sd);
  5755. fd=sd->fd;
  5756. g=guild_search(sd->status.guild_id);
  5757. if(g==NULL)
  5758. return 0;
  5759. WFIFOW(fd,0)=0x0162;
  5760. WFIFOW(fd,4)=g->skill_point;
  5761. for(i=c=0;i<MAX_GUILDSKILL;i++){
  5762. if(g->skill[i].id>0){
  5763. WFIFOW(fd,c*37+ 6) = id = g->skill[i].id;
  5764. WFIFOW(fd,c*37+ 8) = guild_skill_get_inf(id);
  5765. WFIFOW(fd,c*37+10) = 0;
  5766. WFIFOW(fd,c*37+12) = g->skill[i].lv;
  5767. WFIFOW(fd,c*37+14) = guild_skill_get_sp(id,g->skill[i].lv);
  5768. WFIFOW(fd,c*37+16) = guild_skill_get_range(id);
  5769. memset(WFIFOP(fd,c*37+18),0,24);
  5770. if(g->skill[i].lv < guild_skill_get_max(id)) {
  5771. //Kafra and Guardian changed to require Approval [Sara]
  5772. if (g->skill[i].id == GD_KAFRACONTACT && guild_checkskill(g,GD_APPROVAL) <= 0)
  5773. up = 0;
  5774. else if (g->skill[i].id == GD_GUARDIANRESEARCH && guild_checkskill(g,GD_APPROVAL) <= 0)
  5775. up = 0;
  5776. //Glory skill requirements -- Pretty sure correct [Sara]
  5777. else if (g->skill[i].id == GD_LEADERSHIP && guild_checkskill(g,GD_GLORYGUILD) <= 0)
  5778. up = 0;
  5779. else if (g->skill[i].id == GD_GLORYWOUNDS && guild_checkskill(g,GD_GLORYGUILD) <= 0)
  5780. up = 0;
  5781. else if (g->skill[i].id == GD_SOULCOLD && guild_checkskill(g,GD_GLORYWOUNDS) <= 0)
  5782. up = 0;
  5783. else if (g->skill[i].id == GD_HAWKEYES && guild_checkskill(g,GD_LEADERSHIP) <= 0)
  5784. up = 0;
  5785. //Activated skill requirements -- Just guesses [Sara]
  5786. else if (g->skill[i].id == GD_BATTLEORDER && guild_checkskill(g,GD_APPROVAL) <= 0)
  5787. up = 0;
  5788. else if (g->skill[i].id == GD_REGENERATION && guild_checkskill(g,GD_APPROVAL) <= 0)
  5789. up = 0;
  5790. else if (g->skill[i].id == GD_RESTORE && guild_checkskill(g,GD_REGENERATION) <= 0)
  5791. up = 0;
  5792. else if (g->skill[i].id == GD_EMERGENCYCALL && guild_checkskill(g,GD_APPROVAL) <= 0)
  5793. up = 0;
  5794. if (g->skill[i].id == GD_GUARDUP && guild_checkskill(g,GD_GUARDIANRESEARCH) <= 0)
  5795. up = 0;
  5796. //Unadded yet? Has extension description in kRO tables
  5797. else if (g->skill[i].id == GD_DEVELOPMENT)
  5798. up = 0;
  5799. else
  5800. up = 1;
  5801. }
  5802. else {
  5803. up = 0;
  5804. }
  5805. WFIFOB(fd,c*37+42)= up;
  5806. c++;
  5807. }
  5808. }
  5809. WFIFOW(fd,2)=c*37+6;
  5810. WFIFOSET(fd,WFIFOW(fd,2));
  5811. return 0;
  5812. }
  5813. /*==========================================
  5814. * ギルド告知送信
  5815. *------------------------------------------
  5816. */
  5817. int clif_guild_notice(struct map_session_data *sd,struct guild *g)
  5818. {
  5819. int fd;
  5820. nullpo_retr(0, sd);
  5821. nullpo_retr(0, g);
  5822. fd=sd->fd;
  5823. if(*g->mes1==0 && *g->mes2==0)
  5824. return 0;
  5825. WFIFOW(fd,0)=0x16f;
  5826. memcpy(WFIFOP(fd,2),g->mes1,60);
  5827. memcpy(WFIFOP(fd,62),g->mes2,120);
  5828. WFIFOSET(fd,packet_len_table[0x16f]);
  5829. return 0;
  5830. }
  5831. /*==========================================
  5832. * ギルドメンバ勧誘
  5833. *------------------------------------------
  5834. */
  5835. int clif_guild_invite(struct map_session_data *sd,struct guild *g)
  5836. {
  5837. int fd;
  5838. nullpo_retr(0, sd);
  5839. nullpo_retr(0, g);
  5840. fd=sd->fd;
  5841. WFIFOW(fd,0)=0x16a;
  5842. WFIFOL(fd,2)=g->guild_id;
  5843. memcpy(WFIFOP(fd,6),g->name,24);
  5844. WFIFOSET(fd,packet_len_table[0x16a]);
  5845. return 0;
  5846. }
  5847. /*==========================================
  5848. * ギルドメンバ勧誘結果
  5849. *------------------------------------------
  5850. */
  5851. int clif_guild_inviteack(struct map_session_data *sd,int flag)
  5852. {
  5853. int fd;
  5854. nullpo_retr(0, sd);
  5855. fd=sd->fd;
  5856. WFIFOW(fd,0)=0x169;
  5857. WFIFOB(fd,2)=flag;
  5858. WFIFOSET(fd,packet_len_table[0x169]);
  5859. return 0;
  5860. }
  5861. /*==========================================
  5862. * ギルドメンバ脱退通知
  5863. *------------------------------------------
  5864. */
  5865. int clif_guild_leave(struct map_session_data *sd,const char *name,const char *mes)
  5866. {
  5867. unsigned char buf[128];
  5868. nullpo_retr(0, sd);
  5869. WBUFW(buf, 0)=0x15a;
  5870. memcpy(WBUFP(buf, 2),name,24);
  5871. memcpy(WBUFP(buf,26),mes,40);
  5872. clif_send(buf,packet_len_table[0x15a],&sd->bl,GUILD);
  5873. return 0;
  5874. }
  5875. /*==========================================
  5876. * ギルドメンバ追放通知
  5877. *------------------------------------------
  5878. */
  5879. int clif_guild_explusion(struct map_session_data *sd,const char *name,const char *mes,
  5880. int account_id)
  5881. {
  5882. unsigned char buf[128];
  5883. nullpo_retr(0, sd);
  5884. WBUFW(buf, 0)=0x15c;
  5885. memcpy(WBUFP(buf, 2),name,24);
  5886. memcpy(WBUFP(buf,26),mes,40);
  5887. memcpy(WBUFP(buf,66),"dummy",24);
  5888. clif_send(buf,packet_len_table[0x15c],&sd->bl,GUILD);
  5889. return 0;
  5890. }
  5891. /*==========================================
  5892. * ギルド追放メンバリスト
  5893. *------------------------------------------
  5894. */
  5895. int clif_guild_explusionlist(struct map_session_data *sd)
  5896. {
  5897. int fd;
  5898. int i,c;
  5899. struct guild *g;
  5900. nullpo_retr(0, sd);
  5901. fd=sd->fd;
  5902. g=guild_search(sd->status.guild_id);
  5903. if(g==NULL)
  5904. return 0;
  5905. WFIFOW(fd,0)=0x163;
  5906. for(i=c=0;i<MAX_GUILDEXPLUSION;i++){
  5907. struct guild_explusion *e=&g->explusion[i];
  5908. if(e->account_id>0){
  5909. memcpy(WFIFOP(fd,c*88+ 4),e->name,24);
  5910. memcpy(WFIFOP(fd,c*88+28),e->acc,24);
  5911. memcpy(WFIFOP(fd,c*88+52),e->mes,44);
  5912. c++;
  5913. }
  5914. }
  5915. WFIFOW(fd,2)=c*88+4;
  5916. WFIFOSET(fd,WFIFOW(fd,2));
  5917. return 0;
  5918. }
  5919. /*==========================================
  5920. * ギルド会話
  5921. *------------------------------------------
  5922. */
  5923. int clif_guild_message(struct guild *g,int account_id,const char *mes,int len)
  5924. {
  5925. struct map_session_data *sd;
  5926. unsigned char *buf;
  5927. buf = (unsigned char*)aCallocA(len + 4, sizeof(unsigned char));
  5928. WBUFW(buf, 0) = 0x17f;
  5929. WBUFW(buf, 2) = len + 4;
  5930. memcpy(WBUFP(buf,4), mes, len);
  5931. if ((sd = guild_getavailablesd(g)) != NULL)
  5932. clif_send(buf, WBUFW(buf,2), &sd->bl, GUILD);
  5933. if(buf) aFree(buf);
  5934. return 0;
  5935. }
  5936. /*==========================================
  5937. * ギルドスキル割り振り通知
  5938. *------------------------------------------
  5939. */
  5940. int clif_guild_skillup(struct map_session_data *sd,int skill_num,int lv)
  5941. {
  5942. int fd;
  5943. nullpo_retr(0, sd);
  5944. fd=sd->fd;
  5945. WFIFOW(fd,0) = 0x10e;
  5946. WFIFOW(fd,2) = skill_num;
  5947. WFIFOW(fd,4) = lv;
  5948. WFIFOW(fd,6) = guild_skill_get_sp(skill_num,lv);
  5949. WFIFOW(fd,8) = guild_skill_get_range(skill_num);
  5950. WFIFOB(fd,10) = 1;
  5951. WFIFOSET(fd,11);
  5952. return 0;
  5953. }
  5954. /*==========================================
  5955. * ギルド同盟要請
  5956. *------------------------------------------
  5957. */
  5958. int clif_guild_reqalliance(struct map_session_data *sd,int account_id,const char *name)
  5959. {
  5960. int fd;
  5961. nullpo_retr(0, sd);
  5962. fd=sd->fd;
  5963. WFIFOW(fd,0)=0x171;
  5964. WFIFOL(fd,2)=account_id;
  5965. memcpy(WFIFOP(fd,6),name,24);
  5966. WFIFOSET(fd,packet_len_table[0x171]);
  5967. return 0;
  5968. }
  5969. /*==========================================
  5970. * ギルド同盟結果
  5971. *------------------------------------------
  5972. */
  5973. int clif_guild_allianceack(struct map_session_data *sd,int flag)
  5974. {
  5975. int fd;
  5976. nullpo_retr(0, sd);
  5977. fd=sd->fd;
  5978. WFIFOW(fd,0)=0x173;
  5979. WFIFOL(fd,2)=flag;
  5980. WFIFOSET(fd,packet_len_table[0x173]);
  5981. return 0;
  5982. }
  5983. /*==========================================
  5984. * ギルド関係解消通知
  5985. *------------------------------------------
  5986. */
  5987. int clif_guild_delalliance(struct map_session_data *sd,int guild_id,int flag)
  5988. {
  5989. int fd;
  5990. nullpo_retr(0, sd);
  5991. fd=sd->fd;
  5992. WFIFOW(fd,0)=0x184;
  5993. WFIFOL(fd,2)=guild_id;
  5994. WFIFOL(fd,6)=flag;
  5995. WFIFOSET(fd,packet_len_table[0x184]);
  5996. return 0;
  5997. }
  5998. /*==========================================
  5999. * ギルド敵対結果
  6000. *------------------------------------------
  6001. */
  6002. int clif_guild_oppositionack(struct map_session_data *sd,int flag)
  6003. {
  6004. int fd;
  6005. nullpo_retr(0, sd);
  6006. fd=sd->fd;
  6007. WFIFOW(fd,0)=0x181;
  6008. WFIFOB(fd,2)=flag;
  6009. WFIFOSET(fd,packet_len_table[0x181]);
  6010. return 0;
  6011. }
  6012. /*==========================================
  6013. * ギルド関係追加
  6014. *------------------------------------------
  6015. */
  6016. /*int clif_guild_allianceadded(struct guild *g,int idx)
  6017. {
  6018. unsigned char buf[64];
  6019. WBUFW(fd,0)=0x185;
  6020. WBUFL(fd,2)=g->alliance[idx].opposition;
  6021. WBUFL(fd,6)=g->alliance[idx].guild_id;
  6022. memcpy(WBUFP(fd,10),g->alliance[idx].name,24);
  6023. clif_send(buf,packet_len_table[0x185],guild_getavailablesd(g),GUILD);
  6024. return 0;
  6025. }*/
  6026. /*==========================================
  6027. * ギルド解散通知
  6028. *------------------------------------------
  6029. */
  6030. int clif_guild_broken(struct map_session_data *sd,int flag)
  6031. {
  6032. int fd;
  6033. nullpo_retr(0, sd);
  6034. fd=sd->fd;
  6035. WFIFOW(fd,0)=0x15e;
  6036. WFIFOL(fd,2)=flag;
  6037. WFIFOSET(fd,packet_len_table[0x15e]);
  6038. return 0;
  6039. }
  6040. /*==========================================
  6041. * エモーション
  6042. *------------------------------------------
  6043. */
  6044. void clif_emotion(struct block_list *bl,int type)
  6045. {
  6046. unsigned char buf[8];
  6047. nullpo_retv(bl);
  6048. WBUFW(buf,0)=0xc0;
  6049. WBUFL(buf,2)=bl->id;
  6050. WBUFB(buf,6)=type;
  6051. clif_send(buf,packet_len_table[0xc0],bl,AREA);
  6052. }
  6053. /*==========================================
  6054. * トーキーボックス
  6055. *------------------------------------------
  6056. */
  6057. void clif_talkiebox(struct block_list *bl,char* talkie)
  6058. {
  6059. unsigned char buf[86];
  6060. nullpo_retv(bl);
  6061. WBUFW(buf,0)=0x191;
  6062. WBUFL(buf,2)=bl->id;
  6063. memcpy(WBUFP(buf,6),talkie,80);
  6064. clif_send(buf,packet_len_table[0x191],bl,AREA);
  6065. }
  6066. /*==========================================
  6067. * 結婚エフェクト
  6068. *------------------------------------------
  6069. */
  6070. void clif_wedding_effect(struct block_list *bl) {
  6071. unsigned char buf[6];
  6072. nullpo_retv(bl);
  6073. WBUFW(buf,0) = 0x1ea;
  6074. WBUFL(buf,2) = bl->id;
  6075. clif_send(buf, packet_len_table[0x1ea], bl, AREA);
  6076. }
  6077. /*==========================================
  6078. * あなたに逢いたい使用時名前叫び
  6079. *------------------------------------------
  6080. void clif_callpartner(struct map_session_data *sd)
  6081. {
  6082. unsigned char buf[26];
  6083. char *p;
  6084. nullpo_retv(sd);
  6085. if(sd->status.partner_id){
  6086. WBUFW(buf,0)=0x1e6;
  6087. p = map_charid2nick(sd->status.partner_id);
  6088. if(p){
  6089. memcpy(WBUFP(buf,2),p,24);
  6090. }else{
  6091. map_reqchariddb(sd,sd->status.partner_id);
  6092. chrif_searchcharid(sd->status.partner_id);
  6093. WBUFB(buf,2) = 0;
  6094. }
  6095. clif_send(buf,packet_len_table[0x1e6]&sd->bl,AREA);
  6096. }
  6097. return;
  6098. }
  6099. */
  6100. /*==========================================
  6101. * Adopt baby [Celest]
  6102. *------------------------------------------
  6103. */
  6104. void clif_adopt_process(struct map_session_data *sd)
  6105. {
  6106. int fd;
  6107. nullpo_retv(sd);
  6108. fd=sd->fd;
  6109. WFIFOW(fd,0)=0x1f8;
  6110. WFIFOSET(fd,packet_len_table[0x1f8]);
  6111. }
  6112. /*==========================================
  6113. *
  6114. *------------------------------------------
  6115. */
  6116. void clif_parse_ReqAdopt(int fd, struct map_session_data *sd) {
  6117. nullpo_retv(sd);
  6118. printf ("%d\n", RFIFOL(fd,2));
  6119. }
  6120. /*==========================================
  6121. * 座る
  6122. *------------------------------------------
  6123. */
  6124. void clif_sitting(struct map_session_data *sd)
  6125. {
  6126. unsigned char buf[64];
  6127. nullpo_retv(sd);
  6128. WBUFW(buf, 0) = 0x8a;
  6129. WBUFL(buf, 2) = sd->bl.id;
  6130. WBUFB(buf,26) = 2;
  6131. clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
  6132. }
  6133. /*==========================================
  6134. *
  6135. *------------------------------------------
  6136. */
  6137. int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len)
  6138. {
  6139. unsigned char *buf;
  6140. nullpo_retr(0, sd);
  6141. buf = (unsigned char*)aCallocA(len + 8, sizeof(unsigned char));
  6142. WBUFW(buf, 0) = 0x17f;
  6143. WBUFW(buf, 2) = len + 8;
  6144. memcpy(WBUFP(buf,4), mes, len + 4);
  6145. clif_send(buf, WBUFW(buf,2), &sd->bl, SELF);
  6146. if(buf) aFree(buf);
  6147. return 0;
  6148. }
  6149. /*==========================================
  6150. *
  6151. *------------------------------------------
  6152. */
  6153. int clif_GM_kickack(struct map_session_data *sd, int id)
  6154. {
  6155. int fd;
  6156. nullpo_retr(0, sd);
  6157. fd = sd->fd;
  6158. WFIFOW(fd,0) = 0xcd;
  6159. WFIFOL(fd,2) = id;
  6160. WFIFOSET(fd, packet_len_table[0xcd]);
  6161. return 0;
  6162. }
  6163. void clif_parse_QuitGame(int fd,struct map_session_data *sd);
  6164. int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int type)
  6165. {
  6166. nullpo_retr(0, tsd);
  6167. if(type)
  6168. clif_GM_kickack(sd,tsd->status.account_id);
  6169. tsd->opt1 = tsd->opt2 = 0;
  6170. WFIFOW(tsd->fd,0) = 0x18b;
  6171. WFIFOW(tsd->fd,2) = 0;
  6172. WFIFOSET(tsd->fd,packet_len_table[0x18b]);
  6173. clif_setwaitclose(tsd->fd);
  6174. return 0;
  6175. }
  6176. /*==========================================
  6177. *
  6178. *------------------------------------------
  6179. */
  6180. int clif_timedout(struct map_session_data *sd)
  6181. {
  6182. nullpo_retr(0, sd);
  6183. sprintf(tmp_output,"%sCharacter with Account ID '"CL_WHITE"%d"CL_RESET"' timed out.\n", (pc_isGM(sd))?"GM ":"", sd->bl.id);
  6184. ShowInfo(tmp_output);
  6185. map_quit(sd);
  6186. clif_authfail_fd(sd->fd,3); // Even if player is not on we still send anyway
  6187. clif_setwaitclose(sd->fd); // Set session to EOF
  6188. return 0;
  6189. }
  6190. /*==========================================
  6191. * Wis拒否許可応答
  6192. *------------------------------------------
  6193. */
  6194. int clif_wisexin(struct map_session_data *sd,int type,int flag)
  6195. {
  6196. int fd;
  6197. nullpo_retr(0, sd);
  6198. fd=sd->fd;
  6199. WFIFOW(fd,0)=0xd1;
  6200. WFIFOB(fd,2)=type;
  6201. WFIFOB(fd,3)=flag;
  6202. WFIFOSET(fd,packet_len_table[0xd1]);
  6203. return 0;
  6204. }
  6205. /*==========================================
  6206. * Wis全拒否許可応答
  6207. *------------------------------------------
  6208. */
  6209. int clif_wisall(struct map_session_data *sd,int type,int flag)
  6210. {
  6211. int fd;
  6212. nullpo_retr(0, sd);
  6213. fd=sd->fd;
  6214. WFIFOW(fd,0)=0xd2;
  6215. WFIFOB(fd,2)=type;
  6216. WFIFOB(fd,3)=flag;
  6217. WFIFOSET(fd,packet_len_table[0xd2]);
  6218. return 0;
  6219. }
  6220. /*==========================================
  6221. * サウンドエフェクト
  6222. *------------------------------------------
  6223. */
  6224. void clif_soundeffect(struct map_session_data *sd,struct block_list *bl,char *name,int type)
  6225. {
  6226. int fd;
  6227. nullpo_retv(sd);
  6228. nullpo_retv(bl);
  6229. fd=sd->fd;
  6230. WFIFOW(fd,0)=0x1d3;
  6231. memcpy(WFIFOP(fd,2),name,24);
  6232. WFIFOB(fd,26)=type;
  6233. WFIFOL(fd,27)=0;
  6234. WFIFOL(fd,31)=bl->id;
  6235. WFIFOSET(fd,packet_len_table[0x1d3]);
  6236. return;
  6237. }
  6238. int clif_soundeffectall(struct block_list *bl, char *name, int type)
  6239. {
  6240. unsigned char buf[31];
  6241. memset(buf, 0, packet_len_table[0x1d3]);
  6242. nullpo_retr(0, bl);
  6243. WBUFW(buf,0)=0x1d3;
  6244. memcpy(WBUFP(buf,2), name, 24);
  6245. WBUFB(buf,26)=type;
  6246. WBUFL(buf,27)=0;
  6247. WBUFL(buf,31)=bl->id;
  6248. clif_send(buf, packet_len_table[0x1d3], bl, AREA);
  6249. return 0;
  6250. }
  6251. // displaying special effects (npcs, weather, etc) [Valaris]
  6252. int clif_specialeffect(struct block_list *bl, int type, int flag) {
  6253. unsigned char buf[24];
  6254. nullpo_retr(0, bl);
  6255. memset(buf, 0, packet_len_table[0x1f3]);
  6256. WBUFW(buf,0) = 0x1f3;
  6257. WBUFL(buf,2) = bl->id;
  6258. WBUFL(buf,6) = type;
  6259. if (flag == 3) {
  6260. // struct map_session_data *sd;
  6261. struct map_session_data *pl_sd;
  6262. int i;
  6263. for(i = 0; i < fd_max; i++) {
  6264. if (session[i] && (pl_sd = (struct map_session_data*)session[i]->session_data) != NULL &&
  6265. pl_sd->state.auth &&
  6266. (pc_isGM((struct map_session_data *)&bl) > pc_isGM((struct map_session_data *)&pl_sd->bl)))
  6267. clif_specialeffect(&pl_sd->bl, type, 1);
  6268. }
  6269. }
  6270. if (flag == 2) {
  6271. struct map_session_data *sd;
  6272. int i;
  6273. for(i = 0; i < fd_max; i++) {
  6274. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth && sd->bl.m == bl->m)
  6275. clif_specialeffect(&sd->bl, type, 1);
  6276. }
  6277. }
  6278. else if (flag == 1)
  6279. clif_send(buf, packet_len_table[0x1f3], bl, SELF);
  6280. else if (!flag)
  6281. clif_send(buf, packet_len_table[0x1f3], bl, AREA);
  6282. return 0;
  6283. }
  6284. // ------------
  6285. // clif_parse_*
  6286. // ------------
  6287. // パケット読み取って色々操作
  6288. /*==========================================
  6289. *
  6290. *------------------------------------------
  6291. */
  6292. void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
  6293. {
  6294. struct map_session_data *old_sd;
  6295. int cmd, account_id; // account_id in the packet 0x72 or 0x7E
  6296. if (sd) {
  6297. if (battle_config.error_log)
  6298. printf("clif_parse_WantToConnection : invalid request?\n");
  6299. return;
  6300. }
  6301. cmd = RFIFOW(fd,0);
  6302. // packet DB
  6303. if (IS_PACKET_DB_VER(cmd)) {
  6304. //printf("Received bytes %d with packet 0x72.\n", RFIFOREST(fd));
  6305. account_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[0]);
  6306. // 0x72
  6307. } else if (cmd == 0x72) {
  6308. //printf("Received bytes %d with packet 0x72.\n", RFIFOREST(fd));
  6309. if (RFIFOREST(fd) >= 39 && (RFIFOB(fd,38) == 0 || RFIFOB(fd,38) == 1)) // 00 = Female, 01 = Male
  6310. account_id = RFIFOL(fd,12);
  6311. else if (RFIFOREST(fd) >= 22 && (RFIFOB(fd,21) == 0 || RFIFOB(fd,21) == 1)) // 00 = Female, 01 = Male
  6312. account_id = RFIFOL(fd,5);
  6313. else // old packet version
  6314. account_id = RFIFOL(fd,2);
  6315. // 0x7E
  6316. } else if (cmd == 0x7E) {
  6317. //printf("Received bytes %d with packet 0x7E.\n", RFIFOREST(fd));
  6318. if (RFIFOREST(fd) >= 37 && (RFIFOB(fd,36) == 0 || RFIFOB(fd,36) == 1)) // 00 = Female, 01 = Male
  6319. account_id = RFIFOL(fd,9);
  6320. else
  6321. account_id = RFIFOL(fd,12);
  6322. // 0xF5
  6323. } else if (cmd == 0xF5) {
  6324. //printf("Received bytes %d with packet 0xF5.\n", RFIFOREST(fd));
  6325. if (RFIFOREST(fd) >= 34 && (RFIFOB(fd,33) == 0 || RFIFOB(fd,33) == 1)) // 00 = Female, 01 = Male
  6326. account_id = RFIFOL(fd,7);
  6327. else if (RFIFOREST(fd) >= 33 && (RFIFOB(fd,32) == 0 || RFIFOB(fd,32) == 1)) // 00 = Female, 01 = Male
  6328. account_id = RFIFOL(fd,12);
  6329. else if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) // 00 = Female, 01 = Male
  6330. account_id = RFIFOL(fd,10);
  6331. else { // 29 28 28
  6332. /*if (RFIFOW(fd,1) == 0) // testing ^^;
  6333. account_id = RFIFOL(fd,3);
  6334. else*/
  6335. account_id = RFIFOL(fd,5);
  6336. }
  6337. // 0x9B
  6338. } else {
  6339. account_id = RFIFOL(fd,3);
  6340. }
  6341. // if same account already connected, we disconnect the 2 sessions
  6342. if ((old_sd = map_id2sd(account_id)) != NULL) {
  6343. clif_authfail_fd(fd, 8); // still recognizes last connection
  6344. clif_authfail_fd(old_sd->fd, 2); // same id
  6345. if (sd != 0)
  6346. clif_setwaitclose(sd->fd); // Set session to EOF
  6347. } else {
  6348. sd = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data));
  6349. session[fd]->session_data = sd;
  6350. sd->fd = fd;
  6351. if (IS_PACKET_DB_VER(cmd)) {
  6352. sd->packet_ver = clif_config.packet_db_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6353. pc_setnewpc(sd, account_id, RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[1]),
  6354. RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[2]),
  6355. RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[3]),
  6356. RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[4]), fd);
  6357. // 0x72
  6358. } else if (cmd == 0x72) {
  6359. if (RFIFOREST(fd) >= 39 && (RFIFOB(fd,38) == 0 || RFIFOB(fd,38) == 1)) { // 00 = Female, 01 = Male
  6360. sd->packet_ver = 7; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6361. pc_setnewpc(sd, account_id, RFIFOL(fd,22), RFIFOL(fd,30), RFIFOL(fd,34), RFIFOB(fd,38), fd);
  6362. } else if (RFIFOREST(fd) >= 22 && (RFIFOB(fd,21) == 0 || RFIFOB(fd,21) == 1)) { // 00 = Female, 01 = Male
  6363. sd->packet_ver = 6; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6364. pc_setnewpc(sd, account_id, RFIFOL(fd,9), RFIFOL(fd,13), RFIFOL(fd,17), RFIFOB(fd,21), fd);
  6365. } else { // old packet version
  6366. sd->packet_ver = 5; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6367. pc_setnewpc(sd, account_id, RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOB(fd,18), fd);
  6368. }
  6369. // 0x7E
  6370. } else if (cmd == 0x7E) {
  6371. if (RFIFOREST(fd) >= 37 && (RFIFOB(fd,36) == 0 || RFIFOB(fd,36) == 1)) { // 00 = Female, 01 = Male
  6372. sd->packet_ver = 9; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6373. pc_setnewpc(sd, account_id, RFIFOL(fd,21), RFIFOL(fd,28), RFIFOL(fd,32), RFIFOB(fd,36), fd);
  6374. } else {
  6375. sd->packet_ver = 8; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6376. pc_setnewpc(sd, account_id, RFIFOL(fd,18), RFIFOL(fd,24), RFIFOL(fd,28), RFIFOB(fd,32), fd);
  6377. }
  6378. // 0xF5
  6379. } else if (cmd == 0xF5) {
  6380. if (RFIFOREST(fd) >= 34 && (RFIFOB(fd,33) == 0 || RFIFOB(fd,33) == 1)) { // 00 = Female, 01 = Male
  6381. sd->packet_ver = 10; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6382. pc_setnewpc(sd, account_id, RFIFOL(fd,15), RFIFOL(fd,25), RFIFOL(fd,29), RFIFOB(fd,33), fd);
  6383. } else if (RFIFOREST(fd) >= 33 && (RFIFOB(fd,32) == 0 || RFIFOB(fd,32) == 1)) { // 00 = Female, 01 = Male
  6384. sd->packet_ver = 12; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6385. pc_setnewpc(sd, account_id, RFIFOL(fd,18), RFIFOL(fd,24), RFIFOL(fd,28), RFIFOB(fd,32), fd);
  6386. } else if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) { // 00 = Female, 01 = Male
  6387. sd->packet_ver = 11; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6388. pc_setnewpc(sd, account_id, RFIFOL(fd,17), RFIFOL(fd,23), RFIFOL(fd,27), RFIFOB(fd,31), fd);
  6389. } else { // 29
  6390. if (RFIFOW(fd,1) == 0) {
  6391. sd->packet_ver = 15; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6392. pc_setnewpc(sd, account_id, RFIFOL(fd,10), RFIFOL(fd,20), RFIFOL(fd,24), RFIFOB(fd,28), fd);
  6393. } else {
  6394. sd->packet_ver = 13; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6395. pc_setnewpc(sd, account_id, RFIFOL(fd,14), RFIFOL(fd,20), RFIFOL(fd,24), RFIFOB(fd,28), fd);
  6396. }
  6397. }
  6398. // 0x9B
  6399. } else {
  6400. sd->packet_ver = 16; // 16: 10jan05
  6401. pc_setnewpc(sd, account_id, RFIFOL(fd,12), RFIFOL(fd,23), RFIFOL(fd,27), RFIFOB(fd,31), fd);
  6402. }
  6403. WFIFOL(fd,0) = sd->bl.id;
  6404. WFIFOSET(fd,4);
  6405. map_addiddb(&sd->bl);
  6406. chrif_authreq(sd);
  6407. }
  6408. return;
  6409. }
  6410. /*==========================================
  6411. * 007d クライアント側マップ読み込み完了
  6412. * map侵入時に必要なデータを全て送りつける
  6413. *------------------------------------------
  6414. */
  6415. void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
  6416. {
  6417. // struct item_data* item;
  6418. int i;
  6419. nullpo_retv(sd);
  6420. if(sd->bl.prev != NULL)
  6421. return;
  6422. // 接続ok時
  6423. //clif_authok();
  6424. if(sd->npc_id) npc_event_dequeue(sd);
  6425. clif_skillinfoblock(sd);
  6426. pc_checkitem(sd);
  6427. //guild_info();
  6428. // loadendack時
  6429. // next exp
  6430. clif_updatestatus(sd,SP_NEXTBASEEXP);
  6431. clif_updatestatus(sd,SP_NEXTJOBEXP);
  6432. // skill point
  6433. clif_updatestatus(sd,SP_SKILLPOINT);
  6434. // item
  6435. clif_itemlist(sd);
  6436. clif_equiplist(sd);
  6437. // cart
  6438. if(pc_iscarton(sd)){
  6439. clif_cart_itemlist(sd);
  6440. clif_cart_equiplist(sd);
  6441. clif_updatestatus(sd,SP_CARTINFO);
  6442. }
  6443. // param all
  6444. clif_initialstatus(sd);
  6445. // party
  6446. party_send_movemap(sd);
  6447. // guild
  6448. guild_send_memberinfoshort(sd,1);
  6449. // 119
  6450. // 78
  6451. if(battle_config.pc_invincible_time > 0) {
  6452. if(map[sd->bl.m].flag.gvg)
  6453. pc_setinvincibletimer(sd,battle_config.pc_invincible_time<<1);
  6454. else
  6455. pc_setinvincibletimer(sd,battle_config.pc_invincible_time);
  6456. }
  6457. map_addblock(&sd->bl); // ブロック登録
  6458. clif_spawnpc(sd); // spawn
  6459. // weight max , now
  6460. clif_updatestatus(sd,SP_MAXWEIGHT);
  6461. clif_updatestatus(sd,SP_WEIGHT);
  6462. // pvp
  6463. if(sd->pvp_timer!=-1 && !battle_config.pk_mode)
  6464. delete_timer(sd->pvp_timer,pc_calc_pvprank_timer);
  6465. if(map[sd->bl.m].flag.pvp){
  6466. if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris]
  6467. sd->pvp_timer=add_timer(gettick()+200,pc_calc_pvprank_timer,sd->bl.id,0);
  6468. sd->pvp_rank=0;
  6469. sd->pvp_lastusers=0;
  6470. sd->pvp_point=5;
  6471. }
  6472. clif_set0199(sd->fd,1);
  6473. } else {
  6474. sd->pvp_timer=-1;
  6475. }
  6476. if(map[sd->bl.m].flag.gvg) {
  6477. clif_set0199(sd->fd,3);
  6478. }
  6479. // pet
  6480. if(sd->status.pet_id > 0 && sd->pd && sd->pet.intimate > 0) {
  6481. map_addblock(&sd->pd->bl);
  6482. clif_spawnpet(sd->pd);
  6483. clif_send_petdata(sd,0,0);
  6484. clif_send_petdata(sd,5,0x14);
  6485. clif_send_petstatus(sd);
  6486. }
  6487. if(sd->state.connect_new) {
  6488. sd->state.connect_new = 0;
  6489. if(sd->status.class_ != sd->view_class)
  6490. clif_changelook(&sd->bl,LOOK_BASE,sd->view_class);
  6491. if(sd->status.pet_id > 0 && sd->pd && sd->pet.intimate > 900)
  6492. clif_pet_emotion(sd->pd,(sd->pd->class_ - 100)*100 + 50 + pet_hungry_val(sd));
  6493. /* Stop players from spawning inside castles [Valaris] */
  6494. {
  6495. struct guild_castle *gc=guild_mapname2gc(map[sd->bl.m].name);
  6496. if (gc)
  6497. pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,2);
  6498. }
  6499. /* End Addition [Valaris] */
  6500. }
  6501. // view equipment item
  6502. #if PACKETVER < 4
  6503. clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
  6504. clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
  6505. #else
  6506. clif_changelook(&sd->bl,LOOK_WEAPON,0);
  6507. #endif
  6508. if(battle_config.save_clothcolor==1 && sd->status.clothes_color > 0)
  6509. clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->status.clothes_color);
  6510. if(sd->status.hp<sd->status.max_hp>>2 && pc_checkskill(sd,SM_AUTOBERSERK)>0 &&
  6511. (sd->sc_data[SC_PROVOKE].timer==-1 || sd->sc_data[SC_PROVOKE].val2==0 ))
  6512. // オートバーサーク発動
  6513. skill_status_change_start(&sd->bl,SC_PROVOKE,10,1,0,0,0,0);
  6514. // if(time(&timer) < ((weddingtime=pc_readglobalreg(sd,"PC_WEDDING_TIME")) + 3600))
  6515. // skill_status_change_start(&sd->bl,SC_WEDDING,0,weddingtime,0,0,36000,0);
  6516. if(battle_config.muting_players && sd->status.manner < 0)
  6517. skill_status_change_start(&sd->bl,SC_NOCHAT,0,0,0,0,0,0);
  6518. if (night_flag) {
  6519. if (battle_config.night_darkness_level > 0 && !map[sd->bl.m].flag.indoors)
  6520. clif_specialeffect(&sd->bl, 474 + battle_config.night_darkness_level, 0);
  6521. else {
  6522. //clif_specialeffect(&sd->bl, 483, 0); // default darkness level
  6523. // night - when changing from indoors to outdoors - celest
  6524. if (!map[sd->bl.m].flag.indoors && sd->opt2 != STATE_BLIND)
  6525. sd->opt2 |= STATE_BLIND;
  6526. // changing from outdoors to indoors
  6527. else if (map[sd->bl.m].flag.indoors && sd->opt2 == STATE_BLIND)
  6528. sd->opt2 &= ~STATE_BLIND;
  6529. }
  6530. }
  6531. // option
  6532. clif_changeoption(&sd->bl);
  6533. if(sd->sc_data[SC_TRICKDEAD].timer != -1)
  6534. skill_status_change_end(&sd->bl,SC_TRICKDEAD,-1);
  6535. if(sd->sc_data[SC_SIGNUMCRUCIS].timer != -1 && !battle_check_undead(7,sd->def_ele))
  6536. skill_status_change_end(&sd->bl,SC_SIGNUMCRUCIS,-1);
  6537. if(sd->special_state.infinite_endure && sd->sc_data[SC_ENDURE].timer == -1)
  6538. skill_status_change_start(&sd->bl,SC_ENDURE,10,1,0,0,0,0);
  6539. for(i=0;i<MAX_INVENTORY;i++){
  6540. if(sd->status.inventory[i].equip && sd->status.inventory[i].equip & 0x0002 && sd->status.inventory[i].attribute==1)
  6541. skill_status_change_start(&sd->bl,SC_BROKNWEAPON,0,0,0,0,0,0);
  6542. if(sd->status.inventory[i].equip && sd->status.inventory[i].equip & 0x0010 && sd->status.inventory[i].attribute==1)
  6543. skill_status_change_start(&sd->bl,SC_BROKNARMOR,0,0,0,0,0,0);
  6544. }
  6545. 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,0,sd);
  6546. }
  6547. /*==========================================
  6548. *
  6549. *------------------------------------------
  6550. */
  6551. void clif_parse_TickSend(int fd, struct map_session_data *sd) {
  6552. nullpo_retv(sd);
  6553. if (USE_PACKET_DB(sd)) {
  6554. sd->client_tick=RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  6555. } else {
  6556. switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6557. case 8:
  6558. sd->client_tick = RFIFOL(fd,6);
  6559. break;
  6560. case 9:
  6561. sd->client_tick = RFIFOL(fd,9);
  6562. break;
  6563. case 10:
  6564. sd->client_tick = RFIFOL(fd,7);
  6565. break;
  6566. case 11:
  6567. sd->client_tick = RFIFOL(fd,10);
  6568. break;
  6569. case 12:
  6570. sd->client_tick = RFIFOL(fd,6);
  6571. break;
  6572. case 13:
  6573. case 14:
  6574. sd->client_tick = RFIFOL(fd,5);
  6575. break;
  6576. case 15:
  6577. sd->client_tick = RFIFOL(fd,3);
  6578. break;
  6579. case 16:
  6580. sd->client_tick = RFIFOL(fd,5);
  6581. break;
  6582. default: // old version by default (and version 6 + 7)
  6583. sd->client_tick = RFIFOL(fd,2);
  6584. break;
  6585. }
  6586. }
  6587. sd->server_tick = gettick();
  6588. clif_servertick(sd);
  6589. }
  6590. /*==========================================
  6591. *
  6592. *------------------------------------------
  6593. */
  6594. void clif_parse_WalkToXY(int fd, struct map_session_data *sd) {
  6595. int x, y;
  6596. nullpo_retv(sd);
  6597. if (pc_isdead(sd)) {
  6598. clif_clearchar_area(&sd->bl, 1);
  6599. return;
  6600. }
  6601. if (sd->npc_id != 0 || sd->vender_id != 0)
  6602. return;
  6603. if (sd->skilltimer != -1 && pc_checkskill(sd, SA_FREECAST) <= 0) // フリーキャスト
  6604. return;
  6605. if (sd->chatID)
  6606. return;
  6607. if (sd->canmove_tick > gettick())
  6608. return;
  6609. // ステータス異常やハイディング中(トンネルドライブ無)で動けない
  6610. if ((sd->opt1 > 0 && sd->opt1 != 6) ||
  6611. sd->sc_data[SC_ANKLE].timer !=-1 || //アンクルスネア
  6612. sd->sc_data[SC_AUTOCOUNTER].timer !=-1 || //オートカウンター
  6613. sd->sc_data[SC_TRICKDEAD].timer !=-1 || //死んだふり
  6614. sd->sc_data[SC_BLADESTOP].timer !=-1 || //白刃取り
  6615. sd->sc_data[SC_SPIDERWEB].timer !=-1 || //スパイダーウェッブ
  6616. (sd->sc_data[SC_DANCING].timer !=-1 && sd->sc_data[SC_DANCING].val4) || //合奏スキル演奏中は動けない
  6617. (sd->sc_data[SC_GOSPEL].timer !=-1 && sd->sc_data[SC_GOSPEL].val4 == BCT_SELF) || // cannot move while gospel is in effect
  6618. sd->sc_data[SC_CONFUSION].timer !=-1)
  6619. return;
  6620. if ((sd->status.option & 2) && pc_checkskill(sd, RG_TUNNELDRIVE) <= 0)
  6621. return;
  6622. if (sd->invincible_timer != -1)
  6623. pc_delinvincibletimer(sd);
  6624. pc_stopattack(sd);
  6625. if (USE_PACKET_DB(sd)) {
  6626. int cmd = RFIFOW(fd,0);
  6627. x = RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0]) * 4 +
  6628. (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0] + 1) >> 6);
  6629. y = ((RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0]+1) & 0x3f) << 4) +
  6630. (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0] + 2) >> 4);
  6631. } else {
  6632. switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6633. case 6:
  6634. x = RFIFOB(fd,5) * 4 + (RFIFOB(fd,6) >> 6);
  6635. y = ((RFIFOB(fd,6) & 0x3f) << 4) + (RFIFOB(fd,7) >> 4);
  6636. break;
  6637. case 7:
  6638. x = RFIFOB(fd,6) * 4 + (RFIFOB(fd,7) >> 6);
  6639. y = ((RFIFOB(fd,7) & 0x3f) << 4) + (RFIFOB(fd,8) >> 4);
  6640. break;
  6641. case 8:
  6642. x = RFIFOB(fd,3) * 4 + (RFIFOB(fd,4) >> 6);
  6643. y = ((RFIFOB(fd,4) & 0x3f) << 4) + (RFIFOB(fd,5) >> 4);
  6644. break;
  6645. case 9:
  6646. x = RFIFOB(fd,12) * 4 + (RFIFOB(fd,13) >> 6);
  6647. y = ((RFIFOB(fd,13) & 0x3f) << 4) + (RFIFOB(fd,14) >> 4);
  6648. break;
  6649. case 10:
  6650. x = RFIFOB(fd,6) * 4 + (RFIFOB(fd,7) >> 6);
  6651. y = ((RFIFOB(fd,7) & 0x3f) << 4) + (RFIFOB(fd,8) >> 4);
  6652. break;
  6653. case 11:
  6654. x = RFIFOB(fd,11) * 4 + (RFIFOB(fd,12) >> 6);
  6655. y = ((RFIFOB(fd,12) & 0x3f) << 4) + (RFIFOB(fd,13) >> 4);
  6656. break;
  6657. case 12:
  6658. x = RFIFOB(fd,3) * 4 + (RFIFOB(fd,4) >> 6);
  6659. y = ((RFIFOB(fd,4) & 0x3f) << 4) + (RFIFOB(fd,5) >> 4);
  6660. break;
  6661. case 13:
  6662. case 14:
  6663. x = RFIFOB(fd,3) * 4 + (RFIFOB(fd,4) >> 6);
  6664. y = ((RFIFOB(fd,4) & 0x3f) << 4) + (RFIFOB(fd,5) >> 4);
  6665. break;
  6666. case 15:
  6667. x = RFIFOB(fd,4) * 4 + (RFIFOB(fd,5) >> 6);
  6668. y = ((RFIFOB(fd,5) & 0x3f) << 4) + (RFIFOB(fd,6) >> 4);
  6669. break;
  6670. case 16:
  6671. x = RFIFOB(fd,10) * 4 + (RFIFOB(fd,11) >> 6);
  6672. y = ((RFIFOB(fd,11) & 0x3f) << 4) + (RFIFOB(fd,12) >> 4);
  6673. break;
  6674. default: // old version by default
  6675. x = RFIFOB(fd,2) * 4 + (RFIFOB(fd,3) >> 6);
  6676. y = ((RFIFOB(fd,3) & 0x3f) << 4) + (RFIFOB(fd,4) >> 4);
  6677. break;
  6678. }
  6679. }
  6680. pc_walktoxy(sd, x, y);
  6681. }
  6682. /*==========================================
  6683. *
  6684. *------------------------------------------
  6685. */
  6686. void clif_parse_QuitGame(int fd, struct map_session_data *sd) {
  6687. unsigned int tick=gettick();
  6688. struct skill_unit_group* sg;
  6689. nullpo_retv(sd);
  6690. WFIFOW(fd,0) = 0x18b;
  6691. if ((!pc_isdead(sd) && (sd->opt1 || (sd->opt2 && !(night_flag == 1 && sd->opt2 == STATE_BLIND)))) ||
  6692. sd->skilltimer != -1 ||
  6693. (DIFF_TICK(tick, sd->canact_tick) < 0) ||
  6694. (sd->sc_data && sd->sc_data[SC_DANCING].timer!=-1 && sd->sc_data[SC_DANCING].val4 && (sg=(struct skill_unit_group *)sd->sc_data[SC_DANCING].val2) && sg->src_id == sd->bl.id)) {
  6695. WFIFOW(fd,2)=1;
  6696. WFIFOSET(fd,packet_len_table[0x18b]);
  6697. return;
  6698. }
  6699. /* Rovert's prevent logout option fixed [Valaris] */
  6700. if ((battle_config.prevent_logout && (gettick() - sd->canlog_tick) >= 10000) || (!battle_config.prevent_logout)) {
  6701. clif_setwaitclose(fd);
  6702. WFIFOW(fd,2)=0;
  6703. } else {
  6704. WFIFOW(fd,2)=1;
  6705. }
  6706. WFIFOSET(fd,packet_len_table[0x18b]);
  6707. }
  6708. /*==========================================
  6709. *
  6710. *------------------------------------------
  6711. */
  6712. void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) {
  6713. struct block_list *bl;
  6714. int account_id;
  6715. if (USE_PACKET_DB(sd)) {
  6716. account_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  6717. } else {
  6718. switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6719. case 8:
  6720. account_id = RFIFOL(fd,11);
  6721. break;
  6722. case 9:
  6723. account_id = RFIFOL(fd,8);
  6724. break;
  6725. case 10:
  6726. account_id = RFIFOL(fd,10);
  6727. break;
  6728. case 11:
  6729. account_id = RFIFOL(fd,6);
  6730. break;
  6731. case 12:
  6732. account_id = RFIFOL(fd,11);
  6733. break;
  6734. case 13:
  6735. case 14:
  6736. account_id = RFIFOL(fd,6);
  6737. break;
  6738. case 15:
  6739. account_id = RFIFOL(fd,9);
  6740. break;
  6741. case 16:
  6742. account_id = RFIFOL(fd,4);
  6743. break;
  6744. default: // old version by default (+ packet version 6 and 7)
  6745. account_id = RFIFOL(fd,2);
  6746. break;
  6747. }
  6748. }
  6749. bl = map_id2bl(account_id);
  6750. if (bl == NULL)
  6751. return;
  6752. WFIFOW(fd,0) = 0x95;
  6753. WFIFOL(fd,2) = account_id;
  6754. switch(bl->type) {
  6755. case BL_PC:
  6756. {
  6757. struct map_session_data *ssd = (struct map_session_data *)bl;
  6758. struct party *p = NULL;
  6759. struct guild *g = NULL;
  6760. nullpo_retv(ssd);
  6761. memcpy(WFIFOP(fd,6), ssd->status.name, 24);
  6762. if (ssd->status.guild_id > 0 && (g = guild_search(ssd->status.guild_id)) != NULL &&
  6763. (ssd->status.party_id == 0 || (p = party_search(ssd->status.party_id)) != NULL)) {
  6764. // ギルド所属ならパケット0195を返す
  6765. int i, ps = -1;
  6766. for(i = 0; i < g->max_member; i++) {
  6767. if (g->member[i].account_id == ssd->status.account_id &&
  6768. g->member[i].char_id == ssd->status.char_id )
  6769. ps = g->member[i].position;
  6770. }
  6771. if (ps >= 0 && ps < MAX_GUILDPOSITION) {
  6772. WFIFOW(fd, 0) = 0x195;
  6773. if (p)
  6774. memcpy(WFIFOP(fd,30), p->name, 24);
  6775. else
  6776. WFIFOB(fd,30) = 0;
  6777. memcpy(WFIFOP(fd,54), g->name,24);
  6778. memcpy(WFIFOP(fd,78), g->position[ps].name, 24);
  6779. WFIFOSET(fd,packet_len_table[0x195]);
  6780. break;
  6781. }
  6782. }
  6783. WFIFOSET(fd,packet_len_table[0x95]);
  6784. }
  6785. break;
  6786. case BL_PET:
  6787. memcpy(WFIFOP(fd,6), ((struct pet_data*)bl)->name, 24);
  6788. WFIFOSET(fd,packet_len_table[0x95]);
  6789. break;
  6790. case BL_NPC:
  6791. memcpy(WFIFOP(fd,6), ((struct npc_data*)bl)->name, 24);
  6792. WFIFOSET(fd,packet_len_table[0x95]);
  6793. break;
  6794. case BL_MOB:
  6795. {
  6796. struct mob_data *md = (struct mob_data *)bl;
  6797. nullpo_retv(md);
  6798. memcpy(WFIFOP(fd,6), md->name, 24);
  6799. if (md->class_ >= 1285 && md->class_ <= 1288 && md->guild_id) {
  6800. struct guild *g;
  6801. struct guild_castle *gc = guild_mapname2gc(map[md->bl.m].name);
  6802. if (gc && gc->guild_id > 0 && (g = guild_search(gc->guild_id)) != NULL) {
  6803. WFIFOW(fd, 0) = 0x195;
  6804. WFIFOB(fd,30) = 0;
  6805. memcpy(WFIFOP(fd,54), g->name, 24);
  6806. memcpy(WFIFOP(fd,78), gc->castle_name, 24);
  6807. WFIFOSET(fd,packet_len_table[0x195]);
  6808. } else {
  6809. WFIFOSET(fd,packet_len_table[0x95]);
  6810. }
  6811. } else if (battle_config.show_mob_hp == 1) {
  6812. char mobhp[50];
  6813. sprintf(mobhp, "hp: %d/%d", md->hp, mob_db[md->class_].max_hp);
  6814. WFIFOW(fd, 0) = 0x195;
  6815. memcpy(WFIFOP(fd,30), mobhp, 24);
  6816. WFIFOB(fd,54) = 0;
  6817. WFIFOB(fd,78) = 0;
  6818. WFIFOSET(fd,packet_len_table[0x195]);
  6819. } else {
  6820. WFIFOSET(fd,packet_len_table[0x95]);
  6821. }
  6822. }
  6823. break;
  6824. default:
  6825. if (battle_config.error_log)
  6826. printf("clif_parse_GetCharNameRequest : bad type %d(%d)\n", bl->type, account_id);
  6827. break;
  6828. }
  6829. }
  6830. /*==========================================
  6831. *
  6832. *------------------------------------------
  6833. */
  6834. void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c <len>.w <str>.?B
  6835. char *message;
  6836. unsigned char *buf;
  6837. nullpo_retv(sd);
  6838. if ((is_atcommand(fd, sd, (char*)RFIFOP(fd,4), 0) != AtCommand_None) ||
  6839. (is_charcommand(fd, sd, (char*)RFIFOP(fd,4),0)!= CharCommand_None) ||
  6840. (sd->sc_data &&
  6841. (sd->sc_data[SC_BERSERK].timer != -1 || //バーサーク時は会話も不可
  6842. sd->sc_data[SC_NOCHAT].timer != -1 ))) //チャット禁止
  6843. return;
  6844. message = (char*)aCallocA(RFIFOW(fd,2) + 128, sizeof(char));
  6845. buf = (unsigned char*)aCallocA(RFIFOW(fd,2) + 4, sizeof(char));
  6846. //printf("clif_parse_GlobalMessage: message: '%s'.\n", RFIFOP(fd,4));
  6847. if (strncmp((char*)RFIFOP(fd,4), sd->status.name, strlen(sd->status.name)) != 0) {
  6848. printf("Hack on global message: character '%s' (account: %d), use an other name to send a (normal) message.\n", sd->status.name, sd->status.account_id);
  6849. // information is sended to all online GM
  6850. sprintf(message, "Hack on global message (normal message): character '%s' (account: %d) uses another name.", sd->status.name, sd->status.account_id);
  6851. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message, strlen(message) + 1);
  6852. if (strlen((char*)RFIFOP(fd,4)) == 0)
  6853. strcpy(message, " This player sends a void name and a void message.");
  6854. else
  6855. sprintf(message, " This player sends (name:message): '%s'.", RFIFOP(fd,4));
  6856. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message, strlen(message) + 1);
  6857. // message about the ban
  6858. if (battle_config.ban_spoof_namer > 0)
  6859. sprintf(message, " This player has been banned for %d minute(s).", battle_config.ban_spoof_namer);
  6860. else
  6861. sprintf(message, " This player hasn't been banned (Ban option is disabled).");
  6862. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message, strlen(message) + 1);
  6863. // if we ban people
  6864. if (battle_config.ban_spoof_namer > 0) {
  6865. chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_spoof_namer, 0); // type: 2 - ban (year, month, day, hour, minute, second)
  6866. clif_setwaitclose(fd); // forced to disconnect because of the hack
  6867. if(message) aFree(message);
  6868. if(buf) aFree(buf);
  6869. return;
  6870. }
  6871. // but for the hacker, we display on his screen (he see/look no difference).
  6872. } else {
  6873. // send message to others
  6874. WBUFW(buf,0) = 0x8d;
  6875. WBUFW(buf,2) = RFIFOW(fd,2) + 4; // len of message - 4 + 8
  6876. WBUFL(buf,4) = sd->bl.id;
  6877. memcpy(WBUFP(buf,8), RFIFOP(fd,4), RFIFOW(fd,2) - 4);
  6878. clif_send(buf, WBUFW(buf,2), &sd->bl, sd->chatID ? CHAT_WOS : AREA_CHAT_WOC);
  6879. }
  6880. // send back message to the speaker
  6881. memcpy(WFIFOP(fd,0), RFIFOP(fd,0), RFIFOW(fd,2));
  6882. WFIFOW(fd,0) = 0x8e;
  6883. WFIFOSET(fd, WFIFOW(fd,2));
  6884. // Celest
  6885. if (pc_calc_base_job2 (sd->status.class_) == 23 ) {
  6886. int next = pc_nextbaseexp(sd)>0 ? pc_nextbaseexp(sd) : sd->status.base_exp;
  6887. if ((sd->status.base_exp*100/next)%10 == 0) {
  6888. estr_lower((char*)RFIFOP(fd,4));
  6889. if (sd->state.snovice_flag == 0 && strstr((char*)RFIFOP(fd,4), msg_txt(540)))
  6890. sd->state.snovice_flag = 1;
  6891. else if (sd->state.snovice_flag == 1) {
  6892. sprintf(message, msg_txt(541), sd->status.name);
  6893. estr_lower(message);
  6894. if (strstr((char*)RFIFOP(fd,4), message))
  6895. sd->state.snovice_flag = 2;
  6896. }
  6897. else if (sd->state.snovice_flag == 2 && strstr((char*)RFIFOP(fd,4), msg_txt(542)))
  6898. sd->state.snovice_flag = 3;
  6899. else if (sd->state.snovice_flag == 3) {
  6900. int i;
  6901. skill_status_change_start(&sd->bl,SkillStatusChangeTable[MO_EXPLOSIONSPIRITS],1,0,0,0,skill_get_time(MO_EXPLOSIONSPIRITS,1),0 );
  6902. for(i=0;i<5;i++)
  6903. pc_addspiritball(sd,skill_get_time(MO_CALLSPIRITS,1),5);
  6904. sd->state.snovice_flag = 0;
  6905. }
  6906. }
  6907. }
  6908. if(message) aFree(message);
  6909. if(buf) aFree(buf);
  6910. return;
  6911. }
  6912. int clif_message(struct block_list *bl, char* msg)
  6913. {
  6914. unsigned short msg_len = strlen(msg) + 1;
  6915. unsigned char buf[256];
  6916. nullpo_retr(0, bl);
  6917. WBUFW(buf, 0) = 0x8d;
  6918. WBUFW(buf, 2) = msg_len + 8;
  6919. WBUFL(buf, 4) = bl->id;
  6920. memcpy(WBUFP(buf, 8), msg, msg_len);
  6921. clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC); // by Gengar
  6922. return 0;
  6923. }
  6924. /*==========================================
  6925. *
  6926. *------------------------------------------
  6927. */
  6928. void clif_parse_MapMove(int fd, struct map_session_data *sd) {
  6929. // /m /mapmove (as @rura GM command)
  6930. char output[100];
  6931. char map_name[17];
  6932. nullpo_retv(sd);
  6933. memset(output, '\0', sizeof(output));
  6934. memset(map_name, '\0', sizeof(map_name));
  6935. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  6936. (pc_isGM(sd) >= get_atcommand_level(AtCommand_MapMove))) {
  6937. memcpy(map_name, RFIFOP(fd,2), 16);
  6938. sprintf(output, "%s %d %d", map_name, RFIFOW(fd,18), RFIFOW(fd,20));
  6939. atcommand_rura(fd, sd, "@rura", output);
  6940. }
  6941. return;
  6942. }
  6943. /*==========================================
  6944. *
  6945. *------------------------------------------
  6946. */
  6947. void clif_changed_dir(struct block_list *bl) {
  6948. unsigned char buf[64];
  6949. struct map_session_data *sd = NULL;
  6950. if (bl->type == BL_PC)
  6951. nullpo_retv (sd=(struct map_session_data *)bl);
  6952. WBUFW(buf,0) = 0x9c;
  6953. WBUFL(buf,2) = bl->id;
  6954. if (sd)
  6955. WBUFW(buf,6) = sd->head_dir;
  6956. WBUFB(buf,8) = battle_get_dir(bl);
  6957. if (sd && sd->disguise > 23 && sd->disguise < 4001) // mob disguises [Valaris]
  6958. clif_send(buf, packet_len_table[0x9c], &sd->bl, AREA);
  6959. else
  6960. clif_send(buf, packet_len_table[0x9c], bl, AREA_WOS);
  6961. return;
  6962. }
  6963. /*==========================================
  6964. *
  6965. *------------------------------------------
  6966. */
  6967. void clif_parse_ChangeDir(int fd, struct map_session_data *sd) {
  6968. short headdir, dir;
  6969. nullpo_retv(sd);
  6970. if (USE_PACKET_DB(sd)) {
  6971. headdir = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  6972. dir = RFIFOB(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  6973. } else {
  6974. switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  6975. case 7:
  6976. headdir = RFIFOW(fd,5);
  6977. dir = RFIFOB(fd,12);
  6978. break;
  6979. case 8:
  6980. headdir = RFIFOW(fd,5);
  6981. dir = RFIFOB(fd,12);
  6982. break;
  6983. case 9:
  6984. headdir = RFIFOW(fd,7);
  6985. dir = RFIFOB(fd,11);
  6986. break;
  6987. case 10:
  6988. headdir = RFIFOW(fd,4);
  6989. dir = RFIFOB(fd,9);
  6990. break;
  6991. case 11:
  6992. headdir = RFIFOW(fd,8);
  6993. dir = RFIFOB(fd,17);
  6994. break;
  6995. case 12:
  6996. headdir = RFIFOW(fd,5);
  6997. dir = RFIFOB(fd,12);
  6998. break;
  6999. case 13:
  7000. case 14:
  7001. headdir = RFIFOW(fd,6);
  7002. dir = RFIFOB(fd,14);
  7003. break;
  7004. case 15:
  7005. headdir = RFIFOW(fd,3);
  7006. dir = RFIFOB(fd,7);
  7007. break;
  7008. case 16:
  7009. headdir = RFIFOW(fd,12);
  7010. dir = RFIFOB(fd,22);
  7011. break;
  7012. default: // old version by default (and packet version 6)
  7013. headdir = RFIFOW(fd,2);
  7014. dir = RFIFOB(fd,4);
  7015. break;
  7016. }
  7017. }
  7018. pc_setdir(sd, dir, headdir);
  7019. clif_changed_dir(&sd->bl);
  7020. return;
  7021. }
  7022. /*==========================================
  7023. *
  7024. *------------------------------------------
  7025. */
  7026. void clif_parse_Emotion(int fd, struct map_session_data *sd) {
  7027. unsigned char buf[64];
  7028. nullpo_retv(sd);
  7029. if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, NV_BASIC) >= 2) {
  7030. WBUFW(buf,0) = 0xc0;
  7031. WBUFL(buf,2) = sd->bl.id;
  7032. if(RFIFOB(fd,2)==34) // prevent use of the mute emote [Valaris]
  7033. return;
  7034. WBUFB(buf,6) = RFIFOB(fd,2);
  7035. clif_send(buf, packet_len_table[0xc0], &sd->bl, AREA);
  7036. } else
  7037. clif_skill_fail(sd, 1, 0, 1);
  7038. }
  7039. /*==========================================
  7040. *
  7041. *------------------------------------------
  7042. */
  7043. void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) {
  7044. WFIFOW(fd,0) = 0xc2;
  7045. WFIFOL(fd,2) = map_getusers();
  7046. WFIFOSET(fd,packet_len_table[0xc2]);
  7047. }
  7048. /*==========================================
  7049. *
  7050. *------------------------------------------
  7051. */
  7052. void clif_parse_ActionRequest(int fd, struct map_session_data *sd) {
  7053. unsigned int tick;
  7054. unsigned char buf[64];
  7055. int action_type, target_id;
  7056. nullpo_retv(sd);
  7057. if (pc_isdead(sd)) {
  7058. clif_clearchar_area(&sd->bl, 1);
  7059. return;
  7060. }
  7061. if (sd->npc_id != 0 || sd->opt1 > 0 || sd->status.option & 2 ||
  7062. (sd->sc_data &&
  7063. (sd->sc_data[SC_TRICKDEAD].timer != -1 ||
  7064. sd->sc_data[SC_AUTOCOUNTER].timer != -1 || //オートカウンター
  7065. sd->sc_data[SC_BLADESTOP].timer != -1 || //白刃取り
  7066. sd->sc_data[SC_DANCING].timer != -1))) //ダンス中
  7067. return;
  7068. tick = gettick();
  7069. pc_stop_walking(sd, 0);
  7070. pc_stopattack(sd);
  7071. if (USE_PACKET_DB(sd)) {
  7072. target_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  7073. action_type = RFIFOB(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  7074. } else {
  7075. switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  7076. case 8:
  7077. target_id = RFIFOL(fd,3);
  7078. action_type = RFIFOB(fd,8);
  7079. break;
  7080. case 9:
  7081. target_id = RFIFOL(fd,7);
  7082. action_type = RFIFOB(fd,17);
  7083. break;
  7084. case 10:
  7085. target_id = RFIFOL(fd,9);
  7086. action_type = RFIFOB(fd,22);
  7087. break;
  7088. case 11:
  7089. target_id = RFIFOL(fd,3);
  7090. action_type = RFIFOB(fd,8);
  7091. break;
  7092. case 12:
  7093. target_id = RFIFOL(fd,3);
  7094. action_type = RFIFOB(fd,8);
  7095. break;
  7096. case 13:
  7097. case 14:
  7098. target_id = RFIFOL(fd,4);
  7099. action_type = RFIFOB(fd,14);
  7100. break;
  7101. case 15:
  7102. target_id = RFIFOL(fd,6);
  7103. action_type = RFIFOB(fd,17);
  7104. break;
  7105. case 16:
  7106. target_id = RFIFOL(fd,9);
  7107. action_type = RFIFOB(fd,19);
  7108. break;
  7109. default: // old version by default (and packet version 6 and 7)
  7110. target_id = RFIFOL(fd,2);
  7111. action_type = RFIFOB(fd,6);
  7112. break;
  7113. }
  7114. }
  7115. switch(action_type) {
  7116. case 0x00: // once attack
  7117. case 0x07: // continuous attack
  7118. if(sd->sc_data[SC_WEDDING].timer != -1 || sd->view_class==22)
  7119. return;
  7120. if (sd->vender_id != 0)
  7121. return;
  7122. if (!battle_config.sdelay_attack_enable && pc_checkskill(sd, SA_FREECAST) <= 0) {
  7123. if (DIFF_TICK(tick, sd->canact_tick) < 0) {
  7124. clif_skill_fail(sd, 1, 4, 0);
  7125. return;
  7126. }
  7127. }
  7128. if (sd->invincible_timer != -1)
  7129. pc_delinvincibletimer(sd);
  7130. if (sd->attacktarget > 0) // [Valaris]
  7131. sd->attacktarget = 0;
  7132. pc_attack(sd, target_id, action_type != 0);
  7133. break;
  7134. case 0x02: // sitdown
  7135. if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, NV_BASIC) >= 3) {
  7136. pc_stop_walking(sd, 1);
  7137. pc_setsit(sd);
  7138. skill_gangsterparadise(sd, 1); // ギャングスターパラダイス設定 fixed Valaris
  7139. clif_sitting(sd);
  7140. } else
  7141. clif_skill_fail(sd, 1, 0, 2);
  7142. break;
  7143. case 0x03: // standup
  7144. pc_setstand(sd);
  7145. skill_gangsterparadise(sd, 0); // ギャングスターパラダイス解除 fixed Valaris
  7146. WBUFW(buf, 0) = 0x8a;
  7147. WBUFL(buf, 2) = sd->bl.id;
  7148. WBUFB(buf,26) = 3;
  7149. clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
  7150. break;
  7151. }
  7152. }
  7153. /*==========================================
  7154. *
  7155. *------------------------------------------
  7156. */
  7157. void clif_parse_Restart(int fd, struct map_session_data *sd) {
  7158. nullpo_retv(sd);
  7159. switch(RFIFOB(fd,2)) {
  7160. case 0x00:
  7161. if (pc_isdead(sd)) {
  7162. pc_setstand(sd);
  7163. pc_setrestartvalue(sd, 3);
  7164. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 2);
  7165. }
  7166. // in case the player's status somehow wasn't updated yet [Celest]
  7167. else if (sd->status.hp <= 0)
  7168. pc_setdead(sd);
  7169. break;
  7170. case 0x01:
  7171. if(!pc_isdead(sd) && (sd->opt1 || (sd->opt2 && !(night_flag == 1 && sd->opt2 == STATE_BLIND))))
  7172. return;
  7173. /* Rovert's Prevent logout option - Fixed [Valaris] */
  7174. if ((battle_config.prevent_logout && (gettick() - sd->canlog_tick) >= 10000) || (!battle_config.prevent_logout)) {
  7175. chrif_charselectreq(sd);
  7176. } else {
  7177. WFIFOW(fd,0)=0x18b;
  7178. WFIFOW(fd,2)=1;
  7179. WFIFOSET(fd,packet_len_table[0x018b]);
  7180. }
  7181. break;
  7182. }
  7183. }
  7184. /*==========================================
  7185. * Transmission of a wisp (S 0096 <len>.w <nick>.24B <message>.?B)
  7186. *------------------------------------------
  7187. */
  7188. void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 <len>.w <nick>.24B <message>.?B // rewritten by [Yor]
  7189. char *gm_command;
  7190. struct map_session_data *dstsd;
  7191. int i;
  7192. //printf("clif_parse_Wis: message: '%s'.\n", RFIFOP(fd,28));
  7193. gm_command = (char*)aCallocA(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)
  7194. sprintf(gm_command, "%s : %s", sd->status.name, RFIFOP(fd,28));
  7195. if ((is_charcommand(fd, sd, gm_command, 0) != CharCommand_None) ||
  7196. (is_atcommand(fd, sd, gm_command, 0) != AtCommand_None) ||
  7197. (sd && sd->sc_data &&
  7198. (sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク時は会話も不可
  7199. sd->sc_data[SC_NOCHAT].timer != -1))) //チャット禁止
  7200. {
  7201. if(gm_command) aFree(gm_command);
  7202. return;
  7203. }
  7204. if(gm_command) aFree(gm_command);
  7205. // searching destination character
  7206. dstsd = map_nick2sd((char*)RFIFOP(fd,4));
  7207. // player is not on this map-server
  7208. if (dstsd == NULL ||
  7209. // At this point, don't send wisp/page if it's not exactly the same name, because (example)
  7210. // if there are 'Test' player on an other map-server and 'test' player on this map-server,
  7211. // and if we ask for 'Test', we must not contact 'test' player
  7212. // so, we send information to inter-server, which is the only one which decide (and copy correct name).
  7213. strcmp(dstsd->status.name, (const char*)RFIFOP(fd,4)) != 0) // not exactly same name
  7214. // send message to inter-server
  7215. intif_wis_message(sd, (char*)RFIFOP(fd,4), (char*)RFIFOP(fd,28), RFIFOW(fd,2)-28);
  7216. // player is on this map-server
  7217. else {
  7218. // if you send to your self, don't send anything to others
  7219. if (dstsd->fd == fd) // but, normaly, it's impossible!
  7220. clif_wis_message(fd, wisp_server_name, "You can not page yourself. Sorry.", strlen("You can not page yourself. Sorry.") + 1);
  7221. // otherwise, send message and answer immediatly
  7222. else {
  7223. if (dstsd->ignoreAll == 1)
  7224. clif_wis_end(fd, 2); // type: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
  7225. else {
  7226. // if player ignore the source character
  7227. for(i = 0; i < MAX_IGNORE_LIST; i++)
  7228. if (strcmp(dstsd->ignore[i].name, sd->status.name) == 0) {
  7229. clif_wis_end(fd, 2); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
  7230. break;
  7231. }
  7232. // if source player not found in ignore list
  7233. if (i == MAX_IGNORE_LIST) {
  7234. clif_wis_message(dstsd->fd, sd->status.name, (char*)RFIFOP(fd,28), RFIFOW(fd,2) - 28);
  7235. clif_wis_end(fd, 0); // type: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
  7236. }
  7237. }
  7238. }
  7239. }
  7240. return;
  7241. }
  7242. /*==========================================
  7243. *
  7244. *------------------------------------------
  7245. */
  7246. void clif_parse_GMmessage(int fd, struct map_session_data *sd) {
  7247. // /b
  7248. nullpo_retv(sd);
  7249. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  7250. (pc_isGM(sd) >= get_atcommand_level(AtCommand_Broadcast)))
  7251. intif_GMmessage((char*)RFIFOP(fd,4), RFIFOW(fd,2)-4, 0);
  7252. }
  7253. /*==========================================
  7254. *
  7255. *------------------------------------------
  7256. */
  7257. void clif_parse_TakeItem(int fd, struct map_session_data *sd) {
  7258. struct flooritem_data *fitem;
  7259. int map_object_id;
  7260. nullpo_retv(sd);
  7261. if (USE_PACKET_DB(sd)) {
  7262. map_object_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  7263. } else {
  7264. switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  7265. case 7:
  7266. map_object_id = RFIFOL(fd,6);
  7267. break;
  7268. case 8:
  7269. map_object_id = RFIFOL(fd,6);
  7270. break;
  7271. case 9:
  7272. map_object_id = RFIFOL(fd,9);
  7273. break;
  7274. case 10:
  7275. map_object_id = RFIFOL(fd,7);
  7276. break;
  7277. case 11:
  7278. map_object_id = RFIFOL(fd,10);
  7279. break;
  7280. case 12:
  7281. map_object_id = RFIFOL(fd,6);
  7282. break;
  7283. case 13:
  7284. case 14:
  7285. map_object_id = RFIFOL(fd,5);
  7286. break;
  7287. case 15:
  7288. map_object_id = RFIFOL(fd,3);
  7289. break;
  7290. case 16:
  7291. map_object_id = RFIFOL(fd,5);
  7292. break;
  7293. default: // old version by default (and packet version 6)
  7294. map_object_id = RFIFOL(fd,2);
  7295. break;
  7296. }
  7297. }
  7298. fitem = (struct flooritem_data*)map_id2bl(map_object_id);
  7299. if (pc_isdead(sd)) {
  7300. clif_clearchar_area(&sd->bl, 1);
  7301. return;
  7302. }
  7303. if( sd->npc_id!=0 || sd->vender_id != 0 || sd->opt1 > 0 ||
  7304. (sd->sc_data && (sd->sc_data[SC_TRICKDEAD].timer != -1 || //死んだふり
  7305. sd->sc_data[SC_BLADESTOP].timer != -1 || //白刃取り
  7306. sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク
  7307. sd->sc_data[SC_NOCHAT].timer!=-1 )) ) //会話禁止
  7308. return;
  7309. if (fitem == NULL || fitem->bl.m != sd->bl.m)
  7310. return;
  7311. pc_takeitem(sd, fitem);
  7312. }
  7313. /*==========================================
  7314. *
  7315. *------------------------------------------
  7316. */
  7317. void clif_parse_DropItem(int fd, struct map_session_data *sd) {
  7318. int item_index, item_amount;
  7319. nullpo_retv(sd);
  7320. if (pc_isdead(sd)) {
  7321. clif_clearchar_area(&sd->bl, 1);
  7322. return;
  7323. }
  7324. if (sd->npc_id != 0 || sd->vender_id != 0 || sd->opt1 > 0 ||
  7325. (sd->sc_data && (sd->sc_data[SC_AUTOCOUNTER].timer != -1 || //オートカウンター
  7326. sd->sc_data[SC_BLADESTOP].timer != -1 || //白刃取り
  7327. sd->sc_data[SC_BERSERK].timer != -1)) ) //バーサーク
  7328. return;
  7329. if (USE_PACKET_DB(sd)) {
  7330. item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2;
  7331. item_amount = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  7332. } else {
  7333. switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  7334. case 8:
  7335. item_index = RFIFOW(fd,5) - 2;
  7336. item_amount = RFIFOW(fd,12);
  7337. break;
  7338. case 9:
  7339. item_index = RFIFOW(fd,8) - 2;
  7340. item_amount = RFIFOW(fd,15);
  7341. break;
  7342. case 10:
  7343. item_index = RFIFOW(fd,6) - 2;
  7344. item_amount = RFIFOW(fd,15);
  7345. break;
  7346. case 11:
  7347. item_index = RFIFOW(fd,12) - 2;
  7348. item_amount = RFIFOW(fd,17);
  7349. break;
  7350. case 12:
  7351. item_index = RFIFOW(fd,5) - 2;
  7352. item_amount = RFIFOW(fd,12);
  7353. break;
  7354. case 13:
  7355. case 14:
  7356. item_index = RFIFOW(fd,6) - 2;
  7357. item_amount = RFIFOW(fd,10);
  7358. break;
  7359. case 15:
  7360. item_index = RFIFOW(fd,4) - 2;
  7361. item_amount = RFIFOW(fd,10);
  7362. break;
  7363. case 16:
  7364. item_index = RFIFOW(fd,15) - 2;
  7365. item_amount = RFIFOW(fd,18);
  7366. break;
  7367. default: // old version by default (+ packet version 6 and 7)
  7368. item_index = RFIFOW(fd,2) - 2;
  7369. item_amount = RFIFOW(fd,4);
  7370. break;
  7371. }
  7372. }
  7373. pc_dropitem(sd, item_index, item_amount);
  7374. }
  7375. /*==========================================
  7376. *
  7377. *------------------------------------------
  7378. */
  7379. void clif_parse_UseItem(int fd, struct map_session_data *sd) {
  7380. nullpo_retv(sd);
  7381. if (pc_isdead(sd)) {
  7382. clif_clearchar_area(&sd->bl, 1);
  7383. return;
  7384. }
  7385. if (sd->npc_id!=0 || sd->vender_id != 0 || (sd->opt1 > 0 && sd->opt1 != 6) ||
  7386. (sd->sc_data && (sd->sc_data[SC_TRICKDEAD].timer != -1 || //死んだふり
  7387. sd->sc_data[SC_BLADESTOP].timer != -1 || //白刃取り
  7388. sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク
  7389. sd->sc_data[SC_NOCHAT].timer!=-1 )) ) //会話禁止
  7390. return;
  7391. if (sd->invincible_timer != -1)
  7392. pc_delinvincibletimer(sd);
  7393. if (USE_PACKET_DB(sd)) {
  7394. pc_useitem(sd,RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2);
  7395. } else {
  7396. switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  7397. case 6:
  7398. pc_useitem(sd,RFIFOW(fd,5)-2);
  7399. break;
  7400. case 7:
  7401. pc_useitem(sd,RFIFOW(fd,6)-2);
  7402. break;
  7403. case 8:
  7404. pc_useitem(sd,RFIFOW(fd,6)-2);
  7405. break;
  7406. case 9:
  7407. pc_useitem(sd,RFIFOW(fd,9)-2);
  7408. break;
  7409. case 10:
  7410. pc_useitem(sd,RFIFOW(fd,7)-2);
  7411. break;
  7412. case 11:
  7413. pc_useitem(sd,RFIFOW(fd,10)-2);
  7414. break;
  7415. case 12:
  7416. pc_useitem(sd,RFIFOW(fd,6)-2);
  7417. break;
  7418. case 13:
  7419. case 14:
  7420. pc_useitem(sd,RFIFOW(fd,5)-2);
  7421. break;
  7422. case 15:
  7423. pc_useitem(sd,RFIFOW(fd,3)-2);
  7424. break;
  7425. case 16:
  7426. pc_useitem(sd,RFIFOW(fd,5)-2);
  7427. break;
  7428. default: // old version by default
  7429. pc_useitem(sd,RFIFOW(fd,2)-2);
  7430. break;
  7431. }
  7432. }
  7433. }
  7434. /*==========================================
  7435. *
  7436. *------------------------------------------
  7437. */
  7438. void clif_parse_EquipItem(int fd,struct map_session_data *sd)
  7439. {
  7440. int index;
  7441. nullpo_retv(sd);
  7442. if(pc_isdead(sd)) {
  7443. clif_clearchar_area(&sd->bl,1);
  7444. return;
  7445. }
  7446. index = RFIFOW(fd,2)-2;
  7447. if(sd->npc_id!=0 || sd->vender_id != 0) return;
  7448. if(sd->sc_data && ( sd->sc_data[SC_BLADESTOP].timer!=-1 || sd->sc_data[SC_BERSERK].timer!=-1 )) return;
  7449. if(sd->status.inventory[index].identify != 1) { // 未鑑定
  7450. clif_equipitemack(sd,index,0,0); // fail
  7451. return;
  7452. }
  7453. //ペット用装備であるかないか
  7454. if(sd->inventory_data[index]) {
  7455. if(sd->inventory_data[index]->type != 8){
  7456. if(sd->inventory_data[index]->type == 10)
  7457. RFIFOW(fd,4)=0x8000; // 矢を無理やり装備できるように(--;
  7458. pc_equipitem(sd,index,RFIFOW(fd,4));
  7459. } else
  7460. pet_equipitem(sd,index);
  7461. }
  7462. }
  7463. /*==========================================
  7464. *
  7465. *------------------------------------------
  7466. */
  7467. void clif_parse_UnequipItem(int fd,struct map_session_data *sd)
  7468. {
  7469. int index;
  7470. nullpo_retv(sd);
  7471. if(pc_isdead(sd)) {
  7472. clif_clearchar_area(&sd->bl,1);
  7473. return;
  7474. }
  7475. if(sd->npc_id!=0 || sd->vender_id != 0 || sd->opt1 > 0)
  7476. return;
  7477. index = RFIFOW(fd,2)-2;
  7478. /*if(sd->status.inventory[index].attribute == 1 && sd->sc_data && sd->sc_data[SC_BROKNWEAPON].timer!=-1)
  7479. skill_status_change_end(&sd->bl,SC_BROKNWEAPON,-1);
  7480. if(sd->status.inventory[index].attribute == 1 && sd->sc_data && sd->sc_data[SC_BROKNARMOR].timer!=-1)
  7481. skill_status_change_end(&sd->bl,SC_BROKNARMOR,-1);
  7482. if(sd->sc_count && ( sd->sc_data[SC_BLADESTOP].timer!=-1 || sd->sc_data[SC_BERSERK].timer!=-1 ))
  7483. return;*/
  7484. pc_unequipitem(sd,index,1);
  7485. }
  7486. /*==========================================
  7487. *
  7488. *------------------------------------------
  7489. */
  7490. void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
  7491. {
  7492. nullpo_retv(sd);
  7493. if(pc_isdead(sd)) {
  7494. clif_clearchar_area(&sd->bl,1);
  7495. return;
  7496. }
  7497. if(sd->npc_id!=0 || sd->vender_id != 0)
  7498. return;
  7499. npc_click(sd,RFIFOL(fd,2));
  7500. }
  7501. /*==========================================
  7502. *
  7503. *------------------------------------------
  7504. */
  7505. void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd)
  7506. {
  7507. npc_buysellsel(sd,RFIFOL(fd,2),RFIFOB(fd,6));
  7508. }
  7509. /*==========================================
  7510. *
  7511. *------------------------------------------
  7512. */
  7513. void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd)
  7514. {
  7515. int fail=0,n;
  7516. unsigned short *item_list;
  7517. n = (RFIFOW(fd,2)-4) /4;
  7518. item_list = (unsigned short*)RFIFOP(fd,4);
  7519. fail = npc_buylist(sd,n,item_list);
  7520. WFIFOW(fd,0)=0xca;
  7521. WFIFOB(fd,2)=fail;
  7522. WFIFOSET(fd,packet_len_table[0xca]);
  7523. }
  7524. /*==========================================
  7525. *
  7526. *------------------------------------------
  7527. */
  7528. void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd)
  7529. {
  7530. int fail=0,n;
  7531. unsigned short *item_list;
  7532. n = (RFIFOW(fd,2)-4) /4;
  7533. item_list = (unsigned short*)RFIFOP(fd,4);
  7534. fail = npc_selllist(sd,n,item_list);
  7535. WFIFOW(fd,0)=0xcb;
  7536. WFIFOB(fd,2)=fail;
  7537. WFIFOSET(fd,packet_len_table[0xcb]);
  7538. }
  7539. /*==========================================
  7540. *
  7541. *------------------------------------------
  7542. */
  7543. void clif_parse_CreateChatRoom(int fd,struct map_session_data *sd)
  7544. {
  7545. if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 4){
  7546. chat_createchat(sd,RFIFOW(fd,4),RFIFOB(fd,6),(char*)RFIFOP(fd,7),(char*)RFIFOP(fd,15),RFIFOW(fd,2)-15);
  7547. } else
  7548. clif_skill_fail(sd,1,0,3);
  7549. }
  7550. /*==========================================
  7551. *
  7552. *------------------------------------------
  7553. */
  7554. void clif_parse_ChatAddMember(int fd,struct map_session_data *sd)
  7555. {
  7556. chat_joinchat(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
  7557. }
  7558. /*==========================================
  7559. *
  7560. *------------------------------------------
  7561. */
  7562. void clif_parse_ChatRoomStatusChange(int fd,struct map_session_data *sd)
  7563. {
  7564. chat_changechatstatus(sd,RFIFOW(fd,4),RFIFOB(fd,6),(char*)RFIFOP(fd,7),(char*)RFIFOP(fd,15),RFIFOW(fd,2)-15);
  7565. }
  7566. /*==========================================
  7567. *
  7568. *------------------------------------------
  7569. */
  7570. void clif_parse_ChangeChatOwner(int fd,struct map_session_data *sd)
  7571. {
  7572. chat_changechatowner(sd,(char*)RFIFOP(fd,6));
  7573. }
  7574. /*==========================================
  7575. *
  7576. *------------------------------------------
  7577. */
  7578. void clif_parse_KickFromChat(int fd,struct map_session_data *sd)
  7579. {
  7580. chat_kickchat(sd,(char*)RFIFOP(fd,2));
  7581. }
  7582. /*==========================================
  7583. *
  7584. *------------------------------------------
  7585. */
  7586. void clif_parse_ChatLeave(int fd,struct map_session_data *sd)
  7587. {
  7588. chat_leavechat(sd);
  7589. }
  7590. /*==========================================
  7591. * 取引要請を相手に送る
  7592. *------------------------------------------
  7593. */
  7594. void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
  7595. {
  7596. nullpo_retv(sd);
  7597. if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 1){
  7598. trade_traderequest(sd,RFIFOL(sd->fd,2));
  7599. } else
  7600. clif_skill_fail(sd,1,0,0);
  7601. }
  7602. /*==========================================
  7603. * 取引要請
  7604. *------------------------------------------
  7605. */
  7606. void clif_parse_TradeAck(int fd,struct map_session_data *sd)
  7607. {
  7608. nullpo_retv(sd);
  7609. trade_tradeack(sd,RFIFOB(sd->fd,2));
  7610. }
  7611. /*==========================================
  7612. * アイテム追加
  7613. *------------------------------------------
  7614. */
  7615. void clif_parse_TradeAddItem(int fd,struct map_session_data *sd)
  7616. {
  7617. nullpo_retv(sd);
  7618. trade_tradeadditem(sd,RFIFOW(sd->fd,2),RFIFOL(sd->fd,4));
  7619. }
  7620. /*==========================================
  7621. * アイテム追加完了(ok押し)
  7622. *------------------------------------------
  7623. */
  7624. void clif_parse_TradeOk(int fd,struct map_session_data *sd)
  7625. {
  7626. trade_tradeok(sd);
  7627. }
  7628. /*==========================================
  7629. * 取引キャンセル
  7630. *------------------------------------------
  7631. */
  7632. void clif_parse_TradeCancel(int fd,struct map_session_data *sd)
  7633. {
  7634. trade_tradecancel(sd);
  7635. }
  7636. /*==========================================
  7637. * 取引許諾(trade押し)
  7638. *------------------------------------------
  7639. */
  7640. void clif_parse_TradeCommit(int fd,struct map_session_data *sd)
  7641. {
  7642. trade_tradecommit(sd);
  7643. }
  7644. /*==========================================
  7645. *
  7646. *------------------------------------------
  7647. */
  7648. void clif_parse_StopAttack(int fd,struct map_session_data *sd)
  7649. {
  7650. pc_stopattack(sd);
  7651. }
  7652. /*==========================================
  7653. * カートへアイテムを移す
  7654. *------------------------------------------
  7655. */
  7656. void clif_parse_PutItemToCart(int fd,struct map_session_data *sd)
  7657. {
  7658. nullpo_retv(sd);
  7659. if(sd->npc_id!=0 || sd->vender_id != 0)
  7660. return;
  7661. pc_putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
  7662. }
  7663. /*==========================================
  7664. * カートからアイテムを出す
  7665. *------------------------------------------
  7666. */
  7667. void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd)
  7668. {
  7669. nullpo_retv(sd);
  7670. if(sd->npc_id!=0 || sd->vender_id != 0) return;
  7671. pc_getitemfromcart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
  7672. }
  7673. /*==========================================
  7674. * 付属品(鷹,ペコ,カート)をはずす
  7675. *------------------------------------------
  7676. */
  7677. void clif_parse_RemoveOption(int fd,struct map_session_data *sd)
  7678. {
  7679. if(pc_isriding(sd)) { // jobchange when removing peco [Valaris]
  7680. if(sd->status.class_==13)
  7681. sd->status.class_=sd->view_class=7;
  7682. if(sd->status.class_==21)
  7683. sd->status.class_=sd->view_class=14;
  7684. if(sd->status.class_==4014)
  7685. sd->status.class_=sd->view_class=4008;
  7686. if(sd->status.class_==4022)
  7687. sd->status.class_=sd->view_class=4015;
  7688. }
  7689. pc_setoption(sd,0);
  7690. }
  7691. /*==========================================
  7692. * チェンジカート
  7693. *------------------------------------------
  7694. */
  7695. void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
  7696. {
  7697. pc_setcart(sd,RFIFOW(fd,2));
  7698. }
  7699. /*==========================================
  7700. * ステータスアップ
  7701. *------------------------------------------
  7702. */
  7703. void clif_parse_StatusUp(int fd,struct map_session_data *sd)
  7704. {
  7705. pc_statusup(sd,RFIFOW(fd,2));
  7706. }
  7707. /*==========================================
  7708. * スキルレベルアップ
  7709. *------------------------------------------
  7710. */
  7711. void clif_parse_SkillUp(int fd,struct map_session_data *sd)
  7712. {
  7713. pc_skillup(sd,RFIFOW(fd,2));
  7714. }
  7715. /*==========================================
  7716. * スキル使用(ID指定)
  7717. *------------------------------------------
  7718. */
  7719. void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) {
  7720. int skillnum, skilllv, lv, target_id;
  7721. unsigned int tick = gettick();
  7722. nullpo_retv(sd);
  7723. if (sd->chatID || sd->npc_id != 0 || sd->vender_id != 0)
  7724. return;
  7725. if (USE_PACKET_DB(sd)) {
  7726. skilllv = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  7727. skillnum = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  7728. target_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[2]);
  7729. } else {
  7730. switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  7731. case 6:
  7732. skilllv = RFIFOW(fd,4);
  7733. skillnum = RFIFOW(fd,9);
  7734. target_id = RFIFOL(fd,11);
  7735. break;
  7736. case 7:
  7737. skilllv = RFIFOW(fd,7);
  7738. skillnum = RFIFOW(fd,9);
  7739. target_id = RFIFOL(fd,15);
  7740. break;
  7741. case 8:
  7742. skilllv = RFIFOW(fd,7);
  7743. skillnum = RFIFOW(fd,12);
  7744. target_id = RFIFOL(fd,16);
  7745. break;
  7746. case 9:
  7747. skilllv = RFIFOW(fd,11);
  7748. skillnum = RFIFOW(fd,18);
  7749. target_id = RFIFOL(fd,22);
  7750. break;
  7751. case 10:
  7752. skilllv = RFIFOW(fd,9);
  7753. skillnum = RFIFOW(fd,15);
  7754. target_id = RFIFOL(fd,18);
  7755. break;
  7756. case 11:
  7757. skilllv = RFIFOW(fd,4);
  7758. skillnum = RFIFOW(fd,7);
  7759. target_id = RFIFOL(fd,10);
  7760. break;
  7761. case 12:
  7762. skilllv = RFIFOW(fd,7);
  7763. skillnum = RFIFOW(fd,12);
  7764. target_id = RFIFOL(fd,16);
  7765. break;
  7766. case 13:
  7767. case 14:
  7768. skilllv = RFIFOW(fd,4);
  7769. skillnum = RFIFOW(fd,10);
  7770. target_id = RFIFOL(fd,22);
  7771. break;
  7772. case 15:
  7773. skilllv = RFIFOW(fd,8);
  7774. skillnum = RFIFOW(fd,12);
  7775. target_id = RFIFOL(fd,18);
  7776. break;
  7777. case 16:
  7778. skilllv = RFIFOW(fd,8);
  7779. skillnum = RFIFOW(fd,16);
  7780. target_id = RFIFOL(fd,22);
  7781. break;
  7782. default: // old version by default
  7783. skilllv = RFIFOW(fd,2);
  7784. skillnum = RFIFOW(fd,4);
  7785. target_id = RFIFOL(fd,6);
  7786. break;
  7787. }
  7788. }
  7789. if (skillnotok(skillnum, sd))
  7790. return;
  7791. if (sd->skilltimer != -1) {
  7792. if (skillnum != SA_CASTCANCEL)
  7793. return;
  7794. } else if (DIFF_TICK(tick, sd->canact_tick) < 0 &&
  7795. // allow monk combos to ignore this delay [celest]
  7796. !(sd->sc_count && sd->sc_data[SC_COMBO].timer!=-1 &&
  7797. (skillnum == MO_EXTREMITYFIST ||
  7798. skillnum == MO_CHAINCOMBO ||
  7799. skillnum == MO_COMBOFINISH ||
  7800. skillnum == CH_PALMSTRIKE ||
  7801. skillnum == CH_TIGERFIST ||
  7802. skillnum == CH_CHAINCRUSH))) {
  7803. clif_skill_fail(sd, skillnum, 4, 0);
  7804. return;
  7805. }
  7806. if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) ||
  7807. sd->sc_data[SC_BERSERK].timer != -1 || sd->sc_data[SC_NOCHAT].timer != -1 ||
  7808. sd->sc_data[SC_WEDDING].timer != -1 || sd->view_class == 22)
  7809. return;
  7810. if (sd->invincible_timer != -1)
  7811. pc_delinvincibletimer(sd);
  7812. if (sd->skillitem >= 0 && sd->skillitem == skillnum) {
  7813. if (skilllv != sd->skillitemlv)
  7814. skilllv = sd->skillitemlv;
  7815. skill_use_id(sd, target_id, skillnum, skilllv);
  7816. } else {
  7817. sd->skillitem = sd->skillitemlv = -1;
  7818. if (skillnum == MO_EXTREMITYFIST) {
  7819. if ((sd->sc_data[SC_COMBO].timer == -1 || (sd->sc_data[SC_COMBO].val1 != MO_COMBOFINISH && sd->sc_data[SC_COMBO].val1 != CH_CHAINCRUSH))) {
  7820. if (!sd->state.skill_flag ) {
  7821. sd->state.skill_flag = 1;
  7822. clif_skillinfo(sd, MO_EXTREMITYFIST, 1, -1);
  7823. return;
  7824. } else if (sd->bl.id == target_id) {
  7825. clif_skillinfo(sd, MO_EXTREMITYFIST, 1, -1);
  7826. return;
  7827. }
  7828. }
  7829. }
  7830. if ((lv = pc_checkskill(sd, skillnum)) > 0) {
  7831. if (skilllv > lv)
  7832. skilllv = lv;
  7833. skill_use_id(sd, target_id, skillnum, skilllv);
  7834. if (sd->state.skill_flag)
  7835. sd->state.skill_flag = 0;
  7836. }
  7837. }
  7838. }
  7839. /*==========================================
  7840. * スキル使用(場所指定)
  7841. *------------------------------------------
  7842. */
  7843. void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) {
  7844. int skillnum, skilllv, lv, x, y;
  7845. unsigned int tick = gettick();
  7846. int skillmoreinfo;
  7847. nullpo_retv(sd);
  7848. if (sd->npc_id != 0 || sd->vender_id != 0) return;
  7849. if(sd->chatID) return;
  7850. skillmoreinfo = -1;
  7851. if (USE_PACKET_DB(sd)) {
  7852. skilllv = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  7853. skillnum = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  7854. x = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[2]);
  7855. y = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[3]);
  7856. } else {
  7857. switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  7858. case 6:
  7859. skilllv = RFIFOW(fd,4);
  7860. skillnum = RFIFOW(fd,9);
  7861. x = RFIFOW(fd,11);
  7862. y = RFIFOW(fd,13);
  7863. if (RFIFOW(fd,0) == 0x190)
  7864. skillmoreinfo = 15;
  7865. break;
  7866. case 7:
  7867. skilllv = RFIFOW(fd,7);
  7868. skillnum = RFIFOW(fd,9);
  7869. x = RFIFOW(fd,15);
  7870. y = RFIFOW(fd,17);
  7871. if (RFIFOW(fd,0) == 0x190)
  7872. skillmoreinfo = 19;
  7873. break;
  7874. case 8:
  7875. skilllv = RFIFOW(fd,3);
  7876. skillnum = RFIFOW(fd,6);
  7877. x = RFIFOW(fd,17);
  7878. y = RFIFOW(fd,21);
  7879. if (RFIFOW(fd,0) == 0x0a2)
  7880. skillmoreinfo = 23;
  7881. break;
  7882. case 9:
  7883. skilllv = RFIFOW(fd,5);
  7884. skillnum = RFIFOW(fd,15);
  7885. x = RFIFOW(fd,29);
  7886. y = RFIFOW(fd,38);
  7887. if (RFIFOW(fd,0) == 0x0a2)
  7888. skillmoreinfo = 40;
  7889. break;
  7890. case 10:
  7891. skilllv = RFIFOW(fd,10);
  7892. skillnum = RFIFOW(fd,14);
  7893. x = RFIFOW(fd,18);
  7894. y = RFIFOW(fd,23);
  7895. if (RFIFOW(fd,0) == 0x08c)
  7896. skillmoreinfo = 25;
  7897. break;
  7898. case 11:
  7899. skilllv = RFIFOW(fd,6); // 16? to check.
  7900. skillnum = RFIFOW(fd,20);
  7901. x = RFIFOW(fd,23);
  7902. y = RFIFOW(fd,27);
  7903. if (RFIFOW(fd,0) == 0x08c)
  7904. skillmoreinfo = 29;
  7905. break;
  7906. case 12:
  7907. skilllv = RFIFOW(fd,3); // 2? to check.
  7908. skillnum = RFIFOW(fd,6);
  7909. x = RFIFOW(fd,17);
  7910. y = RFIFOW(fd,21);
  7911. if (RFIFOW(fd,0) == 0x08c)
  7912. skillmoreinfo = 23;
  7913. break;
  7914. case 13:
  7915. case 14:
  7916. skilllv = RFIFOW(fd,6);
  7917. skillnum = RFIFOW(fd,9);
  7918. x = RFIFOW(fd,23);
  7919. y = RFIFOW(fd,26);
  7920. if (RFIFOW(fd,0) == 0x08c)
  7921. skillmoreinfo = 28;
  7922. break;
  7923. case 15:
  7924. skilllv = RFIFOW(fd,4);
  7925. skillnum = RFIFOW(fd,9);
  7926. x = RFIFOW(fd,22);
  7927. y = RFIFOW(fd,28);
  7928. if (RFIFOW(fd,0) == 0x113)
  7929. skillmoreinfo = 30;
  7930. break;
  7931. case 16:
  7932. skilllv = RFIFOW(fd,9);
  7933. skillnum = RFIFOW(fd,18);
  7934. x = RFIFOW(fd,22);
  7935. y = RFIFOW(fd,32);
  7936. if (RFIFOW(fd,0) == 0x07e)
  7937. skillmoreinfo = 34;
  7938. break;
  7939. default: // old version by default
  7940. skilllv = RFIFOW(fd,2);
  7941. skillnum = RFIFOW(fd,4);
  7942. x = RFIFOW(fd,6);
  7943. y = RFIFOW(fd,8);
  7944. if (RFIFOW(fd,0) == 0x190)
  7945. skillmoreinfo = 10;
  7946. break;
  7947. }
  7948. }
  7949. if (skillnotok(skillnum, sd))
  7950. return;
  7951. if (skillmoreinfo != -1) {
  7952. if (pc_issit(sd)) {
  7953. clif_skill_fail(sd, skillnum, 0, 0);
  7954. return;
  7955. }
  7956. memcpy(talkie_mes, RFIFOP(fd,skillmoreinfo), 80);
  7957. }
  7958. if (sd->skilltimer != -1)
  7959. return;
  7960. else if (DIFF_TICK(tick, sd->canact_tick) < 0 &&
  7961. // allow monk combos to ignore this delay [celest]
  7962. !(sd->sc_count && sd->sc_data[SC_COMBO].timer!=-1 &&
  7963. (skillnum == MO_EXTREMITYFIST ||
  7964. skillnum == MO_CHAINCOMBO ||
  7965. skillnum == MO_COMBOFINISH ||
  7966. skillnum == CH_PALMSTRIKE ||
  7967. skillnum == CH_TIGERFIST ||
  7968. skillnum == CH_CHAINCRUSH))) {
  7969. clif_skill_fail(sd, skillnum, 4, 0);
  7970. return;
  7971. }
  7972. if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) ||
  7973. sd->sc_data[SC_BERSERK].timer != -1 || sd->sc_data[SC_NOCHAT].timer != -1 ||
  7974. sd->sc_data[SC_WEDDING].timer != -1 || sd->view_class == 22)
  7975. return;
  7976. if (sd->invincible_timer != -1)
  7977. pc_delinvincibletimer(sd);
  7978. if (sd->skillitem >= 0 && sd->skillitem == skillnum) {
  7979. if (skilllv != sd->skillitemlv)
  7980. skilllv = sd->skillitemlv;
  7981. skill_use_pos(sd, x, y, skillnum, skilllv);
  7982. } else {
  7983. sd->skillitem = sd->skillitemlv = -1;
  7984. if ((lv = pc_checkskill(sd, skillnum)) > 0) {
  7985. if (skilllv > lv)
  7986. skilllv = lv;
  7987. skill_use_pos(sd, x, y, skillnum,skilllv);
  7988. }
  7989. }
  7990. }
  7991. /*==========================================
  7992. * スキル使用(map指定)
  7993. *------------------------------------------
  7994. */
  7995. void clif_parse_UseSkillMap(int fd,struct map_session_data *sd)
  7996. {
  7997. nullpo_retv(sd);
  7998. if(sd->chatID) return;
  7999. if (sd->npc_id!=0 || sd->vender_id != 0 || (sd->sc_data &&
  8000. (sd->sc_data[SC_TRICKDEAD].timer != -1 ||
  8001. sd->sc_data[SC_BERSERK].timer!=-1 ||
  8002. sd->sc_data[SC_NOCHAT].timer!=-1 ||
  8003. sd->sc_data[SC_WEDDING].timer!=-1 ||
  8004. sd->view_class==22)))
  8005. return;
  8006. if(sd->invincible_timer != -1)
  8007. pc_delinvincibletimer(sd);
  8008. skill_castend_map(sd,RFIFOW(fd,2),(char*)RFIFOP(fd,4));
  8009. }
  8010. /*==========================================
  8011. * メモ要求
  8012. *------------------------------------------
  8013. */
  8014. void clif_parse_RequestMemo(int fd,struct map_session_data *sd)
  8015. {
  8016. pc_memo(sd,-1);
  8017. }
  8018. /*==========================================
  8019. * アイテム合成
  8020. *------------------------------------------
  8021. */
  8022. void clif_parse_ProduceMix(int fd,struct map_session_data *sd)
  8023. {
  8024. nullpo_retv(sd);
  8025. sd->state.produce_flag = 0;
  8026. skill_produce_mix(sd,RFIFOW(fd,2),RFIFOW(fd,4),RFIFOW(fd,6),RFIFOW(fd,8));
  8027. }
  8028. /*==========================================
  8029. *
  8030. *------------------------------------------
  8031. */
  8032. void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
  8033. {
  8034. nullpo_retv(sd);
  8035. sd->npc_menu=RFIFOB(fd,6);
  8036. npc_scriptcont(sd,RFIFOL(fd,2));
  8037. }
  8038. /*==========================================
  8039. *
  8040. *------------------------------------------
  8041. */
  8042. void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
  8043. {
  8044. npc_scriptcont(sd,RFIFOL(fd,2));
  8045. }
  8046. /*==========================================
  8047. *
  8048. *------------------------------------------
  8049. */
  8050. void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
  8051. {
  8052. nullpo_retv(sd);
  8053. #define RFIFOL_(fd,pos) (*(int*)(session[fd]->rdata+session[fd]->rdata_pos+(pos)))
  8054. //Input Value overflow Exploit FIX
  8055. sd->npc_amount=RFIFOL_(fd,6); //fixed by Lupus. npc_amount is (int) but was RFIFOL changing it to (unsigned int)
  8056. #undef RFIFOL_
  8057. npc_scriptcont(sd,RFIFOL(fd,2));
  8058. }
  8059. /*==========================================
  8060. *
  8061. *------------------------------------------
  8062. */
  8063. void clif_parse_NpcStringInput(int fd,struct map_session_data *sd)
  8064. {
  8065. nullpo_retv(sd);
  8066. if(RFIFOW(fd,2)-7 >= sizeof(sd->npc_str)){
  8067. printf("clif: input string too long !\n");
  8068. memcpy(sd->npc_str,RFIFOP(fd,8),sizeof(sd->npc_str));
  8069. sd->npc_str[sizeof(sd->npc_str)-1]=0;
  8070. } else
  8071. strcpy(sd->npc_str,(char*)RFIFOP(fd,8));
  8072. npc_scriptcont(sd,RFIFOL(fd,4));
  8073. }
  8074. /*==========================================
  8075. *
  8076. *------------------------------------------
  8077. */
  8078. void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd)
  8079. {
  8080. npc_scriptcont(sd,RFIFOL(fd,2));
  8081. }
  8082. /*==========================================
  8083. * アイテム鑑定
  8084. *------------------------------------------
  8085. */
  8086. void clif_parse_ItemIdentify(int fd,struct map_session_data *sd)
  8087. {
  8088. pc_item_identify(sd,RFIFOW(fd,2)-2);
  8089. }
  8090. /*==========================================
  8091. * 矢作成
  8092. *------------------------------------------
  8093. */
  8094. void clif_parse_SelectArrow(int fd,struct map_session_data *sd)
  8095. {
  8096. nullpo_retv(sd);
  8097. sd->state.make_arrow_flag = 0;
  8098. skill_arrow_create(sd,RFIFOW(fd,2));
  8099. }
  8100. /*==========================================
  8101. * オートスペル受信
  8102. *------------------------------------------
  8103. */
  8104. void clif_parse_AutoSpell(int fd,struct map_session_data *sd)
  8105. {
  8106. skill_autospell(sd,RFIFOW(fd,2));
  8107. }
  8108. /*==========================================
  8109. * カード使用
  8110. *------------------------------------------
  8111. */
  8112. void clif_parse_UseCard(int fd,struct map_session_data *sd)
  8113. {
  8114. clif_use_card(sd,RFIFOW(fd,2)-2);
  8115. }
  8116. /*==========================================
  8117. * カード挿入装備選択
  8118. *------------------------------------------
  8119. */
  8120. void clif_parse_InsertCard(int fd,struct map_session_data *sd)
  8121. {
  8122. pc_insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2);
  8123. }
  8124. /*==========================================
  8125. * 0193 キャラID名前引き
  8126. *------------------------------------------
  8127. */
  8128. void clif_parse_SolveCharName(int fd, struct map_session_data *sd) {
  8129. int char_id;
  8130. if (USE_PACKET_DB(sd)) {
  8131. char_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  8132. } else {
  8133. switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  8134. case 8:
  8135. char_id = RFIFOL(fd,8);
  8136. break;
  8137. case 9:
  8138. char_id = RFIFOL(fd,7);
  8139. break;
  8140. case 10:
  8141. char_id = RFIFOL(fd,10);
  8142. break;
  8143. case 11:
  8144. char_id = RFIFOL(fd,6);
  8145. break;
  8146. case 12:
  8147. char_id = RFIFOL(fd,8);
  8148. break;
  8149. case 13:
  8150. case 14:
  8151. char_id = RFIFOL(fd,12);
  8152. break;
  8153. case 15:
  8154. char_id = RFIFOL(fd,10);
  8155. break;
  8156. case 16:
  8157. char_id = RFIFOL(fd,7);
  8158. break;
  8159. default: // old version by default (+ packet version 6 and 7)
  8160. char_id = RFIFOL(fd,2);
  8161. break;
  8162. }
  8163. }
  8164. clif_solved_charname(sd, char_id);
  8165. }
  8166. /*==========================================
  8167. * 0197 /resetskill /resetstate
  8168. *------------------------------------------
  8169. */
  8170. void clif_parse_ResetChar(int fd, struct map_session_data *sd) {
  8171. nullpo_retv(sd);
  8172. if (battle_config.atc_gmonly == 0 || pc_isGM(sd)) {
  8173. switch(RFIFOW(fd,2)){
  8174. case 0:
  8175. if (pc_isGM(sd) >= get_atcommand_level(AtCommand_ResetState))
  8176. pc_resetstate(sd);
  8177. break;
  8178. case 1:
  8179. if (pc_isGM(sd) >= get_atcommand_level(AtCommand_ResetState))
  8180. pc_resetskill(sd);
  8181. break;
  8182. }
  8183. }
  8184. }
  8185. /*==========================================
  8186. * 019c /lb等
  8187. *------------------------------------------
  8188. */
  8189. void clif_parse_LGMmessage(int fd, struct map_session_data *sd) {
  8190. unsigned char buf[512];
  8191. nullpo_retv(sd);
  8192. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  8193. (pc_isGM(sd) >= get_atcommand_level(AtCommand_LocalBroadcast))) {
  8194. WBUFW(buf,0) = 0x9a;
  8195. WBUFW(buf,2) = RFIFOW(fd,2);
  8196. memcpy(WBUFP(buf,4), RFIFOP(fd,4), RFIFOW(fd,2) - 4);
  8197. clif_send(buf, RFIFOW(fd,2), &sd->bl, ALL_SAMEMAP);
  8198. }
  8199. }
  8200. /*==========================================
  8201. * カプラ倉庫へ入れる
  8202. *------------------------------------------
  8203. */
  8204. void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) {
  8205. int item_index, item_amount;
  8206. nullpo_retv(sd);
  8207. if (sd->npc_id != 0 || sd->vender_id != 0)
  8208. return;
  8209. if (USE_PACKET_DB(sd)) {
  8210. item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2;
  8211. item_amount = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  8212. } else {
  8213. switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  8214. case 8:
  8215. item_index = RFIFOW(fd,5) - 2;
  8216. item_amount = RFIFOL(fd,12);
  8217. break;
  8218. case 9:
  8219. item_index = RFIFOW(fd,5) - 2;
  8220. item_amount = RFIFOL(fd,19);
  8221. break;
  8222. case 10:
  8223. item_index = RFIFOW(fd,3) - 2;
  8224. item_amount = RFIFOL(fd,15);
  8225. break;
  8226. case 11:
  8227. item_index = RFIFOW(fd,6) - 2;
  8228. item_amount = RFIFOL(fd,21);
  8229. break;
  8230. case 12:
  8231. item_index = RFIFOW(fd,5) - 2;
  8232. item_amount = RFIFOL(fd,12);
  8233. break;
  8234. case 13:
  8235. case 14:
  8236. item_index = RFIFOW(fd,6) - 2;
  8237. item_amount = RFIFOL(fd,9);
  8238. break;
  8239. case 15:
  8240. item_index = RFIFOW(fd,4) - 2;
  8241. item_amount = RFIFOL(fd,10);
  8242. break;
  8243. case 16:
  8244. item_index = RFIFOW(fd,10) - 2;
  8245. item_amount = RFIFOL(fd,16);
  8246. break;
  8247. default: // old version by default (+ packet version 6 and 7)
  8248. item_index = RFIFOW(fd,2) - 2;
  8249. item_amount = RFIFOL(fd,4);
  8250. break;
  8251. }
  8252. }
  8253. if (item_index < 0 || item_index >= MAX_INVENTORY)
  8254. return;
  8255. if(itemdb_isdropable(sd->status.inventory[item_index].nameid) == 0)
  8256. return;
  8257. if (sd->state.storage_flag)
  8258. storage_guild_storageadd(sd, item_index, item_amount);
  8259. else
  8260. storage_storageadd(sd, item_index, item_amount);
  8261. }
  8262. /*==========================================
  8263. * カプラ倉庫から出す
  8264. *------------------------------------------
  8265. */
  8266. void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd) {
  8267. int item_index, item_amount;
  8268. nullpo_retv(sd);
  8269. if (USE_PACKET_DB(sd)) {
  8270. item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-1;
  8271. item_amount = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  8272. } else {
  8273. switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
  8274. case 8:
  8275. item_index = RFIFOW(fd,10) - 1;
  8276. item_amount = RFIFOL(fd,22);
  8277. break;
  8278. case 9:
  8279. item_index = RFIFOW(fd,11) - 1;
  8280. item_amount = RFIFOL(fd,22);
  8281. break;
  8282. case 10:
  8283. item_index = RFIFOW(fd,3) - 1;
  8284. item_amount = RFIFOL(fd,13);
  8285. break;
  8286. case 11:
  8287. item_index = RFIFOW(fd,4) - 1;
  8288. item_amount = RFIFOL(fd,8);
  8289. break;
  8290. case 12:
  8291. item_index = RFIFOW(fd,10) - 1;
  8292. item_amount = RFIFOL(fd,22);
  8293. break;
  8294. case 13:
  8295. case 14:
  8296. item_index = RFIFOW(fd,12) - 1;
  8297. item_amount = RFIFOL(fd,18);
  8298. break;
  8299. case 15:
  8300. item_index = RFIFOW(fd,4) - 1;
  8301. item_amount = RFIFOL(fd,17);
  8302. break;
  8303. case 16:
  8304. item_index = RFIFOW(fd,11) - 1;
  8305. item_amount = RFIFOL(fd,17);
  8306. break;
  8307. default: // old version by default (+ packet version 6 and 7)
  8308. item_index = RFIFOW(fd,2) - 1;
  8309. item_amount = RFIFOL(fd,4);
  8310. break;
  8311. }
  8312. }
  8313. if (sd->npc_id != 0 || sd->vender_id != 0)
  8314. return;
  8315. if (sd->state.storage_flag)
  8316. storage_guild_storageget(sd, item_index, item_amount);
  8317. else
  8318. storage_storageget(sd, item_index, item_amount);
  8319. }
  8320. /*==========================================
  8321. * カプラ倉庫へカートから入れる
  8322. *------------------------------------------
  8323. */
  8324. void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd) {
  8325. nullpo_retv(sd);
  8326. if (sd->npc_id != 0 || sd->vender_id != 0 || sd->trade_partner != 0)
  8327. return;
  8328. if (sd->state.storage_flag)
  8329. storage_guild_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
  8330. else
  8331. storage_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
  8332. }
  8333. /*==========================================
  8334. * カプラ倉庫から出す
  8335. *------------------------------------------
  8336. */
  8337. void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd) {
  8338. nullpo_retv(sd);
  8339. if (sd->npc_id != 0 || sd->vender_id != 0)
  8340. return;
  8341. if (sd->state.storage_flag)
  8342. storage_guild_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
  8343. else
  8344. storage_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
  8345. }
  8346. /*==========================================
  8347. * カプラ倉庫を閉じる
  8348. *------------------------------------------
  8349. */
  8350. void clif_parse_CloseKafra(int fd, struct map_session_data *sd) {
  8351. nullpo_retv(sd);
  8352. if (sd->state.storage_flag)
  8353. storage_guild_storageclose(sd);
  8354. else
  8355. storage_storageclose(sd);
  8356. }
  8357. /*==========================================
  8358. * パーティを作る
  8359. *------------------------------------------
  8360. */
  8361. void clif_parse_CreateParty(int fd, struct map_session_data *sd) {
  8362. if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7) {
  8363. party_create(sd,(char*)RFIFOP(fd,2));
  8364. } else
  8365. clif_skill_fail(sd,1,0,4);
  8366. }
  8367. /*==========================================
  8368. * パーティを作る
  8369. *------------------------------------------
  8370. */
  8371. void clif_parse_CreateParty2(int fd, struct map_session_data *sd) {
  8372. if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7){
  8373. party_create(sd,(char*)RFIFOP(fd,2));
  8374. } else
  8375. clif_skill_fail(sd,1,0,4);
  8376. }
  8377. /*==========================================
  8378. * パーティに勧誘
  8379. *------------------------------------------
  8380. */
  8381. void clif_parse_PartyInvite(int fd, struct map_session_data *sd) {
  8382. party_invite(sd, RFIFOL(fd,2));
  8383. }
  8384. /*==========================================
  8385. * パーティ勧誘返答
  8386. *------------------------------------------
  8387. */
  8388. void clif_parse_ReplyPartyInvite(int fd,struct map_session_data *sd) {
  8389. if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 5){
  8390. party_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6));
  8391. } else {
  8392. party_reply_invite(sd,RFIFOL(fd,2),-1);
  8393. clif_skill_fail(sd,1,0,4);
  8394. }
  8395. }
  8396. /*==========================================
  8397. * パーティ脱退要求
  8398. *------------------------------------------
  8399. */
  8400. void clif_parse_LeaveParty(int fd, struct map_session_data *sd) {
  8401. party_leave(sd);
  8402. }
  8403. /*==========================================
  8404. * パーティ除名要求
  8405. *------------------------------------------
  8406. */
  8407. void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) {
  8408. party_removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
  8409. }
  8410. /*==========================================
  8411. * パーティ設定変更要求
  8412. *------------------------------------------
  8413. */
  8414. void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) {
  8415. party_changeoption(sd, RFIFOW(fd,2), RFIFOW(fd,4));
  8416. }
  8417. /*==========================================
  8418. * パーティメッセージ送信要求
  8419. *------------------------------------------
  8420. */
  8421. void clif_parse_PartyMessage(int fd, struct map_session_data *sd) {
  8422. nullpo_retv(sd);
  8423. if (is_charcommand(fd, sd, (char*)RFIFOP(fd,4), 0) != CharCommand_None)
  8424. return;
  8425. if (is_atcommand(fd, sd, (char*)RFIFOP(fd,4), 0) != AtCommand_None)
  8426. return;
  8427. if(sd->sc_data &&
  8428. (sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク時は会話も不可
  8429. sd->sc_data[SC_NOCHAT].timer!=-1)) //チャット禁止
  8430. return;
  8431. party_send_message(sd, (char*)RFIFOP(fd,4), RFIFOW(fd,2)-4);
  8432. }
  8433. /*==========================================
  8434. * 露店閉鎖
  8435. *------------------------------------------
  8436. */
  8437. void clif_parse_CloseVending(int fd, struct map_session_data *sd) {
  8438. vending_closevending(sd);
  8439. }
  8440. /*==========================================
  8441. * 露店アイテムリスト要求
  8442. *------------------------------------------
  8443. */
  8444. void clif_parse_VendingListReq(int fd, struct map_session_data *sd) {
  8445. nullpo_retv(sd);
  8446. vending_vendinglistreq(sd,RFIFOL(fd,2));
  8447. if(sd->npc_id)
  8448. npc_event_dequeue(sd);
  8449. }
  8450. /*==========================================
  8451. * 露店アイテム購入
  8452. *------------------------------------------
  8453. */
  8454. void clif_parse_PurchaseReq(int fd, struct map_session_data *sd) {
  8455. vending_purchasereq(sd, RFIFOW(fd,2), RFIFOL(fd,4), RFIFOP(fd,8));
  8456. }
  8457. /*==========================================
  8458. * 露店開設
  8459. *------------------------------------------
  8460. */
  8461. void clif_parse_OpenVending(int fd,struct map_session_data *sd) {
  8462. vending_openvending(sd, RFIFOW(fd,2), (char*)RFIFOP(fd,4), RFIFOB(fd,84), RFIFOP(fd,85));
  8463. }
  8464. /*==========================================
  8465. * /monster /item rewriten by [Yor]
  8466. *------------------------------------------
  8467. */
  8468. void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) {
  8469. char monster_item_name[25];
  8470. nullpo_retv(sd);
  8471. memset(monster_item_name, '\0', sizeof(monster_item_name));
  8472. if (battle_config.atc_gmonly == 0 || pc_isGM(sd)) {
  8473. memcpy(monster_item_name, RFIFOP(fd,2), 24);
  8474. if (mobdb_searchname(monster_item_name) != 0) {
  8475. if (pc_isGM(sd) >= get_atcommand_level(AtCommand_Monster))
  8476. atcommand_spawn(fd, sd, "@spawn", monster_item_name); // as @spawn
  8477. } else if (itemdb_searchname(monster_item_name) != NULL) {
  8478. if (pc_isGM(sd) >= get_atcommand_level(AtCommand_Item))
  8479. atcommand_item(fd, sd, "@item", monster_item_name); // as @item
  8480. }
  8481. }
  8482. }
  8483. /*==========================================
  8484. * ギルドを作る
  8485. *------------------------------------------
  8486. */
  8487. void clif_parse_CreateGuild(int fd,struct map_session_data *sd) {
  8488. guild_create(sd, (char*)RFIFOP(fd,6));
  8489. }
  8490. /*==========================================
  8491. * ギルドマスターかどうか確認
  8492. *------------------------------------------
  8493. */
  8494. void clif_parse_GuildCheckMaster(int fd, struct map_session_data *sd) {
  8495. clif_guild_masterormember(sd);
  8496. }
  8497. /*==========================================
  8498. * ギルド情報要求
  8499. *------------------------------------------
  8500. */
  8501. void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd) {
  8502. switch(RFIFOL(fd,2)){
  8503. case 0: // ギルド基本情報、同盟敵対情報
  8504. clif_guild_basicinfo(sd);
  8505. clif_guild_allianceinfo(sd);
  8506. break;
  8507. case 1: // メンバーリスト、役職名リスト
  8508. clif_guild_positionnamelist(sd);
  8509. clif_guild_memberlist(sd);
  8510. break;
  8511. case 2: // 役職名リスト、役職情報リスト
  8512. clif_guild_positionnamelist(sd);
  8513. clif_guild_positioninfolist(sd);
  8514. break;
  8515. case 3: // スキルリスト
  8516. clif_guild_skillinfo(sd);
  8517. break;
  8518. case 4: // 追放リスト
  8519. clif_guild_explusionlist(sd);
  8520. break;
  8521. default:
  8522. if (battle_config.error_log)
  8523. printf("clif: guild request info: unknown type %d\n", RFIFOL(fd,2));
  8524. break;
  8525. }
  8526. }
  8527. /*==========================================
  8528. * ギルド役職変更
  8529. *------------------------------------------
  8530. */
  8531. void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) {
  8532. int i;
  8533. for(i = 4; i < RFIFOW(fd,2); i += 40 ){
  8534. guild_change_position(sd, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), (char*)RFIFOP(fd,i+16));
  8535. }
  8536. }
  8537. /*==========================================
  8538. * ギルドメンバ役職変更
  8539. *------------------------------------------
  8540. */
  8541. void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd) {
  8542. int i;
  8543. nullpo_retv(sd);
  8544. for(i=4;i<RFIFOW(fd,2);i+=12){
  8545. guild_change_memberposition(sd->status.guild_id,
  8546. RFIFOL(fd,i),RFIFOL(fd,i+4),RFIFOL(fd,i+8));
  8547. }
  8548. }
  8549. /*==========================================
  8550. * ギルドエンブレム要求
  8551. *------------------------------------------
  8552. */
  8553. void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd) {
  8554. struct guild *g=guild_search(RFIFOL(fd,2));
  8555. if(g!=NULL)
  8556. clif_guild_emblem(sd,g);
  8557. }
  8558. /*==========================================
  8559. * ギルドエンブレム変更
  8560. *------------------------------------------
  8561. */
  8562. void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd) {
  8563. guild_change_emblem(sd,RFIFOW(fd,2)-4,(char*)RFIFOP(fd,4));
  8564. }
  8565. /*==========================================
  8566. * ギルド告知変更
  8567. *------------------------------------------
  8568. */
  8569. void clif_parse_GuildChangeNotice(int fd,struct map_session_data *sd) {
  8570. guild_change_notice(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6),(char*)RFIFOP(fd,66));
  8571. }
  8572. /*==========================================
  8573. * ギルド勧誘
  8574. *------------------------------------------
  8575. */
  8576. void clif_parse_GuildInvite(int fd,struct map_session_data *sd) {
  8577. guild_invite(sd,RFIFOL(fd,2));
  8578. }
  8579. /*==========================================
  8580. * ギルド勧誘返信
  8581. *------------------------------------------
  8582. */
  8583. void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd) {
  8584. guild_reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6));
  8585. }
  8586. /*==========================================
  8587. * ギルド脱退
  8588. *------------------------------------------
  8589. */
  8590. void clif_parse_GuildLeave(int fd,struct map_session_data *sd) {
  8591. guild_leave(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
  8592. }
  8593. /*==========================================
  8594. * ギルド追放
  8595. *------------------------------------------
  8596. */
  8597. void clif_parse_GuildExplusion(int fd,struct map_session_data *sd) {
  8598. guild_explusion(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
  8599. }
  8600. /*==========================================
  8601. * ギルド会話
  8602. *------------------------------------------
  8603. */
  8604. void clif_parse_GuildMessage(int fd,struct map_session_data *sd) {
  8605. nullpo_retv(sd);
  8606. if (is_charcommand(fd, sd, (char*)RFIFOP(fd, 4), 0) != CharCommand_None)
  8607. return;
  8608. if (is_atcommand(fd, sd, (char*)RFIFOP(fd, 4), 0) != AtCommand_None)
  8609. return;
  8610. if(sd->sc_data &&
  8611. (sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク時は会話も不可
  8612. sd->sc_data[SC_NOCHAT].timer!=-1)) //チャット禁止
  8613. return;
  8614. guild_send_message(sd, (char*)RFIFOP(fd,4), RFIFOW(fd,2)-4);
  8615. }
  8616. /*==========================================
  8617. * ギルド同盟要求
  8618. *------------------------------------------
  8619. */
  8620. void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) {
  8621. guild_reqalliance(sd,RFIFOL(fd,2));
  8622. }
  8623. /*==========================================
  8624. * ギルド同盟要求返信
  8625. *------------------------------------------
  8626. */
  8627. void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd) {
  8628. guild_reply_reqalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
  8629. }
  8630. /*==========================================
  8631. * ギルド関係解消
  8632. *------------------------------------------
  8633. */
  8634. void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) {
  8635. guild_delalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
  8636. }
  8637. /*==========================================
  8638. * ギルド敵対
  8639. *------------------------------------------
  8640. */
  8641. void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) {
  8642. guild_opposition(sd,RFIFOL(fd,2));
  8643. }
  8644. /*==========================================
  8645. * ギルド解散
  8646. *------------------------------------------
  8647. */
  8648. void clif_parse_GuildBreak(int fd, struct map_session_data *sd) {
  8649. guild_break(sd,(char*)RFIFOP(fd,2));
  8650. }
  8651. // pet
  8652. void clif_parse_PetMenu(int fd, struct map_session_data *sd) {
  8653. pet_menu(sd,RFIFOB(fd,2));
  8654. }
  8655. void clif_parse_CatchPet(int fd, struct map_session_data *sd) {
  8656. pet_catch_process2(sd,RFIFOL(fd,2));
  8657. }
  8658. void clif_parse_SelectEgg(int fd, struct map_session_data *sd) {
  8659. pet_select_egg(sd,RFIFOW(fd,2)-2);
  8660. }
  8661. void clif_parse_SendEmotion(int fd, struct map_session_data *sd) {
  8662. nullpo_retv(sd);
  8663. if(sd->pd)
  8664. clif_pet_emotion(sd->pd,RFIFOL(fd,2));
  8665. }
  8666. void clif_parse_ChangePetName(int fd, struct map_session_data *sd) {
  8667. pet_change_name(sd,(char*)RFIFOP(fd,2));
  8668. }
  8669. // Kick (right click menu for GM "(name) force to quit")
  8670. void clif_parse_GMKick(int fd, struct map_session_data *sd) {
  8671. struct block_list *target;
  8672. int tid = RFIFOL(fd,2);
  8673. nullpo_retv(sd);
  8674. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  8675. (pc_isGM(sd) >= get_atcommand_level(AtCommand_Kick))) {
  8676. target = map_id2bl(tid);
  8677. if (target) {
  8678. if (target->type == BL_PC) {
  8679. struct map_session_data *tsd = (struct map_session_data *)target;
  8680. if (pc_isGM(sd) > pc_isGM(tsd))
  8681. clif_GM_kick(sd, tsd, 1);
  8682. else
  8683. clif_GM_kickack(sd, 0);
  8684. } else if (target->type == BL_MOB) {
  8685. struct mob_data *md = (struct mob_data *)target;
  8686. sd->state.attack_type = 0;
  8687. mob_damage(&sd->bl, md, md->hp, 2);
  8688. } else
  8689. clif_GM_kickack(sd, 0);
  8690. } else
  8691. clif_GM_kickack(sd, 0);
  8692. }
  8693. }
  8694. /*==========================================
  8695. * /shift
  8696. *------------------------------------------
  8697. */
  8698. void clif_parse_Shift(int fd, struct map_session_data *sd) { // Rewriten by [Yor]
  8699. char player_name[25];
  8700. nullpo_retv(sd);
  8701. memset(player_name, '\0', sizeof(player_name));
  8702. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  8703. (pc_isGM(sd) >= get_atcommand_level(AtCommand_JumpTo))) {
  8704. memcpy(player_name, RFIFOP(fd,2), 24);
  8705. atcommand_jumpto(fd, sd, "@jumpto", player_name); // as @jumpto
  8706. }
  8707. return;
  8708. }
  8709. /*==========================================
  8710. * /recall
  8711. *------------------------------------------
  8712. */
  8713. void clif_parse_Recall(int fd, struct map_session_data *sd) { // Added by RoVeRT
  8714. char player_name[25];
  8715. nullpo_retv(sd);
  8716. memset(player_name, '\0', sizeof(player_name));
  8717. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  8718. (pc_isGM(sd) >= get_atcommand_level(AtCommand_Recall))) {
  8719. memcpy(player_name, RFIFOP(fd,2), 24);
  8720. atcommand_recall(fd, sd, "@recall", player_name); // as @recall
  8721. }
  8722. return;
  8723. }
  8724. void clif_parse_GMHide(int fd, struct map_session_data *sd) { // Modified by [Yor]
  8725. nullpo_retv(sd);
  8726. //printf("%2x %2x %2x\n", RFIFOW(fd,0), RFIFOW(fd,2), RFIFOW(fd,4)); // R 019d <Option_value>.2B <flag>.2B
  8727. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  8728. (pc_isGM(sd) >= get_atcommand_level(AtCommand_Hide))) {
  8729. if (sd->status.option & OPTION_HIDE) { // OPTION_HIDE = 0x40
  8730. sd->status.option &= ~OPTION_HIDE; // OPTION_HIDE = 0x40
  8731. clif_displaymessage(fd, "Invisible: Off.");
  8732. } else {
  8733. sd->status.option |= OPTION_HIDE; // OPTION_HIDE = 0x40
  8734. clif_displaymessage(fd, "Invisible: On.");
  8735. }
  8736. clif_changeoption(&sd->bl);
  8737. }
  8738. }
  8739. /*==========================================
  8740. * GMによるチャット禁止時間付与
  8741. *------------------------------------------
  8742. */
  8743. void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd)
  8744. {
  8745. int tid = RFIFOL(fd,2);
  8746. int type = RFIFOB(fd,6);
  8747. int limit = RFIFOW(fd,7);
  8748. struct block_list *bl = map_id2bl(tid);
  8749. struct map_session_data *dstsd;
  8750. int dstfd;
  8751. nullpo_retv(sd);
  8752. if(!battle_config.muting_players) {
  8753. clif_displaymessage(fd, "Muting is disabled.");
  8754. return;
  8755. }
  8756. if(type == 0)
  8757. limit = 0 - limit;
  8758. if(bl->type == BL_PC && (dstsd =(struct map_session_data *)bl)){
  8759. if((tid == bl->id && type == 2 && !pc_isGM(sd)) || (pc_isGM(sd) > pc_isGM(dstsd)) ){
  8760. dstfd = dstsd->fd;
  8761. WFIFOW(dstfd,0)=0x14b;
  8762. WFIFOB(dstfd,2)=(type==2)?1:type;
  8763. memcpy(WFIFOP(dstfd,3),sd->status.name,24);
  8764. WFIFOSET(dstfd,packet_len_table[0x14b]);
  8765. dstsd->status.manner -= limit;
  8766. if(dstsd->status.manner < 0)
  8767. skill_status_change_start(bl,SC_NOCHAT,0,0,0,0,0,0);
  8768. else{
  8769. dstsd->status.manner = 0;
  8770. skill_status_change_end(bl,SC_NOCHAT,-1);
  8771. }
  8772. printf("name:%s type:%d limit:%d manner:%d\n",dstsd->status.name,type,limit,dstsd->status.manner);
  8773. }
  8774. }
  8775. return;
  8776. }
  8777. /*==========================================
  8778. * GMによるチャット禁止時間参照(?)
  8779. *------------------------------------------
  8780. */
  8781. void clif_parse_GMReqNoChatCount(int fd, struct map_session_data *sd)
  8782. {
  8783. int tid = RFIFOL(fd,2);
  8784. WFIFOW(fd,0) = 0x1e0;
  8785. WFIFOL(fd,2) = tid;
  8786. sprintf((char*)WFIFOP(fd,6),"%d",tid);
  8787. // memcpy(WFIFOP(fd,6), "TESTNAME", 24);
  8788. WFIFOSET(fd, packet_len_table[0x1e0]);
  8789. return;
  8790. }
  8791. void clif_parse_PMIgnore(int fd, struct map_session_data *sd) { // Rewritten by [Yor]
  8792. char output[512];
  8793. char *nick; // S 00cf <nick>.24B <type>.B: 00 (/ex nick) deny speech from nick, 01 (/in nick) allow speech from nick
  8794. int i, pos;
  8795. memset(output, '\0', sizeof(output));
  8796. nick = (char*)RFIFOP(fd,2); // speed up
  8797. RFIFOB(fd,25) = '\0'; // to be sure that the player name have at maximum 23 characters
  8798. //printf("Ignore: char '%s' state: %d\n", nick, RFIFOB(fd,26));
  8799. WFIFOW(fd,0) = 0x0d1; // R 00d1 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
  8800. WFIFOB(fd,2) = RFIFOB(fd,26);
  8801. // do nothing only if nick can not exist
  8802. if (strlen(nick) < 4) {
  8803. WFIFOB(fd,3) = 1; // fail
  8804. WFIFOSET(fd, packet_len_table[0x0d1]);
  8805. if (RFIFOB(fd,26) == 0) // type
  8806. clif_wis_message(fd, wisp_server_name, "It's impossible to block this player.", strlen("It's impossible to block this player.") + 1);
  8807. else
  8808. clif_wis_message(fd, wisp_server_name, "It's impossible to unblock this player.", strlen("It's impossible to unblock this player.") + 1);
  8809. return;
  8810. // name can exist
  8811. } else {
  8812. // deny action (we add nick only if it's not already exist
  8813. if (RFIFOB(fd,26) == 0) { // type
  8814. pos = -1;
  8815. for(i = 0; i < MAX_IGNORE_LIST; i++) {
  8816. if (strcmp(sd->ignore[i].name, nick) == 0) {
  8817. WFIFOB(fd,3) = 1; // fail
  8818. WFIFOSET(fd, packet_len_table[0x0d1]);
  8819. clif_wis_message(fd, wisp_server_name, "This player is already blocked.", strlen("This player is already blocked.") + 1);
  8820. if (strcmp(wisp_server_name, nick) == 0) { // to found possible bot users who automaticaly ignore people.
  8821. 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);
  8822. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output, strlen(output) + 1);
  8823. }
  8824. return;
  8825. } else if (pos == -1 && sd->ignore[i].name[0] == '\0')
  8826. pos = i;
  8827. }
  8828. // if a position is found and name not found, we add it in the list
  8829. if (pos != -1) {
  8830. memcpy(sd->ignore[pos].name, nick, 24);
  8831. WFIFOB(fd,3) = 0; // success
  8832. WFIFOSET(fd, packet_len_table[0x0d1]);
  8833. if (strcmp(wisp_server_name, nick) == 0) { // to found possible bot users who automaticaly ignore people.
  8834. 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);
  8835. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output, strlen(output) + 1);
  8836. // send something to be inform and force bot to ignore twice... If GM receiving block + block again, it's a bot :)
  8837. 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);
  8838. }
  8839. } else {
  8840. WFIFOB(fd,3) = 1; // fail
  8841. WFIFOSET(fd, packet_len_table[0x0d1]);
  8842. clif_wis_message(fd, wisp_server_name, "You can not block more people.", strlen("You can not block more people.") + 1);
  8843. if (strcmp(wisp_server_name, nick) == 0) { // to found possible bot users who automaticaly ignore people.
  8844. 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);
  8845. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output, strlen(output) + 1);
  8846. }
  8847. }
  8848. // allow action (we remove all same nicks if they exist)
  8849. } else {
  8850. pos = -1;
  8851. for(i = 0; i < MAX_IGNORE_LIST; i++)
  8852. if (strcmp(sd->ignore[i].name, nick) == 0) {
  8853. memset(sd->ignore[i].name, 0, sizeof(sd->ignore[i].name));
  8854. if (pos != -1) {
  8855. WFIFOB(fd,3) = 0; // success
  8856. WFIFOSET(fd, packet_len_table[0x0d1]);
  8857. pos = i; // don't break, to remove ALL same nick
  8858. }
  8859. }
  8860. if (pos == -1) {
  8861. WFIFOB(fd,3) = 1; // fail
  8862. WFIFOSET(fd, packet_len_table[0x0d1]);
  8863. clif_wis_message(fd, wisp_server_name, "This player is not blocked by you.", strlen("This player is not blocked by you.") + 1);
  8864. }
  8865. }
  8866. }
  8867. // for(i = 0; i < MAX_IGNORE_LIST; i++) // for debug only
  8868. // if (sd->ignore[i].name[0] != '\0')
  8869. // printf("Ignored player: '%s'\n", sd->ignore[i].name);
  8870. return;
  8871. }
  8872. void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd) { // Rewritten by [Yor]
  8873. //printf("Ignore all: state: %d\n", RFIFOB(fd,2));
  8874. if (RFIFOB(fd,2) == 0) {// S 00d0 <type>len.B: 00 (/exall) deny all speech, 01 (/inall) allow all speech
  8875. WFIFOW(fd,0) = 0x0d2; // R 00d2 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
  8876. WFIFOB(fd,2) = 0;
  8877. if (sd->ignoreAll == 0) {
  8878. sd->ignoreAll = 1;
  8879. WFIFOB(fd,3) = 0; // success
  8880. WFIFOSET(fd, packet_len_table[0x0d2]);
  8881. } else {
  8882. WFIFOB(fd,3) = 1; // fail
  8883. WFIFOSET(fd, packet_len_table[0x0d2]);
  8884. clif_wis_message(fd, wisp_server_name, "You already block everyone.", strlen("You already block everyone.") + 1);
  8885. }
  8886. } else {
  8887. WFIFOW(fd,0) = 0x0d2; // R 00d2 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
  8888. WFIFOB(fd,2) = 1;
  8889. if (sd->ignoreAll == 1) {
  8890. sd->ignoreAll = 0;
  8891. WFIFOB(fd,3) = 0; // success
  8892. WFIFOSET(fd, packet_len_table[0x0d2]);
  8893. } else {
  8894. WFIFOB(fd,3) = 1; // fail
  8895. WFIFOSET(fd, packet_len_table[0x0d2]);
  8896. clif_wis_message(fd, wisp_server_name, "You already allow everyone.", strlen("You already allow everyone.") + 1);
  8897. }
  8898. }
  8899. return;
  8900. }
  8901. void clif_parse_skillMessage(int fd, struct map_session_data *sd) { // Added by RoVeRT
  8902. int skillid,skilllv, x, y;
  8903. char *mes;
  8904. skilllv = RFIFOW(fd,2);
  8905. skillid = RFIFOW(fd,4);
  8906. y = RFIFOB(fd,6);
  8907. x = RFIFOB(fd,8);
  8908. mes = (char*)RFIFOP(fd,10);
  8909. // skill 220 = graffiti
  8910. // printf("skill: %d %d location: %3d %3d message: %s\n", skillid, skilllv, x, y, (char*)mes);
  8911. }
  8912. int monk(struct map_session_data *sd, struct block_list *target, int type) {
  8913. //R 01d1 <Monk id>L <Target monster id>L <Bool>L
  8914. int fd=sd->fd;
  8915. WFIFOW(fd,0)=0x1d1;
  8916. WFIFOL(fd,2)=sd->bl.id;
  8917. WFIFOL(fd,6)=target->id;
  8918. WFIFOL(fd,10)=type;
  8919. WFIFOSET(fd,packet_len_table[0x1d1]);
  8920. return 0;
  8921. }
  8922. /*==========================================
  8923. * スパノビの/doridoriによるSPR2倍
  8924. *------------------------------------------
  8925. */
  8926. void clif_parse_sn_doridori(int fd, struct map_session_data *sd) {
  8927. if (sd)
  8928. sd->doridori_counter = 1;
  8929. return;
  8930. }
  8931. /*==========================================
  8932. * スパノビの爆裂波動
  8933. *------------------------------------------
  8934. */
  8935. void clif_parse_sn_explosionspirits(int fd, struct map_session_data *sd)
  8936. {
  8937. if(sd){
  8938. int nextbaseexp=pc_nextbaseexp(sd);
  8939. struct pc_base_job s_class = pc_calc_base_job(sd->status.class_);
  8940. if (battle_config.etc_log){
  8941. if(nextbaseexp != 0)
  8942. printf("SuperNovice explosionspirits!! %d %d %d %d\n",sd->bl.id,s_class.job,sd->status.base_exp,(int)((double)1000*sd->status.base_exp/nextbaseexp));
  8943. else
  8944. printf("SuperNovice explosionspirits!! %d %d %d 000\n",sd->bl.id,s_class.job,sd->status.base_exp);
  8945. }
  8946. if(s_class.job == 23 && sd->status.base_exp > 0 && nextbaseexp > 0 && (int)((double)1000*sd->status.base_exp/nextbaseexp)%100==0){
  8947. clif_skill_nodamage(&sd->bl,&sd->bl,MO_EXPLOSIONSPIRITS,5,1);
  8948. skill_status_change_start(&sd->bl,SkillStatusChangeTable[MO_EXPLOSIONSPIRITS],5,0,0,0,skill_get_time(MO_EXPLOSIONSPIRITS,5),0 );
  8949. }
  8950. }
  8951. return;
  8952. }
  8953. /*==========================================
  8954. * Friends List
  8955. *------------------------------------------
  8956. */
  8957. void clif_friends_list_send(struct map_session_data *sd) {
  8958. int i, n;
  8959. // Send friends list
  8960. n = 0;
  8961. WFIFOW(sd->fd, 0) = 0x201;
  8962. for(i = 0; i < 20; i++)
  8963. if (sd->status.friend_id[i]) {
  8964. WFIFOL(sd->fd,4 + 32 * n + 1) = sd->status.friend_id[i];
  8965. //WFIFOB(sd->fd,4 + 32 * n + 5) = (online[n]) ? 0 : 1; // <- We don't know this yet. I'd reckon its 5 but... i could be wrong.
  8966. memcpy(WFIFOP(sd->fd,4 + 32 * n + 8), &sd->status.friend_name[i], 23);
  8967. n++;
  8968. }
  8969. WFIFOW(sd->fd,2) = 4 + 32 * n;
  8970. WFIFOSET(sd->fd, WFIFOW(sd->fd,2));
  8971. }
  8972. void clif_parse_friends_list_add(int fd, struct map_session_data *sd) {
  8973. struct map_session_data *f_sd;
  8974. int i;
  8975. f_sd = map_nick2sd((char*)RFIFOP(fd,2));
  8976. // Friend doesn't exist (no player with this name)
  8977. if (f_sd == NULL) {
  8978. clif_displaymessage(fd, "This name (for a friend) doesn't exist.");
  8979. return;
  8980. }
  8981. // Friend already exists
  8982. for (i = 0; i < 20; i++)
  8983. if (sd->status.friend_id[i] == f_sd->status.char_id) {
  8984. clif_displaymessage(fd, "Friend already exists.");
  8985. return;
  8986. }
  8987. // Find an empty slot
  8988. for (i = 0; i < 20; i++)
  8989. if (sd->status.friend_id[i] == 0)
  8990. break;
  8991. if (i == 20) {
  8992. clif_displaymessage(fd, "Friends list is full.");
  8993. return;
  8994. }
  8995. sd->status.friend_id[i] = f_sd->status.char_id;
  8996. memset(sd->status.friend_name[i], 0, sizeof(sd->status.friend_name[i]));
  8997. memcpy(sd->status.friend_name[i], f_sd->status.name, 23);
  8998. clif_displaymessage(fd, "Friend added.");
  8999. clif_friends_list_send(sd);
  9000. //printf("clif_parse_friends_list_add");
  9001. return;
  9002. }
  9003. void clif_parse_friends_list_remove(int fd, struct map_session_data *sd) {
  9004. // 0x203 </o> <ID to be removed W 4B>
  9005. int id = RFIFOL(fd,3);
  9006. int i, j;
  9007. // Search friend
  9008. for (i = 0; i < 20; i ++)
  9009. if (sd->status.friend_id[i] == id) {
  9010. // move all chars down
  9011. for(j = i + 1; j < 20; j++) {
  9012. sd->status.friend_id[j-1] = sd->status.friend_id[j];
  9013. memcpy(sd->status.friend_name[j-1], sd->status.friend_name[j], sizeof(sd->status.friend_name[j]));
  9014. }
  9015. sd->status.friend_id[19] = 0;
  9016. memset(sd->status.friend_name[19], 0, sizeof(sd->status.friend_name[19]));
  9017. clif_displaymessage(fd, "Friend removed");
  9018. clif_friends_list_send(sd);
  9019. break;
  9020. }
  9021. if (i == 20)
  9022. clif_displaymessage(fd, "Name not found in list.");
  9023. return;
  9024. }
  9025. /*==========================================
  9026. * /killall
  9027. *------------------------------------------
  9028. */
  9029. void clif_parse_GMkillall(int fd,struct map_session_data *sd)
  9030. {
  9031. char message[50];
  9032. nullpo_retv(sd);
  9033. strncpy(message,sd->status.name, 24);
  9034. is_atcommand(fd, sd, strcat(message," : @kickall"),0);
  9035. return;
  9036. }
  9037. /*==========================================
  9038. * パケットデバッグ
  9039. *------------------------------------------
  9040. */
  9041. void clif_parse_debug(int fd,struct map_session_data *sd)
  9042. {
  9043. int i, cmd;
  9044. cmd = RFIFOW(fd,0);
  9045. printf("packet debug 0x%4X\n",cmd);
  9046. printf("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
  9047. for(i=0;i<packet_db[sd->packet_ver][cmd].len;i++){
  9048. if((i&15)==0)
  9049. printf("\n%04X ",i);
  9050. printf("%02X ",RFIFOB(fd,i));
  9051. }
  9052. printf("\n");
  9053. }
  9054. // functions list
  9055. static void (*clif_parse_func_table[MAX_PACKET_DB])(int, struct map_session_data *) = {
  9056. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9057. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9058. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9059. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9060. // 40
  9061. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9062. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9063. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9064. // 70
  9065. NULL, NULL, clif_parse_WantToConnection, NULL, NULL, NULL, NULL, NULL,
  9066. NULL, NULL, NULL, NULL, NULL, clif_parse_LoadEndAck, clif_parse_TickSend, NULL,
  9067. // 80
  9068. NULL, NULL, NULL, NULL, NULL, clif_parse_WalkToXY, NULL, NULL,
  9069. NULL, clif_parse_ActionRequest, NULL, NULL, clif_parse_GlobalMessage, NULL, NULL, NULL,
  9070. // 90
  9071. clif_parse_NpcClicked, NULL, NULL, NULL, clif_parse_GetCharNameRequest, NULL, clif_parse_Wis, NULL,
  9072. NULL, clif_parse_GMmessage, NULL, clif_parse_ChangeDir, NULL, NULL, NULL, clif_parse_TakeItem,
  9073. // a0
  9074. NULL, NULL, clif_parse_DropItem, NULL, NULL, NULL, NULL, clif_parse_UseItem,
  9075. NULL, clif_parse_EquipItem, NULL, clif_parse_UnequipItem, NULL, NULL, NULL, NULL,
  9076. // b0
  9077. NULL, NULL, clif_parse_Restart, NULL, NULL, NULL, NULL, NULL,
  9078. clif_parse_NpcSelectMenu, clif_parse_NpcNextClicked, NULL, clif_parse_StatusUp, NULL, NULL, NULL, clif_parse_Emotion,
  9079. // c0
  9080. NULL, clif_parse_HowManyConnections, NULL, NULL, NULL, clif_parse_NpcBuySellSelected, NULL, NULL,
  9081. clif_parse_NpcBuyListSend, clif_parse_NpcSellListSend, NULL, NULL, clif_parse_GMKick, NULL, clif_parse_GMkillall, clif_parse_PMIgnore,
  9082. // d0
  9083. clif_parse_PMIgnoreAll, NULL, NULL, NULL, NULL, clif_parse_CreateChatRoom, NULL, NULL,
  9084. NULL, clif_parse_ChatAddMember, NULL, NULL, NULL, NULL, clif_parse_ChatRoomStatusChange, NULL,
  9085. // e0
  9086. clif_parse_ChangeChatOwner, NULL, clif_parse_KickFromChat, clif_parse_ChatLeave, clif_parse_TradeRequest, NULL, clif_parse_TradeAck, NULL,
  9087. clif_parse_TradeAddItem, NULL, NULL, clif_parse_TradeOk, NULL, clif_parse_TradeCancel, NULL, clif_parse_TradeCommit,
  9088. // f0
  9089. NULL, NULL, NULL, clif_parse_MoveToKafra, NULL, clif_parse_MoveFromKafra, NULL, clif_parse_CloseKafra,
  9090. NULL, clif_parse_CreateParty, NULL, NULL, clif_parse_PartyInvite, NULL, NULL, clif_parse_ReplyPartyInvite,
  9091. // 100
  9092. clif_parse_LeaveParty, NULL, clif_parse_PartyChangeOption, clif_parse_RemovePartyMember, NULL, NULL, NULL, NULL,
  9093. clif_parse_PartyMessage, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9094. // 110
  9095. NULL, NULL, clif_parse_SkillUp, clif_parse_UseSkillToId, NULL, NULL, clif_parse_UseSkillToPos, NULL,
  9096. clif_parse_StopAttack, NULL, NULL, clif_parse_UseSkillMap, NULL, clif_parse_RequestMemo, NULL, NULL,
  9097. // 120
  9098. NULL, NULL, NULL, NULL, NULL, NULL, clif_parse_PutItemToCart, clif_parse_GetItemFromCart,
  9099. clif_parse_MoveFromKafraToCart, clif_parse_MoveToKafraFromCart, clif_parse_RemoveOption, NULL, NULL, NULL, clif_parse_CloseVending, NULL,
  9100. // 130
  9101. clif_parse_VendingListReq, NULL, NULL, NULL, clif_parse_PurchaseReq, NULL, NULL, NULL,
  9102. NULL, NULL, NULL, NULL, NULL, NULL, NULL, clif_parse_GM_Monster_Item,
  9103. // 140
  9104. clif_parse_MapMove, NULL, NULL, clif_parse_NpcAmountInput, NULL, NULL, clif_parse_NpcCloseClicked, NULL,
  9105. NULL, clif_parse_GMReqNoChat, NULL, NULL, NULL, clif_parse_GuildCheckMaster, NULL, clif_parse_GuildRequestInfo,
  9106. // 150
  9107. NULL, clif_parse_GuildRequestEmblem, NULL, clif_parse_GuildChangeEmblem, NULL, clif_parse_GuildChangeMemberPosition, NULL, NULL,
  9108. NULL, clif_parse_GuildLeave, NULL, clif_parse_GuildExplusion, NULL, clif_parse_GuildBreak, NULL, NULL,
  9109. // 160
  9110. NULL, clif_parse_GuildChangePositionInfo, NULL, NULL, NULL, clif_parse_CreateGuild, NULL, NULL,
  9111. clif_parse_GuildInvite, NULL, NULL, clif_parse_GuildReplyInvite, NULL, NULL, clif_parse_GuildChangeNotice, NULL,
  9112. // 170
  9113. clif_parse_GuildRequestAlliance, NULL, clif_parse_GuildReplyAlliance, NULL, NULL, NULL, NULL, NULL,
  9114. clif_parse_ItemIdentify, NULL, clif_parse_UseCard, NULL, clif_parse_InsertCard, NULL, clif_parse_GuildMessage, NULL,
  9115. // 180
  9116. clif_parse_GuildOpposition, NULL, NULL, clif_parse_GuildDelAlliance, NULL, NULL, NULL, NULL,
  9117. NULL, NULL, clif_parse_QuitGame, NULL, NULL, NULL, clif_parse_ProduceMix, NULL,
  9118. // 190
  9119. clif_parse_UseSkillToPos, NULL, NULL, clif_parse_SolveCharName, NULL, NULL, NULL, clif_parse_ResetChar,
  9120. NULL, NULL, NULL, NULL, clif_parse_LGMmessage, clif_parse_GMHide, NULL, clif_parse_CatchPet,
  9121. // 1a0
  9122. NULL, clif_parse_PetMenu, NULL, NULL, NULL, clif_parse_ChangePetName, NULL, clif_parse_SelectEgg,
  9123. NULL, clif_parse_SendEmotion, NULL, NULL, NULL, NULL, clif_parse_SelectArrow, clif_parse_ChangeCart,
  9124. // 1b0
  9125. NULL, NULL, clif_parse_OpenVending, NULL, NULL, NULL, NULL, NULL,
  9126. NULL, NULL, clif_parse_Shift, clif_parse_Shift, clif_parse_Recall, clif_parse_Recall, NULL, NULL,
  9127. // 1c0
  9128. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9129. NULL, NULL, NULL, NULL, NULL, NULL, clif_parse_AutoSpell,
  9130. NULL,
  9131. // 1d0
  9132. NULL, NULL, NULL, NULL, NULL, clif_parse_NpcStringInput, NULL, NULL,
  9133. NULL, NULL, NULL, NULL, NULL, NULL, NULL, clif_parse_GMReqNoChatCount,
  9134. // 1e0
  9135. NULL, NULL, NULL, NULL, NULL, NULL, NULL, clif_parse_sn_doridori,
  9136. clif_parse_CreateParty2, NULL, NULL, NULL, NULL, clif_parse_sn_explosionspirits, NULL, NULL,
  9137. // 1f0
  9138. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, clif_parse_ReqAdopt,
  9139. NULL, NULL, NULL, NULL, NULL, NULL,
  9140. // 200
  9141. NULL, NULL, clif_parse_friends_list_add, clif_parse_friends_list_remove, NULL, NULL, NULL, NULL,
  9142. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9143. // 210
  9144. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9145. #if 0
  9146. case 0xd3: clif_parse_IgnoreList
  9147. #endif
  9148. };
  9149. /*==========================================
  9150. * クライアントからのパケット解析
  9151. * socket.cのdo_parsepacketから呼び出される
  9152. *------------------------------------------
  9153. */
  9154. static int clif_parse(int fd) {
  9155. int packet_len = 0, cmd, packet_ver;
  9156. struct map_session_data *sd;
  9157. sd = (struct map_session_data*)session[fd]->session_data;
  9158. // 接続が切れてるので後始末
  9159. if (!chrif_isconnect() || session[fd]->eof) { // char鯖に繋がってない間は接続禁止 (!chrif_isconnect())
  9160. if (sd && sd->state.auth) {
  9161. clif_quitsave(fd, sd); // the function doesn't send to inter-server/char-server if it is not connected [Yor]
  9162. if (sd->status.name != NULL)
  9163. sprintf(tmp_output,"%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off.\n", (pc_isGM(sd))?"GM ":"",sd->status.name); // Player logout display [Valaris]
  9164. else
  9165. sprintf(tmp_output,"%sCharacter with Account ID '"CL_WHITE"%d"CL_RESET"' logged off.\n", (pc_isGM(sd))?"GM ":"", sd->bl.id); // Player logout display [Yor]
  9166. } else if (sd) { // not authentified! (refused by char-server or disconnect before to be authentified)
  9167. sprintf(tmp_output,"Player not authenticated with Account ID '"CL_WHITE"%d"CL_RESET"' logged off.\n", sd->bl.id); // Player logout display [Yor]
  9168. // if (chrif_isconnect())
  9169. // clif_quitsave(fd, sd);
  9170. map_deliddb(&sd->bl); // account_id has been included in the DB before auth answer [Yor]
  9171. // sd = 0;
  9172. } else {
  9173. unsigned char *ip = (unsigned char *) &session[fd]->client_addr.sin_addr;
  9174. sprintf(tmp_output,"Player not identified with IP '"CL_WHITE"%d.%d.%d.%d"CL_RESET"' logged off.\n", ip[0],ip[1],ip[2],ip[3]);
  9175. }
  9176. ShowInfo(tmp_output);
  9177. close(fd);
  9178. // if (sd) // 追加
  9179. // map_deliddb(&sd->bl); // 追加
  9180. delete_session(fd);
  9181. return 0;
  9182. }
  9183. if (RFIFOREST(fd) < 2)
  9184. return 0;
  9185. // printf("clif_parse: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
  9186. cmd = RFIFOW(fd,0);
  9187. // 管理用パケット処理
  9188. if (cmd >= 30000) {
  9189. switch(cmd) {
  9190. case 0x7530: // Athena情報所得
  9191. WFIFOW(fd,0) = 0x7531;
  9192. WFIFOB(fd,2) = ATHENA_MAJOR_VERSION;
  9193. WFIFOB(fd,3) = ATHENA_MINOR_VERSION;
  9194. WFIFOB(fd,4) = ATHENA_REVISION;
  9195. WFIFOB(fd,5) = ATHENA_RELEASE_FLAG;
  9196. WFIFOB(fd,6) = ATHENA_OFFICIAL_FLAG;
  9197. WFIFOB(fd,7) = ATHENA_SERVER_MAP;
  9198. WFIFOW(fd,8) = ATHENA_MOD_VERSION;
  9199. WFIFOSET(fd,10);
  9200. RFIFOSKIP(fd,2);
  9201. break;
  9202. case 0x7532: // 接続の切断
  9203. close(fd);
  9204. session[fd]->eof=1;
  9205. break;
  9206. }
  9207. return 0;
  9208. }
  9209. // get packet version before to parse
  9210. packet_ver = 0;
  9211. if (sd)
  9212. packet_ver = sd->packet_ver;
  9213. // check authentification packet to know packet version
  9214. else {
  9215. // packet DB
  9216. if (IS_PACKET_DB_VER (cmd)) {
  9217. if (RFIFOREST(fd) >= packet_db[clif_config.packet_db_ver][cmd].len &&
  9218. (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[4]) == 0 ||
  9219. RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[4]) == 1)) {// 00 = Female, 01 = Male
  9220. packet_ver = clif_config.packet_db_ver;
  9221. }
  9222. // 0x72
  9223. } else if (cmd == 0x72) {
  9224. if (RFIFOREST(fd) >= 39 && (RFIFOB(fd,38) == 0 || RFIFOB(fd,38) == 1)) // 00 = Female, 01 = Male
  9225. packet_ver = 7; // 7: 13july04
  9226. else if (RFIFOREST(fd) >= 22 && (RFIFOB(fd,21) == 0 || RFIFOB(fd,21) == 1)) // 00 = Female, 01 = Male
  9227. packet_ver = 6; // 6: 7july04
  9228. else if (RFIFOREST(fd) >= 19 && (RFIFOB(fd,18) == 0 || RFIFOB(fd,18) == 1)) // 00 = Female, 01 = Male
  9229. packet_ver = 5; // 5: old
  9230. // else probably incomplete packet
  9231. else if (RFIFOREST(fd) < 19)
  9232. return 0;
  9233. // 0x7E
  9234. } else if (cmd == 0x7E) {
  9235. if (RFIFOREST(fd) >= 37 && (RFIFOB(fd,36) == 0 || RFIFOB(fd,36) == 1)) // 00 = Female, 01 = Male
  9236. packet_ver = 9; // 9: 9aug04/16aug04/17aug04
  9237. else if (RFIFOREST(fd) >= 33 && (RFIFOB(fd,32) == 0 || RFIFOB(fd,32) == 1)) // 00 = Female, 01 = Male
  9238. packet_ver = 8; // 8: 26july04
  9239. // else probably incomplete packet
  9240. else if (RFIFOREST(fd) < 33)
  9241. return 0;
  9242. // 0xF5
  9243. } else if (cmd == 0xF5) {
  9244. if (RFIFOREST(fd) >= 34 && (RFIFOB(fd,33) == 0 || RFIFOB(fd,33) == 1)) // 00 = Female, 01 = Male
  9245. packet_ver = 10; // 10: 6sept04
  9246. else if (RFIFOREST(fd) >= 33 && (RFIFOB(fd,32) == 0 || RFIFOB(fd,32) == 1)) // 00 = Female, 01 = Male
  9247. packet_ver = 12; // 12: 18oct04
  9248. else if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) // 00 = Female, 01 = Male
  9249. packet_ver = 11; // 11: 21sept04
  9250. else if (RFIFOREST(fd) >= 29 && (RFIFOB(fd,28) == 0 || RFIFOB(fd,28) == 1)) { // 00 = Female, 01 = Male
  9251. /*if (RFIFOW(fd,1) == 0) // testing ^^;
  9252. packet_ver = 15;
  9253. else*/
  9254. packet_ver = 13; // 13: 25oct04 (by [Yor])
  9255. }
  9256. // -- some way to identify version 14 and 15? --
  9257. // else probably incomplete packet
  9258. else if (RFIFOREST(fd) < 29)
  9259. return 0;
  9260. // 0x9B
  9261. } else if (cmd == 0x9B) {
  9262. if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) // 00 = Female, 01 = Male
  9263. packet_ver = 16; // 16: 10jan05
  9264. else if (RFIFOREST(fd) < 32)
  9265. return 0;
  9266. } else {
  9267. // unknown client? leave packet ver as 0 so it'll disconnect anyway
  9268. }
  9269. // check if version is accepted
  9270. if (packet_ver <= 5 || // reject really old client versions
  9271. (packet_ver <= 9 && (battle_config.packet_ver_flag & 1) == 0) || // older than 6sept04
  9272. (packet_ver == 10 && (battle_config.packet_ver_flag & 2) == 0) ||
  9273. (packet_ver == 11 && (battle_config.packet_ver_flag & 4) == 0) ||
  9274. (packet_ver == 12 && (battle_config.packet_ver_flag & 8) == 0) ||
  9275. (packet_ver == 13 && (battle_config.packet_ver_flag & 16) == 0) ||
  9276. (packet_ver == 14 && (battle_config.packet_ver_flag & 32) == 0) ||
  9277. (packet_ver == 15 && (battle_config.packet_ver_flag & 64) == 0) ||
  9278. (packet_ver == 16 && (battle_config.packet_ver_flag & 128) == 0) ||
  9279. packet_ver > MAX_PACKET_VER || // no packet version support yet
  9280. // identified version, but unknown client?
  9281. (!sd && packet_db[packet_ver][cmd].func != clif_parse_WantToConnection)) {
  9282. WFIFOW(fd,0) = 0x6a;
  9283. WFIFOB(fd,2) = 5; // 05 = Game's EXE is not the latest version
  9284. WFIFOSET(fd,23);
  9285. clif_setwaitclose(fd);
  9286. return 0;
  9287. }
  9288. }
  9289. // ゲーム用以外パケットか、認証を終える前に0072以外が来たら、切断する
  9290. 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
  9291. if (!fd)
  9292. return 0;
  9293. close(fd);
  9294. session[fd]->eof = 1;
  9295. printf("clif_parse: session #%d, packet 0x%x (%d bytes received) -> disconnected.\n", fd, cmd, RFIFOREST(fd));
  9296. return 0;
  9297. }
  9298. // パケット長を計算
  9299. packet_len = packet_db[packet_ver][cmd].len;
  9300. if (packet_len == -1) {
  9301. if (RFIFOREST(fd) < 4)
  9302. return 0; // 可変長パケットで長さの所までデータが来てない
  9303. packet_len = RFIFOW(fd,2);
  9304. if (packet_len < 4 || packet_len > 32768) {
  9305. close(fd);
  9306. session[fd]->eof =1;
  9307. return 0;
  9308. }
  9309. }
  9310. if (RFIFOREST(fd) < packet_len)
  9311. return 0; // まだ1パケット分データが揃ってない
  9312. if (sd && sd->state.auth == 1 && sd->state.waitingdisconnect == 1) { // 切断待ちの場合パケットを処理しない
  9313. } else if (packet_db[packet_ver][cmd].func) { // packet version 5-6-7 use same functions, but size are different
  9314. // パケット処理
  9315. packet_db[packet_ver][cmd].func(fd, sd);
  9316. } else {
  9317. // 不明なパケット
  9318. if (battle_config.error_log) {
  9319. if (fd)
  9320. printf("\nclif_parse: session #%d, packet 0x%x, lenght %d\n", fd, cmd, packet_len);
  9321. #ifdef DUMP_UNKNOWN_PACKET
  9322. {
  9323. int i;
  9324. FILE *fp;
  9325. char packet_txt[256] = "save/packet.txt";
  9326. time_t now;
  9327. printf("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
  9328. for(i = 0; i < packet_len; i++) {
  9329. if ((i & 15) == 0)
  9330. printf("\n%04X ",i);
  9331. printf("%02X ", RFIFOB(fd,i));
  9332. }
  9333. if (sd && sd->state.auth) {
  9334. if (sd->status.name != NULL)
  9335. printf("\nAccount ID %d, character ID %d, player name %s.\n",
  9336. sd->status.account_id, sd->status.char_id, sd->status.name);
  9337. else
  9338. printf("\nAccount ID %d.\n", sd->bl.id);
  9339. } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
  9340. printf("\nAccount ID %d.\n", sd->bl.id);
  9341. if ((fp = fopen(packet_txt, "a")) == NULL) {
  9342. printf("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt);
  9343. return 1;
  9344. } else {
  9345. time(&now);
  9346. if (sd && sd->state.auth) {
  9347. if (sd->status.name != NULL)
  9348. fprintf(fp, "%sPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n",
  9349. asctime(localtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name);
  9350. else
  9351. fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
  9352. } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
  9353. fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
  9354. fprintf(fp, "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
  9355. for(i = 0; i < packet_len; i++) {
  9356. if ((i & 15) == 0)
  9357. fprintf(fp, "\n\t%04X ", i);
  9358. fprintf(fp, "%02X ", RFIFOB(fd,i));
  9359. }
  9360. fprintf(fp, "\n\n");
  9361. fclose(fp);
  9362. }
  9363. }
  9364. #endif
  9365. }
  9366. }
  9367. RFIFOSKIP(fd, packet_len);
  9368. return 0;
  9369. }
  9370. /*==========================================
  9371. * パケットデータベース読み込み
  9372. *------------------------------------------
  9373. */
  9374. static int packetdb_readdb(void)
  9375. {
  9376. FILE *fp;
  9377. char line[1024];
  9378. int ln=0;
  9379. int cmd,j,k,packet_ver;
  9380. char *str[32],*p,*str2[32],*p2,w1[24],w2[24];
  9381. struct {
  9382. void (*func)(int, struct map_session_data *);
  9383. char *name;
  9384. } clif_parse_func[]={
  9385. {clif_parse_WantToConnection,"wanttoconnection"},
  9386. {clif_parse_LoadEndAck,"loadendack"},
  9387. {clif_parse_TickSend,"ticksend"},
  9388. {clif_parse_WalkToXY,"walktoxy"},
  9389. {clif_parse_QuitGame,"quitgame"},
  9390. {clif_parse_GetCharNameRequest,"getcharnamerequest"},
  9391. {clif_parse_GlobalMessage,"globalmessage"},
  9392. {clif_parse_MapMove,"mapmove"},
  9393. {clif_parse_ChangeDir,"changedir"},
  9394. {clif_parse_Emotion,"emotion"},
  9395. {clif_parse_HowManyConnections,"howmanyconnections"},
  9396. {clif_parse_ActionRequest,"actionrequest"},
  9397. {clif_parse_Restart,"restart"},
  9398. {clif_parse_Wis,"wis"},
  9399. {clif_parse_GMmessage,"gmmessage"},
  9400. {clif_parse_TakeItem,"takeitem"},
  9401. {clif_parse_DropItem,"dropitem"},
  9402. {clif_parse_UseItem,"useitem"},
  9403. {clif_parse_EquipItem,"equipitem"},
  9404. {clif_parse_UnequipItem,"unequipitem"},
  9405. {clif_parse_NpcClicked,"npcclicked"},
  9406. {clif_parse_NpcBuySellSelected,"npcbuysellselected"},
  9407. {clif_parse_NpcBuyListSend,"npcbuylistsend"},
  9408. {clif_parse_NpcSellListSend,"npcselllistsend"},
  9409. {clif_parse_CreateChatRoom,"createchatroom"},
  9410. {clif_parse_ChatAddMember,"chataddmember"},
  9411. {clif_parse_ChatRoomStatusChange,"chatroomstatuschange"},
  9412. {clif_parse_ChangeChatOwner,"changechatowner"},
  9413. {clif_parse_KickFromChat,"kickfromchat"},
  9414. {clif_parse_ChatLeave,"chatleave"},
  9415. {clif_parse_TradeRequest,"traderequest"},
  9416. {clif_parse_TradeAck,"tradeack"},
  9417. {clif_parse_TradeAddItem,"tradeadditem"},
  9418. {clif_parse_TradeOk,"tradeok"},
  9419. {clif_parse_TradeCancel,"tradecancel"},
  9420. {clif_parse_TradeCommit,"tradecommit"},
  9421. {clif_parse_StopAttack,"stopattack"},
  9422. {clif_parse_PutItemToCart,"putitemtocart"},
  9423. {clif_parse_GetItemFromCart,"getitemfromcart"},
  9424. {clif_parse_RemoveOption,"removeoption"},
  9425. {clif_parse_ChangeCart,"changecart"},
  9426. {clif_parse_StatusUp,"statusup"},
  9427. {clif_parse_SkillUp,"skillup"},
  9428. {clif_parse_UseSkillToId,"useskilltoid"},
  9429. {clif_parse_UseSkillToPos,"useskilltopos"},
  9430. {clif_parse_UseSkillMap,"useskillmap"},
  9431. {clif_parse_RequestMemo,"requestmemo"},
  9432. {clif_parse_ProduceMix,"producemix"},
  9433. {clif_parse_NpcSelectMenu,"npcselectmenu"},
  9434. {clif_parse_NpcNextClicked,"npcnextclicked"},
  9435. {clif_parse_NpcAmountInput,"npcamountinput"},
  9436. {clif_parse_NpcStringInput,"npcstringinput"},
  9437. {clif_parse_NpcCloseClicked,"npccloseclicked"},
  9438. {clif_parse_ItemIdentify,"itemidentify"},
  9439. {clif_parse_SelectArrow,"selectarrow"},
  9440. {clif_parse_AutoSpell,"autospell"},
  9441. {clif_parse_UseCard,"usecard"},
  9442. {clif_parse_InsertCard,"insertcard"},
  9443. {clif_parse_SolveCharName,"solvecharname"},
  9444. {clif_parse_ResetChar,"resetchar"},
  9445. {clif_parse_LGMmessage,"lgmmessage"},
  9446. {clif_parse_MoveToKafra,"movetokafra"},
  9447. {clif_parse_MoveFromKafra,"movefromkafra"},
  9448. {clif_parse_MoveToKafraFromCart,"movetokafrafromcart"},
  9449. {clif_parse_MoveFromKafraToCart,"movefromkafratocart"},
  9450. {clif_parse_CloseKafra,"closekafra"},
  9451. {clif_parse_CreateParty,"createparty"},
  9452. {clif_parse_CreateParty2,"createparty2"},
  9453. {clif_parse_PartyInvite,"partyinvite"},
  9454. {clif_parse_ReplyPartyInvite,"replypartyinvite"},
  9455. {clif_parse_LeaveParty,"leaveparty"},
  9456. {clif_parse_RemovePartyMember,"removepartymember"},
  9457. {clif_parse_PartyChangeOption,"partychangeoption"},
  9458. {clif_parse_PartyMessage,"partymessage"},
  9459. {clif_parse_CloseVending,"closevending"},
  9460. {clif_parse_VendingListReq,"vendinglistreq"},
  9461. {clif_parse_PurchaseReq,"purchasereq"},
  9462. {clif_parse_OpenVending,"openvending"},
  9463. {clif_parse_CreateGuild,"createguild"},
  9464. {clif_parse_GuildCheckMaster,"guildcheckmaster"},
  9465. {clif_parse_GuildRequestInfo,"guildrequestinfo"},
  9466. {clif_parse_GuildChangePositionInfo,"guildchangepositioninfo"},
  9467. {clif_parse_GuildChangeMemberPosition,"guildchangememberposition"},
  9468. {clif_parse_GuildRequestEmblem,"guildrequestemblem"},
  9469. {clif_parse_GuildChangeEmblem,"guildchangeemblem"},
  9470. {clif_parse_GuildChangeNotice,"guildchangenotice"},
  9471. {clif_parse_GuildInvite,"guildinvite"},
  9472. {clif_parse_GuildReplyInvite,"guildreplyinvite"},
  9473. {clif_parse_GuildLeave,"guildleave"},
  9474. {clif_parse_GuildExplusion,"guildexplusion"},
  9475. {clif_parse_GuildMessage,"guildmessage"},
  9476. {clif_parse_GuildRequestAlliance,"guildrequestalliance"},
  9477. {clif_parse_GuildReplyAlliance,"guildreplyalliance"},
  9478. {clif_parse_GuildDelAlliance,"guilddelalliance"},
  9479. {clif_parse_GuildOpposition,"guildopposition"},
  9480. {clif_parse_GuildBreak,"guildbreak"},
  9481. {clif_parse_PetMenu,"petmenu"},
  9482. {clif_parse_CatchPet,"catchpet"},
  9483. {clif_parse_SelectEgg,"selectegg"},
  9484. {clif_parse_SendEmotion,"sendemotion"},
  9485. {clif_parse_ChangePetName,"changepetname"},
  9486. {clif_parse_GMKick,"gmkick"},
  9487. {clif_parse_GMHide,"gmhide"},
  9488. {clif_parse_GMReqNoChat,"gmreqnochat"},
  9489. {clif_parse_GMReqNoChatCount,"gmreqnochatcount"},
  9490. {clif_parse_sn_doridori,"sndoridori"},
  9491. {clif_parse_sn_explosionspirits,"snexplosionspirits"},
  9492. // {clif_parse_wisexin,"wisexin"},
  9493. // {clif_parse_wisexlist,"wisexlist"},
  9494. // {clif_parse_wisall,"wisall"},
  9495. {clif_parse_GMkillall,"killall"},
  9496. {clif_parse_GM_Monster_Item,"summon"},
  9497. {clif_parse_Shift,"shift"},
  9498. {clif_parse_debug,"debug"},
  9499. {NULL,NULL}
  9500. };
  9501. if( (fp=fopen("db/packet_db.txt","r"))==NULL ){
  9502. printf("can't read db/packet_db.txt\n");
  9503. return 1;
  9504. }
  9505. clif_config.packet_db_ver = MAX_PACKET_VER;
  9506. packet_ver = MAX_PACKET_VER; // read into packet_db's version by default
  9507. while(fgets(line,1020,fp)){
  9508. if(line[0]=='/' && line[1]=='/')
  9509. continue;
  9510. if (sscanf(line,"%[^:]: %[^\r\n]",w1,w2) == 2) {
  9511. if(strcmpi(w1,"packet_ver")==0) {
  9512. packet_ver = atoi(w2);
  9513. // copy from previous version into new version and continue
  9514. // - indicating all following packets should be read into the newer version
  9515. // -- on 2nd thought, rereading everything isn't the best thing to do...
  9516. // memcpy(&packet_db[packet_ver], &packet_db[packet_ver - 1], sizeof(packet_db[0]));
  9517. continue;
  9518. } else if(strcmpi(w1,"packet_db_ver")==0) {
  9519. // optional: if you do not wish to read multiple versions from the packet_db,
  9520. // remove all "packet_ver: ##" lines, and define the packet DB version with this
  9521. if(strcmpi(w2,"default")==0)
  9522. clif_config.packet_db_ver = MAX_PACKET_VER;
  9523. else {
  9524. // to manually set the packet DB version
  9525. clif_config.packet_db_ver = atoi(w2);
  9526. // check for invalid version
  9527. if (clif_config.packet_db_ver > MAX_PACKET_VER ||
  9528. clif_config.packet_db_ver < 0)
  9529. clif_config.packet_db_ver = MAX_PACKET_VER;
  9530. }
  9531. continue;
  9532. } else if(strcmpi(w1,"enable_packet_db")==0) {
  9533. // whether we want to allow identifying clients via the packet DB
  9534. clif_config.enable_packet_db = battle_config_switch(w2);
  9535. // if we don't want to read the packet DB, and use hardcoded values only
  9536. if (!clif_config.enable_packet_db)
  9537. return 0;
  9538. continue;
  9539. } else if(strcmpi(w1,"prefer_packet_db")==0) {
  9540. // whether the packet DB takes higher precedence over the hardcoded one (type 1)
  9541. // and whether to overwrite predefined packet length and functions when reading
  9542. // from the DB (type 2)
  9543. clif_config.prefer_packet_db = battle_config_switch(w2); // not used for now
  9544. continue;
  9545. }
  9546. }
  9547. memset(str,0,sizeof(str));
  9548. for(j=0,p=line;j<4 && p;j++){
  9549. str[j]=p;
  9550. p=strchr(p,',');
  9551. if(p) *p++=0;
  9552. }
  9553. if(str[0]==NULL)
  9554. continue;
  9555. cmd=strtol(str[0],(char **)NULL,0);
  9556. if(cmd<=0 || cmd>=MAX_PACKET_DB)
  9557. continue;
  9558. if(str[1]==NULL){
  9559. sprintf(tmp_output, "packet_db: packet len error\n");
  9560. ShowError(tmp_output);
  9561. continue;
  9562. }
  9563. k = atoi(str[1]);
  9564. // if (packet_db[packet_ver][cmd].len != k && clif_config.prefer_packet_db) // not used for now
  9565. packet_db[packet_ver][cmd].len = k;
  9566. if(str[2]==NULL){
  9567. ln++;
  9568. continue;
  9569. }
  9570. for(j=0;j<sizeof(clif_parse_func)/sizeof(clif_parse_func[0]);j++){
  9571. if(clif_parse_func[j].name != NULL &&
  9572. strcmp(str[2],clif_parse_func[j].name)==0){
  9573. // if (packet_db[packet_ver][cmd].func != clif_parse_func[j].func && !clif_config.prefer_packet_db)
  9574. // break; // not used for now
  9575. packet_db[packet_ver][cmd].func = clif_parse_func[j].func;
  9576. break;
  9577. }
  9578. }
  9579. // set the identifying cmd for the packet_db version
  9580. if (strcmp(str[2],"wanttoconnection")==0){
  9581. clif_config.connect_cmd = cmd;
  9582. }
  9583. if(str[3]==NULL){
  9584. sprintf(tmp_output, "packet_db: packet error\n");
  9585. ShowError(tmp_output);
  9586. exit(1);
  9587. }
  9588. for(j=0,p2=str[3];p2;j++){
  9589. str2[j]=p2;
  9590. p2=strchr(p2,':');
  9591. if(p2) *p2++=0;
  9592. k = atoi(str2[j]);
  9593. // if (packet_db[packet_ver][cmd].pos[j] != k && clif_config.prefer_packet_db) // not used for now
  9594. packet_db[packet_ver][cmd].pos[j] = k;
  9595. }
  9596. ln++;
  9597. // if(packet_db[clif_config.packet_db_ver][cmd].len > 2 /* && packet_db[cmd].pos[0] == 0 */)
  9598. // 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);
  9599. }
  9600. fclose(fp);
  9601. sprintf(tmp_output,"Done reading packet version '"CL_WHITE"%d"CL_RESET"' in '"CL_WHITE"%s"CL_RESET"'.\n", clif_config.packet_db_ver, "db/packet_db.txt");
  9602. ShowStatus(tmp_output);
  9603. return 0;
  9604. }
  9605. /*==========================================
  9606. *
  9607. *------------------------------------------
  9608. */
  9609. int do_init_clif(void) {
  9610. int i;
  9611. clif_config.enable_packet_db = 1; // whether to use the packet DB for client connection
  9612. clif_config.packet_db_ver = -1; // the main packet version of the DB
  9613. clif_config.prefer_packet_db = 1; // whether the packet version takes precedence
  9614. clif_config.connect_cmd = 0xF5; // the default packet used for connecting to the server
  9615. memset(packet_db,0,sizeof(packet_db));
  9616. // size of packet version 5 (old)
  9617. for(i=0;i<sizeof(packet_len_table)/sizeof(packet_len_table[0]);i++){
  9618. packet_db[0][i].len = packet_len_table[i];
  9619. }
  9620. // packet functions of version 5 (old)
  9621. for(i=0;i<sizeof(clif_parse_func_table)/sizeof(clif_parse_func_table[0]);i++){
  9622. packet_db[0][i].func = clif_parse_func_table[i];
  9623. }
  9624. // using hardcoded packet values isn't necessary with packet_db now,
  9625. // but... just in case, i'll leave it to initialise for now ^^;
  9626. // init packet version 5 and lower
  9627. memcpy(&packet_db[1], &packet_db[0], sizeof(packet_db[0]));
  9628. memcpy(&packet_db[2], &packet_db[1], sizeof(packet_db[0]));
  9629. memcpy(&packet_db[3], &packet_db[2], sizeof(packet_db[0]));
  9630. memcpy(&packet_db[4], &packet_db[3], sizeof(packet_db[0]));
  9631. memcpy(&packet_db[5], &packet_db[4], sizeof(packet_db[0]));
  9632. #ifndef PREFER_PACKET_DB
  9633. // functions of packet version 5-6-7 are same, but size are different
  9634. // size of packet version 6 (7july04)
  9635. memcpy(&packet_db[6], &packet_db[5], sizeof(packet_db[0]));
  9636. packet_db[6][0x072].len = 22;
  9637. packet_db[6][0x085].len = 8;
  9638. packet_db[6][0x0a7].len = 13;
  9639. packet_db[6][0x113].len = 15;
  9640. packet_db[6][0x116].len = 15;
  9641. packet_db[6][0x190].len = 95;
  9642. // size of packet version 7 (13july04)
  9643. memcpy(&packet_db[7], &packet_db[6], sizeof(packet_db[0]));
  9644. packet_db[7][0x072].len = 39;
  9645. packet_db[7][0x085].len = 9;
  9646. packet_db[7][0x09b].len = 13;
  9647. packet_db[7][0x09f].len = 10;
  9648. packet_db[7][0x0a7].len = 17;
  9649. packet_db[7][0x113].len = 19;
  9650. packet_db[7][0x116].len = 19;
  9651. packet_db[7][0x190].len = 99;
  9652. // init packet function calls for packet ver 8
  9653. memcpy(packet_db[8], packet_db[7], sizeof(packet_db[0]));
  9654. packet_db[8][0x072].func = clif_parse_DropItem;
  9655. packet_db[8][0x07e].func = clif_parse_WantToConnection;
  9656. packet_db[8][0x085].func = clif_parse_UseSkillToId;
  9657. packet_db[8][0x089].func = clif_parse_GetCharNameRequest;
  9658. packet_db[8][0x08c].func = clif_parse_UseSkillToPos;
  9659. packet_db[8][0x094].func = clif_parse_TakeItem;
  9660. packet_db[8][0x09b].func = clif_parse_WalkToXY;
  9661. packet_db[8][0x09f].func = clif_parse_ChangeDir;
  9662. packet_db[8][0x0a2].func = clif_parse_UseSkillToPos;
  9663. packet_db[8][0x0a7].func = clif_parse_SolveCharName;
  9664. packet_db[8][0x0f3].func = clif_parse_GlobalMessage;
  9665. packet_db[8][0x0f5].func = clif_parse_UseItem;
  9666. packet_db[8][0x0f7].func = clif_parse_TickSend;
  9667. packet_db[8][0x113].func = clif_parse_MoveToKafra;
  9668. packet_db[8][0x116].func = clif_parse_CloseKafra;
  9669. packet_db[8][0x190].func = clif_parse_MoveFromKafra;
  9670. packet_db[8][0x193].func = clif_parse_ActionRequest;
  9671. // size of packet version 8 (26july04)
  9672. packet_db[8][0x072].len = 14;
  9673. packet_db[8][0x07e].len = 33;
  9674. packet_db[8][0x085].len = 20;
  9675. packet_db[8][0x089].len = 15;
  9676. packet_db[8][0x08c].len = 23;
  9677. packet_db[8][0x094].len = 10;
  9678. packet_db[8][0x09b].len = 6;
  9679. packet_db[8][0x09f].len = 13;
  9680. packet_db[8][0x0a2].len = 103;
  9681. packet_db[8][0x0a7].len = 12;
  9682. packet_db[8][0x0f3].len = -1;
  9683. packet_db[8][0x0f5].len = 17;
  9684. packet_db[8][0x0f7].len = 10;
  9685. packet_db[8][0x113].len = 16;
  9686. packet_db[8][0x116].len = 2;
  9687. packet_db[8][0x190].len = 26;
  9688. packet_db[8][0x193].len = 9;
  9689. // init packet function calls for packet ver 9 (same function of packet version 8, but size are different)
  9690. memcpy(packet_db[9], packet_db[8], sizeof(packet_db[0]));
  9691. // size of packet version 9 (9aug04/16aug04/17aug04)
  9692. packet_db[9][0x072].len = 17;
  9693. packet_db[9][0x07e].len = 37;
  9694. packet_db[9][0x085].len = 26;
  9695. packet_db[9][0x089].len = 12;
  9696. packet_db[9][0x08c].len = 40;
  9697. packet_db[9][0x094].len = 13;
  9698. packet_db[9][0x09b].len = 15;
  9699. packet_db[9][0x09f].len = 12;
  9700. packet_db[9][0x0a2].len = 120;
  9701. packet_db[9][0x0a7].len = 11;
  9702. // packet_db[9][0x0f3].len = -1;
  9703. packet_db[9][0x0f5].len = 24;
  9704. packet_db[9][0x0f7].len = 13;
  9705. packet_db[9][0x113].len = 23;
  9706. // packet_db[9][0x116].len = 2;
  9707. packet_db[9][0x190].len = 26;
  9708. packet_db[9][0x193].len = 18;
  9709. // new packet
  9710. packet_db[9][0x20f].len = 10;
  9711. packet_db[9][0x210].len = 22;
  9712. packet_db[9][0x212].len = 26;
  9713. packet_db[9][0x213].len = 26;
  9714. packet_db[9][0x214].len = 42;
  9715. // init packet function calls for packet ver 10
  9716. memcpy(packet_db[10], packet_db[9], sizeof(packet_db[0]));
  9717. packet_db[10][0x072].func = clif_parse_UseItem;
  9718. packet_db[10][0x07e].func = clif_parse_MoveToKafra;
  9719. packet_db[10][0x085].func = clif_parse_ActionRequest;
  9720. packet_db[10][0x089].func = clif_parse_WalkToXY;
  9721. packet_db[10][0x08c].func = clif_parse_UseSkillToPos;
  9722. packet_db[10][0x094].func = clif_parse_DropItem;
  9723. packet_db[10][0x09b].func = clif_parse_GetCharNameRequest;
  9724. packet_db[10][0x09f].func = clif_parse_GlobalMessage;
  9725. packet_db[10][0x0a2].func = clif_parse_SolveCharName;
  9726. packet_db[10][0x0a7].func = clif_parse_UseSkillToPos;
  9727. packet_db[10][0x0f3].func = clif_parse_ChangeDir;
  9728. packet_db[10][0x0f5].func = clif_parse_WantToConnection;
  9729. packet_db[10][0x0f7].func = clif_parse_CloseKafra;
  9730. packet_db[10][0x113].func = clif_parse_TakeItem;
  9731. packet_db[10][0x116].func = clif_parse_TickSend;
  9732. packet_db[10][0x190].func = clif_parse_UseSkillToId;
  9733. packet_db[10][0x193].func = clif_parse_MoveFromKafra;
  9734. // size of packet version 10 (6sept04)
  9735. packet_db[10][0x072].len = 20;
  9736. packet_db[10][0x07e].len = 19;
  9737. packet_db[10][0x085].len = 23;
  9738. packet_db[10][0x089].len = 9;
  9739. packet_db[10][0x08c].len = 105;
  9740. packet_db[10][0x094].len = 17;
  9741. packet_db[10][0x09b].len = 14;
  9742. packet_db[10][0x09f].len = -1;
  9743. packet_db[10][0x0a2].len = 14;
  9744. packet_db[10][0x0a7].len = 25;
  9745. packet_db[10][0x0f3].len = 10;
  9746. packet_db[10][0x0f5].len = 34;
  9747. packet_db[10][0x0f7].len = 2;
  9748. packet_db[10][0x113].len = 11;
  9749. packet_db[10][0x116].len = 11;
  9750. packet_db[10][0x190].len = 22;
  9751. packet_db[10][0x193].len = 17;
  9752. // init packet function calls for packet ver 11 (same function of packet version 10, but size are different)
  9753. memcpy(packet_db[11], packet_db[10], sizeof(packet_db[0]));
  9754. // size of packet version 11 (21sept04)
  9755. packet_db[11][0x072].len = 18;
  9756. packet_db[11][0x07e].len = 25;
  9757. packet_db[11][0x085].len = 9;
  9758. packet_db[11][0x089].len = 14;
  9759. packet_db[11][0x08c].len = 109;
  9760. packet_db[11][0x094].len = 19;
  9761. packet_db[11][0x09b].len = 10;
  9762. // packet_db[11][0x09f].len = -1;
  9763. packet_db[11][0x0a2].len = 10;
  9764. packet_db[11][0x0a7].len = 29;
  9765. packet_db[11][0x0f3].len = 18;
  9766. packet_db[11][0x0f5].len = 32;
  9767. // packet_db[11][0x0f7].len = 2;
  9768. packet_db[11][0x113].len = 14;
  9769. packet_db[11][0x116].len = 14;
  9770. packet_db[11][0x190].len = 14;
  9771. packet_db[11][0x193].len = 12;
  9772. // init packet function calls for packet ver 12 (same function of packet version 11, but size are different)
  9773. memcpy(packet_db[12], packet_db[11], sizeof(packet_db[0]));
  9774. // size of packet version 12 (18oct04)
  9775. packet_db[12][0x072].len = 17;
  9776. packet_db[12][0x07e].len = 16;
  9777. // packet_db[12][0x085].len = 9;
  9778. packet_db[12][0x089].len = 6;
  9779. packet_db[12][0x08c].len = 103;
  9780. packet_db[12][0x094].len = 14;
  9781. packet_db[12][0x09b].len = 15;
  9782. // packet_db[12][0x09f].len = -1;
  9783. packet_db[12][0x0a2].len = 12;
  9784. packet_db[12][0x0a7].len = 23;
  9785. packet_db[12][0x0f3].len = 13;
  9786. packet_db[12][0x0f5].len = 33;
  9787. // packet_db[12][0x0f7].len = 2;
  9788. packet_db[12][0x113].len = 10;
  9789. packet_db[12][0x116].len = 10;
  9790. packet_db[12][0x190].len = 20;
  9791. packet_db[12][0x193].len = 26;
  9792. // init packet function calls for packet ver 13 (same function of packet version 12, but size are different)
  9793. memcpy(packet_db[13], packet_db[12], sizeof(packet_db[0]));
  9794. // size of packet version 13 (25oct04)
  9795. packet_db[13][0x072].len = 13;
  9796. packet_db[13][0x07e].len = 13;
  9797. packet_db[13][0x085].len = 15;
  9798. // packet_db[13][0x089].len = 6;
  9799. packet_db[13][0x08c].len = 108;
  9800. packet_db[13][0x094].len = 12;
  9801. packet_db[13][0x09b].len = 10;
  9802. // packet_db[13][0x09f].len = -1;
  9803. packet_db[13][0x0a2].len = 16;
  9804. packet_db[13][0x0a7].len = 28;
  9805. packet_db[13][0x0f3].len = 15;
  9806. packet_db[13][0x0f5].len = 29;
  9807. // packet_db[13][0x0f7].len = 2;
  9808. packet_db[13][0x113].len = 9;
  9809. packet_db[13][0x116].len = 9;
  9810. packet_db[13][0x190].len = 26;
  9811. packet_db[13][0x193].len = 22;
  9812. // init packet function calls for packet ver 14 (same function of packet version 13, but size are different)
  9813. memcpy(packet_db[14], packet_db[13], sizeof(packet_db[0]));
  9814. // size of packet version 14 - Added by nsstrunks (1nov04)
  9815. packet_db[14][0x072].len = 13;
  9816. packet_db[14][0x07e].len = 13;
  9817. packet_db[14][0x085].len = 15;
  9818. packet_db[14][0x089].len = 6;
  9819. packet_db[14][0x08c].len = 108;
  9820. packet_db[14][0x094].len = 12;
  9821. packet_db[14][0x09b].len = 10;
  9822. packet_db[14][0x09f].len = -1;
  9823. packet_db[14][0x0a2].len = 16;
  9824. packet_db[14][0x0a7].len = 28;
  9825. packet_db[14][0x0f3].len = 15;
  9826. packet_db[14][0x0f5].len = 29;
  9827. packet_db[14][0x113].len = 9;
  9828. packet_db[14][0x116].len = 9;
  9829. packet_db[14][0x190].len = 26;
  9830. packet_db[14][0x193].len = 22;
  9831. packet_db[14][0x215].len = 6;
  9832. packet_db[14][0x216].len = 6;
  9833. packet_db[14][0x217].len = 2;
  9834. packet_db[14][0x218].len = 2;
  9835. packet_db[14][0x219].len = 282;
  9836. packet_db[14][0x21a].len = 282;
  9837. packet_db[14][0x21b].len = 10;
  9838. packet_db[14][0x21c].len = 10;
  9839. // packet_db[14][0x143].len = 23; // is this required? uncomment if it is
  9840. // Init packet function calls for packet ver 15
  9841. memcpy(packet_db[15], packet_db[14], sizeof(packet_db[0]));
  9842. packet_db[15][0x072].func = clif_parse_UseSkillToId;
  9843. packet_db[15][0x07e].func = clif_parse_UseSkillToPos;
  9844. packet_db[15][0x089].func = clif_parse_TickSend;
  9845. packet_db[15][0x085].func = clif_parse_GlobalMessage;
  9846. packet_db[15][0x08c].func = clif_parse_GetCharNameRequest;
  9847. packet_db[15][0x094].func = clif_parse_MoveToKafra;
  9848. packet_db[15][0x09b].func = clif_parse_CloseKafra;
  9849. packet_db[15][0x09f].func = clif_parse_ActionRequest;
  9850. packet_db[15][0x0a2].func = clif_parse_TakeItem;
  9851. packet_db[15][0x0a7].func = clif_parse_WalkToXY;
  9852. packet_db[15][0x0f3].func = clif_parse_ChangeDir;
  9853. packet_db[15][0x0f5].func = clif_parse_WantToConnection;
  9854. packet_db[15][0x0f7].func = clif_parse_SolveCharName;
  9855. packet_db[15][0x113].func = clif_parse_UseSkillToPos;
  9856. packet_db[15][0x116].func = clif_parse_DropItem;
  9857. packet_db[15][0x190].func = clif_parse_UseItem;
  9858. packet_db[15][0x193].func = clif_parse_MoveFromKafra;
  9859. // Size of packet version 15 - Added by nsstrunks (6dec04)
  9860. packet_db[15][0x072].len = 22;
  9861. packet_db[15][0x07e].len = 30;
  9862. packet_db[15][0x094].len = 14;
  9863. packet_db[15][0x09f].len = 18;
  9864. packet_db[15][0x085].len = -1;
  9865. packet_db[15][0x08c].len = 13;
  9866. packet_db[15][0x089].len = 7;
  9867. packet_db[15][0x09b].len = 2;
  9868. packet_db[15][0x0a2].len = 7;
  9869. packet_db[15][0x0a7].len = 7;
  9870. packet_db[15][0x0f3].len = 8;
  9871. packet_db[15][0x0f5].len = 29;
  9872. packet_db[15][0x0f7].len = 14;
  9873. packet_db[15][0x113].len = 110;
  9874. packet_db[15][0x116].len = 12;
  9875. packet_db[15][0x190].len = 15;
  9876. packet_db[15][0x193].len = 21;
  9877. packet_db[15][0x21d].len = 6;
  9878. packet_db[15][0x222].len = 6;
  9879. packet_db[15][0x221].len = -1;
  9880. packet_db[15][0x223].len = 8;
  9881. // Init packet function calls for packet ver 16
  9882. memcpy(packet_db[16], packet_db[15], sizeof(packet_db[0]));
  9883. packet_db[16][0x072].func = clif_parse_UseSkillToId;
  9884. packet_db[16][0x07e].func = clif_parse_UseSkillToPos;
  9885. packet_db[16][0x089].func = clif_parse_TickSend;
  9886. packet_db[16][0x0f3].func = clif_parse_GlobalMessage;
  9887. packet_db[16][0x08c].func = clif_parse_GetCharNameRequest;
  9888. packet_db[16][0x094].func = clif_parse_MoveToKafra;
  9889. packet_db[16][0x193].func = clif_parse_CloseKafra;
  9890. packet_db[16][0x190].func = clif_parse_ActionRequest;
  9891. packet_db[16][0x0f5].func = clif_parse_TakeItem;
  9892. packet_db[16][0x0a7].func = clif_parse_WalkToXY;
  9893. packet_db[16][0x085].func = clif_parse_ChangeDir;
  9894. packet_db[16][0x09b].func = clif_parse_WantToConnection;
  9895. packet_db[16][0x0a2].func = clif_parse_SolveCharName;
  9896. packet_db[16][0x113].func = clif_parse_UseSkillToPos;
  9897. packet_db[16][0x116].func = clif_parse_DropItem;
  9898. packet_db[16][0x09f].func = clif_parse_UseItem;
  9899. packet_db[16][0x0f7].func = clif_parse_MoveFromKafra;
  9900. // Size of packet version 16 [10jan05]
  9901. packet_db[16][0x072].len = 26;
  9902. packet_db[16][0x07e].len = 114;
  9903. packet_db[16][0x089].len = 9;
  9904. packet_db[16][0x0f3].len = -1;
  9905. packet_db[16][0x08c].len = 8;
  9906. packet_db[16][0x094].len = 20;
  9907. packet_db[16][0x193].len = 2;
  9908. packet_db[16][0x190].len = 20;
  9909. packet_db[16][0x0f5].len = 9;
  9910. packet_db[16][0x0a7].len = 13;
  9911. packet_db[16][0x085].len = 23;
  9912. packet_db[16][0x09b].len = 32;
  9913. packet_db[16][0x0a2].len = 11;
  9914. packet_db[16][0x113].len = 34;
  9915. packet_db[16][0x116].len = 20;
  9916. packet_db[16][0x09f].len = 17;
  9917. packet_db[16][0x0f7].len = 21;
  9918. packet_db[16][0x143].len = 10;
  9919. // Init packet function calls for the packet_db.txt (17)
  9920. memcpy(packet_db[MAX_PACKET_VER], packet_db[MAX_PACKET_VER - 1], sizeof(packet_db[0]));
  9921. #endif
  9922. if (clif_config.enable_packet_db)
  9923. packetdb_readdb();
  9924. set_defaultparse(clif_parse);
  9925. #ifdef __WIN32
  9926. if (!make_listen_port(map_port)) {
  9927. printf("cant bind game port\n");
  9928. exit(1);
  9929. }
  9930. #else
  9931. for(i = 0; i < 10; i++) {
  9932. if (make_listen_port(map_port))
  9933. break;
  9934. sleep(20);
  9935. }
  9936. if (i == 10) {
  9937. printf("cant bind game port\n");
  9938. exit(1);
  9939. }
  9940. #endif
  9941. add_timer_func_list(clif_waitclose, "clif_waitclose");
  9942. add_timer_func_list(clif_clearchar_delay_sub, "clif_clearchar_delay_sub");
  9943. return 0;
  9944. }