clif.c 306 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446
  1. // $Id: clif.c 2200 2004-11-07 11:49:58Z Yor $
  2. #define DUMP_UNKNOWN_PACKET 1
  3. #define DUMP_ALL_PACKETS 0
  4. #include <stdio.h>
  5. #include <ctype.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <stdarg.h>
  9. #ifdef __WIN32
  10. #define __USE_W32_SOCKETS
  11. #include <windows.h>
  12. #else
  13. #include <unistd.h>
  14. #include <sys/types.h>
  15. #include <sys/socket.h>
  16. #include <netinet/in.h>
  17. #include <arpa/inet.h>
  18. #endif
  19. #include <time.h>
  20. #include "../common/socket.h"
  21. #include "../common/timer.h"
  22. #include "../common/malloc.h"
  23. #include "../common/version.h"
  24. #include "../common/nullpo.h"
  25. #include "../common/showmsg.h"
  26. #include "map.h"
  27. #include "chrif.h"
  28. #include "clif.h"
  29. #include "pc.h"
  30. #include "status.h"
  31. #include "npc.h"
  32. #include "itemdb.h"
  33. #include "chat.h"
  34. #include "trade.h"
  35. #include "storage.h"
  36. #include "script.h"
  37. #include "skill.h"
  38. #include "atcommand.h"
  39. #include "charcommand.h"
  40. #include "intif.h"
  41. #include "battle.h"
  42. #include "mob.h"
  43. #include "party.h"
  44. #include "guild.h"
  45. #include "vending.h"
  46. #include "pet.h"
  47. #ifdef MEMWATCH
  48. #include "memwatch.h"
  49. #endif
  50. #define STATE_BLIND 0x10
  51. struct Clif_Config clif_config;
  52. struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB];
  53. #define USE_PACKET_DB(sd) \
  54. clif_config.enable_packet_db && sd->packet_ver == clif_config.packet_db_ver
  55. #define IS_PACKET_DB_VER(cmd) \
  56. cmd == clif_config.connect_cmd
  57. static const int packet_len_table[MAX_PACKET_DB] = {
  58. 10, 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. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  61. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  62. //#0x0040
  63. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  64. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  65. 0, 0, 0, 0, 55, 17, 3, 37, 46, -1, 23, -1, 3,108, 3, 2,
  66. #if PACKETVER < 2
  67. 3, 28, 19, 11, 3, -1, 9, 5, 52, 51, 56, 58, 41, 2, 6, 6,
  68. #else // 78-7b 亀島以降 lv99エフェクト用
  69. 3, 28, 19, 11, 3, -1, 9, 5, 54, 53, 58, 60, 41, 2, 6, 6,
  70. #endif
  71. //#0x0080
  72. 7, 3, 2, 2, 2, 5, 16, 12, 10, 7, 29, 2, -1, -1, -1, 0, // 0x8b changed to 2 (was 23)
  73. 7, 22, 28, 2, 6, 30, -1, -1, 3, -1, -1, 5, 9, 17, 17, 6,
  74. 23, 6, 6, -1, -1, -1, -1, 8, 7, 6, 7, 4, 7, 0, -1, 6,
  75. 8, 8, 3, 3, -1, 6, 6, -1, 7, 6, 2, 5, 6, 44, 5, 3,
  76. //#0x00C0
  77. 7, 2, 6, 8, 6, 7, -1, -1, -1, -1, 3, 3, 6, 3, 2, 27, // 0xcd change to 3 (was 6)
  78. 3, 4, 4, 2, -1, -1, 3, -1, 6, 14, 3, -1, 28, 29, -1, -1,
  79. 30, 30, 26, 2, 6, 26, 3, 3, 8, 19, 5, 2, 3, 2, 2, 2,
  80. 3, 2, 6, 8, 21, 8, 8, 2, 2, 26, 3, -1, 6, 27, 30, 10,
  81. //#0x0100
  82. 2, 6, 6, 30, 79, 31, 10, 10, -1, -1, 4, 6, 6, 2, 11, -1,
  83. 10, 39, 4, 10, 31, 35, 10, 18, 2, 13, 15, 20, 68, 2, 3, 16,
  84. 6, 14, -1, -1, 21, 8, 8, 8, 8, 8, 2, 2, 3, 4, 2, -1,
  85. 6, 86, 6, -1, -1, 7, -1, 6, 3, 16, 4, 4, 4, 6, 24, 26,
  86. //#0x0140
  87. 22, 14, 6, 10, 23, 19, 6, 39, 8, 9, 6, 27, -1, 2, 6, 6,
  88. 110, 6, -1, -1, -1, -1, -1, 6, -1, 54, 66, 54, 90, 42, 6, 42,
  89. -1, -1, -1, -1, -1, 30, -1, 3, 14, 3, 30, 10, 43, 14,186,182,
  90. 14, 30, 10, 3, -1, 6,106, -1, 4, 5, 4, -1, 6, 7, -1, -1,
  91. //#0x0180
  92. 6, 3,106, 10, 10, 34, 0, 6, 8, 4, 4, 4, 29, -1, 10, 6,
  93. #if PACKETVER < 1
  94. 90, 86, 24, 6, 30,102, 8, 4, 8, 4, 14, 10, -1, 6, 2, 6,
  95. #else // 196 comodo以降 状態表示アイコン用
  96. 90, 86, 24, 6, 30,102, 9, 4, 8, 4, 14, 10, -1, 6, 2, 6,
  97. #endif
  98. 3, 3, 35, 5, 11, 26, -1, 4, 4, 6, 10, 12, 6, -1, 4, 4,
  99. 11, 7, -1, 67, 12, 18,114, 6, 3, 6, 26, 26, 26, 26, 2, 3,
  100. //#0x01C0, Set 0x1d5=-1
  101. 2, 14, 10, -1, 22, 22, 4, 2, 13, 97, 0, 9, 9, 30, 6, 28,
  102. 8, 14, 10, 35, 6, -1, 4, 11, 54, 53, 60, 2, -1, 47, 33, 6,
  103. 30, 8, 34, 14, 2, 6, 26, 2, 28, 81, 6, 10, 26, 2, -1, -1,
  104. -1, -1, 20, 10, 32, 9, 34, 14, 2, 6, 48, 56, -1, 4, 5, 10,
  105. //#0x200
  106. 26, -1, 26, 10, 18, 26, 11, 34, 14, 36, 10, 0, 0, -1, 24, 0, // 0x20c change to 0 (was 19)
  107. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  108. 0, 0, 0, 0
  109. };
  110. // local define
  111. enum {
  112. ALL_CLIENT,
  113. ALL_SAMEMAP,
  114. AREA,
  115. AREA_WOS,
  116. AREA_WOC,
  117. AREA_WOSC,
  118. AREA_CHAT_WOC,
  119. CHAT,
  120. CHAT_WOS,
  121. PARTY,
  122. PARTY_WOS,
  123. PARTY_SAMEMAP,
  124. PARTY_SAMEMAP_WOS,
  125. PARTY_AREA,
  126. PARTY_AREA_WOS,
  127. GUILD,
  128. GUILD_WOS,
  129. GUILD_SAMEMAP, // [Valaris]
  130. GUILD_SAMEMAP_WOS,
  131. GUILD_AREA,
  132. GUILD_AREA_WOS, // end additions [Valaris]
  133. SELF
  134. };
  135. #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; }
  136. #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); }
  137. #define WFIFOPOS(fd,pos,x,y) { WBUFPOS (WFIFOP(fd,pos),0,x,y); }
  138. #define WFIFOPOS2(fd,pos,x0,y0,x1,y1) { WBUFPOS2(WFIFOP(fd,pos),0,x0,y0,x1,y1); }
  139. static char map_ip_str[16];
  140. static in_addr_t map_ip;
  141. static in_addr_t bind_ip = INADDR_ANY;
  142. static int map_port = 5121;
  143. int map_fd;
  144. char talkie_mes[80];
  145. /*==========================================
  146. * map鯖のip設定
  147. *------------------------------------------
  148. */
  149. void clif_setip(char *ip)
  150. {
  151. memcpy(map_ip_str, ip, 16);
  152. map_ip = inet_addr(map_ip_str);
  153. }
  154. void clif_setbindip(char *ip)
  155. {
  156. bind_ip = inet_addr(ip);
  157. }
  158. /*==========================================
  159. * map鯖のport設定
  160. *------------------------------------------
  161. */
  162. void clif_setport(int port)
  163. {
  164. map_port = port;
  165. }
  166. /*==========================================
  167. * map鯖のip読み出し
  168. *------------------------------------------
  169. */
  170. in_addr_t clif_getip(void)
  171. {
  172. return map_ip;
  173. }
  174. /*==========================================
  175. * map鯖のport読み出し
  176. *------------------------------------------
  177. */
  178. int clif_getport(void)
  179. {
  180. return map_port;
  181. }
  182. /*==========================================
  183. *
  184. *------------------------------------------
  185. */
  186. int clif_countusers(void)
  187. {
  188. int users = 0, i;
  189. struct map_session_data *sd;
  190. for(i = 0; i < fd_max; i++) {
  191. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd && sd->state.auth &&
  192. !(battle_config.hide_GM_session && pc_isGM(sd)))
  193. users++;
  194. }
  195. return users;
  196. }
  197. /*==========================================
  198. * 全てのclientに対してfunc()実行
  199. *------------------------------------------
  200. */
  201. int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...)
  202. {
  203. int i;
  204. va_list ap;
  205. struct map_session_data *sd;
  206. va_start(ap,func);
  207. for(i = 0; i < fd_max; i++) {
  208. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd && sd->state.auth)
  209. func(sd, ap);
  210. }
  211. va_end(ap);
  212. return 0;
  213. }
  214. /*==========================================
  215. * clif_sendでAREA*指定時用
  216. *------------------------------------------
  217. */
  218. int clif_send_sub(struct block_list *bl, va_list ap)
  219. {
  220. unsigned char *buf;
  221. int len;
  222. struct block_list *src_bl;
  223. int type;
  224. struct map_session_data *sd;
  225. nullpo_retr(0, bl);
  226. nullpo_retr(0, ap);
  227. nullpo_retr(0, sd = (struct map_session_data *)bl);
  228. buf = va_arg(ap,unsigned char*);
  229. len = va_arg(ap,int);
  230. nullpo_retr(0, src_bl = va_arg(ap,struct block_list*));
  231. type = va_arg(ap,int);
  232. switch(type) {
  233. case AREA_WOS:
  234. if (bl && bl == src_bl)
  235. return 0;
  236. break;
  237. case AREA_WOC:
  238. if ((sd && sd->chatID) || (bl && bl == src_bl))
  239. return 0;
  240. break;
  241. case AREA_WOSC:
  242. if ((sd) && sd->chatID && sd->chatID == ((struct map_session_data*)src_bl)->chatID)
  243. return 0;
  244. break;
  245. }
  246. if ((sd != NULL) && (session[sd->fd] != NULL)) {
  247. if (WFIFOP(sd->fd,0) == buf) {
  248. printf("WARNING: Invalid use of clif_send function\n");
  249. printf(" Packet x%4x use a WFIFO of a player instead of to use a buffer.\n", WBUFW(buf,0));
  250. printf(" Please correct your code.\n");
  251. // don't send to not move the pointer of the packet for next sessions in the loop
  252. } else {
  253. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  254. memcpy(WFIFOP(sd->fd,0), buf, len);
  255. WFIFOSET(sd->fd,len);
  256. }
  257. }
  258. }
  259. return 0;
  260. }
  261. /*==========================================
  262. *
  263. *------------------------------------------
  264. */
  265. int clif_send(unsigned char *buf, int len, struct block_list *bl, int type) {
  266. int i;
  267. struct map_session_data *sd = NULL;
  268. struct party *p = NULL;
  269. struct guild *g = NULL;
  270. int x0 = 0, x1 = 0, y0 = 0, y1 = 0;
  271. if (type != ALL_CLIENT) {
  272. nullpo_retr(0, bl);
  273. }
  274. if (bl && bl->type == BL_PC) {
  275. nullpo_retr (0, sd=(struct map_session_data*)bl);
  276. }
  277. switch(type) {
  278. case ALL_CLIENT: // 全クライアントに送信
  279. for(i = 0; i < fd_max; i++) {
  280. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth) {
  281. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  282. memcpy(WFIFOP(i,0), buf, len);
  283. WFIFOSET(i,len);
  284. }
  285. }
  286. }
  287. break;
  288. case ALL_SAMEMAP: // 同じマップの全クライアントに送信
  289. for(i = 0; i < fd_max; i++) {
  290. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth && sd->bl.m == bl->m) {
  291. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  292. memcpy(WFIFOP(i,0), buf, len);
  293. WFIFOSET(i,len);
  294. }
  295. }
  296. }
  297. break;
  298. case AREA:
  299. case AREA_WOS:
  300. case AREA_WOC:
  301. case AREA_WOSC:
  302. 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);
  303. break;
  304. case AREA_CHAT_WOC:
  305. 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);
  306. break;
  307. case CHAT:
  308. case CHAT_WOS:
  309. {
  310. struct chat_data *cd;
  311. if (sd) {
  312. cd = (struct chat_data*)map_id2bl(sd->chatID);
  313. } else if (bl->type == BL_CHAT) {
  314. cd = (struct chat_data*)bl;
  315. } else if (bl->type != BL_CHAT)
  316. break;
  317. if (cd == NULL)
  318. break;
  319. for(i = 0; i < cd->users; i++) {
  320. if (type == CHAT_WOS && cd->usersd[i] == sd)
  321. continue;
  322. if (packet_db[cd->usersd[i]->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  323. if (cd->usersd[i]->fd >=0 && session[cd->usersd[i]->fd]) // Added check to see if session exists [PoW]
  324. memcpy(WFIFOP(cd->usersd[i]->fd,0), buf, len);
  325. WFIFOSET(cd->usersd[i]->fd,len);
  326. }
  327. }
  328. }
  329. break;
  330. case PARTY_AREA: // 同じ画面内の全パーティーメンバに送信
  331. case PARTY_AREA_WOS: // 自分以外の同じ画面内の全パーティーメンバに送信
  332. x0 = bl->x - AREA_SIZE;
  333. y0 = bl->y - AREA_SIZE;
  334. x1 = bl->x + AREA_SIZE;
  335. y1 = bl->y + AREA_SIZE;
  336. case PARTY: // 全パーティーメンバに送信
  337. case PARTY_WOS: // 自分以外の全パーティーメンバに送信
  338. case PARTY_SAMEMAP: // 同じマップの全パーティーメンバに送信
  339. case PARTY_SAMEMAP_WOS: // 自分以外の同じマップの全パーティーメンバに送信
  340. if (sd) {
  341. if (sd->partyspy > 0) {
  342. p = party_search(sd->partyspy);
  343. } else if (sd->status.party_id > 0) {
  344. p = party_search(sd->status.party_id);
  345. }
  346. }
  347. if (p) {
  348. for(i=0;i<MAX_PARTY;i++){
  349. if ((sd = p->member[i].sd) != NULL) {
  350. if ((session[sd->fd] == NULL) || (session[sd->fd]->session_data == NULL))
  351. continue;
  352. if (sd->bl.id == bl->id && (type == PARTY_WOS ||
  353. type == PARTY_SAMEMAP_WOS || type == PARTY_AREA_WOS))
  354. continue;
  355. if (type != PARTY && type != PARTY_WOS && bl->m != sd->bl.m) // マップチェック
  356. continue;
  357. if ((type == PARTY_AREA || type == PARTY_AREA_WOS) &&
  358. (sd->bl.x < x0 || sd->bl.y < y0 ||
  359. sd->bl.x > x1 || sd->bl.y > y1))
  360. continue;
  361. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  362. memcpy(WFIFOP(sd->fd,0), buf, len);
  363. WFIFOSET(sd->fd,len);
  364. }
  365. // if(battle_config.etc_log)
  366. // printf("send party %d %d %d\n",p->party_id,i,flag)
  367. }
  368. }
  369. for (i = 0; i < fd_max; i++){
  370. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth) {
  371. if (sd->partyspy == p->party_id) {
  372. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  373. memcpy(WFIFOP(sd->fd,0), buf, len);
  374. WFIFOSET(sd->fd,len);
  375. }
  376. }
  377. }
  378. }
  379. }
  380. break;
  381. case SELF:
  382. if (sd && packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  383. memcpy(WFIFOP(sd->fd,0), buf, len);
  384. WFIFOSET(sd->fd,len);
  385. }
  386. break;
  387. /* New definitions for guilds [Valaris] */
  388. case GUILD_AREA:
  389. case GUILD_AREA_WOS:
  390. x0 = bl->x - AREA_SIZE;
  391. y0 = bl->y - AREA_SIZE;
  392. x1 = bl->x + AREA_SIZE;
  393. y1 = bl->y + AREA_SIZE;
  394. case GUILD:
  395. case GUILD_WOS:
  396. if (sd) { // guildspy [Syrus22]
  397. if (sd->guildspy > 0) {
  398. g = guild_search(sd->guildspy);
  399. } else if (sd->status.guild_id > 0) {
  400. g = guild_search(sd->status.guild_id);
  401. }
  402. }
  403. if (g) {
  404. for(i = 0; i < g->max_member; i++) {
  405. if ((sd = g->member[i].sd) != NULL) {
  406. if (type == GUILD_WOS && sd->bl.id == bl->id)
  407. continue;
  408. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  409. memcpy(WFIFOP(sd->fd,0), buf, len);
  410. WFIFOSET(sd->fd,len);
  411. }
  412. }
  413. }
  414. for (i = 0; i < fd_max; i++){
  415. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth) {
  416. if (sd->guildspy == g->guild_id) {
  417. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  418. memcpy(WFIFOP(sd->fd,0), buf, len);
  419. WFIFOSET(sd->fd,len);
  420. }
  421. }
  422. }
  423. }
  424. }
  425. break;
  426. case GUILD_SAMEMAP:
  427. case GUILD_SAMEMAP_WOS:
  428. if (sd && sd->status.guild_id > 0) {
  429. g = guild_search(sd->status.guild_id);
  430. }
  431. if (g) {
  432. for(i = 0; i < g->max_member; i++) {
  433. if ((sd = g->member[i].sd) != NULL) {
  434. if (sd->bl.id == bl->id && (type == GUILD_WOS ||
  435. type == GUILD_SAMEMAP_WOS || type == GUILD_AREA_WOS))
  436. continue;
  437. if (type != GUILD && type != GUILD_WOS && bl->m != sd->bl.m) // マップチェック
  438. continue;
  439. if ((type == GUILD_AREA || type == GUILD_AREA_WOS) &&
  440. (sd->bl.x < x0 || sd->bl.y < y0 ||
  441. sd->bl.x > x1 || sd->bl.y > y1))
  442. continue;
  443. if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
  444. memcpy(WFIFOP(sd->fd,0), buf, len);
  445. WFIFOSET(sd->fd,len);
  446. }
  447. }
  448. }
  449. }
  450. break;
  451. /* End [Valaris] */
  452. default:
  453. if (battle_config.error_log)
  454. printf("clif_send まだ作ってないよー\n");
  455. return -1;
  456. }
  457. return 0;
  458. }
  459. //
  460. // パケット作って送信
  461. //
  462. /*==========================================
  463. *
  464. *------------------------------------------
  465. */
  466. int clif_authok(struct map_session_data *sd) {
  467. int fd;
  468. nullpo_retr(0, sd);
  469. if (!sd)
  470. return 0;
  471. if (!sd->fd)
  472. return 0;
  473. fd = sd->fd;
  474. WFIFOW(fd, 0) = 0x73;
  475. WFIFOL(fd, 2) = gettick();
  476. WFIFOPOS(fd, 6, sd->bl.x, sd->bl.y);
  477. WFIFOB(fd, 9) = 5;
  478. WFIFOB(fd,10) = 5;
  479. WFIFOSET(fd,packet_len_table[0x73]);
  480. return 0;
  481. }
  482. /*==========================================
  483. *
  484. *------------------------------------------
  485. */
  486. int clif_authfail_fd(int fd, int type) {
  487. if (!fd || !session[fd])
  488. return 0;
  489. WFIFOW(fd,0) = 0x81;
  490. WFIFOL(fd,2) = type;
  491. WFIFOSET(fd,packet_len_table[0x81]);
  492. clif_setwaitclose(fd);
  493. return 0;
  494. }
  495. /*==========================================
  496. *
  497. *------------------------------------------
  498. */
  499. int clif_charselectok(int id) {
  500. struct map_session_data *sd;
  501. int fd;
  502. if ((sd = map_id2sd(id)) == NULL)
  503. return 1;
  504. if (!sd->fd)
  505. return 1;
  506. fd = sd->fd;
  507. WFIFOW(fd,0) = 0xb3;
  508. WFIFOB(fd,2) = 1;
  509. WFIFOSET(fd,packet_len_table[0xb3]);
  510. return 0;
  511. }
  512. /*==========================================
  513. *
  514. *------------------------------------------
  515. */
  516. static int clif_set009e(struct flooritem_data *fitem,unsigned char *buf) {
  517. int view;
  518. nullpo_retr(0, fitem);
  519. //009e <ID>.l <name ID>.w <identify flag>.B <X>.w <Y>.w <subX>.B <subY>.B <amount>.w
  520. WBUFW(buf, 0) = 0x9e;
  521. WBUFL(buf, 2) = fitem->bl.id;
  522. if ((view = itemdb_viewid(fitem->item_data.nameid)) > 0)
  523. WBUFW(buf, 6) = view;
  524. else
  525. WBUFW(buf, 6) = fitem->item_data.nameid;
  526. WBUFB(buf, 8) = fitem->item_data.identify;
  527. WBUFW(buf, 9) = fitem->bl.x;
  528. WBUFW(buf,11) = fitem->bl.y;
  529. WBUFB(buf,13) = fitem->subx;
  530. WBUFB(buf,14) = fitem->suby;
  531. WBUFW(buf,15) = fitem->item_data.amount;
  532. return packet_len_table[0x9e];
  533. }
  534. /*==========================================
  535. *
  536. *------------------------------------------
  537. */
  538. int clif_dropflooritem(struct flooritem_data *fitem) {
  539. unsigned char buf[64];
  540. nullpo_retr(0, fitem);
  541. if (fitem->item_data.nameid <= 0)
  542. return 0;
  543. clif_set009e(fitem, buf);
  544. clif_send(buf, packet_len_table[0x9e], &fitem->bl, AREA);
  545. return 0;
  546. }
  547. /*==========================================
  548. *
  549. *------------------------------------------
  550. */
  551. int clif_clearflooritem(struct flooritem_data *fitem, int fd) {
  552. unsigned char buf[16];
  553. nullpo_retr(0, fitem);
  554. WBUFW(buf,0) = 0xa1;
  555. WBUFL(buf,2) = fitem->bl.id;
  556. if (fd == 0) {
  557. clif_send(buf, packet_len_table[0xa1], &fitem->bl, AREA);
  558. } else {
  559. memcpy(WFIFOP(fd,0), buf, 6);
  560. WFIFOSET(fd,packet_len_table[0xa1]);
  561. }
  562. return 0;
  563. }
  564. /*==========================================
  565. *
  566. *------------------------------------------
  567. */
  568. int clif_clearchar(struct block_list *bl, int type) {
  569. unsigned char buf[16];
  570. nullpo_retr(0, bl);
  571. WBUFW(buf,0) = 0x80;
  572. WBUFL(buf,2) = bl->id;
  573. if (type == 9) {
  574. WBUFB(buf,6) = 0;
  575. clif_send(buf, packet_len_table[0x80], bl, AREA);
  576. } else {
  577. WBUFB(buf,6) = type;
  578. clif_send(buf, packet_len_table[0x80], bl, type == 1 ? AREA : AREA_WOS);
  579. }
  580. return 0;
  581. }
  582. static int clif_clearchar_delay_sub(int tid, unsigned int tick, int id, int data) {
  583. struct block_list *bl = (struct block_list *)id;
  584. clif_clearchar(bl,data);
  585. map_freeblock(bl);
  586. return 0;
  587. }
  588. int clif_clearchar_delay(unsigned int tick, struct block_list *bl, int type) {
  589. struct block_list *tmpbl;
  590. tmpbl = (struct block_list*)aCalloc(1, sizeof(struct block_list));
  591. memcpy(tmpbl, bl, sizeof(struct block_list));
  592. add_timer(tick, clif_clearchar_delay_sub, (int)tmpbl, type);
  593. return 0;
  594. }
  595. /*==========================================
  596. *
  597. *------------------------------------------
  598. */
  599. int clif_clearchar_id(int id, int type, int fd) {
  600. unsigned char buf[16];
  601. WBUFW(buf,0) = 0x80;
  602. WBUFL(buf,2) = id;
  603. WBUFB(buf,6) = type;
  604. memcpy(WFIFOP(fd,0), buf, 7);
  605. WFIFOSET(fd, packet_len_table[0x80]);
  606. return 0;
  607. }
  608. /*==========================================
  609. *
  610. *------------------------------------------
  611. */
  612. static int clif_set0078(struct map_session_data *sd, unsigned char *buf) {
  613. int level;
  614. nullpo_retr(0, sd);
  615. if (sd->disguise > 23 && sd->disguise < 4001) { // mob disguises [Valaris]
  616. WBUFW(buf,0) = 0x78;
  617. WBUFL(buf,2) = sd->bl.id;
  618. WBUFW(buf,6) = status_get_speed(&sd->bl);
  619. WBUFW(buf,8) = sd->opt1;
  620. WBUFW(buf,10) = sd->opt2;
  621. WBUFW(buf,12) = sd->status.option;
  622. WBUFW(buf,14) = sd->disguise;
  623. WBUFW(buf,42) = 0;
  624. WBUFB(buf,44) = 0;
  625. WBUFPOS(buf, 46, sd->bl.x, sd->bl.y);
  626. WBUFB(buf,48) |= sd->dir & 0x0f;
  627. WBUFB(buf,49) = 5;
  628. WBUFB(buf,50) = 5;
  629. WBUFB(buf,51) = 0;
  630. WBUFW(buf,52) = ((level = status_get_lv(&sd->bl)) > battle_config.max_lv) ? battle_config.max_lv : level;
  631. return packet_len_table[0x78];
  632. }
  633. #if PACKETVER < 4
  634. WBUFW(buf,0)= 0x78;
  635. WBUFL(buf,2)= sd->bl.id;
  636. WBUFW(buf,6)= sd->speed;
  637. WBUFW(buf,8)= sd->opt1;
  638. WBUFW(buf,10)= sd->opt2;
  639. WBUFW(buf,12)= sd->status.option;
  640. WBUFW(buf,14)= sd->view_class;
  641. WBUFW(buf,16)= sd->status.hair;
  642. if (sd->view_class != 22)
  643. WBUFW(buf,18) = sd->status.weapon;
  644. else
  645. WBUFW(buf,18)=0;
  646. WBUFW(buf,20)=sd->status.head_bottom;
  647. WBUFW(buf,22)=sd->status.shield;
  648. WBUFW(buf,24)=sd->status.head_top;
  649. WBUFW(buf,26)=sd->status.head_mid;
  650. WBUFW(buf,28)=sd->status.hair_color;
  651. WBUFW(buf,30)=sd->status.clothes_color;
  652. WBUFW(buf,32)=sd->head_dir;
  653. WBUFL(buf,34)=sd->status.guild_id;
  654. WBUFL(buf,38)=sd->guild_emblem_id;
  655. WBUFW(buf,42)=sd->status.manner;
  656. WBUFB(buf,44)=sd->status.karma;
  657. WBUFB(buf,45)=sd->sex;
  658. WBUFPOS(buf,46,sd->bl.x,sd->bl.y);
  659. WBUFB(buf,48)|=sd->dir&0x0f;
  660. WBUFB(buf,49)=5;
  661. WBUFB(buf,50)=5;
  662. WBUFB(buf,51)=sd->state.dead_sit;
  663. WBUFW(buf,52)=(sd->status.base_level>battle_config.max_lv)?battle_config.max_lv:sd->status.base_level;
  664. return packet_len_table[0x78];
  665. #else
  666. WBUFW(buf,0) = 0x1d8;
  667. WBUFL(buf,2) = sd->bl.id;
  668. WBUFW(buf,6) = sd->speed;
  669. WBUFW(buf,8) = sd->opt1;
  670. WBUFW(buf,10) = sd->opt2;
  671. WBUFW(buf,12) = sd->status.option;
  672. WBUFW(buf,14) = sd->view_class;
  673. WBUFW(buf,16) = sd->status.hair;
  674. if (sd->equip_index[9] >= 0 && sd->inventory_data[sd->equip_index[9]] && sd->view_class != 22) {
  675. if (sd->inventory_data[sd->equip_index[9]]->view_id > 0)
  676. WBUFW(buf,18) = sd->inventory_data[sd->equip_index[9]]->view_id;
  677. else
  678. WBUFW(buf,18) = sd->status.inventory[sd->equip_index[9]].nameid;
  679. } else
  680. WBUFW(buf,18) = 0;
  681. 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) {
  682. if (sd->inventory_data[sd->equip_index[8]]->view_id > 0)
  683. WBUFW(buf,20) = sd->inventory_data[sd->equip_index[8]]->view_id;
  684. else
  685. WBUFW(buf,20) = sd->status.inventory[sd->equip_index[8]].nameid;
  686. } else
  687. WBUFW(buf,20) = 0;
  688. WBUFW(buf,22) = sd->status.head_bottom;
  689. WBUFW(buf,24) = sd->status.head_top;
  690. WBUFW(buf,26) = sd->status.head_mid;
  691. WBUFW(buf,28) = sd->status.hair_color;
  692. WBUFW(buf,30) = sd->status.clothes_color;
  693. WBUFW(buf,32) = sd->head_dir;
  694. WBUFL(buf,34) = sd->status.guild_id;
  695. WBUFW(buf,38) = sd->guild_emblem_id;
  696. WBUFW(buf,40) = sd->status.manner;
  697. WBUFW(buf,42)=sd->opt3;
  698. WBUFB(buf,44) = sd->status.karma;
  699. WBUFB(buf,45) = sd->sex;
  700. WBUFPOS(buf, 46, sd->bl.x, sd->bl.y);
  701. WBUFB(buf,48) |= sd->dir & 0x0f;
  702. WBUFB(buf,49) = 5;
  703. WBUFB(buf,50) = 5;
  704. WBUFB(buf,51) = sd->state.dead_sit;
  705. WBUFW(buf,52) = ((level = status_get_lv(&sd->bl)) > battle_config.max_lv) ? battle_config.max_lv : level;
  706. return packet_len_table[0x1d8];
  707. #endif
  708. }
  709. /*==========================================
  710. *
  711. *------------------------------------------
  712. */
  713. static int clif_set007b(struct map_session_data *sd,unsigned char *buf) {
  714. int level;
  715. nullpo_retr(0, sd);
  716. if (sd->disguise > 23 && sd->disguise < 4001) { // mob disguises [Valaris]
  717. WBUFW(buf,0)=0x7b;
  718. WBUFL(buf,2)=sd->bl.id;
  719. WBUFW(buf,6)=status_get_speed(&sd->bl);
  720. WBUFW(buf,8)=sd->opt1;
  721. WBUFW(buf,10)=sd->opt2;
  722. WBUFW(buf,12)=sd->status.option;
  723. WBUFW(buf,14)=sd->disguise;
  724. WBUFL(buf,22)=gettick();
  725. WBUFW(buf,46)=0;
  726. WBUFB(buf,48)=0;
  727. WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->to_x,sd->to_y);
  728. WBUFB(buf,55)=0;
  729. WBUFB(buf,56)=5;
  730. WBUFB(buf,57)=5;
  731. WBUFW(buf,58)=((level = status_get_lv(&sd->bl))>battle_config.max_lv)? battle_config.max_lv:level;
  732. return packet_len_table[0x7b];
  733. }
  734. #if PACKETVER < 4
  735. WBUFW(buf,0)=0x7b;
  736. WBUFL(buf,2)=sd->bl.id;
  737. WBUFW(buf,6)=sd->speed;
  738. WBUFW(buf,8)=sd->opt1;
  739. WBUFW(buf,10)=sd->opt2;
  740. WBUFW(buf,12)=sd->status.option;
  741. WBUFW(buf,14)=sd->view_class;
  742. WBUFW(buf,16)=sd->status.hair;
  743. if(sd->view_class != 22)
  744. WBUFW(buf,18)=sd->status.weapon;
  745. else
  746. WBUFW(buf,18)=0;
  747. WBUFW(buf,20)=sd->status.head_bottom;
  748. WBUFL(buf,22)=gettick();
  749. WBUFW(buf,26)=sd->status.shield;
  750. WBUFW(buf,28)=sd->status.head_top;
  751. WBUFW(buf,30)=sd->status.head_mid;
  752. WBUFW(buf,32)=sd->status.hair_color;
  753. WBUFW(buf,34)=sd->status.clothes_color;
  754. WBUFW(buf,36)=sd->head_dir;
  755. WBUFL(buf,38)=sd->status.guild_id;
  756. WBUFL(buf,42)=sd->guild_emblem_id;
  757. WBUFW(buf,46)=sd->status.manner;
  758. WBUFB(buf,48)=sd->status.karma;
  759. WBUFB(buf,49)=sd->sex;
  760. WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->to_x,sd->to_y);
  761. WBUFB(buf,55)=0;
  762. WBUFB(buf,56)=5;
  763. WBUFB(buf,57)=5;
  764. WBUFW(buf,58)=(sd->status.base_level>battle_config.max_lv)?battle_config.max_lv:sd->status.base_level;
  765. return packet_len_table[0x7b];
  766. #else
  767. WBUFW(buf,0)=0x1da;
  768. WBUFL(buf,2)=sd->bl.id;
  769. WBUFW(buf,6)=sd->speed;
  770. WBUFW(buf,8)=sd->opt1;
  771. WBUFW(buf,10)=sd->opt2;
  772. WBUFW(buf,12)=sd->status.option;
  773. WBUFW(buf,14)=sd->view_class;
  774. WBUFW(buf,16)=sd->status.hair;
  775. if(sd->equip_index[9] >= 0 && sd->inventory_data[sd->equip_index[9]] && sd->view_class != 22) {
  776. if(sd->inventory_data[sd->equip_index[9]]->view_id > 0)
  777. WBUFW(buf,18)=sd->inventory_data[sd->equip_index[9]]->view_id;
  778. else
  779. WBUFW(buf,18)=sd->status.inventory[sd->equip_index[9]].nameid;
  780. }
  781. else
  782. WBUFW(buf,18)=0;
  783. 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) {
  784. if(sd->inventory_data[sd->equip_index[8]]->view_id > 0)
  785. WBUFW(buf,20)=sd->inventory_data[sd->equip_index[8]]->view_id;
  786. else
  787. WBUFW(buf,20)=sd->status.inventory[sd->equip_index[8]].nameid;
  788. }
  789. else
  790. WBUFW(buf,20)=0;
  791. WBUFW(buf,22)=sd->status.head_bottom;
  792. WBUFL(buf,24)=gettick();
  793. WBUFW(buf,28)=sd->status.head_top;
  794. WBUFW(buf,30)=sd->status.head_mid;
  795. WBUFW(buf,32)=sd->status.hair_color;
  796. WBUFW(buf,34)=sd->status.clothes_color;
  797. WBUFW(buf,36)=sd->head_dir;
  798. WBUFL(buf,38)=sd->status.guild_id;
  799. WBUFW(buf,42)=sd->guild_emblem_id;
  800. WBUFW(buf,44)=sd->status.manner;
  801. WBUFW(buf,46)=sd->opt3;
  802. WBUFB(buf,48)=sd->status.karma;
  803. WBUFB(buf,49)=sd->sex;
  804. WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->to_x,sd->to_y);
  805. WBUFB(buf,55)=0;
  806. WBUFB(buf,56)=5;
  807. WBUFB(buf,57)=5;
  808. WBUFW(buf,58)=(sd->status.base_level>battle_config.max_lv)?battle_config.max_lv:sd->status.base_level;
  809. return packet_len_table[0x1da];
  810. #endif
  811. }
  812. /*==========================================
  813. * クラスチェンジ typeはMobの場合は1で他は0?
  814. *------------------------------------------
  815. */
  816. int clif_class_change(struct block_list *bl,int class_,int type)
  817. {
  818. unsigned char buf[16];
  819. nullpo_retr(0, bl);
  820. if(class_ >= MAX_PC_CLASS) {
  821. WBUFW(buf,0)=0x1b0;
  822. WBUFL(buf,2)=bl->id;
  823. WBUFB(buf,6)=type;
  824. WBUFL(buf,7)=class_;
  825. clif_send(buf,packet_len_table[0x1b0],bl,AREA);
  826. }
  827. return 0;
  828. }
  829. /*==========================================
  830. *
  831. *------------------------------------------
  832. */
  833. int clif_mob_class_change(struct mob_data *md, int class_) {
  834. unsigned char buf[16];
  835. int view = mob_get_viewclass(class_);
  836. nullpo_retr(0, md);
  837. if(view >= MAX_PC_CLASS) {
  838. WBUFW(buf,0)=0x1b0;
  839. WBUFL(buf,2)=md->bl.id;
  840. WBUFB(buf,6)=1;
  841. WBUFL(buf,7)=view;
  842. clif_send(buf,packet_len_table[0x1b0],&md->bl,AREA);
  843. }
  844. return 0;
  845. }
  846. // mob equipment [Valaris]
  847. int clif_mob_equip(struct mob_data *md, int nameid) {
  848. unsigned char buf[16];
  849. nullpo_retr(0, md);
  850. memset(buf,0,packet_len_table[0x1a4]);
  851. WBUFW(buf,0)=0x1a4;
  852. WBUFB(buf,2)=3;
  853. WBUFL(buf,3)=md->bl.id;
  854. WBUFL(buf,7)=nameid;
  855. clif_send(buf,packet_len_table[0x1a4],&md->bl,AREA);
  856. return 0;
  857. }
  858. /*==========================================
  859. * MOB表示1
  860. *------------------------------------------
  861. */
  862. static int clif_mob0078(struct mob_data *md, unsigned char *buf)
  863. {
  864. int level;
  865. memset(buf,0,packet_len_table[0x78]);
  866. nullpo_retr(0, md);
  867. WBUFW(buf,0)=0x78;
  868. WBUFL(buf,2)=md->bl.id;
  869. WBUFW(buf,6)=status_get_speed(&md->bl);
  870. WBUFW(buf,8)=md->opt1;
  871. WBUFW(buf,10)=md->opt2;
  872. WBUFW(buf,12)=md->option;
  873. WBUFW(buf,14)=mob_get_viewclass(md->class_);
  874. if((mob_get_viewclass(md->class_) <= 23) || (mob_get_viewclass(md->class_) == 812) || (mob_get_viewclass(md->class_) >= 4001)) {
  875. WBUFW(buf,12)|=mob_db[md->class_].option;
  876. WBUFW(buf,16)=mob_get_hair(md->class_);
  877. WBUFW(buf,18)=mob_get_weapon(md->class_);
  878. WBUFW(buf,20)=mob_get_head_buttom(md->class_);
  879. WBUFW(buf,22)=mob_get_shield(md->class_);
  880. WBUFW(buf,24)=mob_get_head_top(md->class_);
  881. WBUFW(buf,26)=mob_get_head_mid(md->class_);
  882. WBUFW(buf,28)=mob_get_hair_color(md->class_);
  883. WBUFW(buf,30)=mob_get_clothes_color(md->class_); //Add for player monster dye - Valaris
  884. WBUFB(buf,45)=mob_get_sex(md->class_);
  885. }
  886. if (md->class_ >= 1285 && md->class_ <= 1287 && md->guild_id) { // Added guardian emblems [Valaris]
  887. struct guild *g;
  888. struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name);
  889. if (gc && gc->guild_id > 0) {
  890. g=guild_search(gc->guild_id);
  891. if (g) {
  892. WBUFL(buf,22)=g->emblem_id;
  893. WBUFL(buf,26)=gc->guild_id;
  894. }
  895. }
  896. } // End addition
  897. WBUFPOS(buf,46,md->bl.x,md->bl.y);
  898. WBUFB(buf,48)|=md->dir&0x0f;
  899. WBUFB(buf,49)=5;
  900. WBUFB(buf,50)=5;
  901. WBUFW(buf,52)=((level = status_get_lv(&md->bl))>battle_config.max_lv)? battle_config.max_lv:level;
  902. return packet_len_table[0x78];
  903. }
  904. /*==========================================
  905. * MOB表示2
  906. *------------------------------------------
  907. */
  908. static int clif_mob007b(struct mob_data *md, unsigned char *buf) {
  909. int level;
  910. memset(buf,0,packet_len_table[0x7b]);
  911. nullpo_retr(0, md);
  912. WBUFW(buf,0)=0x7b;
  913. WBUFL(buf,2)=md->bl.id;
  914. WBUFW(buf,6)=status_get_speed(&md->bl);
  915. WBUFW(buf,8)=md->opt1;
  916. WBUFW(buf,10)=md->opt2;
  917. WBUFW(buf,12)=md->option;
  918. WBUFW(buf,14)=mob_get_viewclass(md->class_);
  919. if ((mob_get_viewclass(md->class_) < 24) || (mob_get_viewclass(md->class_) > 4000)) {
  920. WBUFW(buf,12)|=mob_db[md->class_].option;
  921. WBUFW(buf,16)=mob_get_hair(md->class_);
  922. WBUFW(buf,18)=mob_get_weapon(md->class_);
  923. WBUFW(buf,20)=mob_get_head_buttom(md->class_);
  924. WBUFL(buf,22)=gettick();
  925. WBUFW(buf,26)=mob_get_shield(md->class_);
  926. WBUFW(buf,28)=mob_get_head_top(md->class_);
  927. WBUFW(buf,30)=mob_get_head_mid(md->class_);
  928. WBUFW(buf,32)=mob_get_hair_color(md->class_);
  929. WBUFW(buf,34)=mob_get_clothes_color(md->class_); //Add for player monster dye - Valaris
  930. WBUFB(buf,49)=mob_get_sex(md->class_);
  931. } else
  932. WBUFL(buf,22)=gettick();
  933. if(md->class_ >= 1285 && md->class_ <= 1287 && md->guild_id) { // Added guardian emblems [Valaris]
  934. struct guild *g;
  935. struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name);
  936. if(gc && gc->guild_id > 0){
  937. g=guild_search(gc->guild_id);
  938. if(g) {
  939. WBUFL(buf,28)=gc->guild_id;
  940. WBUFL(buf,24)=g->emblem_id;
  941. }
  942. }
  943. } // End addition
  944. WBUFPOS2(buf,50,md->bl.x,md->bl.y,md->to_x,md->to_y);
  945. WBUFB(buf,56)=5;
  946. WBUFB(buf,57)=5;
  947. WBUFW(buf,58)=((level = status_get_lv(&md->bl))>battle_config.max_lv)? battle_config.max_lv:level;
  948. return packet_len_table[0x7b];
  949. }
  950. /*==========================================
  951. *
  952. *------------------------------------------
  953. */
  954. static int clif_npc0078(struct npc_data *nd, unsigned char *buf) {
  955. struct guild *g;
  956. nullpo_retr(0, nd);
  957. memset(buf,0,packet_len_table[0x78]);
  958. WBUFW(buf,0)=0x78;
  959. WBUFL(buf,2)=nd->bl.id;
  960. WBUFW(buf,6)=nd->speed;
  961. WBUFW(buf,14)=nd->class_;
  962. if ((nd->class_ == 722) && (nd->u.scr.guild_id > 0) && ((g=guild_search(nd->u.scr.guild_id)) != NULL)) {
  963. WBUFL(buf,22)=g->emblem_id;
  964. WBUFL(buf,26)=g->guild_id;
  965. }
  966. WBUFPOS(buf,46,nd->bl.x,nd->bl.y);
  967. WBUFB(buf,48)|=nd->dir&0x0f;
  968. WBUFB(buf,49)=5;
  969. WBUFB(buf,50)=5;
  970. return packet_len_table[0x78];
  971. }
  972. // NPC Walking [Valaris]
  973. static int clif_npc007b(struct npc_data *nd, unsigned char *buf) {
  974. struct guild *g;
  975. nullpo_retr(0, nd);
  976. memset(buf,0,packet_len_table[0x7b]);
  977. WBUFW(buf,0)=0x7b;
  978. WBUFL(buf,2)=nd->bl.id;
  979. WBUFW(buf,6)=nd->speed;
  980. WBUFW(buf,14)=nd->class_;
  981. if ((nd->class_ == 722) && (nd->u.scr.guild_id > 0) && ((g=guild_search(nd->u.scr.guild_id)) != NULL)) {
  982. WBUFL(buf,22)=g->emblem_id;
  983. WBUFL(buf,26)=g->guild_id;
  984. }
  985. WBUFL(buf,22)=gettick();
  986. WBUFPOS2(buf,50,nd->bl.x,nd->bl.y,nd->to_x,nd->to_y);
  987. WBUFB(buf,56)=5;
  988. WBUFB(buf,57)=5;
  989. return packet_len_table[0x7b];
  990. }
  991. /*==========================================
  992. *
  993. *------------------------------------------
  994. */
  995. static int clif_pet0078(struct pet_data *pd, unsigned char *buf) {
  996. int view,level;
  997. nullpo_retr(0, pd);
  998. memset(buf,0,packet_len_table[0x78]);
  999. WBUFW(buf,0)=0x78;
  1000. WBUFL(buf,2)=pd->bl.id;
  1001. WBUFW(buf,6)=pd->speed;
  1002. WBUFW(buf,14)=mob_get_viewclass(pd->class_);
  1003. if((mob_get_viewclass(pd->class_) < 24) || (mob_get_viewclass(pd->class_) > 4000)) {
  1004. WBUFW(buf,12)=mob_db[pd->class_].option;
  1005. WBUFW(buf,16)=mob_get_hair(pd->class_);
  1006. WBUFW(buf,18)=mob_get_weapon(pd->class_);
  1007. WBUFW(buf,20)=mob_get_head_buttom(pd->class_);
  1008. WBUFW(buf,22)=mob_get_shield(pd->class_);
  1009. WBUFW(buf,24)=mob_get_head_top(pd->class_);
  1010. WBUFW(buf,26)=mob_get_head_mid(pd->class_);
  1011. WBUFW(buf,28)=mob_get_hair_color(pd->class_);
  1012. WBUFW(buf,30)=mob_get_clothes_color(pd->class_); //Add for player pet dye - Valaris
  1013. WBUFB(buf,45)=mob_get_sex(pd->class_);
  1014. } else {
  1015. WBUFW(buf,16)=0x14;
  1016. if((view = itemdb_viewid(pd->equip)) > 0)
  1017. WBUFW(buf,20)=view;
  1018. else
  1019. WBUFW(buf,20)=pd->equip;
  1020. }
  1021. WBUFPOS(buf,46,pd->bl.x,pd->bl.y);
  1022. WBUFB(buf,48)|=pd->dir&0x0f;
  1023. WBUFB(buf,49)=0;
  1024. WBUFB(buf,50)=0;
  1025. WBUFW(buf,52)=((level = status_get_lv(&pd->bl))>battle_config.max_lv)? battle_config.max_lv:level;
  1026. return packet_len_table[0x78];
  1027. }
  1028. /*==========================================
  1029. *
  1030. *------------------------------------------
  1031. */
  1032. static int clif_pet007b(struct pet_data *pd, unsigned char *buf) {
  1033. int view,level;
  1034. nullpo_retr(0, pd);
  1035. memset(buf,0,packet_len_table[0x7b]);
  1036. WBUFW(buf,0)=0x7b;
  1037. WBUFL(buf,2)=pd->bl.id;
  1038. WBUFW(buf,6)=pd->speed;
  1039. WBUFW(buf,14)=mob_get_viewclass(pd->class_);
  1040. if((mob_get_viewclass(pd->class_) < 24) || (mob_get_viewclass(pd->class_) > 4000)) {
  1041. WBUFW(buf,12)=mob_db[pd->class_].option;
  1042. WBUFW(buf,16)=mob_get_hair(pd->class_);
  1043. WBUFW(buf,18)=mob_get_weapon(pd->class_);
  1044. WBUFW(buf,20)=mob_get_head_buttom(pd->class_);
  1045. WBUFL(buf,22)=gettick();
  1046. WBUFW(buf,26)=mob_get_shield(pd->class_);
  1047. WBUFW(buf,28)=mob_get_head_top(pd->class_);
  1048. WBUFW(buf,30)=mob_get_head_mid(pd->class_);
  1049. WBUFW(buf,32)=mob_get_hair_color(pd->class_);
  1050. WBUFW(buf,34)=mob_get_clothes_color(pd->class_); //Add for player pet dye - Valaris
  1051. WBUFB(buf,49)=mob_get_sex(pd->class_);
  1052. } else {
  1053. WBUFW(buf,16)=0x14;
  1054. if ((view = itemdb_viewid(pd->equip)) > 0)
  1055. WBUFW(buf,20)=view;
  1056. else
  1057. WBUFW(buf,20)=pd->equip;
  1058. WBUFL(buf,22)=gettick();
  1059. }
  1060. WBUFPOS2(buf,50,pd->bl.x,pd->bl.y,pd->to_x,pd->to_y);
  1061. WBUFB(buf,56)=0;
  1062. WBUFB(buf,57)=0;
  1063. WBUFW(buf,58)=((level = status_get_lv(&pd->bl))>battle_config.max_lv)? battle_config.max_lv:level;
  1064. return packet_len_table[0x7b];
  1065. }
  1066. /*==========================================
  1067. *
  1068. *------------------------------------------
  1069. */
  1070. static int clif_set01e1(struct map_session_data *sd, unsigned char *buf) {
  1071. nullpo_retr(0, sd);
  1072. WBUFW(buf,0)=0x1e1;
  1073. WBUFL(buf,2)=sd->bl.id;
  1074. WBUFW(buf,6)=sd->spiritball;
  1075. return packet_len_table[0x1e1];
  1076. }
  1077. /*==========================================
  1078. *
  1079. *------------------------------------------
  1080. */
  1081. static int clif_set0192(int fd, int m, int x, int y, int type) {
  1082. WFIFOW(fd,0) = 0x192;
  1083. WFIFOW(fd,2) = x;
  1084. WFIFOW(fd,4) = y;
  1085. WFIFOW(fd,6) = type;
  1086. memcpy(WFIFOP(fd,8),map[m].name,16);
  1087. WFIFOSET(fd,packet_len_table[0x192]);
  1088. return 0;
  1089. }
  1090. /*==========================================
  1091. *
  1092. *------------------------------------------
  1093. */
  1094. int clif_spawnpc(struct map_session_data *sd) {
  1095. unsigned char buf[128];
  1096. nullpo_retr(0, sd);
  1097. if (sd->disguise > 23 && sd->disguise < 4001) { // mob disguises [Valaris]
  1098. clif_clearchar(&sd->bl, 9);
  1099. memset(buf, 0, packet_len_table[0x119]);
  1100. WBUFW(buf, 0) = 0x119;
  1101. WBUFL(buf, 2) = sd->bl.id;
  1102. WBUFW(buf, 6) = 0;
  1103. WBUFW(buf, 8) = 0;
  1104. WBUFW(buf,10) = 0x40;
  1105. WBUFB(buf,12) = 0;
  1106. clif_send(buf, packet_len_table[0x119], &sd->bl, SELF);
  1107. memset(buf, 0, packet_len_table[0x7c]);
  1108. WBUFW(buf, 0) = 0x7c;
  1109. WBUFL(buf, 2) = sd->bl.id;
  1110. WBUFW(buf, 6) = sd->speed;
  1111. WBUFW(buf, 8) = sd->opt1;
  1112. WBUFW(buf,10) = sd->opt2;
  1113. WBUFW(buf,12) = sd->status.option;
  1114. WBUFW(buf,20) = sd->disguise;
  1115. WBUFPOS(buf, 36, sd->bl.x, sd->bl.y);
  1116. clif_send(buf, packet_len_table[0x7c], &sd->bl, AREA);
  1117. }
  1118. clif_set0078(sd, buf);
  1119. #if PACKETVER < 4
  1120. WBUFW(buf, 0) = 0x79;
  1121. WBUFW(buf,51) = (sd->status.base_level > battle_config.max_lv) ? battle_config.max_lv : sd->status.base_level;
  1122. clif_send(buf, packet_len_table[0x79], &sd->bl, AREA_WOS);
  1123. #else
  1124. WBUFW(buf, 0) = 0x1d9;
  1125. WBUFW(buf,51) = (sd->status.base_level > battle_config.max_lv) ? battle_config.max_lv : sd->status.base_level;
  1126. clif_send(buf, packet_len_table[0x1d9], &sd->bl, AREA_WOS);
  1127. #endif
  1128. if (sd->spiritball > 0)
  1129. clif_spiritball(sd);
  1130. if (sd->status.guild_id > 0) { // force display of guild emblem [Valaris]
  1131. struct guild *g = guild_search(sd->status.guild_id);
  1132. if (g)
  1133. clif_guild_emblem(sd,g);
  1134. } // end addition [Valaris]
  1135. if (sd->status.class_==13 || sd->status.class_==21 || sd->status.class_==4014 || sd->status.class_==4022)
  1136. pc_setoption(sd,sd->status.option|0x0020); // [Valaris]
  1137. if ((pc_isriding(sd) && pc_checkskill(sd,KN_RIDING)>0) && (sd->status.class_==7 ||
  1138. sd->status.class_==14 || sd->status.class_==4008 || sd->status.class_==4015))
  1139. pc_setriding(sd); // update peco riders for people upgrading athena [Valaris]
  1140. if (map[sd->bl.m].flag.snow)
  1141. clif_specialeffect(&sd->bl, 162, 1);
  1142. if (map[sd->bl.m].flag.fog)
  1143. clif_specialeffect(&sd->bl, 233, 1);
  1144. if (map[sd->bl.m].flag.sakura)
  1145. clif_specialeffect(&sd->bl, 163, 1);
  1146. if (map[sd->bl.m].flag.leaves)
  1147. clif_specialeffect(&sd->bl, 333, 1);
  1148. if (map[sd->bl.m].flag.rain)
  1149. clif_specialeffect(&sd->bl, 161, 1);
  1150. return 0;
  1151. }
  1152. /*==========================================
  1153. *
  1154. *------------------------------------------
  1155. */
  1156. int clif_spawnnpc(struct npc_data *nd)
  1157. {
  1158. unsigned char buf[64];
  1159. int len;
  1160. nullpo_retr(0, nd);
  1161. if(nd->class_ < 0 || nd->flag&1 || nd->class_ == INVISIBLE_CLASS)
  1162. return 0;
  1163. memset(buf,0,packet_len_table[0x7c]);
  1164. WBUFW(buf,0)=0x7c;
  1165. WBUFL(buf,2)=nd->bl.id;
  1166. WBUFW(buf,6)=nd->speed;
  1167. WBUFW(buf,20)=nd->class_;
  1168. WBUFPOS(buf,36,nd->bl.x,nd->bl.y);
  1169. clif_send(buf,packet_len_table[0x7c],&nd->bl,AREA);
  1170. len = clif_npc0078(nd,buf);
  1171. clif_send(buf,len,&nd->bl,AREA);
  1172. return 0;
  1173. }
  1174. /*==========================================
  1175. *
  1176. *------------------------------------------
  1177. */
  1178. int clif_spawnmob(struct mob_data *md)
  1179. {
  1180. unsigned char buf[64];
  1181. int len;
  1182. nullpo_retr(0, md);
  1183. if (mob_get_viewclass(md->class_) > 23 ) {
  1184. memset(buf,0,packet_len_table[0x7c]);
  1185. WBUFW(buf,0)=0x7c;
  1186. WBUFL(buf,2)=md->bl.id;
  1187. WBUFW(buf,6)=md->speed;
  1188. WBUFW(buf,8)=md->opt1;
  1189. WBUFW(buf,10)=md->opt2;
  1190. WBUFW(buf,12)=md->option;
  1191. WBUFW(buf,20)=mob_get_viewclass(md->class_);
  1192. WBUFPOS(buf,36,md->bl.x,md->bl.y);
  1193. clif_send(buf,packet_len_table[0x7c],&md->bl,AREA);
  1194. }
  1195. len = clif_mob0078(md,buf);
  1196. clif_send(buf,len,&md->bl,AREA);
  1197. if (mob_get_equip(md->class_) > 0) // mob equipment [Valaris]
  1198. clif_mob_equip(md,mob_get_equip(md->class_));
  1199. if(md->size==2) // tiny/big mobs [Valaris]
  1200. clif_specialeffect(&md->bl,423,0);
  1201. else if(md->size==1)
  1202. clif_specialeffect(&md->bl,421,0);
  1203. return 0;
  1204. }
  1205. // pet
  1206. /*==========================================
  1207. *
  1208. *------------------------------------------
  1209. */
  1210. int clif_spawnpet(struct pet_data *pd)
  1211. {
  1212. unsigned char buf[64];
  1213. int len;
  1214. nullpo_retr(0, pd);
  1215. if (mob_get_viewclass(pd->class_) >= MAX_PC_CLASS) {
  1216. memset(buf,0,packet_len_table[0x7c]);
  1217. WBUFW(buf,0)=0x7c;
  1218. WBUFL(buf,2)=pd->bl.id;
  1219. WBUFW(buf,6)=pd->speed;
  1220. WBUFW(buf,20)=mob_get_viewclass(pd->class_);
  1221. WBUFPOS(buf,36,pd->bl.x,pd->bl.y);
  1222. clif_send(buf,packet_len_table[0x7c],&pd->bl,AREA);
  1223. }
  1224. len = clif_pet0078(pd,buf);
  1225. clif_send(buf,len,&pd->bl,AREA);
  1226. return 0;
  1227. }
  1228. /*==========================================
  1229. *
  1230. *------------------------------------------
  1231. */
  1232. int clif_movepet(struct pet_data *pd) {
  1233. unsigned char buf[256];
  1234. int len;
  1235. nullpo_retr(0, pd);
  1236. len = clif_pet007b(pd,buf);
  1237. clif_send(buf,len,&pd->bl,AREA);
  1238. return 0;
  1239. }
  1240. /*==========================================
  1241. * npc walking [Valaris]
  1242. *------------------------------------------
  1243. */
  1244. int clif_movenpc(struct npc_data *nd) {
  1245. unsigned char buf[256];
  1246. int len;
  1247. nullpo_retr(0, nd);
  1248. len = clif_npc007b(nd,buf);
  1249. clif_send(buf,len,&nd->bl,AREA);
  1250. return 0;
  1251. }
  1252. /*==========================================
  1253. *
  1254. *------------------------------------------
  1255. */
  1256. int clif_servertick(struct map_session_data *sd)
  1257. {
  1258. int fd;
  1259. nullpo_retr(0, sd);
  1260. fd=sd->fd;
  1261. WFIFOW(fd,0)=0x7f;
  1262. WFIFOL(fd,2)=sd->server_tick;
  1263. WFIFOSET(fd,packet_len_table[0x7f]);
  1264. return 0;
  1265. }
  1266. /*==========================================
  1267. *
  1268. *------------------------------------------
  1269. */
  1270. int clif_walkok(struct map_session_data *sd)
  1271. {
  1272. int fd;
  1273. nullpo_retr(0, sd);
  1274. fd=sd->fd;
  1275. WFIFOW(fd,0)=0x87;
  1276. WFIFOL(fd,2)=gettick();;
  1277. WFIFOPOS2(fd,6,sd->bl.x,sd->bl.y,sd->to_x,sd->to_y);
  1278. WFIFOB(fd,11)=0;
  1279. WFIFOSET(fd,packet_len_table[0x87]);
  1280. return 0;
  1281. }
  1282. /*==========================================
  1283. *
  1284. *------------------------------------------
  1285. */
  1286. int clif_movechar(struct map_session_data *sd) {
  1287. int fd;
  1288. int len;
  1289. unsigned char buf[256];
  1290. nullpo_retr(0, sd);
  1291. fd = sd->fd;
  1292. len = clif_set007b(sd, buf);
  1293. if (sd->disguise > 23 && sd->disguise < 4001) {
  1294. clif_send(buf, len, &sd->bl, AREA);
  1295. return 0;
  1296. } else
  1297. clif_send(buf, len, &sd->bl, AREA_WOS);
  1298. if (battle_config.save_clothcolor == 1 && sd->status.clothes_color > 0)
  1299. clif_changelook(&sd->bl, LOOK_CLOTHES_COLOR, sd->status.clothes_color);
  1300. return 0;
  1301. }
  1302. /*==========================================
  1303. *
  1304. *------------------------------------------
  1305. */
  1306. void clif_quitsave(int fd,struct map_session_data *sd)
  1307. {
  1308. map_quit(sd);
  1309. }
  1310. /*==========================================
  1311. *
  1312. *------------------------------------------
  1313. */
  1314. static int clif_waitclose(int tid, unsigned int tick, int id, int data) {
  1315. if (session[id])
  1316. session[id]->eof = 1;
  1317. close(id);
  1318. return 0;
  1319. }
  1320. /*==========================================
  1321. *
  1322. *------------------------------------------
  1323. */
  1324. void clif_setwaitclose(int fd) {
  1325. struct map_session_data *sd;
  1326. // if player is not already in the game (double connection probably)
  1327. if ((sd = (struct map_session_data*)session[fd]->session_data) == NULL) {
  1328. // limited timer, just to send information.
  1329. add_timer(gettick() + 1000, clif_waitclose, fd, 0);
  1330. } else
  1331. add_timer(gettick() + 5000, clif_waitclose, fd, 0);
  1332. }
  1333. /*==========================================
  1334. *
  1335. *------------------------------------------
  1336. */
  1337. int clif_changemap(struct map_session_data *sd, char *mapname, int x, int y) {
  1338. int fd;
  1339. nullpo_retr(0, sd);
  1340. fd = sd->fd;
  1341. WFIFOW(fd,0) = 0x91;
  1342. memcpy(WFIFOP(fd,2), mapname, 16);
  1343. WFIFOW(fd,18) = x;
  1344. WFIFOW(fd,20) = y;
  1345. WFIFOSET(fd, packet_len_table[0x91]);
  1346. if (sd->disguise > 23 && sd->disguise < 4001) // mob disguises [Valaris]
  1347. clif_spawnpc(sd);
  1348. return 0;
  1349. }
  1350. /*==========================================
  1351. *
  1352. *------------------------------------------
  1353. */
  1354. int clif_changemapserver(struct map_session_data *sd, char *mapname, int x, int y, int ip, int port) {
  1355. int fd;
  1356. nullpo_retr(0, sd);
  1357. fd = sd->fd;
  1358. WFIFOW(fd,0) = 0x92;
  1359. memcpy(WFIFOP(fd,2), mapname, 16);
  1360. WFIFOW(fd,18) = x;
  1361. WFIFOW(fd,20) = y;
  1362. WFIFOL(fd,22) = ip;
  1363. WFIFOW(fd,26) = port;
  1364. WFIFOSET(fd, packet_len_table[0x92]);
  1365. return 0;
  1366. }
  1367. /*==========================================
  1368. *
  1369. *------------------------------------------
  1370. */
  1371. int clif_fixpos(struct block_list *bl) {
  1372. unsigned char buf[16];
  1373. nullpo_retr(0, bl);
  1374. WBUFW(buf,0)=0x88;
  1375. WBUFL(buf,2)=bl->id;
  1376. WBUFW(buf,6)=bl->x;
  1377. WBUFW(buf,8)=bl->y;
  1378. clif_send(buf, packet_len_table[0x88], bl, AREA);
  1379. return 0;
  1380. }
  1381. /*==========================================
  1382. *
  1383. *------------------------------------------
  1384. */
  1385. int clif_npcbuysell(struct map_session_data* sd, int id) {
  1386. int fd;
  1387. nullpo_retr(0, sd);
  1388. fd=sd->fd;
  1389. WFIFOW(fd,0)=0xc4;
  1390. WFIFOL(fd,2)=id;
  1391. WFIFOSET(fd,packet_len_table[0xc4]);
  1392. return 0;
  1393. }
  1394. /*==========================================
  1395. *
  1396. *------------------------------------------
  1397. */
  1398. int clif_buylist(struct map_session_data *sd, struct npc_data *nd) {
  1399. struct item_data *id;
  1400. int fd,i,val;
  1401. nullpo_retr(0, sd);
  1402. nullpo_retr(0, nd);
  1403. fd=sd->fd;
  1404. WFIFOW(fd,0)=0xc6;
  1405. for(i=0;nd->u.shop_item[i].nameid > 0;i++){
  1406. id = itemdb_search(nd->u.shop_item[i].nameid);
  1407. val=nd->u.shop_item[i].value;
  1408. WFIFOL(fd,4+i*11)=val;
  1409. if (!id->flag.value_notdc)
  1410. val=pc_modifybuyvalue(sd,val);
  1411. WFIFOL(fd,8+i*11)=val;
  1412. WFIFOB(fd,12+i*11)=id->type;
  1413. if (id->view_id > 0)
  1414. WFIFOW(fd,13+i*11)=id->view_id;
  1415. else
  1416. WFIFOW(fd,13+i*11)=nd->u.shop_item[i].nameid;
  1417. }
  1418. WFIFOW(fd,2)=i*11+4;
  1419. WFIFOSET(fd,WFIFOW(fd,2));
  1420. return 0;
  1421. }
  1422. /*==========================================
  1423. *
  1424. *------------------------------------------
  1425. */
  1426. int clif_selllist(struct map_session_data *sd) {
  1427. int fd,i,c=0,val;
  1428. nullpo_retr(0, sd);
  1429. fd=sd->fd;
  1430. WFIFOW(fd,0)=0xc7;
  1431. for(i=0;i<MAX_INVENTORY;i++) {
  1432. if(sd->status.inventory[i].nameid > 0 && sd->inventory_data[i]) {
  1433. val=sd->inventory_data[i]->value_sell;
  1434. if (val < 0)
  1435. continue;
  1436. WFIFOW(fd,4+c*10)=i+2;
  1437. WFIFOL(fd,6+c*10)=val;
  1438. if (!sd->inventory_data[i]->flag.value_notoc)
  1439. val=pc_modifysellvalue(sd,val);
  1440. WFIFOL(fd,10+c*10)=val;
  1441. c++;
  1442. }
  1443. }
  1444. WFIFOW(fd,2)=c*10+4;
  1445. WFIFOSET(fd,WFIFOW(fd,2));
  1446. return 0;
  1447. }
  1448. /*==========================================
  1449. *
  1450. *------------------------------------------
  1451. */
  1452. int clif_scriptmes(struct map_session_data *sd, int npcid, char *mes) {
  1453. int fd;
  1454. nullpo_retr(0, sd);
  1455. fd=sd->fd;
  1456. WFIFOW(fd,0)=0xb4;
  1457. WFIFOW(fd,2)=strlen(mes)+9;
  1458. WFIFOL(fd,4)=npcid;
  1459. strcpy((char*)WFIFOP(fd,8),mes);
  1460. WFIFOSET(fd,WFIFOW(fd,2));
  1461. return 0;
  1462. }
  1463. /*==========================================
  1464. *
  1465. *------------------------------------------
  1466. */
  1467. int clif_scriptnext(struct map_session_data *sd,int npcid) {
  1468. int fd;
  1469. nullpo_retr(0, sd);
  1470. fd=sd->fd;
  1471. WFIFOW(fd,0)=0xb5;
  1472. WFIFOL(fd,2)=npcid;
  1473. WFIFOSET(fd,packet_len_table[0xb5]);
  1474. return 0;
  1475. }
  1476. /*==========================================
  1477. *
  1478. *------------------------------------------
  1479. */
  1480. int clif_scriptclose(struct map_session_data *sd, int npcid) {
  1481. int fd;
  1482. nullpo_retr(0, sd);
  1483. fd=sd->fd;
  1484. WFIFOW(fd,0)=0xb6;
  1485. WFIFOL(fd,2)=npcid;
  1486. WFIFOSET(fd,packet_len_table[0xb6]);
  1487. return 0;
  1488. }
  1489. /*==========================================
  1490. *
  1491. *------------------------------------------
  1492. */
  1493. int clif_scriptmenu(struct map_session_data *sd, int npcid, char *mes) {
  1494. int fd;
  1495. nullpo_retr(0, sd);
  1496. fd=sd->fd;
  1497. WFIFOW(fd,0)=0xb7;
  1498. WFIFOW(fd,2)=strlen(mes)+8;
  1499. WFIFOL(fd,4)=npcid;
  1500. strcpy((char*)WFIFOP(fd,8),mes);
  1501. WFIFOSET(fd,WFIFOW(fd,2));
  1502. return 0;
  1503. }
  1504. /*==========================================
  1505. *
  1506. *------------------------------------------
  1507. */
  1508. int clif_scriptinput(struct map_session_data *sd, int npcid) {
  1509. int fd;
  1510. nullpo_retr(0, sd);
  1511. fd=sd->fd;
  1512. WFIFOW(fd,0)=0x142;
  1513. WFIFOL(fd,2)=npcid;
  1514. WFIFOSET(fd,packet_len_table[0x142]);
  1515. return 0;
  1516. }
  1517. /*==========================================
  1518. *
  1519. *------------------------------------------
  1520. */
  1521. int clif_scriptinputstr(struct map_session_data *sd, int npcid) {
  1522. int fd;
  1523. nullpo_retr(0, sd);
  1524. fd=sd->fd;
  1525. WFIFOW(fd,0)=0x1d4;
  1526. WFIFOL(fd,2)=npcid;
  1527. WFIFOSET(fd,packet_len_table[0x1d4]);
  1528. return 0;
  1529. }
  1530. /*==========================================
  1531. *
  1532. *------------------------------------------
  1533. */
  1534. int clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, int y, int id, int color) {
  1535. int fd;
  1536. nullpo_retr(0, sd);
  1537. fd=sd->fd;
  1538. WFIFOW(fd,0)=0x144;
  1539. WFIFOL(fd,2)=npc_id;
  1540. WFIFOL(fd,6)=type;
  1541. WFIFOL(fd,10)=x;
  1542. WFIFOL(fd,14)=y;
  1543. WFIFOB(fd,18)=id;
  1544. WFIFOL(fd,19)=color;
  1545. WFIFOSET(fd,packet_len_table[0x144]);
  1546. return 0;
  1547. }
  1548. /*==========================================
  1549. *
  1550. *------------------------------------------
  1551. */
  1552. int clif_cutin(struct map_session_data *sd, char *image, int type) {
  1553. int fd;
  1554. nullpo_retr(0, sd);
  1555. fd=sd->fd;
  1556. WFIFOW(fd,0)=0x1b3;
  1557. strncpy((char*)WFIFOP(fd,2),image,64);
  1558. WFIFOB(fd,66)=type;
  1559. WFIFOSET(fd,packet_len_table[0x1b3]);
  1560. return 0;
  1561. }
  1562. /*==========================================
  1563. *
  1564. *------------------------------------------
  1565. */
  1566. int clif_additem(struct map_session_data *sd, int n, int amount, int fail) {
  1567. int fd,j;
  1568. unsigned char *buf;
  1569. nullpo_retr(0, sd);
  1570. fd=sd->fd;
  1571. buf=WFIFOP(fd,0);
  1572. if(fail) {
  1573. WBUFW(buf,0)=0xa0;
  1574. WBUFW(buf,2)=n+2;
  1575. WBUFW(buf,4)=amount;
  1576. WBUFW(buf,6)=0;
  1577. WBUFB(buf,8)=0;
  1578. WBUFB(buf,9)=0;
  1579. WBUFB(buf,10)=0;
  1580. WBUFW(buf,11)=0;
  1581. WBUFW(buf,13)=0;
  1582. WBUFW(buf,15)=0;
  1583. WBUFW(buf,17)=0;
  1584. WBUFW(buf,19)=0;
  1585. WBUFB(buf,21)=0;
  1586. WBUFB(buf,22)=fail;
  1587. } else {
  1588. if (n<0 || n>=MAX_INVENTORY || sd->status.inventory[n].nameid <=0 || sd->inventory_data[n] == NULL)
  1589. return 1;
  1590. WBUFW(buf,0)=0xa0;
  1591. WBUFW(buf,2)=n+2;
  1592. WBUFW(buf,4)=amount;
  1593. if (sd->inventory_data[n]->view_id > 0)
  1594. WBUFW(buf,6)=sd->inventory_data[n]->view_id;
  1595. else
  1596. WBUFW(buf,6)=sd->status.inventory[n].nameid;
  1597. WBUFB(buf,8)=sd->status.inventory[n].identify;
  1598. WBUFB(buf,9)=sd->status.inventory[n].attribute;
  1599. WBUFB(buf,10)=sd->status.inventory[n].refine;
  1600. if(sd->status.inventory[n].card[0]==0x00ff || sd->status.inventory[n].card[0]==0x00fe || sd->status.inventory[n].card[0]==(short)0xff00) {
  1601. WBUFW(buf,11)=sd->status.inventory[n].card[0];
  1602. WBUFW(buf,13)=sd->status.inventory[n].card[1];
  1603. WBUFW(buf,15)=sd->status.inventory[n].card[2];
  1604. WBUFW(buf,17)=sd->status.inventory[n].card[3];
  1605. } else {
  1606. if (sd->status.inventory[n].card[0] > 0 && (j=itemdb_viewid(sd->status.inventory[n].card[0])) > 0)
  1607. WBUFW(buf,11)=j;
  1608. else
  1609. WBUFW(buf,11)=sd->status.inventory[n].card[0];
  1610. if (sd->status.inventory[n].card[1] > 0 && (j=itemdb_viewid(sd->status.inventory[n].card[1])) > 0)
  1611. WBUFW(buf,13)=j;
  1612. else
  1613. WBUFW(buf,13)=sd->status.inventory[n].card[1];
  1614. if (sd->status.inventory[n].card[2] > 0 && (j=itemdb_viewid(sd->status.inventory[n].card[2])) > 0)
  1615. WBUFW(buf,15)=j;
  1616. else
  1617. WBUFW(buf,15)=sd->status.inventory[n].card[2];
  1618. if (sd->status.inventory[n].card[3] > 0 && (j=itemdb_viewid(sd->status.inventory[n].card[3])) > 0)
  1619. WBUFW(buf,17)=j;
  1620. else
  1621. WBUFW(buf,17)=sd->status.inventory[n].card[3];
  1622. }
  1623. WBUFW(buf,19)=pc_equippoint(sd,n);
  1624. WBUFB(buf,21)=(sd->inventory_data[n]->type == 7)? 4:sd->inventory_data[n]->type;
  1625. WBUFB(buf,22)=fail;
  1626. }
  1627. WFIFOSET(fd,packet_len_table[0xa0]);
  1628. return 0;
  1629. }
  1630. /*==========================================
  1631. *
  1632. *------------------------------------------
  1633. */
  1634. int clif_delitem(struct map_session_data *sd,int n,int amount)
  1635. {
  1636. int fd;
  1637. nullpo_retr(0, sd);
  1638. fd=sd->fd;
  1639. WFIFOW(fd,0)=0xaf;
  1640. WFIFOW(fd,2)=n+2;
  1641. WFIFOW(fd,4)=amount;
  1642. WFIFOSET(fd,packet_len_table[0xaf]);
  1643. return 0;
  1644. }
  1645. /*==========================================
  1646. *
  1647. *------------------------------------------
  1648. */
  1649. int clif_itemlist(struct map_session_data *sd)
  1650. {
  1651. int i,n,fd,arrow=-1;
  1652. unsigned char *buf;
  1653. nullpo_retr(0, sd);
  1654. fd=sd->fd;
  1655. buf = WFIFOP(fd,0);
  1656. #if PACKETVER < 5
  1657. WBUFW(buf,0)=0xa3;
  1658. for(i=0,n=0;i<MAX_INVENTORY;i++){
  1659. if (sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL || itemdb_isequip2(sd->inventory_data[i]))
  1660. continue;
  1661. WBUFW(buf,n*10+4)=i+2;
  1662. if (sd->inventory_data[i]->view_id > 0)
  1663. WBUFW(buf,n*10+6)=sd->inventory_data[i]->view_id;
  1664. else
  1665. WBUFW(buf,n*10+6)=sd->status.inventory[i].nameid;
  1666. WBUFB(buf,n*10+8)=sd->inventory_data[i]->type;
  1667. WBUFB(buf,n*10+9)=sd->status.inventory[i].identify;
  1668. WBUFW(buf,n*10+10)=sd->status.inventory[i].amount;
  1669. if (sd->inventory_data[i]->equip == 0x8000) {
  1670. WBUFW(buf,n*10+12)=0x8000;
  1671. if (sd->status.inventory[i].equip)
  1672. arrow=i; // ついでに矢装備チェック
  1673. } else
  1674. WBUFW(buf,n*10+12)=0;
  1675. n++;
  1676. }
  1677. if (n) {
  1678. WBUFW(buf,2)=4+n*10;
  1679. WFIFOSET(fd,WFIFOW(fd,2));
  1680. }
  1681. #else
  1682. WBUFW(buf,0)=0x1ee;
  1683. for(i=0,n=0;i<MAX_INVENTORY;i++){
  1684. if(sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL || itemdb_isequip2(sd->inventory_data[i]))
  1685. continue;
  1686. WBUFW(buf,n*18+4)=i+2;
  1687. if(sd->inventory_data[i]->view_id > 0)
  1688. WBUFW(buf,n*18+6)=sd->inventory_data[i]->view_id;
  1689. else
  1690. WBUFW(buf,n*18+6)=sd->status.inventory[i].nameid;
  1691. WBUFB(buf,n*18+8)=sd->inventory_data[i]->type;
  1692. WBUFB(buf,n*18+9)=sd->status.inventory[i].identify;
  1693. WBUFW(buf,n*18+10)=sd->status.inventory[i].amount;
  1694. if (sd->inventory_data[i]->equip == 0x8000) {
  1695. WBUFW(buf,n*18+12)=0x8000;
  1696. if(sd->status.inventory[i].equip)
  1697. arrow=i; // ついでに矢装備チェック
  1698. } else
  1699. WBUFW(buf,n*18+12)=0;
  1700. WBUFW(buf,n*18+14)=sd->status.inventory[i].card[0];
  1701. WBUFW(buf,n*18+16)=sd->status.inventory[i].card[1];
  1702. WBUFW(buf,n*18+18)=sd->status.inventory[i].card[2];
  1703. WBUFW(buf,n*18+20)=sd->status.inventory[i].card[3];
  1704. n++;
  1705. }
  1706. if (n) {
  1707. WBUFW(buf,2)=4+n*18;
  1708. WFIFOSET(fd,WFIFOW(fd,2));
  1709. }
  1710. #endif
  1711. if(arrow >= 0)
  1712. clif_arrowequip(sd,arrow);
  1713. return 0;
  1714. }
  1715. /*==========================================
  1716. *
  1717. *------------------------------------------
  1718. */
  1719. int clif_equiplist(struct map_session_data *sd)
  1720. {
  1721. int i,j,n,fd;
  1722. unsigned char *buf;
  1723. nullpo_retr(0, sd);
  1724. fd=sd->fd;
  1725. buf = WFIFOP(fd,0);
  1726. WBUFW(buf,0)=0xa4;
  1727. for(i=0,n=0;i<MAX_INVENTORY;i++){
  1728. if(sd->status.inventory[i].nameid<=0 || sd->inventory_data[i] == NULL || !itemdb_isequip2(sd->inventory_data[i]))
  1729. continue;
  1730. WBUFW(buf,n*20+4)=i+2;
  1731. if(sd->inventory_data[i]->view_id > 0)
  1732. WBUFW(buf,n*20+6)=sd->inventory_data[i]->view_id;
  1733. else
  1734. WBUFW(buf,n*20+6)=sd->status.inventory[i].nameid;
  1735. WBUFB(buf,n*20+8)=(sd->inventory_data[i]->type == 7)? 4:sd->inventory_data[i]->type;
  1736. WBUFB(buf,n*20+9)=sd->status.inventory[i].identify;
  1737. WBUFW(buf,n*20+10)=pc_equippoint(sd,i);
  1738. WBUFW(buf,n*20+12)=sd->status.inventory[i].equip;
  1739. WBUFB(buf,n*20+14)=sd->status.inventory[i].attribute;
  1740. WBUFB(buf,n*20+15)=sd->status.inventory[i].refine;
  1741. if(sd->status.inventory[i].card[0]==0x00ff || sd->status.inventory[i].card[0]==0x00fe || sd->status.inventory[i].card[0]==(short)0xff00) {
  1742. WBUFW(buf,n*20+16)=sd->status.inventory[i].card[0];
  1743. WBUFW(buf,n*20+18)=sd->status.inventory[i].card[1];
  1744. WBUFW(buf,n*20+20)=sd->status.inventory[i].card[2];
  1745. WBUFW(buf,n*20+22)=sd->status.inventory[i].card[3];
  1746. } else {
  1747. if(sd->status.inventory[i].card[0] > 0 && (j=itemdb_viewid(sd->status.inventory[i].card[0])) > 0)
  1748. WBUFW(buf,n*20+16)=j;
  1749. else
  1750. WBUFW(buf,n*20+16)=sd->status.inventory[i].card[0];
  1751. if(sd->status.inventory[i].card[1] > 0 && (j=itemdb_viewid(sd->status.inventory[i].card[1])) > 0)
  1752. WBUFW(buf,n*20+18)=j;
  1753. else
  1754. WBUFW(buf,n*20+18)=sd->status.inventory[i].card[1];
  1755. if(sd->status.inventory[i].card[2] > 0 && (j=itemdb_viewid(sd->status.inventory[i].card[2])) > 0)
  1756. WBUFW(buf,n*20+20)=j;
  1757. else
  1758. WBUFW(buf,n*20+20)=sd->status.inventory[i].card[2];
  1759. if(sd->status.inventory[i].card[3] > 0 && (j=itemdb_viewid(sd->status.inventory[i].card[3])) > 0)
  1760. WBUFW(buf,n*20+22)=j;
  1761. else
  1762. WBUFW(buf,n*20+22)=sd->status.inventory[i].card[3];
  1763. }
  1764. n++;
  1765. }
  1766. if(n){
  1767. WBUFW(buf,2)=4+n*20;
  1768. WFIFOSET(fd,WFIFOW(fd,2));
  1769. }
  1770. return 0;
  1771. }
  1772. /*==========================================
  1773. * カプラさんに預けてある消耗品&収集品リスト
  1774. *------------------------------------------
  1775. */
  1776. int clif_storageitemlist(struct map_session_data *sd,struct storage *stor)
  1777. {
  1778. struct item_data *id;
  1779. int i,n,fd;
  1780. unsigned char *buf;
  1781. nullpo_retr(0, sd);
  1782. nullpo_retr(0, stor);
  1783. fd=sd->fd;
  1784. buf = WFIFOP(fd,0);
  1785. #if PACKETVER < 5
  1786. WBUFW(buf,0)=0xa5;
  1787. for(i=0,n=0;i<MAX_STORAGE;i++){
  1788. if(stor->storage[i].nameid<=0)
  1789. continue;
  1790. nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
  1791. if(itemdb_isequip2(id))
  1792. continue;
  1793. WBUFW(buf,n*10+4)=i+1;
  1794. if(id->view_id > 0)
  1795. WBUFW(buf,n*10+6)=id->view_id;
  1796. else
  1797. WBUFW(buf,n*10+6)=stor->storage[i].nameid;
  1798. WBUFB(buf,n*10+8)=id->type;;
  1799. WBUFB(buf,n*10+9)=stor->storage[i].identify;
  1800. WBUFW(buf,n*10+10)=stor->storage[i].amount;
  1801. WBUFW(buf,n*10+12)=0;
  1802. n++;
  1803. }
  1804. if(n){
  1805. WBUFW(buf,2)=4+n*10;
  1806. WFIFOSET(fd,WFIFOW(fd,2));
  1807. }
  1808. #else
  1809. WBUFW(buf,0)=0x1f0;
  1810. for(i=0,n=0;i<MAX_STORAGE;i++){
  1811. if(stor->storage[i].nameid<=0)
  1812. continue;
  1813. nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
  1814. if(itemdb_isequip2(id))
  1815. continue;
  1816. WBUFW(buf,n*18+4)=i+1;
  1817. if(id->view_id > 0)
  1818. WBUFW(buf,n*18+6)=id->view_id;
  1819. else
  1820. WBUFW(buf,n*18+6)=stor->storage[i].nameid;
  1821. WBUFB(buf,n*18+8)=id->type;;
  1822. WBUFB(buf,n*18+9)=stor->storage[i].identify;
  1823. WBUFW(buf,n*18+10)=stor->storage[i].amount;
  1824. WBUFW(buf,n*18+12)=0;
  1825. WBUFW(buf,n*18+14)=stor->storage[i].card[0];
  1826. WBUFW(buf,n*18+16)=stor->storage[i].card[1];
  1827. WBUFW(buf,n*18+18)=stor->storage[i].card[2];
  1828. WBUFW(buf,n*18+20)=stor->storage[i].card[3];
  1829. n++;
  1830. }
  1831. if(n){
  1832. WBUFW(buf,2)=4+n*18;
  1833. WFIFOSET(fd,WFIFOW(fd,2));
  1834. }
  1835. #endif
  1836. return 0;
  1837. }
  1838. /*==========================================
  1839. * カプラさんに預けてある装備リスト
  1840. *------------------------------------------
  1841. */
  1842. int clif_storageequiplist(struct map_session_data *sd,struct storage *stor)
  1843. {
  1844. struct item_data *id;
  1845. int i,j,n,fd;
  1846. unsigned char *buf;
  1847. nullpo_retr(0, sd);
  1848. nullpo_retr(0, stor);
  1849. fd=sd->fd;
  1850. buf = WFIFOP(fd,0);
  1851. WBUFW(buf,0)=0xa6;
  1852. for(i=0,n=0;i<MAX_STORAGE;i++){
  1853. if(stor->storage[i].nameid<=0)
  1854. continue;
  1855. nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
  1856. if(!itemdb_isequip2(id))
  1857. continue;
  1858. WBUFW(buf,n*20+4)=i+1;
  1859. if(id->view_id > 0)
  1860. WBUFW(buf,n*20+6)=id->view_id;
  1861. else
  1862. WBUFW(buf,n*20+6)=stor->storage[i].nameid;
  1863. WBUFB(buf,n*20+8)=id->type;
  1864. WBUFB(buf,n*20+9)=stor->storage[i].identify;
  1865. WBUFW(buf,n*20+10)=id->equip;
  1866. WBUFW(buf,n*20+12)=stor->storage[i].equip;
  1867. WBUFB(buf,n*20+14)=stor->storage[i].attribute;
  1868. WBUFB(buf,n*20+15)=stor->storage[i].refine;
  1869. if(stor->storage[i].card[0]==0x00ff || stor->storage[i].card[0]==0x00fe || stor->storage[i].card[0]==(short)0xff00) {
  1870. WBUFW(buf,n*20+16)=stor->storage[i].card[0];
  1871. WBUFW(buf,n*20+18)=stor->storage[i].card[1];
  1872. WBUFW(buf,n*20+20)=stor->storage[i].card[2];
  1873. WBUFW(buf,n*20+22)=stor->storage[i].card[3];
  1874. } else {
  1875. if(stor->storage[i].card[0] > 0 && (j=itemdb_viewid(stor->storage[i].card[0])) > 0)
  1876. WBUFW(buf,n*20+16)=j;
  1877. else
  1878. WBUFW(buf,n*20+16)=stor->storage[i].card[0];
  1879. if(stor->storage[i].card[1] > 0 && (j=itemdb_viewid(stor->storage[i].card[1])) > 0)
  1880. WBUFW(buf,n*20+18)=j;
  1881. else
  1882. WBUFW(buf,n*20+18)=stor->storage[i].card[1];
  1883. if(stor->storage[i].card[2] > 0 && (j=itemdb_viewid(stor->storage[i].card[2])) > 0)
  1884. WBUFW(buf,n*20+20)=j;
  1885. else
  1886. WBUFW(buf,n*20+20)=stor->storage[i].card[2];
  1887. if(stor->storage[i].card[3] > 0 && (j=itemdb_viewid(stor->storage[i].card[3])) > 0)
  1888. WBUFW(buf,n*20+22)=j;
  1889. else
  1890. WBUFW(buf,n*20+22)=stor->storage[i].card[3];
  1891. }
  1892. n++;
  1893. }
  1894. if(n){
  1895. WBUFW(buf,2)=4+n*20;
  1896. WFIFOSET(fd,WFIFOW(fd,2));
  1897. }
  1898. return 0;
  1899. }
  1900. /*==========================================
  1901. *
  1902. *------------------------------------------
  1903. */
  1904. int clif_guildstorageitemlist(struct map_session_data *sd,struct guild_storage *stor)
  1905. {
  1906. struct item_data *id;
  1907. int i,n,fd;
  1908. unsigned char *buf;
  1909. nullpo_retr(0, sd);
  1910. nullpo_retr(0, stor);
  1911. fd=sd->fd;
  1912. buf=WFIFOP(fd,0);
  1913. #if PACKETVER < 5
  1914. WBUFW(buf,0)=0xa5;
  1915. for(i=0,n=0;i<MAX_GUILD_STORAGE;i++){
  1916. if(stor->storage[i].nameid<=0)
  1917. continue;
  1918. nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
  1919. if(itemdb_isequip2(id))
  1920. continue;
  1921. WBUFW(buf,n*10+4)=i+1;
  1922. if(id->view_id > 0)
  1923. WBUFW(buf,n*10+6)=id->view_id;
  1924. else
  1925. WBUFW(buf,n*10+6)=stor->storage[i].nameid;
  1926. WBUFB(buf,n*10+8)=id->type;;
  1927. WBUFB(buf,n*10+9)=stor->storage[i].identify;
  1928. WBUFW(buf,n*10+10)=stor->storage[i].amount;
  1929. WBUFW(buf,n*10+12)=0;
  1930. n++;
  1931. }
  1932. if(n){
  1933. WBUFW(buf,2)=4+n*10;
  1934. WFIFOSET(fd,WFIFOW(fd,2));
  1935. }
  1936. #else
  1937. WBUFW(buf,0)=0x1f0;
  1938. for(i=0,n=0;i<MAX_GUILD_STORAGE;i++){
  1939. if(stor->storage[i].nameid<=0)
  1940. continue;
  1941. nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
  1942. if(itemdb_isequip2(id))
  1943. continue;
  1944. WBUFW(buf,n*18+4)=i+1;
  1945. if(id->view_id > 0)
  1946. WBUFW(buf,n*18+6)=id->view_id;
  1947. else
  1948. WBUFW(buf,n*18+6)=stor->storage[i].nameid;
  1949. WBUFB(buf,n*18+8)=id->type;;
  1950. WBUFB(buf,n*18+9)=stor->storage[i].identify;
  1951. WBUFW(buf,n*18+10)=stor->storage[i].amount;
  1952. WBUFW(buf,n*18+12)=0;
  1953. WBUFW(buf,n*18+14)=stor->storage[i].card[0];
  1954. WBUFW(buf,n*18+16)=stor->storage[i].card[1];
  1955. WBUFW(buf,n*18+18)=stor->storage[i].card[2];
  1956. WBUFW(buf,n*18+20)=stor->storage[i].card[3];
  1957. n++;
  1958. }
  1959. if(n){
  1960. WBUFW(buf,2)=4+n*18;
  1961. WFIFOSET(fd,WFIFOW(fd,2));
  1962. }
  1963. #endif
  1964. return 0;
  1965. }
  1966. /*==========================================
  1967. *
  1968. *------------------------------------------
  1969. */
  1970. int clif_guildstorageequiplist(struct map_session_data *sd,struct guild_storage *stor)
  1971. {
  1972. struct item_data *id;
  1973. int i,j,n,fd;
  1974. unsigned char *buf;
  1975. nullpo_retr(0, sd);
  1976. fd=sd->fd;
  1977. buf=WFIFOP(fd,0);
  1978. WBUFW(buf,0)=0xa6;
  1979. for(i=0,n=0;i<MAX_GUILD_STORAGE;i++){
  1980. if(stor->storage[i].nameid<=0)
  1981. continue;
  1982. nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
  1983. if(!itemdb_isequip2(id))
  1984. continue;
  1985. WBUFW(buf,n*20+4)=i+1;
  1986. if(id->view_id > 0)
  1987. WBUFW(buf,n*20+6)=id->view_id;
  1988. else
  1989. WBUFW(buf,n*20+6)=stor->storage[i].nameid;
  1990. WBUFB(buf,n*20+8)=id->type;
  1991. WBUFB(buf,n*20+9)=stor->storage[i].identify;
  1992. WBUFW(buf,n*20+10)=id->equip;
  1993. WBUFW(buf,n*20+12)=stor->storage[i].equip;
  1994. WBUFB(buf,n*20+14)=stor->storage[i].attribute;
  1995. WBUFB(buf,n*20+15)=stor->storage[i].refine;
  1996. if(stor->storage[i].card[0]==0x00ff || stor->storage[i].card[0]==0x00fe || stor->storage[i].card[0]==(short)0xff00) {
  1997. WBUFW(buf,n*20+16)=stor->storage[i].card[0];
  1998. WBUFW(buf,n*20+18)=stor->storage[i].card[1];
  1999. WBUFW(buf,n*20+20)=stor->storage[i].card[2];
  2000. WBUFW(buf,n*20+22)=stor->storage[i].card[3];
  2001. } else {
  2002. if(stor->storage[i].card[0] > 0 && (j=itemdb_viewid(stor->storage[i].card[0])) > 0)
  2003. WBUFW(buf,n*20+16)=j;
  2004. else
  2005. WBUFW(buf,n*20+16)=stor->storage[i].card[0];
  2006. if(stor->storage[i].card[1] > 0 && (j=itemdb_viewid(stor->storage[i].card[1])) > 0)
  2007. WBUFW(buf,n*20+18)=j;
  2008. else
  2009. WBUFW(buf,n*20+18)=stor->storage[i].card[1];
  2010. if(stor->storage[i].card[2] > 0 && (j=itemdb_viewid(stor->storage[i].card[2])) > 0)
  2011. WBUFW(buf,n*20+20)=j;
  2012. else
  2013. WBUFW(buf,n*20+20)=stor->storage[i].card[2];
  2014. if(stor->storage[i].card[3] > 0 && (j=itemdb_viewid(stor->storage[i].card[3])) > 0)
  2015. WBUFW(buf,n*20+22)=j;
  2016. else
  2017. WBUFW(buf,n*20+22)=stor->storage[i].card[3];
  2018. }
  2019. n++;
  2020. }
  2021. if(n){
  2022. WBUFW(buf,2)=4+n*20;
  2023. WFIFOSET(fd,WFIFOW(fd,2));
  2024. }
  2025. return 0;
  2026. }
  2027. /*==========================================
  2028. * ステータスを送りつける
  2029. * 表示専用数字はこの中で計算して送る
  2030. *------------------------------------------
  2031. */
  2032. int clif_updatestatus(struct map_session_data *sd,int type)
  2033. {
  2034. int fd,len=8;
  2035. nullpo_retr(0, sd);
  2036. fd=sd->fd;
  2037. WFIFOW(fd,0)=0xb0;
  2038. WFIFOW(fd,2)=type;
  2039. switch(type){
  2040. // 00b0
  2041. case SP_WEIGHT:
  2042. pc_checkweighticon(sd);
  2043. WFIFOW(fd,0)=0xb0;
  2044. WFIFOW(fd,2)=type;
  2045. WFIFOL(fd,4)=sd->weight;
  2046. break;
  2047. case SP_MAXWEIGHT:
  2048. WFIFOL(fd,4)=sd->max_weight;
  2049. break;
  2050. case SP_SPEED:
  2051. WFIFOL(fd,4)=sd->speed;
  2052. break;
  2053. case SP_BASELEVEL:
  2054. WFIFOL(fd,4)=sd->status.base_level;
  2055. break;
  2056. case SP_JOBLEVEL:
  2057. WFIFOL(fd,4)=sd->status.job_level;
  2058. break;
  2059. case SP_MANNER:
  2060. WFIFOL(fd,4)=sd->status.manner;
  2061. clif_changestatus(&sd->bl,SP_MANNER,sd->status.manner);
  2062. break;
  2063. case SP_STATUSPOINT:
  2064. WFIFOL(fd,4)=sd->status.status_point;
  2065. break;
  2066. case SP_SKILLPOINT:
  2067. WFIFOL(fd,4)=sd->status.skill_point;
  2068. break;
  2069. case SP_HIT:
  2070. WFIFOL(fd,4)=sd->hit;
  2071. break;
  2072. case SP_FLEE1:
  2073. WFIFOL(fd,4)=sd->flee;
  2074. break;
  2075. case SP_FLEE2:
  2076. WFIFOL(fd,4)=sd->flee2/10;
  2077. break;
  2078. case SP_MAXHP:
  2079. WFIFOL(fd,4)=sd->status.max_hp;
  2080. break;
  2081. case SP_MAXSP:
  2082. WFIFOL(fd,4)=sd->status.max_sp;
  2083. break;
  2084. case SP_HP:
  2085. WFIFOL(fd,4)=sd->status.hp;
  2086. if(battle_config.disp_hpmeter)
  2087. clif_hpmeter(sd);
  2088. break;
  2089. case SP_SP:
  2090. WFIFOL(fd,4)=sd->status.sp;
  2091. break;
  2092. case SP_ASPD:
  2093. WFIFOL(fd,4)=sd->aspd;
  2094. break;
  2095. case SP_ATK1:
  2096. WFIFOL(fd,4)=sd->base_atk+sd->watk;
  2097. break;
  2098. case SP_DEF1:
  2099. WFIFOL(fd,4)=sd->def;
  2100. break;
  2101. case SP_MDEF1:
  2102. WFIFOL(fd,4)=sd->mdef;
  2103. break;
  2104. case SP_ATK2:
  2105. WFIFOL(fd,4)=sd->watk2;
  2106. break;
  2107. case SP_DEF2:
  2108. WFIFOL(fd,4)=sd->def2;
  2109. break;
  2110. case SP_MDEF2:
  2111. WFIFOL(fd,4)=sd->mdef2;
  2112. break;
  2113. case SP_CRITICAL:
  2114. WFIFOL(fd,4)=sd->critical/10;
  2115. break;
  2116. case SP_MATK1:
  2117. WFIFOL(fd,4)=sd->matk1;
  2118. break;
  2119. case SP_MATK2:
  2120. WFIFOL(fd,4)=sd->matk2;
  2121. break;
  2122. case SP_ZENY:
  2123. WFIFOW(fd,0)=0xb1;
  2124. if(sd->status.zeny < 0)
  2125. sd->status.zeny = 0;
  2126. WFIFOL(fd,4)=sd->status.zeny;
  2127. break;
  2128. case SP_BASEEXP:
  2129. WFIFOW(fd,0)=0xb1;
  2130. WFIFOL(fd,4)=sd->status.base_exp;
  2131. break;
  2132. case SP_JOBEXP:
  2133. WFIFOW(fd,0)=0xb1;
  2134. WFIFOL(fd,4)=sd->status.job_exp;
  2135. break;
  2136. case SP_NEXTBASEEXP:
  2137. WFIFOW(fd,0)=0xb1;
  2138. WFIFOL(fd,4)=pc_nextbaseexp(sd);
  2139. break;
  2140. case SP_NEXTJOBEXP:
  2141. WFIFOW(fd,0)=0xb1;
  2142. WFIFOL(fd,4)=pc_nextjobexp(sd);
  2143. break;
  2144. // 00be 終了
  2145. case SP_USTR:
  2146. case SP_UAGI:
  2147. case SP_UVIT:
  2148. case SP_UINT:
  2149. case SP_UDEX:
  2150. case SP_ULUK:
  2151. WFIFOW(fd,0)=0xbe;
  2152. WFIFOB(fd,4)=pc_need_status_point(sd,type-SP_USTR+SP_STR);
  2153. len=5;
  2154. break;
  2155. // 013a 終了
  2156. case SP_ATTACKRANGE:
  2157. WFIFOW(fd,0)=0x13a;
  2158. WFIFOW(fd,2)=sd->attackrange;
  2159. len=4;
  2160. break;
  2161. // 0141 終了
  2162. case SP_STR:
  2163. WFIFOW(fd,0)=0x141;
  2164. WFIFOL(fd,2)=type;
  2165. WFIFOL(fd,6)=sd->status.str;
  2166. WFIFOL(fd,10)=sd->paramb[0] + sd->parame[0];
  2167. len=14;
  2168. break;
  2169. case SP_AGI:
  2170. WFIFOW(fd,0)=0x141;
  2171. WFIFOL(fd,2)=type;
  2172. WFIFOL(fd,6)=sd->status.agi;
  2173. WFIFOL(fd,10)=sd->paramb[1] + sd->parame[1];
  2174. len=14;
  2175. break;
  2176. case SP_VIT:
  2177. WFIFOW(fd,0)=0x141;
  2178. WFIFOL(fd,2)=type;
  2179. WFIFOL(fd,6)=sd->status.vit;
  2180. WFIFOL(fd,10)=sd->paramb[2] + sd->parame[2];
  2181. len=14;
  2182. break;
  2183. case SP_INT:
  2184. WFIFOW(fd,0)=0x141;
  2185. WFIFOL(fd,2)=type;
  2186. WFIFOL(fd,6)=sd->status.int_;
  2187. WFIFOL(fd,10)=sd->paramb[3] + sd->parame[3];
  2188. len=14;
  2189. break;
  2190. case SP_DEX:
  2191. WFIFOW(fd,0)=0x141;
  2192. WFIFOL(fd,2)=type;
  2193. WFIFOL(fd,6)=sd->status.dex;
  2194. WFIFOL(fd,10)=sd->paramb[4] + sd->parame[4];
  2195. len=14;
  2196. break;
  2197. case SP_LUK:
  2198. WFIFOW(fd,0)=0x141;
  2199. WFIFOL(fd,2)=type;
  2200. WFIFOL(fd,6)=sd->status.luk;
  2201. WFIFOL(fd,10)=sd->paramb[5] + sd->parame[5];
  2202. len=14;
  2203. break;
  2204. case SP_CARTINFO:
  2205. WFIFOW(fd,0)=0x121;
  2206. WFIFOW(fd,2)=sd->cart_num;
  2207. WFIFOW(fd,4)=sd->cart_max_num;
  2208. WFIFOL(fd,6)=sd->cart_weight;
  2209. WFIFOL(fd,10)=sd->cart_max_weight;
  2210. len=14;
  2211. break;
  2212. default:
  2213. if(battle_config.error_log)
  2214. printf("clif_updatestatus : make %d routine\n",type);
  2215. return 1;
  2216. }
  2217. WFIFOSET(fd,len);
  2218. return 0;
  2219. }
  2220. int clif_changestatus(struct block_list *bl,int type,int val)
  2221. {
  2222. unsigned char buf[12];
  2223. struct map_session_data *sd = NULL;
  2224. nullpo_retr(0, bl);
  2225. if(bl->type == BL_PC)
  2226. sd = (struct map_session_data *)bl;
  2227. //printf("clif_changestatus id:%d type:%d val:%d\n",bl->id,type,val);
  2228. if(sd){
  2229. WBUFW(buf,0)=0x1ab;
  2230. WBUFL(buf,2)=bl->id;
  2231. WBUFW(buf,6)=type;
  2232. switch(type){
  2233. case SP_MANNER:
  2234. WBUFL(buf,8)=val;
  2235. break;
  2236. default:
  2237. if(battle_config.error_log)
  2238. printf("clif_changestatus : make %d routine\n",type);
  2239. return 1;
  2240. }
  2241. clif_send(buf,packet_len_table[0x1ab],bl,AREA_WOS);
  2242. }
  2243. return 0;
  2244. }
  2245. /*==========================================
  2246. *
  2247. *------------------------------------------
  2248. */
  2249. int clif_changelook(struct block_list *bl,int type,int val)
  2250. {
  2251. unsigned char buf[32];
  2252. struct map_session_data *sd = NULL;
  2253. nullpo_retr(0, bl);
  2254. if(bl->type == BL_PC)
  2255. sd = (struct map_session_data *)bl;
  2256. if(sd && sd->disguise > 23 && sd->disguise < 4001) // mob disguises [Valaris]
  2257. return 0;
  2258. #if PACKETVER < 4
  2259. if(sd && (type == LOOK_WEAPON || type == LOOK_SHIELD) && sd->view_class == 22)
  2260. val =0;
  2261. WBUFW(buf,0)=0xc3;
  2262. WBUFL(buf,2)=bl->id;
  2263. WBUFB(buf,6)=type;
  2264. WBUFB(buf,7)=val;
  2265. clif_send(buf,packet_len_table[0xc3],bl,AREA);
  2266. #else
  2267. if(sd && (type == LOOK_WEAPON || type == LOOK_SHIELD || type == LOOK_SHOES)) {
  2268. WBUFW(buf,0)=0x1d7;
  2269. WBUFL(buf,2)=bl->id;
  2270. if(type == LOOK_SHOES) {
  2271. WBUFB(buf,6)=9;
  2272. if(sd->equip_index[2] >= 0 && sd->inventory_data[sd->equip_index[2]]) {
  2273. if(sd->inventory_data[sd->equip_index[2]]->view_id > 0)
  2274. WBUFW(buf,7)=sd->inventory_data[sd->equip_index[2]]->view_id;
  2275. else
  2276. WBUFW(buf,7)=sd->status.inventory[sd->equip_index[2]].nameid;
  2277. } else
  2278. WBUFW(buf,7)=0;
  2279. WBUFW(buf,9)=0;
  2280. }
  2281. else {
  2282. WBUFB(buf,6)=2;
  2283. if(sd->equip_index[9] >= 0 && sd->inventory_data[sd->equip_index[9]] && sd->view_class != 22) {
  2284. if(sd->inventory_data[sd->equip_index[9]]->view_id > 0)
  2285. WBUFW(buf,7)=sd->inventory_data[sd->equip_index[9]]->view_id;
  2286. else
  2287. WBUFW(buf,7)=sd->status.inventory[sd->equip_index[9]].nameid;
  2288. } else
  2289. WBUFW(buf,7)=0;
  2290. if(sd->equip_index[8] >= 0 && sd->equip_index[8] != sd->equip_index[9] && sd->inventory_data[sd->equip_index[8]] &&
  2291. sd->view_class != 22) {
  2292. if(sd->inventory_data[sd->equip_index[8]]->view_id > 0)
  2293. WBUFW(buf,9)=sd->inventory_data[sd->equip_index[8]]->view_id;
  2294. else
  2295. WBUFW(buf,9)=sd->status.inventory[sd->equip_index[8]].nameid;
  2296. } else
  2297. WBUFW(buf,9)=0;
  2298. }
  2299. clif_send(buf,packet_len_table[0x1d7],bl,AREA);
  2300. }
  2301. else if(sd && (type == LOOK_BASE) && (val > 255))
  2302. {
  2303. WBUFW(buf,0)=0x1d7;
  2304. WBUFL(buf,2)=bl->id;
  2305. WBUFB(buf,6)=type;
  2306. WBUFW(buf,7)=val;
  2307. WBUFW(buf,9)=0;
  2308. clif_send(buf,packet_len_table[0x1d7],bl,AREA);
  2309. } else {
  2310. WBUFW(buf,0)=0xc3;
  2311. WBUFL(buf,2)=bl->id;
  2312. WBUFB(buf,6)=type;
  2313. WBUFB(buf,7)=val;
  2314. clif_send(buf,packet_len_table[0xc3],bl,AREA);
  2315. }
  2316. #endif
  2317. return 0;
  2318. }
  2319. /*==========================================
  2320. *
  2321. *------------------------------------------
  2322. */
  2323. int clif_initialstatus(struct map_session_data *sd)
  2324. {
  2325. int fd;
  2326. unsigned char *buf;
  2327. nullpo_retr(0, sd);
  2328. fd=sd->fd;
  2329. buf=WFIFOP(fd,0);
  2330. WBUFW(buf,0)=0xbd;
  2331. WBUFW(buf,2)=sd->status.status_point;
  2332. WBUFB(buf,4)=(sd->status.str > 255)? 255:sd->status.str;
  2333. WBUFB(buf,5)=pc_need_status_point(sd,SP_STR);
  2334. WBUFB(buf,6)=(sd->status.agi > 255)? 255:sd->status.agi;
  2335. WBUFB(buf,7)=pc_need_status_point(sd,SP_AGI);
  2336. WBUFB(buf,8)=(sd->status.vit > 255)? 255:sd->status.vit;
  2337. WBUFB(buf,9)=pc_need_status_point(sd,SP_VIT);
  2338. WBUFB(buf,10)=(sd->status.int_ > 255)? 255:sd->status.int_;
  2339. WBUFB(buf,11)=pc_need_status_point(sd,SP_INT);
  2340. WBUFB(buf,12)=(sd->status.dex > 255)? 255:sd->status.dex;
  2341. WBUFB(buf,13)=pc_need_status_point(sd,SP_DEX);
  2342. WBUFB(buf,14)=(sd->status.luk > 255)? 255:sd->status.luk;
  2343. WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK);
  2344. WBUFW(buf,16) = sd->base_atk + sd->watk;
  2345. WBUFW(buf,18) = sd->watk2; //atk bonus
  2346. WBUFW(buf,20) = sd->matk1;
  2347. WBUFW(buf,22) = sd->matk2;
  2348. WBUFW(buf,24) = sd->def; // def
  2349. WBUFW(buf,26) = sd->def2;
  2350. WBUFW(buf,28) = sd->mdef; // mdef
  2351. WBUFW(buf,30) = sd->mdef2;
  2352. WBUFW(buf,32) = sd->hit;
  2353. WBUFW(buf,34) = sd->flee;
  2354. WBUFW(buf,36) = sd->flee2/10;
  2355. WBUFW(buf,38) = sd->critical/10;
  2356. WBUFW(buf,40) = sd->status.karma;
  2357. WBUFW(buf,42) = sd->status.manner;
  2358. WFIFOSET(fd,packet_len_table[0xbd]);
  2359. clif_updatestatus(sd,SP_STR);
  2360. clif_updatestatus(sd,SP_AGI);
  2361. clif_updatestatus(sd,SP_VIT);
  2362. clif_updatestatus(sd,SP_INT);
  2363. clif_updatestatus(sd,SP_DEX);
  2364. clif_updatestatus(sd,SP_LUK);
  2365. clif_updatestatus(sd,SP_ATTACKRANGE);
  2366. clif_updatestatus(sd,SP_ASPD);
  2367. return 0;
  2368. }
  2369. /*==========================================
  2370. *矢装備
  2371. *------------------------------------------
  2372. */
  2373. int clif_arrowequip(struct map_session_data *sd,int val)
  2374. {
  2375. int fd;
  2376. nullpo_retr(0, sd);
  2377. if(sd->attacktarget && sd->attacktarget > 0) // [Valaris]
  2378. sd->attacktarget = 0;
  2379. fd=sd->fd;
  2380. WFIFOW(fd,0)=0x013c;
  2381. WFIFOW(fd,2)=val+2;//矢のアイテムID
  2382. WFIFOSET(fd,packet_len_table[0x013c]);
  2383. return 0;
  2384. }
  2385. /*==========================================
  2386. *
  2387. *------------------------------------------
  2388. */
  2389. int clif_arrow_fail(struct map_session_data *sd,int type)
  2390. {
  2391. int fd;
  2392. nullpo_retr(0, sd);
  2393. fd=sd->fd;
  2394. WFIFOW(fd,0)=0x013b;
  2395. WFIFOW(fd,2)=type;
  2396. WFIFOSET(fd,packet_len_table[0x013b]);
  2397. return 0;
  2398. }
  2399. /*==========================================
  2400. * 作成可能 矢リスト送信
  2401. *------------------------------------------
  2402. */
  2403. int clif_arrow_create_list(struct map_session_data *sd)
  2404. {
  2405. int i,c,view;
  2406. int fd;
  2407. nullpo_retr(0, sd);
  2408. fd=sd->fd;
  2409. WFIFOW(fd,0)=0x1ad;
  2410. for(i=0,c=0;i<MAX_SKILL_ARROW_DB;i++){
  2411. if(skill_arrow_db[i].nameid > 0 && pc_search_inventory(sd,skill_arrow_db[i].nameid)>=0){
  2412. if((view = itemdb_viewid(skill_arrow_db[i].nameid)) > 0)
  2413. WFIFOW(fd,c*2+4) = view;
  2414. else
  2415. WFIFOW(fd,c*2+4) = skill_arrow_db[i].nameid;
  2416. c++;
  2417. }
  2418. }
  2419. WFIFOW(fd,2)=c*2+4;
  2420. WFIFOSET(fd,WFIFOW(fd,2));
  2421. if(c > 0) sd->state.make_arrow_flag = 1;
  2422. return 0;
  2423. }
  2424. /*==========================================
  2425. *
  2426. *------------------------------------------
  2427. */
  2428. int clif_statusupack(struct map_session_data *sd,int type,int ok,int val)
  2429. {
  2430. int fd;
  2431. nullpo_retr(0, sd);
  2432. fd=sd->fd;
  2433. WFIFOW(fd,0)=0xbc;
  2434. WFIFOW(fd,2)=type;
  2435. WFIFOB(fd,4)=ok;
  2436. WFIFOB(fd,5)=val;
  2437. WFIFOSET(fd,packet_len_table[0xbc]);
  2438. return 0;
  2439. }
  2440. /*==========================================
  2441. *
  2442. *------------------------------------------
  2443. */
  2444. int clif_equipitemack(struct map_session_data *sd,int n,int pos,int ok)
  2445. {
  2446. int fd;
  2447. nullpo_retr(0, sd);
  2448. fd=sd->fd;
  2449. WFIFOW(fd,0)=0xaa;
  2450. WFIFOW(fd,2)=n+2;
  2451. WFIFOW(fd,4)=pos;
  2452. WFIFOB(fd,6)=ok;
  2453. WFIFOSET(fd,packet_len_table[0xaa]);
  2454. return 0;
  2455. }
  2456. /*==========================================
  2457. *
  2458. *------------------------------------------
  2459. */
  2460. int clif_unequipitemack(struct map_session_data *sd,int n,int pos,int ok)
  2461. {
  2462. int fd;
  2463. nullpo_retr(0, sd);
  2464. fd=sd->fd;
  2465. WFIFOW(fd,0)=0xac;
  2466. WFIFOW(fd,2)=n+2;
  2467. WFIFOW(fd,4)=pos;
  2468. WFIFOB(fd,6)=ok;
  2469. WFIFOSET(fd,packet_len_table[0xac]);
  2470. return 0;
  2471. }
  2472. /*==========================================
  2473. *
  2474. *------------------------------------------
  2475. */
  2476. int clif_misceffect(struct block_list* bl,int type)
  2477. {
  2478. unsigned char buf[32];
  2479. nullpo_retr(0, bl);
  2480. WBUFW(buf,0) = 0x19b;
  2481. WBUFL(buf,2) = bl->id;
  2482. WBUFL(buf,6) = type;
  2483. clif_send(buf,packet_len_table[0x19b],bl,AREA);
  2484. return 0;
  2485. }
  2486. int clif_misceffect2(struct block_list *bl, int type) {
  2487. unsigned char buf[24];
  2488. nullpo_retr(0, bl);
  2489. memset(buf, 0, packet_len_table[0x1f3]);
  2490. WBUFW(buf,0) = 0x1f3;
  2491. WBUFL(buf,2) = bl->id;
  2492. WBUFL(buf,6) = type;
  2493. clif_send(buf, packet_len_table[0x1f3], bl, AREA);
  2494. return 0;
  2495. }
  2496. /*==========================================
  2497. * 表示オプション変更
  2498. *------------------------------------------
  2499. */
  2500. int clif_changeoption(struct block_list* bl)
  2501. {
  2502. unsigned char buf[32];
  2503. short option;
  2504. struct status_change *sc_data;
  2505. static const int omask[]={ 0x10,0x20 };
  2506. static const int scnum[]={ SC_FALCON, SC_RIDING };
  2507. int i;
  2508. nullpo_retr(0, bl);
  2509. option = *status_get_option(bl);
  2510. sc_data = status_get_sc_data(bl);
  2511. WBUFW(buf,0) = 0x119;
  2512. WBUFL(buf,2) = bl->id;
  2513. WBUFW(buf,6) = *status_get_opt1(bl);
  2514. WBUFW(buf,8) = *status_get_opt2(bl);
  2515. WBUFW(buf,10) = option;
  2516. WBUFB(buf,12) = 0; // ??
  2517. if(bl->type==BL_PC) { // disguises [Valaris]
  2518. struct map_session_data *sd=(struct map_session_data *)bl;
  2519. if(sd && sd->disguise > 23 && sd->disguise < 4001) {
  2520. clif_send(buf,packet_len_table[0x119],bl,AREA_WOS);
  2521. clif_spawnpc(sd);
  2522. } else
  2523. clif_send(buf,packet_len_table[0x119],bl,AREA);
  2524. } else
  2525. clif_send(buf,packet_len_table[0x119],bl,AREA);
  2526. // アイコンの表示
  2527. for(i=0;i<sizeof(omask)/sizeof(omask[0]);i++){
  2528. if( option&omask[i] ){
  2529. if( sc_data[scnum[i]].timer==-1)
  2530. status_change_start(bl,scnum[i],0,0,0,0,0,0);
  2531. } else {
  2532. status_change_end(bl,scnum[i],-1);
  2533. }
  2534. }
  2535. return 0;
  2536. }
  2537. /*==========================================
  2538. *
  2539. *------------------------------------------
  2540. */
  2541. int clif_useitemack(struct map_session_data *sd,int index,int amount,int ok)
  2542. {
  2543. nullpo_retr(0, sd);
  2544. if(!ok) {
  2545. int fd=sd->fd;
  2546. WFIFOW(fd,0)=0xa8;
  2547. WFIFOW(fd,2)=index+2;
  2548. WFIFOW(fd,4)=amount;
  2549. WFIFOB(fd,6)=ok;
  2550. WFIFOSET(fd,packet_len_table[0xa8]);
  2551. }
  2552. else {
  2553. #if PACKETVER < 3
  2554. int fd=sd->fd;
  2555. WFIFOW(fd,0)=0xa8;
  2556. WFIFOW(fd,2)=index+2;
  2557. WFIFOW(fd,4)=amount;
  2558. WFIFOB(fd,6)=ok;
  2559. WFIFOSET(fd,packet_len_table[0xa8]);
  2560. #else
  2561. unsigned char buf[32];
  2562. WBUFW(buf,0)=0x1c8;
  2563. WBUFW(buf,2)=index+2;
  2564. if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0)
  2565. WBUFW(buf,4)=sd->inventory_data[index]->view_id;
  2566. else
  2567. WBUFW(buf,4)=sd->status.inventory[index].nameid;
  2568. WBUFL(buf,6)=sd->bl.id;
  2569. WBUFW(buf,10)=amount;
  2570. WBUFB(buf,12)=ok;
  2571. clif_send(buf,packet_len_table[0x1c8],&sd->bl,AREA);
  2572. #endif
  2573. }
  2574. return 0;
  2575. }
  2576. /*==========================================
  2577. *
  2578. *------------------------------------------
  2579. */
  2580. int clif_createchat(struct map_session_data *sd,int fail)
  2581. {
  2582. int fd;
  2583. nullpo_retr(0, sd);
  2584. fd=sd->fd;
  2585. WFIFOW(fd,0)=0xd6;
  2586. WFIFOB(fd,2)=fail;
  2587. WFIFOSET(fd,packet_len_table[0xd6]);
  2588. return 0;
  2589. }
  2590. /*==========================================
  2591. *
  2592. *------------------------------------------
  2593. */
  2594. int clif_dispchat(struct chat_data *cd,int fd)
  2595. {
  2596. unsigned char buf[128]; // 最大title(60バイト)+17
  2597. if(cd==NULL || *cd->owner==NULL)
  2598. return 1;
  2599. WBUFW(buf,0)=0xd7;
  2600. WBUFW(buf,2)=strlen((const char*)cd->title)+17;
  2601. WBUFL(buf,4)=(*cd->owner)->id;
  2602. WBUFL(buf,8)=cd->bl.id;
  2603. WBUFW(buf,12)=cd->limit;
  2604. WBUFW(buf,14)=cd->users;
  2605. WBUFB(buf,16)=cd->pub;
  2606. strcpy((char*)WBUFP(buf,17),(const char*)cd->title);
  2607. if(fd){
  2608. memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2));
  2609. WFIFOSET(fd,WBUFW(buf,2));
  2610. } else {
  2611. clif_send(buf,WBUFW(buf,2),*cd->owner,AREA_WOSC);
  2612. }
  2613. return 0;
  2614. }
  2615. /*==========================================
  2616. * chatの状態変更成功
  2617. * 外部の人用と命令コード(d7->df)が違うだけ
  2618. *------------------------------------------
  2619. */
  2620. int clif_changechatstatus(struct chat_data *cd)
  2621. {
  2622. unsigned char buf[128]; // 最大title(60バイト)+17
  2623. if(cd==NULL || cd->usersd[0]==NULL)
  2624. return 1;
  2625. WBUFW(buf,0)=0xdf;
  2626. WBUFW(buf,2)=strlen((char*)cd->title)+17;
  2627. WBUFL(buf,4)=cd->usersd[0]->bl.id;
  2628. WBUFL(buf,8)=cd->bl.id;
  2629. WBUFW(buf,12)=cd->limit;
  2630. WBUFW(buf,14)=cd->users;
  2631. WBUFB(buf,16)=cd->pub;
  2632. strcpy((char*)WBUFP(buf,17),(const char*)cd->title);
  2633. clif_send(buf,WBUFW(buf,2),&cd->usersd[0]->bl,CHAT);
  2634. return 0;
  2635. }
  2636. /*==========================================
  2637. *
  2638. *------------------------------------------
  2639. */
  2640. int clif_clearchat(struct chat_data *cd,int fd)
  2641. {
  2642. unsigned char buf[32];
  2643. nullpo_retr(0, cd);
  2644. WBUFW(buf,0)=0xd8;
  2645. WBUFL(buf,2)=cd->bl.id;
  2646. if(fd){
  2647. memcpy(WFIFOP(fd,0),buf,packet_len_table[0xd8]);
  2648. WFIFOSET(fd,packet_len_table[0xd8]);
  2649. } else {
  2650. clif_send(buf,packet_len_table[0xd8],*cd->owner,AREA_WOSC);
  2651. }
  2652. return 0;
  2653. }
  2654. /*==========================================
  2655. *
  2656. *------------------------------------------
  2657. */
  2658. int clif_joinchatfail(struct map_session_data *sd,int fail)
  2659. {
  2660. int fd;
  2661. nullpo_retr(0, sd);
  2662. fd=sd->fd;
  2663. WFIFOW(fd,0)=0xda;
  2664. WFIFOB(fd,2)=fail;
  2665. WFIFOSET(fd,packet_len_table[0xda]);
  2666. return 0;
  2667. }
  2668. /*==========================================
  2669. *
  2670. *------------------------------------------
  2671. */
  2672. int clif_joinchatok(struct map_session_data *sd,struct chat_data* cd)
  2673. {
  2674. int fd;
  2675. int i;
  2676. nullpo_retr(0, sd);
  2677. nullpo_retr(0, cd);
  2678. fd=sd->fd;
  2679. WFIFOW(fd,0)=0xdb;
  2680. WFIFOW(fd,2)=8+(28*cd->users);
  2681. WFIFOL(fd,4)=cd->bl.id;
  2682. for(i = 0;i < cd->users;i++){
  2683. WFIFOL(fd,8+i*28) = (i!=0)||((*cd->owner)->type==BL_NPC);
  2684. memcpy(WFIFOP(fd,8+i*28+4),cd->usersd[i]->status.name,24);
  2685. }
  2686. WFIFOSET(fd,WFIFOW(fd,2));
  2687. return 0;
  2688. }
  2689. /*==========================================
  2690. *
  2691. *------------------------------------------
  2692. */
  2693. int clif_addchat(struct chat_data* cd,struct map_session_data *sd)
  2694. {
  2695. unsigned char buf[32];
  2696. nullpo_retr(0, sd);
  2697. nullpo_retr(0, cd);
  2698. WBUFW(buf, 0) = 0x0dc;
  2699. WBUFW(buf, 2) = cd->users;
  2700. memcpy(WBUFP(buf, 4),sd->status.name,24);
  2701. clif_send(buf,packet_len_table[0xdc],&sd->bl,CHAT_WOS);
  2702. return 0;
  2703. }
  2704. /*==========================================
  2705. *
  2706. *------------------------------------------
  2707. */
  2708. int clif_changechatowner(struct chat_data* cd,struct map_session_data *sd)
  2709. {
  2710. unsigned char buf[64];
  2711. nullpo_retr(0, sd);
  2712. nullpo_retr(0, cd);
  2713. WBUFW(buf, 0) = 0xe1;
  2714. WBUFL(buf, 2) = 1;
  2715. memcpy(WBUFP(buf,6),cd->usersd[0]->status.name,24);
  2716. WBUFW(buf,30) = 0xe1;
  2717. WBUFL(buf,32) = 0;
  2718. memcpy(WBUFP(buf,36),sd->status.name,24);
  2719. clif_send(buf,packet_len_table[0xe1]*2,&sd->bl,CHAT);
  2720. return 0;
  2721. }
  2722. /*==========================================
  2723. *
  2724. *------------------------------------------
  2725. */
  2726. int clif_leavechat(struct chat_data* cd,struct map_session_data *sd)
  2727. {
  2728. unsigned char buf[32];
  2729. nullpo_retr(0, sd);
  2730. nullpo_retr(0, cd);
  2731. WBUFW(buf, 0) = 0xdd;
  2732. WBUFW(buf, 2) = cd->users-1;
  2733. memcpy(WBUFP(buf,4),sd->status.name,24);
  2734. WBUFB(buf,28) = 0;
  2735. clif_send(buf,packet_len_table[0xdd],&sd->bl,CHAT);
  2736. return 0;
  2737. }
  2738. /*==========================================
  2739. * 取り引き要請受け
  2740. *------------------------------------------
  2741. */
  2742. int clif_traderequest(struct map_session_data *sd,char *name)
  2743. {
  2744. int fd;
  2745. nullpo_retr(0, sd);
  2746. fd=sd->fd;
  2747. WFIFOW(fd,0)=0xe5;
  2748. strcpy((char*)WFIFOP(fd,2),name);
  2749. WFIFOSET(fd,packet_len_table[0xe5]);
  2750. return 0;
  2751. }
  2752. /*==========================================
  2753. * 取り引き要求応答
  2754. *------------------------------------------
  2755. */
  2756. int clif_tradestart(struct map_session_data *sd,int type)
  2757. {
  2758. int fd;
  2759. nullpo_retr(0, sd);
  2760. fd=sd->fd;
  2761. WFIFOW(fd,0)=0xe7;
  2762. WFIFOB(fd,2)=type;
  2763. WFIFOSET(fd,packet_len_table[0xe7]);
  2764. return 0;
  2765. }
  2766. /*==========================================
  2767. * 相手方からのアイテム追加
  2768. *------------------------------------------
  2769. */
  2770. int clif_tradeadditem(struct map_session_data *sd,struct map_session_data *tsd,int index,int amount)
  2771. {
  2772. int fd,j;
  2773. nullpo_retr(0, sd);
  2774. nullpo_retr(0, tsd);
  2775. fd=tsd->fd;
  2776. WFIFOW(fd,0)=0xe9;
  2777. WFIFOL(fd,2)=amount;
  2778. if(index==0){
  2779. WFIFOW(fd,6) = 0; // type id
  2780. WFIFOB(fd,8) = 0; //identify flag
  2781. WFIFOB(fd,9) = 0; // attribute
  2782. WFIFOB(fd,10)= 0; //refine
  2783. WFIFOW(fd,11)= 0; //card (4w)
  2784. WFIFOW(fd,13)= 0; //card (4w)
  2785. WFIFOW(fd,15)= 0; //card (4w)
  2786. WFIFOW(fd,17)= 0; //card (4w)
  2787. }
  2788. else{
  2789. index -= 2;
  2790. if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0)
  2791. WFIFOW(fd,6) = sd->inventory_data[index]->view_id;
  2792. else
  2793. WFIFOW(fd,6) = sd->status.inventory[index].nameid; // type id
  2794. WFIFOB(fd,8) = sd->status.inventory[index].identify; //identify flag
  2795. WFIFOB(fd,9) = sd->status.inventory[index].attribute; // attribute
  2796. WFIFOB(fd,10)= sd->status.inventory[index].refine; //refine
  2797. if(sd->status.inventory[index].card[0]==0x00ff || sd->status.inventory[index].card[0]==0x00fe || sd->status.inventory[index].card[0]==(short)0xff00) {
  2798. WFIFOW(fd,11)= sd->status.inventory[index].card[0]; //card (4w)
  2799. WFIFOW(fd,13)= sd->status.inventory[index].card[1]; //card (4w)
  2800. WFIFOW(fd,15)= sd->status.inventory[index].card[2]; //card (4w)
  2801. WFIFOW(fd,17)= sd->status.inventory[index].card[3]; //card (4w)
  2802. } else {
  2803. if(sd->status.inventory[index].card[0] > 0 && (j=itemdb_viewid(sd->status.inventory[index].card[0])) > 0)
  2804. WFIFOW(fd,11)= j;
  2805. else
  2806. WFIFOW(fd,11)= sd->status.inventory[index].card[0];
  2807. if(sd->status.inventory[index].card[1] > 0 && (j=itemdb_viewid(sd->status.inventory[index].card[1])) > 0)
  2808. WFIFOW(fd,13)= j;
  2809. else
  2810. WFIFOW(fd,13)= sd->status.inventory[index].card[1];
  2811. if(sd->status.inventory[index].card[2] > 0 && (j=itemdb_viewid(sd->status.inventory[index].card[2])) > 0)
  2812. WFIFOW(fd,15)= j;
  2813. else
  2814. WFIFOW(fd,15)= sd->status.inventory[index].card[2];
  2815. if(sd->status.inventory[index].card[3] > 0 && (j=itemdb_viewid(sd->status.inventory[index].card[3])) > 0)
  2816. WFIFOW(fd,17)= j;
  2817. else
  2818. WFIFOW(fd,17)= sd->status.inventory[index].card[3];
  2819. }
  2820. }
  2821. WFIFOSET(fd,packet_len_table[0xe9]);
  2822. return 0;
  2823. }
  2824. /*==========================================
  2825. * アイテム追加成功/失敗
  2826. *------------------------------------------
  2827. */
  2828. int clif_tradeitemok(struct map_session_data *sd,int index,int fail)
  2829. {
  2830. int fd;
  2831. nullpo_retr(0, sd);
  2832. fd=sd->fd;
  2833. WFIFOW(fd,0)=0xea;
  2834. WFIFOW(fd,2)=index;
  2835. WFIFOB(fd,4)=fail;
  2836. WFIFOSET(fd,packet_len_table[0xea]);
  2837. return 0;
  2838. }
  2839. /*==========================================
  2840. * 取り引きok押し
  2841. *------------------------------------------
  2842. */
  2843. int clif_tradedeal_lock(struct map_session_data *sd,int fail)
  2844. {
  2845. int fd;
  2846. nullpo_retr(0, sd);
  2847. fd=sd->fd;
  2848. WFIFOW(fd,0)=0xec;
  2849. WFIFOB(fd,2)=fail; // 0=you 1=the other person
  2850. WFIFOSET(fd,packet_len_table[0xec]);
  2851. return 0;
  2852. }
  2853. /*==========================================
  2854. * 取り引きがキャンセルされました
  2855. *------------------------------------------
  2856. */
  2857. int clif_tradecancelled(struct map_session_data *sd)
  2858. {
  2859. int fd;
  2860. nullpo_retr(0, sd);
  2861. fd=sd->fd;
  2862. WFIFOW(fd,0)=0xee;
  2863. WFIFOSET(fd,packet_len_table[0xee]);
  2864. return 0;
  2865. }
  2866. /*==========================================
  2867. * 取り引き完了
  2868. *------------------------------------------
  2869. */
  2870. int clif_tradecompleted(struct map_session_data *sd,int fail)
  2871. {
  2872. int fd;
  2873. nullpo_retr(0, sd);
  2874. fd=sd->fd;
  2875. WFIFOW(fd,0)=0xf0;
  2876. WFIFOB(fd,2)=fail;
  2877. WFIFOSET(fd,packet_len_table[0xf0]);
  2878. return 0;
  2879. }
  2880. /*==========================================
  2881. * カプラ倉庫のアイテム数を更新
  2882. *------------------------------------------
  2883. */
  2884. int clif_updatestorageamount(struct map_session_data *sd,struct storage *stor)
  2885. {
  2886. int fd;
  2887. nullpo_retr(0, sd);
  2888. nullpo_retr(0, stor);
  2889. fd=sd->fd;
  2890. WFIFOW(fd,0) = 0xf2; // update storage amount
  2891. WFIFOW(fd,2) = stor->storage_amount; //items
  2892. WFIFOW(fd,4) = MAX_STORAGE; //items max
  2893. WFIFOSET(fd,packet_len_table[0xf2]);
  2894. return 0;
  2895. }
  2896. /*==========================================
  2897. * カプラ倉庫にアイテムを追加する
  2898. *------------------------------------------
  2899. */
  2900. int clif_storageitemadded(struct map_session_data *sd,struct storage *stor,int index,int amount)
  2901. {
  2902. int view,fd,j;
  2903. nullpo_retr(0, sd);
  2904. nullpo_retr(0, stor);
  2905. fd=sd->fd;
  2906. WFIFOW(fd,0) =0xf4; // Storage item added
  2907. WFIFOW(fd,2) =index+1; // index
  2908. WFIFOL(fd,4) =amount; // amount
  2909. if((view = itemdb_viewid(stor->storage[index].nameid)) > 0)
  2910. WFIFOW(fd,8) =view;
  2911. else
  2912. WFIFOW(fd,8) =stor->storage[index].nameid; // id
  2913. WFIFOB(fd,10)=stor->storage[index].identify; //identify flag
  2914. WFIFOB(fd,11)=stor->storage[index].attribute; // attribute
  2915. WFIFOB(fd,12)=stor->storage[index].refine; //refine
  2916. if(stor->storage[index].card[0]==0x00ff || stor->storage[index].card[0]==0x00fe || stor->storage[index].card[0]==(short)0xff00) {
  2917. WFIFOW(fd,13)=stor->storage[index].card[0]; //card (4w)
  2918. WFIFOW(fd,15)=stor->storage[index].card[1]; //card (4w)
  2919. WFIFOW(fd,17)=stor->storage[index].card[2]; //card (4w)
  2920. WFIFOW(fd,19)=stor->storage[index].card[3]; //card (4w)
  2921. } else {
  2922. if(stor->storage[index].card[0] > 0 && (j=itemdb_viewid(stor->storage[index].card[0])) > 0)
  2923. WFIFOW(fd,13)= j;
  2924. else
  2925. WFIFOW(fd,13)= stor->storage[index].card[0];
  2926. if(stor->storage[index].card[1] > 0 && (j=itemdb_viewid(stor->storage[index].card[1])) > 0)
  2927. WFIFOW(fd,15)= j;
  2928. else
  2929. WFIFOW(fd,15)= stor->storage[index].card[1];
  2930. if(stor->storage[index].card[2] > 0 && (j=itemdb_viewid(stor->storage[index].card[2])) > 0)
  2931. WFIFOW(fd,17)= j;
  2932. else
  2933. WFIFOW(fd,17)= stor->storage[index].card[2];
  2934. if(stor->storage[index].card[3] > 0 && (j=itemdb_viewid(stor->storage[index].card[3])) > 0)
  2935. WFIFOW(fd,19)= j;
  2936. else
  2937. WFIFOW(fd,19)= stor->storage[index].card[3];
  2938. }
  2939. WFIFOSET(fd,packet_len_table[0xf4]);
  2940. return 0;
  2941. }
  2942. /*==========================================
  2943. *
  2944. *------------------------------------------
  2945. */
  2946. int clif_updateguildstorageamount(struct map_session_data *sd,struct guild_storage *stor)
  2947. {
  2948. int fd;
  2949. nullpo_retr(0, sd);
  2950. nullpo_retr(0, stor);
  2951. fd=sd->fd;
  2952. WFIFOW(fd,0) = 0xf2; // update storage amount
  2953. WFIFOW(fd,2) = stor->storage_amount; //items
  2954. WFIFOW(fd,4) = MAX_GUILD_STORAGE; //items max
  2955. WFIFOSET(fd,packet_len_table[0xf2]);
  2956. return 0;
  2957. }
  2958. /*==========================================
  2959. *
  2960. *------------------------------------------
  2961. */
  2962. int clif_guildstorageitemadded(struct map_session_data *sd,struct guild_storage *stor,int index,int amount)
  2963. {
  2964. int view,fd,j;
  2965. nullpo_retr(0, sd);
  2966. nullpo_retr(0, stor);
  2967. fd=sd->fd;
  2968. WFIFOW(fd,0) =0xf4; // Storage item added
  2969. WFIFOW(fd,2) =index+1; // index
  2970. WFIFOL(fd,4) =amount; // amount
  2971. if((view = itemdb_viewid(stor->storage[index].nameid)) > 0)
  2972. WFIFOW(fd,8) =view;
  2973. else
  2974. WFIFOW(fd,8) =stor->storage[index].nameid; // id
  2975. WFIFOB(fd,10)=stor->storage[index].identify; //identify flag
  2976. WFIFOB(fd,11)=stor->storage[index].attribute; // attribute
  2977. WFIFOB(fd,12)=stor->storage[index].refine; //refine
  2978. if(stor->storage[index].card[0]==0x00ff || stor->storage[index].card[0]==0x00fe || stor->storage[index].card[0]==(short)0xff00) {
  2979. WFIFOW(fd,13)=stor->storage[index].card[0]; //card (4w)
  2980. WFIFOW(fd,15)=stor->storage[index].card[1]; //card (4w)
  2981. WFIFOW(fd,17)=stor->storage[index].card[2]; //card (4w)
  2982. WFIFOW(fd,19)=stor->storage[index].card[3]; //card (4w)
  2983. } else {
  2984. if(stor->storage[index].card[0] > 0 && (j=itemdb_viewid(stor->storage[index].card[0])) > 0)
  2985. WFIFOW(fd,13)= j;
  2986. else
  2987. WFIFOW(fd,13)= stor->storage[index].card[0];
  2988. if(stor->storage[index].card[1] > 0 && (j=itemdb_viewid(stor->storage[index].card[1])) > 0)
  2989. WFIFOW(fd,15)= j;
  2990. else
  2991. WFIFOW(fd,15)= stor->storage[index].card[1];
  2992. if(stor->storage[index].card[2] > 0 && (j=itemdb_viewid(stor->storage[index].card[2])) > 0)
  2993. WFIFOW(fd,17)= j;
  2994. else
  2995. WFIFOW(fd,17)= stor->storage[index].card[2];
  2996. if(stor->storage[index].card[3] > 0 && (j=itemdb_viewid(stor->storage[index].card[3])) > 0)
  2997. WFIFOW(fd,19)= j;
  2998. else
  2999. WFIFOW(fd,19)= stor->storage[index].card[3];
  3000. }
  3001. WFIFOSET(fd,packet_len_table[0xf4]);
  3002. return 0;
  3003. }
  3004. /*==========================================
  3005. * カプラ倉庫からアイテムを取り去る
  3006. *------------------------------------------
  3007. */
  3008. int clif_storageitemremoved(struct map_session_data *sd,int index,int amount)
  3009. {
  3010. int fd;
  3011. nullpo_retr(0, sd);
  3012. fd=sd->fd;
  3013. WFIFOW(fd,0)=0xf6; // Storage item removed
  3014. WFIFOW(fd,2)=index+1;
  3015. WFIFOL(fd,4)=amount;
  3016. WFIFOSET(fd,packet_len_table[0xf6]);
  3017. return 0;
  3018. }
  3019. /*==========================================
  3020. * カプラ倉庫を閉じる
  3021. *------------------------------------------
  3022. */
  3023. int clif_storageclose(struct map_session_data *sd)
  3024. {
  3025. int fd;
  3026. nullpo_retr(0, sd);
  3027. fd=sd->fd;
  3028. WFIFOW(fd,0)=0xf8; // Storage Closed
  3029. WFIFOSET(fd,packet_len_table[0xf8]);
  3030. return 0;
  3031. }
  3032. //
  3033. // callback系 ?
  3034. //
  3035. /*==========================================
  3036. * PC表示
  3037. *------------------------------------------
  3038. */
  3039. void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* dstsd)
  3040. {
  3041. int len;
  3042. nullpo_retv(sd);
  3043. nullpo_retv(dstsd);
  3044. if(dstsd->walktimer != -1){
  3045. len = clif_set007b(dstsd,WFIFOP(sd->fd,0));
  3046. WFIFOSET(sd->fd,len);
  3047. } else {
  3048. len = clif_set0078(dstsd,WFIFOP(sd->fd,0));
  3049. WFIFOSET(sd->fd,len);
  3050. }
  3051. if(dstsd->chatID){
  3052. struct chat_data *cd;
  3053. cd=(struct chat_data*)map_id2bl(dstsd->chatID);
  3054. if(cd->usersd[0]==dstsd)
  3055. clif_dispchat(cd,sd->fd);
  3056. }
  3057. if(dstsd->vender_id){
  3058. clif_showvendingboard(&dstsd->bl,dstsd->message,sd->fd);
  3059. }
  3060. if(dstsd->spiritball > 0) {
  3061. clif_set01e1(dstsd,WFIFOP(sd->fd,0));
  3062. WFIFOSET(sd->fd,packet_len_table[0x1e1]);
  3063. }
  3064. if(battle_config.save_clothcolor==1 && dstsd->status.clothes_color > 0)
  3065. clif_changelook(&dstsd->bl,LOOK_CLOTHES_COLOR,dstsd->status.clothes_color);
  3066. if(sd->status.manner < 0)
  3067. clif_changestatus(&sd->bl,SP_MANNER,sd->status.manner);
  3068. }
  3069. /*==========================================
  3070. * NPC表示
  3071. *------------------------------------------
  3072. */
  3073. //fixed by Valaris
  3074. void clif_getareachar_npc(struct map_session_data* sd,struct npc_data* nd)
  3075. {
  3076. int len;
  3077. nullpo_retv(sd);
  3078. nullpo_retv(nd);
  3079. if(nd->class_ < 0 || nd->flag&1 || nd->class_ == INVISIBLE_CLASS)
  3080. return;
  3081. if(nd->state.state == MS_WALK){
  3082. len = clif_npc007b(nd,WFIFOP(sd->fd,0));
  3083. WFIFOSET(sd->fd,len);
  3084. } else {
  3085. len = clif_npc0078(nd,WFIFOP(sd->fd,0));
  3086. WFIFOSET(sd->fd,len);
  3087. }
  3088. if(nd->chat_id){
  3089. clif_dispchat((struct chat_data*)map_id2bl(nd->chat_id),sd->fd);
  3090. }
  3091. }
  3092. /*==========================================
  3093. * 移動停止
  3094. *------------------------------------------
  3095. */
  3096. int clif_movemob(struct mob_data *md)
  3097. {
  3098. unsigned char buf[256];
  3099. int len;
  3100. nullpo_retr(0, md);
  3101. len = clif_mob007b(md,buf);
  3102. clif_send(buf,len,&md->bl,AREA);
  3103. if(mob_get_equip(md->class_) > 0) // mob equipment [Valaris]
  3104. clif_mob_equip(md,mob_get_equip(md->class_));
  3105. if(md->size==2) // tiny/big mobs [Valaris]
  3106. clif_specialeffect(&md->bl,423,0);
  3107. else if(md->size==1)
  3108. clif_specialeffect(&md->bl,421,0);
  3109. return 0;
  3110. }
  3111. /*==========================================
  3112. * モンスターの位置修正
  3113. *------------------------------------------
  3114. */
  3115. int clif_fixmobpos(struct mob_data *md)
  3116. {
  3117. unsigned char buf[256];
  3118. int len;
  3119. nullpo_retr(0, md);
  3120. if(md->state.state == MS_WALK){
  3121. len = clif_mob007b(md,buf);
  3122. clif_send(buf,len,&md->bl,AREA);
  3123. } else {
  3124. len = clif_mob0078(md,buf);
  3125. clif_send(buf,len,&md->bl,AREA);
  3126. }
  3127. return 0;
  3128. }
  3129. /*==========================================
  3130. * PCの位置修正
  3131. *------------------------------------------
  3132. */
  3133. int clif_fixpcpos(struct map_session_data *sd)
  3134. {
  3135. unsigned char buf[256];
  3136. int len;
  3137. nullpo_retr(0, sd);
  3138. if(sd->walktimer != -1){
  3139. len = clif_set007b(sd,buf);
  3140. clif_send(buf,len,&sd->bl,AREA);
  3141. } else {
  3142. len = clif_set0078(sd,buf);
  3143. clif_send(buf,len,&sd->bl,AREA);
  3144. }
  3145. return 0;
  3146. }
  3147. /*==========================================
  3148. *
  3149. *------------------------------------------
  3150. */
  3151. int clif_fixpetpos(struct pet_data *pd)
  3152. {
  3153. unsigned char buf[256];
  3154. int len;
  3155. nullpo_retr(0, pd);
  3156. if(pd->state.state == MS_WALK){
  3157. len = clif_pet007b(pd,buf);
  3158. clif_send(buf,len,&pd->bl,AREA);
  3159. } else {
  3160. len = clif_pet0078(pd,buf);
  3161. clif_send(buf,len,&pd->bl,AREA);
  3162. }
  3163. return 0;
  3164. }
  3165. // npc walking [Valaris]
  3166. int clif_fixnpcpos(struct npc_data *nd)
  3167. {
  3168. unsigned char buf[256];
  3169. int len;
  3170. nullpo_retr(0, nd);
  3171. if(nd->state.state == MS_WALK){
  3172. len = clif_npc007b(nd,buf);
  3173. clif_send(buf,len,&nd->bl,AREA);
  3174. } else {
  3175. len = clif_npc0078(nd,buf);
  3176. clif_send(buf,len,&nd->bl,AREA);
  3177. }
  3178. return 0;
  3179. }
  3180. /*==========================================
  3181. * 通常攻撃エフェクト&ダメージ
  3182. *------------------------------------------
  3183. */
  3184. 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)
  3185. {
  3186. unsigned char buf[256];
  3187. struct status_change *sc_data;
  3188. nullpo_retr(0, src);
  3189. nullpo_retr(0, dst);
  3190. sc_data = status_get_sc_data(dst);
  3191. if(type != 4 && dst->type == BL_PC && ((struct map_session_data *)dst)->special_state.infinite_endure)
  3192. type = 9;
  3193. if(sc_data) {
  3194. if(type != 4 && sc_data[SC_ENDURE].timer != -1)
  3195. type = 9;
  3196. if(sc_data[SC_HALLUCINATION].timer != -1) {
  3197. if(damage > 0)
  3198. damage = damage*(5+sc_data[SC_HALLUCINATION].val1) + rand()%100;
  3199. if(damage2 > 0)
  3200. damage2 = damage2*(5+sc_data[SC_HALLUCINATION].val1) + rand()%100;
  3201. }
  3202. }
  3203. WBUFW(buf,0)=0x8a;
  3204. WBUFL(buf,2)=src->id;
  3205. WBUFL(buf,6)=dst->id;
  3206. WBUFL(buf,10)=tick;
  3207. WBUFL(buf,14)=sdelay;
  3208. WBUFL(buf,18)=ddelay;
  3209. WBUFW(buf,22)=(damage > 0x7fff)? 0x7fff:damage;
  3210. WBUFW(buf,24)=div;
  3211. WBUFB(buf,26)=type;
  3212. WBUFW(buf,27)=damage2;
  3213. clif_send(buf,packet_len_table[0x8a],src,AREA);
  3214. return 0;
  3215. }
  3216. /*==========================================
  3217. *
  3218. *------------------------------------------
  3219. */
  3220. void clif_getareachar_mob(struct map_session_data* sd,struct mob_data* md)
  3221. {
  3222. int len;
  3223. nullpo_retv(sd);
  3224. nullpo_retv(md);
  3225. if (session[sd->fd] == NULL)
  3226. return;
  3227. if(md->state.state == MS_WALK){
  3228. len = clif_mob007b(md,WFIFOP(sd->fd,0));
  3229. WFIFOSET(sd->fd,len);
  3230. } else {
  3231. len = clif_mob0078(md,WFIFOP(sd->fd,0));
  3232. WFIFOSET(sd->fd,len);
  3233. }
  3234. if(mob_get_equip(md->class_) > 0) // mob equipment [Valaris]
  3235. clif_mob_equip(md,mob_get_equip(md->class_));
  3236. if(md->size==2) // tiny/big mobs [Valaris]
  3237. clif_specialeffect(&md->bl,423,0);
  3238. else if(md->size==1)
  3239. clif_specialeffect(&md->bl,421,0);
  3240. }
  3241. /*==========================================
  3242. *
  3243. *------------------------------------------
  3244. */
  3245. void clif_getareachar_pet(struct map_session_data* sd,struct pet_data* pd)
  3246. {
  3247. int len;
  3248. nullpo_retv(sd);
  3249. nullpo_retv(pd);
  3250. if(pd->state.state == MS_WALK){
  3251. len = clif_pet007b(pd,WFIFOP(sd->fd,0));
  3252. WFIFOSET(sd->fd,len);
  3253. } else {
  3254. len = clif_pet0078(pd,WFIFOP(sd->fd,0));
  3255. WFIFOSET(sd->fd,len);
  3256. }
  3257. }
  3258. /*==========================================
  3259. *
  3260. *------------------------------------------
  3261. */
  3262. void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fitem)
  3263. {
  3264. int view,fd;
  3265. nullpo_retv(sd);
  3266. nullpo_retv(fitem);
  3267. fd=sd->fd;
  3268. //009d <ID>.l <item ID>.w <identify flag>.B <X>.w <Y>.w <amount>.w <subX>.B <subY>.B
  3269. WFIFOW(fd,0)=0x9d;
  3270. WFIFOL(fd,2)=fitem->bl.id;
  3271. if((view = itemdb_viewid(fitem->item_data.nameid)) > 0)
  3272. WFIFOW(fd,6)=view;
  3273. else
  3274. WFIFOW(fd,6)=fitem->item_data.nameid;
  3275. WFIFOB(fd,8)=fitem->item_data.identify;
  3276. WFIFOW(fd,9)=fitem->bl.x;
  3277. WFIFOW(fd,11)=fitem->bl.y;
  3278. WFIFOW(fd,13)=fitem->item_data.amount;
  3279. WFIFOB(fd,15)=fitem->subx;
  3280. WFIFOB(fd,16)=fitem->suby;
  3281. WFIFOSET(fd,packet_len_table[0x9d]);
  3282. }
  3283. /*==========================================
  3284. * 場所スキルエフェクトが視界に入る
  3285. *------------------------------------------
  3286. */
  3287. int clif_getareachar_skillunit(struct map_session_data *sd,struct skill_unit *unit)
  3288. {
  3289. int fd;
  3290. struct block_list *bl;
  3291. nullpo_retr(0, unit);
  3292. fd=sd->fd;
  3293. bl=map_id2bl(unit->group->src_id);
  3294. #if PACKETVER < 3
  3295. memset(WFIFOP(fd,0),0,packet_len_table[0x11f]);
  3296. WFIFOW(fd, 0)=0x11f;
  3297. WFIFOL(fd, 2)=unit->bl.id;
  3298. WFIFOL(fd, 6)=unit->group->src_id;
  3299. WFIFOW(fd,10)=unit->bl.x;
  3300. WFIFOW(fd,12)=unit->bl.y;
  3301. WFIFOB(fd,14)=unit->group->unit_id;
  3302. WFIFOB(fd,15)=0;
  3303. WFIFOSET(fd,packet_len_table[0x11f]);
  3304. #else
  3305. memset(WFIFOP(fd,0),0,packet_len_table[0x1c9]);
  3306. WFIFOW(fd, 0)=0x1c9;
  3307. WFIFOL(fd, 2)=unit->bl.id;
  3308. WFIFOL(fd, 6)=unit->group->src_id;
  3309. WFIFOW(fd,10)=unit->bl.x;
  3310. WFIFOW(fd,12)=unit->bl.y;
  3311. WFIFOB(fd,14)=unit->group->unit_id;
  3312. WFIFOB(fd,15)=1;
  3313. WFIFOL(fd,15+1)=0; //1-4調べた限り固定
  3314. WFIFOL(fd,15+5)=0; //5-8調べた限り固定
  3315. //9-12マップごとで一定の77-80とはまた違う4バイトのかなり大きな数字
  3316. WFIFOL(fd,15+13)=unit->bl.y - 0x12; //13-16ユニットのY座標-18っぽい(Y:17でFF FF FF FF)
  3317. WFIFOL(fd,15+17)=0x004f37dd; //17-20調べた限り固定
  3318. WFIFOL(fd,15+21)=0x0012f674; //21-24調べた限り固定
  3319. WFIFOL(fd,15+25)=0x0012f664; //25-28調べた限り固定
  3320. WFIFOL(fd,15+29)=0x0012f654; //29-32調べた限り固定
  3321. WFIFOL(fd,15+33)=0x77527bbc; //33-36調べた限り固定
  3322. //37-39
  3323. WFIFOB(fd,15+40)=0x2d; //40調べた限り固定
  3324. WFIFOL(fd,15+41)=0; //41-44調べた限り0固定
  3325. WFIFOL(fd,15+45)=0; //45-48調べた限り0固定
  3326. WFIFOL(fd,15+49)=0; //49-52調べた限り0固定
  3327. WFIFOL(fd,15+53)=0x0048d919; //53-56調べた限り固定
  3328. WFIFOL(fd,15+57)=0x0000003e; //57-60調べた限り固定
  3329. WFIFOL(fd,15+61)=0x0012f66c; //61-64調べた限り固定
  3330. //65-68
  3331. //69-72
  3332. if(bl) WFIFOL(fd,15+73)=bl->y; //73-76術者のY座標
  3333. WFIFOL(fd,15+77)=unit->bl.m; //77-80マップIDかなぁ?かなり2バイトで足りそうな数字
  3334. WFIFOB(fd,15+81)=0xaa; //81終端文字0xaa
  3335. /* Graffiti [Valaris] */
  3336. if(unit->group->unit_id==0xb0) {
  3337. WFIFOL(fd,15)=1;
  3338. WFIFOL(fd,16)=1;
  3339. memcpy(WFIFOP(fd,17),unit->group->valstr,80);
  3340. }
  3341. WFIFOSET(fd,packet_len_table[0x1c9]);
  3342. #endif
  3343. if(unit->group->skill_id == WZ_ICEWALL)
  3344. clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,5);
  3345. return 0;
  3346. }
  3347. /*==========================================
  3348. * 場所スキルエフェクトが視界から消える
  3349. *------------------------------------------
  3350. */
  3351. int clif_clearchar_skillunit(struct skill_unit *unit,int fd)
  3352. {
  3353. nullpo_retr(0, unit);
  3354. WFIFOW(fd, 0)=0x120;
  3355. WFIFOL(fd, 2)=unit->bl.id;
  3356. WFIFOSET(fd,packet_len_table[0x120]);
  3357. if(unit->group && unit->group->skill_id == WZ_ICEWALL)
  3358. clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2);
  3359. return 0;
  3360. }
  3361. /*==========================================
  3362. *
  3363. *------------------------------------------
  3364. */
  3365. int clif_01ac(struct block_list *bl)
  3366. {
  3367. unsigned char buf[32];
  3368. nullpo_retr(0, bl);
  3369. WBUFW(buf, 0) = 0x1ac;
  3370. WBUFL(buf, 2) = bl->id;
  3371. clif_send(buf,packet_len_table[0x1ac],bl,AREA);
  3372. return 0;
  3373. }
  3374. /*==========================================
  3375. *
  3376. *------------------------------------------
  3377. */
  3378. int clif_getareachar(struct block_list* bl,va_list ap)
  3379. {
  3380. struct map_session_data *sd;
  3381. nullpo_retr(0, bl);
  3382. nullpo_retr(0, ap);
  3383. sd=va_arg(ap,struct map_session_data*);
  3384. if (sd == NULL || session[sd->fd] == NULL)
  3385. return 0;
  3386. switch(bl->type){
  3387. case BL_PC:
  3388. if(sd==(struct map_session_data*)bl)
  3389. break;
  3390. clif_getareachar_pc(sd,(struct map_session_data*) bl);
  3391. break;
  3392. case BL_NPC:
  3393. clif_getareachar_npc(sd,(struct npc_data*) bl);
  3394. break;
  3395. case BL_MOB:
  3396. clif_getareachar_mob(sd,(struct mob_data*) bl);
  3397. break;
  3398. case BL_PET:
  3399. clif_getareachar_pet(sd,(struct pet_data*) bl);
  3400. break;
  3401. case BL_ITEM:
  3402. clif_getareachar_item(sd,(struct flooritem_data*) bl);
  3403. break;
  3404. case BL_SKILL:
  3405. clif_getareachar_skillunit(sd,(struct skill_unit *)bl);
  3406. break;
  3407. default:
  3408. if(battle_config.error_log)
  3409. printf("get area char ??? %d\n",bl->type);
  3410. break;
  3411. }
  3412. return 0;
  3413. }
  3414. /*==========================================
  3415. *
  3416. *------------------------------------------
  3417. */
  3418. int clif_pcoutsight(struct block_list *bl,va_list ap)
  3419. {
  3420. struct map_session_data *sd,*dstsd;
  3421. nullpo_retr(0, bl);
  3422. nullpo_retr(0, ap);
  3423. nullpo_retr(0, sd=va_arg(ap,struct map_session_data*));
  3424. switch(bl->type){
  3425. case BL_PC:
  3426. dstsd = (struct map_session_data*) bl;
  3427. if(sd != dstsd) {
  3428. clif_clearchar_id(dstsd->bl.id,0,sd->fd);
  3429. clif_clearchar_id(sd->bl.id,0,dstsd->fd);
  3430. if(dstsd->chatID){
  3431. struct chat_data *cd;
  3432. cd=(struct chat_data*)map_id2bl(dstsd->chatID);
  3433. if(cd->usersd[0]==dstsd)
  3434. clif_dispchat(cd,sd->fd);
  3435. }
  3436. if(dstsd->vender_id){
  3437. clif_closevendingboard(&dstsd->bl,sd->fd);
  3438. }
  3439. }
  3440. break;
  3441. case BL_NPC:
  3442. if( ((struct npc_data *)bl)->class_ != INVISIBLE_CLASS )
  3443. clif_clearchar_id(bl->id,0,sd->fd);
  3444. break;
  3445. case BL_MOB:
  3446. case BL_PET:
  3447. clif_clearchar_id(bl->id,0,sd->fd);
  3448. break;
  3449. case BL_ITEM:
  3450. clif_clearflooritem((struct flooritem_data*)bl,sd->fd);
  3451. break;
  3452. case BL_SKILL:
  3453. clif_clearchar_skillunit((struct skill_unit *)bl,sd->fd);
  3454. break;
  3455. }
  3456. return 0;
  3457. }
  3458. /*==========================================
  3459. *
  3460. *------------------------------------------
  3461. */
  3462. int clif_pcinsight(struct block_list *bl,va_list ap)
  3463. {
  3464. struct map_session_data *sd,*dstsd;
  3465. nullpo_retr(0, bl);
  3466. nullpo_retr(0, ap);
  3467. nullpo_retr(0, sd=va_arg(ap,struct map_session_data*));
  3468. switch(bl->type){
  3469. case BL_PC:
  3470. dstsd = (struct map_session_data *)bl;
  3471. if(sd != dstsd) {
  3472. clif_getareachar_pc(sd,dstsd);
  3473. clif_getareachar_pc(dstsd,sd);
  3474. }
  3475. break;
  3476. case BL_NPC:
  3477. clif_getareachar_npc(sd,(struct npc_data*)bl);
  3478. break;
  3479. case BL_MOB:
  3480. clif_getareachar_mob(sd,(struct mob_data*)bl);
  3481. break;
  3482. case BL_PET:
  3483. clif_getareachar_pet(sd,(struct pet_data*)bl);
  3484. break;
  3485. case BL_ITEM:
  3486. clif_getareachar_item(sd,(struct flooritem_data*)bl);
  3487. break;
  3488. case BL_SKILL:
  3489. clif_getareachar_skillunit(sd,(struct skill_unit *)bl);
  3490. break;
  3491. }
  3492. return 0;
  3493. }
  3494. /*==========================================
  3495. *
  3496. *------------------------------------------
  3497. */
  3498. int clif_moboutsight(struct block_list *bl,va_list ap)
  3499. {
  3500. struct map_session_data *sd;
  3501. struct mob_data *md;
  3502. nullpo_retr(0, bl);
  3503. nullpo_retr(0, ap);
  3504. nullpo_retr(0, md=va_arg(ap,struct mob_data*));
  3505. if(bl->type==BL_PC
  3506. && ((sd = (struct map_session_data*) bl) != NULL)
  3507. && session[sd->fd] != NULL) {
  3508. clif_clearchar_id(md->bl.id,0,sd->fd);
  3509. }
  3510. return 0;
  3511. }
  3512. /*==========================================
  3513. *
  3514. *------------------------------------------
  3515. */
  3516. int clif_mobinsight(struct block_list *bl,va_list ap)
  3517. {
  3518. struct map_session_data *sd;
  3519. struct mob_data *md;
  3520. nullpo_retr(0, bl);
  3521. nullpo_retr(0, ap);
  3522. md=va_arg(ap,struct mob_data*);
  3523. if(bl->type==BL_PC
  3524. && ((sd = (struct map_session_data*) bl) != NULL)
  3525. && session[sd->fd] != NULL) {
  3526. clif_getareachar_mob(sd,md);
  3527. }
  3528. return 0;
  3529. }
  3530. /*==========================================
  3531. *
  3532. *------------------------------------------
  3533. */
  3534. int clif_petoutsight(struct block_list *bl,va_list ap)
  3535. {
  3536. struct map_session_data *sd;
  3537. struct pet_data *pd;
  3538. nullpo_retr(0, bl);
  3539. nullpo_retr(0, ap);
  3540. nullpo_retr(0, pd=va_arg(ap,struct pet_data*));
  3541. if(bl->type==BL_PC
  3542. && ((sd = (struct map_session_data*) bl) != NULL)
  3543. && session[sd->fd] != NULL) {
  3544. clif_clearchar_id(pd->bl.id,0,sd->fd);
  3545. }
  3546. return 0;
  3547. }
  3548. // npc walking [Valaris]
  3549. int clif_npcoutsight(struct block_list *bl,va_list ap)
  3550. {
  3551. struct map_session_data *sd;
  3552. struct npc_data *nd;
  3553. nullpo_retr(0, bl);
  3554. nullpo_retr(0, ap);
  3555. nullpo_retr(0, nd=va_arg(ap,struct npc_data*));
  3556. if(bl->type==BL_PC
  3557. && ((sd = (struct map_session_data*) bl) != NULL)
  3558. && session[sd->fd] != NULL) {
  3559. clif_clearchar_id(nd->bl.id,0,sd->fd);
  3560. }
  3561. return 0;
  3562. }
  3563. /*==========================================
  3564. *
  3565. *------------------------------------------
  3566. */
  3567. int clif_petinsight(struct block_list *bl,va_list ap)
  3568. {
  3569. struct map_session_data *sd;
  3570. struct pet_data *pd;
  3571. nullpo_retr(0, bl);
  3572. nullpo_retr(0, ap);
  3573. pd=va_arg(ap,struct pet_data*);
  3574. if(bl->type==BL_PC
  3575. && ((sd = (struct map_session_data*) bl) != NULL)
  3576. && session[sd->fd] != NULL) {
  3577. clif_getareachar_pet(sd,pd);
  3578. }
  3579. return 0;
  3580. }
  3581. // npc walking [Valaris]
  3582. int clif_npcinsight(struct block_list *bl,va_list ap)
  3583. {
  3584. struct map_session_data *sd;
  3585. struct npc_data *nd;
  3586. nullpo_retr(0, bl);
  3587. nullpo_retr(0, ap);
  3588. nd=va_arg(ap,struct npc_data*);
  3589. if(bl->type==BL_PC
  3590. && ((sd = (struct map_session_data*) bl) != NULL)
  3591. && session[sd->fd] != NULL) {
  3592. clif_getareachar_npc(sd,nd);
  3593. }
  3594. return 0;
  3595. }
  3596. /*==========================================
  3597. *
  3598. *------------------------------------------
  3599. */
  3600. int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range)
  3601. {
  3602. int fd,id;
  3603. nullpo_retr(0, sd);
  3604. fd=sd->fd;
  3605. if( (id=sd->status.skill[skillid].id) <= 0 )
  3606. return 0;
  3607. WFIFOW(fd,0)=0x147;
  3608. WFIFOW(fd,2) = id;
  3609. if(type < 0)
  3610. WFIFOW(fd,4) = skill_get_inf(id);
  3611. else
  3612. WFIFOW(fd,4) = type;
  3613. WFIFOW(fd,6) = 0;
  3614. WFIFOW(fd,8) = sd->status.skill[skillid].lv;
  3615. WFIFOW(fd,10) = skill_get_sp(id,sd->status.skill[skillid].lv);
  3616. if(range < 0) {
  3617. range = skill_get_range(id,sd->status.skill[skillid].lv);
  3618. if(range < 0)
  3619. range = status_get_range(&sd->bl) - (range + 1);
  3620. WFIFOW(fd,12)= range;
  3621. } else
  3622. WFIFOW(fd,12)= range;
  3623. memset(WFIFOP(fd,14),0,24);
  3624. if(!(skill_get_inf2(id)&0x01) || battle_config.quest_skill_learn == 1 || (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill) )
  3625. //WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_get_max(id) && sd->status.skill[skillid].flag ==0 )? 1:0;
  3626. WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_tree_get_max(id, sd->status.class_) && sd->status.skill[skillid].flag ==0 )? 1:0;
  3627. else
  3628. WFIFOB(fd,38) = 0;
  3629. WFIFOSET(fd,packet_len_table[0x147]);
  3630. return 0;
  3631. }
  3632. /*==========================================
  3633. * スキルリストを送信する
  3634. *------------------------------------------
  3635. */
  3636. int clif_skillinfoblock(struct map_session_data *sd)
  3637. {
  3638. int fd;
  3639. int i,c,len=4,id,range;
  3640. nullpo_retr(0, sd);
  3641. fd=sd->fd;
  3642. WFIFOW(fd,0)=0x10f;
  3643. for ( i = c = 0; i < MAX_SKILL; i++){
  3644. if( (id=sd->status.skill[i].id)!=0 ){
  3645. WFIFOW(fd,len ) = id;
  3646. WFIFOW(fd,len+2) = skill_get_inf(id);
  3647. WFIFOW(fd,len+4) = 0;
  3648. WFIFOW(fd,len+6) = sd->status.skill[i].lv;
  3649. WFIFOW(fd,len+8) = skill_get_sp(id,sd->status.skill[i].lv);
  3650. range = skill_get_range(id,sd->status.skill[i].lv);
  3651. if(range < 0)
  3652. range = status_get_range(&sd->bl) - (range + 1);
  3653. WFIFOW(fd,len+10)= range;
  3654. memset(WFIFOP(fd,len+12),0,24);
  3655. if(!(skill_get_inf2(id)&0x01) || battle_config.quest_skill_learn == 1 || (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill) )
  3656. //WFIFOB(fd,len+36)= (sd->status.skill[i].lv < skill_get_max(id) && sd->status.skill[i].flag ==0 )? 1:0;
  3657. 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;
  3658. else
  3659. WFIFOB(fd,len+36) = 0;
  3660. len+=37;
  3661. c++;
  3662. }
  3663. }
  3664. WFIFOW(fd,2)=len;
  3665. WFIFOSET(fd,len);
  3666. return 0;
  3667. }
  3668. /*==========================================
  3669. * スキル割り振り通知
  3670. *------------------------------------------
  3671. */
  3672. int clif_skillup(struct map_session_data *sd,int skill_num)
  3673. {
  3674. int range,fd;
  3675. nullpo_retr(0, sd);
  3676. fd=sd->fd;
  3677. WFIFOW(fd,0) = 0x10e;
  3678. WFIFOW(fd,2) = skill_num;
  3679. WFIFOW(fd,4) = sd->status.skill[skill_num].lv;
  3680. WFIFOW(fd,6) = skill_get_sp(skill_num,sd->status.skill[skill_num].lv);
  3681. range = skill_get_range(skill_num,sd->status.skill[skill_num].lv);
  3682. if(range < 0)
  3683. range = status_get_range(&sd->bl) - (range + 1);
  3684. WFIFOW(fd,8) = range;
  3685. //WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_get_max(sd->status.skill[skill_num].id)) ? 1 : 0;
  3686. WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_tree_get_max(sd->status.skill[skill_num].id, sd->status.class_)) ? 1 : 0;
  3687. WFIFOSET(fd,packet_len_table[0x10e]);
  3688. return 0;
  3689. }
  3690. /*==========================================
  3691. * スキル詠唱エフェクトを送信する
  3692. *------------------------------------------
  3693. */
  3694. int clif_skillcasting(struct block_list* bl,
  3695. int src_id,int dst_id,int dst_x,int dst_y,int skill_num,int casttime)
  3696. {
  3697. unsigned char buf[32];
  3698. WBUFW(buf,0) = 0x13e;
  3699. WBUFL(buf,2) = src_id;
  3700. WBUFL(buf,6) = dst_id;
  3701. WBUFW(buf,10) = dst_x;
  3702. WBUFW(buf,12) = dst_y;
  3703. WBUFW(buf,14) = skill_num;//魔法詠唱スキル
  3704. WBUFL(buf,16) = skill_get_pl(skill_num);//属性
  3705. WBUFL(buf,20) = casttime;//skill詠唱時間
  3706. clif_send(buf,packet_len_table[0x13e], bl, AREA);
  3707. return 0;
  3708. }
  3709. /*==========================================
  3710. *
  3711. *------------------------------------------
  3712. */
  3713. int clif_skillcastcancel(struct block_list* bl)
  3714. {
  3715. unsigned char buf[16];
  3716. nullpo_retr(0, bl);
  3717. WBUFW(buf,0) = 0x1b9;
  3718. WBUFL(buf,2) = bl->id;
  3719. clif_send(buf,packet_len_table[0x1b9], bl, AREA);
  3720. return 0;
  3721. }
  3722. /*==========================================
  3723. * スキル詠唱失敗
  3724. *------------------------------------------
  3725. */
  3726. int clif_skill_fail(struct map_session_data *sd,int skill_id,int type,int btype)
  3727. {
  3728. int fd;
  3729. nullpo_retr(0, sd);
  3730. fd=sd->fd;
  3731. // reset all variables [celest]
  3732. sd->skillx = sd->skilly = -1;
  3733. sd->skillid = sd->skilllv = -1;
  3734. sd->skillitem = sd->skillitemlv = -1;
  3735. if(type==0x4 && battle_config.display_delay_skill_fail==0){
  3736. return 0;
  3737. }
  3738. WFIFOW(fd,0) = 0x110;
  3739. WFIFOW(fd,2) = skill_id;
  3740. WFIFOW(fd,4) = btype;
  3741. WFIFOW(fd,6) = 0;
  3742. WFIFOB(fd,8) = 0;
  3743. WFIFOB(fd,9) = type;
  3744. WFIFOSET(fd,packet_len_table[0x110]);
  3745. return 0;
  3746. }
  3747. /*==========================================
  3748. * スキル攻撃エフェクト&ダメージ
  3749. *------------------------------------------
  3750. */
  3751. int clif_skill_damage(struct block_list *src,struct block_list *dst,
  3752. unsigned int tick,int sdelay,int ddelay,int damage,int div,int skill_id,int skill_lv,int type)
  3753. {
  3754. unsigned char buf[64];
  3755. struct status_change *sc_data;
  3756. nullpo_retr(0, src);
  3757. nullpo_retr(0, dst);
  3758. sc_data = status_get_sc_data(dst);
  3759. if(type != 5 && dst->type == BL_PC && ((struct map_session_data *)dst)->special_state.infinite_endure)
  3760. type = 9;
  3761. if(sc_data) {
  3762. if(type != 5 && sc_data[SC_ENDURE].timer != -1)
  3763. type = 9;
  3764. if(sc_data[SC_HALLUCINATION].timer != -1 && damage > 0)
  3765. damage = damage*(5+sc_data[SC_HALLUCINATION].val1) + rand()%100;
  3766. }
  3767. #if PACKETVER < 3
  3768. WBUFW(buf,0)=0x114;
  3769. WBUFW(buf,2)=skill_id;
  3770. WBUFL(buf,4)=src->id;
  3771. WBUFL(buf,8)=dst->id;
  3772. WBUFL(buf,12)=tick;
  3773. WBUFL(buf,16)=sdelay;
  3774. WBUFL(buf,20)=ddelay;
  3775. WBUFW(buf,24)=damage;
  3776. WBUFW(buf,26)=skill_lv;
  3777. WBUFW(buf,28)=div;
  3778. WBUFB(buf,30)=(type>0)?type:skill_get_hit(skill_id);
  3779. clif_send(buf,packet_len_table[0x114],src,AREA);
  3780. #else
  3781. WBUFW(buf,0)=0x1de;
  3782. WBUFW(buf,2)=skill_id;
  3783. WBUFL(buf,4)=src->id;
  3784. WBUFL(buf,8)=dst->id;
  3785. WBUFL(buf,12)=tick;
  3786. WBUFL(buf,16)=sdelay;
  3787. WBUFL(buf,20)=ddelay;
  3788. WBUFL(buf,24)=damage;
  3789. WBUFW(buf,28)=skill_lv;
  3790. WBUFW(buf,30)=div;
  3791. WBUFB(buf,32)=(type>0)?type:skill_get_hit(skill_id);
  3792. clif_send(buf,packet_len_table[0x1de],src,AREA);
  3793. #endif
  3794. return 0;
  3795. }
  3796. /*==========================================
  3797. * 吹き飛ばしスキル攻撃エフェクト&ダメージ
  3798. *------------------------------------------
  3799. */
  3800. int clif_skill_damage2(struct block_list *src,struct block_list *dst,
  3801. unsigned int tick,int sdelay,int ddelay,int damage,int div,int skill_id,int skill_lv,int type)
  3802. {
  3803. unsigned char buf[64];
  3804. struct status_change *sc_data;
  3805. nullpo_retr(0, src);
  3806. nullpo_retr(0, dst);
  3807. sc_data = status_get_sc_data(dst);
  3808. if(type != 5 && dst->type == BL_PC && ((struct map_session_data *)dst)->special_state.infinite_endure)
  3809. type = 9;
  3810. if(sc_data) {
  3811. if(type != 5 && sc_data[SC_ENDURE].timer != -1)
  3812. type = 9;
  3813. if(sc_data[SC_HALLUCINATION].timer != -1 && damage > 0)
  3814. damage = damage*(5+sc_data[SC_HALLUCINATION].val1) + rand()%100;
  3815. }
  3816. WBUFW(buf,0)=0x115;
  3817. WBUFW(buf,2)=skill_id;
  3818. WBUFL(buf,4)=src->id;
  3819. WBUFL(buf,8)=dst->id;
  3820. WBUFL(buf,12)=tick;
  3821. WBUFL(buf,16)=sdelay;
  3822. WBUFL(buf,20)=ddelay;
  3823. WBUFW(buf,24)=dst->x;
  3824. WBUFW(buf,26)=dst->y;
  3825. WBUFW(buf,28)=damage;
  3826. WBUFW(buf,30)=skill_lv;
  3827. WBUFW(buf,32)=div;
  3828. WBUFB(buf,34)=(type>0)?type:skill_get_hit(skill_id);
  3829. clif_send(buf,packet_len_table[0x115],src,AREA);
  3830. return 0;
  3831. }
  3832. /*==========================================
  3833. * 支援/回復スキルエフェクト
  3834. *------------------------------------------
  3835. */
  3836. int clif_skill_nodamage(struct block_list *src,struct block_list *dst,
  3837. int skill_id,int heal,int fail)
  3838. {
  3839. unsigned char buf[32];
  3840. nullpo_retr(0, src);
  3841. nullpo_retr(0, dst);
  3842. WBUFW(buf,0)=0x11a;
  3843. WBUFW(buf,2)=skill_id;
  3844. WBUFW(buf,4)=(heal > 0x7fff)? 0x7fff:heal;
  3845. WBUFL(buf,6)=dst->id;
  3846. WBUFL(buf,10)=src->id;
  3847. WBUFB(buf,14)=fail;
  3848. clif_send(buf,packet_len_table[0x11a],src,AREA);
  3849. return 0;
  3850. }
  3851. /*==========================================
  3852. * 場所スキルエフェクト
  3853. *------------------------------------------
  3854. */
  3855. int clif_skill_poseffect(struct block_list *src,int skill_id,int val,int x,int y,int tick)
  3856. {
  3857. unsigned char buf[32];
  3858. nullpo_retr(0, src);
  3859. WBUFW(buf,0)=0x117;
  3860. WBUFW(buf,2)=skill_id;
  3861. WBUFL(buf,4)=src->id;
  3862. WBUFW(buf,8)=val;
  3863. WBUFW(buf,10)=x;
  3864. WBUFW(buf,12)=y;
  3865. WBUFL(buf,14)=tick;
  3866. clif_send(buf,packet_len_table[0x117],src,AREA);
  3867. return 0;
  3868. }
  3869. /*==========================================
  3870. * 場所スキルエフェクト表示
  3871. *------------------------------------------
  3872. */
  3873. int clif_skill_setunit(struct skill_unit *unit)
  3874. {
  3875. unsigned char buf[128];
  3876. struct block_list *bl;
  3877. nullpo_retr(0, unit);
  3878. bl=map_id2bl(unit->group->src_id);
  3879. #if PACKETVER < 3
  3880. memset(WBUFP(buf, 0),0,packet_len_table[0x11f]);
  3881. WBUFW(buf, 0)=0x11f;
  3882. WBUFL(buf, 2)=unit->bl.id;
  3883. WBUFL(buf, 6)=unit->group->src_id;
  3884. WBUFW(buf,10)=unit->bl.x;
  3885. WBUFW(buf,12)=unit->bl.y;
  3886. WBUFB(buf,14)=unit->group->unit_id;
  3887. WBUFB(buf,15)=0;
  3888. clif_send(buf,packet_len_table[0x11f],&unit->bl,AREA);
  3889. #else
  3890. memset(WBUFP(buf, 0),0,packet_len_table[0x1c9]);
  3891. WBUFW(buf, 0)=0x1c9;
  3892. WBUFL(buf, 2)=unit->bl.id;
  3893. WBUFL(buf, 6)=unit->group->src_id;
  3894. WBUFW(buf,10)=unit->bl.x;
  3895. WBUFW(buf,12)=unit->bl.y;
  3896. WBUFB(buf,14)=unit->group->unit_id;
  3897. WBUFB(buf,15)=1;
  3898. WBUFL(buf,15+1)=0; //1-4調べた限り固定
  3899. WBUFL(buf,15+5)=0; //5-8調べた限り固定
  3900. //9-12マップごとで一定の77-80とはまた違う4バイトのかなり大きな数字
  3901. WBUFL(buf,15+13)=unit->bl.y - 0x12; //13-16ユニットのY座標-18っぽい(Y:17でFF FF FF FF)
  3902. WBUFL(buf,15+17)=0x004f37dd; //17-20調べた限り固定(0x1b2で0x004fdbddだった)
  3903. WBUFL(buf,15+21)=0x0012f674; //21-24調べた限り固定
  3904. WBUFL(buf,15+25)=0x0012f664; //25-28調べた限り固定
  3905. WBUFL(buf,15+29)=0x0012f654; //29-32調べた限り固定
  3906. WBUFL(buf,15+33)=0x77527bbc; //33-36調べた限り固定
  3907. //37-39
  3908. WBUFB(buf,15+40)=0x2d; //40調べた限り固定
  3909. WBUFL(buf,15+41)=0; //41-44調べた限り0固定
  3910. WBUFL(buf,15+45)=0; //45-48調べた限り0固定
  3911. WBUFL(buf,15+49)=0; //49-52調べた限り0固定
  3912. WBUFL(buf,15+53)=0x0048d919; //53-56調べた限り固定(0x01b2で0x00495119だった)
  3913. WBUFL(buf,15+57)=0x0000003e; //57-60調べた限り固定
  3914. WBUFL(buf,15+61)=0x0012f66c; //61-64調べた限り固定
  3915. //65-68
  3916. //69-72
  3917. if(bl) WBUFL(buf,15+73)=bl->y; //73-76術者のY座標
  3918. WBUFL(buf,15+77)=unit->bl.m; //77-80マップIDかなぁ?かなり2バイトで足りそうな数字
  3919. WBUFB(buf,15+81)=0xaa; //81終端文字0xaa
  3920. /* Graffiti [Valaris] */
  3921. if(unit->group->unit_id==0xb0) {
  3922. WBUFL(buf,15)=1;
  3923. WBUFL(buf,16)=1;
  3924. memcpy(WBUFP(buf,17),unit->group->valstr,80);
  3925. }
  3926. clif_send(buf,packet_len_table[0x1c9],&unit->bl,AREA);
  3927. #endif
  3928. return 0;
  3929. }
  3930. /*==========================================
  3931. * 場所スキルエフェクト削除
  3932. *------------------------------------------
  3933. */
  3934. int clif_skill_delunit(struct skill_unit *unit)
  3935. {
  3936. unsigned char buf[16];
  3937. nullpo_retr(0, unit);
  3938. WBUFW(buf, 0)=0x120;
  3939. WBUFL(buf, 2)=unit->bl.id;
  3940. clif_send(buf,packet_len_table[0x120],&unit->bl,AREA);
  3941. return 0;
  3942. }
  3943. /*==========================================
  3944. * ワープ場所選択
  3945. *------------------------------------------
  3946. */
  3947. int clif_skill_warppoint(struct map_session_data *sd,int skill_num,
  3948. const char *map1,const char *map2,const char *map3,const char *map4)
  3949. {
  3950. int fd;
  3951. nullpo_retr(0, sd);
  3952. fd=sd->fd;
  3953. WFIFOW(fd,0)=0x11c;
  3954. WFIFOW(fd,2)=skill_num;
  3955. strncpy((char*)WFIFOP(fd, 4),map1,16);
  3956. strncpy((char*)WFIFOP(fd,20),map2,16);
  3957. strncpy((char*)WFIFOP(fd,36),map3,16);
  3958. strncpy((char*)WFIFOP(fd,52),map4,16);
  3959. WFIFOSET(fd,packet_len_table[0x11c]);
  3960. return 0;
  3961. }
  3962. /*==========================================
  3963. * メモ応答
  3964. *------------------------------------------
  3965. */
  3966. int clif_skill_memo(struct map_session_data *sd,int flag)
  3967. {
  3968. int fd;
  3969. nullpo_retr(0, sd);
  3970. fd=sd->fd;
  3971. WFIFOW(fd,0)=0x11e;
  3972. WFIFOB(fd,2)=flag;
  3973. WFIFOSET(fd,packet_len_table[0x11e]);
  3974. return 0;
  3975. }
  3976. int clif_skill_teleportmessage(struct map_session_data *sd,int flag)
  3977. {
  3978. int fd;
  3979. nullpo_retr(0, sd);
  3980. fd=sd->fd;
  3981. WFIFOW(fd,0)=0x189;
  3982. WFIFOW(fd,2)=flag;
  3983. WFIFOSET(fd,packet_len_table[0x189]);
  3984. return 0;
  3985. }
  3986. /*==========================================
  3987. * モンスター情報
  3988. *------------------------------------------
  3989. */
  3990. int clif_skill_estimation(struct map_session_data *sd,struct block_list *dst)
  3991. {
  3992. struct mob_data *md;
  3993. unsigned char buf[64];
  3994. int i;
  3995. nullpo_retr(0, sd);
  3996. nullpo_retr(0, dst);
  3997. if(dst->type!=BL_MOB )
  3998. return 0;
  3999. if((md=(struct mob_data *)dst) == NULL)
  4000. return 0;
  4001. WBUFW(buf, 0)=0x18c;
  4002. WBUFW(buf, 2)=mob_get_viewclass(md->class_);
  4003. WBUFW(buf, 4)=md->level;
  4004. WBUFW(buf, 6)=mob_db[md->class_].size;
  4005. WBUFL(buf, 8)=md->hp;
  4006. WBUFW(buf,12)=status_get_def2(&md->bl);
  4007. WBUFW(buf,14)=mob_db[md->class_].race;
  4008. WBUFW(buf,16)=status_get_mdef2(&md->bl) - (mob_db[md->class_].vit>>1);
  4009. WBUFW(buf,18)=status_get_elem_type(&md->bl);
  4010. for(i=0;i<9;i++)
  4011. WBUFB(buf,20+i)= battle_attr_fix(100,i+1,md->def_ele);
  4012. if(sd->status.party_id>0)
  4013. clif_send(buf,packet_len_table[0x18c],&sd->bl,PARTY_AREA);
  4014. else{
  4015. memcpy(WFIFOP(sd->fd,0),buf,packet_len_table[0x18c]);
  4016. WFIFOSET(sd->fd,packet_len_table[0x18c]);
  4017. }
  4018. return 0;
  4019. }
  4020. /*==========================================
  4021. * アイテム合成可能リスト
  4022. *------------------------------------------
  4023. */
  4024. int clif_skill_produce_mix_list(struct map_session_data *sd,int trigger)
  4025. {
  4026. int i,c,view,fd;
  4027. nullpo_retr(0, sd);
  4028. fd=sd->fd;
  4029. WFIFOW(fd, 0)=0x18d;
  4030. for(i=0,c=0;i<MAX_SKILL_PRODUCE_DB;i++){
  4031. if( skill_can_produce_mix(sd,skill_produce_db[i].nameid,trigger) ){
  4032. if((view = itemdb_viewid(skill_produce_db[i].nameid)) > 0)
  4033. WFIFOW(fd,c*8+ 4)= view;
  4034. else
  4035. WFIFOW(fd,c*8+ 4)= skill_produce_db[i].nameid;
  4036. WFIFOW(fd,c*8+ 6)= 0x0012;
  4037. WFIFOL(fd,c*8+ 8)= sd->status.char_id;
  4038. c++;
  4039. }
  4040. }
  4041. WFIFOW(fd, 2)=c*8+8;
  4042. WFIFOSET(fd,WFIFOW(fd,2));
  4043. if(c > 0) sd->state.produce_flag = 1;
  4044. return 0;
  4045. }
  4046. /*==========================================
  4047. * 状態異常アイコン/メッセージ表示
  4048. *------------------------------------------
  4049. */
  4050. int clif_status_change(struct block_list *bl,int type,int flag)
  4051. {
  4052. unsigned char buf[16];
  4053. nullpo_retr(0, bl);
  4054. WBUFW(buf,0)=0x0196;
  4055. WBUFW(buf,2)=type;
  4056. WBUFL(buf,4)=bl->id;
  4057. WBUFB(buf,8)=flag;
  4058. clif_send(buf,packet_len_table[0x196],bl,AREA);
  4059. return 0;
  4060. }
  4061. /*==========================================
  4062. * Send message (modified by [Yor])
  4063. *------------------------------------------
  4064. */
  4065. int clif_displaymessage(const int fd, char* mes)
  4066. {
  4067. //Console [Wizputer]
  4068. if (fd == 0)
  4069. printf("\033[0;36mConsole: \033[0m\033[1m%s\033[0m\n", mes);
  4070. else {
  4071. int len_mes = strlen(mes);
  4072. if (len_mes > 0) { // don't send a void message (it's not displaying on the client chat). @help can send void line.
  4073. WFIFOW(fd,0) = 0x8e;
  4074. WFIFOW(fd,2) = 5 + len_mes; // 4 + len + NULL teminate
  4075. memcpy(WFIFOP(fd,4), mes, len_mes + 1);
  4076. WFIFOSET(fd, 5 + len_mes);
  4077. }
  4078. }
  4079. return 0;
  4080. }
  4081. /*==========================================
  4082. * 天の声を送信する
  4083. *------------------------------------------
  4084. */
  4085. int clif_GMmessage(struct block_list *bl, char* mes, int len, int flag)
  4086. {
  4087. unsigned char *buf;
  4088. int lp;
  4089. lp = (flag & 0x10) ? 8 : 4;
  4090. buf = (unsigned char*)aCallocA(len + lp, sizeof(unsigned char));
  4091. WBUFW(buf,0) = 0x9a;
  4092. WBUFW(buf,2) = len + lp;
  4093. WBUFL(buf,4) = 0x65756c62;
  4094. memcpy(WBUFP(buf,lp), mes, len);
  4095. flag &= 0x07;
  4096. clif_send(buf, WBUFW(buf,2), bl,
  4097. (flag == 1) ? ALL_SAMEMAP :
  4098. (flag == 2) ? AREA :
  4099. (flag == 3) ? SELF :
  4100. ALL_CLIENT);
  4101. if(buf) aFree(buf);
  4102. return 0;
  4103. }
  4104. /*==========================================
  4105. * グローバルメッセージ
  4106. *------------------------------------------
  4107. */
  4108. void clif_GlobalMessage(struct block_list *bl,char *message)
  4109. {
  4110. char buf[100];
  4111. int len,cmd=0x8d;
  4112. if(!bl || !message)
  4113. return;
  4114. len=strlen(message)+1;
  4115. WBUFW(buf,0)=cmd;
  4116. WBUFW(buf,2)=len+8;
  4117. WBUFL(buf,4)=bl->id;
  4118. strncpy(WBUFP(buf,8),message,len);
  4119. clif_send(buf,WBUFW(buf,2),bl,AREA_CHAT_WOC);
  4120. }
  4121. /*==========================================
  4122. * HPSP回復エフェクトを送信する
  4123. *------------------------------------------
  4124. */
  4125. int clif_heal(int fd,int type,int val)
  4126. {
  4127. WFIFOW(fd,0)=0x13d;
  4128. WFIFOW(fd,2)=type;
  4129. WFIFOW(fd,4)=val;
  4130. WFIFOSET(fd,packet_len_table[0x13d]);
  4131. return 0;
  4132. }
  4133. /*==========================================
  4134. * 復活する
  4135. *------------------------------------------
  4136. */
  4137. int clif_resurrection(struct block_list *bl,int type)
  4138. {
  4139. unsigned char buf[16];
  4140. nullpo_retr(0, bl);
  4141. if(bl->type==BL_PC) { // disguises [Valaris]
  4142. struct map_session_data *sd=((struct map_session_data *)bl);
  4143. if(sd && sd->disguise > 23 && sd->disguise < 4001)
  4144. clif_spawnpc(sd);
  4145. }
  4146. WBUFW(buf,0)=0x148;
  4147. WBUFL(buf,2)=bl->id;
  4148. WBUFW(buf,6)=type;
  4149. clif_send(buf,packet_len_table[0x148],bl,type==1 ? AREA : AREA_WOS);
  4150. return 0;
  4151. }
  4152. /*==========================================
  4153. * PVP実装?(仮)
  4154. *------------------------------------------
  4155. */
  4156. int clif_set0199(int fd,int type)
  4157. {
  4158. WFIFOW(fd,0)=0x199;
  4159. WFIFOW(fd,2)=type;
  4160. WFIFOSET(fd,packet_len_table[0x199]);
  4161. return 0;
  4162. }
  4163. /*==========================================
  4164. * PVP実装?(仮)
  4165. *------------------------------------------
  4166. */
  4167. int clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type)
  4168. {
  4169. nullpo_retr(0, sd);
  4170. if(map[sd->bl.m].flag.nopvp)
  4171. return 0;
  4172. if(type == 2) {
  4173. WFIFOW(sd->fd,0) = 0x19a;
  4174. WFIFOL(sd->fd,2) = sd->bl.id;
  4175. if(pvprank<=0)
  4176. pc_calc_pvprank(sd);
  4177. WFIFOL(sd->fd,6) = pvprank;
  4178. WFIFOL(sd->fd,10) = pvpnum;
  4179. WFIFOSET(sd->fd,packet_len_table[0x19a]);
  4180. } else {
  4181. unsigned char buf[32];
  4182. WBUFW(buf,0) = 0x19a;
  4183. WBUFL(buf,2) = sd->bl.id;
  4184. if(sd->status.option&0x46)
  4185. // WTF? a -1 to an unsigned value...
  4186. WBUFL(buf,6) = -1;
  4187. else
  4188. if(pvprank<=0)
  4189. pc_calc_pvprank(sd);
  4190. WBUFL(buf,6) = pvprank;
  4191. WBUFL(buf,10) = pvpnum;
  4192. if(!type)
  4193. clif_send(buf,packet_len_table[0x19a],&sd->bl,AREA);
  4194. else
  4195. clif_send(buf,packet_len_table[0x19a],&sd->bl,ALL_SAMEMAP);
  4196. }
  4197. return 0;
  4198. }
  4199. /*==========================================
  4200. *
  4201. *------------------------------------------
  4202. */
  4203. int clif_send0199(int map,int type)
  4204. {
  4205. struct block_list bl;
  4206. unsigned char buf[16];
  4207. bl.m = map;
  4208. WBUFW(buf,0)=0x199;
  4209. WBUFW(buf,2)=type;
  4210. clif_send(buf,packet_len_table[0x199],&bl,ALL_SAMEMAP);
  4211. return 0;
  4212. }
  4213. /*==========================================
  4214. * 精錬エフェクトを送信する
  4215. *------------------------------------------
  4216. */
  4217. int clif_refine(int fd,struct map_session_data *sd,int fail,int index,int val)
  4218. {
  4219. WFIFOW(fd,0)=0x188;
  4220. WFIFOW(fd,2)=fail;
  4221. WFIFOW(fd,4)=index+2;
  4222. WFIFOW(fd,6)=val;
  4223. WFIFOSET(fd,packet_len_table[0x188]);
  4224. return 0;
  4225. }
  4226. /*==========================================
  4227. * Wisp/page is transmitted to the destination player
  4228. *------------------------------------------
  4229. */
  4230. int clif_wis_message(int fd, char *nick, char *mes, int mes_len) // R 0097 <len>.w <nick>.24B <message>.?B
  4231. {
  4232. // printf("clif_wis_message(%d, %s, %s)\n", fd, nick, mes);
  4233. WFIFOW(fd,0) = 0x97;
  4234. WFIFOW(fd,2) = mes_len + 24 + 4;
  4235. memcpy(WFIFOP(fd,4), nick, 24);
  4236. memcpy(WFIFOP(fd,28), mes, mes_len);
  4237. WFIFOSET(fd,WFIFOW(fd,2));
  4238. return 0;
  4239. }
  4240. /*==========================================
  4241. * The transmission result of Wisp/page is transmitted to the source player
  4242. *------------------------------------------
  4243. */
  4244. 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
  4245. {
  4246. WFIFOW(fd,0) = 0x98;
  4247. WFIFOW(fd,2) = flag;
  4248. WFIFOSET(fd,packet_len_table[0x98]);
  4249. return 0;
  4250. }
  4251. /*==========================================
  4252. * キャラID名前引き結果を送信する
  4253. *------------------------------------------
  4254. */
  4255. int clif_solved_charname(struct map_session_data *sd,int char_id)
  4256. {
  4257. char *p= map_charid2nick(char_id);
  4258. int fd;
  4259. nullpo_retr(0, sd);
  4260. fd=sd->fd;
  4261. if(p!=NULL){
  4262. WFIFOW(fd,0)=0x194;
  4263. WFIFOL(fd,2)=char_id;
  4264. memcpy(WFIFOP(fd,6), p,24 );
  4265. WFIFOSET(fd,packet_len_table[0x194]);
  4266. }else{
  4267. map_reqchariddb(sd,char_id);
  4268. chrif_searchcharid(char_id);
  4269. }
  4270. return 0;
  4271. }
  4272. /*==========================================
  4273. * カードの挿入可能リストを返す
  4274. *------------------------------------------
  4275. */
  4276. int clif_use_card(struct map_session_data *sd,int idx)
  4277. {
  4278. nullpo_retr(0, sd);
  4279. if(sd->inventory_data[idx]) {
  4280. int i,c;
  4281. int ep=sd->inventory_data[idx]->equip;
  4282. int fd=sd->fd;
  4283. WFIFOW(fd,0)=0x017b;
  4284. for(i=c=0;i<MAX_INVENTORY;i++){
  4285. int j;
  4286. if(sd->inventory_data[i] == NULL)
  4287. continue;
  4288. if(sd->inventory_data[i]->type!=4 && sd->inventory_data[i]->type!=5) // 武器防具じゃない
  4289. continue;
  4290. if(sd->status.inventory[i].card[0]==0x00ff) // 製造武器
  4291. continue;
  4292. if(sd->status.inventory[i].card[0]==(short)0xff00 || sd->status.inventory[i].card[0]==0x00fe)
  4293. continue;
  4294. if(sd->status.inventory[i].identify==0 ) // 未鑑定
  4295. continue;
  4296. if((sd->inventory_data[i]->equip&ep)==0) // 装備個所が違う
  4297. continue;
  4298. if(sd->inventory_data[i]->type==4 && ep==32) // 盾カードと両手武器
  4299. continue;
  4300. for(j=0;j<sd->inventory_data[i]->slot;j++){
  4301. if( sd->status.inventory[i].card[j]==0 )
  4302. break;
  4303. }
  4304. if(j==sd->inventory_data[i]->slot) // すでにカードが一杯
  4305. continue;
  4306. WFIFOW(fd,4+c*2)=i+2;
  4307. c++;
  4308. }
  4309. WFIFOW(fd,2)=4+c*2;
  4310. WFIFOSET(fd,WFIFOW(fd,2));
  4311. }
  4312. return 0;
  4313. }
  4314. /*==========================================
  4315. * カードの挿入終了
  4316. *------------------------------------------
  4317. */
  4318. int clif_insert_card(struct map_session_data *sd,int idx_equip,int idx_card,int flag)
  4319. {
  4320. int fd;
  4321. nullpo_retr(0, sd);
  4322. fd=sd->fd;
  4323. WFIFOW(fd,0)=0x17d;
  4324. WFIFOW(fd,2)=idx_equip+2;
  4325. WFIFOW(fd,4)=idx_card+2;
  4326. WFIFOB(fd,6)=flag;
  4327. WFIFOSET(fd,packet_len_table[0x17d]);
  4328. return 0;
  4329. }
  4330. /*==========================================
  4331. * 鑑定可能アイテムリスト送信
  4332. *------------------------------------------
  4333. */
  4334. int clif_item_identify_list(struct map_session_data *sd)
  4335. {
  4336. int i,c;
  4337. int fd;
  4338. nullpo_retr(0, sd);
  4339. fd=sd->fd;
  4340. WFIFOW(fd,0)=0x177;
  4341. for(i=c=0;i<MAX_INVENTORY;i++){
  4342. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  4343. WFIFOW(fd,c*2+4)=i+2;
  4344. c++;
  4345. }
  4346. }
  4347. if(c > 0) {
  4348. WFIFOW(fd,2)=c*2+4;
  4349. WFIFOSET(fd,WFIFOW(fd,2));
  4350. }
  4351. return 0;
  4352. }
  4353. /*==========================================
  4354. * 鑑定結果
  4355. *------------------------------------------
  4356. */
  4357. int clif_item_identified(struct map_session_data *sd,int idx,int flag)
  4358. {
  4359. int fd;
  4360. nullpo_retr(0, sd);
  4361. fd=sd->fd;
  4362. WFIFOW(fd, 0)=0x179;
  4363. WFIFOW(fd, 2)=idx+2;
  4364. WFIFOB(fd, 4)=flag;
  4365. WFIFOSET(fd,packet_len_table[0x179]);
  4366. return 0;
  4367. }
  4368. /*==========================================
  4369. * 修理可能アイテムリスト送信
  4370. * ※実際のパケットがわからないので動作しません
  4371. *------------------------------------------
  4372. */
  4373. int clif_item_repair_list(struct map_session_data *sd)
  4374. {
  4375. int i,c;
  4376. int fd;
  4377. nullpo_retr(0, sd);
  4378. fd=sd->fd;
  4379. WFIFOW(fd,0)=0x177; // temporarily use same packet as clif_item_identify
  4380. for(i=c=0;i<MAX_INVENTORY;i++){
  4381. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].attribute==1){
  4382. WFIFOW(fd,c*2+4)=i+2;
  4383. c++;
  4384. }
  4385. }
  4386. if(c > 0) {
  4387. WFIFOW(fd,2)=c*2+4;
  4388. WFIFOSET(fd,WFIFOW(fd,2));
  4389. }
  4390. return 0;
  4391. }
  4392. /*==========================================
  4393. * Weapon Refining [Celest]
  4394. *------------------------------------------
  4395. */
  4396. int clif_item_refine_list(struct map_session_data *sd)
  4397. {
  4398. int i,c;
  4399. int fd;
  4400. nullpo_retr(0, sd);
  4401. fd=sd->fd;
  4402. WFIFOW(fd,0)=0x177; // temporarily use same packet as clif_item_identify
  4403. for(i=c=0;i<MAX_INVENTORY;i++){
  4404. if(sd->status.inventory[i].nameid > 0 && itemdb_type(sd->status.inventory[i].nameid)==4){
  4405. WFIFOW(fd,c*2+4)=i+2;
  4406. c++;
  4407. }
  4408. }
  4409. if(c > 0) {
  4410. WFIFOW(fd,2)=c*2+4;
  4411. WFIFOSET(fd,WFIFOW(fd,2));
  4412. }
  4413. return 0;
  4414. }
  4415. /*==========================================
  4416. * アイテムによる一時的なスキル効果
  4417. *------------------------------------------
  4418. */
  4419. int clif_item_skill(struct map_session_data *sd,int skillid,int skilllv,const char *name)
  4420. {
  4421. int range,fd;
  4422. nullpo_retr(0, sd);
  4423. fd=sd->fd;
  4424. WFIFOW(fd, 0)=0x147;
  4425. WFIFOW(fd, 2)=skillid;
  4426. WFIFOW(fd, 4)=skill_get_inf(skillid);
  4427. WFIFOW(fd, 6)=0;
  4428. WFIFOW(fd, 8)=skilllv;
  4429. WFIFOW(fd,10)=skill_get_sp(skillid,skilllv);
  4430. range = skill_get_range(skillid,skilllv);
  4431. if(range < 0)
  4432. range = status_get_range(&sd->bl) - (range + 1);
  4433. WFIFOW(fd,12)=range;
  4434. strncpy((char*)WFIFOP(fd,14),name,24);
  4435. WFIFOB(fd,38)=0;
  4436. WFIFOSET(fd,packet_len_table[0x147]);
  4437. return 0;
  4438. }
  4439. /*==========================================
  4440. * カートにアイテム追加
  4441. *------------------------------------------
  4442. */
  4443. int clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail)
  4444. {
  4445. int view,j,fd;
  4446. unsigned char *buf;
  4447. nullpo_retr(0, sd);
  4448. fd=sd->fd;
  4449. buf=WFIFOP(fd,0);
  4450. if(n<0 || n>=MAX_CART || sd->status.cart[n].nameid<=0)
  4451. return 1;
  4452. WBUFW(buf,0)=0x124;
  4453. WBUFW(buf,2)=n+2;
  4454. WBUFL(buf,4)=amount;
  4455. if((view = itemdb_viewid(sd->status.cart[n].nameid)) > 0)
  4456. WBUFW(buf,8)=view;
  4457. else
  4458. WBUFW(buf,8)=sd->status.cart[n].nameid;
  4459. WBUFB(buf,10)=sd->status.cart[n].identify;
  4460. WBUFB(buf,11)=sd->status.cart[n].attribute;
  4461. WBUFB(buf,12)=sd->status.cart[n].refine;
  4462. if(sd->status.cart[n].card[0]==0x00ff || sd->status.cart[n].card[0]==0x00fe || sd->status.cart[n].card[0]==(short)0xff00) {
  4463. WBUFW(buf,13)=sd->status.cart[n].card[0];
  4464. WBUFW(buf,15)=sd->status.cart[n].card[1];
  4465. WBUFW(buf,17)=sd->status.cart[n].card[2];
  4466. WBUFW(buf,19)=sd->status.cart[n].card[3];
  4467. } else {
  4468. if(sd->status.cart[n].card[0] > 0 && (j=itemdb_viewid(sd->status.cart[n].card[0])) > 0)
  4469. WBUFW(buf,13)= j;
  4470. else
  4471. WBUFW(buf,13)= sd->status.cart[n].card[0];
  4472. if(sd->status.cart[n].card[1] > 0 && (j=itemdb_viewid(sd->status.cart[n].card[1])) > 0)
  4473. WBUFW(buf,15)= j;
  4474. else
  4475. WBUFW(buf,15)= sd->status.cart[n].card[1];
  4476. if(sd->status.cart[n].card[2] > 0 && (j=itemdb_viewid(sd->status.cart[n].card[2])) > 0)
  4477. WBUFW(buf,17)= j;
  4478. else
  4479. WBUFW(buf,17)= sd->status.cart[n].card[2];
  4480. if(sd->status.cart[n].card[3] > 0 && (j=itemdb_viewid(sd->status.cart[n].card[3])) > 0)
  4481. WBUFW(buf,19)= j;
  4482. else
  4483. WBUFW(buf,19)= sd->status.cart[n].card[3];
  4484. }
  4485. WFIFOSET(fd,packet_len_table[0x124]);
  4486. return 0;
  4487. }
  4488. /*==========================================
  4489. * カートからアイテム削除
  4490. *------------------------------------------
  4491. */
  4492. int clif_cart_delitem(struct map_session_data *sd,int n,int amount)
  4493. {
  4494. int fd;
  4495. nullpo_retr(0, sd);
  4496. fd=sd->fd;
  4497. WFIFOW(fd,0)=0x125;
  4498. WFIFOW(fd,2)=n+2;
  4499. WFIFOL(fd,4)=amount;
  4500. WFIFOSET(fd,packet_len_table[0x125]);
  4501. return 0;
  4502. }
  4503. /*==========================================
  4504. * カートのアイテムリスト
  4505. *------------------------------------------
  4506. */
  4507. int clif_cart_itemlist(struct map_session_data *sd)
  4508. {
  4509. struct item_data *id;
  4510. int i,n,fd;
  4511. unsigned char *buf;
  4512. nullpo_retr(0, sd);
  4513. fd=sd->fd;
  4514. buf = WFIFOP(fd,0);
  4515. #if PACKETVER < 5
  4516. WBUFW(buf,0)=0x123;
  4517. for(i=0,n=0;i<MAX_CART;i++){
  4518. if(sd->status.cart[i].nameid<=0)
  4519. continue;
  4520. id = itemdb_search(sd->status.cart[i].nameid);
  4521. if(itemdb_isequip2(id))
  4522. continue;
  4523. WBUFW(buf,n*10+4)=i+2;
  4524. if(id->view_id > 0)
  4525. WBUFW(buf,n*10+6)=id->view_id;
  4526. else
  4527. WBUFW(buf,n*10+6)=sd->status.cart[i].nameid;
  4528. WBUFB(buf,n*10+8)=id->type;
  4529. WBUFB(buf,n*10+9)=sd->status.cart[i].identify;
  4530. WBUFW(buf,n*10+10)=sd->status.cart[i].amount;
  4531. WBUFW(buf,n*10+12)=0;
  4532. n++;
  4533. }
  4534. if(n){
  4535. WBUFW(buf,2)=4+n*10;
  4536. WFIFOSET(fd,WFIFOW(fd,2));
  4537. }
  4538. #else
  4539. WBUFW(buf,0)=0x1ef;
  4540. for(i=0,n=0;i<MAX_CART;i++){
  4541. if(sd->status.cart[i].nameid<=0)
  4542. continue;
  4543. id = itemdb_search(sd->status.cart[i].nameid);
  4544. if(itemdb_isequip2(id))
  4545. continue;
  4546. WBUFW(buf,n*18+4)=i+2;
  4547. if(id->view_id > 0)
  4548. WBUFW(buf,n*18+6)=id->view_id;
  4549. else
  4550. WBUFW(buf,n*18+6)=sd->status.cart[i].nameid;
  4551. WBUFB(buf,n*18+8)=id->type;
  4552. WBUFB(buf,n*18+9)=sd->status.cart[i].identify;
  4553. WBUFW(buf,n*18+10)=sd->status.cart[i].amount;
  4554. WBUFW(buf,n*18+12)=0;
  4555. WBUFW(buf,n*18+14)=sd->status.cart[i].card[0];
  4556. WBUFW(buf,n*18+16)=sd->status.cart[i].card[1];
  4557. WBUFW(buf,n*18+18)=sd->status.cart[i].card[2];
  4558. WBUFW(buf,n*18+20)=sd->status.cart[i].card[3];
  4559. n++;
  4560. }
  4561. if(n){
  4562. WBUFW(buf,2)=4+n*18;
  4563. WFIFOSET(fd,WFIFOW(fd,2));
  4564. }
  4565. #endif
  4566. return 0;
  4567. }
  4568. /*==========================================
  4569. * カートの装備品リスト
  4570. *------------------------------------------
  4571. */
  4572. int clif_cart_equiplist(struct map_session_data *sd)
  4573. {
  4574. struct item_data *id;
  4575. int i,j,n,fd;
  4576. unsigned char *buf;
  4577. nullpo_retr(0, sd);
  4578. fd=sd->fd;
  4579. buf = WFIFOP(fd,0);
  4580. WBUFW(buf,0)=0x122;
  4581. for(i=0,n=0;i<MAX_INVENTORY;i++){
  4582. if(sd->status.cart[i].nameid<=0)
  4583. continue;
  4584. id = itemdb_search(sd->status.cart[i].nameid);
  4585. if(!itemdb_isequip2(id))
  4586. continue;
  4587. WBUFW(buf,n*20+4)=i+2;
  4588. if(id->view_id > 0)
  4589. WBUFW(buf,n*20+6)=id->view_id;
  4590. else
  4591. WBUFW(buf,n*20+6)=sd->status.cart[i].nameid;
  4592. WBUFB(buf,n*20+8)=id->type;
  4593. WBUFB(buf,n*20+9)=sd->status.cart[i].identify;
  4594. WBUFW(buf,n*20+10)=id->equip;
  4595. WBUFW(buf,n*20+12)=sd->status.cart[i].equip;
  4596. WBUFB(buf,n*20+14)=sd->status.cart[i].attribute;
  4597. WBUFB(buf,n*20+15)=sd->status.cart[i].refine;
  4598. if(sd->status.cart[i].card[0]==0x00ff || sd->status.cart[i].card[0]==0x00fe || sd->status.cart[i].card[0]==(short)0xff00) {
  4599. WBUFW(buf,n*20+16)=sd->status.cart[i].card[0];
  4600. WBUFW(buf,n*20+18)=sd->status.cart[i].card[1];
  4601. WBUFW(buf,n*20+20)=sd->status.cart[i].card[2];
  4602. WBUFW(buf,n*20+22)=sd->status.cart[i].card[3];
  4603. } else {
  4604. if(sd->status.cart[i].card[0] > 0 && (j=itemdb_viewid(sd->status.cart[i].card[0])) > 0)
  4605. WBUFW(buf,n*20+16)= j;
  4606. else
  4607. WBUFW(buf,n*20+16)= sd->status.cart[i].card[0];
  4608. if(sd->status.cart[i].card[1] > 0 && (j=itemdb_viewid(sd->status.cart[i].card[1])) > 0)
  4609. WBUFW(buf,n*20+18)= j;
  4610. else
  4611. WBUFW(buf,n*20+18)= sd->status.cart[i].card[1];
  4612. if(sd->status.cart[i].card[2] > 0 && (j=itemdb_viewid(sd->status.cart[i].card[2])) > 0)
  4613. WBUFW(buf,n*20+20)= j;
  4614. else
  4615. WBUFW(buf,n*20+20)= sd->status.cart[i].card[2];
  4616. if(sd->status.cart[i].card[3] > 0 && (j=itemdb_viewid(sd->status.cart[i].card[3])) > 0)
  4617. WBUFW(buf,n*20+22)= j;
  4618. else
  4619. WBUFW(buf,n*20+22)= sd->status.cart[i].card[3];
  4620. }
  4621. n++;
  4622. }
  4623. if(n){
  4624. WBUFW(buf,2)=4+n*20;
  4625. WFIFOSET(fd,WFIFOW(fd,2));
  4626. }
  4627. return 0;
  4628. }
  4629. /*==========================================
  4630. * 露店開設
  4631. *------------------------------------------
  4632. */
  4633. int clif_openvendingreq(struct map_session_data *sd,int num)
  4634. {
  4635. int fd;
  4636. nullpo_retr(0, sd);
  4637. fd=sd->fd;
  4638. WFIFOW(fd,0)=0x12d;
  4639. WFIFOW(fd,2)=num;
  4640. WFIFOSET(fd,packet_len_table[0x12d]);
  4641. return 0;
  4642. }
  4643. /*==========================================
  4644. * 露店看板表示
  4645. *------------------------------------------
  4646. */
  4647. int clif_showvendingboard(struct block_list* bl,char *message,int fd)
  4648. {
  4649. unsigned char buf[128];
  4650. nullpo_retr(0, bl);
  4651. WBUFW(buf,0)=0x131;
  4652. WBUFL(buf,2)=bl->id;
  4653. strncpy((char*)WBUFP(buf,6),message,80);
  4654. if(fd){
  4655. memcpy(WFIFOP(fd,0),buf,packet_len_table[0x131]);
  4656. WFIFOSET(fd,packet_len_table[0x131]);
  4657. }else{
  4658. clif_send(buf,packet_len_table[0x131],bl,AREA_WOS);
  4659. }
  4660. return 0;
  4661. }
  4662. /*==========================================
  4663. * 露店看板消去
  4664. *------------------------------------------
  4665. */
  4666. int clif_closevendingboard(struct block_list* bl,int fd)
  4667. {
  4668. unsigned char buf[16];
  4669. nullpo_retr(0, bl);
  4670. WBUFW(buf,0)=0x132;
  4671. WBUFL(buf,2)=bl->id;
  4672. if(fd){
  4673. memcpy(WFIFOP(fd,0),buf,packet_len_table[0x132]);
  4674. WFIFOSET(fd,packet_len_table[0x132]);
  4675. }else{
  4676. clif_send(buf,packet_len_table[0x132],bl,AREA_WOS);
  4677. }
  4678. return 0;
  4679. }
  4680. /*==========================================
  4681. * 露店アイテムリスト
  4682. *------------------------------------------
  4683. */
  4684. int clif_vendinglist(struct map_session_data *sd,int id,struct vending *vending)
  4685. {
  4686. struct item_data *data;
  4687. int i,j,n,index,fd;
  4688. struct map_session_data *vsd;
  4689. unsigned char *buf;
  4690. nullpo_retr(0, sd);
  4691. nullpo_retr(0, vending);
  4692. nullpo_retr(0, vsd=map_id2sd(id));
  4693. fd=sd->fd;
  4694. buf = WFIFOP(fd,0);
  4695. WBUFW(buf,0)=0x133;
  4696. WBUFL(buf,4)=id;
  4697. for(i=0,n=0;i<vsd->vend_num;i++){
  4698. if(vending[i].amount<=0)
  4699. continue;
  4700. WBUFL(buf,8+n*22)=vending[i].value;
  4701. WBUFW(buf,12+n*22)=vending[i].amount;
  4702. WBUFW(buf,14+n*22)=(index=vending[i].index)+2;
  4703. if(vsd->status.cart[index].nameid <= 0 || vsd->status.cart[index].amount <= 0)
  4704. continue;
  4705. data = itemdb_search(vsd->status.cart[index].nameid);
  4706. WBUFB(buf,16+n*22)=data->type;
  4707. if(data->view_id > 0)
  4708. WBUFW(buf,17+n*22)=data->view_id;
  4709. else
  4710. WBUFW(buf,17+n*22)=vsd->status.cart[index].nameid;
  4711. WBUFB(buf,19+n*22)=vsd->status.cart[index].identify;
  4712. WBUFB(buf,20+n*22)=vsd->status.cart[index].attribute;
  4713. WBUFB(buf,21+n*22)=vsd->status.cart[index].refine;
  4714. if(vsd->status.cart[index].card[0]==0x00ff || vsd->status.cart[index].card[0]==0x00fe || vsd->status.cart[index].card[0]==(short)0xff00) {
  4715. WBUFW(buf,22+n*22)=vsd->status.cart[index].card[0];
  4716. WBUFW(buf,24+n*22)=vsd->status.cart[index].card[1];
  4717. WBUFW(buf,26+n*22)=vsd->status.cart[index].card[2];
  4718. WBUFW(buf,28+n*22)=vsd->status.cart[index].card[3];
  4719. } else {
  4720. if(vsd->status.cart[index].card[0] > 0 && (j=itemdb_viewid(vsd->status.cart[index].card[0])) > 0)
  4721. WBUFW(buf,22+n*22)= j;
  4722. else
  4723. WBUFW(buf,22+n*22)= vsd->status.cart[index].card[0];
  4724. if(vsd->status.cart[index].card[1] > 0 && (j=itemdb_viewid(vsd->status.cart[index].card[1])) > 0)
  4725. WBUFW(buf,24+n*22)= j;
  4726. else
  4727. WBUFW(buf,24+n*22)= vsd->status.cart[index].card[1];
  4728. if(vsd->status.cart[index].card[2] > 0 && (j=itemdb_viewid(vsd->status.cart[index].card[2])) > 0)
  4729. WBUFW(buf,26+n*22)= j;
  4730. else
  4731. WBUFW(buf,26+n*22)= vsd->status.cart[index].card[2];
  4732. if(vsd->status.cart[index].card[3] > 0 && (j=itemdb_viewid(vsd->status.cart[index].card[3])) > 0)
  4733. WBUFW(buf,28+n*22)= j;
  4734. else
  4735. WBUFW(buf,28+n*22)= vsd->status.cart[index].card[3];
  4736. }
  4737. n++;
  4738. }
  4739. if(n > 0){
  4740. WBUFW(buf,2)=8+n*22;
  4741. WFIFOSET(fd,WFIFOW(fd,2));
  4742. }
  4743. return 0;
  4744. }
  4745. /*==========================================
  4746. * 露店アイテム購入失敗
  4747. *------------------------------------------
  4748. */
  4749. int clif_buyvending(struct map_session_data *sd,int index,int amount,int fail)
  4750. {
  4751. int fd;
  4752. nullpo_retr(0, sd);
  4753. fd=sd->fd;
  4754. WFIFOW(fd,0)=0x135;
  4755. WFIFOW(fd,2)=index+2;
  4756. WFIFOW(fd,4)=amount;
  4757. WFIFOB(fd,6)=fail;
  4758. WFIFOSET(fd,packet_len_table[0x135]);
  4759. return 0;
  4760. }
  4761. /*==========================================
  4762. * 露店開設成功
  4763. *------------------------------------------
  4764. */
  4765. int clif_openvending(struct map_session_data *sd,int id,struct vending *vending)
  4766. {
  4767. struct item_data *data;
  4768. int i,j,n,index,fd;
  4769. unsigned char *buf;
  4770. nullpo_retr(0, sd);
  4771. fd=sd->fd;
  4772. buf = WFIFOP(fd,0);
  4773. WBUFW(buf,0)=0x136;
  4774. WBUFL(buf,4)=id;
  4775. for(i=0,n=0;i<sd->vend_num;i++){
  4776. if (sd->vend_num > 2+pc_checkskill(sd,MC_VENDING)) return 0;
  4777. WBUFL(buf,8+n*22)=vending[i].value;
  4778. WBUFW(buf,12+n*22)=(index=vending[i].index)+2;
  4779. WBUFW(buf,14+n*22)=vending[i].amount;
  4780. if(sd->status.cart[index].nameid <= 0 || sd->status.cart[index].amount <= 0 || sd->status.cart[index].identify==0 ||
  4781. sd->status.cart[index].attribute==1) // Prevent unidentified and broken items from being sold [Valaris]
  4782. continue;
  4783. data = itemdb_search(sd->status.cart[index].nameid);
  4784. WBUFB(buf,16+n*22)=data->type;
  4785. if(data->view_id > 0)
  4786. WBUFW(buf,17+n*22)=data->view_id;
  4787. else
  4788. WBUFW(buf,17+n*22)=sd->status.cart[index].nameid;
  4789. WBUFB(buf,19+n*22)=sd->status.cart[index].identify;
  4790. WBUFB(buf,20+n*22)=sd->status.cart[index].attribute;
  4791. WBUFB(buf,21+n*22)=sd->status.cart[index].refine;
  4792. if(sd->status.cart[index].card[0]==0x00ff || sd->status.cart[index].card[0]==0x00fe || sd->status.cart[index].card[0]==(short)0xff00) {
  4793. WBUFW(buf,22+n*22)=sd->status.cart[index].card[0];
  4794. WBUFW(buf,24+n*22)=sd->status.cart[index].card[1];
  4795. WBUFW(buf,26+n*22)=sd->status.cart[index].card[2];
  4796. WBUFW(buf,28+n*22)=sd->status.cart[index].card[3];
  4797. } else {
  4798. if(sd->status.cart[index].card[0] > 0 && (j=itemdb_viewid(sd->status.cart[index].card[0])) > 0)
  4799. WBUFW(buf,22+n*22)= j;
  4800. else
  4801. WBUFW(buf,22+n*22)= sd->status.cart[index].card[0];
  4802. if(sd->status.cart[index].card[1] > 0 && (j=itemdb_viewid(sd->status.cart[index].card[1])) > 0)
  4803. WBUFW(buf,24+n*22)= j;
  4804. else
  4805. WBUFW(buf,24+n*22)= sd->status.cart[index].card[1];
  4806. if(sd->status.cart[index].card[2] > 0 && (j=itemdb_viewid(sd->status.cart[index].card[2])) > 0)
  4807. WBUFW(buf,26+n*22)= j;
  4808. else
  4809. WBUFW(buf,26+n*22)= sd->status.cart[index].card[2];
  4810. if(sd->status.cart[index].card[3] > 0 && (j=itemdb_viewid(sd->status.cart[index].card[3])) > 0)
  4811. WBUFW(buf,28+n*22)= j;
  4812. else
  4813. WBUFW(buf,28+n*22)= sd->status.cart[index].card[3];
  4814. }
  4815. n++;
  4816. }
  4817. if(n > 0){
  4818. WBUFW(buf,2)=8+n*22;
  4819. WFIFOSET(fd,WFIFOW(fd,2));
  4820. }
  4821. return n;
  4822. }
  4823. /*==========================================
  4824. * 露店アイテム販売報告
  4825. *------------------------------------------
  4826. */
  4827. int clif_vendingreport(struct map_session_data *sd,int index,int amount)
  4828. {
  4829. int fd;
  4830. nullpo_retr(0, sd);
  4831. fd=sd->fd;
  4832. WFIFOW(fd,0)=0x137;
  4833. WFIFOW(fd,2)=index+2;
  4834. WFIFOW(fd,4)=amount;
  4835. WFIFOSET(fd,packet_len_table[0x137]);
  4836. return 0;
  4837. }
  4838. /*==========================================
  4839. * パーティ作成完了
  4840. *------------------------------------------
  4841. */
  4842. int clif_party_created(struct map_session_data *sd,int flag)
  4843. {
  4844. int fd;
  4845. // printf("clif_party_message(%s, %d, %s)\n", p->name, account_id, mes);
  4846. nullpo_retr(0, sd);
  4847. fd=sd->fd;
  4848. WFIFOW(fd,0)=0xfa;
  4849. WFIFOB(fd,2)=flag;
  4850. WFIFOSET(fd,packet_len_table[0xfa]);
  4851. return 0;
  4852. }
  4853. /*==========================================
  4854. * パーティ情報送信
  4855. *------------------------------------------
  4856. */
  4857. int clif_party_info(struct party *p,int fd)
  4858. {
  4859. unsigned char buf[1024];
  4860. int i,c;
  4861. struct map_session_data *sd=NULL;
  4862. nullpo_retr(0, p);
  4863. WBUFW(buf,0)=0xfb;
  4864. memcpy(WBUFP(buf,4),p->name,24);
  4865. for(i=c=0;i<MAX_PARTY;i++){
  4866. struct party_member *m=&p->member[i];
  4867. if(m->account_id>0){
  4868. if(sd==NULL) sd=m->sd;
  4869. WBUFL(buf,28+c*46)=m->account_id;
  4870. memcpy(WBUFP(buf,28+c*46+ 4),m->name,24);
  4871. memcpy(WBUFP(buf,28+c*46+28),m->map,16);
  4872. WBUFB(buf,28+c*46+44)=(m->leader)?0:1;
  4873. WBUFB(buf,28+c*46+45)=(m->online)?0:1;
  4874. c++;
  4875. }
  4876. }
  4877. WBUFW(buf,2)=28+c*46;
  4878. if(fd>=0){ // fdが設定されてるならそれに送る
  4879. memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2));
  4880. WFIFOSET(fd,WFIFOW(fd,2));
  4881. return 9;
  4882. }
  4883. if(sd!=NULL)
  4884. clif_send(buf,WBUFW(buf,2),&sd->bl,PARTY);
  4885. return 0;
  4886. }
  4887. /*==========================================
  4888. * パーティ勧誘
  4889. *------------------------------------------
  4890. */
  4891. int clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd)
  4892. {
  4893. int fd;
  4894. struct party *p;
  4895. nullpo_retr(0, sd);
  4896. nullpo_retr(0, tsd);
  4897. fd=tsd->fd;
  4898. if( (p=party_search(sd->status.party_id))==NULL )
  4899. return 0;
  4900. WFIFOW(fd,0)=0xfe;
  4901. WFIFOL(fd,2)=sd->status.account_id;
  4902. memcpy(WFIFOP(fd,6),p->name,24);
  4903. WFIFOSET(fd,packet_len_table[0xfe]);
  4904. return 0;
  4905. }
  4906. /*==========================================
  4907. * パーティ勧誘結果
  4908. *------------------------------------------
  4909. */
  4910. int clif_party_inviteack(struct map_session_data *sd,char *nick,int flag)
  4911. {
  4912. int fd;
  4913. nullpo_retr(0, sd);
  4914. fd=sd->fd;
  4915. WFIFOW(fd,0)=0xfd;
  4916. memcpy(WFIFOP(fd,2),nick,24);
  4917. WFIFOB(fd,26)=flag;
  4918. WFIFOSET(fd,packet_len_table[0xfd]);
  4919. return 0;
  4920. }
  4921. /*==========================================
  4922. * パーティ設定送信
  4923. * flag & 0x001=exp変更ミス
  4924. * 0x010=item変更ミス
  4925. * 0x100=一人にのみ送信
  4926. *------------------------------------------
  4927. */
  4928. int clif_party_option(struct party *p,struct map_session_data *sd,int flag)
  4929. {
  4930. unsigned char buf[16];
  4931. nullpo_retr(0, p);
  4932. // if(battle_config.etc_log)
  4933. // printf("clif_party_option: %d %d %d\n",p->exp,p->item,flag);
  4934. if(sd==NULL && flag==0){
  4935. int i;
  4936. for(i=0;i<MAX_PARTY;i++)
  4937. if((sd=map_id2sd(p->member[i].account_id))!=NULL)
  4938. break;
  4939. }
  4940. if(sd==NULL)
  4941. return 0;
  4942. WBUFW(buf,0)=0x101;
  4943. WBUFW(buf,2)=((flag&0x01)?2:p->exp);
  4944. WBUFW(buf,4)=((flag&0x10)?2:p->item);
  4945. if(flag==0)
  4946. clif_send(buf,packet_len_table[0x101],&sd->bl,PARTY);
  4947. else {
  4948. memcpy(WFIFOP(sd->fd,0),buf,packet_len_table[0x101]);
  4949. WFIFOSET(sd->fd,packet_len_table[0x101]);
  4950. }
  4951. return 0;
  4952. }
  4953. /*==========================================
  4954. * パーティ脱退(脱退前に呼ぶこと)
  4955. *------------------------------------------
  4956. */
  4957. int clif_party_leaved(struct party *p,struct map_session_data *sd,int account_id,char *name,int flag)
  4958. {
  4959. unsigned char buf[64];
  4960. int i;
  4961. nullpo_retr(0, p);
  4962. WBUFW(buf,0)=0x105;
  4963. WBUFL(buf,2)=account_id;
  4964. memcpy(WBUFP(buf,6),name,24);
  4965. WBUFB(buf,30)=flag&0x0f;
  4966. if((flag&0xf0)==0){
  4967. if(sd==NULL)
  4968. for(i=0;i<MAX_PARTY;i++)
  4969. if((sd=p->member[i].sd)!=NULL)
  4970. break;
  4971. if (sd!=NULL)
  4972. clif_send(buf,packet_len_table[0x105],&sd->bl,PARTY);
  4973. } else if (sd!=NULL) {
  4974. memcpy(WFIFOP(sd->fd,0),buf,packet_len_table[0x105]);
  4975. WFIFOSET(sd->fd,packet_len_table[0x105]);
  4976. }
  4977. return 0;
  4978. }
  4979. /*==========================================
  4980. * パーティメッセージ送信
  4981. *------------------------------------------
  4982. */
  4983. int clif_party_message(struct party *p,int account_id,char *mes,int len)
  4984. {
  4985. struct map_session_data *sd;
  4986. int i;
  4987. nullpo_retr(0, p);
  4988. for(i=0;i<MAX_PARTY;i++){
  4989. if((sd=p->member[i].sd)!=NULL)
  4990. break;
  4991. }
  4992. if(sd!=NULL){
  4993. unsigned char buf[1024];
  4994. WBUFW(buf,0)=0x109;
  4995. WBUFW(buf,2)=len+8;
  4996. WBUFL(buf,4)=account_id;
  4997. memcpy(WBUFP(buf,8),mes,len);
  4998. clif_send(buf,len+8,&sd->bl,PARTY);
  4999. }
  5000. return 0;
  5001. }
  5002. /*==========================================
  5003. * パーティ座標通知
  5004. *------------------------------------------
  5005. */
  5006. int clif_party_xy(struct party *p,struct map_session_data *sd)
  5007. {
  5008. unsigned char buf[16];
  5009. nullpo_retr(0, sd);
  5010. WBUFW(buf,0)=0x107;
  5011. WBUFL(buf,2)=sd->status.account_id;
  5012. WBUFW(buf,6)=sd->bl.x;
  5013. WBUFW(buf,8)=sd->bl.y;
  5014. clif_send(buf,packet_len_table[0x107],&sd->bl,PARTY_SAMEMAP_WOS);
  5015. // if(battle_config.etc_log)
  5016. // printf("clif_party_xy %d\n",sd->status.account_id);
  5017. return 0;
  5018. }
  5019. /*==========================================
  5020. * パーティHP通知
  5021. *------------------------------------------
  5022. */
  5023. int clif_party_hp(struct party *p,struct map_session_data *sd)
  5024. {
  5025. unsigned char buf[16];
  5026. nullpo_retr(0, sd);
  5027. WBUFW(buf,0)=0x106;
  5028. WBUFL(buf,2)=sd->status.account_id;
  5029. WBUFW(buf,6)=(sd->status.hp > 0x7fff)? 0x7fff:sd->status.hp;
  5030. WBUFW(buf,8)=(sd->status.max_hp > 0x7fff)? 0x7fff:sd->status.max_hp;
  5031. clif_send(buf,packet_len_table[0x106],&sd->bl,PARTY_AREA_WOS);
  5032. // if(battle_config.etc_log)
  5033. // printf("clif_party_hp %d\n",sd->status.account_id);
  5034. return 0;
  5035. }
  5036. /*==========================================
  5037. * GMへ場所とHP通知
  5038. *------------------------------------------
  5039. */
  5040. int clif_hpmeter(struct map_session_data *sd)
  5041. {
  5042. struct map_session_data *md;
  5043. unsigned char buf[16];
  5044. unsigned char buf2[16];
  5045. int i;
  5046. nullpo_retr(0, sd);
  5047. WBUFW(buf,0)=0x107;
  5048. WBUFL(buf,2)=sd->bl.id;
  5049. WBUFW(buf,6)=sd->bl.x;
  5050. WBUFW(buf,8)=sd->bl.y;
  5051. for(i=0;i<fd_max;i++){
  5052. if(session[i] && (md = (struct map_session_data*)session[i]->session_data) && md->state.auth &&
  5053. md->bl.m == sd->bl.m && pc_isGM(md) && sd != md){
  5054. memcpy(WFIFOP(i,0),buf,packet_len_table[0x107]);
  5055. WFIFOSET(i,packet_len_table[0x107]);
  5056. }
  5057. }
  5058. WBUFW(buf2,0)=0x106;
  5059. WBUFL(buf2,2)=sd->status.account_id;
  5060. WBUFW(buf2,6)=(sd->status.hp > 0x7fff)? 0x7fff:sd->status.hp;
  5061. WBUFW(buf2,8)=(sd->status.max_hp > 0x7fff)? 0x7fff:sd->status.max_hp;
  5062. for(i=0;i<fd_max;i++){
  5063. if(session[i] && (md = (struct map_session_data*)session[i]->session_data) && md->state.auth &&
  5064. md->bl.m == sd->bl.m && pc_isGM(md) && sd != md){
  5065. memcpy(WFIFOP(i,0),buf2,packet_len_table[0x106]);
  5066. WFIFOSET(i,packet_len_table[0x106]);
  5067. }
  5068. }
  5069. return 0;
  5070. }
  5071. /*==================================================
  5072. * Update monster hp view if it has changed [Celest]
  5073. *--------------------------------------------------
  5074. */
  5075. int clif_update_mobhp(struct mob_data *md)
  5076. {
  5077. unsigned char buf[102];
  5078. char mobhp[50];
  5079. nullpo_retr(0, md);
  5080. WBUFW(buf,0) = 0x95;
  5081. WBUFL(buf,2) = md->bl.id;
  5082. memcpy(WBUFP(buf,6), md->name, 24);
  5083. sprintf(mobhp, "hp: %d/%d", md->hp, mob_db[md->class_].max_hp);
  5084. WBUFW(buf, 0) = 0x195;
  5085. memcpy(WBUFP(buf,30), mobhp, 24);
  5086. WBUFL(buf,54) = 0;
  5087. WBUFL(buf,78) = 0;
  5088. clif_send(buf,packet_len_table[0x195],&md->bl,AREA);
  5089. return 0;
  5090. }
  5091. /*==========================================
  5092. * パーティ場所移動(未使用)
  5093. *------------------------------------------
  5094. */
  5095. int clif_party_move(struct party *p,struct map_session_data *sd,int online)
  5096. {
  5097. unsigned char buf[128];
  5098. nullpo_retr(0, sd);
  5099. nullpo_retr(0, p);
  5100. WBUFW(buf, 0)=0x104;
  5101. WBUFL(buf, 2)=sd->status.account_id;
  5102. WBUFL(buf, 6)=0;
  5103. WBUFW(buf,10)=sd->bl.x;
  5104. WBUFW(buf,12)=sd->bl.y;
  5105. WBUFB(buf,14)=!online;
  5106. memcpy(WBUFP(buf,15),p->name,24);
  5107. memcpy(WBUFP(buf,39),sd->status.name,24);
  5108. memcpy(WBUFP(buf,63),map[sd->bl.m].name,16);
  5109. clif_send(buf,packet_len_table[0x104],&sd->bl,PARTY);
  5110. return 0;
  5111. }
  5112. /*==========================================
  5113. * 攻撃するために移動が必要
  5114. *------------------------------------------
  5115. */
  5116. int clif_movetoattack(struct map_session_data *sd,struct block_list *bl)
  5117. {
  5118. int fd;
  5119. nullpo_retr(0, sd);
  5120. nullpo_retr(0, bl);
  5121. fd=sd->fd;
  5122. WFIFOW(fd, 0)=0x139;
  5123. WFIFOL(fd, 2)=bl->id;
  5124. WFIFOW(fd, 6)=bl->x;
  5125. WFIFOW(fd, 8)=bl->y;
  5126. WFIFOW(fd,10)=sd->bl.x;
  5127. WFIFOW(fd,12)=sd->bl.y;
  5128. WFIFOW(fd,14)=sd->attackrange;
  5129. WFIFOSET(fd,packet_len_table[0x139]);
  5130. return 0;
  5131. }
  5132. /*==========================================
  5133. * 製造エフェクト
  5134. *------------------------------------------
  5135. */
  5136. int clif_produceeffect(struct map_session_data *sd,int flag,int nameid)
  5137. {
  5138. int view,fd;
  5139. nullpo_retr(0, sd);
  5140. fd=sd->fd;
  5141. // 名前の登録と送信を先にしておく
  5142. if( map_charid2nick(sd->status.char_id)==NULL )
  5143. map_addchariddb(sd->status.char_id,sd->status.name);
  5144. clif_solved_charname(sd,sd->status.char_id);
  5145. WFIFOW(fd, 0)=0x18f;
  5146. WFIFOW(fd, 2)=flag;
  5147. if((view = itemdb_viewid(nameid)) > 0)
  5148. WFIFOW(fd, 4)=view;
  5149. else
  5150. WFIFOW(fd, 4)=nameid;
  5151. WFIFOSET(fd,packet_len_table[0x18f]);
  5152. return 0;
  5153. }
  5154. // pet
  5155. int clif_catch_process(struct map_session_data *sd)
  5156. {
  5157. int fd;
  5158. nullpo_retr(0, sd);
  5159. fd=sd->fd;
  5160. WFIFOW(fd,0)=0x19e;
  5161. WFIFOSET(fd,packet_len_table[0x19e]);
  5162. return 0;
  5163. }
  5164. int clif_pet_rulet(struct map_session_data *sd,int data)
  5165. {
  5166. int fd;
  5167. nullpo_retr(0, sd);
  5168. fd=sd->fd;
  5169. WFIFOW(fd,0)=0x1a0;
  5170. WFIFOB(fd,2)=data;
  5171. WFIFOSET(fd,packet_len_table[0x1a0]);
  5172. return 0;
  5173. }
  5174. /*==========================================
  5175. * pet卵リスト作成
  5176. *------------------------------------------
  5177. */
  5178. int clif_sendegg(struct map_session_data *sd)
  5179. {
  5180. //R 01a6 <len>.w <index>.w*
  5181. int i,n=0,fd;
  5182. nullpo_retr(0, sd);
  5183. fd=sd->fd;
  5184. WFIFOW(fd,0)=0x1a6;
  5185. if(sd->status.pet_id <= 0) {
  5186. for(i=0,n=0;i<MAX_INVENTORY;i++){
  5187. if(sd->status.inventory[i].nameid<=0 || sd->inventory_data[i] == NULL ||
  5188. sd->inventory_data[i]->type!=7 ||
  5189. sd->status.inventory[i].amount<=0)
  5190. continue;
  5191. WFIFOW(fd,n*2+4)=i+2;
  5192. n++;
  5193. }
  5194. }
  5195. WFIFOW(fd,2)=4+n*2;
  5196. WFIFOSET(fd,WFIFOW(fd,2));
  5197. return 0;
  5198. }
  5199. int clif_send_petdata(struct map_session_data *sd,int type,int param)
  5200. {
  5201. int fd;
  5202. nullpo_retr(0, sd);
  5203. fd=sd->fd;
  5204. WFIFOW(fd,0)=0x1a4;
  5205. WFIFOB(fd,2)=type;
  5206. WFIFOL(fd,3)=sd->pd->bl.id;
  5207. WFIFOL(fd,7)=param;
  5208. WFIFOSET(fd,packet_len_table[0x1a4]);
  5209. return 0;
  5210. }
  5211. int clif_send_petstatus(struct map_session_data *sd)
  5212. {
  5213. int fd;
  5214. nullpo_retr(0, sd);
  5215. fd=sd->fd;
  5216. WFIFOW(fd,0)=0x1a2;
  5217. memcpy(WFIFOP(fd,2),sd->pet.name,24);
  5218. WFIFOB(fd,26)=(battle_config.pet_rename == 1)? 0:sd->pet.rename_flag;
  5219. WFIFOW(fd,27)=sd->pet.level;
  5220. WFIFOW(fd,29)=sd->pet.hungry;
  5221. WFIFOW(fd,31)=sd->pet.intimate;
  5222. WFIFOW(fd,33)=sd->pet.equip;
  5223. WFIFOSET(fd,packet_len_table[0x1a2]);
  5224. return 0;
  5225. }
  5226. /*==========================================
  5227. *
  5228. *------------------------------------------
  5229. */
  5230. int clif_pet_emotion(struct pet_data *pd,int param)
  5231. {
  5232. unsigned char buf[16];
  5233. struct map_session_data *sd;
  5234. nullpo_retr(0, pd);
  5235. nullpo_retr(0, sd = pd->msd);
  5236. memset(buf,0,packet_len_table[0x1aa]);
  5237. WBUFW(buf,0)=0x1aa;
  5238. WBUFL(buf,2)=pd->bl.id;
  5239. if(param >= 100 && sd->petDB->talk_convert_class) {
  5240. if(sd->petDB->talk_convert_class < 0)
  5241. return 0;
  5242. else if(sd->petDB->talk_convert_class > 0) {
  5243. param -= (pd->class_ - 100)*100;
  5244. param += (sd->petDB->talk_convert_class - 100)*100;
  5245. }
  5246. }
  5247. WBUFL(buf,6)=param;
  5248. clif_send(buf,packet_len_table[0x1aa],&pd->bl,AREA);
  5249. return 0;
  5250. }
  5251. int clif_pet_performance(struct block_list *bl,int param)
  5252. {
  5253. unsigned char buf[16];
  5254. nullpo_retr(0, bl);
  5255. memset(buf,0,packet_len_table[0x1a4]);
  5256. WBUFW(buf,0)=0x1a4;
  5257. WBUFB(buf,2)=4;
  5258. WBUFL(buf,3)=bl->id;
  5259. WBUFL(buf,7)=param;
  5260. clif_send(buf,packet_len_table[0x1a4],bl,AREA);
  5261. return 0;
  5262. }
  5263. int clif_pet_equip(struct pet_data *pd,int nameid)
  5264. {
  5265. unsigned char buf[16];
  5266. int view;
  5267. nullpo_retr(0, pd);
  5268. memset(buf,0,packet_len_table[0x1a4]);
  5269. WBUFW(buf,0)=0x1a4;
  5270. WBUFB(buf,2)=3;
  5271. WBUFL(buf,3)=pd->bl.id;
  5272. if((view = itemdb_viewid(nameid)) > 0)
  5273. WBUFL(buf,7)=view;
  5274. else
  5275. WBUFL(buf,7)=nameid;
  5276. clif_send(buf,packet_len_table[0x1a4],&pd->bl,AREA);
  5277. return 0;
  5278. }
  5279. int clif_pet_food(struct map_session_data *sd,int foodid,int fail)
  5280. {
  5281. int fd;
  5282. nullpo_retr(0, sd);
  5283. fd=sd->fd;
  5284. WFIFOW(fd,0)=0x1a3;
  5285. WFIFOB(fd,2)=fail;
  5286. WFIFOW(fd,3)=foodid;
  5287. WFIFOSET(fd,packet_len_table[0x1a3]);
  5288. return 0;
  5289. }
  5290. /*==========================================
  5291. * オートスペル リスト送信
  5292. *------------------------------------------
  5293. */
  5294. int clif_autospell(struct map_session_data *sd,int skilllv)
  5295. {
  5296. int fd;
  5297. nullpo_retr(0, sd);
  5298. fd=sd->fd;
  5299. WFIFOW(fd, 0)=0x1cd;
  5300. if(skilllv>0 && pc_checkskill(sd,MG_NAPALMBEAT)>0)
  5301. WFIFOL(fd,2)= MG_NAPALMBEAT;
  5302. else
  5303. WFIFOL(fd,2)= 0x00000000;
  5304. if(skilllv>1 && pc_checkskill(sd,MG_COLDBOLT)>0)
  5305. WFIFOL(fd,6)= MG_COLDBOLT;
  5306. else
  5307. WFIFOL(fd,6)= 0x00000000;
  5308. if(skilllv>1 && pc_checkskill(sd,MG_FIREBOLT)>0)
  5309. WFIFOL(fd,10)= MG_FIREBOLT;
  5310. else
  5311. WFIFOL(fd,10)= 0x00000000;
  5312. if(skilllv>1 && pc_checkskill(sd,MG_LIGHTNINGBOLT)>0)
  5313. WFIFOL(fd,14)= MG_LIGHTNINGBOLT;
  5314. else
  5315. WFIFOL(fd,14)= 0x00000000;
  5316. if(skilllv>4 && pc_checkskill(sd,MG_SOULSTRIKE)>0)
  5317. WFIFOL(fd,18)= MG_SOULSTRIKE;
  5318. else
  5319. WFIFOL(fd,18)= 0x00000000;
  5320. if(skilllv>7 && pc_checkskill(sd,MG_FIREBALL)>0)
  5321. WFIFOL(fd,22)= MG_FIREBALL;
  5322. else
  5323. WFIFOL(fd,22)= 0x00000000;
  5324. if(skilllv>9 && pc_checkskill(sd,MG_FROSTDIVER)>0)
  5325. WFIFOL(fd,26)= MG_FROSTDIVER;
  5326. else
  5327. WFIFOL(fd,26)= 0x00000000;
  5328. WFIFOSET(fd,packet_len_table[0x1cd]);
  5329. return 0;
  5330. }
  5331. /*==========================================
  5332. * ディボーションの青い糸
  5333. *------------------------------------------
  5334. */
  5335. int clif_devotion(struct map_session_data *sd,int target)
  5336. {
  5337. unsigned char buf[56];
  5338. int n;
  5339. nullpo_retr(0, sd);
  5340. WBUFW(buf,0)=0x1cf;
  5341. WBUFL(buf,2)=sd->bl.id;
  5342. // WBUFL(buf,6)=target;
  5343. for(n=0;n<5;n++)
  5344. WBUFL(buf,6+4*n)=sd->dev.val2[n];
  5345. // WBUFL(buf,10+4*n)=0;
  5346. WBUFB(buf,26)=8;
  5347. WBUFB(buf,27)=0;
  5348. clif_send(buf,packet_len_table[0x1cf],&sd->bl,AREA);
  5349. return 0;
  5350. }
  5351. /*==========================================
  5352. * 氣球
  5353. *------------------------------------------
  5354. */
  5355. int clif_spiritball(struct map_session_data *sd)
  5356. {
  5357. unsigned char buf[16];
  5358. nullpo_retr(0, sd);
  5359. WBUFW(buf,0)=0x1d0;
  5360. WBUFL(buf,2)=sd->bl.id;
  5361. WBUFW(buf,6)=sd->spiritball;
  5362. clif_send(buf,packet_len_table[0x1d0],&sd->bl,AREA);
  5363. return 0;
  5364. }
  5365. /*==========================================
  5366. *
  5367. *------------------------------------------
  5368. */
  5369. int clif_combo_delay(struct block_list *bl,int wait)
  5370. {
  5371. unsigned char buf[32];
  5372. nullpo_retr(0, bl);
  5373. WBUFW(buf,0)=0x1d2;
  5374. WBUFL(buf,2)=bl->id;
  5375. WBUFL(buf,6)=wait;
  5376. clif_send(buf,packet_len_table[0x1d2],bl,AREA);
  5377. return 0;
  5378. }
  5379. /*==========================================
  5380. *白刃取り
  5381. *------------------------------------------
  5382. */
  5383. int clif_bladestop(struct block_list *src,struct block_list *dst,
  5384. int _bool)
  5385. {
  5386. unsigned char buf[32];
  5387. nullpo_retr(0, src);
  5388. nullpo_retr(0, dst);
  5389. WBUFW(buf,0)=0x1d1;
  5390. WBUFL(buf,2)=src->id;
  5391. WBUFL(buf,6)=dst->id;
  5392. WBUFL(buf,10)=_bool;
  5393. clif_send(buf,packet_len_table[0x1d1],src,AREA);
  5394. return 0;
  5395. }
  5396. /*==========================================
  5397. *
  5398. *------------------------------------------
  5399. */
  5400. int clif_changemapcell(int m,int x,int y,int cell_type,int type)
  5401. {
  5402. struct block_list bl;
  5403. unsigned char buf[32];
  5404. bl.m = m;
  5405. bl.x = x;
  5406. bl.y = y;
  5407. WBUFW(buf,0) = 0x192;
  5408. WBUFW(buf,2) = x;
  5409. WBUFW(buf,4) = y;
  5410. WBUFW(buf,6) = cell_type;
  5411. memcpy(WBUFP(buf,8),map[m].name,16);
  5412. if(!type)
  5413. clif_send(buf,packet_len_table[0x192],&bl,AREA);
  5414. else
  5415. clif_send(buf,packet_len_table[0x192],&bl,ALL_SAMEMAP);
  5416. return 0;
  5417. }
  5418. /*==========================================
  5419. * MVPエフェクト
  5420. *------------------------------------------
  5421. */
  5422. int clif_mvp_effect(struct map_session_data *sd)
  5423. {
  5424. unsigned char buf[16];
  5425. nullpo_retr(0, sd);
  5426. WBUFW(buf,0)=0x10c;
  5427. WBUFL(buf,2)=sd->bl.id;
  5428. clif_send(buf,packet_len_table[0x10c],&sd->bl,AREA);
  5429. return 0;
  5430. }
  5431. /*==========================================
  5432. * MVPアイテム所得
  5433. *------------------------------------------
  5434. */
  5435. int clif_mvp_item(struct map_session_data *sd,int nameid)
  5436. {
  5437. int view,fd;
  5438. nullpo_retr(0, sd);
  5439. fd=sd->fd;
  5440. WFIFOW(fd,0)=0x10a;
  5441. if((view = itemdb_viewid(nameid)) > 0)
  5442. WFIFOW(fd,2)=view;
  5443. else
  5444. WFIFOW(fd,2)=nameid;
  5445. WFIFOSET(fd,packet_len_table[0x10a]);
  5446. return 0;
  5447. }
  5448. /*==========================================
  5449. * MVP経験値所得
  5450. *------------------------------------------
  5451. */
  5452. int clif_mvp_exp(struct map_session_data *sd,int exp)
  5453. {
  5454. int fd;
  5455. nullpo_retr(0, sd);
  5456. fd=sd->fd;
  5457. WFIFOW(fd,0)=0x10b;
  5458. WFIFOL(fd,2)=exp;
  5459. WFIFOSET(fd,packet_len_table[0x10b]);
  5460. return 0;
  5461. }
  5462. /*==========================================
  5463. * ギルド作成可否通知
  5464. *------------------------------------------
  5465. */
  5466. int clif_guild_created(struct map_session_data *sd,int flag)
  5467. {
  5468. int fd;
  5469. nullpo_retr(0, sd);
  5470. fd=sd->fd;
  5471. WFIFOW(fd,0)=0x167;
  5472. WFIFOB(fd,2)=flag;
  5473. WFIFOSET(fd,packet_len_table[0x167]);
  5474. return 0;
  5475. }
  5476. /*==========================================
  5477. * ギルド所属通知
  5478. *------------------------------------------
  5479. */
  5480. int clif_guild_belonginfo(struct map_session_data *sd,struct guild *g)
  5481. {
  5482. int ps,fd;
  5483. nullpo_retr(0, sd);
  5484. nullpo_retr(0, g);
  5485. fd=sd->fd;
  5486. ps=guild_getposition(sd,g);
  5487. memset(WFIFOP(fd,0),0,packet_len_table[0x16c]);
  5488. WFIFOW(fd,0)=0x16c;
  5489. WFIFOL(fd,2)=g->guild_id;
  5490. WFIFOL(fd,6)=g->emblem_id;
  5491. WFIFOL(fd,10)=g->position[ps].mode;
  5492. memcpy(WFIFOP(fd,19),g->name,24);
  5493. WFIFOSET(fd,packet_len_table[0x16c]);
  5494. return 0;
  5495. }
  5496. /*==========================================
  5497. * ギルドメンバログイン通知
  5498. *------------------------------------------
  5499. */
  5500. int clif_guild_memberlogin_notice(struct guild *g,int idx,int flag)
  5501. {
  5502. unsigned char buf[64];
  5503. nullpo_retr(0, g);
  5504. // printf("clif_guild_message(%s, %d, %s)\n", g->name, account_id, mes);
  5505. WBUFW(buf, 0)=0x16d;
  5506. WBUFL(buf, 2)=g->member[idx].account_id;
  5507. WBUFL(buf, 6)=g->member[idx].char_id;
  5508. WBUFL(buf,10)=flag;
  5509. if(g->member[idx].sd==NULL){
  5510. struct map_session_data *sd=guild_getavailablesd(g);
  5511. if(sd!=NULL)
  5512. clif_send(buf,packet_len_table[0x16d],&sd->bl,GUILD);
  5513. }else
  5514. clif_send(buf,packet_len_table[0x16d],&g->member[idx].sd->bl,GUILD_WOS);
  5515. return 0;
  5516. }
  5517. /*==========================================
  5518. * ギルドマスター通知(14dへの応答)
  5519. *------------------------------------------
  5520. */
  5521. int clif_guild_masterormember(struct map_session_data *sd)
  5522. {
  5523. int type=0x57,fd;
  5524. struct guild *g;
  5525. nullpo_retr(0, sd);
  5526. fd=sd->fd;
  5527. g=guild_search(sd->status.guild_id);
  5528. if(g!=NULL && strcmp(g->master,sd->status.name)==0)
  5529. type=0xd7;
  5530. WFIFOW(fd,0)=0x14e;
  5531. WFIFOL(fd,2)=type;
  5532. WFIFOSET(fd,packet_len_table[0x14e]);
  5533. return 0;
  5534. }
  5535. /*==========================================
  5536. * Basic Info (Territories [Valaris])
  5537. *------------------------------------------
  5538. */
  5539. int clif_guild_basicinfo(struct map_session_data *sd)
  5540. {
  5541. int fd,i,t=0;
  5542. struct guild *g;
  5543. struct guild_castle *gc=NULL;
  5544. nullpo_retr(0, sd);
  5545. fd=sd->fd;
  5546. g=guild_search(sd->status.guild_id);
  5547. if(g==NULL)
  5548. return 0;
  5549. WFIFOW(fd, 0)=0x1b6;//0x150;
  5550. WFIFOL(fd, 2)=g->guild_id;
  5551. WFIFOL(fd, 6)=g->guild_lv;
  5552. WFIFOL(fd,10)=g->connect_member;
  5553. WFIFOL(fd,14)=g->max_member;
  5554. WFIFOL(fd,18)=g->average_lv;
  5555. WFIFOL(fd,22)=g->exp;
  5556. WFIFOL(fd,26)=g->next_exp;
  5557. WFIFOL(fd,30)=0; // 上納
  5558. WFIFOL(fd,34)=0; // VW(性格の悪さ?:性向グラフ左右)
  5559. WFIFOL(fd,38)=0; // RF(正義の度合い?:性向グラフ上下)
  5560. WFIFOL(fd,42)=0; // 人数?
  5561. memcpy(WFIFOP(fd,46),g->name,24);
  5562. memcpy(WFIFOP(fd,70),g->master,24);
  5563. for(i=0;i<MAX_GUILDCASTLE;i++){
  5564. gc=guild_castle_search(i);
  5565. if(!gc) continue;
  5566. if(g->guild_id == gc->guild_id) t++;
  5567. }
  5568. if (t==1) strncpy((char*)WFIFOP(fd,94),"One Castle",20);
  5569. else if (t==2) strncpy((char*)WFIFOP(fd,94),"Two Castles",20);
  5570. else if (t==3) strncpy((char*)WFIFOP(fd,94),"Three Castles",20);
  5571. else if (t==4) strncpy((char*)WFIFOP(fd,94),"Four Castles",20);
  5572. else if (t==5) strncpy((char*)WFIFOP(fd,94),"Five Castles",20);
  5573. else if (t==6) strncpy((char*)WFIFOP(fd,94),"Six Castles",20);
  5574. else if (t==7) strncpy((char*)WFIFOP(fd,94),"Seven Castles",20);
  5575. else if (t==8) strncpy((char*)WFIFOP(fd,94),"Eight Castles",20);
  5576. else if (t==9) strncpy((char*)WFIFOP(fd,94),"Nine Castles",20);
  5577. else if (t==10) strncpy((char*)WFIFOP(fd,94),"Ten Castles",20);
  5578. else if (t==11) strncpy((char*)WFIFOP(fd,94),"Eleven Castles",20);
  5579. else if (t==12) strncpy((char*)WFIFOP(fd,94),"Twelve Castles",20);
  5580. else if (t==13) strncpy((char*)WFIFOP(fd,94),"Thirteen Castles",20);
  5581. else if (t==14) strncpy((char*)WFIFOP(fd,94),"Fourteen Castles",20);
  5582. else if (t==15) strncpy((char*)WFIFOP(fd,94),"Fifteen Castles",20);
  5583. else if (t==16) strncpy((char*)WFIFOP(fd,94),"Sixteen Castles",20);
  5584. else if (t==17) strncpy((char*)WFIFOP(fd,94),"Seventeen Castles",20);
  5585. else if (t==18) strncpy((char*)WFIFOP(fd,94),"Eighteen Castles",20);
  5586. else if (t==19) strncpy((char*)WFIFOP(fd,94),"Nineteen Castles",20);
  5587. else if (t==20) strncpy((char*)WFIFOP(fd,94),"Twenty Castles",20);
  5588. else if (t==21) strncpy((char*)WFIFOP(fd,94),"Twenty One Castles",20);
  5589. else if (t==22) strncpy((char*)WFIFOP(fd,94),"Twenty Two Castles",20);
  5590. else if (t==23) strncpy((char*)WFIFOP(fd,94),"Twenty Three Castles",20);
  5591. else if (t==24) strncpy((char*)WFIFOP(fd,94),"Twenty Four Castles",20);
  5592. else if (t==MAX_GUILDCASTLE) strncpy((char*)WFIFOP(fd,94),"Total Domination",20);
  5593. else strncpy((char*)WFIFOP(fd,94),"None Taken",20);
  5594. WFIFOSET(fd,packet_len_table[WFIFOW(fd,0)]);
  5595. clif_guild_emblem(sd,g); // Guild emblem vanish fix [Valaris]
  5596. return 0;
  5597. }
  5598. /*==========================================
  5599. * ギルド同盟/敵対情報
  5600. *------------------------------------------
  5601. */
  5602. int clif_guild_allianceinfo(struct map_session_data *sd)
  5603. {
  5604. int fd,i,c;
  5605. struct guild *g;
  5606. nullpo_retr(0, sd);
  5607. fd=sd->fd;
  5608. g=guild_search(sd->status.guild_id);
  5609. if(g==NULL)
  5610. return 0;
  5611. WFIFOW(fd, 0)=0x14c;
  5612. for(i=c=0;i<MAX_GUILDALLIANCE;i++){
  5613. struct guild_alliance *a=&g->alliance[i];
  5614. if(a->guild_id>0){
  5615. WFIFOL(fd,c*32+4)=a->opposition;
  5616. WFIFOL(fd,c*32+8)=a->guild_id;
  5617. memcpy(WFIFOP(fd,c*32+12),a->name,24);
  5618. c++;
  5619. }
  5620. }
  5621. WFIFOW(fd, 2)=c*32+4;
  5622. WFIFOSET(fd,WFIFOW(fd,2));
  5623. return 0;
  5624. }
  5625. /*==========================================
  5626. * ギルドメンバーリスト
  5627. *------------------------------------------
  5628. */
  5629. int clif_guild_memberlist(struct map_session_data *sd)
  5630. {
  5631. int fd;
  5632. int i,c;
  5633. struct guild *g;
  5634. nullpo_retr(0, sd);
  5635. fd=sd->fd;
  5636. g=guild_search(sd->status.guild_id);
  5637. if(g==NULL)
  5638. return 0;
  5639. WFIFOW(fd, 0)=0x154;
  5640. for(i=0,c=0;i<g->max_member;i++){
  5641. struct guild_member *m=&g->member[i];
  5642. if(m->account_id==0)
  5643. continue;
  5644. WFIFOL(fd,c*104+ 4)=m->account_id;
  5645. WFIFOL(fd,c*104+ 8)=m->char_id;
  5646. WFIFOW(fd,c*104+12)=m->hair;
  5647. WFIFOW(fd,c*104+14)=m->hair_color;
  5648. WFIFOW(fd,c*104+16)=m->gender;
  5649. WFIFOW(fd,c*104+18)=m->class_;
  5650. WFIFOW(fd,c*104+20)=m->lv;
  5651. WFIFOL(fd,c*104+22)=m->exp;
  5652. WFIFOL(fd,c*104+26)=m->online;
  5653. WFIFOL(fd,c*104+30)=m->position;
  5654. memset(WFIFOP(fd,c*104+34),0,50); // メモ?
  5655. memcpy(WFIFOP(fd,c*104+84),m->name,24);
  5656. c++;
  5657. }
  5658. WFIFOW(fd, 2)=c*104+4;
  5659. WFIFOSET(fd,WFIFOW(fd,2));
  5660. return 0;
  5661. }
  5662. /*==========================================
  5663. * ギルド役職名リスト
  5664. *------------------------------------------
  5665. */
  5666. int clif_guild_positionnamelist(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)=0x166;
  5676. for(i=0;i<MAX_GUILDPOSITION;i++){
  5677. WFIFOL(fd,i*28+4)=i;
  5678. memcpy(WFIFOP(fd,i*28+8),g->position[i].name,24);
  5679. }
  5680. WFIFOW(fd,2)=i*28+4;
  5681. WFIFOSET(fd,WFIFOW(fd,2));
  5682. return 0;
  5683. }
  5684. /*==========================================
  5685. * ギルド役職情報リスト
  5686. *------------------------------------------
  5687. */
  5688. int clif_guild_positioninfolist(struct map_session_data *sd)
  5689. {
  5690. int i,fd;
  5691. struct guild *g;
  5692. nullpo_retr(0, sd);
  5693. fd=sd->fd;
  5694. g=guild_search(sd->status.guild_id);
  5695. if(g==NULL)
  5696. return 0;
  5697. WFIFOW(fd, 0)=0x160;
  5698. for(i=0;i<MAX_GUILDPOSITION;i++){
  5699. struct guild_position *p=&g->position[i];
  5700. WFIFOL(fd,i*16+ 4)=i;
  5701. WFIFOL(fd,i*16+ 8)=p->mode;
  5702. WFIFOL(fd,i*16+12)=i;
  5703. WFIFOL(fd,i*16+16)=p->exp_mode;
  5704. }
  5705. WFIFOW(fd, 2)=i*16+4;
  5706. WFIFOSET(fd,WFIFOW(fd,2));
  5707. return 0;
  5708. }
  5709. /*==========================================
  5710. * ギルド役職変更通知
  5711. *------------------------------------------
  5712. */
  5713. int clif_guild_positionchanged(struct guild *g,int idx)
  5714. {
  5715. struct map_session_data *sd;
  5716. unsigned char buf[128];
  5717. nullpo_retr(0, g);
  5718. WBUFW(buf, 0)=0x174;
  5719. WBUFW(buf, 2)=44;
  5720. WBUFL(buf, 4)=idx;
  5721. WBUFL(buf, 8)=g->position[idx].mode;
  5722. WBUFL(buf,12)=idx;
  5723. WBUFL(buf,16)=g->position[idx].exp_mode;
  5724. memcpy(WBUFP(buf,20),g->position[idx].name,24);
  5725. if( (sd=guild_getavailablesd(g))!=NULL )
  5726. clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
  5727. return 0;
  5728. }
  5729. /*==========================================
  5730. * ギルドメンバ変更通知
  5731. *------------------------------------------
  5732. */
  5733. int clif_guild_memberpositionchanged(struct guild *g,int idx)
  5734. {
  5735. struct map_session_data *sd;
  5736. unsigned char buf[64];
  5737. nullpo_retr(0, g);
  5738. WBUFW(buf, 0)=0x156;
  5739. WBUFW(buf, 2)=16;
  5740. WBUFL(buf, 4)=g->member[idx].account_id;
  5741. WBUFL(buf, 8)=g->member[idx].char_id;
  5742. WBUFL(buf,12)=g->member[idx].position;
  5743. if( (sd=guild_getavailablesd(g))!=NULL )
  5744. clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
  5745. return 0;
  5746. }
  5747. /*==========================================
  5748. * ギルドエンブレム送信
  5749. *------------------------------------------
  5750. */
  5751. int clif_guild_emblem(struct map_session_data *sd,struct guild *g)
  5752. {
  5753. int fd;
  5754. nullpo_retr(0, sd);
  5755. nullpo_retr(0, g);
  5756. fd=sd->fd;
  5757. if(g->emblem_len<=0)
  5758. return 0;
  5759. WFIFOW(fd,0)=0x152;
  5760. WFIFOW(fd,2)=g->emblem_len+12;
  5761. WFIFOL(fd,4)=g->guild_id;
  5762. WFIFOL(fd,8)=g->emblem_id;
  5763. memcpy(WFIFOP(fd,12),g->emblem_data,g->emblem_len);
  5764. WFIFOSET(fd,WFIFOW(fd,2));
  5765. return 0;
  5766. }
  5767. /*==========================================
  5768. * ギルドスキル送信
  5769. *------------------------------------------
  5770. */
  5771. int clif_guild_skillinfo(struct map_session_data *sd)
  5772. {
  5773. int fd;
  5774. int i,id,c,up=1;
  5775. struct guild *g;
  5776. nullpo_retr(0, sd);
  5777. fd=sd->fd;
  5778. g=guild_search(sd->status.guild_id);
  5779. if(g==NULL)
  5780. return 0;
  5781. WFIFOW(fd,0)=0x0162;
  5782. WFIFOW(fd,4)=g->skill_point;
  5783. for(i=c=0;i<MAX_GUILDSKILL;i++){
  5784. if(g->skill[i].id>0){
  5785. WFIFOW(fd,c*37+ 6) = id = g->skill[i].id;
  5786. WFIFOW(fd,c*37+ 8) = guild_skill_get_inf(id);
  5787. WFIFOW(fd,c*37+10) = 0;
  5788. WFIFOW(fd,c*37+12) = g->skill[i].lv;
  5789. WFIFOW(fd,c*37+14) = guild_skill_get_sp(id,g->skill[i].lv);
  5790. WFIFOW(fd,c*37+16) = guild_skill_get_range(id);
  5791. memset(WFIFOP(fd,c*37+18),0,24);
  5792. if(g->skill[i].lv < guild_skill_get_max(id)) {
  5793. //Kafra and Guardian changed to require Approval [Sara]
  5794. switch (g->skill[i].id)
  5795. {
  5796. case GD_KAFRACONTACT:
  5797. case GD_GUARDIANRESEARCH:
  5798. case GD_GUARDUP:
  5799. up = guild_checkskill(g,GD_APPROVAL) > 0;
  5800. break;
  5801. case GD_LEADERSHIP:
  5802. //Glory skill requirements -- Pretty sure correct [Sara]
  5803. up = guild_checkskill(g,GD_GLORYGUILD) > 0;
  5804. break;
  5805. case GD_GLORYWOUNDS:
  5806. up = guild_checkskill(g,GD_GLORYGUILD) > 0;
  5807. break;
  5808. case GD_SOULCOLD:
  5809. up = guild_checkskill(g,GD_GLORYWOUNDS) > 0;
  5810. break;
  5811. case GD_HAWKEYES:
  5812. up = guild_checkskill(g,GD_LEADERSHIP) > 0;
  5813. break;
  5814. case GD_BATTLEORDER:
  5815. up = guild_checkskill(g,GD_APPROVAL) > 0 &&
  5816. guild_checkskill(g,GD_EXTENSION) >= 2;
  5817. break;
  5818. case GD_REGENERATION:
  5819. up = guild_checkskill(g,GD_EXTENSION) >= 5 &&
  5820. guild_checkskill(g,GD_BATTLEORDER) > 0;
  5821. break;
  5822. case GD_RESTORE:
  5823. up = guild_checkskill(g,GD_REGENERATION) >= 2;
  5824. break;
  5825. case GD_EMERGENCYCALL:
  5826. up = guild_checkskill(g,GD_GUARDIANRESEARCH) > 0 &&
  5827. guild_checkskill(g,GD_REGENERATION) > 0;
  5828. break;
  5829. case GD_DEVELOPMENT:
  5830. up = 0;
  5831. break;
  5832. default:
  5833. up = 1;
  5834. }
  5835. }
  5836. else {
  5837. up = 0;
  5838. }
  5839. WFIFOB(fd,c*37+42)= up;
  5840. c++;
  5841. }
  5842. }
  5843. WFIFOW(fd,2)=c*37+6;
  5844. WFIFOSET(fd,WFIFOW(fd,2));
  5845. return 0;
  5846. }
  5847. /*==========================================
  5848. * ギルド告知送信
  5849. *------------------------------------------
  5850. */
  5851. int clif_guild_notice(struct map_session_data *sd,struct guild *g)
  5852. {
  5853. int fd;
  5854. nullpo_retr(0, sd);
  5855. nullpo_retr(0, g);
  5856. fd=sd->fd;
  5857. if(*g->mes1==0 && *g->mes2==0)
  5858. return 0;
  5859. WFIFOW(fd,0)=0x16f;
  5860. memcpy(WFIFOP(fd,2),g->mes1,60);
  5861. memcpy(WFIFOP(fd,62),g->mes2,120);
  5862. WFIFOSET(fd,packet_len_table[0x16f]);
  5863. return 0;
  5864. }
  5865. /*==========================================
  5866. * ギルドメンバ勧誘
  5867. *------------------------------------------
  5868. */
  5869. int clif_guild_invite(struct map_session_data *sd,struct guild *g)
  5870. {
  5871. int fd;
  5872. nullpo_retr(0, sd);
  5873. nullpo_retr(0, g);
  5874. fd=sd->fd;
  5875. WFIFOW(fd,0)=0x16a;
  5876. WFIFOL(fd,2)=g->guild_id;
  5877. memcpy(WFIFOP(fd,6),g->name,24);
  5878. WFIFOSET(fd,packet_len_table[0x16a]);
  5879. return 0;
  5880. }
  5881. /*==========================================
  5882. * ギルドメンバ勧誘結果
  5883. *------------------------------------------
  5884. */
  5885. int clif_guild_inviteack(struct map_session_data *sd,int flag)
  5886. {
  5887. int fd;
  5888. nullpo_retr(0, sd);
  5889. fd=sd->fd;
  5890. WFIFOW(fd,0)=0x169;
  5891. WFIFOB(fd,2)=flag;
  5892. WFIFOSET(fd,packet_len_table[0x169]);
  5893. return 0;
  5894. }
  5895. /*==========================================
  5896. * ギルドメンバ脱退通知
  5897. *------------------------------------------
  5898. */
  5899. int clif_guild_leave(struct map_session_data *sd,const char *name,const char *mes)
  5900. {
  5901. unsigned char buf[128];
  5902. nullpo_retr(0, sd);
  5903. WBUFW(buf, 0)=0x15a;
  5904. memcpy(WBUFP(buf, 2),name,24);
  5905. memcpy(WBUFP(buf,26),mes,40);
  5906. clif_send(buf,packet_len_table[0x15a],&sd->bl,GUILD);
  5907. return 0;
  5908. }
  5909. /*==========================================
  5910. * ギルドメンバ追放通知
  5911. *------------------------------------------
  5912. */
  5913. int clif_guild_explusion(struct map_session_data *sd,const char *name,const char *mes,
  5914. int account_id)
  5915. {
  5916. unsigned char buf[128];
  5917. nullpo_retr(0, sd);
  5918. WBUFW(buf, 0)=0x15c;
  5919. memcpy(WBUFP(buf, 2),name,24);
  5920. memcpy(WBUFP(buf,26),mes,40);
  5921. memcpy(WBUFP(buf,66),"dummy",24);
  5922. clif_send(buf,packet_len_table[0x15c],&sd->bl,GUILD);
  5923. return 0;
  5924. }
  5925. /*==========================================
  5926. * ギルド追放メンバリスト
  5927. *------------------------------------------
  5928. */
  5929. int clif_guild_explusionlist(struct map_session_data *sd)
  5930. {
  5931. int fd;
  5932. int i,c;
  5933. struct guild *g;
  5934. nullpo_retr(0, sd);
  5935. fd=sd->fd;
  5936. g=guild_search(sd->status.guild_id);
  5937. if(g==NULL)
  5938. return 0;
  5939. WFIFOW(fd,0)=0x163;
  5940. for(i=c=0;i<MAX_GUILDEXPLUSION;i++){
  5941. struct guild_explusion *e=&g->explusion[i];
  5942. if(e->account_id>0){
  5943. memcpy(WFIFOP(fd,c*88+ 4),e->name,24);
  5944. memcpy(WFIFOP(fd,c*88+28),e->acc,24);
  5945. memcpy(WFIFOP(fd,c*88+52),e->mes,44);
  5946. c++;
  5947. }
  5948. }
  5949. WFIFOW(fd,2)=c*88+4;
  5950. WFIFOSET(fd,WFIFOW(fd,2));
  5951. return 0;
  5952. }
  5953. /*==========================================
  5954. * ギルド会話
  5955. *------------------------------------------
  5956. */
  5957. int clif_guild_message(struct guild *g,int account_id,const char *mes,int len)
  5958. {
  5959. struct map_session_data *sd;
  5960. unsigned char *buf;
  5961. buf = (unsigned char*)aCallocA(len + 4, sizeof(unsigned char));
  5962. WBUFW(buf, 0) = 0x17f;
  5963. WBUFW(buf, 2) = len + 4;
  5964. memcpy(WBUFP(buf,4), mes, len);
  5965. if ((sd = guild_getavailablesd(g)) != NULL)
  5966. clif_send(buf, WBUFW(buf,2), &sd->bl, GUILD);
  5967. if(buf) aFree(buf);
  5968. return 0;
  5969. }
  5970. /*==========================================
  5971. * ギルドスキル割り振り通知
  5972. *------------------------------------------
  5973. */
  5974. int clif_guild_skillup(struct map_session_data *sd,int skill_num,int lv)
  5975. {
  5976. int fd;
  5977. nullpo_retr(0, sd);
  5978. fd=sd->fd;
  5979. WFIFOW(fd,0) = 0x10e;
  5980. WFIFOW(fd,2) = skill_num;
  5981. WFIFOW(fd,4) = lv;
  5982. WFIFOW(fd,6) = guild_skill_get_sp(skill_num,lv);
  5983. WFIFOW(fd,8) = guild_skill_get_range(skill_num);
  5984. WFIFOB(fd,10) = 1;
  5985. WFIFOSET(fd,11);
  5986. return 0;
  5987. }
  5988. /*==========================================
  5989. * ギルド同盟要請
  5990. *------------------------------------------
  5991. */
  5992. int clif_guild_reqalliance(struct map_session_data *sd,int account_id,const char *name)
  5993. {
  5994. int fd;
  5995. nullpo_retr(0, sd);
  5996. fd=sd->fd;
  5997. WFIFOW(fd,0)=0x171;
  5998. WFIFOL(fd,2)=account_id;
  5999. memcpy(WFIFOP(fd,6),name,24);
  6000. WFIFOSET(fd,packet_len_table[0x171]);
  6001. return 0;
  6002. }
  6003. /*==========================================
  6004. * ギルド同盟結果
  6005. *------------------------------------------
  6006. */
  6007. int clif_guild_allianceack(struct map_session_data *sd,int flag)
  6008. {
  6009. int fd;
  6010. nullpo_retr(0, sd);
  6011. fd=sd->fd;
  6012. WFIFOW(fd,0)=0x173;
  6013. WFIFOL(fd,2)=flag;
  6014. WFIFOSET(fd,packet_len_table[0x173]);
  6015. return 0;
  6016. }
  6017. /*==========================================
  6018. * ギルド関係解消通知
  6019. *------------------------------------------
  6020. */
  6021. int clif_guild_delalliance(struct map_session_data *sd,int guild_id,int flag)
  6022. {
  6023. int fd;
  6024. nullpo_retr(0, sd);
  6025. fd=sd->fd;
  6026. WFIFOW(fd,0)=0x184;
  6027. WFIFOL(fd,2)=guild_id;
  6028. WFIFOL(fd,6)=flag;
  6029. WFIFOSET(fd,packet_len_table[0x184]);
  6030. return 0;
  6031. }
  6032. /*==========================================
  6033. * ギルド敵対結果
  6034. *------------------------------------------
  6035. */
  6036. int clif_guild_oppositionack(struct map_session_data *sd,int flag)
  6037. {
  6038. int fd;
  6039. nullpo_retr(0, sd);
  6040. fd=sd->fd;
  6041. WFIFOW(fd,0)=0x181;
  6042. WFIFOB(fd,2)=flag;
  6043. WFIFOSET(fd,packet_len_table[0x181]);
  6044. return 0;
  6045. }
  6046. /*==========================================
  6047. * ギルド関係追加
  6048. *------------------------------------------
  6049. */
  6050. /*int clif_guild_allianceadded(struct guild *g,int idx)
  6051. {
  6052. unsigned char buf[64];
  6053. WBUFW(fd,0)=0x185;
  6054. WBUFL(fd,2)=g->alliance[idx].opposition;
  6055. WBUFL(fd,6)=g->alliance[idx].guild_id;
  6056. memcpy(WBUFP(fd,10),g->alliance[idx].name,24);
  6057. clif_send(buf,packet_len_table[0x185],guild_getavailablesd(g),GUILD);
  6058. return 0;
  6059. }*/
  6060. /*==========================================
  6061. * ギルド解散通知
  6062. *------------------------------------------
  6063. */
  6064. int clif_guild_broken(struct map_session_data *sd,int flag)
  6065. {
  6066. int fd;
  6067. nullpo_retr(0, sd);
  6068. fd=sd->fd;
  6069. WFIFOW(fd,0)=0x15e;
  6070. WFIFOL(fd,2)=flag;
  6071. WFIFOSET(fd,packet_len_table[0x15e]);
  6072. return 0;
  6073. }
  6074. /*==========================================
  6075. * エモーション
  6076. *------------------------------------------
  6077. */
  6078. void clif_emotion(struct block_list *bl,int type)
  6079. {
  6080. unsigned char buf[8];
  6081. nullpo_retv(bl);
  6082. WBUFW(buf,0)=0xc0;
  6083. WBUFL(buf,2)=bl->id;
  6084. WBUFB(buf,6)=type;
  6085. clif_send(buf,packet_len_table[0xc0],bl,AREA);
  6086. }
  6087. /*==========================================
  6088. * トーキーボックス
  6089. *------------------------------------------
  6090. */
  6091. void clif_talkiebox(struct block_list *bl,char* talkie)
  6092. {
  6093. unsigned char buf[86];
  6094. nullpo_retv(bl);
  6095. WBUFW(buf,0)=0x191;
  6096. WBUFL(buf,2)=bl->id;
  6097. memcpy(WBUFP(buf,6),talkie,80);
  6098. clif_send(buf,packet_len_table[0x191],bl,AREA);
  6099. }
  6100. /*==========================================
  6101. * 結婚エフェクト
  6102. *------------------------------------------
  6103. */
  6104. void clif_wedding_effect(struct block_list *bl) {
  6105. unsigned char buf[6];
  6106. nullpo_retv(bl);
  6107. WBUFW(buf,0) = 0x1ea;
  6108. WBUFL(buf,2) = bl->id;
  6109. clif_send(buf, packet_len_table[0x1ea], bl, AREA);
  6110. }
  6111. /*==========================================
  6112. * あなたに逢いたい使用時名前叫び
  6113. *------------------------------------------
  6114. void clif_callpartner(struct map_session_data *sd)
  6115. {
  6116. unsigned char buf[26];
  6117. char *p;
  6118. nullpo_retv(sd);
  6119. if(sd->status.partner_id){
  6120. WBUFW(buf,0)=0x1e6;
  6121. p = map_charid2nick(sd->status.partner_id);
  6122. if(p){
  6123. memcpy(WBUFP(buf,2),p,24);
  6124. }else{
  6125. map_reqchariddb(sd,sd->status.partner_id);
  6126. chrif_searchcharid(sd->status.partner_id);
  6127. WBUFB(buf,2) = 0;
  6128. }
  6129. clif_send(buf,packet_len_table[0x1e6]&sd->bl,AREA);
  6130. }
  6131. return;
  6132. }
  6133. */
  6134. /*==========================================
  6135. * Adopt baby [Celest]
  6136. *------------------------------------------
  6137. */
  6138. void clif_adopt_process(struct map_session_data *sd)
  6139. {
  6140. int fd;
  6141. nullpo_retv(sd);
  6142. fd=sd->fd;
  6143. WFIFOW(fd,0)=0x1f8;
  6144. WFIFOSET(fd,packet_len_table[0x1f8]);
  6145. }
  6146. /*==========================================
  6147. *
  6148. *------------------------------------------
  6149. */
  6150. void clif_parse_ReqAdopt(int fd, struct map_session_data *sd) {
  6151. nullpo_retv(sd);
  6152. printf ("%d\n", RFIFOL(fd,2));
  6153. }
  6154. /*==========================================
  6155. * 座る
  6156. *------------------------------------------
  6157. */
  6158. void clif_sitting(struct map_session_data *sd)
  6159. {
  6160. unsigned char buf[64];
  6161. nullpo_retv(sd);
  6162. WBUFW(buf, 0) = 0x8a;
  6163. WBUFL(buf, 2) = sd->bl.id;
  6164. WBUFB(buf,26) = 2;
  6165. clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
  6166. }
  6167. /*==========================================
  6168. *
  6169. *------------------------------------------
  6170. */
  6171. int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len)
  6172. {
  6173. unsigned char *buf;
  6174. nullpo_retr(0, sd);
  6175. buf = (unsigned char*)aCallocA(len + 8, sizeof(unsigned char));
  6176. WBUFW(buf, 0) = 0x17f;
  6177. WBUFW(buf, 2) = len + 8;
  6178. memcpy(WBUFP(buf,4), mes, len + 4);
  6179. clif_send(buf, WBUFW(buf,2), &sd->bl, SELF);
  6180. if(buf) aFree(buf);
  6181. return 0;
  6182. }
  6183. /*==========================================
  6184. *
  6185. *------------------------------------------
  6186. */
  6187. int clif_GM_kickack(struct map_session_data *sd, int id)
  6188. {
  6189. int fd;
  6190. nullpo_retr(0, sd);
  6191. fd = sd->fd;
  6192. WFIFOW(fd,0) = 0xcd;
  6193. WFIFOL(fd,2) = id;
  6194. WFIFOSET(fd, packet_len_table[0xcd]);
  6195. return 0;
  6196. }
  6197. void clif_parse_QuitGame(int fd,struct map_session_data *sd);
  6198. int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int type)
  6199. {
  6200. nullpo_retr(0, tsd);
  6201. if(type)
  6202. clif_GM_kickack(sd,tsd->status.account_id);
  6203. tsd->opt1 = tsd->opt2 = 0;
  6204. WFIFOW(tsd->fd,0) = 0x18b;
  6205. WFIFOW(tsd->fd,2) = 0;
  6206. WFIFOSET(tsd->fd,packet_len_table[0x18b]);
  6207. clif_setwaitclose(tsd->fd);
  6208. return 0;
  6209. }
  6210. /*==========================================
  6211. *
  6212. *------------------------------------------
  6213. */
  6214. int clif_timedout(struct map_session_data *sd)
  6215. {
  6216. nullpo_retr(0, sd);
  6217. sprintf(tmp_output,"%sCharacter with Account ID '"CL_WHITE"%d"CL_RESET"' timed out.\n", (pc_isGM(sd))?"GM ":"", sd->bl.id);
  6218. ShowInfo(tmp_output);
  6219. map_quit(sd);
  6220. clif_authfail_fd(sd->fd,3); // Even if player is not on we still send anyway
  6221. clif_setwaitclose(sd->fd); // Set session to EOF
  6222. return 0;
  6223. }
  6224. /*==========================================
  6225. * Wis拒否許可応答
  6226. *------------------------------------------
  6227. */
  6228. int clif_wisexin(struct map_session_data *sd,int type,int flag)
  6229. {
  6230. int fd;
  6231. nullpo_retr(0, sd);
  6232. fd=sd->fd;
  6233. WFIFOW(fd,0)=0xd1;
  6234. WFIFOB(fd,2)=type;
  6235. WFIFOB(fd,3)=flag;
  6236. WFIFOSET(fd,packet_len_table[0xd1]);
  6237. return 0;
  6238. }
  6239. /*==========================================
  6240. * Wis全拒否許可応答
  6241. *------------------------------------------
  6242. */
  6243. int clif_wisall(struct map_session_data *sd,int type,int flag)
  6244. {
  6245. int fd;
  6246. nullpo_retr(0, sd);
  6247. fd=sd->fd;
  6248. WFIFOW(fd,0)=0xd2;
  6249. WFIFOB(fd,2)=type;
  6250. WFIFOB(fd,3)=flag;
  6251. WFIFOSET(fd,packet_len_table[0xd2]);
  6252. return 0;
  6253. }
  6254. /*==========================================
  6255. * サウンドエフェクト
  6256. *------------------------------------------
  6257. */
  6258. void clif_soundeffect(struct map_session_data *sd,struct block_list *bl,char *name,int type)
  6259. {
  6260. int fd;
  6261. nullpo_retv(sd);
  6262. nullpo_retv(bl);
  6263. fd=sd->fd;
  6264. WFIFOW(fd,0)=0x1d3;
  6265. memcpy(WFIFOP(fd,2),name,24);
  6266. WFIFOB(fd,26)=type;
  6267. WFIFOL(fd,27)=0;
  6268. WFIFOL(fd,31)=bl->id;
  6269. WFIFOSET(fd,packet_len_table[0x1d3]);
  6270. return;
  6271. }
  6272. int clif_soundeffectall(struct block_list *bl, char *name, int type)
  6273. {
  6274. unsigned char buf[31];
  6275. memset(buf, 0, packet_len_table[0x1d3]);
  6276. nullpo_retr(0, bl);
  6277. WBUFW(buf,0)=0x1d3;
  6278. memcpy(WBUFP(buf,2), name, 24);
  6279. WBUFB(buf,26)=type;
  6280. WBUFL(buf,27)=0;
  6281. WBUFL(buf,31)=bl->id;
  6282. clif_send(buf, packet_len_table[0x1d3], bl, AREA);
  6283. return 0;
  6284. }
  6285. // displaying special effects (npcs, weather, etc) [Valaris]
  6286. int clif_specialeffect(struct block_list *bl, int type, int flag) {
  6287. unsigned char buf[24];
  6288. nullpo_retr(0, bl);
  6289. memset(buf, 0, packet_len_table[0x1f3]);
  6290. WBUFW(buf,0) = 0x1f3;
  6291. WBUFL(buf,2) = bl->id;
  6292. WBUFL(buf,6) = type;
  6293. if (flag == 3) {
  6294. // struct map_session_data *sd;
  6295. struct map_session_data *pl_sd;
  6296. int i;
  6297. for(i = 0; i < fd_max; i++) {
  6298. if (session[i] && (pl_sd = (struct map_session_data*)session[i]->session_data) != NULL &&
  6299. pl_sd->state.auth &&
  6300. (pc_isGM((struct map_session_data *)&bl) > pc_isGM((struct map_session_data *)&pl_sd->bl)))
  6301. clif_specialeffect(&pl_sd->bl, type, 1);
  6302. }
  6303. }
  6304. if (flag == 2) {
  6305. struct map_session_data *sd;
  6306. int i;
  6307. for(i = 0; i < fd_max; i++) {
  6308. if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth && sd->bl.m == bl->m)
  6309. clif_specialeffect(&sd->bl, type, 1);
  6310. }
  6311. }
  6312. else if (flag == 1)
  6313. clif_send(buf, packet_len_table[0x1f3], bl, SELF);
  6314. else if (!flag)
  6315. clif_send(buf, packet_len_table[0x1f3], bl, AREA);
  6316. return 0;
  6317. }
  6318. // ------------
  6319. // clif_parse_*
  6320. // ------------
  6321. // パケット読み取って色々操作
  6322. /*==========================================
  6323. *
  6324. *------------------------------------------
  6325. */
  6326. void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
  6327. {
  6328. struct map_session_data *old_sd;
  6329. int cmd, account_id; // account_id in the packet 0x72 or 0x7E
  6330. if (sd) {
  6331. if (battle_config.error_log)
  6332. printf("clif_parse_WantToConnection : invalid request?\n");
  6333. return;
  6334. }
  6335. cmd = RFIFOW(fd,0);
  6336. // packet DB
  6337. if (IS_PACKET_DB_VER(cmd)) {
  6338. //printf("Received bytes %d with packet 0x72.\n", RFIFOREST(fd));
  6339. account_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[0]);
  6340. // 0x72
  6341. } else if (cmd == 0x72) {
  6342. //printf("Received bytes %d with packet 0x72.\n", RFIFOREST(fd));
  6343. if (RFIFOREST(fd) >= 39 && (RFIFOB(fd,38) == 0 || RFIFOB(fd,38) == 1)) // 00 = Female, 01 = Male
  6344. account_id = RFIFOL(fd,12);
  6345. else if (RFIFOREST(fd) >= 22 && (RFIFOB(fd,21) == 0 || RFIFOB(fd,21) == 1)) // 00 = Female, 01 = Male
  6346. account_id = RFIFOL(fd,5);
  6347. else // old packet version
  6348. account_id = RFIFOL(fd,2);
  6349. // 0x7E
  6350. } else if (cmd == 0x7E) {
  6351. //printf("Received bytes %d with packet 0x7E.\n", RFIFOREST(fd));
  6352. if (RFIFOREST(fd) >= 37 && (RFIFOB(fd,36) == 0 || RFIFOB(fd,36) == 1)) // 00 = Female, 01 = Male
  6353. account_id = RFIFOL(fd,9);
  6354. else
  6355. account_id = RFIFOL(fd,12);
  6356. // 0xF5
  6357. } else if (cmd == 0xF5) {
  6358. //printf("Received bytes %d with packet 0xF5.\n", RFIFOREST(fd));
  6359. if (RFIFOREST(fd) >= 34 && (RFIFOB(fd,33) == 0 || RFIFOB(fd,33) == 1)) // 00 = Female, 01 = Male
  6360. account_id = RFIFOL(fd,7);
  6361. else if (RFIFOREST(fd) >= 33 && (RFIFOB(fd,32) == 0 || RFIFOB(fd,32) == 1)) // 00 = Female, 01 = Male
  6362. account_id = RFIFOL(fd,12);
  6363. else if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) // 00 = Female, 01 = Male
  6364. account_id = RFIFOL(fd,10);
  6365. else { // 29 28 28 // search correct value
  6366. // if account id and char id of version 14
  6367. if (RFIFOL(fd,3) > 700000 && RFIFOL(fd,10) >= 150000 && RFIFOL(fd,10) < 5000000) // account id / char id (more than 5.000.000 characters?) [Yor]
  6368. account_id = RFIFOL(fd,3);
  6369. else
  6370. account_id = RFIFOL(fd,5);
  6371. }
  6372. // 0x9B
  6373. } else {
  6374. account_id = RFIFOL(fd,3);
  6375. }
  6376. // if same account already connected, we disconnect the 2 sessions
  6377. if ((old_sd = map_id2sd(account_id)) != NULL) {
  6378. clif_authfail_fd(fd, 8); // still recognizes last connection
  6379. clif_authfail_fd(old_sd->fd, 2); // same id
  6380. if (sd != 0)
  6381. clif_setwaitclose(sd->fd); // Set session to EOF
  6382. } else {
  6383. sd = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data));
  6384. session[fd]->session_data = sd;
  6385. sd->fd = fd;
  6386. if (IS_PACKET_DB_VER(cmd)) {
  6387. 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])
  6388. pc_setnewpc(sd, account_id, RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[1]),
  6389. RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[2]),
  6390. RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[3]),
  6391. RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[4]), fd);
  6392. // 0x72
  6393. } else if (cmd == 0x72) {
  6394. if (RFIFOREST(fd) >= 39 && (RFIFOB(fd,38) == 0 || RFIFOB(fd,38) == 1)) { // 00 = Female, 01 = Male
  6395. 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])
  6396. pc_setnewpc(sd, account_id, RFIFOL(fd,22), RFIFOL(fd,30), RFIFOL(fd,34), RFIFOB(fd,38), fd);
  6397. } else if (RFIFOREST(fd) >= 22 && (RFIFOB(fd,21) == 0 || RFIFOB(fd,21) == 1)) { // 00 = Female, 01 = Male
  6398. 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])
  6399. pc_setnewpc(sd, account_id, RFIFOL(fd,9), RFIFOL(fd,13), RFIFOL(fd,17), RFIFOB(fd,21), fd);
  6400. } else { // old packet version
  6401. 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])
  6402. pc_setnewpc(sd, account_id, RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOB(fd,18), fd);
  6403. }
  6404. // 0x7E
  6405. } else if (cmd == 0x7E) {
  6406. if (RFIFOREST(fd) >= 37 && (RFIFOB(fd,36) == 0 || RFIFOB(fd,36) == 1)) { // 00 = Female, 01 = Male
  6407. 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])
  6408. pc_setnewpc(sd, account_id, RFIFOL(fd,21), RFIFOL(fd,28), RFIFOL(fd,32), RFIFOB(fd,36), fd);
  6409. } else {
  6410. 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])
  6411. pc_setnewpc(sd, account_id, RFIFOL(fd,18), RFIFOL(fd,24), RFIFOL(fd,28), RFIFOB(fd,32), fd);
  6412. }
  6413. // 0xF5
  6414. } else if (cmd == 0xF5) {
  6415. if (RFIFOREST(fd) >= 34 && (RFIFOB(fd,33) == 0 || RFIFOB(fd,33) == 1)) { // 00 = Female, 01 = Male
  6416. 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])
  6417. pc_setnewpc(sd, account_id, RFIFOL(fd,15), RFIFOL(fd,25), RFIFOL(fd,29), RFIFOB(fd,33), fd);
  6418. } else if (RFIFOREST(fd) >= 33 && (RFIFOB(fd,32) == 0 || RFIFOB(fd,32) == 1)) { // 00 = Female, 01 = Male
  6419. 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])
  6420. pc_setnewpc(sd, account_id, RFIFOL(fd,18), RFIFOL(fd,24), RFIFOL(fd,28), RFIFOB(fd,32), fd);
  6421. } else if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) { // 00 = Female, 01 = Male
  6422. 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])
  6423. pc_setnewpc(sd, account_id, RFIFOL(fd,17), RFIFOL(fd,23), RFIFOL(fd,27), RFIFOB(fd,31), fd);
  6424. } else { // 29
  6425. // if account id and char id of version 14
  6426. if (RFIFOL(fd,3) > 700000 && RFIFOL(fd,10) >= 150000 && RFIFOL(fd,10) < 5000000) { // account id / char id (more than 5.000.000 characters?)
  6427. 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])
  6428. pc_setnewpc(sd, account_id, RFIFOL(fd,10), RFIFOL(fd,20), RFIFOL(fd,24), RFIFOB(fd,28), fd);
  6429. } else {
  6430. 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])
  6431. pc_setnewpc(sd, account_id, RFIFOL(fd,14), RFIFOL(fd,20), RFIFOL(fd,24), RFIFOB(fd,28), fd);
  6432. }
  6433. }
  6434. // 0x9B
  6435. } else {
  6436. sd->packet_ver = 16; // 16: 10jan05
  6437. pc_setnewpc(sd, account_id, RFIFOL(fd,12), RFIFOL(fd,23), RFIFOL(fd,27), RFIFOB(fd,31), fd);
  6438. }
  6439. WFIFOL(fd,0) = sd->bl.id;
  6440. WFIFOSET(fd,4);
  6441. map_addiddb(&sd->bl);
  6442. chrif_authreq(sd);
  6443. }
  6444. return;
  6445. }
  6446. /*==========================================
  6447. * 007d クライアント側マップ読み込み完了
  6448. * map侵入時に必要なデータを全て送りつける
  6449. *------------------------------------------
  6450. */
  6451. void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
  6452. {
  6453. // struct item_data* item;
  6454. int i;
  6455. nullpo_retv(sd);
  6456. if(sd->bl.prev != NULL)
  6457. return;
  6458. // 接続ok時
  6459. //clif_authok();
  6460. if(sd->npc_id) npc_event_dequeue(sd);
  6461. clif_skillinfoblock(sd);
  6462. pc_checkitem(sd);
  6463. //guild_info();
  6464. // loadendack時
  6465. // next exp
  6466. clif_updatestatus(sd,SP_NEXTBASEEXP);
  6467. clif_updatestatus(sd,SP_NEXTJOBEXP);
  6468. // skill point
  6469. clif_updatestatus(sd,SP_SKILLPOINT);
  6470. // item
  6471. clif_itemlist(sd);
  6472. clif_equiplist(sd);
  6473. // cart
  6474. if(pc_iscarton(sd)){
  6475. clif_cart_itemlist(sd);
  6476. clif_cart_equiplist(sd);
  6477. clif_updatestatus(sd,SP_CARTINFO);
  6478. }
  6479. // param all
  6480. clif_initialstatus(sd);
  6481. // party
  6482. party_send_movemap(sd);
  6483. // guild
  6484. guild_send_memberinfoshort(sd,1);
  6485. // 119
  6486. // 78
  6487. if(battle_config.pc_invincible_time > 0) {
  6488. if(map[sd->bl.m].flag.gvg)
  6489. pc_setinvincibletimer(sd,battle_config.pc_invincible_time<<1);
  6490. else
  6491. pc_setinvincibletimer(sd,battle_config.pc_invincible_time);
  6492. }
  6493. map_addblock(&sd->bl); // ブロック登録
  6494. clif_spawnpc(sd); // spawn
  6495. // weight max , now
  6496. clif_updatestatus(sd,SP_MAXWEIGHT);
  6497. clif_updatestatus(sd,SP_WEIGHT);
  6498. // pvp
  6499. if(sd->pvp_timer!=-1 && !battle_config.pk_mode)
  6500. delete_timer(sd->pvp_timer,pc_calc_pvprank_timer);
  6501. if(map[sd->bl.m].flag.pvp){
  6502. if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris]
  6503. sd->pvp_timer=add_timer(gettick()+200,pc_calc_pvprank_timer,sd->bl.id,0);
  6504. sd->pvp_rank=0;
  6505. sd->pvp_lastusers=0;
  6506. sd->pvp_point=5;
  6507. }
  6508. clif_set0199(sd->fd,1);
  6509. } else {
  6510. sd->pvp_timer=-1;
  6511. }
  6512. if(map[sd->bl.m].flag.gvg) {
  6513. clif_set0199(sd->fd,3);
  6514. }
  6515. // pet
  6516. if(sd->status.pet_id > 0 && sd->pd && sd->pet.intimate > 0) {
  6517. map_addblock(&sd->pd->bl);
  6518. clif_spawnpet(sd->pd);
  6519. clif_send_petdata(sd,0,0);
  6520. clif_send_petdata(sd,5,0x14);
  6521. clif_send_petstatus(sd);
  6522. }
  6523. if(sd->state.connect_new) {
  6524. sd->state.connect_new = 0;
  6525. if(sd->status.class_ != sd->view_class)
  6526. clif_changelook(&sd->bl,LOOK_BASE,sd->view_class);
  6527. if(sd->status.pet_id > 0 && sd->pd && sd->pet.intimate > 900)
  6528. clif_pet_emotion(sd->pd,(sd->pd->class_ - 100)*100 + 50 + pet_hungry_val(sd));
  6529. /* Stop players from spawning inside castles [Valaris] */
  6530. {
  6531. struct guild_castle *gc=guild_mapname2gc(map[sd->bl.m].name);
  6532. if (gc)
  6533. pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,2);
  6534. }
  6535. /* End Addition [Valaris] */
  6536. }
  6537. // view equipment item
  6538. #if PACKETVER < 4
  6539. clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
  6540. clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
  6541. #else
  6542. clif_changelook(&sd->bl,LOOK_WEAPON,0);
  6543. #endif
  6544. if(battle_config.save_clothcolor==1 && sd->status.clothes_color > 0)
  6545. clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->status.clothes_color);
  6546. if(sd->status.hp<sd->status.max_hp>>2 && pc_checkskill(sd,SM_AUTOBERSERK)>0 &&
  6547. (sd->sc_data[SC_PROVOKE].timer==-1 || sd->sc_data[SC_PROVOKE].val2==0 ))
  6548. // オートバーサーク発動
  6549. status_change_start(&sd->bl,SC_PROVOKE,10,1,0,0,0,0);
  6550. // if(time(&timer) < ((weddingtime=pc_readglobalreg(sd,"PC_WEDDING_TIME")) + 3600))
  6551. // status_change_start(&sd->bl,SC_WEDDING,0,weddingtime,0,0,36000,0);
  6552. if(battle_config.muting_players && sd->status.manner < 0)
  6553. status_change_start(&sd->bl,SC_NOCHAT,0,0,0,0,0,0);
  6554. if (night_flag) {
  6555. if (battle_config.night_darkness_level > 0 && !map[sd->bl.m].flag.indoors)
  6556. clif_specialeffect(&sd->bl, 474 + battle_config.night_darkness_level, 0);
  6557. else {
  6558. //clif_specialeffect(&sd->bl, 483, 0); // default darkness level
  6559. // night - when changing from indoors to outdoors - celest
  6560. if (!map[sd->bl.m].flag.indoors && sd->opt2 != STATE_BLIND)
  6561. sd->opt2 |= STATE_BLIND;
  6562. // changing from outdoors to indoors
  6563. else if (map[sd->bl.m].flag.indoors && sd->opt2 == STATE_BLIND)
  6564. sd->opt2 &= ~STATE_BLIND;
  6565. }
  6566. }
  6567. // option
  6568. clif_changeoption(&sd->bl);
  6569. if(sd->sc_data[SC_TRICKDEAD].timer != -1)
  6570. status_change_end(&sd->bl,SC_TRICKDEAD,-1);
  6571. if(sd->sc_data[SC_SIGNUMCRUCIS].timer != -1 && !battle_check_undead(7,sd->def_ele))
  6572. status_change_end(&sd->bl,SC_SIGNUMCRUCIS,-1);
  6573. if(sd->special_state.infinite_endure && sd->sc_data[SC_ENDURE].timer == -1)
  6574. status_change_start(&sd->bl,SC_ENDURE,10,1,0,0,0,0);
  6575. for(i=0;i<MAX_INVENTORY;i++){
  6576. if(sd->status.inventory[i].equip && sd->status.inventory[i].equip & 0x0002 && sd->status.inventory[i].attribute==1)
  6577. status_change_start(&sd->bl,SC_BROKNWEAPON,0,0,0,0,0,0);
  6578. if(sd->status.inventory[i].equip && sd->status.inventory[i].equip & 0x0010 && sd->status.inventory[i].attribute==1)
  6579. status_change_start(&sd->bl,SC_BROKNARMOR,0,0,0,0,0,0);
  6580. }
  6581. 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);
  6582. }
  6583. /*==========================================
  6584. *
  6585. *------------------------------------------
  6586. */
  6587. void clif_parse_TickSend(int fd, struct map_session_data *sd) {
  6588. nullpo_retv(sd);
  6589. if (USE_PACKET_DB(sd)) {
  6590. sd->client_tick=RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  6591. } else {
  6592. 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])
  6593. case 8:
  6594. sd->client_tick = RFIFOL(fd,6);
  6595. break;
  6596. case 9:
  6597. sd->client_tick = RFIFOL(fd,9);
  6598. break;
  6599. case 10:
  6600. sd->client_tick = RFIFOL(fd,7);
  6601. break;
  6602. case 11:
  6603. sd->client_tick = RFIFOL(fd,10);
  6604. break;
  6605. case 12:
  6606. sd->client_tick = RFIFOL(fd,6);
  6607. break;
  6608. case 13:
  6609. case 14:
  6610. sd->client_tick = RFIFOL(fd,5);
  6611. break;
  6612. case 15:
  6613. sd->client_tick = RFIFOL(fd,3);
  6614. break;
  6615. case 16:
  6616. sd->client_tick = RFIFOL(fd,5);
  6617. break;
  6618. default: // old version by default (and version 6 + 7)
  6619. sd->client_tick = RFIFOL(fd,2);
  6620. break;
  6621. }
  6622. }
  6623. sd->server_tick = gettick();
  6624. clif_servertick(sd);
  6625. }
  6626. /*==========================================
  6627. *
  6628. *------------------------------------------
  6629. */
  6630. void clif_parse_WalkToXY(int fd, struct map_session_data *sd) {
  6631. int x, y;
  6632. nullpo_retv(sd);
  6633. if (pc_isdead(sd)) {
  6634. clif_clearchar_area(&sd->bl, 1);
  6635. return;
  6636. }
  6637. if (sd->npc_id != 0 || sd->vender_id != 0)
  6638. return;
  6639. if (sd->skilltimer != -1 && pc_checkskill(sd, SA_FREECAST) <= 0) // フリーキャスト
  6640. return;
  6641. if (sd->chatID)
  6642. return;
  6643. if (sd->canmove_tick > gettick())
  6644. return;
  6645. // ステータス異常やハイディング中(トンネルドライブ無)で動けない
  6646. if ((sd->opt1 > 0 && sd->opt1 != 6) ||
  6647. sd->sc_data[SC_ANKLE].timer !=-1 || //アンクルスネア
  6648. sd->sc_data[SC_AUTOCOUNTER].timer !=-1 || //オートカウンター
  6649. sd->sc_data[SC_TRICKDEAD].timer !=-1 || //死んだふり
  6650. sd->sc_data[SC_BLADESTOP].timer !=-1 || //白刃取り
  6651. sd->sc_data[SC_SPIDERWEB].timer !=-1 || //スパイダーウェッブ
  6652. (sd->sc_data[SC_DANCING].timer !=-1 && sd->sc_data[SC_DANCING].val4) || //合奏スキル演奏中は動けない
  6653. (sd->sc_data[SC_GOSPEL].timer !=-1 && sd->sc_data[SC_GOSPEL].val4 == BCT_SELF) || // cannot move while gospel is in effect
  6654. sd->sc_data[SC_CONFUSION].timer !=-1)
  6655. return;
  6656. if ((sd->status.option & 2) && pc_checkskill(sd, RG_TUNNELDRIVE) <= 0)
  6657. return;
  6658. if (sd->invincible_timer != -1)
  6659. pc_delinvincibletimer(sd);
  6660. pc_stopattack(sd);
  6661. if (USE_PACKET_DB(sd)) {
  6662. int cmd = RFIFOW(fd,0);
  6663. x = RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0]) * 4 +
  6664. (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0] + 1) >> 6);
  6665. y = ((RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0]+1) & 0x3f) << 4) +
  6666. (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0] + 2) >> 4);
  6667. } else {
  6668. 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])
  6669. case 6:
  6670. x = RFIFOB(fd,5) * 4 + (RFIFOB(fd,6) >> 6);
  6671. y = ((RFIFOB(fd,6) & 0x3f) << 4) + (RFIFOB(fd,7) >> 4);
  6672. break;
  6673. case 7:
  6674. x = RFIFOB(fd,6) * 4 + (RFIFOB(fd,7) >> 6);
  6675. y = ((RFIFOB(fd,7) & 0x3f) << 4) + (RFIFOB(fd,8) >> 4);
  6676. break;
  6677. case 8:
  6678. x = RFIFOB(fd,3) * 4 + (RFIFOB(fd,4) >> 6);
  6679. y = ((RFIFOB(fd,4) & 0x3f) << 4) + (RFIFOB(fd,5) >> 4);
  6680. break;
  6681. case 9:
  6682. x = RFIFOB(fd,12) * 4 + (RFIFOB(fd,13) >> 6);
  6683. y = ((RFIFOB(fd,13) & 0x3f) << 4) + (RFIFOB(fd,14) >> 4);
  6684. break;
  6685. case 10:
  6686. x = RFIFOB(fd,6) * 4 + (RFIFOB(fd,7) >> 6);
  6687. y = ((RFIFOB(fd,7) & 0x3f) << 4) + (RFIFOB(fd,8) >> 4);
  6688. break;
  6689. case 11:
  6690. x = RFIFOB(fd,11) * 4 + (RFIFOB(fd,12) >> 6);
  6691. y = ((RFIFOB(fd,12) & 0x3f) << 4) + (RFIFOB(fd,13) >> 4);
  6692. break;
  6693. case 12:
  6694. x = RFIFOB(fd,3) * 4 + (RFIFOB(fd,4) >> 6);
  6695. y = ((RFIFOB(fd,4) & 0x3f) << 4) + (RFIFOB(fd,5) >> 4);
  6696. break;
  6697. case 13:
  6698. case 14:
  6699. x = RFIFOB(fd,3) * 4 + (RFIFOB(fd,4) >> 6);
  6700. y = ((RFIFOB(fd,4) & 0x3f) << 4) + (RFIFOB(fd,5) >> 4);
  6701. break;
  6702. case 15:
  6703. x = RFIFOB(fd,4) * 4 + (RFIFOB(fd,5) >> 6);
  6704. y = ((RFIFOB(fd,5) & 0x3f) << 4) + (RFIFOB(fd,6) >> 4);
  6705. break;
  6706. case 16:
  6707. x = RFIFOB(fd,10) * 4 + (RFIFOB(fd,11) >> 6);
  6708. y = ((RFIFOB(fd,11) & 0x3f) << 4) + (RFIFOB(fd,12) >> 4);
  6709. break;
  6710. default: // old version by default
  6711. x = RFIFOB(fd,2) * 4 + (RFIFOB(fd,3) >> 6);
  6712. y = ((RFIFOB(fd,3) & 0x3f) << 4) + (RFIFOB(fd,4) >> 4);
  6713. break;
  6714. }
  6715. }
  6716. pc_walktoxy(sd, x, y);
  6717. }
  6718. /*==========================================
  6719. *
  6720. *------------------------------------------
  6721. */
  6722. void clif_parse_QuitGame(int fd, struct map_session_data *sd) {
  6723. unsigned int tick=gettick();
  6724. struct skill_unit_group* sg;
  6725. nullpo_retv(sd);
  6726. WFIFOW(fd,0) = 0x18b;
  6727. if ((!pc_isdead(sd) && (sd->opt1 || (sd->opt2 && !(night_flag == 1 && sd->opt2 == STATE_BLIND)))) ||
  6728. sd->skilltimer != -1 ||
  6729. (DIFF_TICK(tick, sd->canact_tick) < 0) ||
  6730. (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)) {
  6731. WFIFOW(fd,2)=1;
  6732. WFIFOSET(fd,packet_len_table[0x18b]);
  6733. return;
  6734. }
  6735. /* Rovert's prevent logout option fixed [Valaris] */
  6736. if ((battle_config.prevent_logout && (gettick() - sd->canlog_tick) >= 10000) || (!battle_config.prevent_logout)) {
  6737. clif_setwaitclose(fd);
  6738. WFIFOW(fd,2)=0;
  6739. } else {
  6740. WFIFOW(fd,2)=1;
  6741. }
  6742. WFIFOSET(fd,packet_len_table[0x18b]);
  6743. }
  6744. /*==========================================
  6745. *
  6746. *------------------------------------------
  6747. */
  6748. void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) {
  6749. struct block_list *bl;
  6750. int account_id;
  6751. if (USE_PACKET_DB(sd)) {
  6752. account_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  6753. } else {
  6754. 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])
  6755. case 8:
  6756. account_id = RFIFOL(fd,11);
  6757. break;
  6758. case 9:
  6759. account_id = RFIFOL(fd,8);
  6760. break;
  6761. case 10:
  6762. account_id = RFIFOL(fd,10);
  6763. break;
  6764. case 11:
  6765. account_id = RFIFOL(fd,6);
  6766. break;
  6767. case 12:
  6768. account_id = RFIFOL(fd,11);
  6769. break;
  6770. case 13:
  6771. case 14:
  6772. account_id = RFIFOL(fd,6);
  6773. break;
  6774. case 15:
  6775. account_id = RFIFOL(fd,9);
  6776. break;
  6777. case 16:
  6778. account_id = RFIFOL(fd,4);
  6779. break;
  6780. default: // old version by default (+ packet version 6 and 7)
  6781. account_id = RFIFOL(fd,2);
  6782. break;
  6783. }
  6784. }
  6785. bl = map_id2bl(account_id);
  6786. if (bl == NULL)
  6787. return;
  6788. WFIFOW(fd,0) = 0x95;
  6789. WFIFOL(fd,2) = account_id;
  6790. switch(bl->type) {
  6791. case BL_PC:
  6792. {
  6793. struct map_session_data *ssd = (struct map_session_data *)bl;
  6794. struct party *p = NULL;
  6795. struct guild *g = NULL;
  6796. nullpo_retv(ssd);
  6797. memcpy(WFIFOP(fd,6), ssd->status.name, 24);
  6798. if (ssd->status.guild_id > 0 && (g = guild_search(ssd->status.guild_id)) != NULL &&
  6799. (ssd->status.party_id == 0 || (p = party_search(ssd->status.party_id)) != NULL)) {
  6800. // ギルド所属ならパケット0195を返す
  6801. int i, ps = -1;
  6802. for(i = 0; i < g->max_member; i++) {
  6803. if (g->member[i].account_id == ssd->status.account_id &&
  6804. g->member[i].char_id == ssd->status.char_id )
  6805. ps = g->member[i].position;
  6806. }
  6807. if (ps >= 0 && ps < MAX_GUILDPOSITION) {
  6808. WFIFOW(fd, 0) = 0x195;
  6809. if (p)
  6810. memcpy(WFIFOP(fd,30), p->name, 24);
  6811. else
  6812. WFIFOB(fd,30) = 0;
  6813. memcpy(WFIFOP(fd,54), g->name,24);
  6814. memcpy(WFIFOP(fd,78), g->position[ps].name, 24);
  6815. WFIFOSET(fd,packet_len_table[0x195]);
  6816. break;
  6817. }
  6818. }
  6819. WFIFOSET(fd,packet_len_table[0x95]);
  6820. }
  6821. break;
  6822. case BL_PET:
  6823. memcpy(WFIFOP(fd,6), ((struct pet_data*)bl)->name, 24);
  6824. WFIFOSET(fd,packet_len_table[0x95]);
  6825. break;
  6826. case BL_NPC:
  6827. memcpy(WFIFOP(fd,6), ((struct npc_data*)bl)->name, 24);
  6828. WFIFOSET(fd,packet_len_table[0x95]);
  6829. break;
  6830. case BL_MOB:
  6831. {
  6832. struct mob_data *md = (struct mob_data *)bl;
  6833. nullpo_retv(md);
  6834. memcpy(WFIFOP(fd,6), md->name, 24);
  6835. if (md->class_ >= 1285 && md->class_ <= 1288 && md->guild_id) {
  6836. struct guild *g;
  6837. struct guild_castle *gc = guild_mapname2gc(map[md->bl.m].name);
  6838. if (gc && gc->guild_id > 0 && (g = guild_search(gc->guild_id)) != NULL) {
  6839. WFIFOW(fd, 0) = 0x195;
  6840. WFIFOB(fd,30) = 0;
  6841. memcpy(WFIFOP(fd,54), g->name, 24);
  6842. memcpy(WFIFOP(fd,78), gc->castle_name, 24);
  6843. WFIFOSET(fd,packet_len_table[0x195]);
  6844. } else {
  6845. WFIFOSET(fd,packet_len_table[0x95]);
  6846. }
  6847. } else if (battle_config.show_mob_hp == 1) {
  6848. char mobhp[50];
  6849. sprintf(mobhp, "hp: %d/%d", md->hp, mob_db[md->class_].max_hp);
  6850. WFIFOW(fd, 0) = 0x195;
  6851. memcpy(WFIFOP(fd,30), mobhp, 24);
  6852. WFIFOB(fd,54) = 0;
  6853. WFIFOB(fd,78) = 0;
  6854. WFIFOSET(fd,packet_len_table[0x195]);
  6855. } else {
  6856. WFIFOSET(fd,packet_len_table[0x95]);
  6857. }
  6858. }
  6859. break;
  6860. default:
  6861. if (battle_config.error_log)
  6862. printf("clif_parse_GetCharNameRequest : bad type %d(%d)\n", bl->type, account_id);
  6863. break;
  6864. }
  6865. }
  6866. /*==========================================
  6867. *
  6868. *------------------------------------------
  6869. */
  6870. void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c <len>.w <str>.?B
  6871. char *message;
  6872. unsigned char *buf;
  6873. nullpo_retv(sd);
  6874. if ((is_atcommand(fd, sd, (char*)RFIFOP(fd,4), 0) != AtCommand_None) ||
  6875. (is_charcommand(fd, sd, (char*)RFIFOP(fd,4),0)!= CharCommand_None) ||
  6876. (sd->sc_data &&
  6877. (sd->sc_data[SC_BERSERK].timer != -1 || //バーサーク時は会話も不可
  6878. sd->sc_data[SC_NOCHAT].timer != -1 ))) //チャット禁止
  6879. return;
  6880. message = (char*)aCallocA(RFIFOW(fd,2) + 128, sizeof(char));
  6881. buf = (unsigned char*)aCallocA(RFIFOW(fd,2) + 4, sizeof(char));
  6882. //printf("clif_parse_GlobalMessage: message: '%s'.\n", RFIFOP(fd,4));
  6883. if (strncmp((char*)RFIFOP(fd,4), sd->status.name, strlen(sd->status.name)) != 0) {
  6884. 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);
  6885. // information is sended to all online GM
  6886. sprintf(message, "Hack on global message (normal message): character '%s' (account: %d) uses another name.", sd->status.name, sd->status.account_id);
  6887. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message);
  6888. if (strlen((char*)RFIFOP(fd,4)) == 0)
  6889. strcpy(message, " This player sends a void name and a void message.");
  6890. else
  6891. sprintf(message, " This player sends (name:message): '%s'.", RFIFOP(fd,4));
  6892. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message);
  6893. // message about the ban
  6894. if (battle_config.ban_spoof_namer > 0)
  6895. sprintf(message, " This player has been banned for %d minute(s).", battle_config.ban_spoof_namer);
  6896. else
  6897. sprintf(message, " This player hasn't been banned (Ban option is disabled).");
  6898. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message);
  6899. // if we ban people
  6900. if (battle_config.ban_spoof_namer > 0) {
  6901. 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)
  6902. clif_setwaitclose(fd); // forced to disconnect because of the hack
  6903. if(message) aFree(message);
  6904. if(buf) aFree(buf);
  6905. return;
  6906. }
  6907. // but for the hacker, we display on his screen (he see/look no difference).
  6908. } else {
  6909. // send message to others
  6910. WBUFW(buf,0) = 0x8d;
  6911. WBUFW(buf,2) = RFIFOW(fd,2) + 4; // len of message - 4 + 8
  6912. WBUFL(buf,4) = sd->bl.id;
  6913. memcpy(WBUFP(buf,8), RFIFOP(fd,4), RFIFOW(fd,2) - 4);
  6914. clif_send(buf, WBUFW(buf,2), &sd->bl, sd->chatID ? CHAT_WOS : AREA_CHAT_WOC);
  6915. }
  6916. // send back message to the speaker
  6917. memcpy(WFIFOP(fd,0), RFIFOP(fd,0), RFIFOW(fd,2));
  6918. WFIFOW(fd,0) = 0x8e;
  6919. WFIFOSET(fd, WFIFOW(fd,2));
  6920. #ifdef PCRE_SUPPORT
  6921. map_foreachinarea(npc_chat_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_NPC, RFIFOP(fd,4), strlen(RFIFOP(fd,4)), &sd->bl);
  6922. #endif
  6923. // Celest
  6924. if (pc_calc_base_job2 (sd->status.class_) == 23 ) {
  6925. int next = pc_nextbaseexp(sd)>0 ? pc_nextbaseexp(sd) : sd->status.base_exp;
  6926. if (next > 0 && (sd->status.base_exp*100/next)%10 == 0) {
  6927. estr_lower((char*)RFIFOP(fd,4));
  6928. if (sd->state.snovice_flag == 0 && strstr((char*)RFIFOP(fd,4), msg_txt(504)))
  6929. sd->state.snovice_flag = 1;
  6930. else if (sd->state.snovice_flag == 1) {
  6931. sprintf(message, msg_txt(505), sd->status.name);
  6932. estr_lower(message);
  6933. if (strstr((char*)RFIFOP(fd,4), message))
  6934. sd->state.snovice_flag = 2;
  6935. }
  6936. else if (sd->state.snovice_flag == 2 && strstr((char*)RFIFOP(fd,4), msg_txt(506)))
  6937. sd->state.snovice_flag = 3;
  6938. else if (sd->state.snovice_flag == 3) {
  6939. int i;
  6940. status_change_start(&sd->bl,SkillStatusChangeTable[MO_EXPLOSIONSPIRITS],1,0,0,0,skill_get_time(MO_EXPLOSIONSPIRITS,1),0 );
  6941. for(i=0;i<5;i++)
  6942. pc_addspiritball(sd,skill_get_time(MO_CALLSPIRITS,1),5);
  6943. sd->state.snovice_flag = 0;
  6944. }
  6945. }
  6946. }
  6947. if(message) aFree(message);
  6948. if(buf) aFree(buf);
  6949. return;
  6950. }
  6951. int clif_message(struct block_list *bl, char* msg)
  6952. {
  6953. unsigned short msg_len = strlen(msg) + 1;
  6954. unsigned char buf[256];
  6955. nullpo_retr(0, bl);
  6956. WBUFW(buf, 0) = 0x8d;
  6957. WBUFW(buf, 2) = msg_len + 8;
  6958. WBUFL(buf, 4) = bl->id;
  6959. memcpy(WBUFP(buf, 8), msg, msg_len);
  6960. clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC); // by Gengar
  6961. return 0;
  6962. }
  6963. /*==========================================
  6964. *
  6965. *------------------------------------------
  6966. */
  6967. void clif_parse_MapMove(int fd, struct map_session_data *sd) {
  6968. // /m /mapmove (as @rura GM command)
  6969. char output[30]; // 17+4+4=26, 30 max.
  6970. char map_name[17];
  6971. nullpo_retv(sd);
  6972. // not needed at all as far as sprintf is used // [Ilpalazzo-sama]
  6973. // memset(output, '\0', sizeof(output));
  6974. // not needed -- map_name[16]='\0'; will do
  6975. // memset(map_name, '\0', sizeof(map_name));
  6976. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  6977. (pc_isGM(sd) >= get_atcommand_level(AtCommand_MapMove))) {
  6978. memcpy(map_name, RFIFOP(fd,2), 16);
  6979. map_name[16]='\0';
  6980. sprintf(output, "%s %d %d", map_name, RFIFOW(fd,18), RFIFOW(fd,20));
  6981. atcommand_rura(fd, sd, "@rura", output);
  6982. }
  6983. return;
  6984. }
  6985. /*==========================================
  6986. *
  6987. *------------------------------------------
  6988. */
  6989. void clif_changed_dir(struct block_list *bl) {
  6990. unsigned char buf[64];
  6991. struct map_session_data *sd = NULL;
  6992. if (bl->type == BL_PC)
  6993. nullpo_retv (sd=(struct map_session_data *)bl);
  6994. WBUFW(buf,0) = 0x9c;
  6995. WBUFL(buf,2) = bl->id;
  6996. if (sd)
  6997. WBUFW(buf,6) = sd->head_dir;
  6998. WBUFB(buf,8) = status_get_dir(bl);
  6999. if (sd && sd->disguise > 23 && sd->disguise < 4001) // mob disguises [Valaris]
  7000. clif_send(buf, packet_len_table[0x9c], &sd->bl, AREA);
  7001. else
  7002. clif_send(buf, packet_len_table[0x9c], bl, AREA_WOS);
  7003. return;
  7004. }
  7005. /*==========================================
  7006. *
  7007. *------------------------------------------
  7008. */
  7009. void clif_parse_ChangeDir(int fd, struct map_session_data *sd) {
  7010. short headdir, dir;
  7011. nullpo_retv(sd);
  7012. if (USE_PACKET_DB(sd)) {
  7013. headdir = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  7014. dir = RFIFOB(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  7015. } else {
  7016. 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])
  7017. case 7:
  7018. headdir = RFIFOW(fd,5);
  7019. dir = RFIFOB(fd,12);
  7020. break;
  7021. case 8:
  7022. headdir = RFIFOW(fd,5);
  7023. dir = RFIFOB(fd,12);
  7024. break;
  7025. case 9:
  7026. headdir = RFIFOW(fd,7);
  7027. dir = RFIFOB(fd,11);
  7028. break;
  7029. case 10:
  7030. headdir = RFIFOW(fd,4);
  7031. dir = RFIFOB(fd,9);
  7032. break;
  7033. case 11:
  7034. headdir = RFIFOW(fd,8);
  7035. dir = RFIFOB(fd,17);
  7036. break;
  7037. case 12:
  7038. headdir = RFIFOW(fd,5);
  7039. dir = RFIFOB(fd,12);
  7040. break;
  7041. case 13:
  7042. case 14:
  7043. headdir = RFIFOW(fd,6);
  7044. dir = RFIFOB(fd,14);
  7045. break;
  7046. case 15:
  7047. headdir = RFIFOW(fd,3);
  7048. dir = RFIFOB(fd,7);
  7049. break;
  7050. case 16:
  7051. headdir = RFIFOW(fd,12);
  7052. dir = RFIFOB(fd,22);
  7053. break;
  7054. default: // old version by default (and packet version 6)
  7055. headdir = RFIFOW(fd,2);
  7056. dir = RFIFOB(fd,4);
  7057. break;
  7058. }
  7059. }
  7060. pc_setdir(sd, dir, headdir);
  7061. clif_changed_dir(&sd->bl);
  7062. return;
  7063. }
  7064. /*==========================================
  7065. *
  7066. *------------------------------------------
  7067. */
  7068. void clif_parse_Emotion(int fd, struct map_session_data *sd) {
  7069. unsigned char buf[64];
  7070. nullpo_retv(sd);
  7071. if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, NV_BASIC) >= 2) {
  7072. if (RFIFOB(fd,2) == 34) {// prevent use of the mute emote [Valaris]
  7073. clif_skill_fail(sd, 1, 0, 1);
  7074. return;
  7075. }
  7076. // fix flood of emotion icon (ro-proxy): flood only the hacker player
  7077. if (sd->emotionlasttime >= time(NULL)) {
  7078. sd->emotionlasttime = time(NULL) + 2; // not more than 1 every 2 seconds (normal client is every 3-4 seconds)
  7079. clif_skill_fail(sd, 1, 0, 1);
  7080. return;
  7081. }
  7082. sd->emotionlasttime = time(NULL) + 2; // not more than 1 every 2 seconds (normal client is every 3-4 seconds)
  7083. WBUFW(buf,0) = 0xc0;
  7084. WBUFL(buf,2) = sd->bl.id;
  7085. WBUFB(buf,6) = RFIFOB(fd,2);
  7086. clif_send(buf, packet_len_table[0xc0], &sd->bl, AREA);
  7087. } else
  7088. clif_skill_fail(sd, 1, 0, 1);
  7089. }
  7090. /*==========================================
  7091. *
  7092. *------------------------------------------
  7093. */
  7094. void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) {
  7095. WFIFOW(fd,0) = 0xc2;
  7096. WFIFOL(fd,2) = map_getusers();
  7097. WFIFOSET(fd,packet_len_table[0xc2]);
  7098. }
  7099. /*==========================================
  7100. *
  7101. *------------------------------------------
  7102. */
  7103. void clif_parse_ActionRequest(int fd, struct map_session_data *sd) {
  7104. unsigned int tick;
  7105. unsigned char buf[64];
  7106. int action_type, target_id;
  7107. nullpo_retv(sd);
  7108. if (pc_isdead(sd)) {
  7109. clif_clearchar_area(&sd->bl, 1);
  7110. return;
  7111. }
  7112. if (sd->npc_id != 0 || sd->opt1 > 0 || sd->status.option & 2 ||
  7113. (sd->sc_data &&
  7114. (sd->sc_data[SC_TRICKDEAD].timer != -1 ||
  7115. sd->sc_data[SC_AUTOCOUNTER].timer != -1 || //オートカウンター
  7116. sd->sc_data[SC_BLADESTOP].timer != -1 || //白刃取り
  7117. sd->sc_data[SC_DANCING].timer != -1))) //ダンス中
  7118. return;
  7119. tick = gettick();
  7120. pc_stop_walking(sd, 0);
  7121. pc_stopattack(sd);
  7122. if (USE_PACKET_DB(sd)) {
  7123. target_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  7124. action_type = RFIFOB(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  7125. } else {
  7126. 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])
  7127. case 8:
  7128. target_id = RFIFOL(fd,3);
  7129. action_type = RFIFOB(fd,8);
  7130. break;
  7131. case 9:
  7132. target_id = RFIFOL(fd,7);
  7133. action_type = RFIFOB(fd,17);
  7134. break;
  7135. case 10:
  7136. target_id = RFIFOL(fd,9);
  7137. action_type = RFIFOB(fd,22);
  7138. break;
  7139. case 11:
  7140. target_id = RFIFOL(fd,3);
  7141. action_type = RFIFOB(fd,8);
  7142. break;
  7143. case 12:
  7144. target_id = RFIFOL(fd,3);
  7145. action_type = RFIFOB(fd,8);
  7146. break;
  7147. case 13:
  7148. case 14:
  7149. target_id = RFIFOL(fd,4);
  7150. action_type = RFIFOB(fd,14);
  7151. break;
  7152. case 15:
  7153. target_id = RFIFOL(fd,6);
  7154. action_type = RFIFOB(fd,17);
  7155. break;
  7156. case 16:
  7157. target_id = RFIFOL(fd,9);
  7158. action_type = RFIFOB(fd,19);
  7159. break;
  7160. default: // old version by default (and packet version 6 and 7)
  7161. target_id = RFIFOL(fd,2);
  7162. action_type = RFIFOB(fd,6);
  7163. break;
  7164. }
  7165. }
  7166. switch(action_type) {
  7167. case 0x00: // once attack
  7168. case 0x07: // continuous attack
  7169. if(sd->sc_data[SC_WEDDING].timer != -1 || sd->view_class==22)
  7170. return;
  7171. if (sd->vender_id != 0)
  7172. return;
  7173. if (!battle_config.sdelay_attack_enable && pc_checkskill(sd, SA_FREECAST) <= 0) {
  7174. if (DIFF_TICK(tick, sd->canact_tick) < 0) {
  7175. clif_skill_fail(sd, 1, 4, 0);
  7176. return;
  7177. }
  7178. }
  7179. if (sd->invincible_timer != -1)
  7180. pc_delinvincibletimer(sd);
  7181. if (sd->attacktarget > 0) // [Valaris]
  7182. sd->attacktarget = 0;
  7183. pc_attack(sd, target_id, action_type != 0);
  7184. break;
  7185. case 0x02: // sitdown
  7186. if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, NV_BASIC) >= 3) {
  7187. pc_stop_walking(sd, 1);
  7188. pc_setsit(sd);
  7189. skill_gangsterparadise(sd, 1); // ギャングスターパラダイス設定 fixed Valaris
  7190. clif_sitting(sd);
  7191. } else
  7192. clif_skill_fail(sd, 1, 0, 2);
  7193. break;
  7194. case 0x03: // standup
  7195. pc_setstand(sd);
  7196. skill_gangsterparadise(sd, 0); // ギャングスターパラダイス解除 fixed Valaris
  7197. WBUFW(buf, 0) = 0x8a;
  7198. WBUFL(buf, 2) = sd->bl.id;
  7199. WBUFB(buf,26) = 3;
  7200. clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
  7201. break;
  7202. }
  7203. }
  7204. /*==========================================
  7205. *
  7206. *------------------------------------------
  7207. */
  7208. void clif_parse_Restart(int fd, struct map_session_data *sd) {
  7209. nullpo_retv(sd);
  7210. switch(RFIFOB(fd,2)) {
  7211. case 0x00:
  7212. if (pc_isdead(sd)) {
  7213. pc_setstand(sd);
  7214. pc_setrestartvalue(sd, 3);
  7215. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 2);
  7216. }
  7217. // in case the player's status somehow wasn't updated yet [Celest]
  7218. else if (sd->status.hp <= 0)
  7219. pc_setdead(sd);
  7220. break;
  7221. case 0x01:
  7222. if(!pc_isdead(sd) && (sd->opt1 || (sd->opt2 && !(night_flag == 1 && sd->opt2 == STATE_BLIND))))
  7223. return;
  7224. /* Rovert's Prevent logout option - Fixed [Valaris] */
  7225. if ((battle_config.prevent_logout && (gettick() - sd->canlog_tick) >= 10000) || (!battle_config.prevent_logout)) {
  7226. chrif_charselectreq(sd);
  7227. } else {
  7228. WFIFOW(fd,0)=0x18b;
  7229. WFIFOW(fd,2)=1;
  7230. WFIFOSET(fd,packet_len_table[0x018b]);
  7231. }
  7232. break;
  7233. }
  7234. }
  7235. /*==========================================
  7236. * Transmission of a wisp (S 0096 <len>.w <nick>.24B <message>.?B)
  7237. *------------------------------------------
  7238. */
  7239. void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 <len>.w <nick>.24B <message>.?B // rewritten by [Yor]
  7240. char *gm_command;
  7241. struct map_session_data *dstsd;
  7242. int i;
  7243. //printf("clif_parse_Wis: message: '%s'.\n", RFIFOP(fd,28));
  7244. 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)
  7245. sprintf(gm_command, "%s : %s", sd->status.name, RFIFOP(fd,28));
  7246. if ((is_charcommand(fd, sd, gm_command, 0) != CharCommand_None) ||
  7247. (is_atcommand(fd, sd, gm_command, 0) != AtCommand_None) ||
  7248. (sd && sd->sc_data &&
  7249. (sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク時は会話も不可
  7250. sd->sc_data[SC_NOCHAT].timer != -1))) //チャット禁止
  7251. {
  7252. if(gm_command) aFree(gm_command);
  7253. return;
  7254. }
  7255. if(gm_command) aFree(gm_command);
  7256. // searching destination character
  7257. dstsd = map_nick2sd((char*)RFIFOP(fd,4));
  7258. // player is not on this map-server
  7259. if (dstsd == NULL ||
  7260. // At this point, don't send wisp/page if it's not exactly the same name, because (example)
  7261. // if there are 'Test' player on an other map-server and 'test' player on this map-server,
  7262. // and if we ask for 'Test', we must not contact 'test' player
  7263. // so, we send information to inter-server, which is the only one which decide (and copy correct name).
  7264. strcmp(dstsd->status.name, (const char*)RFIFOP(fd,4)) != 0) // not exactly same name
  7265. // send message to inter-server
  7266. intif_wis_message(sd, (char*)RFIFOP(fd,4), (char*)RFIFOP(fd,28), RFIFOW(fd,2)-28);
  7267. // player is on this map-server
  7268. else {
  7269. // if you send to your self, don't send anything to others
  7270. if (dstsd->fd == fd) // but, normaly, it's impossible!
  7271. clif_wis_message(fd, wisp_server_name, "You can not page yourself. Sorry.", strlen("You can not page yourself. Sorry.") + 1);
  7272. // otherwise, send message and answer immediatly
  7273. else {
  7274. if (dstsd->ignoreAll == 1)
  7275. clif_wis_end(fd, 2); // type: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
  7276. else {
  7277. // if player ignore the source character
  7278. for(i = 0; i < MAX_IGNORE_LIST; i++)
  7279. if (strcmp(dstsd->ignore[i].name, sd->status.name) == 0) {
  7280. clif_wis_end(fd, 2); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
  7281. break;
  7282. }
  7283. // if source player not found in ignore list
  7284. if (i == MAX_IGNORE_LIST) {
  7285. clif_wis_message(dstsd->fd, sd->status.name, (char*)RFIFOP(fd,28), RFIFOW(fd,2) - 28);
  7286. clif_wis_end(fd, 0); // type: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
  7287. }
  7288. }
  7289. }
  7290. }
  7291. return;
  7292. }
  7293. /*==========================================
  7294. *
  7295. *------------------------------------------
  7296. */
  7297. void clif_parse_GMmessage(int fd, struct map_session_data *sd) {
  7298. // /b
  7299. nullpo_retv(sd);
  7300. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  7301. (pc_isGM(sd) >= get_atcommand_level(AtCommand_Broadcast)))
  7302. intif_GMmessage((char*)RFIFOP(fd,4), RFIFOW(fd,2)-4, 0);
  7303. }
  7304. /*==========================================
  7305. *
  7306. *------------------------------------------
  7307. */
  7308. void clif_parse_TakeItem(int fd, struct map_session_data *sd) {
  7309. struct flooritem_data *fitem;
  7310. int map_object_id;
  7311. nullpo_retv(sd);
  7312. if (USE_PACKET_DB(sd)) {
  7313. map_object_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  7314. } else {
  7315. 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])
  7316. case 7:
  7317. map_object_id = RFIFOL(fd,6);
  7318. break;
  7319. case 8:
  7320. map_object_id = RFIFOL(fd,6);
  7321. break;
  7322. case 9:
  7323. map_object_id = RFIFOL(fd,9);
  7324. break;
  7325. case 10:
  7326. map_object_id = RFIFOL(fd,7);
  7327. break;
  7328. case 11:
  7329. map_object_id = RFIFOL(fd,10);
  7330. break;
  7331. case 12:
  7332. map_object_id = RFIFOL(fd,6);
  7333. break;
  7334. case 13:
  7335. case 14:
  7336. map_object_id = RFIFOL(fd,5);
  7337. break;
  7338. case 15:
  7339. map_object_id = RFIFOL(fd,3);
  7340. break;
  7341. case 16:
  7342. map_object_id = RFIFOL(fd,5);
  7343. break;
  7344. default: // old version by default (and packet version 6)
  7345. map_object_id = RFIFOL(fd,2);
  7346. break;
  7347. }
  7348. }
  7349. fitem = (struct flooritem_data*)map_id2bl(map_object_id);
  7350. if (pc_isdead(sd)) {
  7351. clif_clearchar_area(&sd->bl, 1);
  7352. return;
  7353. }
  7354. if( sd->npc_id!=0 || sd->vender_id != 0 || sd->opt1 > 0 ||
  7355. (sd->sc_data && (sd->sc_data[SC_TRICKDEAD].timer != -1 || //死んだふり
  7356. sd->sc_data[SC_BLADESTOP].timer != -1 || //白刃取り
  7357. sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク
  7358. sd->sc_data[SC_NOCHAT].timer!=-1 )) ) //会話禁止
  7359. return;
  7360. if (fitem == NULL || fitem->bl.m != sd->bl.m)
  7361. return;
  7362. pc_takeitem(sd, fitem);
  7363. }
  7364. /*==========================================
  7365. *
  7366. *------------------------------------------
  7367. */
  7368. void clif_parse_DropItem(int fd, struct map_session_data *sd) {
  7369. int item_index, item_amount;
  7370. nullpo_retv(sd);
  7371. if (pc_isdead(sd)) {
  7372. clif_clearchar_area(&sd->bl, 1);
  7373. return;
  7374. }
  7375. if (sd->npc_id != 0 || sd->vender_id != 0 || sd->opt1 > 0 ||
  7376. (sd->sc_data && (sd->sc_data[SC_AUTOCOUNTER].timer != -1 || //オートカウンター
  7377. sd->sc_data[SC_BLADESTOP].timer != -1 || //白刃取り
  7378. sd->sc_data[SC_BERSERK].timer != -1)) ) //バーサーク
  7379. return;
  7380. if (USE_PACKET_DB(sd)) {
  7381. item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2;
  7382. item_amount = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  7383. } else {
  7384. 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])
  7385. case 8:
  7386. item_index = RFIFOW(fd,5) - 2;
  7387. item_amount = RFIFOW(fd,12);
  7388. break;
  7389. case 9:
  7390. item_index = RFIFOW(fd,8) - 2;
  7391. item_amount = RFIFOW(fd,15);
  7392. break;
  7393. case 10:
  7394. item_index = RFIFOW(fd,6) - 2;
  7395. item_amount = RFIFOW(fd,15);
  7396. break;
  7397. case 11:
  7398. item_index = RFIFOW(fd,12) - 2;
  7399. item_amount = RFIFOW(fd,17);
  7400. break;
  7401. case 12:
  7402. item_index = RFIFOW(fd,5) - 2;
  7403. item_amount = RFIFOW(fd,12);
  7404. break;
  7405. case 13:
  7406. case 14:
  7407. item_index = RFIFOW(fd,6) - 2;
  7408. item_amount = RFIFOW(fd,10);
  7409. break;
  7410. case 15:
  7411. item_index = RFIFOW(fd,4) - 2;
  7412. item_amount = RFIFOW(fd,10);
  7413. break;
  7414. case 16:
  7415. item_index = RFIFOW(fd,15) - 2;
  7416. item_amount = RFIFOW(fd,18);
  7417. break;
  7418. default: // old version by default (+ packet version 6 and 7)
  7419. item_index = RFIFOW(fd,2) - 2;
  7420. item_amount = RFIFOW(fd,4);
  7421. break;
  7422. }
  7423. }
  7424. pc_dropitem(sd, item_index, item_amount);
  7425. }
  7426. /*==========================================
  7427. *
  7428. *------------------------------------------
  7429. */
  7430. void clif_parse_UseItem(int fd, struct map_session_data *sd) {
  7431. nullpo_retv(sd);
  7432. if (pc_isdead(sd)) {
  7433. clif_clearchar_area(&sd->bl, 1);
  7434. return;
  7435. }
  7436. if (sd->npc_id!=0 || sd->vender_id != 0 || (sd->opt1 > 0 && sd->opt1 != 6) ||
  7437. (sd->sc_data && (sd->sc_data[SC_TRICKDEAD].timer != -1 || //死んだふり
  7438. sd->sc_data[SC_BLADESTOP].timer != -1 || //白刃取り
  7439. sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク
  7440. sd->sc_data[SC_NOCHAT].timer!=-1 )) ) //会話禁止
  7441. return;
  7442. if (sd->invincible_timer != -1)
  7443. pc_delinvincibletimer(sd);
  7444. if (USE_PACKET_DB(sd)) {
  7445. pc_useitem(sd,RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2);
  7446. } else {
  7447. 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])
  7448. case 6:
  7449. pc_useitem(sd,RFIFOW(fd,5)-2);
  7450. break;
  7451. case 7:
  7452. pc_useitem(sd,RFIFOW(fd,6)-2);
  7453. break;
  7454. case 8:
  7455. pc_useitem(sd,RFIFOW(fd,6)-2);
  7456. break;
  7457. case 9:
  7458. pc_useitem(sd,RFIFOW(fd,9)-2);
  7459. break;
  7460. case 10:
  7461. pc_useitem(sd,RFIFOW(fd,7)-2);
  7462. break;
  7463. case 11:
  7464. pc_useitem(sd,RFIFOW(fd,10)-2);
  7465. break;
  7466. case 12:
  7467. pc_useitem(sd,RFIFOW(fd,6)-2);
  7468. break;
  7469. case 13:
  7470. case 14:
  7471. pc_useitem(sd,RFIFOW(fd,5)-2);
  7472. break;
  7473. case 15:
  7474. pc_useitem(sd,RFIFOW(fd,3)-2);
  7475. break;
  7476. case 16:
  7477. pc_useitem(sd,RFIFOW(fd,5)-2);
  7478. break;
  7479. default: // old version by default
  7480. pc_useitem(sd,RFIFOW(fd,2)-2);
  7481. break;
  7482. }
  7483. }
  7484. }
  7485. /*==========================================
  7486. *
  7487. *------------------------------------------
  7488. */
  7489. void clif_parse_EquipItem(int fd,struct map_session_data *sd)
  7490. {
  7491. int index;
  7492. nullpo_retv(sd);
  7493. if(pc_isdead(sd)) {
  7494. clif_clearchar_area(&sd->bl,1);
  7495. return;
  7496. }
  7497. index = RFIFOW(fd,2)-2;
  7498. if(sd->npc_id!=0 || sd->vender_id != 0) return;
  7499. if(sd->sc_data && ( sd->sc_data[SC_BLADESTOP].timer!=-1 || sd->sc_data[SC_BERSERK].timer!=-1 )) return;
  7500. if(sd->status.inventory[index].identify != 1) { // 未鑑定
  7501. clif_equipitemack(sd,index,0,0); // fail
  7502. return;
  7503. }
  7504. //ペット用装備であるかないか
  7505. if(sd->inventory_data[index]) {
  7506. if(sd->inventory_data[index]->type != 8){
  7507. if(sd->inventory_data[index]->type == 10)
  7508. RFIFOW(fd,4)=0x8000; // 矢を無理やり装備できるように(--;
  7509. pc_equipitem(sd,index,RFIFOW(fd,4));
  7510. } else
  7511. pet_equipitem(sd,index);
  7512. }
  7513. }
  7514. /*==========================================
  7515. *
  7516. *------------------------------------------
  7517. */
  7518. void clif_parse_UnequipItem(int fd,struct map_session_data *sd)
  7519. {
  7520. int index;
  7521. nullpo_retv(sd);
  7522. if(pc_isdead(sd)) {
  7523. clif_clearchar_area(&sd->bl,1);
  7524. return;
  7525. }
  7526. if(sd->npc_id!=0 || sd->vender_id != 0 || sd->opt1 > 0)
  7527. return;
  7528. index = RFIFOW(fd,2)-2;
  7529. /*if(sd->status.inventory[index].attribute == 1 && sd->sc_data && sd->sc_data[SC_BROKNWEAPON].timer!=-1)
  7530. status_change_end(&sd->bl,SC_BROKNWEAPON,-1);
  7531. if(sd->status.inventory[index].attribute == 1 && sd->sc_data && sd->sc_data[SC_BROKNARMOR].timer!=-1)
  7532. status_change_end(&sd->bl,SC_BROKNARMOR,-1);
  7533. if(sd->sc_count && ( sd->sc_data[SC_BLADESTOP].timer!=-1 || sd->sc_data[SC_BERSERK].timer!=-1 ))
  7534. return;*/
  7535. pc_unequipitem(sd,index,1);
  7536. }
  7537. /*==========================================
  7538. *
  7539. *------------------------------------------
  7540. */
  7541. void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
  7542. {
  7543. nullpo_retv(sd);
  7544. if(pc_isdead(sd)) {
  7545. clif_clearchar_area(&sd->bl,1);
  7546. return;
  7547. }
  7548. if(sd->npc_id!=0 || sd->vender_id != 0)
  7549. return;
  7550. npc_click(sd,RFIFOL(fd,2));
  7551. }
  7552. /*==========================================
  7553. *
  7554. *------------------------------------------
  7555. */
  7556. void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd)
  7557. {
  7558. npc_buysellsel(sd,RFIFOL(fd,2),RFIFOB(fd,6));
  7559. }
  7560. /*==========================================
  7561. *
  7562. *------------------------------------------
  7563. */
  7564. void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd)
  7565. {
  7566. int fail=0,n;
  7567. unsigned short *item_list;
  7568. n = (RFIFOW(fd,2)-4) /4;
  7569. item_list = (unsigned short*)RFIFOP(fd,4);
  7570. fail = npc_buylist(sd,n,item_list);
  7571. WFIFOW(fd,0)=0xca;
  7572. WFIFOB(fd,2)=fail;
  7573. WFIFOSET(fd,packet_len_table[0xca]);
  7574. }
  7575. /*==========================================
  7576. *
  7577. *------------------------------------------
  7578. */
  7579. void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd)
  7580. {
  7581. int fail=0,n;
  7582. unsigned short *item_list;
  7583. n = (RFIFOW(fd,2)-4) /4;
  7584. item_list = (unsigned short*)RFIFOP(fd,4);
  7585. fail = npc_selllist(sd,n,item_list);
  7586. WFIFOW(fd,0)=0xcb;
  7587. WFIFOB(fd,2)=fail;
  7588. WFIFOSET(fd,packet_len_table[0xcb]);
  7589. }
  7590. /*==========================================
  7591. *
  7592. *------------------------------------------
  7593. */
  7594. void clif_parse_CreateChatRoom(int fd,struct map_session_data *sd)
  7595. {
  7596. if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 4){
  7597. chat_createchat(sd,RFIFOW(fd,4),RFIFOB(fd,6),(char*)RFIFOP(fd,7),(char*)RFIFOP(fd,15),RFIFOW(fd,2)-15);
  7598. } else
  7599. clif_skill_fail(sd,1,0,3);
  7600. }
  7601. /*==========================================
  7602. *
  7603. *------------------------------------------
  7604. */
  7605. void clif_parse_ChatAddMember(int fd,struct map_session_data *sd)
  7606. {
  7607. chat_joinchat(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
  7608. }
  7609. /*==========================================
  7610. *
  7611. *------------------------------------------
  7612. */
  7613. void clif_parse_ChatRoomStatusChange(int fd,struct map_session_data *sd)
  7614. {
  7615. chat_changechatstatus(sd,RFIFOW(fd,4),RFIFOB(fd,6),(char*)RFIFOP(fd,7),(char*)RFIFOP(fd,15),RFIFOW(fd,2)-15);
  7616. }
  7617. /*==========================================
  7618. *
  7619. *------------------------------------------
  7620. */
  7621. void clif_parse_ChangeChatOwner(int fd,struct map_session_data *sd)
  7622. {
  7623. chat_changechatowner(sd,(char*)RFIFOP(fd,6));
  7624. }
  7625. /*==========================================
  7626. *
  7627. *------------------------------------------
  7628. */
  7629. void clif_parse_KickFromChat(int fd,struct map_session_data *sd)
  7630. {
  7631. chat_kickchat(sd,(char*)RFIFOP(fd,2));
  7632. }
  7633. /*==========================================
  7634. *
  7635. *------------------------------------------
  7636. */
  7637. void clif_parse_ChatLeave(int fd,struct map_session_data *sd)
  7638. {
  7639. chat_leavechat(sd);
  7640. }
  7641. /*==========================================
  7642. * 取引要請を相手に送る
  7643. *------------------------------------------
  7644. */
  7645. void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
  7646. {
  7647. nullpo_retv(sd);
  7648. if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 1){
  7649. trade_traderequest(sd,RFIFOL(sd->fd,2));
  7650. } else
  7651. clif_skill_fail(sd,1,0,0);
  7652. }
  7653. /*==========================================
  7654. * 取引要請
  7655. *------------------------------------------
  7656. */
  7657. void clif_parse_TradeAck(int fd,struct map_session_data *sd)
  7658. {
  7659. nullpo_retv(sd);
  7660. trade_tradeack(sd,RFIFOB(sd->fd,2));
  7661. }
  7662. /*==========================================
  7663. * アイテム追加
  7664. *------------------------------------------
  7665. */
  7666. void clif_parse_TradeAddItem(int fd,struct map_session_data *sd)
  7667. {
  7668. nullpo_retv(sd);
  7669. trade_tradeadditem(sd,RFIFOW(sd->fd,2),RFIFOL(sd->fd,4));
  7670. }
  7671. /*==========================================
  7672. * アイテム追加完了(ok押し)
  7673. *------------------------------------------
  7674. */
  7675. void clif_parse_TradeOk(int fd,struct map_session_data *sd)
  7676. {
  7677. trade_tradeok(sd);
  7678. }
  7679. /*==========================================
  7680. * 取引キャンセル
  7681. *------------------------------------------
  7682. */
  7683. void clif_parse_TradeCancel(int fd,struct map_session_data *sd)
  7684. {
  7685. trade_tradecancel(sd);
  7686. }
  7687. /*==========================================
  7688. * 取引許諾(trade押し)
  7689. *------------------------------------------
  7690. */
  7691. void clif_parse_TradeCommit(int fd,struct map_session_data *sd)
  7692. {
  7693. trade_tradecommit(sd);
  7694. }
  7695. /*==========================================
  7696. *
  7697. *------------------------------------------
  7698. */
  7699. void clif_parse_StopAttack(int fd,struct map_session_data *sd)
  7700. {
  7701. pc_stopattack(sd);
  7702. }
  7703. /*==========================================
  7704. * カートへアイテムを移す
  7705. *------------------------------------------
  7706. */
  7707. void clif_parse_PutItemToCart(int fd,struct map_session_data *sd)
  7708. {
  7709. nullpo_retv(sd);
  7710. if(sd->npc_id!=0 || sd->vender_id != 0)
  7711. return;
  7712. pc_putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
  7713. }
  7714. /*==========================================
  7715. * カートからアイテムを出す
  7716. *------------------------------------------
  7717. */
  7718. void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd)
  7719. {
  7720. nullpo_retv(sd);
  7721. if(sd->npc_id!=0 || sd->vender_id != 0) return;
  7722. pc_getitemfromcart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
  7723. }
  7724. /*==========================================
  7725. * 付属品(鷹,ペコ,カート)をはずす
  7726. *------------------------------------------
  7727. */
  7728. void clif_parse_RemoveOption(int fd,struct map_session_data *sd)
  7729. {
  7730. if(pc_isriding(sd)) { // jobchange when removing peco [Valaris]
  7731. if(sd->status.class_==13)
  7732. sd->status.class_=sd->view_class=7;
  7733. if(sd->status.class_==21)
  7734. sd->status.class_=sd->view_class=14;
  7735. if(sd->status.class_==4014)
  7736. sd->status.class_=sd->view_class=4008;
  7737. if(sd->status.class_==4022)
  7738. sd->status.class_=sd->view_class=4015;
  7739. }
  7740. pc_setoption(sd,0);
  7741. }
  7742. /*==========================================
  7743. * チェンジカート
  7744. *------------------------------------------
  7745. */
  7746. void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
  7747. {
  7748. pc_setcart(sd,RFIFOW(fd,2));
  7749. }
  7750. /*==========================================
  7751. * ステータスアップ
  7752. *------------------------------------------
  7753. */
  7754. void clif_parse_StatusUp(int fd,struct map_session_data *sd)
  7755. {
  7756. pc_statusup(sd,RFIFOW(fd,2));
  7757. }
  7758. /*==========================================
  7759. * スキルレベルアップ
  7760. *------------------------------------------
  7761. */
  7762. void clif_parse_SkillUp(int fd,struct map_session_data *sd)
  7763. {
  7764. pc_skillup(sd,RFIFOW(fd,2));
  7765. }
  7766. /*==========================================
  7767. * スキル使用(ID指定)
  7768. *------------------------------------------
  7769. */
  7770. void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) {
  7771. int skillnum, skilllv, lv, target_id;
  7772. unsigned int tick = gettick();
  7773. nullpo_retv(sd);
  7774. if (sd->chatID || sd->npc_id != 0 || sd->vender_id != 0)
  7775. return;
  7776. if (USE_PACKET_DB(sd)) {
  7777. skilllv = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  7778. skillnum = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  7779. target_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[2]);
  7780. } else {
  7781. 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])
  7782. case 6:
  7783. skilllv = RFIFOW(fd,4);
  7784. skillnum = RFIFOW(fd,9);
  7785. target_id = RFIFOL(fd,11);
  7786. break;
  7787. case 7:
  7788. skilllv = RFIFOW(fd,7);
  7789. skillnum = RFIFOW(fd,9);
  7790. target_id = RFIFOL(fd,15);
  7791. break;
  7792. case 8:
  7793. skilllv = RFIFOW(fd,7);
  7794. skillnum = RFIFOW(fd,12);
  7795. target_id = RFIFOL(fd,16);
  7796. break;
  7797. case 9:
  7798. skilllv = RFIFOW(fd,11);
  7799. skillnum = RFIFOW(fd,18);
  7800. target_id = RFIFOL(fd,22);
  7801. break;
  7802. case 10:
  7803. skilllv = RFIFOW(fd,9);
  7804. skillnum = RFIFOW(fd,15);
  7805. target_id = RFIFOL(fd,18);
  7806. break;
  7807. case 11:
  7808. skilllv = RFIFOW(fd,4);
  7809. skillnum = RFIFOW(fd,7);
  7810. target_id = RFIFOL(fd,10);
  7811. break;
  7812. case 12:
  7813. skilllv = RFIFOW(fd,7);
  7814. skillnum = RFIFOW(fd,12);
  7815. target_id = RFIFOL(fd,16);
  7816. break;
  7817. case 13:
  7818. case 14:
  7819. skilllv = RFIFOW(fd,4);
  7820. skillnum = RFIFOW(fd,10);
  7821. target_id = RFIFOL(fd,22);
  7822. break;
  7823. case 15:
  7824. skilllv = RFIFOW(fd,8);
  7825. skillnum = RFIFOW(fd,12);
  7826. target_id = RFIFOL(fd,18);
  7827. break;
  7828. case 16:
  7829. skilllv = RFIFOW(fd,8);
  7830. skillnum = RFIFOW(fd,16);
  7831. target_id = RFIFOL(fd,22);
  7832. break;
  7833. default: // old version by default
  7834. skilllv = RFIFOW(fd,2);
  7835. skillnum = RFIFOW(fd,4);
  7836. target_id = RFIFOL(fd,6);
  7837. break;
  7838. }
  7839. }
  7840. if (skillnotok(skillnum, sd))
  7841. return;
  7842. if (sd->skilltimer != -1) {
  7843. if (skillnum != SA_CASTCANCEL)
  7844. return;
  7845. } else if (DIFF_TICK(tick, sd->canact_tick) < 0 &&
  7846. // allow monk combos to ignore this delay [celest]
  7847. !(sd->sc_count && sd->sc_data[SC_COMBO].timer!=-1 &&
  7848. (skillnum == MO_EXTREMITYFIST ||
  7849. skillnum == MO_CHAINCOMBO ||
  7850. skillnum == MO_COMBOFINISH ||
  7851. skillnum == CH_PALMSTRIKE ||
  7852. skillnum == CH_TIGERFIST ||
  7853. skillnum == CH_CHAINCRUSH))) {
  7854. clif_skill_fail(sd, skillnum, 4, 0);
  7855. return;
  7856. }
  7857. if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) ||
  7858. sd->sc_data[SC_BERSERK].timer != -1 || sd->sc_data[SC_NOCHAT].timer != -1 ||
  7859. sd->sc_data[SC_WEDDING].timer != -1 || sd->view_class == 22)
  7860. return;
  7861. if (sd->invincible_timer != -1)
  7862. pc_delinvincibletimer(sd);
  7863. if (sd->skillitem >= 0 && sd->skillitem == skillnum) {
  7864. if (skilllv != sd->skillitemlv)
  7865. skilllv = sd->skillitemlv;
  7866. skill_use_id(sd, target_id, skillnum, skilllv);
  7867. } else {
  7868. sd->skillitem = sd->skillitemlv = -1;
  7869. if (skillnum == MO_EXTREMITYFIST) {
  7870. if ((sd->sc_data[SC_COMBO].timer == -1 || (sd->sc_data[SC_COMBO].val1 != MO_COMBOFINISH && sd->sc_data[SC_COMBO].val1 != CH_CHAINCRUSH))) {
  7871. if (!sd->state.skill_flag ) {
  7872. sd->state.skill_flag = 1;
  7873. clif_skillinfo(sd, MO_EXTREMITYFIST, 1, -1);
  7874. return;
  7875. } else if (sd->bl.id == target_id) {
  7876. clif_skillinfo(sd, MO_EXTREMITYFIST, 1, -1);
  7877. return;
  7878. }
  7879. }
  7880. } else if (skillnum == CH_TIGERFIST) {
  7881. if (sd->sc_data[SC_COMBO].timer == -1 || sd->sc_data[SC_COMBO].val1 != MO_COMBOFINISH) {
  7882. if (!sd->state.skill_flag ) {
  7883. sd->state.skill_flag = 1;
  7884. if (!sd->attacktarget) {
  7885. clif_skillinfo(sd, CH_TIGERFIST, 1, -2);
  7886. return;
  7887. } else
  7888. target_id = sd->attacktarget;
  7889. } else if (sd->bl.id == target_id) {
  7890. clif_skillinfo(sd, CH_TIGERFIST, 1, -2);
  7891. return;
  7892. }
  7893. }
  7894. }
  7895. if ((lv = pc_checkskill(sd, skillnum)) > 0) {
  7896. if (skilllv > lv)
  7897. skilllv = lv;
  7898. skill_use_id(sd, target_id, skillnum, skilllv);
  7899. if (sd->state.skill_flag)
  7900. sd->state.skill_flag = 0;
  7901. }
  7902. }
  7903. }
  7904. /*==========================================
  7905. * スキル使用(場所指定)
  7906. *------------------------------------------
  7907. */
  7908. void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) {
  7909. int skillnum, skilllv, lv, x, y;
  7910. unsigned int tick = gettick();
  7911. int skillmoreinfo;
  7912. nullpo_retv(sd);
  7913. if (sd->npc_id != 0 || sd->vender_id != 0) return;
  7914. if(sd->chatID) return;
  7915. skillmoreinfo = -1;
  7916. if (USE_PACKET_DB(sd)) {
  7917. skilllv = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  7918. skillnum = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  7919. x = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[2]);
  7920. y = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[3]);
  7921. } else {
  7922. 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])
  7923. case 6:
  7924. skilllv = RFIFOW(fd,4);
  7925. skillnum = RFIFOW(fd,9);
  7926. x = RFIFOW(fd,11);
  7927. y = RFIFOW(fd,13);
  7928. if (RFIFOW(fd,0) == 0x190)
  7929. skillmoreinfo = 15;
  7930. break;
  7931. case 7:
  7932. skilllv = RFIFOW(fd,7);
  7933. skillnum = RFIFOW(fd,9);
  7934. x = RFIFOW(fd,15);
  7935. y = RFIFOW(fd,17);
  7936. if (RFIFOW(fd,0) == 0x190)
  7937. skillmoreinfo = 19;
  7938. break;
  7939. case 8:
  7940. skilllv = RFIFOW(fd,3);
  7941. skillnum = RFIFOW(fd,6);
  7942. x = RFIFOW(fd,17);
  7943. y = RFIFOW(fd,21);
  7944. if (RFIFOW(fd,0) == 0x0a2)
  7945. skillmoreinfo = 23;
  7946. break;
  7947. case 9:
  7948. skilllv = RFIFOW(fd,5);
  7949. skillnum = RFIFOW(fd,15);
  7950. x = RFIFOW(fd,29);
  7951. y = RFIFOW(fd,38);
  7952. if (RFIFOW(fd,0) == 0x0a2)
  7953. skillmoreinfo = 40;
  7954. break;
  7955. case 10:
  7956. skilllv = RFIFOW(fd,10);
  7957. skillnum = RFIFOW(fd,14);
  7958. x = RFIFOW(fd,18);
  7959. y = RFIFOW(fd,23);
  7960. if (RFIFOW(fd,0) == 0x08c)
  7961. skillmoreinfo = 25;
  7962. break;
  7963. case 11:
  7964. skilllv = RFIFOW(fd,6); // 16? to check.
  7965. skillnum = RFIFOW(fd,20);
  7966. x = RFIFOW(fd,23);
  7967. y = RFIFOW(fd,27);
  7968. if (RFIFOW(fd,0) == 0x08c)
  7969. skillmoreinfo = 29;
  7970. break;
  7971. case 12:
  7972. skilllv = RFIFOW(fd,3); // 2? to check.
  7973. skillnum = RFIFOW(fd,6);
  7974. x = RFIFOW(fd,17);
  7975. y = RFIFOW(fd,21);
  7976. if (RFIFOW(fd,0) == 0x08c)
  7977. skillmoreinfo = 23;
  7978. break;
  7979. case 13:
  7980. case 14:
  7981. skilllv = RFIFOW(fd,6);
  7982. skillnum = RFIFOW(fd,9);
  7983. x = RFIFOW(fd,23);
  7984. y = RFIFOW(fd,26);
  7985. if (RFIFOW(fd,0) == 0x08c)
  7986. skillmoreinfo = 28;
  7987. break;
  7988. case 15:
  7989. skilllv = RFIFOW(fd,4);
  7990. skillnum = RFIFOW(fd,9);
  7991. x = RFIFOW(fd,22);
  7992. y = RFIFOW(fd,28);
  7993. if (RFIFOW(fd,0) == 0x113)
  7994. skillmoreinfo = 30;
  7995. break;
  7996. case 16:
  7997. skilllv = RFIFOW(fd,9);
  7998. skillnum = RFIFOW(fd,18);
  7999. x = RFIFOW(fd,22);
  8000. y = RFIFOW(fd,32);
  8001. if (RFIFOW(fd,0) == 0x07e)
  8002. skillmoreinfo = 34;
  8003. break;
  8004. default: // old version by default
  8005. skilllv = RFIFOW(fd,2);
  8006. skillnum = RFIFOW(fd,4);
  8007. x = RFIFOW(fd,6);
  8008. y = RFIFOW(fd,8);
  8009. if (RFIFOW(fd,0) == 0x190)
  8010. skillmoreinfo = 10;
  8011. break;
  8012. }
  8013. }
  8014. if (skillnotok(skillnum, sd))
  8015. return;
  8016. if (skillmoreinfo != -1) {
  8017. if (pc_issit(sd)) {
  8018. clif_skill_fail(sd, skillnum, 0, 0);
  8019. return;
  8020. }
  8021. memcpy(talkie_mes, RFIFOP(fd,skillmoreinfo), 80);
  8022. }
  8023. if (sd->skilltimer != -1)
  8024. return;
  8025. else if (DIFF_TICK(tick, sd->canact_tick) < 0 &&
  8026. // allow monk combos to ignore this delay [celest]
  8027. !(sd->sc_count && sd->sc_data[SC_COMBO].timer!=-1 &&
  8028. (skillnum == MO_EXTREMITYFIST ||
  8029. skillnum == MO_CHAINCOMBO ||
  8030. skillnum == MO_COMBOFINISH ||
  8031. skillnum == CH_PALMSTRIKE ||
  8032. skillnum == CH_TIGERFIST ||
  8033. skillnum == CH_CHAINCRUSH))) {
  8034. clif_skill_fail(sd, skillnum, 4, 0);
  8035. return;
  8036. }
  8037. if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) ||
  8038. sd->sc_data[SC_BERSERK].timer != -1 || sd->sc_data[SC_NOCHAT].timer != -1 ||
  8039. sd->sc_data[SC_WEDDING].timer != -1 || sd->view_class == 22)
  8040. return;
  8041. if (sd->invincible_timer != -1)
  8042. pc_delinvincibletimer(sd);
  8043. if (sd->skillitem >= 0 && sd->skillitem == skillnum) {
  8044. if (skilllv != sd->skillitemlv)
  8045. skilllv = sd->skillitemlv;
  8046. skill_use_pos(sd, x, y, skillnum, skilllv);
  8047. } else {
  8048. sd->skillitem = sd->skillitemlv = -1;
  8049. if ((lv = pc_checkskill(sd, skillnum)) > 0) {
  8050. if (skilllv > lv)
  8051. skilllv = lv;
  8052. skill_use_pos(sd, x, y, skillnum,skilllv);
  8053. }
  8054. }
  8055. }
  8056. /*==========================================
  8057. * スキル使用(map指定)
  8058. *------------------------------------------
  8059. */
  8060. void clif_parse_UseSkillMap(int fd,struct map_session_data *sd)
  8061. {
  8062. nullpo_retv(sd);
  8063. if(sd->chatID) return;
  8064. if (sd->npc_id!=0 || sd->vender_id != 0 || (sd->sc_data &&
  8065. (sd->sc_data[SC_TRICKDEAD].timer != -1 ||
  8066. sd->sc_data[SC_BERSERK].timer!=-1 ||
  8067. sd->sc_data[SC_NOCHAT].timer!=-1 ||
  8068. sd->sc_data[SC_WEDDING].timer!=-1 ||
  8069. sd->view_class==22)))
  8070. return;
  8071. if(sd->invincible_timer != -1)
  8072. pc_delinvincibletimer(sd);
  8073. skill_castend_map(sd,RFIFOW(fd,2),(char*)RFIFOP(fd,4));
  8074. }
  8075. /*==========================================
  8076. * メモ要求
  8077. *------------------------------------------
  8078. */
  8079. void clif_parse_RequestMemo(int fd,struct map_session_data *sd)
  8080. {
  8081. pc_memo(sd,-1);
  8082. }
  8083. /*==========================================
  8084. * アイテム合成
  8085. *------------------------------------------
  8086. */
  8087. void clif_parse_ProduceMix(int fd,struct map_session_data *sd)
  8088. {
  8089. nullpo_retv(sd);
  8090. sd->state.produce_flag = 0;
  8091. skill_produce_mix(sd,RFIFOW(fd,2),RFIFOW(fd,4),RFIFOW(fd,6),RFIFOW(fd,8));
  8092. }
  8093. /*==========================================
  8094. *
  8095. *------------------------------------------
  8096. */
  8097. void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
  8098. {
  8099. nullpo_retv(sd);
  8100. sd->npc_menu=RFIFOB(fd,6);
  8101. npc_scriptcont(sd,RFIFOL(fd,2));
  8102. }
  8103. /*==========================================
  8104. *
  8105. *------------------------------------------
  8106. */
  8107. void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
  8108. {
  8109. npc_scriptcont(sd,RFIFOL(fd,2));
  8110. }
  8111. /*==========================================
  8112. *
  8113. *------------------------------------------
  8114. */
  8115. void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
  8116. {
  8117. nullpo_retv(sd);
  8118. #define RFIFOL_(fd,pos) (*(int*)(session[fd]->rdata+session[fd]->rdata_pos+(pos)))
  8119. //Input Value overflow Exploit FIX
  8120. sd->npc_amount=RFIFOL_(fd,6); //fixed by Lupus. npc_amount is (int) but was RFIFOL changing it to (unsigned int)
  8121. #undef RFIFOL_
  8122. npc_scriptcont(sd,RFIFOL(fd,2));
  8123. }
  8124. /*==========================================
  8125. *
  8126. *------------------------------------------
  8127. */
  8128. void clif_parse_NpcStringInput(int fd,struct map_session_data *sd)
  8129. {
  8130. nullpo_retv(sd);
  8131. if(RFIFOW(fd,2)-7 >= sizeof(sd->npc_str)){
  8132. printf("clif: input string too long !\n");
  8133. memcpy(sd->npc_str,RFIFOP(fd,8),sizeof(sd->npc_str));
  8134. sd->npc_str[sizeof(sd->npc_str)-1]=0;
  8135. } else
  8136. strcpy(sd->npc_str,(char*)RFIFOP(fd,8));
  8137. npc_scriptcont(sd,RFIFOL(fd,4));
  8138. }
  8139. /*==========================================
  8140. *
  8141. *------------------------------------------
  8142. */
  8143. void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd)
  8144. {
  8145. npc_scriptcont(sd,RFIFOL(fd,2));
  8146. }
  8147. /*==========================================
  8148. * アイテム鑑定
  8149. *------------------------------------------
  8150. */
  8151. void clif_parse_ItemIdentify(int fd,struct map_session_data *sd)
  8152. {
  8153. pc_item_identify(sd,RFIFOW(fd,2)-2);
  8154. }
  8155. /*==========================================
  8156. * 矢作成
  8157. *------------------------------------------
  8158. */
  8159. void clif_parse_SelectArrow(int fd,struct map_session_data *sd)
  8160. {
  8161. nullpo_retv(sd);
  8162. sd->state.make_arrow_flag = 0;
  8163. skill_arrow_create(sd,RFIFOW(fd,2));
  8164. }
  8165. /*==========================================
  8166. * オートスペル受信
  8167. *------------------------------------------
  8168. */
  8169. void clif_parse_AutoSpell(int fd,struct map_session_data *sd)
  8170. {
  8171. skill_autospell(sd,RFIFOW(fd,2));
  8172. }
  8173. /*==========================================
  8174. * カード使用
  8175. *------------------------------------------
  8176. */
  8177. void clif_parse_UseCard(int fd,struct map_session_data *sd)
  8178. {
  8179. clif_use_card(sd,RFIFOW(fd,2)-2);
  8180. }
  8181. /*==========================================
  8182. * カード挿入装備選択
  8183. *------------------------------------------
  8184. */
  8185. void clif_parse_InsertCard(int fd,struct map_session_data *sd)
  8186. {
  8187. pc_insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2);
  8188. }
  8189. /*==========================================
  8190. * 0193 キャラID名前引き
  8191. *------------------------------------------
  8192. */
  8193. void clif_parse_SolveCharName(int fd, struct map_session_data *sd) {
  8194. int char_id;
  8195. if (USE_PACKET_DB(sd)) {
  8196. char_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
  8197. } else {
  8198. 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])
  8199. case 8:
  8200. char_id = RFIFOL(fd,8);
  8201. break;
  8202. case 9:
  8203. char_id = RFIFOL(fd,7);
  8204. break;
  8205. case 10:
  8206. char_id = RFIFOL(fd,10);
  8207. break;
  8208. case 11:
  8209. char_id = RFIFOL(fd,6);
  8210. break;
  8211. case 12:
  8212. char_id = RFIFOL(fd,8);
  8213. break;
  8214. case 13:
  8215. case 14:
  8216. char_id = RFIFOL(fd,12);
  8217. break;
  8218. case 15:
  8219. char_id = RFIFOL(fd,10);
  8220. break;
  8221. case 16:
  8222. char_id = RFIFOL(fd,7);
  8223. break;
  8224. default: // old version by default (+ packet version 6 and 7)
  8225. char_id = RFIFOL(fd,2);
  8226. break;
  8227. }
  8228. }
  8229. clif_solved_charname(sd, char_id);
  8230. }
  8231. /*==========================================
  8232. * 0197 /resetskill /resetstate
  8233. *------------------------------------------
  8234. */
  8235. void clif_parse_ResetChar(int fd, struct map_session_data *sd) {
  8236. nullpo_retv(sd);
  8237. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  8238. pc_isGM(sd) >= get_atcommand_level(AtCommand_ResetState)) {
  8239. switch(RFIFOW(fd,2)){
  8240. case 0:
  8241. pc_resetstate(sd);
  8242. break;
  8243. case 1:
  8244. pc_resetskill(sd);
  8245. break;
  8246. }
  8247. }
  8248. }
  8249. /*==========================================
  8250. * 019c /lb等
  8251. *------------------------------------------
  8252. */
  8253. void clif_parse_LGMmessage(int fd, struct map_session_data *sd) {
  8254. unsigned char buf[512];
  8255. nullpo_retv(sd);
  8256. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  8257. (pc_isGM(sd) >= get_atcommand_level(AtCommand_LocalBroadcast))) {
  8258. WBUFW(buf,0) = 0x9a;
  8259. WBUFW(buf,2) = RFIFOW(fd,2);
  8260. memcpy(WBUFP(buf,4), RFIFOP(fd,4), RFIFOW(fd,2) - 4);
  8261. clif_send(buf, RFIFOW(fd,2), &sd->bl, ALL_SAMEMAP);
  8262. }
  8263. }
  8264. /*==========================================
  8265. * カプラ倉庫へ入れる
  8266. *------------------------------------------
  8267. */
  8268. void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) {
  8269. int item_index, item_amount;
  8270. nullpo_retv(sd);
  8271. if (sd->npc_id != 0 || sd->vender_id != 0)
  8272. return;
  8273. if (USE_PACKET_DB(sd)) {
  8274. item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2;
  8275. item_amount = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  8276. } else {
  8277. 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])
  8278. case 8:
  8279. item_index = RFIFOW(fd,5) - 2;
  8280. item_amount = RFIFOL(fd,12);
  8281. break;
  8282. case 9:
  8283. item_index = RFIFOW(fd,5) - 2;
  8284. item_amount = RFIFOL(fd,19);
  8285. break;
  8286. case 10:
  8287. item_index = RFIFOW(fd,3) - 2;
  8288. item_amount = RFIFOL(fd,15);
  8289. break;
  8290. case 11:
  8291. item_index = RFIFOW(fd,6) - 2;
  8292. item_amount = RFIFOL(fd,21);
  8293. break;
  8294. case 12:
  8295. item_index = RFIFOW(fd,5) - 2;
  8296. item_amount = RFIFOL(fd,12);
  8297. break;
  8298. case 13:
  8299. case 14:
  8300. item_index = RFIFOW(fd,6) - 2;
  8301. item_amount = RFIFOL(fd,9);
  8302. break;
  8303. case 15:
  8304. item_index = RFIFOW(fd,4) - 2;
  8305. item_amount = RFIFOL(fd,10);
  8306. break;
  8307. case 16:
  8308. item_index = RFIFOW(fd,10) - 2;
  8309. item_amount = RFIFOL(fd,16);
  8310. break;
  8311. default: // old version by default (+ packet version 6 and 7)
  8312. item_index = RFIFOW(fd,2) - 2;
  8313. item_amount = RFIFOL(fd,4);
  8314. break;
  8315. }
  8316. }
  8317. if (item_index < 0 || item_index >= MAX_INVENTORY)
  8318. return;
  8319. if(itemdb_isdropable(sd->status.inventory[item_index].nameid) == 0)
  8320. return;
  8321. if (sd->state.storage_flag)
  8322. storage_guild_storageadd(sd, item_index, item_amount);
  8323. else
  8324. storage_storageadd(sd, item_index, item_amount);
  8325. }
  8326. /*==========================================
  8327. * カプラ倉庫から出す
  8328. *------------------------------------------
  8329. */
  8330. void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd) {
  8331. int item_index, item_amount;
  8332. nullpo_retv(sd);
  8333. if (USE_PACKET_DB(sd)) {
  8334. item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-1;
  8335. item_amount = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
  8336. } else {
  8337. 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])
  8338. case 8:
  8339. item_index = RFIFOW(fd,10) - 1;
  8340. item_amount = RFIFOL(fd,22);
  8341. break;
  8342. case 9:
  8343. item_index = RFIFOW(fd,11) - 1;
  8344. item_amount = RFIFOL(fd,22);
  8345. break;
  8346. case 10:
  8347. item_index = RFIFOW(fd,3) - 1;
  8348. item_amount = RFIFOL(fd,13);
  8349. break;
  8350. case 11:
  8351. item_index = RFIFOW(fd,4) - 1;
  8352. item_amount = RFIFOL(fd,8);
  8353. break;
  8354. case 12:
  8355. item_index = RFIFOW(fd,10) - 1;
  8356. item_amount = RFIFOL(fd,22);
  8357. break;
  8358. case 13:
  8359. case 14:
  8360. item_index = RFIFOW(fd,12) - 1;
  8361. item_amount = RFIFOL(fd,18);
  8362. break;
  8363. case 15:
  8364. item_index = RFIFOW(fd,4) - 1;
  8365. item_amount = RFIFOL(fd,17);
  8366. break;
  8367. case 16:
  8368. item_index = RFIFOW(fd,11) - 1;
  8369. item_amount = RFIFOL(fd,17);
  8370. break;
  8371. default: // old version by default (+ packet version 6 and 7)
  8372. item_index = RFIFOW(fd,2) - 1;
  8373. item_amount = RFIFOL(fd,4);
  8374. break;
  8375. }
  8376. }
  8377. if (sd->npc_id != 0 || sd->vender_id != 0)
  8378. return;
  8379. if (sd->state.storage_flag)
  8380. storage_guild_storageget(sd, item_index, item_amount);
  8381. else
  8382. storage_storageget(sd, item_index, item_amount);
  8383. }
  8384. /*==========================================
  8385. * カプラ倉庫へカートから入れる
  8386. *------------------------------------------
  8387. */
  8388. void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd) {
  8389. nullpo_retv(sd);
  8390. if (sd->npc_id != 0 || sd->vender_id != 0 || sd->trade_partner != 0)
  8391. return;
  8392. if (sd->state.storage_flag)
  8393. storage_guild_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
  8394. else
  8395. storage_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
  8396. }
  8397. /*==========================================
  8398. * カプラ倉庫から出す
  8399. *------------------------------------------
  8400. */
  8401. void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd) {
  8402. nullpo_retv(sd);
  8403. if (sd->npc_id != 0 || sd->vender_id != 0)
  8404. return;
  8405. if (sd->state.storage_flag)
  8406. storage_guild_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
  8407. else
  8408. storage_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
  8409. }
  8410. /*==========================================
  8411. * カプラ倉庫を閉じる
  8412. *------------------------------------------
  8413. */
  8414. void clif_parse_CloseKafra(int fd, struct map_session_data *sd) {
  8415. nullpo_retv(sd);
  8416. if (sd->state.storage_flag)
  8417. storage_guild_storageclose(sd);
  8418. else
  8419. storage_storageclose(sd);
  8420. }
  8421. /*==========================================
  8422. * パーティを作る
  8423. *------------------------------------------
  8424. */
  8425. void clif_parse_CreateParty(int fd, struct map_session_data *sd) {
  8426. if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7) {
  8427. party_create(sd,(char*)RFIFOP(fd,2),0,0);
  8428. } else
  8429. clif_skill_fail(sd,1,0,4);
  8430. }
  8431. /*==========================================
  8432. * パーティを作る
  8433. *------------------------------------------
  8434. */
  8435. void clif_parse_CreateParty2(int fd, struct map_session_data *sd) {
  8436. if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7){
  8437. party_create(sd,(char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27));
  8438. } else
  8439. clif_skill_fail(sd,1,0,4);
  8440. }
  8441. /*==========================================
  8442. * パーティに勧誘
  8443. *------------------------------------------
  8444. */
  8445. void clif_parse_PartyInvite(int fd, struct map_session_data *sd) {
  8446. party_invite(sd, RFIFOL(fd,2));
  8447. }
  8448. /*==========================================
  8449. * パーティ勧誘返答
  8450. *------------------------------------------
  8451. */
  8452. void clif_parse_ReplyPartyInvite(int fd,struct map_session_data *sd) {
  8453. if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 5){
  8454. party_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6));
  8455. } else {
  8456. party_reply_invite(sd,RFIFOL(fd,2),-1);
  8457. clif_skill_fail(sd,1,0,4);
  8458. }
  8459. }
  8460. /*==========================================
  8461. * パーティ脱退要求
  8462. *------------------------------------------
  8463. */
  8464. void clif_parse_LeaveParty(int fd, struct map_session_data *sd) {
  8465. party_leave(sd);
  8466. }
  8467. /*==========================================
  8468. * パーティ除名要求
  8469. *------------------------------------------
  8470. */
  8471. void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) {
  8472. party_removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
  8473. }
  8474. /*==========================================
  8475. * パーティ設定変更要求
  8476. *------------------------------------------
  8477. */
  8478. void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) {
  8479. party_changeoption(sd, RFIFOW(fd,2), RFIFOW(fd,4));
  8480. }
  8481. /*==========================================
  8482. * パーティメッセージ送信要求
  8483. *------------------------------------------
  8484. */
  8485. void clif_parse_PartyMessage(int fd, struct map_session_data *sd) {
  8486. nullpo_retv(sd);
  8487. if (is_charcommand(fd, sd, (char*)RFIFOP(fd,4), 0) != CharCommand_None ||
  8488. is_atcommand(fd, sd, (char*)RFIFOP(fd,4), 0) != AtCommand_None ||
  8489. (sd->sc_data &&
  8490. (sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク時は会話も不可
  8491. sd->sc_data[SC_NOCHAT].timer!=-1))) //チャット禁止
  8492. return;
  8493. party_send_message(sd, (char*)RFIFOP(fd,4), RFIFOW(fd,2)-4);
  8494. }
  8495. /*==========================================
  8496. * 露店閉鎖
  8497. *------------------------------------------
  8498. */
  8499. void clif_parse_CloseVending(int fd, struct map_session_data *sd) {
  8500. vending_closevending(sd);
  8501. }
  8502. /*==========================================
  8503. * 露店アイテムリスト要求
  8504. *------------------------------------------
  8505. */
  8506. void clif_parse_VendingListReq(int fd, struct map_session_data *sd) {
  8507. nullpo_retv(sd);
  8508. vending_vendinglistreq(sd,RFIFOL(fd,2));
  8509. if(sd->npc_id)
  8510. npc_event_dequeue(sd);
  8511. }
  8512. /*==========================================
  8513. * 露店アイテム購入
  8514. *------------------------------------------
  8515. */
  8516. void clif_parse_PurchaseReq(int fd, struct map_session_data *sd) {
  8517. vending_purchasereq(sd, RFIFOW(fd,2), RFIFOL(fd,4), RFIFOP(fd,8));
  8518. }
  8519. /*==========================================
  8520. * 露店開設
  8521. *------------------------------------------
  8522. */
  8523. void clif_parse_OpenVending(int fd,struct map_session_data *sd) {
  8524. vending_openvending(sd, RFIFOW(fd,2), (char*)RFIFOP(fd,4), RFIFOB(fd,84), RFIFOP(fd,85));
  8525. }
  8526. /*==========================================
  8527. * /monster /item rewriten by [Yor]
  8528. *------------------------------------------
  8529. */
  8530. void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) {
  8531. char monster_item_name[25];
  8532. nullpo_retv(sd);
  8533. memset(monster_item_name, '\0', sizeof(monster_item_name));
  8534. if (battle_config.atc_gmonly == 0 || pc_isGM(sd)) {
  8535. memcpy(monster_item_name, RFIFOP(fd,2), 24);
  8536. if (mobdb_searchname(monster_item_name) != 0) {
  8537. if (pc_isGM(sd) >= get_atcommand_level(AtCommand_Monster))
  8538. atcommand_spawn(fd, sd, "@spawn", monster_item_name); // as @spawn
  8539. } else if (itemdb_searchname(monster_item_name) != NULL) {
  8540. if (pc_isGM(sd) >= get_atcommand_level(AtCommand_Item))
  8541. atcommand_item(fd, sd, "@item", monster_item_name); // as @item
  8542. }
  8543. }
  8544. }
  8545. /*==========================================
  8546. * ギルドを作る
  8547. *------------------------------------------
  8548. */
  8549. void clif_parse_CreateGuild(int fd,struct map_session_data *sd) {
  8550. guild_create(sd, (char*)RFIFOP(fd,6));
  8551. }
  8552. /*==========================================
  8553. * ギルドマスターかどうか確認
  8554. *------------------------------------------
  8555. */
  8556. void clif_parse_GuildCheckMaster(int fd, struct map_session_data *sd) {
  8557. clif_guild_masterormember(sd);
  8558. }
  8559. /*==========================================
  8560. * ギルド情報要求
  8561. *------------------------------------------
  8562. */
  8563. void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd) {
  8564. switch(RFIFOL(fd,2)){
  8565. case 0: // ギルド基本情報、同盟敵対情報
  8566. clif_guild_basicinfo(sd);
  8567. clif_guild_allianceinfo(sd);
  8568. break;
  8569. case 1: // メンバーリスト、役職名リスト
  8570. clif_guild_positionnamelist(sd);
  8571. clif_guild_memberlist(sd);
  8572. break;
  8573. case 2: // 役職名リスト、役職情報リスト
  8574. clif_guild_positionnamelist(sd);
  8575. clif_guild_positioninfolist(sd);
  8576. break;
  8577. case 3: // スキルリスト
  8578. clif_guild_skillinfo(sd);
  8579. break;
  8580. case 4: // 追放リスト
  8581. clif_guild_explusionlist(sd);
  8582. break;
  8583. default:
  8584. if (battle_config.error_log)
  8585. printf("clif: guild request info: unknown type %d\n", RFIFOL(fd,2));
  8586. break;
  8587. }
  8588. }
  8589. /*==========================================
  8590. * ギルド役職変更
  8591. *------------------------------------------
  8592. */
  8593. void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) {
  8594. int i;
  8595. for(i = 4; i < RFIFOW(fd,2); i += 40 ){
  8596. guild_change_position(sd, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), (char*)RFIFOP(fd,i+16));
  8597. }
  8598. }
  8599. /*==========================================
  8600. * ギルドメンバ役職変更
  8601. *------------------------------------------
  8602. */
  8603. void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd) {
  8604. int i;
  8605. nullpo_retv(sd);
  8606. for(i=4;i<RFIFOW(fd,2);i+=12){
  8607. guild_change_memberposition(sd->status.guild_id,
  8608. RFIFOL(fd,i),RFIFOL(fd,i+4),RFIFOL(fd,i+8));
  8609. }
  8610. }
  8611. /*==========================================
  8612. * ギルドエンブレム要求
  8613. *------------------------------------------
  8614. */
  8615. void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd) {
  8616. struct guild *g=guild_search(RFIFOL(fd,2));
  8617. if(g!=NULL)
  8618. clif_guild_emblem(sd,g);
  8619. }
  8620. /*==========================================
  8621. * ギルドエンブレム変更
  8622. *------------------------------------------
  8623. */
  8624. void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd) {
  8625. guild_change_emblem(sd,RFIFOW(fd,2)-4,(char*)RFIFOP(fd,4));
  8626. }
  8627. /*==========================================
  8628. * ギルド告知変更
  8629. *------------------------------------------
  8630. */
  8631. void clif_parse_GuildChangeNotice(int fd,struct map_session_data *sd) {
  8632. guild_change_notice(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6),(char*)RFIFOP(fd,66));
  8633. }
  8634. /*==========================================
  8635. * ギルド勧誘
  8636. *------------------------------------------
  8637. */
  8638. void clif_parse_GuildInvite(int fd,struct map_session_data *sd) {
  8639. guild_invite(sd,RFIFOL(fd,2));
  8640. }
  8641. /*==========================================
  8642. * ギルド勧誘返信
  8643. *------------------------------------------
  8644. */
  8645. void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd) {
  8646. guild_reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6));
  8647. }
  8648. /*==========================================
  8649. * ギルド脱退
  8650. *------------------------------------------
  8651. */
  8652. void clif_parse_GuildLeave(int fd,struct map_session_data *sd) {
  8653. guild_leave(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
  8654. }
  8655. /*==========================================
  8656. * ギルド追放
  8657. *------------------------------------------
  8658. */
  8659. void clif_parse_GuildExplusion(int fd,struct map_session_data *sd) {
  8660. guild_explusion(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
  8661. }
  8662. /*==========================================
  8663. * ギルド会話
  8664. *------------------------------------------
  8665. */
  8666. void clif_parse_GuildMessage(int fd,struct map_session_data *sd) {
  8667. nullpo_retv(sd);
  8668. if (is_charcommand(fd, sd, (char*)RFIFOP(fd, 4), 0) != CharCommand_None ||
  8669. is_atcommand(fd, sd, (char*)RFIFOP(fd, 4), 0) != AtCommand_None ||
  8670. (sd->sc_data &&
  8671. (sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク時は会話も不可
  8672. sd->sc_data[SC_NOCHAT].timer!=-1))) //チャット禁止
  8673. return;
  8674. guild_send_message(sd, (char*)RFIFOP(fd,4), RFIFOW(fd,2)-4);
  8675. }
  8676. /*==========================================
  8677. * ギルド同盟要求
  8678. *------------------------------------------
  8679. */
  8680. void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) {
  8681. guild_reqalliance(sd,RFIFOL(fd,2));
  8682. }
  8683. /*==========================================
  8684. * ギルド同盟要求返信
  8685. *------------------------------------------
  8686. */
  8687. void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd) {
  8688. guild_reply_reqalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
  8689. }
  8690. /*==========================================
  8691. * ギルド関係解消
  8692. *------------------------------------------
  8693. */
  8694. void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) {
  8695. guild_delalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
  8696. }
  8697. /*==========================================
  8698. * ギルド敵対
  8699. *------------------------------------------
  8700. */
  8701. void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) {
  8702. guild_opposition(sd,RFIFOL(fd,2));
  8703. }
  8704. /*==========================================
  8705. * ギルド解散
  8706. *------------------------------------------
  8707. */
  8708. void clif_parse_GuildBreak(int fd, struct map_session_data *sd) {
  8709. guild_break(sd,(char*)RFIFOP(fd,2));
  8710. }
  8711. // pet
  8712. void clif_parse_PetMenu(int fd, struct map_session_data *sd) {
  8713. pet_menu(sd,RFIFOB(fd,2));
  8714. }
  8715. void clif_parse_CatchPet(int fd, struct map_session_data *sd) {
  8716. pet_catch_process2(sd,RFIFOL(fd,2));
  8717. }
  8718. void clif_parse_SelectEgg(int fd, struct map_session_data *sd) {
  8719. pet_select_egg(sd,RFIFOW(fd,2)-2);
  8720. }
  8721. void clif_parse_SendEmotion(int fd, struct map_session_data *sd) {
  8722. nullpo_retv(sd);
  8723. if(sd->pd)
  8724. clif_pet_emotion(sd->pd,RFIFOL(fd,2));
  8725. }
  8726. void clif_parse_ChangePetName(int fd, struct map_session_data *sd) {
  8727. pet_change_name(sd,(char*)RFIFOP(fd,2));
  8728. }
  8729. // Kick (right click menu for GM "(name) force to quit")
  8730. void clif_parse_GMKick(int fd, struct map_session_data *sd) {
  8731. struct block_list *target;
  8732. int tid = RFIFOL(fd,2);
  8733. nullpo_retv(sd);
  8734. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  8735. (pc_isGM(sd) >= get_atcommand_level(AtCommand_Kick))) {
  8736. target = map_id2bl(tid);
  8737. if (target) {
  8738. if (target->type == BL_PC) {
  8739. struct map_session_data *tsd = (struct map_session_data *)target;
  8740. if (pc_isGM(sd) > pc_isGM(tsd))
  8741. clif_GM_kick(sd, tsd, 1);
  8742. else
  8743. clif_GM_kickack(sd, 0);
  8744. } else if (target->type == BL_MOB) {
  8745. struct mob_data *md = (struct mob_data *)target;
  8746. sd->state.attack_type = 0;
  8747. mob_damage(&sd->bl, md, md->hp, 2);
  8748. } else
  8749. clif_GM_kickack(sd, 0);
  8750. } else
  8751. clif_GM_kickack(sd, 0);
  8752. }
  8753. }
  8754. /*==========================================
  8755. * /shift
  8756. *------------------------------------------
  8757. */
  8758. void clif_parse_Shift(int fd, struct map_session_data *sd) { // Rewriten by [Yor]
  8759. char player_name[25];
  8760. nullpo_retv(sd);
  8761. memset(player_name, '\0', sizeof(player_name));
  8762. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  8763. (pc_isGM(sd) >= get_atcommand_level(AtCommand_JumpTo))) {
  8764. memcpy(player_name, RFIFOP(fd,2), 24);
  8765. atcommand_jumpto(fd, sd, "@jumpto", player_name); // as @jumpto
  8766. }
  8767. return;
  8768. }
  8769. /*==========================================
  8770. * /recall
  8771. *------------------------------------------
  8772. */
  8773. void clif_parse_Recall(int fd, struct map_session_data *sd) { // Added by RoVeRT
  8774. char player_name[25];
  8775. nullpo_retv(sd);
  8776. memset(player_name, '\0', sizeof(player_name));
  8777. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  8778. (pc_isGM(sd) >= get_atcommand_level(AtCommand_Recall))) {
  8779. memcpy(player_name, RFIFOP(fd,2), 24);
  8780. atcommand_recall(fd, sd, "@recall", player_name); // as @recall
  8781. }
  8782. return;
  8783. }
  8784. void clif_parse_GMHide(int fd, struct map_session_data *sd) { // Modified by [Yor]
  8785. nullpo_retv(sd);
  8786. //printf("%2x %2x %2x\n", RFIFOW(fd,0), RFIFOW(fd,2), RFIFOW(fd,4)); // R 019d <Option_value>.2B <flag>.2B
  8787. if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
  8788. (pc_isGM(sd) >= get_atcommand_level(AtCommand_Hide))) {
  8789. if (sd->status.option & OPTION_HIDE) { // OPTION_HIDE = 0x40
  8790. sd->status.option &= ~OPTION_HIDE; // OPTION_HIDE = 0x40
  8791. clif_displaymessage(fd, "Invisible: Off.");
  8792. } else {
  8793. sd->status.option |= OPTION_HIDE; // OPTION_HIDE = 0x40
  8794. clif_displaymessage(fd, "Invisible: On.");
  8795. }
  8796. clif_changeoption(&sd->bl);
  8797. }
  8798. }
  8799. /*==========================================
  8800. * GMによるチャット禁止時間付与
  8801. *------------------------------------------
  8802. */
  8803. void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd)
  8804. {
  8805. int tid = RFIFOL(fd,2);
  8806. int type = RFIFOB(fd,6);
  8807. int limit = RFIFOW(fd,7);
  8808. struct block_list *bl = map_id2bl(tid);
  8809. struct map_session_data *dstsd;
  8810. int dstfd;
  8811. nullpo_retv(sd);
  8812. if(!battle_config.muting_players) {
  8813. clif_displaymessage(fd, "Muting is disabled.");
  8814. return;
  8815. }
  8816. if(type == 0)
  8817. limit = 0 - limit;
  8818. if(bl->type == BL_PC && (dstsd =(struct map_session_data *)bl)){
  8819. if((tid == bl->id && type == 2 && !pc_isGM(sd)) || (pc_isGM(sd) > pc_isGM(dstsd)) ){
  8820. dstfd = dstsd->fd;
  8821. WFIFOW(dstfd,0)=0x14b;
  8822. WFIFOB(dstfd,2)=(type==2)?1:type;
  8823. memcpy(WFIFOP(dstfd,3),sd->status.name,24);
  8824. WFIFOSET(dstfd,packet_len_table[0x14b]);
  8825. dstsd->status.manner -= limit;
  8826. if(dstsd->status.manner < 0)
  8827. status_change_start(bl,SC_NOCHAT,0,0,0,0,0,0);
  8828. else{
  8829. dstsd->status.manner = 0;
  8830. status_change_end(bl,SC_NOCHAT,-1);
  8831. }
  8832. printf("name:%s type:%d limit:%d manner:%d\n",dstsd->status.name,type,limit,dstsd->status.manner);
  8833. }
  8834. }
  8835. return;
  8836. }
  8837. /*==========================================
  8838. * GMによるチャット禁止時間参照(?)
  8839. *------------------------------------------
  8840. */
  8841. void clif_parse_GMReqNoChatCount(int fd, struct map_session_data *sd)
  8842. {
  8843. int tid = RFIFOL(fd,2);
  8844. WFIFOW(fd,0) = 0x1e0;
  8845. WFIFOL(fd,2) = tid;
  8846. sprintf((char*)WFIFOP(fd,6),"%d",tid);
  8847. // memcpy(WFIFOP(fd,6), "TESTNAME", 24);
  8848. WFIFOSET(fd, packet_len_table[0x1e0]);
  8849. return;
  8850. }
  8851. void clif_parse_PMIgnore(int fd, struct map_session_data *sd) { // Rewritten by [Yor]
  8852. char output[512];
  8853. char *nick; // S 00cf <nick>.24B <type>.B: 00 (/ex nick) deny speech from nick, 01 (/in nick) allow speech from nick
  8854. int i, pos;
  8855. memset(output, '\0', sizeof(output));
  8856. nick = (char*)RFIFOP(fd,2); // speed up
  8857. RFIFOB(fd,25) = '\0'; // to be sure that the player name have at maximum 23 characters
  8858. //printf("Ignore: char '%s' state: %d\n", nick, RFIFOB(fd,26));
  8859. WFIFOW(fd,0) = 0x0d1; // R 00d1 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
  8860. WFIFOB(fd,2) = RFIFOB(fd,26);
  8861. // do nothing only if nick can not exist
  8862. if (strlen(nick) < 4) {
  8863. WFIFOB(fd,3) = 1; // fail
  8864. WFIFOSET(fd, packet_len_table[0x0d1]);
  8865. if (RFIFOB(fd,26) == 0) // type
  8866. clif_wis_message(fd, wisp_server_name, "It's impossible to block this player.", strlen("It's impossible to block this player.") + 1);
  8867. else
  8868. clif_wis_message(fd, wisp_server_name, "It's impossible to unblock this player.", strlen("It's impossible to unblock this player.") + 1);
  8869. return;
  8870. // name can exist
  8871. } else {
  8872. // deny action (we add nick only if it's not already exist
  8873. if (RFIFOB(fd,26) == 0) { // type
  8874. pos = -1;
  8875. for(i = 0; i < MAX_IGNORE_LIST; i++) {
  8876. if (strcmp(sd->ignore[i].name, nick) == 0) {
  8877. WFIFOB(fd,3) = 1; // fail
  8878. WFIFOSET(fd, packet_len_table[0x0d1]);
  8879. clif_wis_message(fd, wisp_server_name, "This player is already blocked.", strlen("This player is already blocked.") + 1);
  8880. if (strcmp(wisp_server_name, nick) == 0) { // to found possible bot users who automaticaly ignore people.
  8881. 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);
  8882. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output);
  8883. }
  8884. return;
  8885. } else if (pos == -1 && sd->ignore[i].name[0] == '\0')
  8886. pos = i;
  8887. }
  8888. // if a position is found and name not found, we add it in the list
  8889. if (pos != -1) {
  8890. memcpy(sd->ignore[pos].name, nick, 24);
  8891. WFIFOB(fd,3) = 0; // success
  8892. WFIFOSET(fd, packet_len_table[0x0d1]);
  8893. if (strcmp(wisp_server_name, nick) == 0) { // to found possible bot users who automaticaly ignore people.
  8894. 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);
  8895. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output);
  8896. // send something to be inform and force bot to ignore twice... If GM receiving block + block again, it's a bot :)
  8897. 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);
  8898. }
  8899. } else {
  8900. WFIFOB(fd,3) = 1; // fail
  8901. WFIFOSET(fd, packet_len_table[0x0d1]);
  8902. clif_wis_message(fd, wisp_server_name, "You can not block more people.", strlen("You can not block more people.") + 1);
  8903. if (strcmp(wisp_server_name, nick) == 0) { // to found possible bot users who automaticaly ignore people.
  8904. 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);
  8905. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output);
  8906. }
  8907. }
  8908. // allow action (we remove all same nicks if they exist)
  8909. } else {
  8910. pos = -1;
  8911. for(i = 0; i < MAX_IGNORE_LIST; i++)
  8912. if (strcmp(sd->ignore[i].name, nick) == 0) {
  8913. memset(sd->ignore[i].name, 0, sizeof(sd->ignore[i].name));
  8914. if (pos == -1) {
  8915. WFIFOB(fd,3) = 0; // success
  8916. WFIFOSET(fd, packet_len_table[0x0d1]);
  8917. pos = i; // don't break, to remove ALL same nick
  8918. }
  8919. }
  8920. if (pos == -1) {
  8921. WFIFOB(fd,3) = 1; // fail
  8922. WFIFOSET(fd, packet_len_table[0x0d1]);
  8923. clif_wis_message(fd, wisp_server_name, "This player is not blocked by you.", strlen("This player is not blocked by you.") + 1);
  8924. }
  8925. }
  8926. }
  8927. // for(i = 0; i < MAX_IGNORE_LIST; i++) // for debug only
  8928. // if (sd->ignore[i].name[0] != '\0')
  8929. // printf("Ignored player: '%s'\n", sd->ignore[i].name);
  8930. return;
  8931. }
  8932. void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd) { // Rewritten by [Yor]
  8933. //printf("Ignore all: state: %d\n", RFIFOB(fd,2));
  8934. if (RFIFOB(fd,2) == 0) {// S 00d0 <type>len.B: 00 (/exall) deny all speech, 01 (/inall) allow all speech
  8935. WFIFOW(fd,0) = 0x0d2; // R 00d2 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
  8936. WFIFOB(fd,2) = 0;
  8937. if (sd->ignoreAll == 0) {
  8938. sd->ignoreAll = 1;
  8939. WFIFOB(fd,3) = 0; // success
  8940. WFIFOSET(fd, packet_len_table[0x0d2]);
  8941. } else {
  8942. WFIFOB(fd,3) = 1; // fail
  8943. WFIFOSET(fd, packet_len_table[0x0d2]);
  8944. clif_wis_message(fd, wisp_server_name, "You already block everyone.", strlen("You already block everyone.") + 1);
  8945. }
  8946. } else {
  8947. WFIFOW(fd,0) = 0x0d2; // R 00d2 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
  8948. WFIFOB(fd,2) = 1;
  8949. if (sd->ignoreAll == 1) {
  8950. sd->ignoreAll = 0;
  8951. WFIFOB(fd,3) = 0; // success
  8952. WFIFOSET(fd, packet_len_table[0x0d2]);
  8953. } else {
  8954. WFIFOB(fd,3) = 1; // fail
  8955. WFIFOSET(fd, packet_len_table[0x0d2]);
  8956. clif_wis_message(fd, wisp_server_name, "You already allow everyone.", strlen("You already allow everyone.") + 1);
  8957. }
  8958. }
  8959. return;
  8960. }
  8961. /*==========================================
  8962. * Wis拒否リスト
  8963. *------------------------------------------
  8964. */
  8965. int pstrcmp(const void *a, const void *b)
  8966. {
  8967. return strcmp((char *)a, (char *)b);
  8968. }
  8969. void clif_parse_PMIgnoreList(int fd,struct map_session_data *sd)
  8970. {
  8971. int i,j=0,count=0;
  8972. qsort (sd->ignore[0].name, MAX_IGNORE_LIST, sizeof(sd->ignore[0].name), pstrcmp);
  8973. for(i = 0; i < MAX_IGNORE_LIST; i++){ //中身があるのを数える
  8974. if(sd->ignore[i].name[0] != 0)
  8975. count++;
  8976. }
  8977. WFIFOW(fd,0) = 0xd4;
  8978. WFIFOW(fd,2) = 4 + (24 * count);
  8979. for(i = 0; i < MAX_IGNORE_LIST; i++){
  8980. if(sd->ignore[i].name[0] != 0){
  8981. memcpy(WFIFOP(fd, 4 + j * 24),sd->ignore[i].name, 24);
  8982. j++;
  8983. }
  8984. }
  8985. WFIFOSET(fd, WFIFOW(fd,2));
  8986. if(count >= MAX_IGNORE_LIST) //満タンなら最後の1個を消す
  8987. sd->ignore[MAX_IGNORE_LIST - 1].name[0] = 0;
  8988. return;
  8989. }
  8990. void clif_parse_skillMessage(int fd, struct map_session_data *sd) { // Added by RoVeRT
  8991. int skillid,skilllv, x, y;
  8992. char *mes;
  8993. skilllv = RFIFOW(fd,2);
  8994. skillid = RFIFOW(fd,4);
  8995. y = RFIFOB(fd,6);
  8996. x = RFIFOB(fd,8);
  8997. mes = (char*)RFIFOP(fd,10);
  8998. // skill 220 = graffiti
  8999. // printf("skill: %d %d location: %3d %3d message: %s\n", skillid, skilllv, x, y, (char*)mes);
  9000. }
  9001. int monk(struct map_session_data *sd, struct block_list *target, int type) {
  9002. //R 01d1 <Monk id>L <Target monster id>L <Bool>L
  9003. int fd=sd->fd;
  9004. WFIFOW(fd,0)=0x1d1;
  9005. WFIFOL(fd,2)=sd->bl.id;
  9006. WFIFOL(fd,6)=target->id;
  9007. WFIFOL(fd,10)=type;
  9008. WFIFOSET(fd,packet_len_table[0x1d1]);
  9009. return 0;
  9010. }
  9011. /*==========================================
  9012. * スパノビの/doridoriによるSPR2倍
  9013. *------------------------------------------
  9014. */
  9015. void clif_parse_sn_doridori(int fd, struct map_session_data *sd) {
  9016. if (sd)
  9017. sd->doridori_counter = 1;
  9018. return;
  9019. }
  9020. /*==========================================
  9021. * スパノビの爆裂波動
  9022. *------------------------------------------
  9023. */
  9024. void clif_parse_sn_explosionspirits(int fd, struct map_session_data *sd)
  9025. {
  9026. if(sd){
  9027. int nextbaseexp=pc_nextbaseexp(sd);
  9028. struct pc_base_job s_class = pc_calc_base_job(sd->status.class_);
  9029. if (battle_config.etc_log){
  9030. if(nextbaseexp != 0)
  9031. 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));
  9032. else
  9033. printf("SuperNovice explosionspirits!! %d %d %d 000\n",sd->bl.id,s_class.job,sd->status.base_exp);
  9034. }
  9035. if(s_class.job == 23 && sd->status.base_exp > 0 && nextbaseexp > 0 && (int)((double)1000*sd->status.base_exp/nextbaseexp)%100==0){
  9036. clif_skill_nodamage(&sd->bl,&sd->bl,MO_EXPLOSIONSPIRITS,5,1);
  9037. status_change_start(&sd->bl,SkillStatusChangeTable[MO_EXPLOSIONSPIRITS],5,0,0,0,skill_get_time(MO_EXPLOSIONSPIRITS,5),0 );
  9038. }
  9039. }
  9040. return;
  9041. }
  9042. /*==========================================
  9043. * Friends List
  9044. *------------------------------------------
  9045. */
  9046. void clif_friends_list_send(struct map_session_data *sd) {
  9047. int i, n;
  9048. // Send friends list
  9049. n = 0;
  9050. WFIFOW(sd->fd, 0) = 0x201;
  9051. for(i = 0; i < 20; i++)
  9052. if (sd->status.friend_id[i]) {
  9053. WFIFOL(sd->fd,4 + 32 * n + 1) = sd->status.friend_id[i];
  9054. //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.
  9055. memcpy(WFIFOP(sd->fd,4 + 32 * n + 8), &sd->status.friend_name[i], 23);
  9056. n++;
  9057. }
  9058. WFIFOW(sd->fd,2) = 4 + 32 * n;
  9059. WFIFOSET(sd->fd, WFIFOW(sd->fd,2));
  9060. }
  9061. void clif_parse_friends_list_add(int fd, struct map_session_data *sd) {
  9062. struct map_session_data *f_sd;
  9063. int i;
  9064. f_sd = map_nick2sd((char*)RFIFOP(fd,2));
  9065. // Friend doesn't exist (no player with this name)
  9066. if (f_sd == NULL) {
  9067. clif_displaymessage(fd, "This name (for a friend) doesn't exist.");
  9068. return;
  9069. }
  9070. // Friend already exists
  9071. for (i = 0; i < 20; i++)
  9072. if (sd->status.friend_id[i] == f_sd->status.char_id) {
  9073. clif_displaymessage(fd, "Friend already exists.");
  9074. return;
  9075. }
  9076. // Find an empty slot
  9077. for (i = 0; i < 20; i++)
  9078. if (sd->status.friend_id[i] == 0)
  9079. break;
  9080. if (i == 20) {
  9081. clif_displaymessage(fd, "Friends list is full.");
  9082. return;
  9083. }
  9084. sd->status.friend_id[i] = f_sd->status.char_id;
  9085. memset(sd->status.friend_name[i], 0, sizeof(sd->status.friend_name[i]));
  9086. memcpy(sd->status.friend_name[i], f_sd->status.name, 23);
  9087. clif_displaymessage(fd, "Friend added.");
  9088. clif_friends_list_send(sd);
  9089. //printf("clif_parse_friends_list_add");
  9090. return;
  9091. }
  9092. void clif_parse_friends_list_remove(int fd, struct map_session_data *sd) {
  9093. // 0x203 </o> <ID to be removed W 4B>
  9094. int id = RFIFOL(fd,3);
  9095. int i, j;
  9096. // Search friend
  9097. for (i = 0; i < 20; i ++)
  9098. if (sd->status.friend_id[i] == id) {
  9099. // move all chars down
  9100. for(j = i + 1; j < 20; j++) {
  9101. sd->status.friend_id[j-1] = sd->status.friend_id[j];
  9102. memcpy(sd->status.friend_name[j-1], sd->status.friend_name[j], sizeof(sd->status.friend_name[j]));
  9103. }
  9104. sd->status.friend_id[19] = 0;
  9105. memset(sd->status.friend_name[19], 0, sizeof(sd->status.friend_name[19]));
  9106. clif_displaymessage(fd, "Friend removed");
  9107. clif_friends_list_send(sd);
  9108. break;
  9109. }
  9110. if (i == 20)
  9111. clif_displaymessage(fd, "Name not found in list.");
  9112. return;
  9113. }
  9114. /*==========================================
  9115. * /killall
  9116. *------------------------------------------
  9117. */
  9118. void clif_parse_GMkillall(int fd,struct map_session_data *sd)
  9119. {
  9120. char message[50];
  9121. nullpo_retv(sd);
  9122. strncpy(message,sd->status.name, 24);
  9123. is_atcommand(fd, sd, strcat(message," : @kickall"),0);
  9124. return;
  9125. }
  9126. /*==========================================
  9127. * パケットデバッグ
  9128. *------------------------------------------
  9129. */
  9130. void clif_parse_debug(int fd,struct map_session_data *sd)
  9131. {
  9132. int i, cmd;
  9133. cmd = RFIFOW(fd,0);
  9134. printf("packet debug 0x%4X\n",cmd);
  9135. printf("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
  9136. for(i=0;i<packet_db[sd->packet_ver][cmd].len;i++){
  9137. if((i&15)==0)
  9138. printf("\n%04X ",i);
  9139. printf("%02X ",RFIFOB(fd,i));
  9140. }
  9141. printf("\n");
  9142. }
  9143. // functions list
  9144. static void (*clif_parse_func_table[MAX_PACKET_DB])(int, struct map_session_data *) = {
  9145. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9146. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9147. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9148. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9149. // 40
  9150. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9151. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9152. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9153. // 70
  9154. NULL, NULL, clif_parse_WantToConnection, NULL, NULL, NULL, NULL, NULL,
  9155. NULL, NULL, NULL, NULL, NULL, clif_parse_LoadEndAck, clif_parse_TickSend, NULL,
  9156. // 80
  9157. NULL, NULL, NULL, NULL, NULL, clif_parse_WalkToXY, NULL, NULL,
  9158. NULL, clif_parse_ActionRequest, NULL, NULL, clif_parse_GlobalMessage, NULL, NULL, NULL,
  9159. // 90
  9160. clif_parse_NpcClicked, NULL, NULL, NULL, clif_parse_GetCharNameRequest, NULL, clif_parse_Wis, NULL,
  9161. NULL, clif_parse_GMmessage, NULL, clif_parse_ChangeDir, NULL, NULL, NULL, clif_parse_TakeItem,
  9162. // a0
  9163. NULL, NULL, clif_parse_DropItem, NULL, NULL, NULL, NULL, clif_parse_UseItem,
  9164. NULL, clif_parse_EquipItem, NULL, clif_parse_UnequipItem, NULL, NULL, NULL, NULL,
  9165. // b0
  9166. NULL, NULL, clif_parse_Restart, NULL, NULL, NULL, NULL, NULL,
  9167. clif_parse_NpcSelectMenu, clif_parse_NpcNextClicked, NULL, clif_parse_StatusUp, NULL, NULL, NULL, clif_parse_Emotion,
  9168. // c0
  9169. NULL, clif_parse_HowManyConnections, NULL, NULL, NULL, clif_parse_NpcBuySellSelected, NULL, NULL,
  9170. clif_parse_NpcBuyListSend, clif_parse_NpcSellListSend, NULL, NULL, clif_parse_GMKick, NULL, clif_parse_GMkillall, clif_parse_PMIgnore,
  9171. // d0
  9172. clif_parse_PMIgnoreAll, NULL, NULL, clif_parse_PMIgnoreList, NULL, clif_parse_CreateChatRoom, NULL, NULL,
  9173. NULL, clif_parse_ChatAddMember, NULL, NULL, NULL, NULL, clif_parse_ChatRoomStatusChange, NULL,
  9174. // e0
  9175. clif_parse_ChangeChatOwner, NULL, clif_parse_KickFromChat, clif_parse_ChatLeave, clif_parse_TradeRequest, NULL, clif_parse_TradeAck, NULL,
  9176. clif_parse_TradeAddItem, NULL, NULL, clif_parse_TradeOk, NULL, clif_parse_TradeCancel, NULL, clif_parse_TradeCommit,
  9177. // f0
  9178. NULL, NULL, NULL, clif_parse_MoveToKafra, NULL, clif_parse_MoveFromKafra, NULL, clif_parse_CloseKafra,
  9179. NULL, clif_parse_CreateParty, NULL, NULL, clif_parse_PartyInvite, NULL, NULL, clif_parse_ReplyPartyInvite,
  9180. // 100
  9181. clif_parse_LeaveParty, NULL, clif_parse_PartyChangeOption, clif_parse_RemovePartyMember, NULL, NULL, NULL, NULL,
  9182. clif_parse_PartyMessage, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9183. // 110
  9184. NULL, NULL, clif_parse_SkillUp, clif_parse_UseSkillToId, NULL, NULL, clif_parse_UseSkillToPos, NULL,
  9185. clif_parse_StopAttack, NULL, NULL, clif_parse_UseSkillMap, NULL, clif_parse_RequestMemo, NULL, NULL,
  9186. // 120
  9187. NULL, NULL, NULL, NULL, NULL, NULL, clif_parse_PutItemToCart, clif_parse_GetItemFromCart,
  9188. clif_parse_MoveFromKafraToCart, clif_parse_MoveToKafraFromCart, clif_parse_RemoveOption, NULL, NULL, NULL, clif_parse_CloseVending, NULL,
  9189. // 130
  9190. clif_parse_VendingListReq, NULL, NULL, NULL, clif_parse_PurchaseReq, NULL, NULL, NULL,
  9191. NULL, NULL, NULL, NULL, NULL, NULL, NULL, clif_parse_GM_Monster_Item,
  9192. // 140
  9193. clif_parse_MapMove, NULL, NULL, clif_parse_NpcAmountInput, NULL, NULL, clif_parse_NpcCloseClicked, NULL,
  9194. NULL, clif_parse_GMReqNoChat, NULL, NULL, NULL, clif_parse_GuildCheckMaster, NULL, clif_parse_GuildRequestInfo,
  9195. // 150
  9196. NULL, clif_parse_GuildRequestEmblem, NULL, clif_parse_GuildChangeEmblem, NULL, clif_parse_GuildChangeMemberPosition, NULL, NULL,
  9197. NULL, clif_parse_GuildLeave, NULL, clif_parse_GuildExplusion, NULL, clif_parse_GuildBreak, NULL, NULL,
  9198. // 160
  9199. NULL, clif_parse_GuildChangePositionInfo, NULL, NULL, NULL, clif_parse_CreateGuild, NULL, NULL,
  9200. clif_parse_GuildInvite, NULL, NULL, clif_parse_GuildReplyInvite, NULL, NULL, clif_parse_GuildChangeNotice, NULL,
  9201. // 170
  9202. clif_parse_GuildRequestAlliance, NULL, clif_parse_GuildReplyAlliance, NULL, NULL, NULL, NULL, NULL,
  9203. clif_parse_ItemIdentify, NULL, clif_parse_UseCard, NULL, clif_parse_InsertCard, NULL, clif_parse_GuildMessage, NULL,
  9204. // 180
  9205. clif_parse_GuildOpposition, NULL, NULL, clif_parse_GuildDelAlliance, NULL, NULL, NULL, NULL,
  9206. NULL, NULL, clif_parse_QuitGame, NULL, NULL, NULL, clif_parse_ProduceMix, NULL,
  9207. // 190
  9208. clif_parse_UseSkillToPos, NULL, NULL, clif_parse_SolveCharName, NULL, NULL, NULL, clif_parse_ResetChar,
  9209. NULL, NULL, NULL, NULL, clif_parse_LGMmessage, clif_parse_GMHide, NULL, clif_parse_CatchPet,
  9210. // 1a0
  9211. NULL, clif_parse_PetMenu, NULL, NULL, NULL, clif_parse_ChangePetName, NULL, clif_parse_SelectEgg,
  9212. NULL, clif_parse_SendEmotion, NULL, NULL, NULL, NULL, clif_parse_SelectArrow, clif_parse_ChangeCart,
  9213. // 1b0
  9214. NULL, NULL, clif_parse_OpenVending, NULL, NULL, NULL, NULL, NULL,
  9215. NULL, NULL, clif_parse_Shift, clif_parse_Shift, clif_parse_Recall, clif_parse_Recall, NULL, NULL,
  9216. // 1c0
  9217. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9218. NULL, NULL, NULL, NULL, NULL, NULL, clif_parse_AutoSpell,
  9219. NULL,
  9220. // 1d0
  9221. NULL, NULL, NULL, NULL, NULL, clif_parse_NpcStringInput, NULL, NULL,
  9222. NULL, NULL, NULL, NULL, NULL, NULL, NULL, clif_parse_GMReqNoChatCount,
  9223. // 1e0
  9224. NULL, NULL, NULL, NULL, NULL, NULL, NULL, clif_parse_sn_doridori,
  9225. clif_parse_CreateParty2, NULL, NULL, NULL, NULL, clif_parse_sn_explosionspirits, NULL, NULL,
  9226. // 1f0
  9227. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, clif_parse_ReqAdopt,
  9228. NULL, NULL, NULL, NULL, NULL, NULL,
  9229. // 200
  9230. NULL, NULL, clif_parse_friends_list_add, clif_parse_friends_list_remove, NULL, NULL, NULL, NULL,
  9231. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9232. // 210
  9233. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  9234. #if 0
  9235. case 0xd3: clif_parse_IgnoreList
  9236. #endif
  9237. };
  9238. /*==========================================
  9239. * クライアントからのパケット解析
  9240. * socket.cのdo_parsepacketから呼び出される
  9241. *------------------------------------------
  9242. */
  9243. static int clif_parse(int fd) {
  9244. int packet_len = 0, cmd, packet_ver, dump = 0;
  9245. struct map_session_data *sd;
  9246. sd = (struct map_session_data*)session[fd]->session_data;
  9247. // 接続が切れてるので後始末
  9248. if (!chrif_isconnect() || session[fd]->eof) { // char鯖に繋がってない間は接続禁止 (!chrif_isconnect())
  9249. if (sd && sd->state.auth) {
  9250. clif_quitsave(fd, sd); // the function doesn't send to inter-server/char-server if it is not connected [Yor]
  9251. if (sd->status.name != NULL)
  9252. sprintf(tmp_output,"%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off.\n", (pc_isGM(sd))?"GM ":"",sd->status.name); // Player logout display [Valaris]
  9253. else
  9254. 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]
  9255. } else if (sd) { // not authentified! (refused by char-server or disconnect before to be authentified)
  9256. sprintf(tmp_output,"Player not authenticated with Account ID '"CL_WHITE"%d"CL_RESET"' logged off.\n", sd->bl.id); // Player logout display [Yor]
  9257. // if (chrif_isconnect())
  9258. // clif_quitsave(fd, sd);
  9259. map_deliddb(&sd->bl); // account_id has been included in the DB before auth answer [Yor]
  9260. // sd = 0;
  9261. } else {
  9262. unsigned char *ip = (unsigned char *) &session[fd]->client_addr.sin_addr;
  9263. 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]);
  9264. }
  9265. ShowInfo(tmp_output);
  9266. close(fd);
  9267. // if (sd) // 追加
  9268. // map_deliddb(&sd->bl); // 追加
  9269. delete_session(fd);
  9270. return 0;
  9271. }
  9272. if (RFIFOREST(fd) < 2)
  9273. return 0;
  9274. // printf("clif_parse: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
  9275. cmd = RFIFOW(fd,0);
  9276. // 管理用パケット処理
  9277. if (cmd >= 30000) {
  9278. switch(cmd) {
  9279. case 0x7530: // Athena情報所得
  9280. WFIFOW(fd,0) = 0x7531;
  9281. WFIFOB(fd,2) = ATHENA_MAJOR_VERSION;
  9282. WFIFOB(fd,3) = ATHENA_MINOR_VERSION;
  9283. WFIFOB(fd,4) = ATHENA_REVISION;
  9284. WFIFOB(fd,5) = ATHENA_RELEASE_FLAG;
  9285. WFIFOB(fd,6) = ATHENA_OFFICIAL_FLAG;
  9286. WFIFOB(fd,7) = ATHENA_SERVER_MAP;
  9287. WFIFOW(fd,8) = ATHENA_MOD_VERSION;
  9288. WFIFOSET(fd,10);
  9289. RFIFOSKIP(fd,2);
  9290. break;
  9291. case 0x7532: // 接続の切断
  9292. close(fd);
  9293. session[fd]->eof=1;
  9294. break;
  9295. }
  9296. return 0;
  9297. }
  9298. // get packet version before to parse
  9299. packet_ver = 0;
  9300. if (sd)
  9301. packet_ver = sd->packet_ver;
  9302. // check authentification packet to know packet version
  9303. else {
  9304. // packet DB
  9305. if (IS_PACKET_DB_VER (cmd)) {
  9306. if (RFIFOREST(fd) >= packet_db[clif_config.packet_db_ver][cmd].len &&
  9307. (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[4]) == 0 ||
  9308. RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[4]) == 1)) {// 00 = Female, 01 = Male
  9309. packet_ver = clif_config.packet_db_ver;
  9310. }
  9311. // 0x72
  9312. } else if (cmd == 0x72) {
  9313. if (RFIFOREST(fd) >= 39 && (RFIFOB(fd,38) == 0 || RFIFOB(fd,38) == 1)) // 00 = Female, 01 = Male
  9314. packet_ver = 7; // 7: 13july04
  9315. else if (RFIFOREST(fd) >= 22 && (RFIFOB(fd,21) == 0 || RFIFOB(fd,21) == 1)) // 00 = Female, 01 = Male
  9316. packet_ver = 6; // 6: 7july04
  9317. else if (RFIFOREST(fd) >= 19 && (RFIFOB(fd,18) == 0 || RFIFOB(fd,18) == 1)) // 00 = Female, 01 = Male
  9318. packet_ver = 5; // 5: old
  9319. // else probably incomplete packet
  9320. else if (RFIFOREST(fd) < 19)
  9321. return 0;
  9322. // 0x7E
  9323. } else if (cmd == 0x7E) {
  9324. if (RFIFOREST(fd) >= 37 && (RFIFOB(fd,36) == 0 || RFIFOB(fd,36) == 1)) // 00 = Female, 01 = Male
  9325. packet_ver = 9; // 9: 9aug04/16aug04/17aug04
  9326. else if (RFIFOREST(fd) >= 33 && (RFIFOB(fd,32) == 0 || RFIFOB(fd,32) == 1)) // 00 = Female, 01 = Male
  9327. packet_ver = 8; // 8: 26july04
  9328. // else probably incomplete packet
  9329. else if (RFIFOREST(fd) < 33)
  9330. return 0;
  9331. // 0xF5
  9332. } else if (cmd == 0xF5) {
  9333. if (RFIFOREST(fd) >= 34 && (RFIFOB(fd,33) == 0 || RFIFOB(fd,33) == 1)) // 00 = Female, 01 = Male
  9334. packet_ver = 10; // 10: 6sept04
  9335. else if (RFIFOREST(fd) >= 33 && (RFIFOB(fd,32) == 0 || RFIFOB(fd,32) == 1)) // 00 = Female, 01 = Male
  9336. packet_ver = 12; // 12: 18oct04
  9337. else if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) // 00 = Female, 01 = Male
  9338. packet_ver = 11; // 11: 21sept04
  9339. else if (RFIFOREST(fd) >= 29 && (RFIFOB(fd,28) == 0 || RFIFOB(fd,28) == 1)) { // 00 = Female, 01 = Male
  9340. if (RFIFOL(fd,3) > 700000 && RFIFOL(fd,10) >= 150000 && RFIFOL(fd,10) < 5000000) // account id / char id (more than 5.000.000 characters?) [Yor]
  9341. packet_ver = 15; // 14: 6dec04
  9342. else
  9343. packet_ver = 13; // 13: 25oct04 (by [Yor])
  9344. }
  9345. // else probably incomplete packet
  9346. else if (RFIFOREST(fd) < 29)
  9347. return 0;
  9348. // 0x9B
  9349. } else if (cmd == 0x9B) {
  9350. if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) // 00 = Female, 01 = Male
  9351. packet_ver = 16; // 16: 10jan05
  9352. else if (RFIFOREST(fd) < 32)
  9353. return 0;
  9354. } else {
  9355. // unknown client? leave packet ver as 0 so it'll disconnect anyway
  9356. }
  9357. // check if version is accepted
  9358. if (packet_ver < 5 || // reject really old client versions
  9359. (packet_ver <= 9 && (battle_config.packet_ver_flag & 1) == 0) || // older than 6sept04
  9360. (packet_ver == 10 && (battle_config.packet_ver_flag & 2) == 0) ||
  9361. (packet_ver == 11 && (battle_config.packet_ver_flag & 4) == 0) ||
  9362. (packet_ver == 12 && (battle_config.packet_ver_flag & 8) == 0) ||
  9363. (packet_ver == 13 && (battle_config.packet_ver_flag & 16) == 0) ||
  9364. (packet_ver == 14 && (battle_config.packet_ver_flag & 32) == 0) ||
  9365. (packet_ver == 15 && (battle_config.packet_ver_flag & 64) == 0) ||
  9366. (packet_ver == 16 && (battle_config.packet_ver_flag & 128) == 0) ||
  9367. packet_ver > MAX_PACKET_VER || // no packet version support yet
  9368. // identified version, but unknown client?
  9369. (!sd && packet_db[packet_ver][cmd].func != clif_parse_WantToConnection)) {
  9370. WFIFOW(fd,0) = 0x6a;
  9371. WFIFOB(fd,2) = 5; // 05 = Game's EXE is not the latest version
  9372. WFIFOSET(fd,23);
  9373. clif_setwaitclose(fd);
  9374. return 0;
  9375. }
  9376. }
  9377. // ゲーム用以外パケットか、認証を終える前に0072以外が来たら、切断する
  9378. 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
  9379. if (!fd)
  9380. return 0;
  9381. close(fd);
  9382. session[fd]->eof = 1;
  9383. printf("clif_parse: session #%d, packet 0x%x (%d bytes received) -> disconnected.\n", fd, cmd, RFIFOREST(fd));
  9384. return 0;
  9385. }
  9386. // パケット長を計算
  9387. packet_len = packet_db[packet_ver][cmd].len;
  9388. if (packet_len == -1) {
  9389. if (RFIFOREST(fd) < 4)
  9390. return 0; // 可変長パケットで長さの所までデータが来てない
  9391. packet_len = RFIFOW(fd,2);
  9392. if (packet_len < 4 || packet_len > 32768) {
  9393. close(fd);
  9394. session[fd]->eof =1;
  9395. return 0;
  9396. }
  9397. }
  9398. if (RFIFOREST(fd) < packet_len)
  9399. return 0; // まだ1パケット分データが揃ってない
  9400. #if DUMP_ALL_PACKETS
  9401. dump = 1;
  9402. #endif
  9403. if (sd && sd->state.auth == 1 && sd->state.waitingdisconnect == 1) { // 切断待ちの場合パケットを処理しない
  9404. } else if (packet_db[packet_ver][cmd].func) { // packet version 5-6-7 use same functions, but size are different
  9405. // パケット処理
  9406. packet_db[packet_ver][cmd].func(fd, sd);
  9407. } else {
  9408. // 不明なパケット
  9409. if (battle_config.error_log) {
  9410. #if DUMP_UNKNOWN_PACKET
  9411. {
  9412. int i;
  9413. FILE *fp;
  9414. char packet_txt[256] = "save/packet.txt";
  9415. time_t now;
  9416. dump = 1;
  9417. if ((fp = fopen(packet_txt, "a")) == NULL) {
  9418. printf("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt);
  9419. return 1;
  9420. } else {
  9421. time(&now);
  9422. if (sd && sd->state.auth) {
  9423. if (sd->status.name != NULL)
  9424. fprintf(fp, "%sPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n",
  9425. asctime(localtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name);
  9426. else
  9427. fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
  9428. } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
  9429. fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
  9430. fprintf(fp, "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
  9431. for(i = 0; i < packet_len; i++) {
  9432. if ((i & 15) == 0)
  9433. fprintf(fp, "\n\t%04X ", i);
  9434. fprintf(fp, "%02X ", RFIFOB(fd,i));
  9435. }
  9436. fprintf(fp, "\n\n");
  9437. fclose(fp);
  9438. }
  9439. }
  9440. #endif
  9441. }
  9442. }
  9443. if (dump) {
  9444. int i;
  9445. if (fd)
  9446. printf("\nclif_parse: session #%d, packet 0x%x, lenght %d\n", fd, cmd, packet_len);
  9447. printf("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
  9448. for(i = 0; i < packet_len; i++) {
  9449. if ((i & 15) == 0)
  9450. printf("\n%04X ",i);
  9451. printf("%02X ", RFIFOB(fd,i));
  9452. }
  9453. if (sd && sd->state.auth) {
  9454. if (sd->status.name != NULL)
  9455. printf("\nAccount ID %d, character ID %d, player name %s.\n",
  9456. sd->status.account_id, sd->status.char_id, sd->status.name);
  9457. else
  9458. printf("\nAccount ID %d.\n", sd->bl.id);
  9459. } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
  9460. printf("\nAccount ID %d.\n", sd->bl.id);
  9461. }
  9462. RFIFOSKIP(fd, packet_len);
  9463. return 0;
  9464. }
  9465. /*==========================================
  9466. * パケットデータベース読み込み
  9467. *------------------------------------------
  9468. */
  9469. static int packetdb_readdb(void)
  9470. {
  9471. FILE *fp;
  9472. char line[1024];
  9473. int ln=0;
  9474. int cmd,j,k,packet_ver;
  9475. char *str[32],*p,*str2[32],*p2,w1[24],w2[24];
  9476. struct {
  9477. void (*func)(int, struct map_session_data *);
  9478. char *name;
  9479. } clif_parse_func[]={
  9480. {clif_parse_WantToConnection,"wanttoconnection"},
  9481. {clif_parse_LoadEndAck,"loadendack"},
  9482. {clif_parse_TickSend,"ticksend"},
  9483. {clif_parse_WalkToXY,"walktoxy"},
  9484. {clif_parse_QuitGame,"quitgame"},
  9485. {clif_parse_GetCharNameRequest,"getcharnamerequest"},
  9486. {clif_parse_GlobalMessage,"globalmessage"},
  9487. {clif_parse_MapMove,"mapmove"},
  9488. {clif_parse_ChangeDir,"changedir"},
  9489. {clif_parse_Emotion,"emotion"},
  9490. {clif_parse_HowManyConnections,"howmanyconnections"},
  9491. {clif_parse_ActionRequest,"actionrequest"},
  9492. {clif_parse_Restart,"restart"},
  9493. {clif_parse_Wis,"wis"},
  9494. {clif_parse_GMmessage,"gmmessage"},
  9495. {clif_parse_TakeItem,"takeitem"},
  9496. {clif_parse_DropItem,"dropitem"},
  9497. {clif_parse_UseItem,"useitem"},
  9498. {clif_parse_EquipItem,"equipitem"},
  9499. {clif_parse_UnequipItem,"unequipitem"},
  9500. {clif_parse_NpcClicked,"npcclicked"},
  9501. {clif_parse_NpcBuySellSelected,"npcbuysellselected"},
  9502. {clif_parse_NpcBuyListSend,"npcbuylistsend"},
  9503. {clif_parse_NpcSellListSend,"npcselllistsend"},
  9504. {clif_parse_CreateChatRoom,"createchatroom"},
  9505. {clif_parse_ChatAddMember,"chataddmember"},
  9506. {clif_parse_ChatRoomStatusChange,"chatroomstatuschange"},
  9507. {clif_parse_ChangeChatOwner,"changechatowner"},
  9508. {clif_parse_KickFromChat,"kickfromchat"},
  9509. {clif_parse_ChatLeave,"chatleave"},
  9510. {clif_parse_TradeRequest,"traderequest"},
  9511. {clif_parse_TradeAck,"tradeack"},
  9512. {clif_parse_TradeAddItem,"tradeadditem"},
  9513. {clif_parse_TradeOk,"tradeok"},
  9514. {clif_parse_TradeCancel,"tradecancel"},
  9515. {clif_parse_TradeCommit,"tradecommit"},
  9516. {clif_parse_StopAttack,"stopattack"},
  9517. {clif_parse_PutItemToCart,"putitemtocart"},
  9518. {clif_parse_GetItemFromCart,"getitemfromcart"},
  9519. {clif_parse_RemoveOption,"removeoption"},
  9520. {clif_parse_ChangeCart,"changecart"},
  9521. {clif_parse_StatusUp,"statusup"},
  9522. {clif_parse_SkillUp,"skillup"},
  9523. {clif_parse_UseSkillToId,"useskilltoid"},
  9524. {clif_parse_UseSkillToPos,"useskilltopos"},
  9525. {clif_parse_UseSkillMap,"useskillmap"},
  9526. {clif_parse_RequestMemo,"requestmemo"},
  9527. {clif_parse_ProduceMix,"producemix"},
  9528. {clif_parse_NpcSelectMenu,"npcselectmenu"},
  9529. {clif_parse_NpcNextClicked,"npcnextclicked"},
  9530. {clif_parse_NpcAmountInput,"npcamountinput"},
  9531. {clif_parse_NpcStringInput,"npcstringinput"},
  9532. {clif_parse_NpcCloseClicked,"npccloseclicked"},
  9533. {clif_parse_ItemIdentify,"itemidentify"},
  9534. {clif_parse_SelectArrow,"selectarrow"},
  9535. {clif_parse_AutoSpell,"autospell"},
  9536. {clif_parse_UseCard,"usecard"},
  9537. {clif_parse_InsertCard,"insertcard"},
  9538. {clif_parse_SolveCharName,"solvecharname"},
  9539. {clif_parse_ResetChar,"resetchar"},
  9540. {clif_parse_LGMmessage,"lgmmessage"},
  9541. {clif_parse_MoveToKafra,"movetokafra"},
  9542. {clif_parse_MoveFromKafra,"movefromkafra"},
  9543. {clif_parse_MoveToKafraFromCart,"movetokafrafromcart"},
  9544. {clif_parse_MoveFromKafraToCart,"movefromkafratocart"},
  9545. {clif_parse_CloseKafra,"closekafra"},
  9546. {clif_parse_CreateParty,"createparty"},
  9547. {clif_parse_CreateParty2,"createparty2"},
  9548. {clif_parse_PartyInvite,"partyinvite"},
  9549. {clif_parse_ReplyPartyInvite,"replypartyinvite"},
  9550. {clif_parse_LeaveParty,"leaveparty"},
  9551. {clif_parse_RemovePartyMember,"removepartymember"},
  9552. {clif_parse_PartyChangeOption,"partychangeoption"},
  9553. {clif_parse_PartyMessage,"partymessage"},
  9554. {clif_parse_CloseVending,"closevending"},
  9555. {clif_parse_VendingListReq,"vendinglistreq"},
  9556. {clif_parse_PurchaseReq,"purchasereq"},
  9557. {clif_parse_OpenVending,"openvending"},
  9558. {clif_parse_CreateGuild,"createguild"},
  9559. {clif_parse_GuildCheckMaster,"guildcheckmaster"},
  9560. {clif_parse_GuildRequestInfo,"guildrequestinfo"},
  9561. {clif_parse_GuildChangePositionInfo,"guildchangepositioninfo"},
  9562. {clif_parse_GuildChangeMemberPosition,"guildchangememberposition"},
  9563. {clif_parse_GuildRequestEmblem,"guildrequestemblem"},
  9564. {clif_parse_GuildChangeEmblem,"guildchangeemblem"},
  9565. {clif_parse_GuildChangeNotice,"guildchangenotice"},
  9566. {clif_parse_GuildInvite,"guildinvite"},
  9567. {clif_parse_GuildReplyInvite,"guildreplyinvite"},
  9568. {clif_parse_GuildLeave,"guildleave"},
  9569. {clif_parse_GuildExplusion,"guildexplusion"},
  9570. {clif_parse_GuildMessage,"guildmessage"},
  9571. {clif_parse_GuildRequestAlliance,"guildrequestalliance"},
  9572. {clif_parse_GuildReplyAlliance,"guildreplyalliance"},
  9573. {clif_parse_GuildDelAlliance,"guilddelalliance"},
  9574. {clif_parse_GuildOpposition,"guildopposition"},
  9575. {clif_parse_GuildBreak,"guildbreak"},
  9576. {clif_parse_PetMenu,"petmenu"},
  9577. {clif_parse_CatchPet,"catchpet"},
  9578. {clif_parse_SelectEgg,"selectegg"},
  9579. {clif_parse_SendEmotion,"sendemotion"},
  9580. {clif_parse_ChangePetName,"changepetname"},
  9581. {clif_parse_GMKick,"gmkick"},
  9582. {clif_parse_GMHide,"gmhide"},
  9583. {clif_parse_GMReqNoChat,"gmreqnochat"},
  9584. {clif_parse_GMReqNoChatCount,"gmreqnochatcount"},
  9585. {clif_parse_sn_doridori,"sndoridori"},
  9586. {clif_parse_sn_explosionspirits,"snexplosionspirits"},
  9587. {clif_parse_PMIgnore,"wisexin"},
  9588. {clif_parse_PMIgnoreList,"wisexlist"},
  9589. {clif_parse_PMIgnoreAll,"wisall"},
  9590. {clif_parse_friends_list_add,"friendslistadd"},
  9591. {clif_parse_friends_list_remove,"friendslistremove"},
  9592. {clif_parse_GMkillall,"killall"},
  9593. {clif_parse_GM_Monster_Item,"summon"},
  9594. {clif_parse_Shift,"shift"},
  9595. {clif_parse_debug,"debug"},
  9596. {NULL,NULL}
  9597. };
  9598. if( (fp=fopen("db/packet_db.txt","r"))==NULL ){
  9599. printf("can't read db/packet_db.txt\n");
  9600. return 1;
  9601. }
  9602. clif_config.packet_db_ver = MAX_PACKET_VER;
  9603. packet_ver = MAX_PACKET_VER; // read into packet_db's version by default
  9604. while(fgets(line,1020,fp)){
  9605. if(line[0]=='/' && line[1]=='/')
  9606. continue;
  9607. if (sscanf(line,"%[^:]: %[^\r\n]",w1,w2) == 2) {
  9608. if(strcmpi(w1,"packet_ver")==0) {
  9609. packet_ver = atoi(w2);
  9610. // copy from previous version into new version and continue
  9611. // - indicating all following packets should be read into the newer version
  9612. // -- on 2nd thought, rereading everything isn't the best thing to do...
  9613. // memcpy(&packet_db[packet_ver], &packet_db[packet_ver - 1], sizeof(packet_db[0]));
  9614. continue;
  9615. } else if(strcmpi(w1,"packet_db_ver")==0) {
  9616. // optional: if you do not wish to read multiple versions from the packet_db,
  9617. // remove all "packet_ver: ##" lines, and define the packet DB version with this
  9618. if(strcmpi(w2,"default")==0)
  9619. clif_config.packet_db_ver = MAX_PACKET_VER;
  9620. else {
  9621. // to manually set the packet DB version
  9622. clif_config.packet_db_ver = atoi(w2);
  9623. // check for invalid version
  9624. if (clif_config.packet_db_ver > MAX_PACKET_VER ||
  9625. clif_config.packet_db_ver < 0)
  9626. clif_config.packet_db_ver = MAX_PACKET_VER;
  9627. }
  9628. continue;
  9629. } else if(strcmpi(w1,"enable_packet_db")==0) {
  9630. // whether we want to allow identifying clients via the packet DB
  9631. clif_config.enable_packet_db = battle_config_switch(w2);
  9632. // if we don't want to read the packet DB, and use hardcoded values only
  9633. if (!clif_config.enable_packet_db)
  9634. return 0;
  9635. continue;
  9636. } else if(strcmpi(w1,"prefer_packet_db")==0) {
  9637. // whether the packet DB takes higher precedence over the hardcoded one (type 1)
  9638. // and whether to overwrite predefined packet length and functions when reading
  9639. // from the DB (type 2)
  9640. clif_config.prefer_packet_db = battle_config_switch(w2); // not used for now
  9641. continue;
  9642. }
  9643. }
  9644. memset(str,0,sizeof(str));
  9645. for(j=0,p=line;j<4 && p;j++){
  9646. str[j]=p;
  9647. p=strchr(p,',');
  9648. if(p) *p++=0;
  9649. }
  9650. if(str[0]==NULL)
  9651. continue;
  9652. cmd=strtol(str[0],(char **)NULL,0);
  9653. if(cmd<=0 || cmd>=MAX_PACKET_DB)
  9654. continue;
  9655. if(str[1]==NULL){
  9656. sprintf(tmp_output, "packet_db: packet len error\n");
  9657. ShowError(tmp_output);
  9658. continue;
  9659. }
  9660. k = atoi(str[1]);
  9661. // if (packet_db[packet_ver][cmd].len != k && clif_config.prefer_packet_db) // not used for now
  9662. packet_db[packet_ver][cmd].len = k;
  9663. if(str[2]==NULL){
  9664. ln++;
  9665. continue;
  9666. }
  9667. for(j=0;j<sizeof(clif_parse_func)/sizeof(clif_parse_func[0]);j++){
  9668. if(clif_parse_func[j].name != NULL &&
  9669. strcmp(str[2],clif_parse_func[j].name)==0){
  9670. // if (packet_db[packet_ver][cmd].func != clif_parse_func[j].func && !clif_config.prefer_packet_db)
  9671. // break; // not used for now
  9672. packet_db[packet_ver][cmd].func = clif_parse_func[j].func;
  9673. break;
  9674. }
  9675. }
  9676. // set the identifying cmd for the packet_db version
  9677. if (strcmp(str[2],"wanttoconnection")==0){
  9678. clif_config.connect_cmd = cmd;
  9679. }
  9680. if(str[3]==NULL){
  9681. sprintf(tmp_output, "packet_db: packet error\n");
  9682. ShowError(tmp_output);
  9683. exit(1);
  9684. }
  9685. for(j=0,p2=str[3];p2;j++){
  9686. str2[j]=p2;
  9687. p2=strchr(p2,':');
  9688. if(p2) *p2++=0;
  9689. k = atoi(str2[j]);
  9690. // if (packet_db[packet_ver][cmd].pos[j] != k && clif_config.prefer_packet_db) // not used for now
  9691. packet_db[packet_ver][cmd].pos[j] = k;
  9692. }
  9693. ln++;
  9694. // if(packet_db[clif_config.packet_db_ver][cmd].len > 2 /* && packet_db[cmd].pos[0] == 0 */)
  9695. // 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);
  9696. }
  9697. fclose(fp);
  9698. 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");
  9699. ShowStatus(tmp_output);
  9700. return 0;
  9701. }
  9702. /*==========================================
  9703. *
  9704. *------------------------------------------
  9705. */
  9706. int do_init_clif(void) {
  9707. int i;
  9708. clif_config.enable_packet_db = 1; // whether to use the packet DB for client connection
  9709. clif_config.packet_db_ver = -1; // the main packet version of the DB
  9710. clif_config.prefer_packet_db = 1; // whether the packet version takes precedence
  9711. clif_config.connect_cmd = 0xF5; // the default packet used for connecting to the server
  9712. memset(packet_db,0,sizeof(packet_db));
  9713. // size of packet version 5 (old)
  9714. for(i=0;i<sizeof(packet_len_table)/sizeof(packet_len_table[0]);i++){
  9715. packet_db[0][i].len = packet_len_table[i];
  9716. }
  9717. // packet functions of version 5 (old)
  9718. for(i=0;i<sizeof(clif_parse_func_table)/sizeof(clif_parse_func_table[0]);i++){
  9719. packet_db[0][i].func = clif_parse_func_table[i];
  9720. }
  9721. // using hardcoded packet values isn't necessary with packet_db now,
  9722. // but... just in case, i'll leave it to initialise for now ^^;
  9723. // init packet version 5 and lower
  9724. memcpy(&packet_db[1], &packet_db[0], sizeof(packet_db[0]));
  9725. memcpy(&packet_db[2], &packet_db[1], sizeof(packet_db[0]));
  9726. memcpy(&packet_db[3], &packet_db[2], sizeof(packet_db[0]));
  9727. memcpy(&packet_db[4], &packet_db[3], sizeof(packet_db[0]));
  9728. memcpy(&packet_db[5], &packet_db[4], sizeof(packet_db[0]));
  9729. #ifndef PREFER_PACKET_DB
  9730. // functions of packet version 5-6-7 are same, but size are different
  9731. // size of packet version 6 (7july04)
  9732. memcpy(&packet_db[6], &packet_db[5], sizeof(packet_db[0]));
  9733. packet_db[6][0x072].len = 22;
  9734. packet_db[6][0x085].len = 8;
  9735. packet_db[6][0x0a7].len = 13;
  9736. packet_db[6][0x113].len = 15;
  9737. packet_db[6][0x116].len = 15;
  9738. packet_db[6][0x190].len = 95;
  9739. // size of packet version 7 (13july04)
  9740. memcpy(&packet_db[7], &packet_db[6], sizeof(packet_db[0]));
  9741. packet_db[7][0x072].len = 39;
  9742. packet_db[7][0x085].len = 9;
  9743. packet_db[7][0x09b].len = 13;
  9744. packet_db[7][0x09f].len = 10;
  9745. packet_db[7][0x0a7].len = 17;
  9746. packet_db[7][0x113].len = 19;
  9747. packet_db[7][0x116].len = 19;
  9748. packet_db[7][0x190].len = 99;
  9749. // init packet function calls for packet ver 8
  9750. memcpy(packet_db[8], packet_db[7], sizeof(packet_db[0]));
  9751. packet_db[8][0x072].func = clif_parse_DropItem;
  9752. packet_db[8][0x07e].func = clif_parse_WantToConnection;
  9753. packet_db[8][0x085].func = clif_parse_UseSkillToId;
  9754. packet_db[8][0x089].func = clif_parse_GetCharNameRequest;
  9755. packet_db[8][0x08c].func = clif_parse_UseSkillToPos;
  9756. packet_db[8][0x094].func = clif_parse_TakeItem;
  9757. packet_db[8][0x09b].func = clif_parse_WalkToXY;
  9758. packet_db[8][0x09f].func = clif_parse_ChangeDir;
  9759. packet_db[8][0x0a2].func = clif_parse_UseSkillToPos;
  9760. packet_db[8][0x0a7].func = clif_parse_SolveCharName;
  9761. packet_db[8][0x0f3].func = clif_parse_GlobalMessage;
  9762. packet_db[8][0x0f5].func = clif_parse_UseItem;
  9763. packet_db[8][0x0f7].func = clif_parse_TickSend;
  9764. packet_db[8][0x113].func = clif_parse_MoveToKafra;
  9765. packet_db[8][0x116].func = clif_parse_CloseKafra;
  9766. packet_db[8][0x190].func = clif_parse_MoveFromKafra;
  9767. packet_db[8][0x193].func = clif_parse_ActionRequest;
  9768. // size of packet version 8 (26july04)
  9769. packet_db[8][0x072].len = 14;
  9770. packet_db[8][0x07e].len = 33;
  9771. packet_db[8][0x085].len = 20;
  9772. packet_db[8][0x089].len = 15;
  9773. packet_db[8][0x08c].len = 23;
  9774. packet_db[8][0x094].len = 10;
  9775. packet_db[8][0x09b].len = 6;
  9776. packet_db[8][0x09f].len = 13;
  9777. packet_db[8][0x0a2].len = 103;
  9778. packet_db[8][0x0a7].len = 12;
  9779. packet_db[8][0x0f3].len = -1;
  9780. packet_db[8][0x0f5].len = 17;
  9781. packet_db[8][0x0f7].len = 10;
  9782. packet_db[8][0x113].len = 16;
  9783. packet_db[8][0x116].len = 2;
  9784. packet_db[8][0x190].len = 26;
  9785. packet_db[8][0x193].len = 9;
  9786. // init packet function calls for packet ver 9 (same function of packet version 8, but size are different)
  9787. memcpy(packet_db[9], packet_db[8], sizeof(packet_db[0]));
  9788. // size of packet version 9 (9aug04/16aug04/17aug04)
  9789. packet_db[9][0x072].len = 17;
  9790. packet_db[9][0x07e].len = 37;
  9791. packet_db[9][0x085].len = 26;
  9792. packet_db[9][0x089].len = 12;
  9793. packet_db[9][0x08c].len = 40;
  9794. packet_db[9][0x094].len = 13;
  9795. packet_db[9][0x09b].len = 15;
  9796. packet_db[9][0x09f].len = 12;
  9797. packet_db[9][0x0a2].len = 120;
  9798. packet_db[9][0x0a7].len = 11;
  9799. // packet_db[9][0x0f3].len = -1;
  9800. packet_db[9][0x0f5].len = 24;
  9801. packet_db[9][0x0f7].len = 13;
  9802. packet_db[9][0x113].len = 23;
  9803. // packet_db[9][0x116].len = 2;
  9804. packet_db[9][0x190].len = 26;
  9805. packet_db[9][0x193].len = 18;
  9806. // new packet
  9807. packet_db[9][0x20f].len = 10;
  9808. packet_db[9][0x210].len = 22;
  9809. packet_db[9][0x212].len = 26;
  9810. packet_db[9][0x213].len = 26;
  9811. packet_db[9][0x214].len = 42;
  9812. // init packet function calls for packet ver 10
  9813. memcpy(packet_db[10], packet_db[9], sizeof(packet_db[0]));
  9814. packet_db[10][0x072].func = clif_parse_UseItem;
  9815. packet_db[10][0x07e].func = clif_parse_MoveToKafra;
  9816. packet_db[10][0x085].func = clif_parse_ActionRequest;
  9817. packet_db[10][0x089].func = clif_parse_WalkToXY;
  9818. packet_db[10][0x08c].func = clif_parse_UseSkillToPos;
  9819. packet_db[10][0x094].func = clif_parse_DropItem;
  9820. packet_db[10][0x09b].func = clif_parse_GetCharNameRequest;
  9821. packet_db[10][0x09f].func = clif_parse_GlobalMessage;
  9822. packet_db[10][0x0a2].func = clif_parse_SolveCharName;
  9823. packet_db[10][0x0a7].func = clif_parse_UseSkillToPos;
  9824. packet_db[10][0x0f3].func = clif_parse_ChangeDir;
  9825. packet_db[10][0x0f5].func = clif_parse_WantToConnection;
  9826. packet_db[10][0x0f7].func = clif_parse_CloseKafra;
  9827. packet_db[10][0x113].func = clif_parse_TakeItem;
  9828. packet_db[10][0x116].func = clif_parse_TickSend;
  9829. packet_db[10][0x190].func = clif_parse_UseSkillToId;
  9830. packet_db[10][0x193].func = clif_parse_MoveFromKafra;
  9831. // size of packet version 10 (6sept04)
  9832. packet_db[10][0x072].len = 20;
  9833. packet_db[10][0x07e].len = 19;
  9834. packet_db[10][0x085].len = 23;
  9835. packet_db[10][0x089].len = 9;
  9836. packet_db[10][0x08c].len = 105;
  9837. packet_db[10][0x094].len = 17;
  9838. packet_db[10][0x09b].len = 14;
  9839. packet_db[10][0x09f].len = -1;
  9840. packet_db[10][0x0a2].len = 14;
  9841. packet_db[10][0x0a7].len = 25;
  9842. packet_db[10][0x0f3].len = 10;
  9843. packet_db[10][0x0f5].len = 34;
  9844. packet_db[10][0x0f7].len = 2;
  9845. packet_db[10][0x113].len = 11;
  9846. packet_db[10][0x116].len = 11;
  9847. packet_db[10][0x190].len = 22;
  9848. packet_db[10][0x193].len = 17;
  9849. // init packet function calls for packet ver 11 (same function of packet version 10, but size are different)
  9850. memcpy(packet_db[11], packet_db[10], sizeof(packet_db[0]));
  9851. // size of packet version 11 (21sept04)
  9852. packet_db[11][0x072].len = 18;
  9853. packet_db[11][0x07e].len = 25;
  9854. packet_db[11][0x085].len = 9;
  9855. packet_db[11][0x089].len = 14;
  9856. packet_db[11][0x08c].len = 109;
  9857. packet_db[11][0x094].len = 19;
  9858. packet_db[11][0x09b].len = 10;
  9859. // packet_db[11][0x09f].len = -1;
  9860. packet_db[11][0x0a2].len = 10;
  9861. packet_db[11][0x0a7].len = 29;
  9862. packet_db[11][0x0f3].len = 18;
  9863. packet_db[11][0x0f5].len = 32;
  9864. // packet_db[11][0x0f7].len = 2;
  9865. packet_db[11][0x113].len = 14;
  9866. packet_db[11][0x116].len = 14;
  9867. packet_db[11][0x190].len = 14;
  9868. packet_db[11][0x193].len = 12;
  9869. // init packet function calls for packet ver 12 (same function of packet version 11, but size are different)
  9870. memcpy(packet_db[12], packet_db[11], sizeof(packet_db[0]));
  9871. // size of packet version 12 (18oct04)
  9872. packet_db[12][0x072].len = 17;
  9873. packet_db[12][0x07e].len = 16;
  9874. // packet_db[12][0x085].len = 9;
  9875. packet_db[12][0x089].len = 6;
  9876. packet_db[12][0x08c].len = 103;
  9877. packet_db[12][0x094].len = 14;
  9878. packet_db[12][0x09b].len = 15;
  9879. // packet_db[12][0x09f].len = -1;
  9880. packet_db[12][0x0a2].len = 12;
  9881. packet_db[12][0x0a7].len = 23;
  9882. packet_db[12][0x0f3].len = 13;
  9883. packet_db[12][0x0f5].len = 33;
  9884. // packet_db[12][0x0f7].len = 2;
  9885. packet_db[12][0x113].len = 10;
  9886. packet_db[12][0x116].len = 10;
  9887. packet_db[12][0x190].len = 20;
  9888. packet_db[12][0x193].len = 26;
  9889. // init packet function calls for packet ver 13 (same function of packet version 12, but size are different)
  9890. memcpy(packet_db[13], packet_db[12], sizeof(packet_db[0]));
  9891. // size of packet version 13 (25oct04)
  9892. packet_db[13][0x072].len = 13;
  9893. packet_db[13][0x07e].len = 13;
  9894. packet_db[13][0x085].len = 15;
  9895. // packet_db[13][0x089].len = 6;
  9896. packet_db[13][0x08c].len = 108;
  9897. packet_db[13][0x094].len = 12;
  9898. packet_db[13][0x09b].len = 10;
  9899. // packet_db[13][0x09f].len = -1;
  9900. packet_db[13][0x0a2].len = 16;
  9901. packet_db[13][0x0a7].len = 28;
  9902. packet_db[13][0x0f3].len = 15;
  9903. packet_db[13][0x0f5].len = 29;
  9904. // packet_db[13][0x0f7].len = 2;
  9905. packet_db[13][0x113].len = 9;
  9906. packet_db[13][0x116].len = 9;
  9907. packet_db[13][0x190].len = 26;
  9908. packet_db[13][0x193].len = 22;
  9909. // init packet function calls for packet ver 14 (same function of packet version 13, but size are different)
  9910. memcpy(packet_db[14], packet_db[13], sizeof(packet_db[0]));
  9911. // size of packet version 14 - Added by nsstrunks (1nov04)
  9912. packet_db[14][0x072].len = 13;
  9913. packet_db[14][0x07e].len = 13;
  9914. packet_db[14][0x085].len = 15;
  9915. packet_db[14][0x089].len = 6;
  9916. packet_db[14][0x08c].len = 108;
  9917. packet_db[14][0x094].len = 12;
  9918. packet_db[14][0x09b].len = 10;
  9919. packet_db[14][0x09f].len = -1;
  9920. packet_db[14][0x0a2].len = 16;
  9921. packet_db[14][0x0a7].len = 28;
  9922. packet_db[14][0x0f3].len = 15;
  9923. packet_db[14][0x0f5].len = 29;
  9924. packet_db[14][0x113].len = 9;
  9925. packet_db[14][0x116].len = 9;
  9926. packet_db[14][0x190].len = 26;
  9927. packet_db[14][0x193].len = 22;
  9928. packet_db[14][0x215].len = 6;
  9929. packet_db[14][0x216].len = 6;
  9930. packet_db[14][0x217].len = 2;
  9931. packet_db[14][0x218].len = 2;
  9932. packet_db[14][0x219].len = 282;
  9933. packet_db[14][0x21a].len = 282;
  9934. packet_db[14][0x21b].len = 10;
  9935. packet_db[14][0x21c].len = 10;
  9936. // packet_db[14][0x143].len = 23; // is this required? uncomment if it is
  9937. // Init packet function calls for packet ver 15
  9938. memcpy(packet_db[15], packet_db[14], sizeof(packet_db[0]));
  9939. packet_db[15][0x072].func = clif_parse_UseSkillToId;
  9940. packet_db[15][0x07e].func = clif_parse_UseSkillToPos;
  9941. packet_db[15][0x089].func = clif_parse_TickSend;
  9942. packet_db[15][0x085].func = clif_parse_GlobalMessage;
  9943. packet_db[15][0x08c].func = clif_parse_GetCharNameRequest;
  9944. packet_db[15][0x094].func = clif_parse_MoveToKafra;
  9945. packet_db[15][0x09b].func = clif_parse_CloseKafra;
  9946. packet_db[15][0x09f].func = clif_parse_ActionRequest;
  9947. packet_db[15][0x0a2].func = clif_parse_TakeItem;
  9948. packet_db[15][0x0a7].func = clif_parse_WalkToXY;
  9949. packet_db[15][0x0f3].func = clif_parse_ChangeDir;
  9950. packet_db[15][0x0f5].func = clif_parse_WantToConnection;
  9951. packet_db[15][0x0f7].func = clif_parse_SolveCharName;
  9952. packet_db[15][0x113].func = clif_parse_UseSkillToPos;
  9953. packet_db[15][0x116].func = clif_parse_DropItem;
  9954. packet_db[15][0x190].func = clif_parse_UseItem;
  9955. packet_db[15][0x193].func = clif_parse_MoveFromKafra;
  9956. // Size of packet version 15 - Added by nsstrunks (6dec04)
  9957. packet_db[15][0x072].len = 22;
  9958. packet_db[15][0x07e].len = 30;
  9959. packet_db[15][0x094].len = 14;
  9960. packet_db[15][0x09f].len = 18;
  9961. packet_db[15][0x085].len = -1;
  9962. packet_db[15][0x08c].len = 13;
  9963. packet_db[15][0x089].len = 7;
  9964. packet_db[15][0x09b].len = 2;
  9965. packet_db[15][0x0a2].len = 7;
  9966. packet_db[15][0x0a7].len = 7;
  9967. packet_db[15][0x0f3].len = 8;
  9968. packet_db[15][0x0f5].len = 29;
  9969. packet_db[15][0x0f7].len = 14;
  9970. packet_db[15][0x113].len = 110;
  9971. packet_db[15][0x116].len = 12;
  9972. packet_db[15][0x190].len = 15;
  9973. packet_db[15][0x193].len = 21;
  9974. packet_db[15][0x21d].len = 6;
  9975. packet_db[15][0x222].len = 6;
  9976. packet_db[15][0x221].len = -1;
  9977. packet_db[15][0x223].len = 8;
  9978. // Init packet function calls for packet ver 16
  9979. memcpy(packet_db[16], packet_db[15], sizeof(packet_db[0]));
  9980. packet_db[16][0x072].func = clif_parse_UseSkillToId;
  9981. packet_db[16][0x07e].func = clif_parse_UseSkillToPos;
  9982. packet_db[16][0x089].func = clif_parse_TickSend;
  9983. packet_db[16][0x0f3].func = clif_parse_GlobalMessage;
  9984. packet_db[16][0x08c].func = clif_parse_GetCharNameRequest;
  9985. packet_db[16][0x094].func = clif_parse_MoveToKafra;
  9986. packet_db[16][0x193].func = clif_parse_CloseKafra;
  9987. packet_db[16][0x190].func = clif_parse_ActionRequest;
  9988. packet_db[16][0x0f5].func = clif_parse_TakeItem;
  9989. packet_db[16][0x0a7].func = clif_parse_WalkToXY;
  9990. packet_db[16][0x085].func = clif_parse_ChangeDir;
  9991. packet_db[16][0x09b].func = clif_parse_WantToConnection;
  9992. packet_db[16][0x0a2].func = clif_parse_SolveCharName;
  9993. packet_db[16][0x113].func = clif_parse_UseSkillToPos;
  9994. packet_db[16][0x116].func = clif_parse_DropItem;
  9995. packet_db[16][0x09f].func = clif_parse_UseItem;
  9996. packet_db[16][0x0f7].func = clif_parse_MoveFromKafra;
  9997. // Size of packet version 16 [10jan05]
  9998. packet_db[16][0x072].len = 26;
  9999. packet_db[16][0x07e].len = 114;
  10000. packet_db[16][0x089].len = 9;
  10001. packet_db[16][0x0f3].len = -1;
  10002. packet_db[16][0x08c].len = 8;
  10003. packet_db[16][0x094].len = 20;
  10004. packet_db[16][0x193].len = 2;
  10005. packet_db[16][0x190].len = 20;
  10006. packet_db[16][0x0f5].len = 9;
  10007. packet_db[16][0x0a7].len = 13;
  10008. packet_db[16][0x085].len = 23;
  10009. packet_db[16][0x09b].len = 32;
  10010. packet_db[16][0x0a2].len = 11;
  10011. packet_db[16][0x113].len = 34;
  10012. packet_db[16][0x116].len = 20;
  10013. packet_db[16][0x09f].len = 17;
  10014. packet_db[16][0x0f7].len = 21;
  10015. packet_db[16][0x143].len = 10;
  10016. // Init packet function calls for the packet_db.txt (17)
  10017. memcpy(packet_db[MAX_PACKET_VER], packet_db[MAX_PACKET_VER - 1], sizeof(packet_db[0]));
  10018. #endif
  10019. if (clif_config.enable_packet_db)
  10020. packetdb_readdb();
  10021. set_defaultparse(clif_parse);
  10022. #ifdef __WIN32
  10023. //if (!make_listen_port(map_port)) {
  10024. if (!make_listen_bind(bind_ip,map_port)) {
  10025. printf("cant bind game port\n");
  10026. exit(1);
  10027. }
  10028. #else
  10029. for(i = 0; i < 10; i++) {
  10030. //if (make_listen_port(map_port))
  10031. if (make_listen_bind(bind_ip,map_port))
  10032. break;
  10033. sleep(20);
  10034. }
  10035. if (i == 10) {
  10036. printf("cant bind game port\n");
  10037. exit(1);
  10038. }
  10039. #endif
  10040. add_timer_func_list(clif_waitclose, "clif_waitclose");
  10041. add_timer_func_list(clif_clearchar_delay_sub, "clif_clearchar_delay_sub");
  10042. return 0;
  10043. }