LLClientView.cs 533 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Net;
  31. using System.Reflection;
  32. using System.Text;
  33. using System.Threading;
  34. using System.Timers;
  35. using System.Xml;
  36. using log4net;
  37. using OpenMetaverse;
  38. using OpenMetaverse.Packets;
  39. using OpenMetaverse.Messages.Linden;
  40. using OpenMetaverse.StructuredData;
  41. using OpenSim.Framework;
  42. using OpenSim.Framework.Client;
  43. using OpenSim.Framework.Statistics;
  44. using OpenSim.Region.Framework.Interfaces;
  45. using OpenSim.Region.Framework.Scenes;
  46. using OpenSim.Services.Interfaces;
  47. using Timer = System.Timers.Timer;
  48. using AssetLandmark = OpenSim.Framework.AssetLandmark;
  49. using Nini.Config;
  50. using System.IO;
  51. namespace OpenSim.Region.ClientStack.LindenUDP
  52. {
  53. public delegate bool PacketMethod(IClientAPI simClient, Packet packet);
  54. /// <summary>
  55. /// Handles new client connections
  56. /// Constructor takes a single Packet and authenticates everything
  57. /// </summary>
  58. public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientIPEndpoint, IStatsCollector
  59. {
  60. /// <value>
  61. /// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details.
  62. /// </value>
  63. protected int m_debugPacketLevel = 0;
  64. #region Events
  65. public event GenericMessage OnGenericMessage;
  66. public event BinaryGenericMessage OnBinaryGenericMessage;
  67. public event Action<IClientAPI> OnLogout;
  68. public event ObjectPermissions OnObjectPermissions;
  69. public event Action<IClientAPI> OnConnectionClosed;
  70. public event ViewerEffectEventHandler OnViewerEffect;
  71. public event ImprovedInstantMessage OnInstantMessage;
  72. public event ChatMessage OnChatFromClient;
  73. public event TextureRequest OnRequestTexture;
  74. public event RezObject OnRezObject;
  75. public event DeRezObject OnDeRezObject;
  76. public event ModifyTerrain OnModifyTerrain;
  77. public event Action<IClientAPI> OnRegionHandShakeReply;
  78. public event GenericCall1 OnRequestWearables;
  79. public event SetAppearance OnSetAppearance;
  80. public event AvatarNowWearing OnAvatarNowWearing;
  81. public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
  82. public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
  83. public event UUIDNameRequest OnDetachAttachmentIntoInv;
  84. public event ObjectAttach OnObjectAttach;
  85. public event ObjectDeselect OnObjectDetach;
  86. public event ObjectDrop OnObjectDrop;
  87. public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
  88. public event UpdateAgent OnPreAgentUpdate;
  89. public event UpdateAgent OnAgentUpdate;
  90. public event AgentRequestSit OnAgentRequestSit;
  91. public event AgentSit OnAgentSit;
  92. public event AvatarPickerRequest OnAvatarPickerRequest;
  93. public event StartAnim OnStartAnim;
  94. public event StopAnim OnStopAnim;
  95. public event Action<IClientAPI> OnRequestAvatarsData;
  96. public event LinkObjects OnLinkObjects;
  97. public event DelinkObjects OnDelinkObjects;
  98. public event GrabObject OnGrabObject;
  99. public event DeGrabObject OnDeGrabObject;
  100. public event SpinStart OnSpinStart;
  101. public event SpinStop OnSpinStop;
  102. public event ObjectDuplicate OnObjectDuplicate;
  103. public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
  104. public event MoveObject OnGrabUpdate;
  105. public event SpinObject OnSpinUpdate;
  106. public event AddNewPrim OnAddPrim;
  107. public event RequestGodlikePowers OnRequestGodlikePowers;
  108. public event GodKickUser OnGodKickUser;
  109. public event ObjectExtraParams OnUpdateExtraParams;
  110. public event UpdateShape OnUpdatePrimShape;
  111. public event ObjectRequest OnObjectRequest;
  112. public event ObjectSelect OnObjectSelect;
  113. public event ObjectDeselect OnObjectDeselect;
  114. public event GenericCall7 OnObjectDescription;
  115. public event GenericCall7 OnObjectName;
  116. public event GenericCall7 OnObjectClickAction;
  117. public event GenericCall7 OnObjectMaterial;
  118. public event ObjectIncludeInSearch OnObjectIncludeInSearch;
  119. public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
  120. public event UpdatePrimFlags OnUpdatePrimFlags;
  121. public event UpdatePrimTexture OnUpdatePrimTexture;
  122. public event UpdateVector OnUpdatePrimGroupPosition;
  123. public event UpdateVector OnUpdatePrimSinglePosition;
  124. public event UpdatePrimRotation OnUpdatePrimGroupRotation;
  125. public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
  126. public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
  127. public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
  128. public event UpdateVector OnUpdatePrimScale;
  129. public event UpdateVector OnUpdatePrimGroupScale;
  130. public event StatusChange OnChildAgentStatus;
  131. public event GenericCall2 OnStopMovement;
  132. public event Action<UUID> OnRemoveAvatar;
  133. public event RequestMapBlocks OnRequestMapBlocks;
  134. public event RequestMapName OnMapNameRequest;
  135. public event TeleportLocationRequest OnTeleportLocationRequest;
  136. public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
  137. public event DisconnectUser OnDisconnectUser;
  138. public event RequestAvatarProperties OnRequestAvatarProperties;
  139. public event SetAlwaysRun OnSetAlwaysRun;
  140. public event FetchInventory OnAgentDataUpdateRequest;
  141. public event TeleportLocationRequest OnSetStartLocationRequest;
  142. public event UpdateAvatarProperties OnUpdateAvatarProperties;
  143. public event CreateNewInventoryItem OnCreateNewInventoryItem;
  144. public event LinkInventoryItem OnLinkInventoryItem;
  145. public event CreateInventoryFolder OnCreateNewInventoryFolder;
  146. public event UpdateInventoryFolder OnUpdateInventoryFolder;
  147. public event MoveInventoryFolder OnMoveInventoryFolder;
  148. public event FetchInventoryDescendents OnFetchInventoryDescendents;
  149. public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
  150. public event FetchInventory OnFetchInventory;
  151. public event RequestTaskInventory OnRequestTaskInventory;
  152. public event UpdateInventoryItem OnUpdateInventoryItem;
  153. public event CopyInventoryItem OnCopyInventoryItem;
  154. public event MoveInventoryItem OnMoveInventoryItem;
  155. public event RemoveInventoryItem OnRemoveInventoryItem;
  156. public event RemoveInventoryFolder OnRemoveInventoryFolder;
  157. public event UDPAssetUploadRequest OnAssetUploadRequest;
  158. public event XferReceive OnXferReceive;
  159. public event RequestXfer OnRequestXfer;
  160. public event ConfirmXfer OnConfirmXfer;
  161. public event AbortXfer OnAbortXfer;
  162. public event RequestTerrain OnRequestTerrain;
  163. public event RezScript OnRezScript;
  164. public event UpdateTaskInventory OnUpdateTaskInventory;
  165. public event MoveTaskInventory OnMoveTaskItem;
  166. public event RemoveTaskInventory OnRemoveTaskItem;
  167. public event RequestAsset OnRequestAsset;
  168. public event UUIDNameRequest OnNameFromUUIDRequest;
  169. public event ParcelAccessListRequest OnParcelAccessListRequest;
  170. public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
  171. public event ParcelPropertiesRequest OnParcelPropertiesRequest;
  172. public event ParcelDivideRequest OnParcelDivideRequest;
  173. public event ParcelJoinRequest OnParcelJoinRequest;
  174. public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
  175. public event ParcelSelectObjects OnParcelSelectObjects;
  176. public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
  177. public event ParcelAbandonRequest OnParcelAbandonRequest;
  178. public event ParcelGodForceOwner OnParcelGodForceOwner;
  179. public event ParcelReclaim OnParcelReclaim;
  180. public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
  181. public event ParcelDeedToGroup OnParcelDeedToGroup;
  182. public event RegionInfoRequest OnRegionInfoRequest;
  183. public event EstateCovenantRequest OnEstateCovenantRequest;
  184. public event FriendActionDelegate OnApproveFriendRequest;
  185. public event FriendActionDelegate OnDenyFriendRequest;
  186. public event FriendshipTermination OnTerminateFriendship;
  187. public event GrantUserFriendRights OnGrantUserRights;
  188. public event MoneyTransferRequest OnMoneyTransferRequest;
  189. public event EconomyDataRequest OnEconomyDataRequest;
  190. public event MoneyBalanceRequest OnMoneyBalanceRequest;
  191. public event ParcelBuy OnParcelBuy;
  192. public event UUIDNameRequest OnTeleportHomeRequest;
  193. public event UUIDNameRequest OnUUIDGroupNameRequest;
  194. public event ScriptAnswer OnScriptAnswer;
  195. public event RequestPayPrice OnRequestPayPrice;
  196. public event ObjectSaleInfo OnObjectSaleInfo;
  197. public event ObjectBuy OnObjectBuy;
  198. public event BuyObjectInventory OnBuyObjectInventory;
  199. public event AgentSit OnUndo;
  200. public event AgentSit OnRedo;
  201. public event LandUndo OnLandUndo;
  202. public event ForceReleaseControls OnForceReleaseControls;
  203. public event GodLandStatRequest OnLandStatRequest;
  204. public event RequestObjectPropertiesFamily OnObjectGroupRequest;
  205. public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
  206. public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
  207. public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
  208. public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
  209. public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
  210. public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
  211. public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
  212. public event BakeTerrain OnBakeTerrain;
  213. public event RequestTerrain OnUploadTerrain;
  214. public event EstateChangeInfo OnEstateChangeInfo;
  215. public event EstateRestartSimRequest OnEstateRestartSimRequest;
  216. public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
  217. public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
  218. public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
  219. public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
  220. public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
  221. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  222. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  223. public event RegionHandleRequest OnRegionHandleRequest;
  224. public event ParcelInfoRequest OnParcelInfoRequest;
  225. public event ScriptReset OnScriptReset;
  226. public event GetScriptRunning OnGetScriptRunning;
  227. public event SetScriptRunning OnSetScriptRunning;
  228. public event Action<Vector3, bool> OnAutoPilotGo;
  229. public event TerrainUnacked OnUnackedTerrain;
  230. public event ActivateGesture OnActivateGesture;
  231. public event DeactivateGesture OnDeactivateGesture;
  232. public event ObjectOwner OnObjectOwner;
  233. public event DirPlacesQuery OnDirPlacesQuery;
  234. public event DirFindQuery OnDirFindQuery;
  235. public event DirLandQuery OnDirLandQuery;
  236. public event DirPopularQuery OnDirPopularQuery;
  237. public event DirClassifiedQuery OnDirClassifiedQuery;
  238. public event EventInfoRequest OnEventInfoRequest;
  239. public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
  240. public event MapItemRequest OnMapItemRequest;
  241. public event OfferCallingCard OnOfferCallingCard;
  242. public event AcceptCallingCard OnAcceptCallingCard;
  243. public event DeclineCallingCard OnDeclineCallingCard;
  244. public event SoundTrigger OnSoundTrigger;
  245. public event StartLure OnStartLure;
  246. public event TeleportLureRequest OnTeleportLureRequest;
  247. public event NetworkStats OnNetworkStatsUpdate;
  248. public event ClassifiedInfoRequest OnClassifiedInfoRequest;
  249. public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
  250. public event ClassifiedDelete OnClassifiedDelete;
  251. public event ClassifiedDelete OnClassifiedGodDelete;
  252. public event EventNotificationAddRequest OnEventNotificationAddRequest;
  253. public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
  254. public event EventGodDelete OnEventGodDelete;
  255. public event ParcelDwellRequest OnParcelDwellRequest;
  256. public event UserInfoRequest OnUserInfoRequest;
  257. public event UpdateUserInfo OnUpdateUserInfo;
  258. public event RetrieveInstantMessages OnRetrieveInstantMessages;
  259. public event PickDelete OnPickDelete;
  260. public event PickGodDelete OnPickGodDelete;
  261. public event PickInfoUpdate OnPickInfoUpdate;
  262. public event AvatarNotesUpdate OnAvatarNotesUpdate;
  263. public event MuteListRequest OnMuteListRequest;
  264. public event AvatarInterestUpdate OnAvatarInterestUpdate;
  265. public event PlacesQuery OnPlacesQuery;
  266. public event AgentFOV OnAgentFOV;
  267. public event FindAgentUpdate OnFindAgent;
  268. public event TrackAgentUpdate OnTrackAgent;
  269. public event NewUserReport OnUserReport;
  270. public event SaveStateHandler OnSaveState;
  271. public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
  272. public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
  273. public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
  274. public event FreezeUserUpdate OnParcelFreezeUser;
  275. public event EjectUserUpdate OnParcelEjectUser;
  276. public event ParcelBuyPass OnParcelBuyPass;
  277. public event ParcelGodMark OnParcelGodMark;
  278. public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
  279. public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
  280. public event SimWideDeletesDelegate OnSimWideDeletes;
  281. public event SendPostcard OnSendPostcard;
  282. public event MuteListEntryUpdate OnUpdateMuteListEntry;
  283. public event MuteListEntryRemove OnRemoveMuteListEntry;
  284. public event GodlikeMessage onGodlikeMessage;
  285. public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
  286. #endregion Events
  287. #region Class Members
  288. // LLClientView Only
  289. public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
  290. /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary>
  291. private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f;
  292. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  293. protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
  294. private readonly LLUDPServer m_udpServer;
  295. private readonly LLUDPClient m_udpClient;
  296. private readonly UUID m_sessionId;
  297. private readonly UUID m_secureSessionId;
  298. protected readonly UUID m_agentId;
  299. private readonly uint m_circuitCode;
  300. private readonly byte[] m_channelVersion = Utils.EmptyBytes;
  301. private readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>();
  302. private readonly IGroupsModule m_GroupsModule;
  303. private int m_cachedTextureSerial;
  304. private PriorityQueue m_entityUpdates;
  305. private PriorityQueue m_entityProps;
  306. private Prioritizer m_prioritizer;
  307. private bool m_disableFacelights = false;
  308. /// <value>
  309. /// List used in construction of data blocks for an object update packet. This is to stop us having to
  310. /// continually recreate it.
  311. /// </value>
  312. protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder;
  313. /// <value>
  314. /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
  315. /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
  316. /// ownerless phantom.
  317. ///
  318. /// All manipulation of this set has to occur under a lock
  319. ///
  320. /// </value>
  321. protected HashSet<uint> m_killRecord;
  322. // protected HashSet<uint> m_attachmentsSent;
  323. private int m_moneyBalance;
  324. private int m_animationSequenceNumber = 1;
  325. private bool m_SendLogoutPacketWhenClosing = true;
  326. private AgentUpdateArgs lastarg;
  327. private bool m_IsActive = true;
  328. private bool m_IsLoggingOut = false;
  329. protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
  330. protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
  331. protected Scene m_scene;
  332. protected LLImageManager m_imageManager;
  333. protected string m_firstName;
  334. protected string m_lastName;
  335. protected Thread m_clientThread;
  336. protected Vector3 m_startpos;
  337. protected EndPoint m_userEndPoint;
  338. protected UUID m_activeGroupID;
  339. protected string m_activeGroupName = String.Empty;
  340. protected ulong m_activeGroupPowers;
  341. protected Dictionary<UUID, ulong> m_groupPowers = new Dictionary<UUID, ulong>();
  342. protected int m_terrainCheckerCount;
  343. protected uint m_agentFOVCounter;
  344. protected IAssetService m_assetService;
  345. private const bool m_checkPackets = true;
  346. #endregion Class Members
  347. #region Properties
  348. public LLUDPClient UDPClient { get { return m_udpClient; } }
  349. public LLUDPServer UDPServer { get { return m_udpServer; } }
  350. public IPEndPoint RemoteEndPoint { get { return m_udpClient.RemoteEndPoint; } }
  351. public UUID SecureSessionId { get { return m_secureSessionId; } }
  352. public IScene Scene { get { return m_scene; } }
  353. public UUID SessionId { get { return m_sessionId; } }
  354. public Vector3 StartPos
  355. {
  356. get { return m_startpos; }
  357. set { m_startpos = value; }
  358. }
  359. public UUID AgentId { get { return m_agentId; } }
  360. public UUID ActiveGroupId { get { return m_activeGroupID; } }
  361. public string ActiveGroupName { get { return m_activeGroupName; } }
  362. public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
  363. public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
  364. /// <summary>
  365. /// Entity update queues
  366. /// </summary>
  367. public PriorityQueue EntityUpdateQueue { get { return m_entityUpdates; } }
  368. /// <summary>
  369. /// First name of the agent/avatar represented by the client
  370. /// </summary>
  371. public string FirstName { get { return m_firstName; } }
  372. /// <summary>
  373. /// Last name of the agent/avatar represented by the client
  374. /// </summary>
  375. public string LastName { get { return m_lastName; } }
  376. /// <summary>
  377. /// Full name of the client (first name and last name)
  378. /// </summary>
  379. public string Name { get { return FirstName + " " + LastName; } }
  380. public uint CircuitCode { get { return m_circuitCode; } }
  381. public int MoneyBalance { get { return m_moneyBalance; } }
  382. public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } }
  383. public bool IsActive
  384. {
  385. get { return m_IsActive; }
  386. set { m_IsActive = value; }
  387. }
  388. public bool IsLoggingOut
  389. {
  390. get { return m_IsLoggingOut; }
  391. set { m_IsLoggingOut = value; }
  392. }
  393. public bool DisableFacelights
  394. {
  395. get { return m_disableFacelights; }
  396. set { m_disableFacelights = value; }
  397. }
  398. public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
  399. #endregion Properties
  400. // ~LLClientView()
  401. // {
  402. // m_log.DebugFormat("[LLCLIENTVIEW]: Destructor called for {0}, circuit code {1}", Name, CircuitCode);
  403. // }
  404. /// <summary>
  405. /// Constructor
  406. /// </summary>
  407. public LLClientView(EndPoint remoteEP, Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo,
  408. UUID agentId, UUID sessionId, uint circuitCode)
  409. {
  410. RegisterInterface<IClientIM>(this);
  411. RegisterInterface<IClientChat>(this);
  412. RegisterInterface<IClientIPEndpoint>(this);
  413. InitDefaultAnimations();
  414. m_scene = scene;
  415. m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
  416. m_entityProps = new PriorityQueue(m_scene.Entities.Count);
  417. m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
  418. m_killRecord = new HashSet<uint>();
  419. // m_attachmentsSent = new HashSet<uint>();
  420. m_assetService = m_scene.RequestModuleInterface<IAssetService>();
  421. m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
  422. m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
  423. m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
  424. m_agentId = agentId;
  425. m_sessionId = sessionId;
  426. m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
  427. m_circuitCode = circuitCode;
  428. m_userEndPoint = remoteEP;
  429. m_firstName = sessionInfo.LoginInfo.First;
  430. m_lastName = sessionInfo.LoginInfo.Last;
  431. m_startpos = sessionInfo.LoginInfo.StartPos;
  432. m_moneyBalance = 1000;
  433. m_udpServer = udpServer;
  434. m_udpClient = udpClient;
  435. m_udpClient.OnQueueEmpty += HandleQueueEmpty;
  436. m_udpClient.OnPacketStats += PopulateStats;
  437. m_prioritizer = new Prioritizer(m_scene);
  438. RegisterLocalPacketHandlers();
  439. }
  440. public void SetDebugPacketLevel(int newDebug)
  441. {
  442. m_debugPacketLevel = newDebug;
  443. }
  444. #region Client Methods
  445. /// <summary>
  446. /// Shut down the client view
  447. /// </summary>
  448. public void Close()
  449. {
  450. m_log.DebugFormat(
  451. "[CLIENT]: Close has been called for {0} attached to scene {1}",
  452. Name, m_scene.RegionInfo.RegionName);
  453. // Send the STOP packet
  454. DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
  455. OutPacket(disable, ThrottleOutPacketType.Unknown);
  456. IsActive = false;
  457. // Shutdown the image manager
  458. if (m_imageManager != null)
  459. m_imageManager.Close();
  460. // Fire the callback for this connection closing
  461. if (OnConnectionClosed != null)
  462. OnConnectionClosed(this);
  463. // Flush all of the packets out of the UDP server for this client
  464. if (m_udpServer != null)
  465. m_udpServer.Flush(m_udpClient);
  466. // Remove ourselves from the scene
  467. m_scene.RemoveClient(AgentId, true);
  468. // We can't reach into other scenes and close the connection
  469. // We need to do this over grid communications
  470. //m_scene.CloseAllAgents(CircuitCode);
  471. // Disable UDP handling for this client
  472. m_udpClient.Shutdown();
  473. //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
  474. //GC.Collect();
  475. //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
  476. }
  477. public void Kick(string message)
  478. {
  479. if (!ChildAgentStatus())
  480. {
  481. KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser);
  482. kupack.UserInfo.AgentID = AgentId;
  483. kupack.UserInfo.SessionID = SessionId;
  484. kupack.TargetBlock.TargetIP = 0;
  485. kupack.TargetBlock.TargetPort = 0;
  486. kupack.UserInfo.Reason = Util.StringToBytes256(message);
  487. OutPacket(kupack, ThrottleOutPacketType.Task);
  488. // You must sleep here or users get no message!
  489. Thread.Sleep(500);
  490. }
  491. }
  492. public void Stop()
  493. {
  494. }
  495. #endregion Client Methods
  496. #region Packet Handling
  497. public void PopulateStats(int inPackets, int outPackets, int unAckedBytes)
  498. {
  499. NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate;
  500. if (handlerNetworkStatsUpdate != null)
  501. {
  502. handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes);
  503. }
  504. }
  505. public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
  506. {
  507. bool result = false;
  508. lock (PacketHandlers)
  509. {
  510. if (!PacketHandlers.ContainsKey(packetType))
  511. {
  512. PacketHandlers.Add(packetType, handler);
  513. result = true;
  514. }
  515. }
  516. return result;
  517. }
  518. /// <summary>
  519. /// Add a handler for the given packet type.
  520. /// </summary>
  521. /// <remarks>The packet is handled on its own thread. If packets must be handled in the order in which thye
  522. /// are received then please us ethe synchronous version of this method.</remarks>
  523. /// <param name="packetType"></param>
  524. /// <param name="handler"></param>
  525. /// <returns>true if the handler was added. This is currently always the case.</returns>
  526. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
  527. {
  528. return AddLocalPacketHandler(packetType, handler, true);
  529. }
  530. /// <summary>
  531. /// Add a handler for the given packet type.
  532. /// </summary>
  533. /// <param name="packetType"></param>
  534. /// <param name="handler"></param>
  535. /// <param name="doAsync">
  536. /// If true, when the packet is received it is handled on its own thread rather than on the main inward bound
  537. /// packet handler thread. This vastly increases respnosiveness but some packets need to be handled
  538. /// synchronously.
  539. /// </param>
  540. /// <returns>true if the handler was added. This is currently always the case.</returns>
  541. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
  542. {
  543. bool result = false;
  544. lock (m_packetHandlers)
  545. {
  546. if (!m_packetHandlers.ContainsKey(packetType))
  547. {
  548. m_packetHandlers.Add(packetType, new PacketProcessor() { method = handler, Async = doAsync });
  549. result = true;
  550. }
  551. }
  552. return result;
  553. }
  554. public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
  555. {
  556. MethodName = MethodName.ToLower().Trim();
  557. bool result = false;
  558. lock (m_genericPacketHandlers)
  559. {
  560. if (!m_genericPacketHandlers.ContainsKey(MethodName))
  561. {
  562. m_genericPacketHandlers.Add(MethodName, handler);
  563. result = true;
  564. }
  565. }
  566. return result;
  567. }
  568. /// <summary>
  569. /// Try to process a packet using registered packet handlers
  570. /// </summary>
  571. /// <param name="packet"></param>
  572. /// <returns>True if a handler was found which successfully processed the packet.</returns>
  573. protected virtual bool ProcessPacketMethod(Packet packet)
  574. {
  575. bool result = false;
  576. PacketProcessor pprocessor;
  577. if (m_packetHandlers.TryGetValue(packet.Type, out pprocessor))
  578. {
  579. //there is a local handler for this packet type
  580. if (pprocessor.Async)
  581. {
  582. object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
  583. Util.FireAndForget(ProcessSpecificPacketAsync, obj);
  584. result = true;
  585. }
  586. else
  587. {
  588. result = pprocessor.method(this, packet);
  589. }
  590. }
  591. else
  592. {
  593. //there is not a local handler so see if there is a Global handler
  594. PacketMethod method = null;
  595. bool found;
  596. lock (PacketHandlers)
  597. {
  598. found = PacketHandlers.TryGetValue(packet.Type, out method);
  599. }
  600. if (found)
  601. {
  602. result = method(this, packet);
  603. }
  604. }
  605. return result;
  606. }
  607. public void ProcessSpecificPacketAsync(object state)
  608. {
  609. AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
  610. try
  611. {
  612. packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
  613. }
  614. catch (Exception e)
  615. {
  616. // Make sure that we see any exception caused by the asynchronous operation.
  617. m_log.ErrorFormat(
  618. "[LLCLIENTVIEW]: Caught exception while processing {0} for {1}, {2} {3}",
  619. packetObject.Pack, Name, e.Message, e.StackTrace);
  620. }
  621. }
  622. #endregion Packet Handling
  623. # region Setup
  624. public virtual void Start()
  625. {
  626. m_scene.AddNewClient(this, PresenceType.User);
  627. RefreshGroupMembership();
  628. }
  629. # endregion
  630. public void ActivateGesture(UUID assetId, UUID gestureId)
  631. {
  632. }
  633. public void DeactivateGesture(UUID assetId, UUID gestureId)
  634. {
  635. }
  636. // Sound
  637. public void SoundTrigger(UUID soundId, UUID owerid, UUID Objectid, UUID ParentId, float Gain, Vector3 Position, UInt64 Handle)
  638. {
  639. }
  640. #region Scene/Avatar to Client
  641. public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
  642. {
  643. RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
  644. handshake.RegionInfo = new RegionHandshakePacket.RegionInfoBlock();
  645. handshake.RegionInfo.BillableFactor = args.billableFactor;
  646. handshake.RegionInfo.IsEstateManager = args.isEstateManager;
  647. handshake.RegionInfo.TerrainHeightRange00 = args.terrainHeightRange0;
  648. handshake.RegionInfo.TerrainHeightRange01 = args.terrainHeightRange1;
  649. handshake.RegionInfo.TerrainHeightRange10 = args.terrainHeightRange2;
  650. handshake.RegionInfo.TerrainHeightRange11 = args.terrainHeightRange3;
  651. handshake.RegionInfo.TerrainStartHeight00 = args.terrainStartHeight0;
  652. handshake.RegionInfo.TerrainStartHeight01 = args.terrainStartHeight1;
  653. handshake.RegionInfo.TerrainStartHeight10 = args.terrainStartHeight2;
  654. handshake.RegionInfo.TerrainStartHeight11 = args.terrainStartHeight3;
  655. handshake.RegionInfo.SimAccess = args.simAccess;
  656. handshake.RegionInfo.WaterHeight = args.waterHeight;
  657. handshake.RegionInfo.RegionFlags = args.regionFlags;
  658. handshake.RegionInfo.SimName = Util.StringToBytes256(args.regionName);
  659. handshake.RegionInfo.SimOwner = args.SimOwner;
  660. handshake.RegionInfo.TerrainBase0 = args.terrainBase0;
  661. handshake.RegionInfo.TerrainBase1 = args.terrainBase1;
  662. handshake.RegionInfo.TerrainBase2 = args.terrainBase2;
  663. handshake.RegionInfo.TerrainBase3 = args.terrainBase3;
  664. handshake.RegionInfo.TerrainDetail0 = args.terrainDetail0;
  665. handshake.RegionInfo.TerrainDetail1 = args.terrainDetail1;
  666. handshake.RegionInfo.TerrainDetail2 = args.terrainDetail2;
  667. handshake.RegionInfo.TerrainDetail3 = args.terrainDetail3;
  668. handshake.RegionInfo.CacheID = UUID.Random(); //I guess this is for the client to remember an old setting?
  669. handshake.RegionInfo2 = new RegionHandshakePacket.RegionInfo2Block();
  670. handshake.RegionInfo2.RegionID = regionInfo.RegionID;
  671. handshake.RegionInfo3 = new RegionHandshakePacket.RegionInfo3Block();
  672. handshake.RegionInfo3.CPUClassID = 9;
  673. handshake.RegionInfo3.CPURatio = 1;
  674. handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
  675. handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
  676. handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
  677. OutPacket(handshake, ThrottleOutPacketType.Task);
  678. }
  679. /// <summary>
  680. ///
  681. /// </summary>
  682. public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
  683. {
  684. AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
  685. mov.SimData.ChannelVersion = m_channelVersion;
  686. mov.AgentData.SessionID = m_sessionId;
  687. mov.AgentData.AgentID = AgentId;
  688. mov.Data.RegionHandle = regInfo.RegionHandle;
  689. mov.Data.Timestamp = (uint)Util.UnixTimeSinceEpoch();
  690. if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
  691. {
  692. mov.Data.Position = m_startpos;
  693. }
  694. else
  695. {
  696. mov.Data.Position = pos;
  697. }
  698. mov.Data.LookAt = look;
  699. // Hack to get this out immediately and skip the throttles
  700. OutPacket(mov, ThrottleOutPacketType.Unknown);
  701. }
  702. public void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName,
  703. UUID fromAgentID, byte source, byte audible)
  704. {
  705. ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
  706. reply.ChatData.Audible = audible;
  707. reply.ChatData.Message = Util.StringToBytes1024(message);
  708. reply.ChatData.ChatType = type;
  709. reply.ChatData.SourceType = source;
  710. reply.ChatData.Position = fromPos;
  711. reply.ChatData.FromName = Util.StringToBytes256(fromName);
  712. reply.ChatData.OwnerID = fromAgentID;
  713. reply.ChatData.SourceID = fromAgentID;
  714. OutPacket(reply, ThrottleOutPacketType.Task);
  715. }
  716. /// <summary>
  717. /// Send an instant message to this client
  718. /// </summary>
  719. //
  720. // Don't remove transaction ID! Groups and item gives need to set it!
  721. public void SendInstantMessage(GridInstantMessage im)
  722. {
  723. if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID)))
  724. {
  725. ImprovedInstantMessagePacket msg
  726. = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
  727. msg.AgentData.AgentID = new UUID(im.fromAgentID);
  728. msg.AgentData.SessionID = UUID.Zero;
  729. msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName);
  730. msg.MessageBlock.Dialog = im.dialog;
  731. msg.MessageBlock.FromGroup = im.fromGroup;
  732. if (im.imSessionID == UUID.Zero.Guid)
  733. msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID);
  734. else
  735. msg.MessageBlock.ID = new UUID(im.imSessionID);
  736. msg.MessageBlock.Offline = im.offline;
  737. msg.MessageBlock.ParentEstateID = im.ParentEstateID;
  738. msg.MessageBlock.Position = im.Position;
  739. msg.MessageBlock.RegionID = new UUID(im.RegionID);
  740. msg.MessageBlock.Timestamp = im.timestamp;
  741. msg.MessageBlock.ToAgentID = new UUID(im.toAgentID);
  742. msg.MessageBlock.Message = Util.StringToBytes1024(im.message);
  743. msg.MessageBlock.BinaryBucket = im.binaryBucket;
  744. if (im.message.StartsWith("[grouptest]"))
  745. { // this block is test code for implementing group IM - delete when group IM is finished
  746. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  747. if (eq != null)
  748. {
  749. im.dialog = 17;
  750. //eq.ChatterboxInvitation(
  751. // new UUID("00000000-68f9-1111-024e-222222111123"),
  752. // "OpenSimulator Testing", im.fromAgentID, im.message, im.toAgentID, im.fromAgentName, im.dialog, 0,
  753. // false, 0, new Vector3(), 1, im.imSessionID, im.fromGroup, im.binaryBucket);
  754. eq.ChatterboxInvitation(
  755. new UUID("00000000-68f9-1111-024e-222222111123"),
  756. "OpenSimulator Testing", new UUID(im.fromAgentID), im.message, new UUID(im.toAgentID), im.fromAgentName, im.dialog, 0,
  757. false, 0, new Vector3(), 1, new UUID(im.imSessionID), im.fromGroup, Util.StringToBytes256("OpenSimulator Testing"));
  758. eq.ChatterBoxSessionAgentListUpdates(
  759. new UUID("00000000-68f9-1111-024e-222222111123"),
  760. new UUID(im.fromAgentID), new UUID(im.toAgentID), false, false, false);
  761. }
  762. Console.WriteLine("SendInstantMessage: " + msg);
  763. }
  764. else
  765. OutPacket(msg, ThrottleOutPacketType.Task);
  766. }
  767. }
  768. public void SendGenericMessage(string method, List<string> message)
  769. {
  770. GenericMessagePacket gmp = new GenericMessagePacket();
  771. gmp.MethodData.Method = Util.StringToBytes256(method);
  772. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  773. int i = 0;
  774. foreach (string val in message)
  775. {
  776. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  777. gmp.ParamList[i++].Parameter = Util.StringToBytes256(val);
  778. }
  779. OutPacket(gmp, ThrottleOutPacketType.Task);
  780. }
  781. public void SendGenericMessage(string method, List<byte[]> message)
  782. {
  783. GenericMessagePacket gmp = new GenericMessagePacket();
  784. gmp.MethodData.Method = Util.StringToBytes256(method);
  785. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  786. int i = 0;
  787. foreach (byte[] val in message)
  788. {
  789. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  790. gmp.ParamList[i++].Parameter = val;
  791. }
  792. OutPacket(gmp, ThrottleOutPacketType.Task);
  793. }
  794. public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
  795. {
  796. int i = 0;
  797. foreach (GroupActiveProposals Proposal in Proposals)
  798. {
  799. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  800. GAPIRP.AgentData.AgentID = AgentId;
  801. GAPIRP.AgentData.GroupID = groupID;
  802. GAPIRP.TransactionData.TransactionID = transactionID;
  803. GAPIRP.TransactionData.TotalNumItems = ((uint)i+1);
  804. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  805. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  806. ProposalData.VoteCast = Utils.StringToBytes("false");
  807. ProposalData.VoteID = new UUID(Proposal.VoteID);
  808. ProposalData.VoteInitiator = new UUID(Proposal.VoteInitiator);
  809. ProposalData.Majority = (float)Convert.ToInt32(Proposal.Majority);
  810. ProposalData.Quorum = Convert.ToInt32(Proposal.Quorum);
  811. ProposalData.TerseDateID = Utils.StringToBytes(Proposal.TerseDateID);
  812. ProposalData.StartDateTime = Utils.StringToBytes(Proposal.StartDateTime);
  813. ProposalData.EndDateTime = Utils.StringToBytes(Proposal.EndDateTime);
  814. ProposalData.ProposalText = Utils.StringToBytes(Proposal.ProposalText);
  815. ProposalData.AlreadyVoted = false;
  816. GAPIRP.ProposalData[i] = ProposalData;
  817. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  818. i++;
  819. }
  820. if (Proposals.Length == 0)
  821. {
  822. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  823. GAPIRP.AgentData.AgentID = AgentId;
  824. GAPIRP.AgentData.GroupID = groupID;
  825. GAPIRP.TransactionData.TransactionID = transactionID;
  826. GAPIRP.TransactionData.TotalNumItems = 1;
  827. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  828. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  829. ProposalData.VoteCast = Utils.StringToBytes("false");
  830. ProposalData.VoteID = UUID.Zero;
  831. ProposalData.VoteInitiator = UUID.Zero;
  832. ProposalData.Majority = 0;
  833. ProposalData.Quorum = 0;
  834. ProposalData.TerseDateID = Utils.StringToBytes("");
  835. ProposalData.StartDateTime = Utils.StringToBytes("");
  836. ProposalData.EndDateTime = Utils.StringToBytes("");
  837. ProposalData.ProposalText = Utils.StringToBytes("");
  838. ProposalData.AlreadyVoted = false;
  839. GAPIRP.ProposalData[0] = ProposalData;
  840. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  841. }
  842. }
  843. public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
  844. {
  845. int i = 0;
  846. foreach (GroupVoteHistory Vote in Votes)
  847. {
  848. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  849. GVHIRP.AgentData.AgentID = AgentId;
  850. GVHIRP.AgentData.GroupID = groupID;
  851. GVHIRP.TransactionData.TransactionID = transactionID;
  852. GVHIRP.TransactionData.TotalNumItems = ((uint)i+1);
  853. GVHIRP.HistoryItemData.VoteID = new UUID(Vote.VoteID);
  854. GVHIRP.HistoryItemData.VoteInitiator = new UUID(Vote.VoteInitiator);
  855. GVHIRP.HistoryItemData.Majority = (float)Convert.ToInt32(Vote.Majority);
  856. GVHIRP.HistoryItemData.Quorum = Convert.ToInt32(Vote.Quorum);
  857. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes(Vote.TerseDateID);
  858. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes(Vote.StartDateTime);
  859. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes(Vote.EndDateTime);
  860. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes(Vote.VoteType);
  861. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes(Vote.VoteResult);
  862. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes(Vote.ProposalText);
  863. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  864. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  865. VoteItem.CandidateID = UUID.Zero;
  866. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  867. VoteItem.VoteCast = Utils.StringToBytes("Yes");
  868. GVHIRP.VoteItem[i] = VoteItem;
  869. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  870. i++;
  871. }
  872. if (Votes.Length == 0)
  873. {
  874. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  875. GVHIRP.AgentData.AgentID = AgentId;
  876. GVHIRP.AgentData.GroupID = groupID;
  877. GVHIRP.TransactionData.TransactionID = transactionID;
  878. GVHIRP.TransactionData.TotalNumItems = 0;
  879. GVHIRP.HistoryItemData.VoteID = UUID.Zero;
  880. GVHIRP.HistoryItemData.VoteInitiator = UUID.Zero;
  881. GVHIRP.HistoryItemData.Majority = 0;
  882. GVHIRP.HistoryItemData.Quorum = 0;
  883. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes("");
  884. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes("");
  885. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes("");
  886. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes("");
  887. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes("");
  888. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes("");
  889. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  890. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  891. VoteItem.CandidateID = UUID.Zero;
  892. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  893. VoteItem.VoteCast = Utils.StringToBytes("No");
  894. GVHIRP.VoteItem[0] = VoteItem;
  895. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  896. }
  897. }
  898. public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  899. {
  900. GroupAccountDetailsReplyPacket GADRP = new GroupAccountDetailsReplyPacket();
  901. GADRP.AgentData = new GroupAccountDetailsReplyPacket.AgentDataBlock();
  902. GADRP.AgentData.AgentID = sender.AgentId;
  903. GADRP.AgentData.GroupID = groupID;
  904. GADRP.HistoryData = new GroupAccountDetailsReplyPacket.HistoryDataBlock[1];
  905. GroupAccountDetailsReplyPacket.HistoryDataBlock History = new GroupAccountDetailsReplyPacket.HistoryDataBlock();
  906. GADRP.MoneyData = new GroupAccountDetailsReplyPacket.MoneyDataBlock();
  907. GADRP.MoneyData.CurrentInterval = 0;
  908. GADRP.MoneyData.IntervalDays = 7;
  909. GADRP.MoneyData.RequestID = transactionID;
  910. GADRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  911. History.Amount = amt;
  912. History.Description = Utils.StringToBytes("");
  913. GADRP.HistoryData[0] = History;
  914. OutPacket(GADRP, ThrottleOutPacketType.Task);
  915. }
  916. public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
  917. {
  918. GroupAccountSummaryReplyPacket GASRP =
  919. (GroupAccountSummaryReplyPacket)PacketPool.Instance.GetPacket(
  920. PacketType.GroupAccountSummaryReply);
  921. GASRP.AgentData = new GroupAccountSummaryReplyPacket.AgentDataBlock();
  922. GASRP.AgentData.AgentID = sender.AgentId;
  923. GASRP.AgentData.GroupID = groupID;
  924. GASRP.MoneyData = new GroupAccountSummaryReplyPacket.MoneyDataBlock();
  925. GASRP.MoneyData.Balance = (int)moneyAmt;
  926. GASRP.MoneyData.TotalCredits = totalTier;
  927. GASRP.MoneyData.TotalDebits = usedTier;
  928. GASRP.MoneyData.StartDate = new byte[1];
  929. GASRP.MoneyData.CurrentInterval = 1;
  930. GASRP.MoneyData.GroupTaxCurrent = 0;
  931. GASRP.MoneyData.GroupTaxEstimate = 0;
  932. GASRP.MoneyData.IntervalDays = 0;
  933. GASRP.MoneyData.LandTaxCurrent = 0;
  934. GASRP.MoneyData.LandTaxEstimate = 0;
  935. GASRP.MoneyData.LastTaxDate = new byte[1];
  936. GASRP.MoneyData.LightTaxCurrent = 0;
  937. GASRP.MoneyData.TaxDate = new byte[1];
  938. GASRP.MoneyData.RequestID = sender.AgentId;
  939. GASRP.MoneyData.ParcelDirFeeEstimate = 0;
  940. GASRP.MoneyData.ParcelDirFeeCurrent = 0;
  941. GASRP.MoneyData.ObjectTaxEstimate = 0;
  942. GASRP.MoneyData.NonExemptMembers = 0;
  943. GASRP.MoneyData.ObjectTaxCurrent = 0;
  944. GASRP.MoneyData.LightTaxEstimate = 0;
  945. OutPacket(GASRP, ThrottleOutPacketType.Task);
  946. }
  947. public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  948. {
  949. GroupAccountTransactionsReplyPacket GATRP =
  950. (GroupAccountTransactionsReplyPacket)PacketPool.Instance.GetPacket(
  951. PacketType.GroupAccountTransactionsReply);
  952. GATRP.AgentData = new GroupAccountTransactionsReplyPacket.AgentDataBlock();
  953. GATRP.AgentData.AgentID = sender.AgentId;
  954. GATRP.AgentData.GroupID = groupID;
  955. GATRP.MoneyData = new GroupAccountTransactionsReplyPacket.MoneyDataBlock();
  956. GATRP.MoneyData.CurrentInterval = 0;
  957. GATRP.MoneyData.IntervalDays = 7;
  958. GATRP.MoneyData.RequestID = transactionID;
  959. GATRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  960. GATRP.HistoryData = new GroupAccountTransactionsReplyPacket.HistoryDataBlock[1];
  961. GroupAccountTransactionsReplyPacket.HistoryDataBlock History = new GroupAccountTransactionsReplyPacket.HistoryDataBlock();
  962. History.Amount = 0;
  963. History.Item = Utils.StringToBytes("");
  964. History.Time = Utils.StringToBytes("");
  965. History.Type = 0;
  966. History.User = Utils.StringToBytes("");
  967. GATRP.HistoryData[0] = History;
  968. OutPacket(GATRP, ThrottleOutPacketType.Task);
  969. }
  970. /// <summary>
  971. /// Send the region heightmap to the client
  972. /// </summary>
  973. /// <param name="map">heightmap</param>
  974. public virtual void SendLayerData(float[] map)
  975. {
  976. Util.FireAndForget(DoSendLayerData, map);
  977. }
  978. /// <summary>
  979. /// Send terrain layer information to the client.
  980. /// </summary>
  981. /// <param name="o"></param>
  982. private void DoSendLayerData(object o)
  983. {
  984. float[] map = LLHeightFieldMoronize((float[])o);
  985. try
  986. {
  987. //for (int y = 0; y < 16; y++)
  988. //{
  989. // for (int x = 0; x < 16; x++)
  990. // {
  991. // SendLayerData(x, y, map);
  992. // }
  993. //}
  994. // Send LayerData in a spiral pattern. Fun!
  995. SendLayerTopRight(map, 0, 0, 15, 15);
  996. }
  997. catch (Exception e)
  998. {
  999. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1000. }
  1001. }
  1002. private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2)
  1003. {
  1004. // Row
  1005. for (int i = x1; i <= x2; i++)
  1006. SendLayerData(i, y1, map);
  1007. // Column
  1008. for (int j = y1 + 1; j <= y2; j++)
  1009. SendLayerData(x2, j, map);
  1010. if (x2 - x1 > 0)
  1011. SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
  1012. }
  1013. void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2)
  1014. {
  1015. // Row in reverse
  1016. for (int i = x2; i >= x1; i--)
  1017. SendLayerData(i, y2, map);
  1018. // Column in reverse
  1019. for (int j = y2 - 1; j >= y1; j--)
  1020. SendLayerData(x1, j, map);
  1021. if (x2 - x1 > 0)
  1022. SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
  1023. }
  1024. /// <summary>
  1025. /// Sends a set of four patches (x, x+1, ..., x+3) to the client
  1026. /// </summary>
  1027. /// <param name="map">heightmap</param>
  1028. /// <param name="px">X coordinate for patches 0..12</param>
  1029. /// <param name="py">Y coordinate for patches 0..15</param>
  1030. // private void SendLayerPacket(float[] map, int y, int x)
  1031. // {
  1032. // int[] patches = new int[4];
  1033. // patches[0] = x + 0 + y * 16;
  1034. // patches[1] = x + 1 + y * 16;
  1035. // patches[2] = x + 2 + y * 16;
  1036. // patches[3] = x + 3 + y * 16;
  1037. // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
  1038. // OutPacket(layerpack, ThrottleOutPacketType.Land);
  1039. // }
  1040. /// <summary>
  1041. /// Sends a specified patch to a client
  1042. /// </summary>
  1043. /// <param name="px">Patch coordinate (x) 0..15</param>
  1044. /// <param name="py">Patch coordinate (y) 0..15</param>
  1045. /// <param name="map">heightmap</param>
  1046. public void SendLayerData(int px, int py, float[] map)
  1047. {
  1048. try
  1049. {
  1050. int[] patches = new int[] { py * 16 + px };
  1051. float[] heightmap = (map.Length == 65536) ?
  1052. map :
  1053. LLHeightFieldMoronize(map);
  1054. LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
  1055. layerpack.Header.Reliable = true;
  1056. OutPacket(layerpack, ThrottleOutPacketType.Land);
  1057. }
  1058. catch (Exception e)
  1059. {
  1060. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1061. }
  1062. }
  1063. /// <summary>
  1064. /// Munges heightfield into the LLUDP backed in restricted heightfield.
  1065. /// </summary>
  1066. /// <param name="map">float array in the base; Constants.RegionSize</param>
  1067. /// <returns>float array in the base 256</returns>
  1068. internal float[] LLHeightFieldMoronize(float[] map)
  1069. {
  1070. if (map.Length == 65536)
  1071. return map;
  1072. else
  1073. {
  1074. float[] returnmap = new float[65536];
  1075. if (map.Length < 65535)
  1076. {
  1077. // rebase the vector stride to 256
  1078. for (int i = 0; i < Constants.RegionSize; i++)
  1079. Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, (int)Constants.RegionSize);
  1080. }
  1081. else
  1082. {
  1083. for (int i = 0; i < 256; i++)
  1084. Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, 256);
  1085. }
  1086. //Array.Copy(map,0,returnmap,0,(map.Length < 65536)? map.Length : 65536);
  1087. return returnmap;
  1088. }
  1089. }
  1090. /// <summary>
  1091. /// Send the wind matrix to the client
  1092. /// </summary>
  1093. /// <param name="windSpeeds">16x16 array of wind speeds</param>
  1094. public virtual void SendWindData(Vector2[] windSpeeds)
  1095. {
  1096. Util.FireAndForget(DoSendWindData, windSpeeds);
  1097. }
  1098. /// <summary>
  1099. /// Send the cloud matrix to the client
  1100. /// </summary>
  1101. /// <param name="windSpeeds">16x16 array of cloud densities</param>
  1102. public virtual void SendCloudData(float[] cloudDensity)
  1103. {
  1104. Util.FireAndForget(DoSendCloudData, cloudDensity);
  1105. }
  1106. /// <summary>
  1107. /// Send wind layer information to the client.
  1108. /// </summary>
  1109. /// <param name="o"></param>
  1110. private void DoSendWindData(object o)
  1111. {
  1112. Vector2[] windSpeeds = (Vector2[])o;
  1113. TerrainPatch[] patches = new TerrainPatch[2];
  1114. patches[0] = new TerrainPatch();
  1115. patches[0].Data = new float[16 * 16];
  1116. patches[1] = new TerrainPatch();
  1117. patches[1].Data = new float[16 * 16];
  1118. for (int y = 0; y < 16; y++)
  1119. {
  1120. for (int x = 0; x < 16; x++)
  1121. {
  1122. patches[0].Data[y * 16 + x] = windSpeeds[y * 16 + x].X;
  1123. patches[1].Data[y * 16 + x] = windSpeeds[y * 16 + x].Y;
  1124. }
  1125. }
  1126. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Wind);
  1127. layerpack.Header.Zerocoded = true;
  1128. OutPacket(layerpack, ThrottleOutPacketType.Wind);
  1129. }
  1130. /// <summary>
  1131. /// Send cloud layer information to the client.
  1132. /// </summary>
  1133. /// <param name="o"></param>
  1134. private void DoSendCloudData(object o)
  1135. {
  1136. float[] cloudCover = (float[])o;
  1137. TerrainPatch[] patches = new TerrainPatch[1];
  1138. patches[0] = new TerrainPatch();
  1139. patches[0].Data = new float[16 * 16];
  1140. for (int y = 0; y < 16; y++)
  1141. {
  1142. for (int x = 0; x < 16; x++)
  1143. {
  1144. patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x];
  1145. }
  1146. }
  1147. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Cloud);
  1148. layerpack.Header.Zerocoded = true;
  1149. OutPacket(layerpack, ThrottleOutPacketType.Cloud);
  1150. }
  1151. /// <summary>
  1152. /// Tell the client that the given neighbour region is ready to receive a child agent.
  1153. /// </summary>
  1154. public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
  1155. {
  1156. IPAddress neighbourIP = neighbourEndPoint.Address;
  1157. ushort neighbourPort = (ushort)neighbourEndPoint.Port;
  1158. EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.EnableSimulator);
  1159. // TODO: don't create new blocks if recycling an old packet
  1160. enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
  1161. enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
  1162. byte[] byteIP = neighbourIP.GetAddressBytes();
  1163. enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
  1164. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
  1165. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
  1166. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
  1167. enablesimpacket.SimulatorInfo.Port = neighbourPort;
  1168. enablesimpacket.Header.Reliable = true; // ESP's should be reliable.
  1169. OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
  1170. }
  1171. public AgentCircuitData RequestClientInfo()
  1172. {
  1173. AgentCircuitData agentData = new AgentCircuitData();
  1174. agentData.AgentID = AgentId;
  1175. agentData.SessionID = m_sessionId;
  1176. agentData.SecureSessionID = SecureSessionId;
  1177. agentData.circuitcode = m_circuitCode;
  1178. agentData.child = false;
  1179. agentData.firstname = m_firstName;
  1180. agentData.lastname = m_lastName;
  1181. ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
  1182. if (capsModule == null) // can happen when shutting down.
  1183. return agentData;
  1184. agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
  1185. agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
  1186. return agentData;
  1187. }
  1188. public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint,
  1189. string capsURL)
  1190. {
  1191. Vector3 look = new Vector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
  1192. //CrossedRegionPacket newSimPack = (CrossedRegionPacket)PacketPool.Instance.GetPacket(PacketType.CrossedRegion);
  1193. CrossedRegionPacket newSimPack = new CrossedRegionPacket();
  1194. // TODO: don't create new blocks if recycling an old packet
  1195. newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
  1196. newSimPack.AgentData.AgentID = AgentId;
  1197. newSimPack.AgentData.SessionID = m_sessionId;
  1198. newSimPack.Info = new CrossedRegionPacket.InfoBlock();
  1199. newSimPack.Info.Position = pos;
  1200. newSimPack.Info.LookAt = look;
  1201. newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
  1202. newSimPack.RegionData.RegionHandle = newRegionHandle;
  1203. byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
  1204. newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
  1205. newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
  1206. newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
  1207. newSimPack.RegionData.SimIP += (uint)byteIP[0];
  1208. newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
  1209. newSimPack.RegionData.SeedCapability = Util.StringToBytes256(capsURL);
  1210. // Hack to get this out immediately and skip throttles
  1211. OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
  1212. }
  1213. internal void SendMapBlockSplit(List<MapBlockData> mapBlocks, uint flag)
  1214. {
  1215. MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
  1216. // TODO: don't create new blocks if recycling an old packet
  1217. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1218. mapReply.AgentData.AgentID = AgentId;
  1219. mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length];
  1220. mapReply.AgentData.Flags = flag;
  1221. for (int i = 0; i < mapBlocks2.Length; i++)
  1222. {
  1223. mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
  1224. mapReply.Data[i].MapImageID = mapBlocks2[i].MapImageId;
  1225. //m_log.Warn(mapBlocks2[i].MapImageId.ToString());
  1226. mapReply.Data[i].X = mapBlocks2[i].X;
  1227. mapReply.Data[i].Y = mapBlocks2[i].Y;
  1228. mapReply.Data[i].WaterHeight = mapBlocks2[i].WaterHeight;
  1229. mapReply.Data[i].Name = Utils.StringToBytes(mapBlocks2[i].Name);
  1230. mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags;
  1231. mapReply.Data[i].Access = mapBlocks2[i].Access;
  1232. mapReply.Data[i].Agents = mapBlocks2[i].Agents;
  1233. }
  1234. OutPacket(mapReply, ThrottleOutPacketType.Land);
  1235. }
  1236. public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
  1237. {
  1238. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1239. int maxsend = 10;
  1240. //int packets = Math.Ceiling(mapBlocks2.Length / maxsend);
  1241. List<MapBlockData> sendingBlocks = new List<MapBlockData>();
  1242. for (int i = 0; i < mapBlocks2.Length; i++)
  1243. {
  1244. sendingBlocks.Add(mapBlocks2[i]);
  1245. if (((i + 1) == mapBlocks2.Length) || (((i + 1) % maxsend) == 0))
  1246. {
  1247. SendMapBlockSplit(sendingBlocks, flag);
  1248. sendingBlocks = new List<MapBlockData>();
  1249. }
  1250. }
  1251. }
  1252. public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
  1253. {
  1254. TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
  1255. tpLocal.Info.AgentID = AgentId;
  1256. tpLocal.Info.TeleportFlags = flags;
  1257. tpLocal.Info.LocationID = 2;
  1258. tpLocal.Info.LookAt = lookAt;
  1259. tpLocal.Info.Position = position;
  1260. // Hack to get this out immediately and skip throttles
  1261. OutPacket(tpLocal, ThrottleOutPacketType.Unknown);
  1262. }
  1263. public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID,
  1264. uint flags, string capsURL)
  1265. {
  1266. //TeleportFinishPacket teleport = (TeleportFinishPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFinish);
  1267. TeleportFinishPacket teleport = new TeleportFinishPacket();
  1268. teleport.Info.AgentID = AgentId;
  1269. teleport.Info.RegionHandle = regionHandle;
  1270. teleport.Info.SimAccess = simAccess;
  1271. teleport.Info.SeedCapability = Util.StringToBytes256(capsURL);
  1272. IPAddress oIP = newRegionEndPoint.Address;
  1273. byte[] byteIP = oIP.GetAddressBytes();
  1274. uint ip = (uint)byteIP[3] << 24;
  1275. ip += (uint)byteIP[2] << 16;
  1276. ip += (uint)byteIP[1] << 8;
  1277. ip += (uint)byteIP[0];
  1278. teleport.Info.SimIP = ip;
  1279. teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
  1280. teleport.Info.LocationID = 4;
  1281. teleport.Info.TeleportFlags = 1 << 4;
  1282. // Hack to get this out immediately and skip throttles.
  1283. OutPacket(teleport, ThrottleOutPacketType.Unknown);
  1284. }
  1285. /// <summary>
  1286. /// Inform the client that a teleport attempt has failed
  1287. /// </summary>
  1288. public void SendTeleportFailed(string reason)
  1289. {
  1290. TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
  1291. tpFailed.Info.AgentID = AgentId;
  1292. tpFailed.Info.Reason = Util.StringToBytes256(reason);
  1293. tpFailed.AlertInfo = new TeleportFailedPacket.AlertInfoBlock[0];
  1294. // Hack to get this out immediately and skip throttles
  1295. OutPacket(tpFailed, ThrottleOutPacketType.Unknown);
  1296. }
  1297. /// <summary>
  1298. ///
  1299. /// </summary>
  1300. public void SendTeleportStart(uint flags)
  1301. {
  1302. TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart);
  1303. //TeleportStartPacket tpStart = new TeleportStartPacket();
  1304. tpStart.Info.TeleportFlags = flags; //16; // Teleport via location
  1305. // Hack to get this out immediately and skip throttles
  1306. OutPacket(tpStart, ThrottleOutPacketType.Unknown);
  1307. }
  1308. public void SendTeleportProgress(uint flags, string message)
  1309. {
  1310. TeleportProgressPacket tpProgress = (TeleportProgressPacket)PacketPool.Instance.GetPacket(PacketType.TeleportProgress);
  1311. tpProgress.AgentData.AgentID = this.AgentId;
  1312. tpProgress.Info.TeleportFlags = flags;
  1313. tpProgress.Info.Message = Util.StringToBytes256(message);
  1314. // Hack to get this out immediately and skip throttles
  1315. OutPacket(tpProgress, ThrottleOutPacketType.Unknown);
  1316. }
  1317. public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance)
  1318. {
  1319. MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket)PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply);
  1320. money.MoneyData.AgentID = AgentId;
  1321. money.MoneyData.TransactionID = transaction;
  1322. money.MoneyData.TransactionSuccess = success;
  1323. money.MoneyData.Description = description;
  1324. money.MoneyData.MoneyBalance = balance;
  1325. money.TransactionInfo.ItemDescription = Util.StringToBytes256("NONE");
  1326. OutPacket(money, ThrottleOutPacketType.Task);
  1327. }
  1328. public void SendPayPrice(UUID objectID, int[] payPrice)
  1329. {
  1330. if (payPrice[0] == 0 &&
  1331. payPrice[1] == 0 &&
  1332. payPrice[2] == 0 &&
  1333. payPrice[3] == 0 &&
  1334. payPrice[4] == 0)
  1335. return;
  1336. PayPriceReplyPacket payPriceReply = (PayPriceReplyPacket)PacketPool.Instance.GetPacket(PacketType.PayPriceReply);
  1337. payPriceReply.ObjectData.ObjectID = objectID;
  1338. payPriceReply.ObjectData.DefaultPayPrice = payPrice[0];
  1339. payPriceReply.ButtonData = new PayPriceReplyPacket.ButtonDataBlock[4];
  1340. payPriceReply.ButtonData[0] = new PayPriceReplyPacket.ButtonDataBlock();
  1341. payPriceReply.ButtonData[0].PayButton = payPrice[1];
  1342. payPriceReply.ButtonData[1] = new PayPriceReplyPacket.ButtonDataBlock();
  1343. payPriceReply.ButtonData[1].PayButton = payPrice[2];
  1344. payPriceReply.ButtonData[2] = new PayPriceReplyPacket.ButtonDataBlock();
  1345. payPriceReply.ButtonData[2].PayButton = payPrice[3];
  1346. payPriceReply.ButtonData[3] = new PayPriceReplyPacket.ButtonDataBlock();
  1347. payPriceReply.ButtonData[3].PayButton = payPrice[4];
  1348. OutPacket(payPriceReply, ThrottleOutPacketType.Task);
  1349. }
  1350. public void SendStartPingCheck(byte seq)
  1351. {
  1352. StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
  1353. pc.Header.Reliable = false;
  1354. pc.PingID.PingID = seq;
  1355. // We *could* get OldestUnacked, but it would hurt performance and not provide any benefit
  1356. pc.PingID.OldestUnacked = 0;
  1357. OutPacket(pc, ThrottleOutPacketType.Unknown);
  1358. }
  1359. public void SendKillObject(ulong regionHandle, uint localID)
  1360. {
  1361. // m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, localID, regionHandle);
  1362. KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
  1363. // TODO: don't create new blocks if recycling an old packet
  1364. kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
  1365. kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
  1366. kill.ObjectData[0].ID = localID;
  1367. kill.Header.Reliable = true;
  1368. kill.Header.Zerocoded = true;
  1369. if (m_scene.GetScenePresence(localID) == null)
  1370. {
  1371. // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
  1372. // condition where a kill can be processed before an out-of-date update for the same object.
  1373. lock (m_killRecord)
  1374. {
  1375. m_killRecord.Add(localID);
  1376. // The throttle queue used here must match that being used for updates. Otherwise, there is a
  1377. // chance that a kill packet put on a separate queue will be sent to the client before an existing
  1378. // update packet on another queue. Receiving updates after kills results in unowned and undeletable
  1379. // scene objects in a viewer until that viewer is relogged in.
  1380. OutPacket(kill, ThrottleOutPacketType.Task);
  1381. }
  1382. }
  1383. else
  1384. {
  1385. // OutPacket(kill, ThrottleOutPacketType.State);
  1386. OutPacket(kill, ThrottleOutPacketType.Task);
  1387. }
  1388. }
  1389. /// <summary>
  1390. /// Send information about the items contained in a folder to the client.
  1391. ///
  1392. /// XXX This method needs some refactoring loving
  1393. /// </summary>
  1394. /// <param name="ownerID">The owner of the folder</param>
  1395. /// <param name="folderID">The id of the folder</param>
  1396. /// <param name="items">The items contained in the folder identified by folderID</param>
  1397. /// <param name="folders"></param>
  1398. /// <param name="fetchFolders">Do we need to send folder information?</param>
  1399. /// <param name="fetchItems">Do we need to send item information?</param>
  1400. public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items,
  1401. List<InventoryFolderBase> folders, int version,
  1402. bool fetchFolders, bool fetchItems)
  1403. {
  1404. // An inventory descendents packet consists of a single agent section and an inventory details
  1405. // section for each inventory item. The size of each inventory item is approximately 550 bytes.
  1406. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent
  1407. // packets containing metadata for in excess of 100 items. But in practice, there may be other
  1408. // factors (e.g. firewalls) restraining the maximum UDP packet size. See,
  1409. //
  1410. // http://opensimulator.org/mantis/view.php?id=226
  1411. //
  1412. // for one example of this kind of thing. In fact, the Linden servers appear to only send about
  1413. // 6 to 7 items at a time, so let's stick with 6
  1414. int MAX_ITEMS_PER_PACKET = 5;
  1415. int MAX_FOLDERS_PER_PACKET = 6;
  1416. int totalItems = fetchItems ? items.Count : 0;
  1417. int totalFolders = fetchFolders ? folders.Count : 0;
  1418. int itemsSent = 0;
  1419. int foldersSent = 0;
  1420. int foldersToSend = 0;
  1421. int itemsToSend = 0;
  1422. InventoryDescendentsPacket currentPacket = null;
  1423. // Handle empty folders
  1424. //
  1425. if (totalItems == 0 && totalFolders == 0)
  1426. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, 0, 0);
  1427. // To preserve SL compatibility, we will NOT combine folders and items in one packet
  1428. //
  1429. while (itemsSent < totalItems || foldersSent < totalFolders)
  1430. {
  1431. if (currentPacket == null) // Start a new packet
  1432. {
  1433. foldersToSend = totalFolders - foldersSent;
  1434. if (foldersToSend > MAX_FOLDERS_PER_PACKET)
  1435. foldersToSend = MAX_FOLDERS_PER_PACKET;
  1436. if (foldersToSend == 0)
  1437. {
  1438. itemsToSend = totalItems - itemsSent;
  1439. if (itemsToSend > MAX_ITEMS_PER_PACKET)
  1440. itemsToSend = MAX_ITEMS_PER_PACKET;
  1441. }
  1442. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, foldersToSend, itemsToSend);
  1443. }
  1444. if (foldersToSend-- > 0)
  1445. currentPacket.FolderData[foldersSent % MAX_FOLDERS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]);
  1446. else if (itemsToSend-- > 0)
  1447. currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]);
  1448. else
  1449. {
  1450. // m_log.DebugFormat(
  1451. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1452. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1453. currentPacket = null;
  1454. }
  1455. }
  1456. if (currentPacket != null)
  1457. {
  1458. // m_log.DebugFormat(
  1459. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1460. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1461. }
  1462. }
  1463. private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder)
  1464. {
  1465. InventoryDescendentsPacket.FolderDataBlock newBlock = new InventoryDescendentsPacket.FolderDataBlock();
  1466. newBlock.FolderID = folder.ID;
  1467. newBlock.Name = Util.StringToBytes256(folder.Name);
  1468. newBlock.ParentID = folder.ParentID;
  1469. newBlock.Type = (sbyte)folder.Type;
  1470. return newBlock;
  1471. }
  1472. private InventoryDescendentsPacket.ItemDataBlock CreateItemDataBlock(InventoryItemBase item)
  1473. {
  1474. InventoryDescendentsPacket.ItemDataBlock newBlock = new InventoryDescendentsPacket.ItemDataBlock();
  1475. newBlock.ItemID = item.ID;
  1476. newBlock.AssetID = item.AssetID;
  1477. newBlock.CreatorID = item.CreatorIdAsUuid;
  1478. newBlock.BaseMask = item.BasePermissions;
  1479. newBlock.Description = Util.StringToBytes256(item.Description);
  1480. newBlock.EveryoneMask = item.EveryOnePermissions;
  1481. newBlock.OwnerMask = item.CurrentPermissions;
  1482. newBlock.FolderID = item.Folder;
  1483. newBlock.InvType = (sbyte)item.InvType;
  1484. newBlock.Name = Util.StringToBytes256(item.Name);
  1485. newBlock.NextOwnerMask = item.NextPermissions;
  1486. newBlock.OwnerID = item.Owner;
  1487. newBlock.Type = (sbyte)item.AssetType;
  1488. newBlock.GroupID = item.GroupID;
  1489. newBlock.GroupOwned = item.GroupOwned;
  1490. newBlock.GroupMask = item.GroupPermissions;
  1491. newBlock.CreationDate = item.CreationDate;
  1492. newBlock.SalePrice = item.SalePrice;
  1493. newBlock.SaleType = item.SaleType;
  1494. newBlock.Flags = item.Flags;
  1495. newBlock.CRC =
  1496. Helpers.InventoryCRC(newBlock.CreationDate, newBlock.SaleType,
  1497. newBlock.InvType, newBlock.Type,
  1498. newBlock.AssetID, newBlock.GroupID,
  1499. newBlock.SalePrice,
  1500. newBlock.OwnerID, newBlock.CreatorID,
  1501. newBlock.ItemID, newBlock.FolderID,
  1502. newBlock.EveryoneMask,
  1503. newBlock.Flags, newBlock.OwnerMask,
  1504. newBlock.GroupMask, newBlock.NextOwnerMask);
  1505. return newBlock;
  1506. }
  1507. private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet)
  1508. {
  1509. packet.FolderData = new InventoryDescendentsPacket.FolderDataBlock[1];
  1510. packet.FolderData[0] = new InventoryDescendentsPacket.FolderDataBlock();
  1511. packet.FolderData[0].FolderID = UUID.Zero;
  1512. packet.FolderData[0].ParentID = UUID.Zero;
  1513. packet.FolderData[0].Type = -1;
  1514. packet.FolderData[0].Name = new byte[0];
  1515. }
  1516. private void AddNullItemBlockToDescendentsPacket(ref InventoryDescendentsPacket packet)
  1517. {
  1518. packet.ItemData = new InventoryDescendentsPacket.ItemDataBlock[1];
  1519. packet.ItemData[0] = new InventoryDescendentsPacket.ItemDataBlock();
  1520. packet.ItemData[0].ItemID = UUID.Zero;
  1521. packet.ItemData[0].AssetID = UUID.Zero;
  1522. packet.ItemData[0].CreatorID = UUID.Zero;
  1523. packet.ItemData[0].BaseMask = 0;
  1524. packet.ItemData[0].Description = new byte[0];
  1525. packet.ItemData[0].EveryoneMask = 0;
  1526. packet.ItemData[0].OwnerMask = 0;
  1527. packet.ItemData[0].FolderID = UUID.Zero;
  1528. packet.ItemData[0].InvType = (sbyte)0;
  1529. packet.ItemData[0].Name = new byte[0];
  1530. packet.ItemData[0].NextOwnerMask = 0;
  1531. packet.ItemData[0].OwnerID = UUID.Zero;
  1532. packet.ItemData[0].Type = -1;
  1533. packet.ItemData[0].GroupID = UUID.Zero;
  1534. packet.ItemData[0].GroupOwned = false;
  1535. packet.ItemData[0].GroupMask = 0;
  1536. packet.ItemData[0].CreationDate = 0;
  1537. packet.ItemData[0].SalePrice = 0;
  1538. packet.ItemData[0].SaleType = 0;
  1539. packet.ItemData[0].Flags = 0;
  1540. // No need to add CRC
  1541. }
  1542. private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int descendents, int folders, int items)
  1543. {
  1544. InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents);
  1545. descend.Header.Zerocoded = true;
  1546. descend.AgentData.AgentID = AgentId;
  1547. descend.AgentData.OwnerID = ownerID;
  1548. descend.AgentData.FolderID = folderID;
  1549. descend.AgentData.Version = version;
  1550. descend.AgentData.Descendents = descendents;
  1551. if (folders > 0)
  1552. descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders];
  1553. else
  1554. AddNullFolderBlockToDecendentsPacket(ref descend);
  1555. if (items > 0)
  1556. descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items];
  1557. else
  1558. AddNullItemBlockToDescendentsPacket(ref descend);
  1559. return descend;
  1560. }
  1561. public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
  1562. {
  1563. const uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
  1564. FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
  1565. // TODO: don't create new blocks if recycling an old packet
  1566. inventoryReply.AgentData.AgentID = AgentId;
  1567. inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
  1568. inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
  1569. inventoryReply.InventoryData[0].ItemID = item.ID;
  1570. inventoryReply.InventoryData[0].AssetID = item.AssetID;
  1571. inventoryReply.InventoryData[0].CreatorID = item.CreatorIdAsUuid;
  1572. inventoryReply.InventoryData[0].BaseMask = item.BasePermissions;
  1573. inventoryReply.InventoryData[0].CreationDate = item.CreationDate;
  1574. inventoryReply.InventoryData[0].Description = Util.StringToBytes256(item.Description);
  1575. inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions;
  1576. inventoryReply.InventoryData[0].FolderID = item.Folder;
  1577. inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType;
  1578. inventoryReply.InventoryData[0].Name = Util.StringToBytes256(item.Name);
  1579. inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions;
  1580. inventoryReply.InventoryData[0].OwnerID = item.Owner;
  1581. inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions;
  1582. inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType;
  1583. inventoryReply.InventoryData[0].GroupID = item.GroupID;
  1584. inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned;
  1585. inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions;
  1586. inventoryReply.InventoryData[0].Flags = item.Flags;
  1587. inventoryReply.InventoryData[0].SalePrice = item.SalePrice;
  1588. inventoryReply.InventoryData[0].SaleType = item.SaleType;
  1589. inventoryReply.InventoryData[0].CRC =
  1590. Helpers.InventoryCRC(
  1591. 1000, 0, inventoryReply.InventoryData[0].InvType,
  1592. inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID,
  1593. inventoryReply.InventoryData[0].GroupID, 100,
  1594. inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID,
  1595. inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID,
  1596. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1597. FULL_MASK_PERMISSIONS);
  1598. inventoryReply.Header.Zerocoded = true;
  1599. OutPacket(inventoryReply, ThrottleOutPacketType.Asset);
  1600. }
  1601. protected void SendBulkUpdateInventoryFolder(InventoryFolderBase folderBase)
  1602. {
  1603. // We will use the same transaction id for all the separate packets to be sent out in this update.
  1604. UUID transactionId = UUID.Random();
  1605. List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks
  1606. = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1607. SendBulkUpdateInventoryFolderRecursive(folderBase, ref folderDataBlocks, transactionId);
  1608. if (folderDataBlocks.Count > 0)
  1609. {
  1610. // We'll end up with some unsent folder blocks if there were some empty folders at the end of the list
  1611. // Send these now
  1612. BulkUpdateInventoryPacket bulkUpdate
  1613. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1614. bulkUpdate.Header.Zerocoded = true;
  1615. bulkUpdate.AgentData.AgentID = AgentId;
  1616. bulkUpdate.AgentData.TransactionID = transactionId;
  1617. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1618. List<BulkUpdateInventoryPacket.ItemDataBlock> foo = new List<BulkUpdateInventoryPacket.ItemDataBlock>();
  1619. bulkUpdate.ItemData = foo.ToArray();
  1620. //m_log.Debug("SendBulkUpdateInventory :" + bulkUpdate);
  1621. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1622. }
  1623. }
  1624. /// <summary>
  1625. /// Recursively construct bulk update packets to send folders and items
  1626. /// </summary>
  1627. /// <param name="folder"></param>
  1628. /// <param name="folderDataBlocks"></param>
  1629. /// <param name="transactionId"></param>
  1630. private void SendBulkUpdateInventoryFolderRecursive(
  1631. InventoryFolderBase folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks,
  1632. UUID transactionId)
  1633. {
  1634. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1635. const int MAX_ITEMS_PER_PACKET = 5;
  1636. IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
  1637. // If there are any items then we have to start sending them off in this packet - the next folder will have
  1638. // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit
  1639. // being used on the Linden grid at 20081203).
  1640. InventoryCollection contents = invService.GetFolderContent(AgentId, folder.ID); // folder.RequestListOfItems();
  1641. List<InventoryItemBase> items = contents.Items;
  1642. while (items.Count > 0)
  1643. {
  1644. BulkUpdateInventoryPacket bulkUpdate
  1645. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1646. bulkUpdate.Header.Zerocoded = true;
  1647. bulkUpdate.AgentData.AgentID = AgentId;
  1648. bulkUpdate.AgentData.TransactionID = transactionId;
  1649. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1650. int itemsToSend = (items.Count > MAX_ITEMS_PER_PACKET ? MAX_ITEMS_PER_PACKET : items.Count);
  1651. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[itemsToSend];
  1652. for (int i = 0; i < itemsToSend; i++)
  1653. {
  1654. // Remove from the end of the list so that we don't incur a performance penalty
  1655. bulkUpdate.ItemData[i] = GenerateBulkUpdateItemDataBlock(items[items.Count - 1]);
  1656. items.RemoveAt(items.Count - 1);
  1657. }
  1658. //m_log.Debug("SendBulkUpdateInventoryRecursive :" + bulkUpdate);
  1659. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1660. folderDataBlocks = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1661. // If we're going to be sending another items packet then it needs to contain just the folder to which those
  1662. // items belong.
  1663. if (items.Count > 0)
  1664. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1665. }
  1666. List<InventoryFolderBase> subFolders = contents.Folders;
  1667. foreach (InventoryFolderBase subFolder in subFolders)
  1668. {
  1669. SendBulkUpdateInventoryFolderRecursive(subFolder, ref folderDataBlocks, transactionId);
  1670. }
  1671. }
  1672. /// <summary>
  1673. /// Generate a bulk update inventory data block for the given folder
  1674. /// </summary>
  1675. /// <param name="folder"></param>
  1676. /// <returns></returns>
  1677. private BulkUpdateInventoryPacket.FolderDataBlock GenerateBulkUpdateFolderDataBlock(InventoryFolderBase folder)
  1678. {
  1679. BulkUpdateInventoryPacket.FolderDataBlock folderBlock = new BulkUpdateInventoryPacket.FolderDataBlock();
  1680. folderBlock.FolderID = folder.ID;
  1681. folderBlock.ParentID = folder.ParentID;
  1682. folderBlock.Type = -1;
  1683. folderBlock.Name = Util.StringToBytes256(folder.Name);
  1684. return folderBlock;
  1685. }
  1686. /// <summary>
  1687. /// Generate a bulk update inventory data block for the given item
  1688. /// </summary>
  1689. /// <param name="item"></param>
  1690. /// <returns></returns>
  1691. private BulkUpdateInventoryPacket.ItemDataBlock GenerateBulkUpdateItemDataBlock(InventoryItemBase item)
  1692. {
  1693. BulkUpdateInventoryPacket.ItemDataBlock itemBlock = new BulkUpdateInventoryPacket.ItemDataBlock();
  1694. itemBlock.ItemID = item.ID;
  1695. itemBlock.AssetID = item.AssetID;
  1696. itemBlock.CreatorID = item.CreatorIdAsUuid;
  1697. itemBlock.BaseMask = item.BasePermissions;
  1698. itemBlock.Description = Util.StringToBytes256(item.Description);
  1699. itemBlock.EveryoneMask = item.EveryOnePermissions;
  1700. itemBlock.FolderID = item.Folder;
  1701. itemBlock.InvType = (sbyte)item.InvType;
  1702. itemBlock.Name = Util.StringToBytes256(item.Name);
  1703. itemBlock.NextOwnerMask = item.NextPermissions;
  1704. itemBlock.OwnerID = item.Owner;
  1705. itemBlock.OwnerMask = item.CurrentPermissions;
  1706. itemBlock.Type = (sbyte)item.AssetType;
  1707. itemBlock.GroupID = item.GroupID;
  1708. itemBlock.GroupOwned = item.GroupOwned;
  1709. itemBlock.GroupMask = item.GroupPermissions;
  1710. itemBlock.Flags = item.Flags;
  1711. itemBlock.SalePrice = item.SalePrice;
  1712. itemBlock.SaleType = item.SaleType;
  1713. itemBlock.CreationDate = item.CreationDate;
  1714. itemBlock.CRC =
  1715. Helpers.InventoryCRC(
  1716. 1000, 0, itemBlock.InvType,
  1717. itemBlock.Type, itemBlock.AssetID,
  1718. itemBlock.GroupID, 100,
  1719. itemBlock.OwnerID, itemBlock.CreatorID,
  1720. itemBlock.ItemID, itemBlock.FolderID,
  1721. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  1722. (uint)PermissionMask.All);
  1723. return itemBlock;
  1724. }
  1725. public void SendBulkUpdateInventory(InventoryNodeBase node)
  1726. {
  1727. if (node is InventoryItemBase)
  1728. SendBulkUpdateInventoryItem((InventoryItemBase)node);
  1729. else if (node is InventoryFolderBase)
  1730. SendBulkUpdateInventoryFolder((InventoryFolderBase)node);
  1731. else
  1732. m_log.ErrorFormat("[CLIENT]: Client for {0} sent unknown inventory node named {1}", Name, node.Name);
  1733. }
  1734. protected void SendBulkUpdateInventoryItem(InventoryItemBase item)
  1735. {
  1736. const uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
  1737. BulkUpdateInventoryPacket bulkUpdate
  1738. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1739. bulkUpdate.AgentData.AgentID = AgentId;
  1740. bulkUpdate.AgentData.TransactionID = UUID.Random();
  1741. bulkUpdate.FolderData = new BulkUpdateInventoryPacket.FolderDataBlock[1];
  1742. bulkUpdate.FolderData[0] = new BulkUpdateInventoryPacket.FolderDataBlock();
  1743. bulkUpdate.FolderData[0].FolderID = UUID.Zero;
  1744. bulkUpdate.FolderData[0].ParentID = UUID.Zero;
  1745. bulkUpdate.FolderData[0].Type = -1;
  1746. bulkUpdate.FolderData[0].Name = new byte[0];
  1747. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[1];
  1748. bulkUpdate.ItemData[0] = new BulkUpdateInventoryPacket.ItemDataBlock();
  1749. bulkUpdate.ItemData[0].ItemID = item.ID;
  1750. bulkUpdate.ItemData[0].AssetID = item.AssetID;
  1751. bulkUpdate.ItemData[0].CreatorID = item.CreatorIdAsUuid;
  1752. bulkUpdate.ItemData[0].BaseMask = item.BasePermissions;
  1753. bulkUpdate.ItemData[0].CreationDate = item.CreationDate;
  1754. bulkUpdate.ItemData[0].Description = Util.StringToBytes256(item.Description);
  1755. bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions;
  1756. bulkUpdate.ItemData[0].FolderID = item.Folder;
  1757. bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType;
  1758. bulkUpdate.ItemData[0].Name = Util.StringToBytes256(item.Name);
  1759. bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions;
  1760. bulkUpdate.ItemData[0].OwnerID = item.Owner;
  1761. bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions;
  1762. bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType;
  1763. bulkUpdate.ItemData[0].GroupID = item.GroupID;
  1764. bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned;
  1765. bulkUpdate.ItemData[0].GroupMask = item.GroupPermissions;
  1766. bulkUpdate.ItemData[0].Flags = item.Flags;
  1767. bulkUpdate.ItemData[0].SalePrice = item.SalePrice;
  1768. bulkUpdate.ItemData[0].SaleType = item.SaleType;
  1769. bulkUpdate.ItemData[0].CRC =
  1770. Helpers.InventoryCRC(1000, 0, bulkUpdate.ItemData[0].InvType,
  1771. bulkUpdate.ItemData[0].Type, bulkUpdate.ItemData[0].AssetID,
  1772. bulkUpdate.ItemData[0].GroupID, 100,
  1773. bulkUpdate.ItemData[0].OwnerID, bulkUpdate.ItemData[0].CreatorID,
  1774. bulkUpdate.ItemData[0].ItemID, bulkUpdate.ItemData[0].FolderID,
  1775. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1776. FULL_MASK_PERMISSIONS);
  1777. bulkUpdate.Header.Zerocoded = true;
  1778. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1779. }
  1780. /// <see>IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase)</see>
  1781. public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
  1782. {
  1783. const uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
  1784. UpdateCreateInventoryItemPacket InventoryReply
  1785. = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(
  1786. PacketType.UpdateCreateInventoryItem);
  1787. // TODO: don't create new blocks if recycling an old packet
  1788. InventoryReply.AgentData.AgentID = AgentId;
  1789. InventoryReply.AgentData.SimApproved = true;
  1790. InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
  1791. InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
  1792. InventoryReply.InventoryData[0].ItemID = Item.ID;
  1793. InventoryReply.InventoryData[0].AssetID = Item.AssetID;
  1794. InventoryReply.InventoryData[0].CreatorID = Item.CreatorIdAsUuid;
  1795. InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions;
  1796. InventoryReply.InventoryData[0].Description = Util.StringToBytes256(Item.Description);
  1797. InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions;
  1798. InventoryReply.InventoryData[0].FolderID = Item.Folder;
  1799. InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType;
  1800. InventoryReply.InventoryData[0].Name = Util.StringToBytes256(Item.Name);
  1801. InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions;
  1802. InventoryReply.InventoryData[0].OwnerID = Item.Owner;
  1803. InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions;
  1804. InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType;
  1805. InventoryReply.InventoryData[0].CallbackID = callbackId;
  1806. InventoryReply.InventoryData[0].GroupID = Item.GroupID;
  1807. InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned;
  1808. InventoryReply.InventoryData[0].GroupMask = Item.GroupPermissions;
  1809. InventoryReply.InventoryData[0].Flags = Item.Flags;
  1810. InventoryReply.InventoryData[0].SalePrice = Item.SalePrice;
  1811. InventoryReply.InventoryData[0].SaleType = Item.SaleType;
  1812. InventoryReply.InventoryData[0].CreationDate = Item.CreationDate;
  1813. InventoryReply.InventoryData[0].CRC =
  1814. Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType,
  1815. InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID,
  1816. InventoryReply.InventoryData[0].GroupID, 100,
  1817. InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID,
  1818. InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID,
  1819. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1820. FULL_MASK_PERMISSIONS);
  1821. InventoryReply.Header.Zerocoded = true;
  1822. OutPacket(InventoryReply, ThrottleOutPacketType.Asset);
  1823. }
  1824. public void SendRemoveInventoryItem(UUID itemID)
  1825. {
  1826. RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem);
  1827. // TODO: don't create new blocks if recycling an old packet
  1828. remove.AgentData.AgentID = AgentId;
  1829. remove.AgentData.SessionID = m_sessionId;
  1830. remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
  1831. remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
  1832. remove.InventoryData[0].ItemID = itemID;
  1833. remove.Header.Zerocoded = true;
  1834. OutPacket(remove, ThrottleOutPacketType.Asset);
  1835. }
  1836. public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
  1837. {
  1838. ScriptControlChangePacket scriptcontrol = (ScriptControlChangePacket)PacketPool.Instance.GetPacket(PacketType.ScriptControlChange);
  1839. ScriptControlChangePacket.DataBlock[] data = new ScriptControlChangePacket.DataBlock[1];
  1840. ScriptControlChangePacket.DataBlock ddata = new ScriptControlChangePacket.DataBlock();
  1841. ddata.Controls = (uint)controls;
  1842. ddata.PassToAgent = passToAgent;
  1843. ddata.TakeControls = TakeControls;
  1844. data[0] = ddata;
  1845. scriptcontrol.Data = data;
  1846. OutPacket(scriptcontrol, ThrottleOutPacketType.Task);
  1847. }
  1848. public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
  1849. {
  1850. ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
  1851. replytask.InventoryData.TaskID = taskID;
  1852. replytask.InventoryData.Serial = serial;
  1853. replytask.InventoryData.Filename = fileName;
  1854. OutPacket(replytask, ThrottleOutPacketType.Asset);
  1855. }
  1856. public void SendXferPacket(ulong xferID, uint packet, byte[] data)
  1857. {
  1858. SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket);
  1859. sendXfer.XferID.ID = xferID;
  1860. sendXfer.XferID.Packet = packet;
  1861. sendXfer.DataPacket.Data = data;
  1862. OutPacket(sendXfer, ThrottleOutPacketType.Asset);
  1863. }
  1864. public void SendAbortXferPacket(ulong xferID)
  1865. {
  1866. AbortXferPacket xferItem = (AbortXferPacket)PacketPool.Instance.GetPacket(PacketType.AbortXfer);
  1867. xferItem.XferID.ID = xferID;
  1868. OutPacket(xferItem, ThrottleOutPacketType.Asset);
  1869. }
  1870. public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
  1871. int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
  1872. int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
  1873. int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
  1874. {
  1875. EconomyDataPacket economyData = (EconomyDataPacket)PacketPool.Instance.GetPacket(PacketType.EconomyData);
  1876. economyData.Info.EnergyEfficiency = EnergyEfficiency;
  1877. economyData.Info.ObjectCapacity = ObjectCapacity;
  1878. economyData.Info.ObjectCount = ObjectCount;
  1879. economyData.Info.PriceEnergyUnit = PriceEnergyUnit;
  1880. economyData.Info.PriceGroupCreate = PriceGroupCreate;
  1881. economyData.Info.PriceObjectClaim = PriceObjectClaim;
  1882. economyData.Info.PriceObjectRent = PriceObjectRent;
  1883. economyData.Info.PriceObjectScaleFactor = PriceObjectScaleFactor;
  1884. economyData.Info.PriceParcelClaim = PriceParcelClaim;
  1885. economyData.Info.PriceParcelClaimFactor = PriceParcelClaimFactor;
  1886. economyData.Info.PriceParcelRent = PriceParcelRent;
  1887. economyData.Info.PricePublicObjectDecay = PricePublicObjectDecay;
  1888. economyData.Info.PricePublicObjectDelete = PricePublicObjectDelete;
  1889. economyData.Info.PriceRentLight = PriceRentLight;
  1890. economyData.Info.PriceUpload = PriceUpload;
  1891. economyData.Info.TeleportMinPrice = TeleportMinPrice;
  1892. economyData.Info.TeleportPriceExponent = TeleportPriceExponent;
  1893. economyData.Header.Reliable = true;
  1894. OutPacket(economyData, ThrottleOutPacketType.Task);
  1895. }
  1896. public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
  1897. {
  1898. //construct the AvatarPickerReply packet.
  1899. AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
  1900. replyPacket.AgentData.AgentID = AgentData.AgentID;
  1901. replyPacket.AgentData.QueryID = AgentData.QueryID;
  1902. //int i = 0;
  1903. List<AvatarPickerReplyPacket.DataBlock> data_block = new List<AvatarPickerReplyPacket.DataBlock>();
  1904. foreach (AvatarPickerReplyDataArgs arg in Data)
  1905. {
  1906. AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock();
  1907. db.AvatarID = arg.AvatarID;
  1908. db.FirstName = arg.FirstName;
  1909. db.LastName = arg.LastName;
  1910. data_block.Add(db);
  1911. }
  1912. replyPacket.Data = data_block.ToArray();
  1913. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  1914. }
  1915. public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
  1916. {
  1917. m_activeGroupID = activegroupid;
  1918. m_activeGroupName = groupname;
  1919. m_activeGroupPowers = grouppowers;
  1920. AgentDataUpdatePacket sendAgentDataUpdate = (AgentDataUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentDataUpdate);
  1921. sendAgentDataUpdate.AgentData.ActiveGroupID = activegroupid;
  1922. sendAgentDataUpdate.AgentData.AgentID = agentid;
  1923. sendAgentDataUpdate.AgentData.FirstName = Util.StringToBytes256(firstname);
  1924. sendAgentDataUpdate.AgentData.GroupName = Util.StringToBytes256(groupname);
  1925. sendAgentDataUpdate.AgentData.GroupPowers = grouppowers;
  1926. sendAgentDataUpdate.AgentData.GroupTitle = Util.StringToBytes256(grouptitle);
  1927. sendAgentDataUpdate.AgentData.LastName = Util.StringToBytes256(lastname);
  1928. OutPacket(sendAgentDataUpdate, ThrottleOutPacketType.Task);
  1929. }
  1930. /// <summary>
  1931. /// Send an alert message to the client. On the Linden client (tested 1.19.1.4), this pops up a brief duration
  1932. /// blue information box in the bottom right hand corner.
  1933. /// </summary>
  1934. /// <param name="message"></param>
  1935. public void SendAlertMessage(string message)
  1936. {
  1937. AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
  1938. alertPack.AlertData = new AlertMessagePacket.AlertDataBlock();
  1939. alertPack.AlertData.Message = Util.StringToBytes256(message);
  1940. alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[0];
  1941. OutPacket(alertPack, ThrottleOutPacketType.Task);
  1942. }
  1943. /// <summary>
  1944. /// Send an agent alert message to the client.
  1945. /// </summary>
  1946. /// <param name="message"></param>
  1947. /// <param name="modal">On the linden client, if this true then it displays a one button text box placed in the
  1948. /// middle of the window. If false, the message is displayed in a brief duration blue information box (as for
  1949. /// the AlertMessage packet).</param>
  1950. public void SendAgentAlertMessage(string message, bool modal)
  1951. {
  1952. OutPacket(BuildAgentAlertPacket(message, modal), ThrottleOutPacketType.Task);
  1953. }
  1954. /// <summary>
  1955. /// Construct an agent alert packet
  1956. /// </summary>
  1957. /// <param name="message"></param>
  1958. /// <param name="modal"></param>
  1959. /// <returns></returns>
  1960. public AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal)
  1961. {
  1962. AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage);
  1963. alertPack.AgentData.AgentID = AgentId;
  1964. alertPack.AlertData.Message = Util.StringToBytes256(message);
  1965. alertPack.AlertData.Modal = modal;
  1966. return alertPack;
  1967. }
  1968. public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
  1969. string url)
  1970. {
  1971. LoadURLPacket loadURL = (LoadURLPacket)PacketPool.Instance.GetPacket(PacketType.LoadURL);
  1972. loadURL.Data.ObjectName = Util.StringToBytes256(objectname);
  1973. loadURL.Data.ObjectID = objectID;
  1974. loadURL.Data.OwnerID = ownerID;
  1975. loadURL.Data.OwnerIsGroup = groupOwned;
  1976. loadURL.Data.Message = Util.StringToBytes256(message);
  1977. loadURL.Data.URL = Util.StringToBytes256(url);
  1978. OutPacket(loadURL, ThrottleOutPacketType.Task);
  1979. }
  1980. public void SendDialog(
  1981. string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg,
  1982. UUID textureID, int ch, string[] buttonlabels)
  1983. {
  1984. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  1985. dialog.Data.ObjectID = objectID;
  1986. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  1987. // this is the username of the *owner*
  1988. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  1989. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  1990. dialog.Data.Message = Util.StringToBytes1024(msg);
  1991. dialog.Data.ImageID = textureID;
  1992. dialog.Data.ChatChannel = ch;
  1993. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length];
  1994. for (int i = 0; i < buttonlabels.Length; i++)
  1995. {
  1996. buttons[i] = new ScriptDialogPacket.ButtonsBlock();
  1997. buttons[i].ButtonLabel = Util.StringToBytes256(buttonlabels[i]);
  1998. }
  1999. dialog.Buttons = buttons;
  2000. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  2001. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  2002. dialog.OwnerData[0].OwnerID = ownerID;
  2003. OutPacket(dialog, ThrottleOutPacketType.Task);
  2004. }
  2005. public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
  2006. {
  2007. PreloadSoundPacket preSound = (PreloadSoundPacket)PacketPool.Instance.GetPacket(PacketType.PreloadSound);
  2008. // TODO: don't create new blocks if recycling an old packet
  2009. preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1];
  2010. preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock();
  2011. preSound.DataBlock[0].ObjectID = objectID;
  2012. preSound.DataBlock[0].OwnerID = ownerID;
  2013. preSound.DataBlock[0].SoundID = soundID;
  2014. preSound.Header.Zerocoded = true;
  2015. OutPacket(preSound, ThrottleOutPacketType.Task);
  2016. }
  2017. public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
  2018. {
  2019. AttachedSoundPacket sound = (AttachedSoundPacket)PacketPool.Instance.GetPacket(PacketType.AttachedSound);
  2020. sound.DataBlock.SoundID = soundID;
  2021. sound.DataBlock.ObjectID = objectID;
  2022. sound.DataBlock.OwnerID = ownerID;
  2023. sound.DataBlock.Gain = gain;
  2024. sound.DataBlock.Flags = flags;
  2025. OutPacket(sound, ThrottleOutPacketType.Task);
  2026. }
  2027. public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
  2028. {
  2029. SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
  2030. sound.SoundData.SoundID = soundID;
  2031. sound.SoundData.OwnerID = ownerID;
  2032. sound.SoundData.ObjectID = objectID;
  2033. sound.SoundData.ParentID = parentID;
  2034. sound.SoundData.Handle = handle;
  2035. sound.SoundData.Position = position;
  2036. sound.SoundData.Gain = gain;
  2037. OutPacket(sound, ThrottleOutPacketType.Task);
  2038. }
  2039. public void SendAttachedSoundGainChange(UUID objectID, float gain)
  2040. {
  2041. AttachedSoundGainChangePacket sound = (AttachedSoundGainChangePacket)PacketPool.Instance.GetPacket(PacketType.AttachedSoundGainChange);
  2042. sound.DataBlock.ObjectID = objectID;
  2043. sound.DataBlock.Gain = gain;
  2044. OutPacket(sound, ThrottleOutPacketType.Task);
  2045. }
  2046. public void SendSunPos(Vector3 Position, Vector3 Velocity, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
  2047. {
  2048. // Viewers based on the Linden viwer code, do wacky things for oribital positions from Midnight to Sunrise
  2049. // So adjust for that
  2050. // Contributed by: Godfrey
  2051. if (OrbitalPosition > m_sunPainDaHalfOrbitalCutoff) // things get weird from midnight to sunrise
  2052. {
  2053. OrbitalPosition = (OrbitalPosition - m_sunPainDaHalfOrbitalCutoff) * 0.6666666667f + m_sunPainDaHalfOrbitalCutoff;
  2054. }
  2055. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2056. viewertime.TimeInfo.SunDirection = Position;
  2057. viewertime.TimeInfo.SunAngVelocity = Velocity;
  2058. // Sun module used to add 6 hours to adjust for linden sun hour, adding here
  2059. // to prevent existing code from breaking if it assumed that 6 hours were included.
  2060. // 21600 == 6 hours * 60 minutes * 60 Seconds
  2061. viewertime.TimeInfo.UsecSinceStart = CurrentTime + 21600;
  2062. viewertime.TimeInfo.SecPerDay = SecondsPerSunCycle;
  2063. viewertime.TimeInfo.SecPerYear = SecondsPerYear;
  2064. viewertime.TimeInfo.SunPhase = OrbitalPosition;
  2065. viewertime.Header.Reliable = false;
  2066. viewertime.Header.Zerocoded = true;
  2067. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2068. }
  2069. // Currently Deprecated
  2070. public void SendViewerTime(int phase)
  2071. {
  2072. /*
  2073. Console.WriteLine("SunPhase: {0}", phase);
  2074. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2075. //viewertime.TimeInfo.SecPerDay = 86400;
  2076. //viewertime.TimeInfo.SecPerYear = 31536000;
  2077. viewertime.TimeInfo.SecPerDay = 1000;
  2078. viewertime.TimeInfo.SecPerYear = 365000;
  2079. viewertime.TimeInfo.SunPhase = 1;
  2080. int sunPhase = (phase + 2) / 2;
  2081. if ((sunPhase < 6) || (sunPhase > 36))
  2082. {
  2083. viewertime.TimeInfo.SunDirection = new Vector3(0f, 0.8f, -0.8f);
  2084. Console.WriteLine("sending night");
  2085. }
  2086. else
  2087. {
  2088. if (sunPhase < 12)
  2089. {
  2090. sunPhase = 12;
  2091. }
  2092. sunPhase = sunPhase - 12;
  2093. float yValue = 0.1f * (sunPhase);
  2094. Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue);
  2095. if (yValue > 1.2f)
  2096. {
  2097. yValue = yValue - 1.2f;
  2098. }
  2099. yValue = Util.Clip(yValue, 0, 1);
  2100. if (sunPhase < 14)
  2101. {
  2102. yValue = 1 - yValue;
  2103. }
  2104. if (sunPhase < 12)
  2105. {
  2106. yValue *= -1;
  2107. }
  2108. viewertime.TimeInfo.SunDirection = new Vector3(0f, yValue, 0.3f);
  2109. Console.WriteLine("sending sun update " + yValue);
  2110. }
  2111. viewertime.TimeInfo.SunAngVelocity = new Vector3(0, 0.0f, 10.0f);
  2112. viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch();
  2113. viewertime.Header.Reliable = false;
  2114. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2115. */
  2116. }
  2117. public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
  2118. {
  2119. ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
  2120. packet.Header.Reliable = false;
  2121. packet.Header.Zerocoded = true;
  2122. packet.AgentData.AgentID = AgentId;
  2123. packet.AgentData.SessionID = SessionId;
  2124. packet.Effect = effectBlocks;
  2125. // OutPacket(packet, ThrottleOutPacketType.State);
  2126. OutPacket(packet, ThrottleOutPacketType.Task);
  2127. }
  2128. public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember,
  2129. string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
  2130. UUID partnerID)
  2131. {
  2132. AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply);
  2133. avatarReply.AgentData.AgentID = AgentId;
  2134. avatarReply.AgentData.AvatarID = avatarID;
  2135. if (aboutText != null)
  2136. avatarReply.PropertiesData.AboutText = Util.StringToBytes1024(aboutText);
  2137. else
  2138. avatarReply.PropertiesData.AboutText = Utils.EmptyBytes;
  2139. avatarReply.PropertiesData.BornOn = Util.StringToBytes256(bornOn);
  2140. avatarReply.PropertiesData.CharterMember = charterMember;
  2141. if (flAbout != null)
  2142. avatarReply.PropertiesData.FLAboutText = Util.StringToBytes256(flAbout);
  2143. else
  2144. avatarReply.PropertiesData.FLAboutText = Utils.EmptyBytes;
  2145. avatarReply.PropertiesData.Flags = flags;
  2146. avatarReply.PropertiesData.FLImageID = flImageID;
  2147. avatarReply.PropertiesData.ImageID = imageID;
  2148. avatarReply.PropertiesData.ProfileURL = Util.StringToBytes256(profileURL);
  2149. avatarReply.PropertiesData.PartnerID = partnerID;
  2150. OutPacket(avatarReply, ThrottleOutPacketType.Task);
  2151. }
  2152. /// <summary>
  2153. /// Send the client an Estate message blue box pop-down with a single OK button
  2154. /// </summary>
  2155. /// <param name="FromAvatarID"></param>
  2156. /// <param name="fromSessionID"></param>
  2157. /// <param name="FromAvatarName"></param>
  2158. /// <param name="Message"></param>
  2159. public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
  2160. {
  2161. if (!ChildAgentStatus())
  2162. SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3()));
  2163. //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch());
  2164. }
  2165. public void SendLogoutPacket()
  2166. {
  2167. // I know this is a bit of a hack, however there are times when you don't
  2168. // want to send this, but still need to do the rest of the shutdown process
  2169. // this method gets called from the packet server.. which makes it practically
  2170. // impossible to do any other way.
  2171. if (m_SendLogoutPacketWhenClosing)
  2172. {
  2173. LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply);
  2174. // TODO: don't create new blocks if recycling an old packet
  2175. logReply.AgentData.AgentID = AgentId;
  2176. logReply.AgentData.SessionID = SessionId;
  2177. logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
  2178. logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
  2179. logReply.InventoryData[0].ItemID = UUID.Zero;
  2180. OutPacket(logReply, ThrottleOutPacketType.Task);
  2181. }
  2182. }
  2183. public void SendHealth(float health)
  2184. {
  2185. HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage);
  2186. healthpacket.HealthData.Health = health;
  2187. OutPacket(healthpacket, ThrottleOutPacketType.Task);
  2188. }
  2189. public void SendAgentOnline(UUID[] agentIDs)
  2190. {
  2191. OnlineNotificationPacket onp = new OnlineNotificationPacket();
  2192. OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2193. for (int i = 0; i < agentIDs.Length; i++)
  2194. {
  2195. OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
  2196. onpbl.AgentID = agentIDs[i];
  2197. onpb[i] = onpbl;
  2198. }
  2199. onp.AgentBlock = onpb;
  2200. onp.Header.Reliable = true;
  2201. OutPacket(onp, ThrottleOutPacketType.Task);
  2202. }
  2203. public void SendAgentOffline(UUID[] agentIDs)
  2204. {
  2205. OfflineNotificationPacket offp = new OfflineNotificationPacket();
  2206. OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2207. for (int i = 0; i < agentIDs.Length; i++)
  2208. {
  2209. OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
  2210. onpbl.AgentID = agentIDs[i];
  2211. offpb[i] = onpbl;
  2212. }
  2213. offp.AgentBlock = offpb;
  2214. offp.Header.Reliable = true;
  2215. OutPacket(offp, ThrottleOutPacketType.Task);
  2216. }
  2217. public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
  2218. Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
  2219. {
  2220. AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket();
  2221. avatarSitResponse.SitObject.ID = TargetID;
  2222. if (CameraAtOffset != Vector3.Zero)
  2223. {
  2224. avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset;
  2225. avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset;
  2226. }
  2227. avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook;
  2228. avatarSitResponse.SitTransform.AutoPilot = autopilot;
  2229. avatarSitResponse.SitTransform.SitPosition = OffsetPos;
  2230. avatarSitResponse.SitTransform.SitRotation = SitOrientation;
  2231. OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
  2232. }
  2233. public void SendAdminResponse(UUID Token, uint AdminLevel)
  2234. {
  2235. GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
  2236. GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock();
  2237. GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock();
  2238. adb.AgentID = AgentId;
  2239. adb.SessionID = SessionId; // More security
  2240. gdb.GodLevel = (byte)AdminLevel;
  2241. gdb.Token = Token;
  2242. //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
  2243. respondPacket.GrantData = gdb;
  2244. respondPacket.AgentData = adb;
  2245. OutPacket(respondPacket, ThrottleOutPacketType.Task);
  2246. }
  2247. public void SendGroupMembership(GroupMembershipData[] GroupMembership)
  2248. {
  2249. m_groupPowers.Clear();
  2250. AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket();
  2251. AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length];
  2252. for (int i = 0; i < GroupMembership.Length; i++)
  2253. {
  2254. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  2255. AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock();
  2256. Group.AcceptNotices = GroupMembership[i].AcceptNotices;
  2257. Group.Contribution = GroupMembership[i].Contribution;
  2258. Group.GroupID = GroupMembership[i].GroupID;
  2259. Group.GroupInsigniaID = GroupMembership[i].GroupPicture;
  2260. Group.GroupName = Util.StringToBytes256(GroupMembership[i].GroupName);
  2261. Group.GroupPowers = GroupMembership[i].GroupPowers;
  2262. Groups[i] = Group;
  2263. }
  2264. Groupupdate.GroupData = Groups;
  2265. Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock();
  2266. Groupupdate.AgentData.AgentID = AgentId;
  2267. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2268. try
  2269. {
  2270. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2271. if (eq != null)
  2272. {
  2273. eq.GroupMembership(Groupupdate, this.AgentId);
  2274. }
  2275. }
  2276. catch (Exception ex)
  2277. {
  2278. m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString());
  2279. m_log.Warn("sending group membership data via UDP");
  2280. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2281. }
  2282. }
  2283. public void SendGroupNameReply(UUID groupLLUID, string GroupName)
  2284. {
  2285. UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket();
  2286. UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1];
  2287. UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock();
  2288. uidnamebloc.ID = groupLLUID;
  2289. uidnamebloc.GroupName = Util.StringToBytes256(GroupName);
  2290. uidnameblock[0] = uidnamebloc;
  2291. pack.UUIDNameBlock = uidnameblock;
  2292. OutPacket(pack, ThrottleOutPacketType.Task);
  2293. }
  2294. public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
  2295. {
  2296. LandStatReplyPacket lsrp = new LandStatReplyPacket();
  2297. // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock();
  2298. LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length];
  2299. //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2300. // lsrepdb.
  2301. lsrp.RequestData.ReportType = reportType;
  2302. lsrp.RequestData.RequestFlags = requestFlags;
  2303. lsrp.RequestData.TotalObjectCount = resultCount;
  2304. for (int i = 0; i < lsrpia.Length; i++)
  2305. {
  2306. LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2307. lsrepdb.LocationX = lsrpia[i].LocationX;
  2308. lsrepdb.LocationY = lsrpia[i].LocationY;
  2309. lsrepdb.LocationZ = lsrpia[i].LocationZ;
  2310. lsrepdb.Score = lsrpia[i].Score;
  2311. lsrepdb.TaskID = lsrpia[i].TaskID;
  2312. lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID;
  2313. lsrepdb.TaskName = Util.StringToBytes256(lsrpia[i].TaskName);
  2314. lsrepdb.OwnerName = Util.StringToBytes256(lsrpia[i].OwnerName);
  2315. lsrepdba[i] = lsrepdb;
  2316. }
  2317. lsrp.ReportData = lsrepdba;
  2318. OutPacket(lsrp, ThrottleOutPacketType.Task);
  2319. }
  2320. public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
  2321. {
  2322. ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket();
  2323. scriptRunningReply.Script.ObjectID = objectID;
  2324. scriptRunningReply.Script.ItemID = itemID;
  2325. scriptRunningReply.Script.Running = running;
  2326. OutPacket(scriptRunningReply, ThrottleOutPacketType.Task);
  2327. }
  2328. public void SendAsset(AssetRequestToClient req)
  2329. {
  2330. if (req.AssetInf.Data == null)
  2331. {
  2332. m_log.ErrorFormat("Cannot send asset {0} ({1}), asset data is null",
  2333. req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
  2334. return;
  2335. }
  2336. //m_log.Debug("sending asset " + req.RequestAssetID);
  2337. TransferInfoPacket Transfer = new TransferInfoPacket();
  2338. Transfer.TransferInfo.ChannelType = 2;
  2339. Transfer.TransferInfo.Status = 0;
  2340. Transfer.TransferInfo.TargetType = 0;
  2341. if (req.AssetRequestSource == 2)
  2342. {
  2343. Transfer.TransferInfo.Params = new byte[20];
  2344. Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2345. int assType = req.AssetInf.Type;
  2346. Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
  2347. }
  2348. else if (req.AssetRequestSource == 3)
  2349. {
  2350. Transfer.TransferInfo.Params = req.Params;
  2351. // Transfer.TransferInfo.Params = new byte[100];
  2352. //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2353. //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
  2354. }
  2355. Transfer.TransferInfo.Size = req.AssetInf.Data.Length;
  2356. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2357. Transfer.Header.Zerocoded = true;
  2358. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2359. if (req.NumPackets == 1)
  2360. {
  2361. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2362. TransferPacket.TransferData.Packet = 0;
  2363. TransferPacket.TransferData.ChannelType = 2;
  2364. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2365. TransferPacket.TransferData.Data = req.AssetInf.Data;
  2366. TransferPacket.TransferData.Status = 1;
  2367. TransferPacket.Header.Zerocoded = true;
  2368. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2369. }
  2370. else
  2371. {
  2372. int processedLength = 0;
  2373. int maxChunkSize = Settings.MAX_PACKET_SIZE - 100;
  2374. int packetNumber = 0;
  2375. while (processedLength < req.AssetInf.Data.Length)
  2376. {
  2377. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2378. TransferPacket.TransferData.Packet = packetNumber;
  2379. TransferPacket.TransferData.ChannelType = 2;
  2380. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2381. int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
  2382. byte[] chunk = new byte[chunkSize];
  2383. Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
  2384. TransferPacket.TransferData.Data = chunk;
  2385. // 0 indicates more packets to come, 1 indicates last packet
  2386. if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
  2387. {
  2388. TransferPacket.TransferData.Status = 0;
  2389. }
  2390. else
  2391. {
  2392. TransferPacket.TransferData.Status = 1;
  2393. }
  2394. TransferPacket.Header.Zerocoded = true;
  2395. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2396. processedLength += chunkSize;
  2397. packetNumber++;
  2398. }
  2399. }
  2400. }
  2401. public void SendTexture(AssetBase TextureAsset)
  2402. {
  2403. }
  2404. public void SendRegionHandle(UUID regionID, ulong handle)
  2405. {
  2406. RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply);
  2407. reply.ReplyBlock.RegionID = regionID;
  2408. reply.ReplyBlock.RegionHandle = handle;
  2409. OutPacket(reply, ThrottleOutPacketType.Land);
  2410. }
  2411. public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
  2412. {
  2413. float dwell = 0.0f;
  2414. IDwellModule dwellModule = m_scene.RequestModuleInterface<IDwellModule>();
  2415. if (dwellModule != null)
  2416. dwell = dwellModule.GetDwell(land.GlobalID);
  2417. ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply);
  2418. reply.AgentData.AgentID = m_agentId;
  2419. reply.Data.ParcelID = parcelID;
  2420. reply.Data.OwnerID = land.OwnerID;
  2421. reply.Data.Name = Utils.StringToBytes(land.Name);
  2422. reply.Data.Desc = Utils.StringToBytes(land.Description);
  2423. reply.Data.ActualArea = land.Area;
  2424. reply.Data.BillableArea = land.Area; // TODO: what is this?
  2425. // Bit 0: Mature, bit 7: on sale, other bits: no idea
  2426. reply.Data.Flags = (byte)(
  2427. (info.AccessLevel > 13 ? (1 << 0) : 0) +
  2428. ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0));
  2429. Vector3 pos = land.UserLocation;
  2430. if (pos.Equals(Vector3.Zero))
  2431. {
  2432. pos = (land.AABBMax + land.AABBMin) * 0.5f;
  2433. }
  2434. reply.Data.GlobalX = info.RegionLocX + x;
  2435. reply.Data.GlobalY = info.RegionLocY + y;
  2436. reply.Data.GlobalZ = pos.Z;
  2437. reply.Data.SimName = Utils.StringToBytes(info.RegionName);
  2438. reply.Data.SnapshotID = land.SnapshotID;
  2439. reply.Data.Dwell = dwell;
  2440. reply.Data.SalePrice = land.SalePrice;
  2441. reply.Data.AuctionID = (int)land.AuctionID;
  2442. OutPacket(reply, ThrottleOutPacketType.Land);
  2443. }
  2444. public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
  2445. {
  2446. ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest);
  2447. packet.Data.ObjectName = Utils.StringToBytes(objName);
  2448. packet.Data.SimName = Utils.StringToBytes(simName);
  2449. packet.Data.SimPosition = pos;
  2450. packet.Data.LookAt = lookAt;
  2451. OutPacket(packet, ThrottleOutPacketType.Task);
  2452. }
  2453. public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
  2454. {
  2455. DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2456. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2457. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2458. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2459. packet.AgentData.AgentID = AgentId;
  2460. packet.QueryData[0].QueryID = queryID;
  2461. DirPlacesReplyPacket.QueryRepliesBlock[] replies =
  2462. new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2463. DirPlacesReplyPacket.StatusDataBlock[] status =
  2464. new DirPlacesReplyPacket.StatusDataBlock[0];
  2465. packet.QueryReplies = replies;
  2466. packet.StatusData = status;
  2467. foreach (DirPlacesReplyData d in data)
  2468. {
  2469. int idx = replies.Length;
  2470. Array.Resize(ref replies, idx + 1);
  2471. Array.Resize(ref status, idx + 1);
  2472. replies[idx] = new DirPlacesReplyPacket.QueryRepliesBlock();
  2473. status[idx] = new DirPlacesReplyPacket.StatusDataBlock();
  2474. replies[idx].ParcelID = d.parcelID;
  2475. replies[idx].Name = Utils.StringToBytes(d.name);
  2476. replies[idx].ForSale = d.forSale;
  2477. replies[idx].Auction = d.auction;
  2478. replies[idx].Dwell = d.dwell;
  2479. status[idx].Status = d.Status;
  2480. packet.QueryReplies = replies;
  2481. packet.StatusData = status;
  2482. if (packet.Length >= 1000)
  2483. {
  2484. OutPacket(packet, ThrottleOutPacketType.Task);
  2485. packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2486. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2487. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2488. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2489. packet.AgentData.AgentID = AgentId;
  2490. packet.QueryData[0].QueryID = queryID;
  2491. replies = new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2492. status = new DirPlacesReplyPacket.StatusDataBlock[0];
  2493. }
  2494. }
  2495. if (replies.Length > 0 || data.Length == 0)
  2496. OutPacket(packet, ThrottleOutPacketType.Task);
  2497. }
  2498. public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
  2499. {
  2500. DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply);
  2501. packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock();
  2502. packet.AgentData.AgentID = AgentId;
  2503. packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock();
  2504. packet.QueryData.QueryID = queryID;
  2505. packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[
  2506. data.Length];
  2507. int i = 0;
  2508. foreach (DirPeopleReplyData d in data)
  2509. {
  2510. packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock();
  2511. packet.QueryReplies[i].AgentID = d.agentID;
  2512. packet.QueryReplies[i].FirstName =
  2513. Utils.StringToBytes(d.firstName);
  2514. packet.QueryReplies[i].LastName =
  2515. Utils.StringToBytes(d.lastName);
  2516. packet.QueryReplies[i].Group =
  2517. Utils.StringToBytes(d.group);
  2518. packet.QueryReplies[i].Online = d.online;
  2519. packet.QueryReplies[i].Reputation = d.reputation;
  2520. i++;
  2521. }
  2522. OutPacket(packet, ThrottleOutPacketType.Task);
  2523. }
  2524. public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
  2525. {
  2526. DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply);
  2527. packet.AgentData = new DirEventsReplyPacket.AgentDataBlock();
  2528. packet.AgentData.AgentID = AgentId;
  2529. packet.QueryData = new DirEventsReplyPacket.QueryDataBlock();
  2530. packet.QueryData.QueryID = queryID;
  2531. packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[
  2532. data.Length];
  2533. packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[
  2534. data.Length];
  2535. int i = 0;
  2536. foreach (DirEventsReplyData d in data)
  2537. {
  2538. packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock();
  2539. packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock();
  2540. packet.QueryReplies[i].OwnerID = d.ownerID;
  2541. packet.QueryReplies[i].Name =
  2542. Utils.StringToBytes(d.name);
  2543. packet.QueryReplies[i].EventID = d.eventID;
  2544. packet.QueryReplies[i].Date =
  2545. Utils.StringToBytes(d.date);
  2546. packet.QueryReplies[i].UnixTime = d.unixTime;
  2547. packet.QueryReplies[i].EventFlags = d.eventFlags;
  2548. packet.StatusData[i].Status = d.Status;
  2549. i++;
  2550. }
  2551. OutPacket(packet, ThrottleOutPacketType.Task);
  2552. }
  2553. public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
  2554. {
  2555. DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply);
  2556. packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock();
  2557. packet.AgentData.AgentID = AgentId;
  2558. packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
  2559. packet.QueryData.QueryID = queryID;
  2560. packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[
  2561. data.Length];
  2562. int i = 0;
  2563. foreach (DirGroupsReplyData d in data)
  2564. {
  2565. packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
  2566. packet.QueryReplies[i].GroupID = d.groupID;
  2567. packet.QueryReplies[i].GroupName =
  2568. Utils.StringToBytes(d.groupName);
  2569. packet.QueryReplies[i].Members = d.members;
  2570. packet.QueryReplies[i].SearchOrder = d.searchOrder;
  2571. i++;
  2572. }
  2573. OutPacket(packet, ThrottleOutPacketType.Task);
  2574. }
  2575. public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
  2576. {
  2577. DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply);
  2578. packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock();
  2579. packet.AgentData.AgentID = AgentId;
  2580. packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock();
  2581. packet.QueryData.QueryID = queryID;
  2582. packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[
  2583. data.Length];
  2584. packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[
  2585. data.Length];
  2586. int i = 0;
  2587. foreach (DirClassifiedReplyData d in data)
  2588. {
  2589. packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock();
  2590. packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock();
  2591. packet.QueryReplies[i].ClassifiedID = d.classifiedID;
  2592. packet.QueryReplies[i].Name =
  2593. Utils.StringToBytes(d.name);
  2594. packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags;
  2595. packet.QueryReplies[i].CreationDate = d.creationDate;
  2596. packet.QueryReplies[i].ExpirationDate = d.expirationDate;
  2597. packet.QueryReplies[i].PriceForListing = d.price;
  2598. packet.StatusData[i].Status = d.Status;
  2599. i++;
  2600. }
  2601. OutPacket(packet, ThrottleOutPacketType.Task);
  2602. }
  2603. public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
  2604. {
  2605. DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply);
  2606. packet.AgentData = new DirLandReplyPacket.AgentDataBlock();
  2607. packet.AgentData.AgentID = AgentId;
  2608. packet.QueryData = new DirLandReplyPacket.QueryDataBlock();
  2609. packet.QueryData.QueryID = queryID;
  2610. packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[
  2611. data.Length];
  2612. int i = 0;
  2613. foreach (DirLandReplyData d in data)
  2614. {
  2615. packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock();
  2616. packet.QueryReplies[i].ParcelID = d.parcelID;
  2617. packet.QueryReplies[i].Name =
  2618. Utils.StringToBytes(d.name);
  2619. packet.QueryReplies[i].Auction = d.auction;
  2620. packet.QueryReplies[i].ForSale = d.forSale;
  2621. packet.QueryReplies[i].SalePrice = d.salePrice;
  2622. packet.QueryReplies[i].ActualArea = d.actualArea;
  2623. i++;
  2624. }
  2625. OutPacket(packet, ThrottleOutPacketType.Task);
  2626. }
  2627. public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
  2628. {
  2629. DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply);
  2630. packet.AgentData = new DirPopularReplyPacket.AgentDataBlock();
  2631. packet.AgentData.AgentID = AgentId;
  2632. packet.QueryData = new DirPopularReplyPacket.QueryDataBlock();
  2633. packet.QueryData.QueryID = queryID;
  2634. packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[
  2635. data.Length];
  2636. int i = 0;
  2637. foreach (DirPopularReplyData d in data)
  2638. {
  2639. packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock();
  2640. packet.QueryReplies[i].ParcelID = d.parcelID;
  2641. packet.QueryReplies[i].Name =
  2642. Utils.StringToBytes(d.name);
  2643. packet.QueryReplies[i].Dwell = d.dwell;
  2644. i++;
  2645. }
  2646. OutPacket(packet, ThrottleOutPacketType.Task);
  2647. }
  2648. public void SendEventInfoReply(EventData data)
  2649. {
  2650. EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply);
  2651. packet.AgentData = new EventInfoReplyPacket.AgentDataBlock();
  2652. packet.AgentData.AgentID = AgentId;
  2653. packet.EventData = new EventInfoReplyPacket.EventDataBlock();
  2654. packet.EventData.EventID = data.eventID;
  2655. packet.EventData.Creator = Utils.StringToBytes(data.creator);
  2656. packet.EventData.Name = Utils.StringToBytes(data.name);
  2657. packet.EventData.Category = Utils.StringToBytes(data.category);
  2658. packet.EventData.Desc = Utils.StringToBytes(data.description);
  2659. packet.EventData.Date = Utils.StringToBytes(data.date);
  2660. packet.EventData.DateUTC = data.dateUTC;
  2661. packet.EventData.Duration = data.duration;
  2662. packet.EventData.Cover = data.cover;
  2663. packet.EventData.Amount = data.amount;
  2664. packet.EventData.SimName = Utils.StringToBytes(data.simName);
  2665. packet.EventData.GlobalPos = new Vector3d(data.globalPos);
  2666. packet.EventData.EventFlags = data.eventFlags;
  2667. OutPacket(packet, ThrottleOutPacketType.Task);
  2668. }
  2669. public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
  2670. {
  2671. MapItemReplyPacket mirplk = new MapItemReplyPacket();
  2672. mirplk.AgentData.AgentID = AgentId;
  2673. mirplk.RequestData.ItemType = mapitemtype;
  2674. mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length];
  2675. for (int i = 0; i < replies.Length; i++)
  2676. {
  2677. MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock();
  2678. mrdata.X = replies[i].x;
  2679. mrdata.Y = replies[i].y;
  2680. mrdata.ID = replies[i].id;
  2681. mrdata.Extra = replies[i].Extra;
  2682. mrdata.Extra2 = replies[i].Extra2;
  2683. mrdata.Name = Utils.StringToBytes(replies[i].name);
  2684. mirplk.Data[i] = mrdata;
  2685. }
  2686. //m_log.Debug(mirplk.ToString());
  2687. OutPacket(mirplk, ThrottleOutPacketType.Task);
  2688. }
  2689. public void SendOfferCallingCard(UUID srcID, UUID transactionID)
  2690. {
  2691. // a bit special, as this uses AgentID to store the source instead
  2692. // of the destination. The destination (the receiver) goes into destID
  2693. OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard);
  2694. p.AgentData.AgentID = srcID;
  2695. p.AgentData.SessionID = UUID.Zero;
  2696. p.AgentBlock.DestID = AgentId;
  2697. p.AgentBlock.TransactionID = transactionID;
  2698. OutPacket(p, ThrottleOutPacketType.Task);
  2699. }
  2700. public void SendAcceptCallingCard(UUID transactionID)
  2701. {
  2702. AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard);
  2703. p.AgentData.AgentID = AgentId;
  2704. p.AgentData.SessionID = UUID.Zero;
  2705. p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1];
  2706. p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock();
  2707. p.FolderData[0].FolderID = UUID.Zero;
  2708. OutPacket(p, ThrottleOutPacketType.Task);
  2709. }
  2710. public void SendDeclineCallingCard(UUID transactionID)
  2711. {
  2712. DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard);
  2713. p.AgentData.AgentID = AgentId;
  2714. p.AgentData.SessionID = UUID.Zero;
  2715. p.TransactionBlock.TransactionID = transactionID;
  2716. OutPacket(p, ThrottleOutPacketType.Task);
  2717. }
  2718. public void SendTerminateFriend(UUID exFriendID)
  2719. {
  2720. TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship);
  2721. p.AgentData.AgentID = AgentId;
  2722. p.AgentData.SessionID = SessionId;
  2723. p.ExBlock.OtherID = exFriendID;
  2724. OutPacket(p, ThrottleOutPacketType.Task);
  2725. }
  2726. public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
  2727. {
  2728. OSDMap llsd = new OSDMap(3);
  2729. OSDArray AgentData = new OSDArray(1);
  2730. OSDMap AgentDataMap = new OSDMap(1);
  2731. AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId));
  2732. AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID));
  2733. AgentData.Add(AgentDataMap);
  2734. llsd.Add("AgentData", AgentData);
  2735. OSDArray GroupData = new OSDArray(data.Length);
  2736. OSDArray NewGroupData = new OSDArray(data.Length);
  2737. foreach (GroupMembershipData m in data)
  2738. {
  2739. OSDMap GroupDataMap = new OSDMap(6);
  2740. OSDMap NewGroupDataMap = new OSDMap(1);
  2741. GroupDataMap.Add("GroupPowers", OSD.FromULong(m.GroupPowers));
  2742. GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices));
  2743. GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle));
  2744. GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID));
  2745. GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName));
  2746. GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture));
  2747. NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile));
  2748. GroupData.Add(GroupDataMap);
  2749. NewGroupData.Add(NewGroupDataMap);
  2750. }
  2751. llsd.Add("GroupData", GroupData);
  2752. llsd.Add("NewGroupData", NewGroupData);
  2753. IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
  2754. if (eq != null)
  2755. {
  2756. eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId);
  2757. }
  2758. }
  2759. public void SendJoinGroupReply(UUID groupID, bool success)
  2760. {
  2761. JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply);
  2762. p.AgentData = new JoinGroupReplyPacket.AgentDataBlock();
  2763. p.AgentData.AgentID = AgentId;
  2764. p.GroupData = new JoinGroupReplyPacket.GroupDataBlock();
  2765. p.GroupData.GroupID = groupID;
  2766. p.GroupData.Success = success;
  2767. OutPacket(p, ThrottleOutPacketType.Task);
  2768. }
  2769. public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
  2770. {
  2771. EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply);
  2772. p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock();
  2773. p.AgentData.AgentID = agentID;
  2774. p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock();
  2775. p.GroupData.GroupID = groupID;
  2776. p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock();
  2777. p.EjectData.Success = success;
  2778. OutPacket(p, ThrottleOutPacketType.Task);
  2779. }
  2780. public void SendLeaveGroupReply(UUID groupID, bool success)
  2781. {
  2782. LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply);
  2783. p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock();
  2784. p.AgentData.AgentID = AgentId;
  2785. p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock();
  2786. p.GroupData.GroupID = groupID;
  2787. p.GroupData.Success = success;
  2788. OutPacket(p, ThrottleOutPacketType.Task);
  2789. }
  2790. public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
  2791. {
  2792. if (classifiedID.Length != name.Length)
  2793. return;
  2794. AvatarClassifiedReplyPacket ac =
  2795. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  2796. PacketType.AvatarClassifiedReply);
  2797. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  2798. ac.AgentData.AgentID = AgentId;
  2799. ac.AgentData.TargetID = targetID;
  2800. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length];
  2801. int i;
  2802. for (i = 0; i < classifiedID.Length; i++)
  2803. {
  2804. ac.Data[i].ClassifiedID = classifiedID[i];
  2805. ac.Data[i].Name = Utils.StringToBytes(name[i]);
  2806. }
  2807. OutPacket(ac, ThrottleOutPacketType.Task);
  2808. }
  2809. public void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price)
  2810. {
  2811. ClassifiedInfoReplyPacket cr =
  2812. (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket(
  2813. PacketType.ClassifiedInfoReply);
  2814. cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock();
  2815. cr.AgentData.AgentID = AgentId;
  2816. cr.Data = new ClassifiedInfoReplyPacket.DataBlock();
  2817. cr.Data.ClassifiedID = classifiedID;
  2818. cr.Data.CreatorID = creatorID;
  2819. cr.Data.CreationDate = creationDate;
  2820. cr.Data.ExpirationDate = expirationDate;
  2821. cr.Data.Category = category;
  2822. cr.Data.Name = Utils.StringToBytes(name);
  2823. cr.Data.Desc = Utils.StringToBytes(description);
  2824. cr.Data.ParcelID = parcelID;
  2825. cr.Data.ParentEstate = parentEstate;
  2826. cr.Data.SnapshotID = snapshotID;
  2827. cr.Data.SimName = Utils.StringToBytes(simName);
  2828. cr.Data.PosGlobal = new Vector3d(globalPos);
  2829. cr.Data.ParcelName = Utils.StringToBytes(parcelName);
  2830. cr.Data.ClassifiedFlags = classifiedFlags;
  2831. cr.Data.PriceForListing = price;
  2832. OutPacket(cr, ThrottleOutPacketType.Task);
  2833. }
  2834. public void SendAgentDropGroup(UUID groupID)
  2835. {
  2836. AgentDropGroupPacket dg =
  2837. (AgentDropGroupPacket)PacketPool.Instance.GetPacket(
  2838. PacketType.AgentDropGroup);
  2839. dg.AgentData = new AgentDropGroupPacket.AgentDataBlock();
  2840. dg.AgentData.AgentID = AgentId;
  2841. dg.AgentData.GroupID = groupID;
  2842. OutPacket(dg, ThrottleOutPacketType.Task);
  2843. }
  2844. public void SendAvatarNotesReply(UUID targetID, string text)
  2845. {
  2846. AvatarNotesReplyPacket an =
  2847. (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket(
  2848. PacketType.AvatarNotesReply);
  2849. an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock();
  2850. an.AgentData.AgentID = AgentId;
  2851. an.Data = new AvatarNotesReplyPacket.DataBlock();
  2852. an.Data.TargetID = targetID;
  2853. an.Data.Notes = Utils.StringToBytes(text);
  2854. OutPacket(an, ThrottleOutPacketType.Task);
  2855. }
  2856. public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
  2857. {
  2858. AvatarPicksReplyPacket ap =
  2859. (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket(
  2860. PacketType.AvatarPicksReply);
  2861. ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock();
  2862. ap.AgentData.AgentID = AgentId;
  2863. ap.AgentData.TargetID = targetID;
  2864. ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count];
  2865. int i = 0;
  2866. foreach (KeyValuePair<UUID, string> pick in picks)
  2867. {
  2868. ap.Data[i] = new AvatarPicksReplyPacket.DataBlock();
  2869. ap.Data[i].PickID = pick.Key;
  2870. ap.Data[i].PickName = Utils.StringToBytes(pick.Value);
  2871. i++;
  2872. }
  2873. OutPacket(ap, ThrottleOutPacketType.Task);
  2874. }
  2875. public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
  2876. {
  2877. AvatarClassifiedReplyPacket ac =
  2878. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  2879. PacketType.AvatarClassifiedReply);
  2880. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  2881. ac.AgentData.AgentID = AgentId;
  2882. ac.AgentData.TargetID = targetID;
  2883. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count];
  2884. int i = 0;
  2885. foreach (KeyValuePair<UUID, string> classified in classifieds)
  2886. {
  2887. ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock();
  2888. ac.Data[i].ClassifiedID = classified.Key;
  2889. ac.Data[i].Name = Utils.StringToBytes(classified.Value);
  2890. i++;
  2891. }
  2892. OutPacket(ac, ThrottleOutPacketType.Task);
  2893. }
  2894. public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
  2895. {
  2896. ParcelDwellReplyPacket pd =
  2897. (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket(
  2898. PacketType.ParcelDwellReply);
  2899. pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock();
  2900. pd.AgentData.AgentID = AgentId;
  2901. pd.Data = new ParcelDwellReplyPacket.DataBlock();
  2902. pd.Data.LocalID = localID;
  2903. pd.Data.ParcelID = parcelID;
  2904. pd.Data.Dwell = dwell;
  2905. OutPacket(pd, ThrottleOutPacketType.Land);
  2906. }
  2907. public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
  2908. {
  2909. UserInfoReplyPacket ur =
  2910. (UserInfoReplyPacket)PacketPool.Instance.GetPacket(
  2911. PacketType.UserInfoReply);
  2912. string Visible = "hidden";
  2913. if (visible)
  2914. Visible = "default";
  2915. ur.AgentData = new UserInfoReplyPacket.AgentDataBlock();
  2916. ur.AgentData.AgentID = AgentId;
  2917. ur.UserData = new UserInfoReplyPacket.UserDataBlock();
  2918. ur.UserData.IMViaEMail = imViaEmail;
  2919. ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible);
  2920. ur.UserData.EMail = Utils.StringToBytes(email);
  2921. OutPacket(ur, ThrottleOutPacketType.Task);
  2922. }
  2923. public void SendCreateGroupReply(UUID groupID, bool success, string message)
  2924. {
  2925. CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply);
  2926. createGroupReply.AgentData =
  2927. new CreateGroupReplyPacket.AgentDataBlock();
  2928. createGroupReply.ReplyData =
  2929. new CreateGroupReplyPacket.ReplyDataBlock();
  2930. createGroupReply.AgentData.AgentID = AgentId;
  2931. createGroupReply.ReplyData.GroupID = groupID;
  2932. createGroupReply.ReplyData.Success = success;
  2933. createGroupReply.ReplyData.Message = Utils.StringToBytes(message);
  2934. OutPacket(createGroupReply, ThrottleOutPacketType.Task);
  2935. }
  2936. public void SendUseCachedMuteList()
  2937. {
  2938. UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList);
  2939. useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock();
  2940. useCachedMuteList.AgentData.AgentID = AgentId;
  2941. OutPacket(useCachedMuteList, ThrottleOutPacketType.Task);
  2942. }
  2943. public void SendMuteListUpdate(string filename)
  2944. {
  2945. MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate);
  2946. muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock();
  2947. muteListUpdate.MuteData.AgentID = AgentId;
  2948. muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename);
  2949. OutPacket(muteListUpdate, ThrottleOutPacketType.Task);
  2950. }
  2951. public void SendPickInfoReply(UUID pickID, UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled)
  2952. {
  2953. PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply);
  2954. pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock();
  2955. pickInfoReply.AgentData.AgentID = AgentId;
  2956. pickInfoReply.Data = new PickInfoReplyPacket.DataBlock();
  2957. pickInfoReply.Data.PickID = pickID;
  2958. pickInfoReply.Data.CreatorID = creatorID;
  2959. pickInfoReply.Data.TopPick = topPick;
  2960. pickInfoReply.Data.ParcelID = parcelID;
  2961. pickInfoReply.Data.Name = Utils.StringToBytes(name);
  2962. pickInfoReply.Data.Desc = Utils.StringToBytes(desc);
  2963. pickInfoReply.Data.SnapshotID = snapshotID;
  2964. pickInfoReply.Data.User = Utils.StringToBytes(user);
  2965. pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName);
  2966. pickInfoReply.Data.SimName = Utils.StringToBytes(simName);
  2967. pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal);
  2968. pickInfoReply.Data.SortOrder = sortOrder;
  2969. pickInfoReply.Data.Enabled = enabled;
  2970. OutPacket(pickInfoReply, ThrottleOutPacketType.Task);
  2971. }
  2972. #endregion Scene/Avatar to Client
  2973. // Gesture
  2974. #region Appearance/ Wearables Methods
  2975. public void SendWearables(AvatarWearable[] wearables, int serial)
  2976. {
  2977. AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate);
  2978. aw.AgentData.AgentID = AgentId;
  2979. aw.AgentData.SerialNum = (uint)serial;
  2980. aw.AgentData.SessionID = m_sessionId;
  2981. int count = 0;
  2982. for (int i = 0; i < wearables.Length; i++)
  2983. count += wearables[i].Count;
  2984. // TODO: don't create new blocks if recycling an old packet
  2985. aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[count];
  2986. AgentWearablesUpdatePacket.WearableDataBlock awb;
  2987. int idx = 0;
  2988. for (int i = 0; i < wearables.Length; i++)
  2989. {
  2990. for (int j = 0; j < wearables[i].Count; j++)
  2991. {
  2992. awb = new AgentWearablesUpdatePacket.WearableDataBlock();
  2993. awb.WearableType = (byte)i;
  2994. awb.AssetID = wearables[i][j].AssetID;
  2995. awb.ItemID = wearables[i][j].ItemID;
  2996. aw.WearableData[idx] = awb;
  2997. idx++;
  2998. // m_log.DebugFormat(
  2999. // "[APPEARANCE]: Sending wearable item/asset {0} {1} (index {2}) for {3}",
  3000. // awb.ItemID, awb.AssetID, i, Name);
  3001. }
  3002. }
  3003. OutPacket(aw, ThrottleOutPacketType.Task);
  3004. }
  3005. public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
  3006. {
  3007. AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
  3008. // TODO: don't create new blocks if recycling an old packet
  3009. avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
  3010. avp.ObjectData.TextureEntry = textureEntry;
  3011. AvatarAppearancePacket.VisualParamBlock avblock = null;
  3012. for (int i = 0; i < visualParams.Length; i++)
  3013. {
  3014. avblock = new AvatarAppearancePacket.VisualParamBlock();
  3015. avblock.ParamValue = visualParams[i];
  3016. avp.VisualParam[i] = avblock;
  3017. }
  3018. avp.Sender.IsTrial = false;
  3019. avp.Sender.ID = agentID;
  3020. //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
  3021. OutPacket(avp, ThrottleOutPacketType.Task);
  3022. }
  3023. public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
  3024. {
  3025. //m_log.DebugFormat("[CLIENT]: Sending animations to {0}", Name);
  3026. AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
  3027. // TODO: don't create new blocks if recycling an old packet
  3028. ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[animations.Length];
  3029. ani.Sender = new AvatarAnimationPacket.SenderBlock();
  3030. ani.Sender.ID = sourceAgentId;
  3031. ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length];
  3032. ani.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0];
  3033. for (int i = 0; i < animations.Length; ++i)
  3034. {
  3035. ani.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock();
  3036. ani.AnimationList[i].AnimID = animations[i];
  3037. ani.AnimationList[i].AnimSequenceID = seqs[i];
  3038. ani.AnimationSourceList[i] = new AvatarAnimationPacket.AnimationSourceListBlock();
  3039. if (objectIDs[i].Equals(sourceAgentId))
  3040. ani.AnimationSourceList[i].ObjectID = UUID.Zero;
  3041. else
  3042. ani.AnimationSourceList[i].ObjectID = objectIDs[i];
  3043. }
  3044. ani.Header.Reliable = false;
  3045. OutPacket(ani, ThrottleOutPacketType.Task);
  3046. }
  3047. #endregion
  3048. #region Avatar Packet/Data Sending Methods
  3049. /// <summary>
  3050. /// Send an ObjectUpdate packet with information about an avatar
  3051. /// </summary>
  3052. public void SendAvatarDataImmediate(ISceneEntity avatar)
  3053. {
  3054. ScenePresence presence = avatar as ScenePresence;
  3055. if (presence == null)
  3056. return;
  3057. ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3058. objupdate.Header.Zerocoded = true;
  3059. objupdate.RegionData.RegionHandle = presence.RegionHandle;
  3060. objupdate.RegionData.TimeDilation = ushort.MaxValue;
  3061. objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  3062. objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence);
  3063. OutPacket(objupdate, ThrottleOutPacketType.Task);
  3064. // We need to record the avatar local id since the root prim of an attachment points to this.
  3065. // m_attachmentsSent.Add(avatar.LocalId);
  3066. }
  3067. public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
  3068. {
  3069. if (!IsActive) return; // We don't need to update inactive clients.
  3070. CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
  3071. loc.Header.Reliable = false;
  3072. // Each packet can only hold around 60 avatar positions and the client clears the mini-map each time
  3073. // a CoarseLocationUpdate packet is received. Oh well.
  3074. int total = Math.Min(CoarseLocations.Count, 60);
  3075. CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock();
  3076. loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total];
  3077. loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total];
  3078. int selfindex = -1;
  3079. for (int i = 0; i < total; i++)
  3080. {
  3081. CoarseLocationUpdatePacket.LocationBlock lb =
  3082. new CoarseLocationUpdatePacket.LocationBlock();
  3083. lb.X = (byte)CoarseLocations[i].X;
  3084. lb.Y = (byte)CoarseLocations[i].Y;
  3085. lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f);
  3086. loc.Location[i] = lb;
  3087. loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock();
  3088. loc.AgentData[i].AgentID = users[i];
  3089. if (users[i] == AgentId)
  3090. selfindex = i;
  3091. }
  3092. ib.You = (short)selfindex;
  3093. ib.Prey = -1;
  3094. loc.Index = ib;
  3095. OutPacket(loc, ThrottleOutPacketType.Task);
  3096. }
  3097. #endregion Avatar Packet/Data Sending Methods
  3098. #region Primitive Packet/Data Sending Methods
  3099. /// <summary>
  3100. /// Generate one of the object update packets based on PrimUpdateFlags
  3101. /// and broadcast the packet to clients
  3102. /// </summary>
  3103. public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
  3104. {
  3105. //double priority = m_prioritizer.GetUpdatePriority(this, entity);
  3106. uint priority = m_prioritizer.GetUpdatePriority(this, entity);
  3107. lock (m_entityUpdates.SyncRoot)
  3108. m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation));
  3109. }
  3110. /// <summary>
  3111. /// Requeue an EntityUpdate when it was not acknowledged by the client.
  3112. /// We will update the priority and put it in the correct queue, merging update flags
  3113. /// with any other updates that may be queued for the same entity.
  3114. /// The original update time is used for the merged update.
  3115. /// </summary>
  3116. private void ResendPrimUpdate(EntityUpdate update)
  3117. {
  3118. // If the update exists in priority queue, it will be updated.
  3119. // If it does not exist then it will be added with the current (rather than its original) priority
  3120. uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity);
  3121. lock (m_entityUpdates.SyncRoot)
  3122. m_entityUpdates.Enqueue(priority, update);
  3123. }
  3124. /// <summary>
  3125. /// Requeue a list of EntityUpdates when they were not acknowledged by the client.
  3126. /// We will update the priority and put it in the correct queue, merging update flags
  3127. /// with any other updates that may be queued for the same entity.
  3128. /// The original update time is used for the merged update.
  3129. /// </summary>
  3130. private void ResendPrimUpdates(List<EntityUpdate> updates, OutgoingPacket oPacket)
  3131. {
  3132. // m_log.WarnFormat("[CLIENT] resending prim update {0}",updates[0].UpdateTime);
  3133. // Remove the update packet from the list of packets waiting for acknowledgement
  3134. // because we are requeuing the list of updates. They will be resent in new packets
  3135. // with the most recent state and priority.
  3136. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3137. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3138. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3139. foreach (EntityUpdate update in updates)
  3140. ResendPrimUpdate(update);
  3141. }
  3142. private void ProcessEntityUpdates(int maxUpdates)
  3143. {
  3144. OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3145. OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3146. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3147. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3148. OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3149. OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3150. OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3151. OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3152. // Check to see if this is a flush
  3153. if (maxUpdates <= 0)
  3154. {
  3155. maxUpdates = Int32.MaxValue;
  3156. }
  3157. int updatesThisCall = 0;
  3158. // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
  3159. // condition where a kill can be processed before an out-of-date update for the same object.
  3160. lock (m_killRecord)
  3161. {
  3162. float avgTimeDilation = 1.0f;
  3163. IEntityUpdate iupdate;
  3164. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3165. while (updatesThisCall < maxUpdates)
  3166. {
  3167. lock (m_entityUpdates.SyncRoot)
  3168. if (!m_entityUpdates.TryDequeue(out iupdate, out timeinqueue))
  3169. break;
  3170. EntityUpdate update = (EntityUpdate)iupdate;
  3171. avgTimeDilation += update.TimeDilation;
  3172. avgTimeDilation *= 0.5f;
  3173. if (update.Entity is SceneObjectPart)
  3174. {
  3175. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3176. // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client
  3177. // will never receive an update after a prim kill. Even then, keeping the kill record may be a good
  3178. // safety measure.
  3179. //
  3180. // If a Linden Lab 1.23.5 client (and possibly later and earlier) receives an object update
  3181. // after a kill, it will keep displaying the deleted object until relog. OpenSim currently performs
  3182. // updates and kills on different threads with different scheduling strategies, hence this protection.
  3183. //
  3184. // This doesn't appear to apply to child prims - a client will happily ignore these updates
  3185. // after the root prim has been deleted.
  3186. if (m_killRecord.Contains(part.LocalId))
  3187. {
  3188. // m_log.WarnFormat(
  3189. // "[CLIENT]: Preventing update for prim with local id {0} after client for user {1} told it was deleted",
  3190. // part.LocalId, Name);
  3191. continue;
  3192. }
  3193. if (part.ParentGroup.IsAttachment && m_disableFacelights)
  3194. {
  3195. if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
  3196. part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.RightHand)
  3197. {
  3198. part.Shape.LightEntry = false;
  3199. }
  3200. }
  3201. }
  3202. ++updatesThisCall;
  3203. #region UpdateFlags to packet type conversion
  3204. PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags;
  3205. bool canUseCompressed = true;
  3206. bool canUseImproved = true;
  3207. // Compressed object updates only make sense for LL primitives
  3208. if (!(update.Entity is SceneObjectPart))
  3209. {
  3210. canUseCompressed = false;
  3211. }
  3212. if (updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
  3213. {
  3214. canUseCompressed = false;
  3215. canUseImproved = false;
  3216. }
  3217. else
  3218. {
  3219. if (updateFlags.HasFlag(PrimUpdateFlags.Velocity) ||
  3220. updateFlags.HasFlag(PrimUpdateFlags.Acceleration) ||
  3221. updateFlags.HasFlag(PrimUpdateFlags.CollisionPlane) ||
  3222. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3223. {
  3224. canUseCompressed = false;
  3225. }
  3226. if (updateFlags.HasFlag(PrimUpdateFlags.PrimFlags) ||
  3227. updateFlags.HasFlag(PrimUpdateFlags.ParentID) ||
  3228. updateFlags.HasFlag(PrimUpdateFlags.Scale) ||
  3229. updateFlags.HasFlag(PrimUpdateFlags.PrimData) ||
  3230. updateFlags.HasFlag(PrimUpdateFlags.Text) ||
  3231. updateFlags.HasFlag(PrimUpdateFlags.NameValue) ||
  3232. updateFlags.HasFlag(PrimUpdateFlags.ExtraData) ||
  3233. updateFlags.HasFlag(PrimUpdateFlags.TextureAnim) ||
  3234. updateFlags.HasFlag(PrimUpdateFlags.Sound) ||
  3235. updateFlags.HasFlag(PrimUpdateFlags.Particles) ||
  3236. updateFlags.HasFlag(PrimUpdateFlags.Material) ||
  3237. updateFlags.HasFlag(PrimUpdateFlags.ClickAction) ||
  3238. updateFlags.HasFlag(PrimUpdateFlags.MediaURL) ||
  3239. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3240. {
  3241. canUseImproved = false;
  3242. }
  3243. }
  3244. #endregion UpdateFlags to packet type conversion
  3245. #region Block Construction
  3246. // TODO: Remove this once we can build compressed updates
  3247. canUseCompressed = false;
  3248. if (!canUseImproved && !canUseCompressed)
  3249. {
  3250. if (update.Entity is ScenePresence)
  3251. {
  3252. objectUpdateBlocks.Value.Add(CreateAvatarUpdateBlock((ScenePresence)update.Entity));
  3253. objectUpdates.Value.Add(update);
  3254. }
  3255. else
  3256. {
  3257. objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId));
  3258. objectUpdates.Value.Add(update);
  3259. }
  3260. }
  3261. else if (!canUseImproved)
  3262. {
  3263. compressedUpdateBlocks.Value.Add(CreateCompressedUpdateBlock((SceneObjectPart)update.Entity, updateFlags));
  3264. compressedUpdates.Value.Add(update);
  3265. }
  3266. else
  3267. {
  3268. if (update.Entity is ScenePresence && ((ScenePresence)update.Entity).UUID == AgentId)
  3269. {
  3270. // Self updates go into a special list
  3271. terseAgentUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures)));
  3272. terseAgentUpdates.Value.Add(update);
  3273. }
  3274. else
  3275. {
  3276. // Everything else goes here
  3277. terseUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures)));
  3278. terseUpdates.Value.Add(update);
  3279. }
  3280. }
  3281. #endregion Block Construction
  3282. }
  3283. #region Packet Sending
  3284. ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f);
  3285. if (terseAgentUpdateBlocks.IsValueCreated)
  3286. {
  3287. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
  3288. ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket();
  3289. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3290. packet.RegionData.TimeDilation = timeDilation;
  3291. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3292. for (int i = 0; i < blocks.Count; i++)
  3293. packet.ObjectData[i] = blocks[i];
  3294. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3295. OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseAgentUpdates.Value, oPacket); });
  3296. }
  3297. if (objectUpdateBlocks.IsValueCreated)
  3298. {
  3299. List<ObjectUpdatePacket.ObjectDataBlock> blocks = objectUpdateBlocks.Value;
  3300. ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3301. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3302. packet.RegionData.TimeDilation = timeDilation;
  3303. packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3304. for (int i = 0; i < blocks.Count; i++)
  3305. packet.ObjectData[i] = blocks[i];
  3306. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3307. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(objectUpdates.Value, oPacket); });
  3308. }
  3309. if (compressedUpdateBlocks.IsValueCreated)
  3310. {
  3311. List<ObjectUpdateCompressedPacket.ObjectDataBlock> blocks = compressedUpdateBlocks.Value;
  3312. ObjectUpdateCompressedPacket packet = (ObjectUpdateCompressedPacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdateCompressed);
  3313. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3314. packet.RegionData.TimeDilation = timeDilation;
  3315. packet.ObjectData = new ObjectUpdateCompressedPacket.ObjectDataBlock[blocks.Count];
  3316. for (int i = 0; i < blocks.Count; i++)
  3317. packet.ObjectData[i] = blocks[i];
  3318. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3319. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(compressedUpdates.Value, oPacket); });
  3320. }
  3321. if (terseUpdateBlocks.IsValueCreated)
  3322. {
  3323. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value;
  3324. ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket();
  3325. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3326. packet.RegionData.TimeDilation = timeDilation;
  3327. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3328. for (int i = 0; i < blocks.Count; i++)
  3329. packet.ObjectData[i] = blocks[i];
  3330. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3331. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
  3332. }
  3333. }
  3334. #endregion Packet Sending
  3335. }
  3336. public void ReprioritizeUpdates()
  3337. {
  3338. lock (m_entityUpdates.SyncRoot)
  3339. m_entityUpdates.Reprioritize(UpdatePriorityHandler);
  3340. }
  3341. private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity)
  3342. {
  3343. if (entity != null)
  3344. {
  3345. priority = m_prioritizer.GetUpdatePriority(this, entity);
  3346. return true;
  3347. }
  3348. return false;
  3349. }
  3350. public void FlushPrimUpdates()
  3351. {
  3352. m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName);
  3353. while (m_entityUpdates.Count > 0)
  3354. ProcessEntityUpdates(-1);
  3355. }
  3356. #endregion Primitive Packet/Data Sending Methods
  3357. // These are used to implement an adaptive backoff in the number
  3358. // of updates converted to packets. Since we don't want packets
  3359. // to sit in the queue with old data, only convert enough updates
  3360. // to packets that can be sent in 200ms.
  3361. private Int32 m_LastQueueFill = 0;
  3362. private Int32 m_maxUpdates = 0;
  3363. void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
  3364. {
  3365. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3366. {
  3367. if (m_maxUpdates == 0 || m_LastQueueFill == 0)
  3368. {
  3369. m_maxUpdates = m_udpServer.PrimUpdatesPerCallback;
  3370. }
  3371. else
  3372. {
  3373. if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200)
  3374. m_maxUpdates += 5;
  3375. else
  3376. m_maxUpdates = m_maxUpdates >> 1;
  3377. }
  3378. m_maxUpdates = Util.Clamp<Int32>(m_maxUpdates,10,500);
  3379. m_LastQueueFill = Util.EnvironmentTickCount();
  3380. if (m_entityUpdates.Count > 0)
  3381. ProcessEntityUpdates(m_maxUpdates);
  3382. if (m_entityProps.Count > 0)
  3383. ProcessEntityPropertyRequests(m_maxUpdates);
  3384. }
  3385. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3386. {
  3387. ProcessTextureRequests();
  3388. }
  3389. }
  3390. void ProcessTextureRequests()
  3391. {
  3392. if (m_imageManager != null)
  3393. m_imageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
  3394. }
  3395. public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
  3396. {
  3397. AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
  3398. newPack.AssetBlock.Type = AssetType;
  3399. newPack.AssetBlock.Success = Success;
  3400. newPack.AssetBlock.UUID = AssetFullID;
  3401. newPack.Header.Zerocoded = true;
  3402. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3403. }
  3404. public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
  3405. {
  3406. RequestXferPacket newPack = new RequestXferPacket();
  3407. newPack.XferID.ID = XferID;
  3408. newPack.XferID.VFileType = AssetType;
  3409. newPack.XferID.VFileID = vFileID;
  3410. newPack.XferID.FilePath = FilePath;
  3411. newPack.XferID.Filename = FileName;
  3412. newPack.Header.Zerocoded = true;
  3413. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3414. }
  3415. public void SendConfirmXfer(ulong xferID, uint PacketID)
  3416. {
  3417. ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
  3418. newPack.XferID.ID = xferID;
  3419. newPack.XferID.Packet = PacketID;
  3420. newPack.Header.Zerocoded = true;
  3421. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3422. }
  3423. public void SendInitiateDownload(string simFileName, string clientFileName)
  3424. {
  3425. InitiateDownloadPacket newPack = new InitiateDownloadPacket();
  3426. newPack.AgentData.AgentID = AgentId;
  3427. newPack.FileData.SimFilename = Utils.StringToBytes(simFileName);
  3428. newPack.FileData.ViewerFilename = Utils.StringToBytes(clientFileName);
  3429. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3430. }
  3431. public void SendImageFirstPart(
  3432. ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
  3433. {
  3434. ImageDataPacket im = new ImageDataPacket();
  3435. im.Header.Reliable = false;
  3436. im.ImageID.Packets = numParts;
  3437. im.ImageID.ID = ImageUUID;
  3438. if (ImageSize > 0)
  3439. im.ImageID.Size = ImageSize;
  3440. im.ImageData.Data = ImageData;
  3441. im.ImageID.Codec = imageCodec;
  3442. im.Header.Zerocoded = true;
  3443. OutPacket(im, ThrottleOutPacketType.Texture);
  3444. }
  3445. public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
  3446. {
  3447. ImagePacketPacket im = new ImagePacketPacket();
  3448. im.Header.Reliable = false;
  3449. im.ImageID.Packet = partNumber;
  3450. im.ImageID.ID = imageUuid;
  3451. im.ImageData.Data = imageData;
  3452. OutPacket(im, ThrottleOutPacketType.Texture);
  3453. }
  3454. public void SendImageNotFound(UUID imageid)
  3455. {
  3456. ImageNotInDatabasePacket notFoundPacket
  3457. = (ImageNotInDatabasePacket)PacketPool.Instance.GetPacket(PacketType.ImageNotInDatabase);
  3458. notFoundPacket.ImageID.ID = imageid;
  3459. OutPacket(notFoundPacket, ThrottleOutPacketType.Texture);
  3460. }
  3461. public void SendShutdownConnectionNotice()
  3462. {
  3463. OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown);
  3464. }
  3465. public void SendSimStats(SimStats stats)
  3466. {
  3467. SimStatsPacket pack = new SimStatsPacket();
  3468. pack.Region = new SimStatsPacket.RegionBlock();
  3469. pack.Region.RegionX = stats.RegionX;
  3470. pack.Region.RegionY = stats.RegionY;
  3471. pack.Region.RegionFlags = stats.RegionFlags;
  3472. pack.Region.ObjectCapacity = stats.ObjectCapacity;
  3473. //pack.Region = //stats.RegionBlock;
  3474. pack.Stat = stats.StatsBlock;
  3475. pack.Header.Reliable = false;
  3476. OutPacket(pack, ThrottleOutPacketType.Task);
  3477. }
  3478. private class ObjectPropertyUpdate : IEntityUpdate
  3479. {
  3480. internal bool SendFamilyProps;
  3481. internal bool SendObjectProps;
  3482. public ObjectPropertyUpdate(ISceneEntity entity, uint flags, bool sendfam, bool sendobj)
  3483. : base(entity,flags)
  3484. {
  3485. SendFamilyProps = sendfam;
  3486. SendObjectProps = sendobj;
  3487. }
  3488. public void Update(ObjectPropertyUpdate update)
  3489. {
  3490. SendFamilyProps = SendFamilyProps || update.SendFamilyProps;
  3491. SendObjectProps = SendObjectProps || update.SendObjectProps;
  3492. // other properties may need to be updated by base class
  3493. base.Update(update);
  3494. }
  3495. }
  3496. public void SendObjectPropertiesFamilyData(ISceneEntity entity, uint requestFlags)
  3497. {
  3498. uint priority = 0; // time based ordering only
  3499. lock (m_entityProps.SyncRoot)
  3500. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false));
  3501. }
  3502. private void ResendPropertyUpdate(ObjectPropertyUpdate update)
  3503. {
  3504. uint priority = 0;
  3505. lock (m_entityProps.SyncRoot)
  3506. m_entityProps.Enqueue(priority, update);
  3507. }
  3508. private void ResendPropertyUpdates(List<ObjectPropertyUpdate> updates, OutgoingPacket oPacket)
  3509. {
  3510. // m_log.WarnFormat("[CLIENT] resending object property {0}",updates[0].UpdateTime);
  3511. // Remove the update packet from the list of packets waiting for acknowledgement
  3512. // because we are requeuing the list of updates. They will be resent in new packets
  3513. // with the most recent state.
  3514. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3515. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3516. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3517. foreach (ObjectPropertyUpdate update in updates)
  3518. ResendPropertyUpdate(update);
  3519. }
  3520. public void SendObjectPropertiesReply(ISceneEntity entity)
  3521. {
  3522. uint priority = 0; // time based ordering only
  3523. lock (m_entityProps.SyncRoot)
  3524. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,0,false,true));
  3525. }
  3526. private void ProcessEntityPropertyRequests(int maxUpdates)
  3527. {
  3528. OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>> objectFamilyBlocks =
  3529. new OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>>();
  3530. OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>> objectPropertiesBlocks =
  3531. new OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>>();
  3532. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> familyUpdates =
  3533. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3534. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> propertyUpdates =
  3535. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3536. IEntityUpdate iupdate;
  3537. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3538. int updatesThisCall = 0;
  3539. while (updatesThisCall < m_maxUpdates)
  3540. {
  3541. lock (m_entityProps.SyncRoot)
  3542. if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
  3543. break;
  3544. ObjectPropertyUpdate update = (ObjectPropertyUpdate)iupdate;
  3545. if (update.SendFamilyProps)
  3546. {
  3547. if (update.Entity is SceneObjectPart)
  3548. {
  3549. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3550. ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags);
  3551. objectFamilyBlocks.Value.Add(objPropDB);
  3552. familyUpdates.Value.Add(update);
  3553. }
  3554. }
  3555. if (update.SendObjectProps)
  3556. {
  3557. if (update.Entity is SceneObjectPart)
  3558. {
  3559. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3560. ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop);
  3561. objectPropertiesBlocks.Value.Add(objPropDB);
  3562. propertyUpdates.Value.Add(update);
  3563. }
  3564. }
  3565. updatesThisCall++;
  3566. }
  3567. // Int32 ppcnt = 0;
  3568. // Int32 pbcnt = 0;
  3569. if (objectPropertiesBlocks.IsValueCreated)
  3570. {
  3571. List<ObjectPropertiesPacket.ObjectDataBlock> blocks = objectPropertiesBlocks.Value;
  3572. List<ObjectPropertyUpdate> updates = propertyUpdates.Value;
  3573. ObjectPropertiesPacket packet = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3574. packet.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[blocks.Count];
  3575. for (int i = 0; i < blocks.Count; i++)
  3576. packet.ObjectData[i] = blocks[i];
  3577. packet.Header.Zerocoded = true;
  3578. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3579. // of the object rather than the properties when the packet was created
  3580. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3581. delegate(OutgoingPacket oPacket)
  3582. {
  3583. ResendPropertyUpdates(updates, oPacket);
  3584. });
  3585. // pbcnt += blocks.Count;
  3586. // ppcnt++;
  3587. }
  3588. // Int32 fpcnt = 0;
  3589. // Int32 fbcnt = 0;
  3590. if (objectFamilyBlocks.IsValueCreated)
  3591. {
  3592. List<ObjectPropertiesFamilyPacket.ObjectDataBlock> blocks = objectFamilyBlocks.Value;
  3593. // one packet per object block... uggh...
  3594. for (int i = 0; i < blocks.Count; i++)
  3595. {
  3596. ObjectPropertiesFamilyPacket packet =
  3597. (ObjectPropertiesFamilyPacket)PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily);
  3598. packet.ObjectData = blocks[i];
  3599. packet.Header.Zerocoded = true;
  3600. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3601. // of the object rather than the properties when the packet was created
  3602. List<ObjectPropertyUpdate> updates = new List<ObjectPropertyUpdate>();
  3603. updates.Add(familyUpdates.Value[i]);
  3604. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3605. delegate(OutgoingPacket oPacket)
  3606. {
  3607. ResendPropertyUpdates(updates, oPacket);
  3608. });
  3609. // fpcnt++;
  3610. // fbcnt++;
  3611. }
  3612. }
  3613. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} property packets with {1} blocks",ppcnt,pbcnt);
  3614. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} family property packets with {1} blocks",fpcnt,fbcnt);
  3615. }
  3616. private ObjectPropertiesFamilyPacket.ObjectDataBlock CreateObjectPropertiesFamilyBlock(SceneObjectPart sop, uint requestFlags)
  3617. {
  3618. ObjectPropertiesFamilyPacket.ObjectDataBlock block = new ObjectPropertiesFamilyPacket.ObjectDataBlock();
  3619. block.RequestFlags = requestFlags;
  3620. block.ObjectID = sop.UUID;
  3621. if (sop.OwnerID == sop.GroupID)
  3622. block.OwnerID = UUID.Zero;
  3623. else
  3624. block.OwnerID = sop.OwnerID;
  3625. block.GroupID = sop.GroupID;
  3626. block.BaseMask = sop.BaseMask;
  3627. block.OwnerMask = sop.OwnerMask;
  3628. block.GroupMask = sop.GroupMask;
  3629. block.EveryoneMask = sop.EveryoneMask;
  3630. block.NextOwnerMask = sop.NextOwnerMask;
  3631. // TODO: More properties are needed in SceneObjectPart!
  3632. block.OwnershipCost = sop.OwnershipCost;
  3633. block.SaleType = sop.ObjectSaleType;
  3634. block.SalePrice = sop.SalePrice;
  3635. block.Category = sop.Category;
  3636. block.LastOwnerID = sop.CreatorID; // copied from old SOG call... is this right?
  3637. block.Name = Util.StringToBytes256(sop.Name);
  3638. block.Description = Util.StringToBytes256(sop.Description);
  3639. return block;
  3640. }
  3641. private ObjectPropertiesPacket.ObjectDataBlock CreateObjectPropertiesBlock(SceneObjectPart sop)
  3642. {
  3643. //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3644. // TODO: don't create new blocks if recycling an old packet
  3645. ObjectPropertiesPacket.ObjectDataBlock block =
  3646. new ObjectPropertiesPacket.ObjectDataBlock();
  3647. block.ObjectID = sop.UUID;
  3648. block.Name = Util.StringToBytes256(sop.Name);
  3649. block.Description = Util.StringToBytes256(sop.Description);
  3650. block.CreationDate = (ulong)sop.CreationDate * 1000000; // viewer wants date in microseconds
  3651. block.CreatorID = sop.CreatorID;
  3652. block.GroupID = sop.GroupID;
  3653. block.LastOwnerID = sop.LastOwnerID;
  3654. if (sop.OwnerID == sop.GroupID)
  3655. block.OwnerID = UUID.Zero;
  3656. else
  3657. block.OwnerID = sop.OwnerID;
  3658. block.ItemID = sop.FromUserInventoryItemID;
  3659. block.FolderID = UUID.Zero; // sop.FromFolderID ??
  3660. block.FromTaskID = UUID.Zero; // ???
  3661. block.InventorySerial = (short)sop.InventorySerial;
  3662. SceneObjectPart root = sop.ParentGroup.RootPart;
  3663. block.TouchName = Util.StringToBytes256(root.TouchName);
  3664. block.TextureID = new byte[0]; // TextureID ???
  3665. block.SitName = Util.StringToBytes256(root.SitName);
  3666. block.OwnerMask = root.OwnerMask;
  3667. block.NextOwnerMask = root.NextOwnerMask;
  3668. block.GroupMask = root.GroupMask;
  3669. block.EveryoneMask = root.EveryoneMask;
  3670. block.BaseMask = root.BaseMask;
  3671. block.SaleType = root.ObjectSaleType;
  3672. block.SalePrice = root.SalePrice;
  3673. return block;
  3674. }
  3675. #region Estate Data Sending Methods
  3676. private static bool convertParamStringToBool(byte[] field)
  3677. {
  3678. string s = Utils.BytesToString(field);
  3679. if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
  3680. {
  3681. return true;
  3682. }
  3683. return false;
  3684. }
  3685. public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
  3686. {
  3687. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3688. packet.AgentData.TransactionID = UUID.Random();
  3689. packet.AgentData.AgentID = AgentId;
  3690. packet.AgentData.SessionID = SessionId;
  3691. packet.MethodData.Invoice = invoice;
  3692. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3693. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + Data.Length];
  3694. for (int i = 0; i < (6 + Data.Length); i++)
  3695. {
  3696. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  3697. }
  3698. int j = 0;
  3699. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3700. returnblock[j].Parameter = Utils.StringToBytes(code.ToString()); j++;
  3701. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3702. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3703. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3704. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3705. j = 2; // Agents
  3706. if ((code & 2) != 0)
  3707. j = 3; // Groups
  3708. if ((code & 8) != 0)
  3709. j = 5; // Managers
  3710. returnblock[j].Parameter = Utils.StringToBytes(Data.Length.ToString());
  3711. j = 6;
  3712. for (int i = 0; i < Data.Length; i++)
  3713. {
  3714. returnblock[j].Parameter = Data[i].GetBytes(); j++;
  3715. }
  3716. packet.ParamList = returnblock;
  3717. packet.Header.Reliable = true;
  3718. OutPacket(packet, ThrottleOutPacketType.Task);
  3719. }
  3720. public void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID)
  3721. {
  3722. List<UUID> BannedUsers = new List<UUID>();
  3723. for (int i = 0; i < bl.Length; i++)
  3724. {
  3725. if (bl[i] == null)
  3726. continue;
  3727. if (bl[i].BannedUserID == UUID.Zero)
  3728. continue;
  3729. BannedUsers.Add(bl[i].BannedUserID);
  3730. }
  3731. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3732. packet.AgentData.TransactionID = UUID.Random();
  3733. packet.AgentData.AgentID = AgentId;
  3734. packet.AgentData.SessionID = SessionId;
  3735. packet.MethodData.Invoice = invoice;
  3736. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3737. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
  3738. for (int i = 0; i < (6 + BannedUsers.Count); i++)
  3739. {
  3740. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  3741. }
  3742. int j = 0;
  3743. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3744. returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
  3745. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3746. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3747. returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
  3748. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3749. foreach (UUID banned in BannedUsers)
  3750. {
  3751. returnblock[j].Parameter = banned.GetBytes(); j++;
  3752. }
  3753. packet.ParamList = returnblock;
  3754. packet.Header.Reliable = false;
  3755. OutPacket(packet, ThrottleOutPacketType.Task);
  3756. }
  3757. public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
  3758. {
  3759. RegionInfoPacket rinfopack = new RegionInfoPacket();
  3760. RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
  3761. rinfopack.AgentData.AgentID = AgentId;
  3762. rinfopack.AgentData.SessionID = SessionId;
  3763. rinfoblk.BillableFactor = args.billableFactor;
  3764. rinfoblk.EstateID = args.estateID;
  3765. rinfoblk.MaxAgents = args.maxAgents;
  3766. rinfoblk.ObjectBonusFactor = args.objectBonusFactor;
  3767. rinfoblk.ParentEstateID = args.parentEstateID;
  3768. rinfoblk.PricePerMeter = args.pricePerMeter;
  3769. rinfoblk.RedirectGridX = args.redirectGridX;
  3770. rinfoblk.RedirectGridY = args.redirectGridY;
  3771. rinfoblk.RegionFlags = args.regionFlags;
  3772. rinfoblk.SimAccess = args.simAccess;
  3773. rinfoblk.SunHour = args.sunHour;
  3774. rinfoblk.TerrainLowerLimit = args.terrainLowerLimit;
  3775. rinfoblk.TerrainRaiseLimit = args.terrainRaiseLimit;
  3776. rinfoblk.UseEstateSun = args.useEstateSun;
  3777. rinfoblk.WaterHeight = args.waterHeight;
  3778. rinfoblk.SimName = Utils.StringToBytes(args.simName);
  3779. rinfopack.RegionInfo2 = new RegionInfoPacket.RegionInfo2Block();
  3780. rinfopack.RegionInfo2.HardMaxAgents = uint.MaxValue;
  3781. rinfopack.RegionInfo2.HardMaxObjects = uint.MaxValue;
  3782. rinfopack.RegionInfo2.MaxAgents32 = uint.MaxValue;
  3783. rinfopack.RegionInfo2.ProductName = Util.StringToBytes256(args.regionType);
  3784. rinfopack.RegionInfo2.ProductSKU = Utils.EmptyBytes;
  3785. rinfopack.HasVariableBlocks = true;
  3786. rinfopack.RegionInfo = rinfoblk;
  3787. rinfopack.AgentData = new RegionInfoPacket.AgentDataBlock();
  3788. rinfopack.AgentData.AgentID = AgentId;
  3789. rinfopack.AgentData.SessionID = SessionId;
  3790. OutPacket(rinfopack, ThrottleOutPacketType.Task);
  3791. }
  3792. public void SendEstateCovenantInformation(UUID covenant)
  3793. {
  3794. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending estate covenant asset id of {0} to {1}", covenant, Name);
  3795. EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
  3796. EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
  3797. edata.CovenantID = covenant;
  3798. edata.CovenantTimestamp = 0;
  3799. edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  3800. edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName);
  3801. einfopack.Data = edata;
  3802. OutPacket(einfopack, ThrottleOutPacketType.Task);
  3803. }
  3804. public void SendDetailedEstateData(
  3805. UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition,
  3806. UUID covenant, string abuseEmail, UUID estateOwner)
  3807. {
  3808. // m_log.DebugFormat(
  3809. // "[LLCLIENTVIEW]: Sending detailed estate data to {0} with covenant asset id {1}", Name, covenant);
  3810. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3811. packet.MethodData.Invoice = invoice;
  3812. packet.AgentData.TransactionID = UUID.Random();
  3813. packet.MethodData.Method = Utils.StringToBytes("estateupdateinfo");
  3814. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[10];
  3815. for (int i = 0; i < 10; i++)
  3816. {
  3817. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  3818. }
  3819. //Sending Estate Settings
  3820. returnblock[0].Parameter = Utils.StringToBytes(estateName);
  3821. returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString());
  3822. returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString());
  3823. returnblock[3].Parameter = Utils.StringToBytes(estateFlags.ToString());
  3824. returnblock[4].Parameter = Utils.StringToBytes(sunPosition.ToString());
  3825. returnblock[5].Parameter = Utils.StringToBytes(parentEstate.ToString());
  3826. returnblock[6].Parameter = Utils.StringToBytes(covenant.ToString());
  3827. returnblock[7].Parameter = Utils.StringToBytes("1160895077"); // what is this?
  3828. returnblock[8].Parameter = Utils.StringToBytes("1"); // what is this?
  3829. returnblock[9].Parameter = Utils.StringToBytes(abuseEmail);
  3830. packet.ParamList = returnblock;
  3831. packet.Header.Reliable = false;
  3832. //m_log.Debug("[ESTATE]: SIM--->" + packet.ToString());
  3833. OutPacket(packet, ThrottleOutPacketType.Task);
  3834. }
  3835. #endregion
  3836. #region Land Data Sending Methods
  3837. public void SendLandParcelOverlay(byte[] data, int sequence_id)
  3838. {
  3839. ParcelOverlayPacket packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
  3840. packet.ParcelData.Data = data;
  3841. packet.ParcelData.SequenceID = sequence_id;
  3842. packet.Header.Zerocoded = true;
  3843. OutPacket(packet, ThrottleOutPacketType.Task);
  3844. }
  3845. public void SendLandProperties(
  3846. int sequence_id, bool snap_selection, int request_result, ILandObject lo,
  3847. float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
  3848. {
  3849. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name);
  3850. LandData landData = lo.LandData;
  3851. ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage();
  3852. updateMessage.AABBMax = landData.AABBMax;
  3853. updateMessage.AABBMin = landData.AABBMin;
  3854. updateMessage.Area = landData.Area;
  3855. updateMessage.AuctionID = landData.AuctionID;
  3856. updateMessage.AuthBuyerID = landData.AuthBuyerID;
  3857. updateMessage.Bitmap = landData.Bitmap;
  3858. updateMessage.Desc = landData.Description;
  3859. updateMessage.Category = landData.Category;
  3860. updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate);
  3861. updateMessage.ClaimPrice = landData.ClaimPrice;
  3862. updateMessage.GroupID = landData.GroupID;
  3863. updateMessage.IsGroupOwned = landData.IsGroupOwned;
  3864. updateMessage.LandingType = (LandingType) landData.LandingType;
  3865. updateMessage.LocalID = landData.LocalID;
  3866. if (landData.Area > 0)
  3867. {
  3868. updateMessage.MaxPrims = parcelObjectCapacity;
  3869. }
  3870. else
  3871. {
  3872. updateMessage.MaxPrims = 0;
  3873. }
  3874. updateMessage.MediaAutoScale = Convert.ToBoolean(landData.MediaAutoScale);
  3875. updateMessage.MediaID = landData.MediaID;
  3876. updateMessage.MediaURL = landData.MediaURL;
  3877. updateMessage.MusicURL = landData.MusicURL;
  3878. updateMessage.Name = landData.Name;
  3879. updateMessage.OtherCleanTime = landData.OtherCleanTime;
  3880. updateMessage.OtherCount = 0; //TODO: Unimplemented
  3881. updateMessage.OwnerID = landData.OwnerID;
  3882. updateMessage.ParcelFlags = (ParcelFlags) landData.Flags;
  3883. updateMessage.ParcelPrimBonus = simObjectBonusFactor;
  3884. updateMessage.PassHours = landData.PassHours;
  3885. updateMessage.PassPrice = landData.PassPrice;
  3886. updateMessage.PublicCount = 0; //TODO: Unimplemented
  3887. updateMessage.RegionPushOverride = (regionFlags & (uint)RegionFlags.RestrictPushObject) > 0;
  3888. updateMessage.RegionDenyAnonymous = (regionFlags & (uint)RegionFlags.DenyAnonymous) > 0;
  3889. //updateMessage.RegionDenyIdentified = (regionFlags & (uint)RegionFlags.DenyIdentified) > 0;
  3890. //updateMessage.RegionDenyTransacted = (regionFlags & (uint)RegionFlags.DenyTransacted) > 0;
  3891. updateMessage.RentPrice = 0;
  3892. updateMessage.RequestResult = (ParcelResult) request_result;
  3893. updateMessage.SalePrice = landData.SalePrice;
  3894. updateMessage.SelfCount = 0; //TODO: Unimplemented
  3895. updateMessage.SequenceID = sequence_id;
  3896. if (landData.SimwideArea > 0)
  3897. {
  3898. int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
  3899. updateMessage.SimWideMaxPrims = simulatorCapacity;
  3900. }
  3901. else
  3902. {
  3903. updateMessage.SimWideMaxPrims = 0;
  3904. }
  3905. updateMessage.SnapSelection = snap_selection;
  3906. updateMessage.SnapshotID = landData.SnapshotID;
  3907. updateMessage.Status = (ParcelStatus) landData.Status;
  3908. updateMessage.UserLocation = landData.UserLocation;
  3909. updateMessage.UserLookAt = landData.UserLookAt;
  3910. updateMessage.MediaType = landData.MediaType;
  3911. updateMessage.MediaDesc = landData.MediaDescription;
  3912. updateMessage.MediaWidth = landData.MediaWidth;
  3913. updateMessage.MediaHeight = landData.MediaHeight;
  3914. updateMessage.MediaLoop = landData.MediaLoop;
  3915. updateMessage.ObscureMusic = landData.ObscureMusic;
  3916. updateMessage.ObscureMedia = landData.ObscureMedia;
  3917. IPrimCounts pc = lo.PrimCounts;
  3918. updateMessage.OwnerPrims = pc.Owner;
  3919. updateMessage.GroupPrims = pc.Group;
  3920. updateMessage.OtherPrims = pc.Others;
  3921. updateMessage.SelectedPrims = pc.Selected;
  3922. updateMessage.TotalPrims = pc.Total;
  3923. updateMessage.SimWideTotalPrims = pc.Simulator;
  3924. try
  3925. {
  3926. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  3927. if (eq != null)
  3928. {
  3929. eq.ParcelProperties(updateMessage, this.AgentId);
  3930. }
  3931. else
  3932. {
  3933. m_log.Warn("[LLCLIENTVIEW]: No EQ Interface when sending parcel data.");
  3934. }
  3935. }
  3936. catch (Exception ex)
  3937. {
  3938. m_log.Error("[LLCLIENTVIEW]: Unable to send parcel data via eventqueue - exception: " + ex.ToString());
  3939. }
  3940. }
  3941. public void SendLandAccessListData(List<UUID> avatars, uint accessFlag, int localLandID)
  3942. {
  3943. ParcelAccessListReplyPacket replyPacket = (ParcelAccessListReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
  3944. replyPacket.Data.AgentID = AgentId;
  3945. replyPacket.Data.Flags = accessFlag;
  3946. replyPacket.Data.LocalID = localLandID;
  3947. replyPacket.Data.SequenceID = 0;
  3948. List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>();
  3949. foreach (UUID avatar in avatars)
  3950. {
  3951. ParcelAccessListReplyPacket.ListBlock block = new ParcelAccessListReplyPacket.ListBlock();
  3952. block.Flags = accessFlag;
  3953. block.ID = avatar;
  3954. block.Time = 0;
  3955. list.Add(block);
  3956. }
  3957. replyPacket.List = list.ToArray();
  3958. replyPacket.Header.Zerocoded = true;
  3959. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  3960. }
  3961. public void SendForceClientSelectObjects(List<uint> ObjectIDs)
  3962. {
  3963. m_log.WarnFormat("[LLCLIENTVIEW] sending select with {0} objects", ObjectIDs.Count);
  3964. bool firstCall = true;
  3965. const int MAX_OBJECTS_PER_PACKET = 251;
  3966. ForceObjectSelectPacket pack = (ForceObjectSelectPacket)PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect);
  3967. ForceObjectSelectPacket.DataBlock[] data;
  3968. while (ObjectIDs.Count > 0)
  3969. {
  3970. if (firstCall)
  3971. {
  3972. pack._Header.ResetList = true;
  3973. firstCall = false;
  3974. }
  3975. else
  3976. {
  3977. pack._Header.ResetList = false;
  3978. }
  3979. if (ObjectIDs.Count > MAX_OBJECTS_PER_PACKET)
  3980. {
  3981. data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
  3982. }
  3983. else
  3984. {
  3985. data = new ForceObjectSelectPacket.DataBlock[ObjectIDs.Count];
  3986. }
  3987. int i;
  3988. for (i = 0; i < MAX_OBJECTS_PER_PACKET && ObjectIDs.Count > 0; i++)
  3989. {
  3990. data[i] = new ForceObjectSelectPacket.DataBlock();
  3991. data[i].LocalID = Convert.ToUInt32(ObjectIDs[0]);
  3992. ObjectIDs.RemoveAt(0);
  3993. }
  3994. pack.Data = data;
  3995. pack.Header.Zerocoded = true;
  3996. OutPacket(pack, ThrottleOutPacketType.Task);
  3997. }
  3998. }
  3999. public void SendCameraConstraint(Vector4 ConstraintPlane)
  4000. {
  4001. CameraConstraintPacket cpack = (CameraConstraintPacket)PacketPool.Instance.GetPacket(PacketType.CameraConstraint);
  4002. cpack.CameraCollidePlane = new CameraConstraintPacket.CameraCollidePlaneBlock();
  4003. cpack.CameraCollidePlane.Plane = ConstraintPlane;
  4004. //m_log.DebugFormat("[CLIENTVIEW]: Constraint {0}", ConstraintPlane);
  4005. OutPacket(cpack, ThrottleOutPacketType.Task);
  4006. }
  4007. public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
  4008. {
  4009. int notifyCount = ownersAndCount.Count;
  4010. ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
  4011. if (notifyCount > 0)
  4012. {
  4013. if (notifyCount > 32)
  4014. {
  4015. m_log.InfoFormat(
  4016. "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
  4017. + " - a developer might want to investigate whether this is a hard limit", 32);
  4018. notifyCount = 32;
  4019. }
  4020. ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
  4021. = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
  4022. int num = 0;
  4023. foreach (UUID owner in ownersAndCount.Keys)
  4024. {
  4025. dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
  4026. dataBlock[num].Count = ownersAndCount[owner];
  4027. if (land.GroupID == owner || groups.Contains(owner))
  4028. dataBlock[num].IsGroupOwned = true;
  4029. dataBlock[num].OnlineStatus = true; //TODO: fix me later
  4030. dataBlock[num].OwnerID = owner;
  4031. num++;
  4032. if (num >= notifyCount)
  4033. {
  4034. break;
  4035. }
  4036. }
  4037. pack.Data = dataBlock;
  4038. }
  4039. else
  4040. {
  4041. pack.Data = new ParcelObjectOwnersReplyPacket.DataBlock[0];
  4042. }
  4043. pack.Header.Zerocoded = true;
  4044. this.OutPacket(pack, ThrottleOutPacketType.Task);
  4045. }
  4046. #endregion
  4047. #region Helper Methods
  4048. protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
  4049. {
  4050. #region ScenePresence/SOP Handling
  4051. bool avatar = (entity is ScenePresence);
  4052. uint localID = entity.LocalId;
  4053. uint attachPoint;
  4054. Vector4 collisionPlane;
  4055. Vector3 position, velocity, acceleration, angularVelocity;
  4056. Quaternion rotation;
  4057. byte[] textureEntry;
  4058. if (entity is ScenePresence)
  4059. {
  4060. ScenePresence presence = (ScenePresence)entity;
  4061. attachPoint = 0;
  4062. collisionPlane = presence.CollisionPlane;
  4063. position = presence.OffsetPosition;
  4064. velocity = presence.Velocity;
  4065. acceleration = Vector3.Zero;
  4066. angularVelocity = Vector3.Zero;
  4067. rotation = presence.Rotation;
  4068. if (sendTexture)
  4069. textureEntry = presence.Appearance.Texture.GetBytes();
  4070. else
  4071. textureEntry = null;
  4072. }
  4073. else
  4074. {
  4075. SceneObjectPart part = (SceneObjectPart)entity;
  4076. attachPoint = part.ParentGroup.AttachmentPoint;
  4077. // m_log.DebugFormat(
  4078. // "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}",
  4079. // attachPoint, part.Name, part.LocalId, Name);
  4080. collisionPlane = Vector4.Zero;
  4081. position = part.RelativePosition;
  4082. velocity = part.Velocity;
  4083. acceleration = part.Acceleration;
  4084. angularVelocity = part.AngularVelocity;
  4085. rotation = part.RotationOffset;
  4086. if (sendTexture)
  4087. textureEntry = part.Shape.TextureEntry;
  4088. else
  4089. textureEntry = null;
  4090. }
  4091. #endregion ScenePresence/SOP Handling
  4092. int pos = 0;
  4093. byte[] data = new byte[(avatar ? 60 : 44)];
  4094. // LocalID
  4095. Utils.UIntToBytes(localID, data, pos);
  4096. pos += 4;
  4097. // Avatar/CollisionPlane
  4098. data[pos++] = (byte)((attachPoint % 16) * 16 + (attachPoint / 16)); ;
  4099. if (avatar)
  4100. {
  4101. data[pos++] = 1;
  4102. if (collisionPlane == Vector4.Zero)
  4103. collisionPlane = Vector4.UnitW;
  4104. //m_log.DebugFormat("CollisionPlane: {0}",collisionPlane);
  4105. collisionPlane.ToBytes(data, pos);
  4106. pos += 16;
  4107. }
  4108. else
  4109. {
  4110. ++pos;
  4111. }
  4112. // Position
  4113. position.ToBytes(data, pos);
  4114. pos += 12;
  4115. // Velocity
  4116. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
  4117. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
  4118. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
  4119. // Acceleration
  4120. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
  4121. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4122. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4123. // Rotation
  4124. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.X, -1.0f, 1.0f), data, pos); pos += 2;
  4125. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Y, -1.0f, 1.0f), data, pos); pos += 2;
  4126. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Z, -1.0f, 1.0f), data, pos); pos += 2;
  4127. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
  4128. // Angular Velocity
  4129. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
  4130. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4131. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4132. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
  4133. block.Data = data;
  4134. if (textureEntry != null && textureEntry.Length > 0)
  4135. {
  4136. byte[] teBytesFinal = new byte[textureEntry.Length + 4];
  4137. // Texture Length
  4138. Utils.IntToBytes(textureEntry.Length, textureEntry, 0);
  4139. // Texture
  4140. Buffer.BlockCopy(textureEntry, 0, teBytesFinal, 4, textureEntry.Length);
  4141. block.TextureEntry = teBytesFinal;
  4142. }
  4143. else
  4144. {
  4145. block.TextureEntry = Utils.EmptyBytes;
  4146. }
  4147. return block;
  4148. }
  4149. protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data)
  4150. {
  4151. byte[] objectData = new byte[76];
  4152. data.CollisionPlane.ToBytes(objectData, 0);
  4153. data.OffsetPosition.ToBytes(objectData, 16);
  4154. //data.Velocity.ToBytes(objectData, 28);
  4155. //data.Acceleration.ToBytes(objectData, 40);
  4156. data.Rotation.ToBytes(objectData, 52);
  4157. //data.AngularVelocity.ToBytes(objectData, 64);
  4158. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4159. update.Data = Utils.EmptyBytes;
  4160. update.ExtraParams = new byte[1];
  4161. update.FullID = data.UUID;
  4162. update.ID = data.LocalId;
  4163. update.Material = (byte)Material.Flesh;
  4164. update.MediaURL = Utils.EmptyBytes;
  4165. update.NameValue = Utils.StringToBytes("FirstName STRING RW SV " + data.Firstname + "\nLastName STRING RW SV " +
  4166. data.Lastname + "\nTitle STRING RW SV " + data.Grouptitle);
  4167. update.ObjectData = objectData;
  4168. update.ParentID = data.ParentID;
  4169. update.PathCurve = 16;
  4170. update.PathScaleX = 100;
  4171. update.PathScaleY = 100;
  4172. update.PCode = (byte)PCode.Avatar;
  4173. update.ProfileCurve = 1;
  4174. update.PSBlock = Utils.EmptyBytes;
  4175. update.Scale = new Vector3(0.45f, 0.6f, 1.9f);
  4176. update.Text = Utils.EmptyBytes;
  4177. update.TextColor = new byte[4];
  4178. update.TextureAnim = Utils.EmptyBytes;
  4179. update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes;
  4180. update.UpdateFlags = (uint)(
  4181. PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner |
  4182. PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer |
  4183. PrimFlags.ObjectOwnerModify);
  4184. return update;
  4185. }
  4186. protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
  4187. {
  4188. byte[] objectData = new byte[60];
  4189. data.RelativePosition.ToBytes(objectData, 0);
  4190. data.Velocity.ToBytes(objectData, 12);
  4191. data.Acceleration.ToBytes(objectData, 24);
  4192. try
  4193. {
  4194. data.RotationOffset.ToBytes(objectData, 36);
  4195. }
  4196. catch (Exception e)
  4197. {
  4198. m_log.Warn("[LLClientView]: exception converting quaternion to bytes, using Quaternion.Identity. Exception: " + e.ToString());
  4199. OpenMetaverse.Quaternion.Identity.ToBytes(objectData, 36);
  4200. }
  4201. data.AngularVelocity.ToBytes(objectData, 48);
  4202. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4203. update.ClickAction = (byte)data.ClickAction;
  4204. update.CRC = 0;
  4205. update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes;
  4206. update.FullID = data.UUID;
  4207. update.ID = data.LocalId;
  4208. //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
  4209. //update.JointPivot = Vector3.Zero;
  4210. //update.JointType = 0;
  4211. update.Material = data.Material;
  4212. update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
  4213. if (data.ParentGroup.IsAttachment)
  4214. {
  4215. update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.FromItemID);
  4216. update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
  4217. }
  4218. else
  4219. {
  4220. update.NameValue = Utils.EmptyBytes;
  4221. // The root part state is the canonical state for all parts of the object. The other part states in the
  4222. // case for attachments may contain conflicting values that can end up crashing the viewer.
  4223. update.State = data.ParentGroup.RootPart.Shape.State;
  4224. }
  4225. // m_log.DebugFormat(
  4226. // "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}",
  4227. // update.State, data.Name, data.LocalId, Name);
  4228. update.ObjectData = objectData;
  4229. update.ParentID = data.ParentID;
  4230. update.PathBegin = data.Shape.PathBegin;
  4231. update.PathCurve = data.Shape.PathCurve;
  4232. update.PathEnd = data.Shape.PathEnd;
  4233. update.PathRadiusOffset = data.Shape.PathRadiusOffset;
  4234. update.PathRevolutions = data.Shape.PathRevolutions;
  4235. update.PathScaleX = data.Shape.PathScaleX;
  4236. update.PathScaleY = data.Shape.PathScaleY;
  4237. update.PathShearX = data.Shape.PathShearX;
  4238. update.PathShearY = data.Shape.PathShearY;
  4239. update.PathSkew = data.Shape.PathSkew;
  4240. update.PathTaperX = data.Shape.PathTaperX;
  4241. update.PathTaperY = data.Shape.PathTaperY;
  4242. update.PathTwist = data.Shape.PathTwist;
  4243. update.PathTwistBegin = data.Shape.PathTwistBegin;
  4244. update.PCode = data.Shape.PCode;
  4245. update.ProfileBegin = data.Shape.ProfileBegin;
  4246. update.ProfileCurve = data.Shape.ProfileCurve;
  4247. update.ProfileEnd = data.Shape.ProfileEnd;
  4248. update.ProfileHollow = data.Shape.ProfileHollow;
  4249. update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes;
  4250. update.TextColor = data.GetTextColor().GetBytes(false);
  4251. update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes;
  4252. update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes;
  4253. update.Scale = data.Shape.Scale;
  4254. update.Text = Util.StringToBytes256(data.Text);
  4255. update.MediaURL = Util.StringToBytes256(data.MediaUrl);
  4256. #region PrimFlags
  4257. PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(recipientID, data.UUID);
  4258. // Don't send the CreateSelected flag to everyone
  4259. flags &= ~PrimFlags.CreateSelected;
  4260. if (recipientID == data.OwnerID)
  4261. {
  4262. if (data.CreateSelected)
  4263. {
  4264. // Only send this flag once, then unset it
  4265. flags |= PrimFlags.CreateSelected;
  4266. data.CreateSelected = false;
  4267. }
  4268. }
  4269. // m_log.DebugFormat(
  4270. // "[LLCLIENTVIEW]: Constructing client update for part {0} {1} with flags {2}, localId {3}",
  4271. // data.Name, update.FullID, flags, update.ID);
  4272. update.UpdateFlags = (uint)flags;
  4273. #endregion PrimFlags
  4274. if (data.Sound != UUID.Zero)
  4275. {
  4276. update.Sound = data.Sound;
  4277. update.OwnerID = data.OwnerID;
  4278. update.Gain = (float)data.SoundGain;
  4279. update.Radius = (float)data.SoundRadius;
  4280. update.Flags = data.SoundFlags;
  4281. }
  4282. switch ((PCode)data.Shape.PCode)
  4283. {
  4284. case PCode.Grass:
  4285. case PCode.Tree:
  4286. case PCode.NewTree:
  4287. update.Data = new byte[] { data.Shape.State };
  4288. break;
  4289. default:
  4290. update.Data = Utils.EmptyBytes;
  4291. break;
  4292. }
  4293. return update;
  4294. }
  4295. protected ObjectUpdateCompressedPacket.ObjectDataBlock CreateCompressedUpdateBlock(SceneObjectPart part, PrimUpdateFlags updateFlags)
  4296. {
  4297. // TODO: Implement this
  4298. return null;
  4299. }
  4300. public void SendNameReply(UUID profileId, string firstname, string lastname)
  4301. {
  4302. UUIDNameReplyPacket packet = (UUIDNameReplyPacket)PacketPool.Instance.GetPacket(PacketType.UUIDNameReply);
  4303. // TODO: don't create new blocks if recycling an old packet
  4304. packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
  4305. packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
  4306. packet.UUIDNameBlock[0].ID = profileId;
  4307. packet.UUIDNameBlock[0].FirstName = Util.StringToBytes256(firstname);
  4308. packet.UUIDNameBlock[0].LastName = Util.StringToBytes256(lastname);
  4309. OutPacket(packet, ThrottleOutPacketType.Task);
  4310. }
  4311. public ulong GetGroupPowers(UUID groupID)
  4312. {
  4313. if (groupID == m_activeGroupID)
  4314. return m_activeGroupPowers;
  4315. if (m_groupPowers.ContainsKey(groupID))
  4316. return m_groupPowers[groupID];
  4317. return 0;
  4318. }
  4319. /// <summary>
  4320. /// This is a utility method used by single states to not duplicate kicks and blue card of death messages.
  4321. /// </summary>
  4322. public bool ChildAgentStatus()
  4323. {
  4324. return m_scene.PresenceChildStatus(AgentId);
  4325. }
  4326. #endregion
  4327. /// <summary>
  4328. /// This is a different way of processing packets then ProcessInPacket
  4329. /// </summary>
  4330. protected virtual void RegisterLocalPacketHandlers()
  4331. {
  4332. AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
  4333. AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false);
  4334. AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false);
  4335. AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false);
  4336. AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
  4337. AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
  4338. AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
  4339. AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest, false);
  4340. AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest, false);
  4341. AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage);
  4342. AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest);
  4343. AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
  4344. AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate);
  4345. AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply);
  4346. AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage, false);
  4347. AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship);
  4348. AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship);
  4349. AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFrendship);
  4350. AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
  4351. AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
  4352. AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
  4353. AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply);
  4354. AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest);
  4355. AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance);
  4356. AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing);
  4357. AddLocalPacketHandler(PacketType.RezSingleAttachmentFromInv, HandlerRezSingleAttachmentFromInv);
  4358. AddLocalPacketHandler(PacketType.RezMultipleAttachmentsFromInv, HandleRezMultipleAttachmentsFromInv);
  4359. AddLocalPacketHandler(PacketType.DetachAttachmentIntoInv, HandleDetachAttachmentIntoInv);
  4360. AddLocalPacketHandler(PacketType.ObjectAttach, HandleObjectAttach);
  4361. AddLocalPacketHandler(PacketType.ObjectDetach, HandleObjectDetach);
  4362. AddLocalPacketHandler(PacketType.ObjectDrop, HandleObjectDrop);
  4363. AddLocalPacketHandler(PacketType.SetAlwaysRun, HandleSetAlwaysRun, false);
  4364. AddLocalPacketHandler(PacketType.CompleteAgentMovement, HandleCompleteAgentMovement);
  4365. AddLocalPacketHandler(PacketType.AgentAnimation, HandleAgentAnimation, false);
  4366. AddLocalPacketHandler(PacketType.AgentRequestSit, HandleAgentRequestSit);
  4367. AddLocalPacketHandler(PacketType.AgentSit, HandleAgentSit);
  4368. AddLocalPacketHandler(PacketType.SoundTrigger, HandleSoundTrigger);
  4369. AddLocalPacketHandler(PacketType.AvatarPickerRequest, HandleAvatarPickerRequest);
  4370. AddLocalPacketHandler(PacketType.AgentDataUpdateRequest, HandleAgentDataUpdateRequest);
  4371. AddLocalPacketHandler(PacketType.UserInfoRequest, HandleUserInfoRequest);
  4372. AddLocalPacketHandler(PacketType.UpdateUserInfo, HandleUpdateUserInfo);
  4373. AddLocalPacketHandler(PacketType.SetStartLocationRequest, HandleSetStartLocationRequest);
  4374. AddLocalPacketHandler(PacketType.AgentThrottle, HandleAgentThrottle, false);
  4375. AddLocalPacketHandler(PacketType.AgentPause, HandleAgentPause, false);
  4376. AddLocalPacketHandler(PacketType.AgentResume, HandleAgentResume, false);
  4377. AddLocalPacketHandler(PacketType.ForceScriptControlRelease, HandleForceScriptControlRelease);
  4378. AddLocalPacketHandler(PacketType.ObjectLink, HandleObjectLink);
  4379. AddLocalPacketHandler(PacketType.ObjectDelink, HandleObjectDelink);
  4380. AddLocalPacketHandler(PacketType.ObjectAdd, HandleObjectAdd);
  4381. AddLocalPacketHandler(PacketType.ObjectShape, HandleObjectShape);
  4382. AddLocalPacketHandler(PacketType.ObjectExtraParams, HandleObjectExtraParams);
  4383. AddLocalPacketHandler(PacketType.ObjectDuplicate, HandleObjectDuplicate);
  4384. AddLocalPacketHandler(PacketType.RequestMultipleObjects, HandleRequestMultipleObjects);
  4385. AddLocalPacketHandler(PacketType.ObjectSelect, HandleObjectSelect);
  4386. AddLocalPacketHandler(PacketType.ObjectDeselect, HandleObjectDeselect);
  4387. AddLocalPacketHandler(PacketType.ObjectPosition, HandleObjectPosition);
  4388. AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale);
  4389. AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation);
  4390. AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate);
  4391. // Handle ObjectImage (TextureEntry) updates synchronously, since when updating multiple prim faces at once,
  4392. // some clients will send out a separate ObjectImage packet for each face
  4393. AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage, false);
  4394. AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false);
  4395. AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false);
  4396. AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab);
  4397. AddLocalPacketHandler(PacketType.ObjectSpinStart, HandleObjectSpinStart, false);
  4398. AddLocalPacketHandler(PacketType.ObjectSpinUpdate, HandleObjectSpinUpdate, false);
  4399. AddLocalPacketHandler(PacketType.ObjectSpinStop, HandleObjectSpinStop, false);
  4400. AddLocalPacketHandler(PacketType.ObjectDescription, HandleObjectDescription, false);
  4401. AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false);
  4402. AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false);
  4403. AddLocalPacketHandler(PacketType.Undo, HandleUndo, false);
  4404. AddLocalPacketHandler(PacketType.UndoLand, HandleLandUndo, false);
  4405. AddLocalPacketHandler(PacketType.Redo, HandleRedo, false);
  4406. AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay);
  4407. AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false);
  4408. AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch);
  4409. AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false);
  4410. AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false);
  4411. AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false);
  4412. AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage);
  4413. AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest);
  4414. AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest);
  4415. AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer);
  4416. AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket);
  4417. AddLocalPacketHandler(PacketType.ConfirmXferPacket, HandleConfirmXferPacket);
  4418. AddLocalPacketHandler(PacketType.AbortXfer, HandleAbortXfer);
  4419. AddLocalPacketHandler(PacketType.CreateInventoryFolder, HandleCreateInventoryFolder);
  4420. AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder);
  4421. AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder);
  4422. AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem);
  4423. AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem);
  4424. AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory);
  4425. AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents);
  4426. AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents);
  4427. AddLocalPacketHandler(PacketType.UpdateInventoryItem, HandleUpdateInventoryItem);
  4428. AddLocalPacketHandler(PacketType.CopyInventoryItem, HandleCopyInventoryItem);
  4429. AddLocalPacketHandler(PacketType.MoveInventoryItem, HandleMoveInventoryItem);
  4430. AddLocalPacketHandler(PacketType.RemoveInventoryItem, HandleRemoveInventoryItem);
  4431. AddLocalPacketHandler(PacketType.RemoveInventoryFolder, HandleRemoveInventoryFolder);
  4432. AddLocalPacketHandler(PacketType.RemoveInventoryObjects, HandleRemoveInventoryObjects);
  4433. AddLocalPacketHandler(PacketType.RequestTaskInventory, HandleRequestTaskInventory);
  4434. AddLocalPacketHandler(PacketType.UpdateTaskInventory, HandleUpdateTaskInventory);
  4435. AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory);
  4436. AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory);
  4437. AddLocalPacketHandler(PacketType.RezScript, HandleRezScript);
  4438. AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest, false);
  4439. AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest, false);
  4440. AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest, false);
  4441. AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest);
  4442. AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
  4443. AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
  4444. AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest);
  4445. AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
  4446. AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
  4447. AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
  4448. AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false);
  4449. AddLocalPacketHandler(PacketType.ParcelDivide, HandleParcelDivide);
  4450. AddLocalPacketHandler(PacketType.ParcelJoin, HandleParcelJoin);
  4451. AddLocalPacketHandler(PacketType.ParcelPropertiesUpdate, HandleParcelPropertiesUpdate);
  4452. AddLocalPacketHandler(PacketType.ParcelSelectObjects, HandleParcelSelectObjects);
  4453. AddLocalPacketHandler(PacketType.ParcelObjectOwnersRequest, HandleParcelObjectOwnersRequest);
  4454. AddLocalPacketHandler(PacketType.ParcelGodForceOwner, HandleParcelGodForceOwner);
  4455. AddLocalPacketHandler(PacketType.ParcelRelease, HandleParcelRelease);
  4456. AddLocalPacketHandler(PacketType.ParcelReclaim, HandleParcelReclaim);
  4457. AddLocalPacketHandler(PacketType.ParcelReturnObjects, HandleParcelReturnObjects);
  4458. AddLocalPacketHandler(PacketType.ParcelSetOtherCleanTime, HandleParcelSetOtherCleanTime);
  4459. AddLocalPacketHandler(PacketType.LandStatRequest, HandleLandStatRequest);
  4460. AddLocalPacketHandler(PacketType.ParcelDwellRequest, HandleParcelDwellRequest);
  4461. AddLocalPacketHandler(PacketType.EstateOwnerMessage, HandleEstateOwnerMessage);
  4462. AddLocalPacketHandler(PacketType.RequestRegionInfo, HandleRequestRegionInfo, false);
  4463. AddLocalPacketHandler(PacketType.EstateCovenantRequest, HandleEstateCovenantRequest);
  4464. AddLocalPacketHandler(PacketType.RequestGodlikePowers, HandleRequestGodlikePowers);
  4465. AddLocalPacketHandler(PacketType.GodKickUser, HandleGodKickUser);
  4466. AddLocalPacketHandler(PacketType.MoneyBalanceRequest, HandleMoneyBalanceRequest);
  4467. AddLocalPacketHandler(PacketType.EconomyDataRequest, HandleEconomyDataRequest);
  4468. AddLocalPacketHandler(PacketType.RequestPayPrice, HandleRequestPayPrice);
  4469. AddLocalPacketHandler(PacketType.ObjectSaleInfo, HandleObjectSaleInfo);
  4470. AddLocalPacketHandler(PacketType.ObjectBuy, HandleObjectBuy);
  4471. AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning);
  4472. AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning);
  4473. AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset);
  4474. AddLocalPacketHandler(PacketType.ActivateGestures, HandleActivateGestures);
  4475. AddLocalPacketHandler(PacketType.DeactivateGestures, HandleDeactivateGestures);
  4476. AddLocalPacketHandler(PacketType.ObjectOwner, HandleObjectOwner);
  4477. AddLocalPacketHandler(PacketType.AgentFOV, HandleAgentFOV, false);
  4478. AddLocalPacketHandler(PacketType.ViewerStats, HandleViewerStats);
  4479. AddLocalPacketHandler(PacketType.MapItemRequest, HandleMapItemRequest, false);
  4480. AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
  4481. AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
  4482. AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
  4483. AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
  4484. AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
  4485. AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
  4486. AddLocalPacketHandler(PacketType.DirFindQuery, HandleDirFindQuery);
  4487. AddLocalPacketHandler(PacketType.DirLandQuery, HandleDirLandQuery);
  4488. AddLocalPacketHandler(PacketType.DirPopularQuery, HandleDirPopularQuery);
  4489. AddLocalPacketHandler(PacketType.DirClassifiedQuery, HandleDirClassifiedQuery);
  4490. AddLocalPacketHandler(PacketType.EventInfoRequest, HandleEventInfoRequest);
  4491. AddLocalPacketHandler(PacketType.OfferCallingCard, HandleOfferCallingCard);
  4492. AddLocalPacketHandler(PacketType.AcceptCallingCard, HandleAcceptCallingCard);
  4493. AddLocalPacketHandler(PacketType.DeclineCallingCard, HandleDeclineCallingCard);
  4494. AddLocalPacketHandler(PacketType.ActivateGroup, HandleActivateGroup);
  4495. AddLocalPacketHandler(PacketType.GroupTitlesRequest, HandleGroupTitlesRequest);
  4496. AddLocalPacketHandler(PacketType.GroupProfileRequest, HandleGroupProfileRequest);
  4497. AddLocalPacketHandler(PacketType.GroupMembersRequest, HandleGroupMembersRequest);
  4498. AddLocalPacketHandler(PacketType.GroupRoleDataRequest, HandleGroupRoleDataRequest);
  4499. AddLocalPacketHandler(PacketType.GroupRoleMembersRequest, HandleGroupRoleMembersRequest);
  4500. AddLocalPacketHandler(PacketType.CreateGroupRequest, HandleCreateGroupRequest);
  4501. AddLocalPacketHandler(PacketType.UpdateGroupInfo, HandleUpdateGroupInfo);
  4502. AddLocalPacketHandler(PacketType.SetGroupAcceptNotices, HandleSetGroupAcceptNotices);
  4503. AddLocalPacketHandler(PacketType.GroupTitleUpdate, HandleGroupTitleUpdate);
  4504. AddLocalPacketHandler(PacketType.ParcelDeedToGroup, HandleParcelDeedToGroup);
  4505. AddLocalPacketHandler(PacketType.GroupNoticesListRequest, HandleGroupNoticesListRequest);
  4506. AddLocalPacketHandler(PacketType.GroupNoticeRequest, HandleGroupNoticeRequest);
  4507. AddLocalPacketHandler(PacketType.GroupRoleUpdate, HandleGroupRoleUpdate);
  4508. AddLocalPacketHandler(PacketType.GroupRoleChanges, HandleGroupRoleChanges);
  4509. AddLocalPacketHandler(PacketType.JoinGroupRequest, HandleJoinGroupRequest);
  4510. AddLocalPacketHandler(PacketType.LeaveGroupRequest, HandleLeaveGroupRequest);
  4511. AddLocalPacketHandler(PacketType.EjectGroupMemberRequest, HandleEjectGroupMemberRequest);
  4512. AddLocalPacketHandler(PacketType.InviteGroupRequest, HandleInviteGroupRequest);
  4513. AddLocalPacketHandler(PacketType.StartLure, HandleStartLure);
  4514. AddLocalPacketHandler(PacketType.TeleportLureRequest, HandleTeleportLureRequest);
  4515. AddLocalPacketHandler(PacketType.ClassifiedInfoRequest, HandleClassifiedInfoRequest);
  4516. AddLocalPacketHandler(PacketType.ClassifiedInfoUpdate, HandleClassifiedInfoUpdate);
  4517. AddLocalPacketHandler(PacketType.ClassifiedDelete, HandleClassifiedDelete);
  4518. AddLocalPacketHandler(PacketType.ClassifiedGodDelete, HandleClassifiedGodDelete);
  4519. AddLocalPacketHandler(PacketType.EventGodDelete, HandleEventGodDelete);
  4520. AddLocalPacketHandler(PacketType.EventNotificationAddRequest, HandleEventNotificationAddRequest);
  4521. AddLocalPacketHandler(PacketType.EventNotificationRemoveRequest, HandleEventNotificationRemoveRequest);
  4522. AddLocalPacketHandler(PacketType.RetrieveInstantMessages, HandleRetrieveInstantMessages);
  4523. AddLocalPacketHandler(PacketType.PickDelete, HandlePickDelete);
  4524. AddLocalPacketHandler(PacketType.PickGodDelete, HandlePickGodDelete);
  4525. AddLocalPacketHandler(PacketType.PickInfoUpdate, HandlePickInfoUpdate);
  4526. AddLocalPacketHandler(PacketType.AvatarNotesUpdate, HandleAvatarNotesUpdate);
  4527. AddLocalPacketHandler(PacketType.AvatarInterestsUpdate, HandleAvatarInterestsUpdate);
  4528. AddLocalPacketHandler(PacketType.GrantUserRights, HandleGrantUserRights);
  4529. AddLocalPacketHandler(PacketType.PlacesQuery, HandlePlacesQuery);
  4530. AddLocalPacketHandler(PacketType.UpdateMuteListEntry, HandleUpdateMuteListEntry);
  4531. AddLocalPacketHandler(PacketType.RemoveMuteListEntry, HandleRemoveMuteListEntry);
  4532. AddLocalPacketHandler(PacketType.UserReport, HandleUserReport);
  4533. AddLocalPacketHandler(PacketType.FindAgent, HandleFindAgent);
  4534. AddLocalPacketHandler(PacketType.TrackAgent, HandleTrackAgent);
  4535. AddLocalPacketHandler(PacketType.GodUpdateRegionInfo, HandleGodUpdateRegionInfoUpdate);
  4536. AddLocalPacketHandler(PacketType.GodlikeMessage, HandleGodlikeMessage);
  4537. AddLocalPacketHandler(PacketType.StateSave, HandleSaveStatePacket);
  4538. AddLocalPacketHandler(PacketType.GroupAccountDetailsRequest, HandleGroupAccountDetailsRequest);
  4539. AddLocalPacketHandler(PacketType.GroupAccountSummaryRequest, HandleGroupAccountSummaryRequest);
  4540. AddLocalPacketHandler(PacketType.GroupAccountTransactionsRequest, HandleGroupTransactionsDetailsRequest);
  4541. AddLocalPacketHandler(PacketType.FreezeUser, HandleFreezeUser);
  4542. AddLocalPacketHandler(PacketType.EjectUser, HandleEjectUser);
  4543. AddLocalPacketHandler(PacketType.ParcelBuyPass, HandleParcelBuyPass);
  4544. AddLocalPacketHandler(PacketType.ParcelGodMarkAsContent, HandleParcelGodMarkAsContent);
  4545. AddLocalPacketHandler(PacketType.GroupActiveProposalsRequest, HandleGroupActiveProposalsRequest);
  4546. AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest);
  4547. AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
  4548. AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
  4549. AddGenericPacketHandler("autopilot", HandleAutopilot);
  4550. }
  4551. #region Packet Handlers
  4552. #region Scene/Avatar
  4553. private bool HandleAgentUpdate(IClientAPI sener, Packet Pack)
  4554. {
  4555. if (OnAgentUpdate != null)
  4556. {
  4557. bool update = false;
  4558. AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack;
  4559. #region Packet Session and User Check
  4560. if (agenUpdate.AgentData.SessionID != SessionId || agenUpdate.AgentData.AgentID != AgentId)
  4561. return false;
  4562. #endregion
  4563. AgentUpdatePacket.AgentDataBlock x = agenUpdate.AgentData;
  4564. // We can only check when we have something to check
  4565. // against.
  4566. if (lastarg != null)
  4567. {
  4568. update =
  4569. (
  4570. (x.BodyRotation != lastarg.BodyRotation) ||
  4571. (x.CameraAtAxis != lastarg.CameraAtAxis) ||
  4572. (x.CameraCenter != lastarg.CameraCenter) ||
  4573. (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
  4574. (x.CameraUpAxis != lastarg.CameraUpAxis) ||
  4575. (x.ControlFlags != lastarg.ControlFlags) ||
  4576. (x.Far != lastarg.Far) ||
  4577. (x.Flags != lastarg.Flags) ||
  4578. (x.State != lastarg.State) ||
  4579. (x.HeadRotation != lastarg.HeadRotation) ||
  4580. (x.SessionID != lastarg.SessionID) ||
  4581. (x.AgentID != lastarg.AgentID)
  4582. );
  4583. }
  4584. else
  4585. {
  4586. update = true;
  4587. }
  4588. // These should be ordered from most-likely to
  4589. // least likely to change. I've made an initial
  4590. // guess at that.
  4591. if (update)
  4592. {
  4593. // m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name);
  4594. AgentUpdateArgs arg = new AgentUpdateArgs();
  4595. arg.AgentID = x.AgentID;
  4596. arg.BodyRotation = x.BodyRotation;
  4597. arg.CameraAtAxis = x.CameraAtAxis;
  4598. arg.CameraCenter = x.CameraCenter;
  4599. arg.CameraLeftAxis = x.CameraLeftAxis;
  4600. arg.CameraUpAxis = x.CameraUpAxis;
  4601. arg.ControlFlags = x.ControlFlags;
  4602. arg.Far = x.Far;
  4603. arg.Flags = x.Flags;
  4604. arg.HeadRotation = x.HeadRotation;
  4605. arg.SessionID = x.SessionID;
  4606. arg.State = x.State;
  4607. UpdateAgent handlerAgentUpdate = OnAgentUpdate;
  4608. UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
  4609. lastarg = arg; // save this set of arguments for nexttime
  4610. if (handlerPreAgentUpdate != null)
  4611. OnPreAgentUpdate(this, arg);
  4612. if (handlerAgentUpdate != null)
  4613. OnAgentUpdate(this, arg);
  4614. handlerAgentUpdate = null;
  4615. handlerPreAgentUpdate = null;
  4616. }
  4617. }
  4618. return true;
  4619. }
  4620. private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
  4621. {
  4622. MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
  4623. // validate the agent owns the agentID and sessionID
  4624. if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId &&
  4625. money.AgentData.SessionID == sender.SessionId)
  4626. {
  4627. MoneyTransferRequest handlerMoneyTransferRequest = OnMoneyTransferRequest;
  4628. if (handlerMoneyTransferRequest != null)
  4629. {
  4630. handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID,
  4631. money.MoneyData.Amount, money.MoneyData.TransactionType,
  4632. Util.FieldToString(money.MoneyData.Description));
  4633. }
  4634. return true;
  4635. }
  4636. return false;
  4637. }
  4638. private bool HandleParcelGodMarkAsContent(IClientAPI client, Packet Packet)
  4639. {
  4640. ParcelGodMarkAsContentPacket ParcelGodMarkAsContent =
  4641. (ParcelGodMarkAsContentPacket)Packet;
  4642. ParcelGodMark ParcelGodMarkAsContentHandler = OnParcelGodMark;
  4643. if (ParcelGodMarkAsContentHandler != null)
  4644. {
  4645. ParcelGodMarkAsContentHandler(this,
  4646. ParcelGodMarkAsContent.AgentData.AgentID,
  4647. ParcelGodMarkAsContent.ParcelData.LocalID);
  4648. return true;
  4649. }
  4650. return false;
  4651. }
  4652. private bool HandleFreezeUser(IClientAPI client, Packet Packet)
  4653. {
  4654. FreezeUserPacket FreezeUser = (FreezeUserPacket)Packet;
  4655. FreezeUserUpdate FreezeUserHandler = OnParcelFreezeUser;
  4656. if (FreezeUserHandler != null)
  4657. {
  4658. FreezeUserHandler(this,
  4659. FreezeUser.AgentData.AgentID,
  4660. FreezeUser.Data.Flags,
  4661. FreezeUser.Data.TargetID);
  4662. return true;
  4663. }
  4664. return false;
  4665. }
  4666. private bool HandleEjectUser(IClientAPI client, Packet Packet)
  4667. {
  4668. EjectUserPacket EjectUser =
  4669. (EjectUserPacket)Packet;
  4670. EjectUserUpdate EjectUserHandler = OnParcelEjectUser;
  4671. if (EjectUserHandler != null)
  4672. {
  4673. EjectUserHandler(this,
  4674. EjectUser.AgentData.AgentID,
  4675. EjectUser.Data.Flags,
  4676. EjectUser.Data.TargetID);
  4677. return true;
  4678. }
  4679. return false;
  4680. }
  4681. private bool HandleParcelBuyPass(IClientAPI client, Packet Packet)
  4682. {
  4683. ParcelBuyPassPacket ParcelBuyPass =
  4684. (ParcelBuyPassPacket)Packet;
  4685. ParcelBuyPass ParcelBuyPassHandler = OnParcelBuyPass;
  4686. if (ParcelBuyPassHandler != null)
  4687. {
  4688. ParcelBuyPassHandler(this,
  4689. ParcelBuyPass.AgentData.AgentID,
  4690. ParcelBuyPass.ParcelData.LocalID);
  4691. return true;
  4692. }
  4693. return false;
  4694. }
  4695. private bool HandleParcelBuyRequest(IClientAPI sender, Packet Pack)
  4696. {
  4697. ParcelBuyPacket parcel = (ParcelBuyPacket)Pack;
  4698. if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId)
  4699. {
  4700. ParcelBuy handlerParcelBuy = OnParcelBuy;
  4701. if (handlerParcelBuy != null)
  4702. {
  4703. handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final,
  4704. parcel.Data.IsGroupOwned,
  4705. parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area,
  4706. parcel.ParcelData.Price,
  4707. false);
  4708. }
  4709. return true;
  4710. }
  4711. return false;
  4712. }
  4713. private bool HandleUUIDGroupNameRequest(IClientAPI sender, Packet Pack)
  4714. {
  4715. UUIDGroupNameRequestPacket upack = (UUIDGroupNameRequestPacket)Pack;
  4716. for (int i = 0; i < upack.UUIDNameBlock.Length; i++)
  4717. {
  4718. UUIDNameRequest handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest;
  4719. if (handlerUUIDGroupNameRequest != null)
  4720. {
  4721. handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this);
  4722. }
  4723. }
  4724. return true;
  4725. }
  4726. public bool HandleGenericMessage(IClientAPI sender, Packet pack)
  4727. {
  4728. GenericMessagePacket gmpack = (GenericMessagePacket)pack;
  4729. if (m_genericPacketHandlers.Count == 0) return false;
  4730. if (gmpack.AgentData.SessionID != SessionId) return false;
  4731. GenericMessage handlerGenericMessage = null;
  4732. string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim();
  4733. if (m_genericPacketHandlers.TryGetValue(method, out handlerGenericMessage))
  4734. {
  4735. List<string> msg = new List<string>();
  4736. List<byte[]> msgBytes = new List<byte[]>();
  4737. if (handlerGenericMessage != null)
  4738. {
  4739. foreach (GenericMessagePacket.ParamListBlock block in gmpack.ParamList)
  4740. {
  4741. msg.Add(Util.FieldToString(block.Parameter));
  4742. msgBytes.Add(block.Parameter);
  4743. }
  4744. try
  4745. {
  4746. if (OnBinaryGenericMessage != null)
  4747. {
  4748. OnBinaryGenericMessage(this, method, msgBytes.ToArray());
  4749. }
  4750. handlerGenericMessage(sender, method, msg);
  4751. return true;
  4752. }
  4753. catch (Exception e)
  4754. {
  4755. m_log.ErrorFormat(
  4756. "[LLCLIENTVIEW]: Exeception when handling generic message {0}{1}", e.Message, e.StackTrace);
  4757. }
  4758. }
  4759. }
  4760. //m_log.Debug("[LLCLIENTVIEW]: Not handling GenericMessage with method-type of: " + method);
  4761. return false;
  4762. }
  4763. public bool HandleObjectGroupRequest(IClientAPI sender, Packet Pack)
  4764. {
  4765. ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack;
  4766. if (ogpack.AgentData.SessionID != SessionId) return false;
  4767. RequestObjectPropertiesFamily handlerObjectGroupRequest = OnObjectGroupRequest;
  4768. if (handlerObjectGroupRequest != null)
  4769. {
  4770. for (int i = 0; i < ogpack.ObjectData.Length; i++)
  4771. {
  4772. handlerObjectGroupRequest(this, ogpack.AgentData.GroupID, ogpack.ObjectData[i].ObjectLocalID, UUID.Zero);
  4773. }
  4774. }
  4775. return true;
  4776. }
  4777. private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
  4778. {
  4779. ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
  4780. if (viewer.AgentData.SessionID != SessionId) return false;
  4781. ViewerEffectEventHandler handlerViewerEffect = OnViewerEffect;
  4782. if (handlerViewerEffect != null)
  4783. {
  4784. int length = viewer.Effect.Length;
  4785. List<ViewerEffectEventHandlerArg> args = new List<ViewerEffectEventHandlerArg>(length);
  4786. for (int i = 0; i < length; i++)
  4787. {
  4788. //copy the effects block arguments into the event handler arg.
  4789. ViewerEffectEventHandlerArg argument = new ViewerEffectEventHandlerArg();
  4790. argument.AgentID = viewer.Effect[i].AgentID;
  4791. argument.Color = viewer.Effect[i].Color;
  4792. argument.Duration = viewer.Effect[i].Duration;
  4793. argument.ID = viewer.Effect[i].ID;
  4794. argument.Type = viewer.Effect[i].Type;
  4795. argument.TypeData = viewer.Effect[i].TypeData;
  4796. args.Add(argument);
  4797. }
  4798. handlerViewerEffect(sender, args);
  4799. }
  4800. return true;
  4801. }
  4802. private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack)
  4803. {
  4804. AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
  4805. #region Packet Session and User Check
  4806. if (m_checkPackets)
  4807. {
  4808. if (avatarProperties.AgentData.SessionID != SessionId ||
  4809. avatarProperties.AgentData.AgentID != AgentId)
  4810. return true;
  4811. }
  4812. #endregion
  4813. RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties;
  4814. if (handlerRequestAvatarProperties != null)
  4815. {
  4816. handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
  4817. }
  4818. return true;
  4819. }
  4820. private bool HandleChatFromViewer(IClientAPI sender, Packet Pack)
  4821. {
  4822. ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
  4823. #region Packet Session and User Check
  4824. if (m_checkPackets)
  4825. {
  4826. if (inchatpack.AgentData.SessionID != SessionId ||
  4827. inchatpack.AgentData.AgentID != AgentId)
  4828. return true;
  4829. }
  4830. #endregion
  4831. string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
  4832. byte[] message = inchatpack.ChatData.Message;
  4833. byte type = inchatpack.ChatData.Type;
  4834. Vector3 fromPos = new Vector3(); // ClientAvatar.Pos;
  4835. // UUID fromAgentID = AgentId;
  4836. int channel = inchatpack.ChatData.Channel;
  4837. if (OnChatFromClient != null)
  4838. {
  4839. OSChatMessage args = new OSChatMessage();
  4840. args.Channel = channel;
  4841. args.From = fromName;
  4842. args.Message = Utils.BytesToString(message);
  4843. args.Type = (ChatTypeEnum)type;
  4844. args.Position = fromPos;
  4845. args.Scene = Scene;
  4846. args.Sender = this;
  4847. args.SenderUUID = this.AgentId;
  4848. ChatMessage handlerChatFromClient = OnChatFromClient;
  4849. if (handlerChatFromClient != null)
  4850. handlerChatFromClient(this, args);
  4851. }
  4852. return true;
  4853. }
  4854. private bool HandlerAvatarPropertiesUpdate(IClientAPI sender, Packet Pack)
  4855. {
  4856. AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
  4857. #region Packet Session and User Check
  4858. if (m_checkPackets)
  4859. {
  4860. if (avatarProps.AgentData.SessionID != SessionId ||
  4861. avatarProps.AgentData.AgentID != AgentId)
  4862. return true;
  4863. }
  4864. #endregion
  4865. UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
  4866. if (handlerUpdateAvatarProperties != null)
  4867. {
  4868. AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData;
  4869. UserProfileData UserProfile = new UserProfileData();
  4870. UserProfile.ID = AgentId;
  4871. UserProfile.AboutText = Utils.BytesToString(Properties.AboutText);
  4872. UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
  4873. UserProfile.FirstLifeImage = Properties.FLImageID;
  4874. UserProfile.Image = Properties.ImageID;
  4875. UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
  4876. UserProfile.UserFlags &= ~3;
  4877. UserProfile.UserFlags |= Properties.AllowPublish ? 1 : 0;
  4878. UserProfile.UserFlags |= Properties.MaturePublish ? 2 : 0;
  4879. handlerUpdateAvatarProperties(this, UserProfile);
  4880. }
  4881. return true;
  4882. }
  4883. private bool HandlerScriptDialogReply(IClientAPI sender, Packet Pack)
  4884. {
  4885. ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
  4886. //m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID);
  4887. #region Packet Session and User Check
  4888. if (m_checkPackets)
  4889. {
  4890. if (rdialog.AgentData.SessionID != SessionId ||
  4891. rdialog.AgentData.AgentID != AgentId)
  4892. return true;
  4893. }
  4894. #endregion
  4895. int ch = rdialog.Data.ChatChannel;
  4896. byte[] msg = rdialog.Data.ButtonLabel;
  4897. if (OnChatFromClient != null)
  4898. {
  4899. OSChatMessage args = new OSChatMessage();
  4900. args.Channel = ch;
  4901. args.From = String.Empty;
  4902. args.Message = Utils.BytesToString(msg);
  4903. args.Type = ChatTypeEnum.Shout;
  4904. args.Position = new Vector3();
  4905. args.Scene = Scene;
  4906. args.Sender = this;
  4907. ChatMessage handlerChatFromClient2 = OnChatFromClient;
  4908. if (handlerChatFromClient2 != null)
  4909. handlerChatFromClient2(this, args);
  4910. }
  4911. return true;
  4912. }
  4913. private bool HandlerImprovedInstantMessage(IClientAPI sender, Packet Pack)
  4914. {
  4915. ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
  4916. #region Packet Session and User Check
  4917. if (m_checkPackets)
  4918. {
  4919. if (msgpack.AgentData.SessionID != SessionId ||
  4920. msgpack.AgentData.AgentID != AgentId)
  4921. return true;
  4922. }
  4923. #endregion
  4924. string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
  4925. string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message);
  4926. ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
  4927. if (handlerInstantMessage != null)
  4928. {
  4929. GridInstantMessage im = new GridInstantMessage(Scene,
  4930. msgpack.AgentData.AgentID,
  4931. IMfromName,
  4932. msgpack.MessageBlock.ToAgentID,
  4933. msgpack.MessageBlock.Dialog,
  4934. msgpack.MessageBlock.FromGroup,
  4935. IMmessage,
  4936. msgpack.MessageBlock.ID,
  4937. msgpack.MessageBlock.Offline != 0 ? true : false,
  4938. msgpack.MessageBlock.Position,
  4939. msgpack.MessageBlock.BinaryBucket);
  4940. handlerInstantMessage(this, im);
  4941. }
  4942. return true;
  4943. }
  4944. private bool HandlerAcceptFriendship(IClientAPI sender, Packet Pack)
  4945. {
  4946. AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack;
  4947. #region Packet Session and User Check
  4948. if (m_checkPackets)
  4949. {
  4950. if (afriendpack.AgentData.SessionID != SessionId ||
  4951. afriendpack.AgentData.AgentID != AgentId)
  4952. return true;
  4953. }
  4954. #endregion
  4955. // My guess is this is the folder to stick the calling card into
  4956. List<UUID> callingCardFolders = new List<UUID>();
  4957. UUID agentID = afriendpack.AgentData.AgentID;
  4958. UUID transactionID = afriendpack.TransactionBlock.TransactionID;
  4959. for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
  4960. {
  4961. callingCardFolders.Add(afriendpack.FolderData[fi].FolderID);
  4962. }
  4963. FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest;
  4964. if (handlerApproveFriendRequest != null)
  4965. {
  4966. handlerApproveFriendRequest(this, agentID, transactionID, callingCardFolders);
  4967. }
  4968. return true;
  4969. }
  4970. private bool HandlerDeclineFriendship(IClientAPI sender, Packet Pack)
  4971. {
  4972. DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack;
  4973. #region Packet Session and User Check
  4974. if (m_checkPackets)
  4975. {
  4976. if (dfriendpack.AgentData.SessionID != SessionId ||
  4977. dfriendpack.AgentData.AgentID != AgentId)
  4978. return true;
  4979. }
  4980. #endregion
  4981. if (OnDenyFriendRequest != null)
  4982. {
  4983. OnDenyFriendRequest(this,
  4984. dfriendpack.AgentData.AgentID,
  4985. dfriendpack.TransactionBlock.TransactionID,
  4986. null);
  4987. }
  4988. return true;
  4989. }
  4990. private bool HandlerTerminateFrendship(IClientAPI sender, Packet Pack)
  4991. {
  4992. TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
  4993. #region Packet Session and User Check
  4994. if (m_checkPackets)
  4995. {
  4996. if (tfriendpack.AgentData.SessionID != SessionId ||
  4997. tfriendpack.AgentData.AgentID != AgentId)
  4998. return true;
  4999. }
  5000. #endregion
  5001. UUID listOwnerAgentID = tfriendpack.AgentData.AgentID;
  5002. UUID exFriendID = tfriendpack.ExBlock.OtherID;
  5003. FriendshipTermination handlerTerminateFriendship = OnTerminateFriendship;
  5004. if (handlerTerminateFriendship != null)
  5005. {
  5006. handlerTerminateFriendship(this, listOwnerAgentID, exFriendID);
  5007. }
  5008. return true;
  5009. }
  5010. private bool HandleFindAgent(IClientAPI client, Packet Packet)
  5011. {
  5012. FindAgentPacket FindAgent =
  5013. (FindAgentPacket)Packet;
  5014. FindAgentUpdate FindAgentHandler = OnFindAgent;
  5015. if (FindAgentHandler != null)
  5016. {
  5017. FindAgentHandler(this,FindAgent.AgentBlock.Hunter,FindAgent.AgentBlock.Prey);
  5018. return true;
  5019. }
  5020. return false;
  5021. }
  5022. private bool HandleTrackAgent(IClientAPI client, Packet Packet)
  5023. {
  5024. TrackAgentPacket TrackAgent =
  5025. (TrackAgentPacket)Packet;
  5026. TrackAgentUpdate TrackAgentHandler = OnTrackAgent;
  5027. if (TrackAgentHandler != null)
  5028. {
  5029. TrackAgentHandler(this,
  5030. TrackAgent.AgentData.AgentID,
  5031. TrackAgent.TargetData.PreyID);
  5032. return true;
  5033. }
  5034. return false;
  5035. }
  5036. private bool HandlerRezObject(IClientAPI sender, Packet Pack)
  5037. {
  5038. RezObjectPacket rezPacket = (RezObjectPacket)Pack;
  5039. #region Packet Session and User Check
  5040. if (m_checkPackets)
  5041. {
  5042. if (rezPacket.AgentData.SessionID != SessionId ||
  5043. rezPacket.AgentData.AgentID != AgentId)
  5044. return true;
  5045. }
  5046. #endregion
  5047. RezObject handlerRezObject = OnRezObject;
  5048. if (handlerRezObject != null)
  5049. {
  5050. handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd,
  5051. rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID,
  5052. rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection,
  5053. rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem,
  5054. rezPacket.RezData.FromTaskID);
  5055. }
  5056. return true;
  5057. }
  5058. private bool HandlerDeRezObject(IClientAPI sender, Packet Pack)
  5059. {
  5060. DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack;
  5061. #region Packet Session and User Check
  5062. if (m_checkPackets)
  5063. {
  5064. if (DeRezPacket.AgentData.SessionID != SessionId ||
  5065. DeRezPacket.AgentData.AgentID != AgentId)
  5066. return true;
  5067. }
  5068. #endregion
  5069. DeRezObject handlerDeRezObject = OnDeRezObject;
  5070. if (handlerDeRezObject != null)
  5071. {
  5072. List<uint> deRezIDs = new List<uint>();
  5073. foreach (DeRezObjectPacket.ObjectDataBlock data in
  5074. DeRezPacket.ObjectData)
  5075. {
  5076. deRezIDs.Add(data.ObjectLocalID);
  5077. }
  5078. // It just so happens that the values on the DeRezAction enumerator match the Destination
  5079. // values given by a Second Life client
  5080. handlerDeRezObject(this, deRezIDs,
  5081. DeRezPacket.AgentBlock.GroupID,
  5082. (DeRezAction)DeRezPacket.AgentBlock.Destination,
  5083. DeRezPacket.AgentBlock.DestinationID);
  5084. }
  5085. return true;
  5086. }
  5087. private bool HandlerModifyLand(IClientAPI sender, Packet Pack)
  5088. {
  5089. ModifyLandPacket modify = (ModifyLandPacket)Pack;
  5090. #region Packet Session and User Check
  5091. if (m_checkPackets)
  5092. {
  5093. if (modify.AgentData.SessionID != SessionId ||
  5094. modify.AgentData.AgentID != AgentId)
  5095. return true;
  5096. }
  5097. #endregion
  5098. //m_log.Info("[LAND]: LAND:" + modify.ToString());
  5099. if (modify.ParcelData.Length > 0)
  5100. {
  5101. if (OnModifyTerrain != null)
  5102. {
  5103. for (int i = 0; i < modify.ParcelData.Length; i++)
  5104. {
  5105. ModifyTerrain handlerModifyTerrain = OnModifyTerrain;
  5106. if (handlerModifyTerrain != null)
  5107. {
  5108. handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
  5109. modify.ModifyBlock.BrushSize,
  5110. modify.ModifyBlock.Action, modify.ParcelData[i].North,
  5111. modify.ParcelData[i].West, modify.ParcelData[i].South,
  5112. modify.ParcelData[i].East, AgentId);
  5113. }
  5114. }
  5115. }
  5116. }
  5117. return true;
  5118. }
  5119. private bool HandlerRegionHandshakeReply(IClientAPI sender, Packet Pack)
  5120. {
  5121. Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply;
  5122. if (handlerRegionHandShakeReply != null)
  5123. {
  5124. handlerRegionHandShakeReply(this);
  5125. }
  5126. return true;
  5127. }
  5128. private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
  5129. {
  5130. GenericCall1 handlerRequestWearables = OnRequestWearables;
  5131. if (handlerRequestWearables != null)
  5132. {
  5133. handlerRequestWearables(sender);
  5134. }
  5135. Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
  5136. if (handlerRequestAvatarsData != null)
  5137. {
  5138. handlerRequestAvatarsData(this);
  5139. }
  5140. return true;
  5141. }
  5142. private bool HandlerAgentSetAppearance(IClientAPI sender, Packet Pack)
  5143. {
  5144. AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
  5145. #region Packet Session and User Check
  5146. if (m_checkPackets)
  5147. {
  5148. if (appear.AgentData.SessionID != SessionId ||
  5149. appear.AgentData.AgentID != AgentId)
  5150. return true;
  5151. }
  5152. #endregion
  5153. SetAppearance handlerSetAppearance = OnSetAppearance;
  5154. if (handlerSetAppearance != null)
  5155. {
  5156. // Temporarily protect ourselves from the mantis #951 failure.
  5157. // However, we could do this for several other handlers where a failure isn't terminal
  5158. // for the client session anyway, in order to protect ourselves against bad code in plugins
  5159. try
  5160. {
  5161. byte[] visualparams = new byte[appear.VisualParam.Length];
  5162. for (int i = 0; i < appear.VisualParam.Length; i++)
  5163. visualparams[i] = appear.VisualParam[i].ParamValue;
  5164. Primitive.TextureEntry te = null;
  5165. if (appear.ObjectData.TextureEntry.Length > 1)
  5166. te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
  5167. handlerSetAppearance(sender, te, visualparams);
  5168. }
  5169. catch (Exception e)
  5170. {
  5171. m_log.ErrorFormat(
  5172. "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}",
  5173. e);
  5174. }
  5175. }
  5176. return true;
  5177. }
  5178. private bool HandlerAgentIsNowWearing(IClientAPI sender, Packet Pack)
  5179. {
  5180. if (OnAvatarNowWearing != null)
  5181. {
  5182. AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack;
  5183. #region Packet Session and User Check
  5184. if (m_checkPackets)
  5185. {
  5186. if (nowWearing.AgentData.SessionID != SessionId ||
  5187. nowWearing.AgentData.AgentID != AgentId)
  5188. return true;
  5189. }
  5190. #endregion
  5191. AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
  5192. for (int i = 0; i < nowWearing.WearableData.Length; i++)
  5193. {
  5194. //m_log.DebugFormat("[XXX]: Wearable type {0} item {1}", nowWearing.WearableData[i].WearableType, nowWearing.WearableData[i].ItemID);
  5195. AvatarWearingArgs.Wearable wearable =
  5196. new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
  5197. nowWearing.WearableData[i].WearableType);
  5198. wearingArgs.NowWearing.Add(wearable);
  5199. }
  5200. AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing;
  5201. if (handlerAvatarNowWearing != null)
  5202. {
  5203. handlerAvatarNowWearing(this, wearingArgs);
  5204. }
  5205. }
  5206. return true;
  5207. }
  5208. private bool HandlerRezSingleAttachmentFromInv(IClientAPI sender, Packet Pack)
  5209. {
  5210. RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
  5211. if (handlerRezSingleAttachment != null)
  5212. {
  5213. RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack;
  5214. #region Packet Session and User Check
  5215. if (m_checkPackets)
  5216. {
  5217. if (rez.AgentData.SessionID != SessionId ||
  5218. rez.AgentData.AgentID != AgentId)
  5219. return true;
  5220. }
  5221. #endregion
  5222. handlerRezSingleAttachment(this, rez.ObjectData.ItemID,
  5223. rez.ObjectData.AttachmentPt);
  5224. }
  5225. return true;
  5226. }
  5227. private bool HandleRezMultipleAttachmentsFromInv(IClientAPI sender, Packet Pack)
  5228. {
  5229. RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv;
  5230. if (handlerRezMultipleAttachments != null)
  5231. {
  5232. RezMultipleAttachmentsFromInvPacket rez = (RezMultipleAttachmentsFromInvPacket)Pack;
  5233. handlerRezMultipleAttachments(this, rez.HeaderData,
  5234. rez.ObjectData);
  5235. }
  5236. return true;
  5237. }
  5238. private bool HandleDetachAttachmentIntoInv(IClientAPI sender, Packet Pack)
  5239. {
  5240. UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
  5241. if (handlerDetachAttachmentIntoInv != null)
  5242. {
  5243. DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack;
  5244. #region Packet Session and User Check
  5245. // UNSUPPORTED ON THIS PACKET
  5246. #endregion
  5247. UUID itemID = detachtoInv.ObjectData.ItemID;
  5248. // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID;
  5249. handlerDetachAttachmentIntoInv(itemID, this);
  5250. }
  5251. return true;
  5252. }
  5253. private bool HandleObjectAttach(IClientAPI sender, Packet Pack)
  5254. {
  5255. if (OnObjectAttach != null)
  5256. {
  5257. ObjectAttachPacket att = (ObjectAttachPacket)Pack;
  5258. #region Packet Session and User Check
  5259. if (m_checkPackets)
  5260. {
  5261. if (att.AgentData.SessionID != SessionId ||
  5262. att.AgentData.AgentID != AgentId)
  5263. return true;
  5264. }
  5265. #endregion
  5266. ObjectAttach handlerObjectAttach = OnObjectAttach;
  5267. if (handlerObjectAttach != null)
  5268. {
  5269. if (att.ObjectData.Length > 0)
  5270. {
  5271. handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false);
  5272. }
  5273. }
  5274. }
  5275. return true;
  5276. }
  5277. private bool HandleObjectDetach(IClientAPI sender, Packet Pack)
  5278. {
  5279. ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
  5280. #region Packet Session and User Check
  5281. if (m_checkPackets)
  5282. {
  5283. if (dett.AgentData.SessionID != SessionId ||
  5284. dett.AgentData.AgentID != AgentId)
  5285. return true;
  5286. }
  5287. #endregion
  5288. for (int j = 0; j < dett.ObjectData.Length; j++)
  5289. {
  5290. uint obj = dett.ObjectData[j].ObjectLocalID;
  5291. ObjectDeselect handlerObjectDetach = OnObjectDetach;
  5292. if (handlerObjectDetach != null)
  5293. {
  5294. handlerObjectDetach(obj, this);
  5295. }
  5296. }
  5297. return true;
  5298. }
  5299. private bool HandleObjectDrop(IClientAPI sender, Packet Pack)
  5300. {
  5301. ObjectDropPacket dropp = (ObjectDropPacket)Pack;
  5302. #region Packet Session and User Check
  5303. if (m_checkPackets)
  5304. {
  5305. if (dropp.AgentData.SessionID != SessionId ||
  5306. dropp.AgentData.AgentID != AgentId)
  5307. return true;
  5308. }
  5309. #endregion
  5310. for (int j = 0; j < dropp.ObjectData.Length; j++)
  5311. {
  5312. uint obj = dropp.ObjectData[j].ObjectLocalID;
  5313. ObjectDrop handlerObjectDrop = OnObjectDrop;
  5314. if (handlerObjectDrop != null)
  5315. {
  5316. handlerObjectDrop(obj, this);
  5317. }
  5318. }
  5319. return true;
  5320. }
  5321. private bool HandleSetAlwaysRun(IClientAPI sender, Packet Pack)
  5322. {
  5323. SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
  5324. #region Packet Session and User Check
  5325. if (m_checkPackets)
  5326. {
  5327. if (run.AgentData.SessionID != SessionId ||
  5328. run.AgentData.AgentID != AgentId)
  5329. return true;
  5330. }
  5331. #endregion
  5332. SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun;
  5333. if (handlerSetAlwaysRun != null)
  5334. handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
  5335. return true;
  5336. }
  5337. private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
  5338. {
  5339. Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
  5340. if (handlerCompleteMovementToRegion != null)
  5341. {
  5342. handlerCompleteMovementToRegion(sender, true);
  5343. }
  5344. handlerCompleteMovementToRegion = null;
  5345. return true;
  5346. }
  5347. private bool HandleAgentAnimation(IClientAPI sender, Packet Pack)
  5348. {
  5349. AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
  5350. #region Packet Session and User Check
  5351. if (m_checkPackets)
  5352. {
  5353. if (AgentAni.AgentData.SessionID != SessionId ||
  5354. AgentAni.AgentData.AgentID != AgentId)
  5355. return true;
  5356. }
  5357. #endregion
  5358. StartAnim handlerStartAnim = null;
  5359. StopAnim handlerStopAnim = null;
  5360. for (int i = 0; i < AgentAni.AnimationList.Length; i++)
  5361. {
  5362. if (AgentAni.AnimationList[i].StartAnim)
  5363. {
  5364. handlerStartAnim = OnStartAnim;
  5365. if (handlerStartAnim != null)
  5366. {
  5367. handlerStartAnim(this, AgentAni.AnimationList[i].AnimID);
  5368. }
  5369. }
  5370. else
  5371. {
  5372. handlerStopAnim = OnStopAnim;
  5373. if (handlerStopAnim != null)
  5374. {
  5375. handlerStopAnim(this, AgentAni.AnimationList[i].AnimID);
  5376. }
  5377. }
  5378. }
  5379. return true;
  5380. }
  5381. private bool HandleAgentRequestSit(IClientAPI sender, Packet Pack)
  5382. {
  5383. if (OnAgentRequestSit != null)
  5384. {
  5385. AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack;
  5386. #region Packet Session and User Check
  5387. if (m_checkPackets)
  5388. {
  5389. if (agentRequestSit.AgentData.SessionID != SessionId ||
  5390. agentRequestSit.AgentData.AgentID != AgentId)
  5391. return true;
  5392. }
  5393. #endregion
  5394. AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
  5395. if (handlerAgentRequestSit != null)
  5396. handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
  5397. agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
  5398. }
  5399. return true;
  5400. }
  5401. private bool HandleAgentSit(IClientAPI sender, Packet Pack)
  5402. {
  5403. if (OnAgentSit != null)
  5404. {
  5405. AgentSitPacket agentSit = (AgentSitPacket)Pack;
  5406. #region Packet Session and User Check
  5407. if (m_checkPackets)
  5408. {
  5409. if (agentSit.AgentData.SessionID != SessionId ||
  5410. agentSit.AgentData.AgentID != AgentId)
  5411. return true;
  5412. }
  5413. #endregion
  5414. AgentSit handlerAgentSit = OnAgentSit;
  5415. if (handlerAgentSit != null)
  5416. {
  5417. OnAgentSit(this, agentSit.AgentData.AgentID);
  5418. }
  5419. }
  5420. return true;
  5421. }
  5422. private bool HandleSoundTrigger(IClientAPI sender, Packet Pack)
  5423. {
  5424. SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
  5425. #region Packet Session and User Check
  5426. if (m_checkPackets)
  5427. {
  5428. // UNSUPPORTED ON THIS PACKET
  5429. }
  5430. #endregion
  5431. SoundTrigger handlerSoundTrigger = OnSoundTrigger;
  5432. if (handlerSoundTrigger != null)
  5433. {
  5434. // UUIDS are sent as zeroes by the client, substitute agent's id
  5435. handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, AgentId,
  5436. AgentId, AgentId,
  5437. soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position,
  5438. soundTriggerPacket.SoundData.Handle, 0);
  5439. }
  5440. return true;
  5441. }
  5442. private bool HandleAvatarPickerRequest(IClientAPI sender, Packet Pack)
  5443. {
  5444. AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
  5445. #region Packet Session and User Check
  5446. if (m_checkPackets)
  5447. {
  5448. if (avRequestQuery.AgentData.SessionID != SessionId ||
  5449. avRequestQuery.AgentData.AgentID != AgentId)
  5450. return true;
  5451. }
  5452. #endregion
  5453. AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
  5454. AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
  5455. //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name));
  5456. AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest;
  5457. if (handlerAvatarPickerRequest != null)
  5458. {
  5459. handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
  5460. Utils.BytesToString(querydata.Name));
  5461. }
  5462. return true;
  5463. }
  5464. private bool HandleAgentDataUpdateRequest(IClientAPI sender, Packet Pack)
  5465. {
  5466. AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
  5467. #region Packet Session and User Check
  5468. if (m_checkPackets)
  5469. {
  5470. if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId ||
  5471. avRequestDataUpdatePacket.AgentData.AgentID != AgentId)
  5472. return true;
  5473. }
  5474. #endregion
  5475. FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest;
  5476. if (handlerAgentDataUpdateRequest != null)
  5477. {
  5478. handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID);
  5479. }
  5480. return true;
  5481. }
  5482. private bool HandleUserInfoRequest(IClientAPI sender, Packet Pack)
  5483. {
  5484. UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest;
  5485. if (handlerUserInfoRequest != null)
  5486. {
  5487. handlerUserInfoRequest(this);
  5488. }
  5489. else
  5490. {
  5491. SendUserInfoReply(false, true, "");
  5492. }
  5493. return true;
  5494. }
  5495. private bool HandleUpdateUserInfo(IClientAPI sender, Packet Pack)
  5496. {
  5497. UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack;
  5498. #region Packet Session and User Check
  5499. if (m_checkPackets)
  5500. {
  5501. if (updateUserInfo.AgentData.SessionID != SessionId ||
  5502. updateUserInfo.AgentData.AgentID != AgentId)
  5503. return true;
  5504. }
  5505. #endregion
  5506. UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo;
  5507. if (handlerUpdateUserInfo != null)
  5508. {
  5509. bool visible = true;
  5510. string DirectoryVisibility =
  5511. Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility);
  5512. if (DirectoryVisibility == "hidden")
  5513. visible = false;
  5514. handlerUpdateUserInfo(
  5515. updateUserInfo.UserData.IMViaEMail,
  5516. visible, this);
  5517. }
  5518. return true;
  5519. }
  5520. private bool HandleSetStartLocationRequest(IClientAPI sender, Packet Pack)
  5521. {
  5522. SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack;
  5523. #region Packet Session and User Check
  5524. if (m_checkPackets)
  5525. {
  5526. if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId ||
  5527. avSetStartLocationRequestPacket.AgentData.AgentID != AgentId)
  5528. return true;
  5529. }
  5530. #endregion
  5531. if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
  5532. {
  5533. // Linden Client limitation..
  5534. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f
  5535. || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5536. {
  5537. ScenePresence avatar = null;
  5538. if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
  5539. {
  5540. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
  5541. {
  5542. avSetStartLocationRequestPacket.StartLocationData.LocationPos.X = avatar.AbsolutePosition.X;
  5543. }
  5544. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5545. {
  5546. avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y = avatar.AbsolutePosition.Y;
  5547. }
  5548. }
  5549. }
  5550. TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest;
  5551. if (handlerSetStartLocationRequest != null)
  5552. {
  5553. handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos,
  5554. avSetStartLocationRequestPacket.StartLocationData.LocationLookAt,
  5555. avSetStartLocationRequestPacket.StartLocationData.LocationID);
  5556. }
  5557. }
  5558. return true;
  5559. }
  5560. private bool HandleAgentThrottle(IClientAPI sender, Packet Pack)
  5561. {
  5562. AgentThrottlePacket atpack = (AgentThrottlePacket)Pack;
  5563. #region Packet Session and User Check
  5564. if (m_checkPackets)
  5565. {
  5566. if (atpack.AgentData.SessionID != SessionId ||
  5567. atpack.AgentData.AgentID != AgentId)
  5568. return true;
  5569. }
  5570. #endregion
  5571. m_udpClient.SetThrottles(atpack.Throttle.Throttles);
  5572. return true;
  5573. }
  5574. private bool HandleAgentPause(IClientAPI sender, Packet Pack)
  5575. {
  5576. m_udpClient.IsPaused = true;
  5577. return true;
  5578. }
  5579. private bool HandleAgentResume(IClientAPI sender, Packet Pack)
  5580. {
  5581. m_udpClient.IsPaused = false;
  5582. SendStartPingCheck(m_udpClient.CurrentPingSequence++);
  5583. return true;
  5584. }
  5585. private bool HandleForceScriptControlRelease(IClientAPI sender, Packet Pack)
  5586. {
  5587. ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls;
  5588. if (handlerForceReleaseControls != null)
  5589. {
  5590. handlerForceReleaseControls(this, AgentId);
  5591. }
  5592. return true;
  5593. }
  5594. #endregion Scene/Avatar
  5595. #region Objects/m_sceneObjects
  5596. private bool HandleObjectLink(IClientAPI sender, Packet Pack)
  5597. {
  5598. ObjectLinkPacket link = (ObjectLinkPacket)Pack;
  5599. #region Packet Session and User Check
  5600. if (m_checkPackets)
  5601. {
  5602. if (link.AgentData.SessionID != SessionId ||
  5603. link.AgentData.AgentID != AgentId)
  5604. return true;
  5605. }
  5606. #endregion
  5607. uint parentprimid = 0;
  5608. List<uint> childrenprims = new List<uint>();
  5609. if (link.ObjectData.Length > 1)
  5610. {
  5611. parentprimid = link.ObjectData[0].ObjectLocalID;
  5612. for (int i = 1; i < link.ObjectData.Length; i++)
  5613. {
  5614. childrenprims.Add(link.ObjectData[i].ObjectLocalID);
  5615. }
  5616. }
  5617. LinkObjects handlerLinkObjects = OnLinkObjects;
  5618. if (handlerLinkObjects != null)
  5619. {
  5620. handlerLinkObjects(this, parentprimid, childrenprims);
  5621. }
  5622. return true;
  5623. }
  5624. private bool HandleObjectDelink(IClientAPI sender, Packet Pack)
  5625. {
  5626. ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack;
  5627. #region Packet Session and User Check
  5628. if (m_checkPackets)
  5629. {
  5630. if (delink.AgentData.SessionID != SessionId ||
  5631. delink.AgentData.AgentID != AgentId)
  5632. return true;
  5633. }
  5634. #endregion
  5635. // It appears the prim at index 0 is not always the root prim (for
  5636. // instance, when one prim of a link set has been edited independently
  5637. // of the others). Therefore, we'll pass all the ids onto the delink
  5638. // method for it to decide which is the root.
  5639. List<uint> prims = new List<uint>();
  5640. for (int i = 0; i < delink.ObjectData.Length; i++)
  5641. {
  5642. prims.Add(delink.ObjectData[i].ObjectLocalID);
  5643. }
  5644. DelinkObjects handlerDelinkObjects = OnDelinkObjects;
  5645. if (handlerDelinkObjects != null)
  5646. {
  5647. handlerDelinkObjects(prims, this);
  5648. }
  5649. return true;
  5650. }
  5651. private bool HandleObjectAdd(IClientAPI sender, Packet Pack)
  5652. {
  5653. if (OnAddPrim != null)
  5654. {
  5655. ObjectAddPacket addPacket = (ObjectAddPacket)Pack;
  5656. #region Packet Session and User Check
  5657. if (m_checkPackets)
  5658. {
  5659. if (addPacket.AgentData.SessionID != SessionId ||
  5660. addPacket.AgentData.AgentID != AgentId)
  5661. return true;
  5662. }
  5663. #endregion
  5664. PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
  5665. // m_log.Info("[REZData]: " + addPacket.ToString());
  5666. //BypassRaycast: 1
  5667. //RayStart: <69.79469, 158.2652, 98.40343>
  5668. //RayEnd: <61.97724, 141.995, 92.58341>
  5669. //RayTargetID: 00000000-0000-0000-0000-000000000000
  5670. //Check to see if adding the prim is allowed; useful for any module wanting to restrict the
  5671. //object from rezing initially
  5672. AddNewPrim handlerAddPrim = OnAddPrim;
  5673. if (handlerAddPrim != null)
  5674. handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);
  5675. }
  5676. return true;
  5677. }
  5678. private bool HandleObjectShape(IClientAPI sender, Packet Pack)
  5679. {
  5680. ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
  5681. #region Packet Session and User Check
  5682. if (m_checkPackets)
  5683. {
  5684. if (shapePacket.AgentData.SessionID != SessionId ||
  5685. shapePacket.AgentData.AgentID != AgentId)
  5686. return true;
  5687. }
  5688. #endregion
  5689. UpdateShape handlerUpdatePrimShape = null;
  5690. for (int i = 0; i < shapePacket.ObjectData.Length; i++)
  5691. {
  5692. handlerUpdatePrimShape = OnUpdatePrimShape;
  5693. if (handlerUpdatePrimShape != null)
  5694. {
  5695. UpdateShapeArgs shapeData = new UpdateShapeArgs();
  5696. shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID;
  5697. shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin;
  5698. shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve;
  5699. shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd;
  5700. shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset;
  5701. shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions;
  5702. shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX;
  5703. shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY;
  5704. shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX;
  5705. shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY;
  5706. shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew;
  5707. shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX;
  5708. shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY;
  5709. shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist;
  5710. shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin;
  5711. shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin;
  5712. shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve;
  5713. shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd;
  5714. shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow;
  5715. handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
  5716. shapeData);
  5717. }
  5718. }
  5719. return true;
  5720. }
  5721. private bool HandleObjectExtraParams(IClientAPI sender, Packet Pack)
  5722. {
  5723. ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack;
  5724. #region Packet Session and User Check
  5725. if (m_checkPackets)
  5726. {
  5727. if (extraPar.AgentData.SessionID != SessionId ||
  5728. extraPar.AgentData.AgentID != AgentId)
  5729. return true;
  5730. }
  5731. #endregion
  5732. ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams;
  5733. if (handlerUpdateExtraParams != null)
  5734. {
  5735. for (int i = 0; i < extraPar.ObjectData.Length; i++)
  5736. {
  5737. handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID,
  5738. extraPar.ObjectData[i].ParamType,
  5739. extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData);
  5740. }
  5741. }
  5742. return true;
  5743. }
  5744. private bool HandleObjectDuplicate(IClientAPI sender, Packet Pack)
  5745. {
  5746. ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
  5747. #region Packet Session and User Check
  5748. if (m_checkPackets)
  5749. {
  5750. if (dupe.AgentData.SessionID != SessionId ||
  5751. dupe.AgentData.AgentID != AgentId)
  5752. return true;
  5753. }
  5754. #endregion
  5755. // ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData;
  5756. ObjectDuplicate handlerObjectDuplicate = null;
  5757. for (int i = 0; i < dupe.ObjectData.Length; i++)
  5758. {
  5759. handlerObjectDuplicate = OnObjectDuplicate;
  5760. if (handlerObjectDuplicate != null)
  5761. {
  5762. handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
  5763. dupe.SharedData.DuplicateFlags, AgentId,
  5764. m_activeGroupID);
  5765. }
  5766. }
  5767. return true;
  5768. }
  5769. private bool HandleRequestMultipleObjects(IClientAPI sender, Packet Pack)
  5770. {
  5771. RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack;
  5772. #region Packet Session and User Check
  5773. if (m_checkPackets)
  5774. {
  5775. if (incomingRequest.AgentData.SessionID != SessionId ||
  5776. incomingRequest.AgentData.AgentID != AgentId)
  5777. return true;
  5778. }
  5779. #endregion
  5780. ObjectRequest handlerObjectRequest = null;
  5781. for (int i = 0; i < incomingRequest.ObjectData.Length; i++)
  5782. {
  5783. handlerObjectRequest = OnObjectRequest;
  5784. if (handlerObjectRequest != null)
  5785. {
  5786. handlerObjectRequest(incomingRequest.ObjectData[i].ID, this);
  5787. }
  5788. }
  5789. return true;
  5790. }
  5791. private bool HandleObjectSelect(IClientAPI sender, Packet Pack)
  5792. {
  5793. ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
  5794. #region Packet Session and User Check
  5795. if (m_checkPackets)
  5796. {
  5797. if (incomingselect.AgentData.SessionID != SessionId ||
  5798. incomingselect.AgentData.AgentID != AgentId)
  5799. return true;
  5800. }
  5801. #endregion
  5802. ObjectSelect handlerObjectSelect = null;
  5803. for (int i = 0; i < incomingselect.ObjectData.Length; i++)
  5804. {
  5805. handlerObjectSelect = OnObjectSelect;
  5806. if (handlerObjectSelect != null)
  5807. {
  5808. handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
  5809. }
  5810. }
  5811. return true;
  5812. }
  5813. private bool HandleObjectDeselect(IClientAPI sender, Packet Pack)
  5814. {
  5815. ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
  5816. #region Packet Session and User Check
  5817. if (m_checkPackets)
  5818. {
  5819. if (incomingdeselect.AgentData.SessionID != SessionId ||
  5820. incomingdeselect.AgentData.AgentID != AgentId)
  5821. return true;
  5822. }
  5823. #endregion
  5824. ObjectDeselect handlerObjectDeselect = null;
  5825. for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
  5826. {
  5827. handlerObjectDeselect = OnObjectDeselect;
  5828. if (handlerObjectDeselect != null)
  5829. {
  5830. OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this);
  5831. }
  5832. }
  5833. return true;
  5834. }
  5835. private bool HandleObjectPosition(IClientAPI sender, Packet Pack)
  5836. {
  5837. // DEPRECATED: but till libsecondlife removes it, people will use it
  5838. ObjectPositionPacket position = (ObjectPositionPacket)Pack;
  5839. #region Packet Session and User Check
  5840. if (m_checkPackets)
  5841. {
  5842. if (position.AgentData.SessionID != SessionId ||
  5843. position.AgentData.AgentID != AgentId)
  5844. return true;
  5845. }
  5846. #endregion
  5847. for (int i = 0; i < position.ObjectData.Length; i++)
  5848. {
  5849. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  5850. if (handlerUpdateVector != null)
  5851. handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this);
  5852. }
  5853. return true;
  5854. }
  5855. private bool HandleObjectScale(IClientAPI sender, Packet Pack)
  5856. {
  5857. // DEPRECATED: but till libsecondlife removes it, people will use it
  5858. ObjectScalePacket scale = (ObjectScalePacket)Pack;
  5859. #region Packet Session and User Check
  5860. if (m_checkPackets)
  5861. {
  5862. if (scale.AgentData.SessionID != SessionId ||
  5863. scale.AgentData.AgentID != AgentId)
  5864. return true;
  5865. }
  5866. #endregion
  5867. for (int i = 0; i < scale.ObjectData.Length; i++)
  5868. {
  5869. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  5870. if (handlerUpdatePrimGroupScale != null)
  5871. handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this);
  5872. }
  5873. return true;
  5874. }
  5875. private bool HandleObjectRotation(IClientAPI sender, Packet Pack)
  5876. {
  5877. // DEPRECATED: but till libsecondlife removes it, people will use it
  5878. ObjectRotationPacket rotation = (ObjectRotationPacket)Pack;
  5879. #region Packet Session and User Check
  5880. if (m_checkPackets)
  5881. {
  5882. if (rotation.AgentData.SessionID != SessionId ||
  5883. rotation.AgentData.AgentID != AgentId)
  5884. return true;
  5885. }
  5886. #endregion
  5887. for (int i = 0; i < rotation.ObjectData.Length; i++)
  5888. {
  5889. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  5890. if (handlerUpdatePrimRotation != null)
  5891. handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this);
  5892. }
  5893. return true;
  5894. }
  5895. private bool HandleObjectFlagUpdate(IClientAPI sender, Packet Pack)
  5896. {
  5897. ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
  5898. #region Packet Session and User Check
  5899. if (m_checkPackets)
  5900. {
  5901. if (flags.AgentData.SessionID != SessionId ||
  5902. flags.AgentData.AgentID != AgentId)
  5903. return true;
  5904. }
  5905. #endregion
  5906. UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags;
  5907. if (handlerUpdatePrimFlags != null)
  5908. {
  5909. byte[] data = Pack.ToBytes();
  5910. // 46,47,48 are special positions within the packet
  5911. // This may change so perhaps we need a better way
  5912. // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
  5913. bool UsePhysics = (data[46] != 0) ? true : false;
  5914. bool IsTemporary = (data[47] != 0) ? true : false;
  5915. bool IsPhantom = (data[48] != 0) ? true : false;
  5916. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
  5917. }
  5918. return true;
  5919. }
  5920. private bool HandleObjectImage(IClientAPI sender, Packet Pack)
  5921. {
  5922. ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
  5923. UpdatePrimTexture handlerUpdatePrimTexture = null;
  5924. for (int i = 0; i < imagePack.ObjectData.Length; i++)
  5925. {
  5926. handlerUpdatePrimTexture = OnUpdatePrimTexture;
  5927. if (handlerUpdatePrimTexture != null)
  5928. {
  5929. handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID,
  5930. imagePack.ObjectData[i].TextureEntry, this);
  5931. }
  5932. }
  5933. return true;
  5934. }
  5935. private bool HandleObjectGrab(IClientAPI sender, Packet Pack)
  5936. {
  5937. ObjectGrabPacket grab = (ObjectGrabPacket)Pack;
  5938. #region Packet Session and User Check
  5939. if (m_checkPackets)
  5940. {
  5941. if (grab.AgentData.SessionID != SessionId ||
  5942. grab.AgentData.AgentID != AgentId)
  5943. return true;
  5944. }
  5945. #endregion
  5946. GrabObject handlerGrabObject = OnGrabObject;
  5947. if (handlerGrabObject != null)
  5948. {
  5949. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  5950. if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0))
  5951. {
  5952. foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo)
  5953. {
  5954. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  5955. arg.Binormal = surfaceInfo.Binormal;
  5956. arg.FaceIndex = surfaceInfo.FaceIndex;
  5957. arg.Normal = surfaceInfo.Normal;
  5958. arg.Position = surfaceInfo.Position;
  5959. arg.STCoord = surfaceInfo.STCoord;
  5960. arg.UVCoord = surfaceInfo.UVCoord;
  5961. touchArgs.Add(arg);
  5962. }
  5963. }
  5964. handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs);
  5965. }
  5966. return true;
  5967. }
  5968. private bool HandleObjectGrabUpdate(IClientAPI sender, Packet Pack)
  5969. {
  5970. ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack;
  5971. #region Packet Session and User Check
  5972. if (m_checkPackets)
  5973. {
  5974. if (grabUpdate.AgentData.SessionID != SessionId ||
  5975. grabUpdate.AgentData.AgentID != AgentId)
  5976. return true;
  5977. }
  5978. #endregion
  5979. MoveObject handlerGrabUpdate = OnGrabUpdate;
  5980. if (handlerGrabUpdate != null)
  5981. {
  5982. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  5983. if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0))
  5984. {
  5985. foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo)
  5986. {
  5987. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  5988. arg.Binormal = surfaceInfo.Binormal;
  5989. arg.FaceIndex = surfaceInfo.FaceIndex;
  5990. arg.Normal = surfaceInfo.Normal;
  5991. arg.Position = surfaceInfo.Position;
  5992. arg.STCoord = surfaceInfo.STCoord;
  5993. arg.UVCoord = surfaceInfo.UVCoord;
  5994. touchArgs.Add(arg);
  5995. }
  5996. }
  5997. handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
  5998. grabUpdate.ObjectData.GrabPosition, this, touchArgs);
  5999. }
  6000. return true;
  6001. }
  6002. private bool HandleObjectDeGrab(IClientAPI sender, Packet Pack)
  6003. {
  6004. ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack;
  6005. #region Packet Session and User Check
  6006. if (m_checkPackets)
  6007. {
  6008. if (deGrab.AgentData.SessionID != SessionId ||
  6009. deGrab.AgentData.AgentID != AgentId)
  6010. return true;
  6011. }
  6012. #endregion
  6013. DeGrabObject handlerDeGrabObject = OnDeGrabObject;
  6014. if (handlerDeGrabObject != null)
  6015. {
  6016. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6017. if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0))
  6018. {
  6019. foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo)
  6020. {
  6021. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6022. arg.Binormal = surfaceInfo.Binormal;
  6023. arg.FaceIndex = surfaceInfo.FaceIndex;
  6024. arg.Normal = surfaceInfo.Normal;
  6025. arg.Position = surfaceInfo.Position;
  6026. arg.STCoord = surfaceInfo.STCoord;
  6027. arg.UVCoord = surfaceInfo.UVCoord;
  6028. touchArgs.Add(arg);
  6029. }
  6030. }
  6031. handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs);
  6032. }
  6033. return true;
  6034. }
  6035. private bool HandleObjectSpinStart(IClientAPI sender, Packet Pack)
  6036. {
  6037. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet");
  6038. ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack;
  6039. #region Packet Session and User Check
  6040. if (m_checkPackets)
  6041. {
  6042. if (spinStart.AgentData.SessionID != SessionId ||
  6043. spinStart.AgentData.AgentID != AgentId)
  6044. return true;
  6045. }
  6046. #endregion
  6047. SpinStart handlerSpinStart = OnSpinStart;
  6048. if (handlerSpinStart != null)
  6049. {
  6050. handlerSpinStart(spinStart.ObjectData.ObjectID, this);
  6051. }
  6052. return true;
  6053. }
  6054. private bool HandleObjectSpinUpdate(IClientAPI sender, Packet Pack)
  6055. {
  6056. //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet");
  6057. ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack;
  6058. #region Packet Session and User Check
  6059. if (m_checkPackets)
  6060. {
  6061. if (spinUpdate.AgentData.SessionID != SessionId ||
  6062. spinUpdate.AgentData.AgentID != AgentId)
  6063. return true;
  6064. }
  6065. #endregion
  6066. Vector3 axis;
  6067. float angle;
  6068. spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle);
  6069. //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle);
  6070. SpinObject handlerSpinUpdate = OnSpinUpdate;
  6071. if (handlerSpinUpdate != null)
  6072. {
  6073. handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this);
  6074. }
  6075. return true;
  6076. }
  6077. private bool HandleObjectSpinStop(IClientAPI sender, Packet Pack)
  6078. {
  6079. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet");
  6080. ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack;
  6081. #region Packet Session and User Check
  6082. if (m_checkPackets)
  6083. {
  6084. if (spinStop.AgentData.SessionID != SessionId ||
  6085. spinStop.AgentData.AgentID != AgentId)
  6086. return true;
  6087. }
  6088. #endregion
  6089. SpinStop handlerSpinStop = OnSpinStop;
  6090. if (handlerSpinStop != null)
  6091. {
  6092. handlerSpinStop(spinStop.ObjectData.ObjectID, this);
  6093. }
  6094. return true;
  6095. }
  6096. private bool HandleObjectDescription(IClientAPI sender, Packet Pack)
  6097. {
  6098. ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
  6099. #region Packet Session and User Check
  6100. if (m_checkPackets)
  6101. {
  6102. if (objDes.AgentData.SessionID != SessionId ||
  6103. objDes.AgentData.AgentID != AgentId)
  6104. return true;
  6105. }
  6106. #endregion
  6107. GenericCall7 handlerObjectDescription = null;
  6108. for (int i = 0; i < objDes.ObjectData.Length; i++)
  6109. {
  6110. handlerObjectDescription = OnObjectDescription;
  6111. if (handlerObjectDescription != null)
  6112. {
  6113. handlerObjectDescription(this, objDes.ObjectData[i].LocalID,
  6114. Util.FieldToString(objDes.ObjectData[i].Description));
  6115. }
  6116. }
  6117. return true;
  6118. }
  6119. private bool HandleObjectName(IClientAPI sender, Packet Pack)
  6120. {
  6121. ObjectNamePacket objName = (ObjectNamePacket)Pack;
  6122. #region Packet Session and User Check
  6123. if (m_checkPackets)
  6124. {
  6125. if (objName.AgentData.SessionID != SessionId ||
  6126. objName.AgentData.AgentID != AgentId)
  6127. return true;
  6128. }
  6129. #endregion
  6130. GenericCall7 handlerObjectName = null;
  6131. for (int i = 0; i < objName.ObjectData.Length; i++)
  6132. {
  6133. handlerObjectName = OnObjectName;
  6134. if (handlerObjectName != null)
  6135. {
  6136. handlerObjectName(this, objName.ObjectData[i].LocalID,
  6137. Util.FieldToString(objName.ObjectData[i].Name));
  6138. }
  6139. }
  6140. return true;
  6141. }
  6142. private bool HandleObjectPermissions(IClientAPI sender, Packet Pack)
  6143. {
  6144. if (OnObjectPermissions != null)
  6145. {
  6146. ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
  6147. #region Packet Session and User Check
  6148. if (m_checkPackets)
  6149. {
  6150. if (newobjPerms.AgentData.SessionID != SessionId ||
  6151. newobjPerms.AgentData.AgentID != AgentId)
  6152. return true;
  6153. }
  6154. #endregion
  6155. UUID AgentID = newobjPerms.AgentData.AgentID;
  6156. UUID SessionID = newobjPerms.AgentData.SessionID;
  6157. ObjectPermissions handlerObjectPermissions = null;
  6158. for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
  6159. {
  6160. ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
  6161. byte field = permChanges.Field;
  6162. uint localID = permChanges.ObjectLocalID;
  6163. uint mask = permChanges.Mask;
  6164. byte set = permChanges.Set;
  6165. handlerObjectPermissions = OnObjectPermissions;
  6166. if (handlerObjectPermissions != null)
  6167. handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
  6168. }
  6169. }
  6170. // Here's our data,
  6171. // PermField contains the field the info goes into
  6172. // PermField determines which mask we're changing
  6173. //
  6174. // chmask is the mask of the change
  6175. // setTF is whether we're adding it or taking it away
  6176. //
  6177. // objLocalID is the localID of the object.
  6178. // Unfortunately, we have to pass the event the packet because objData is an array
  6179. // That means multiple object perms may be updated in a single packet.
  6180. return true;
  6181. }
  6182. private bool HandleUndo(IClientAPI sender, Packet Pack)
  6183. {
  6184. UndoPacket undoitem = (UndoPacket)Pack;
  6185. #region Packet Session and User Check
  6186. if (m_checkPackets)
  6187. {
  6188. if (undoitem.AgentData.SessionID != SessionId ||
  6189. undoitem.AgentData.AgentID != AgentId)
  6190. return true;
  6191. }
  6192. #endregion
  6193. if (undoitem.ObjectData.Length > 0)
  6194. {
  6195. for (int i = 0; i < undoitem.ObjectData.Length; i++)
  6196. {
  6197. UUID objiD = undoitem.ObjectData[i].ObjectID;
  6198. AgentSit handlerOnUndo = OnUndo;
  6199. if (handlerOnUndo != null)
  6200. {
  6201. handlerOnUndo(this, objiD);
  6202. }
  6203. }
  6204. }
  6205. return true;
  6206. }
  6207. private bool HandleLandUndo(IClientAPI sender, Packet Pack)
  6208. {
  6209. UndoLandPacket undolanditem = (UndoLandPacket)Pack;
  6210. #region Packet Session and User Check
  6211. if (m_checkPackets)
  6212. {
  6213. if (undolanditem.AgentData.SessionID != SessionId ||
  6214. undolanditem.AgentData.AgentID != AgentId)
  6215. return true;
  6216. }
  6217. #endregion
  6218. LandUndo handlerOnUndo = OnLandUndo;
  6219. if (handlerOnUndo != null)
  6220. {
  6221. handlerOnUndo(this);
  6222. }
  6223. return true;
  6224. }
  6225. private bool HandleRedo(IClientAPI sender, Packet Pack)
  6226. {
  6227. RedoPacket redoitem = (RedoPacket)Pack;
  6228. #region Packet Session and User Check
  6229. if (m_checkPackets)
  6230. {
  6231. if (redoitem.AgentData.SessionID != SessionId ||
  6232. redoitem.AgentData.AgentID != AgentId)
  6233. return true;
  6234. }
  6235. #endregion
  6236. if (redoitem.ObjectData.Length > 0)
  6237. {
  6238. for (int i = 0; i < redoitem.ObjectData.Length; i++)
  6239. {
  6240. UUID objiD = redoitem.ObjectData[i].ObjectID;
  6241. AgentSit handlerOnRedo = OnRedo;
  6242. if (handlerOnRedo != null)
  6243. {
  6244. handlerOnRedo(this, objiD);
  6245. }
  6246. }
  6247. }
  6248. return true;
  6249. }
  6250. private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack)
  6251. {
  6252. ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
  6253. #region Packet Session and User Check
  6254. if (m_checkPackets)
  6255. {
  6256. if (dupeOnRay.AgentData.SessionID != SessionId ||
  6257. dupeOnRay.AgentData.AgentID != AgentId)
  6258. return true;
  6259. }
  6260. #endregion
  6261. ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null;
  6262. for (int i = 0; i < dupeOnRay.ObjectData.Length; i++)
  6263. {
  6264. handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay;
  6265. if (handlerObjectDuplicateOnRay != null)
  6266. {
  6267. handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags,
  6268. AgentId, m_activeGroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd,
  6269. dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection,
  6270. dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates);
  6271. }
  6272. }
  6273. return true;
  6274. }
  6275. private bool HandleRequestObjectPropertiesFamily(IClientAPI sender, Packet Pack)
  6276. {
  6277. //This powers the little tooltip that appears when you move your mouse over an object
  6278. RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack;
  6279. #region Packet Session and User Check
  6280. if (m_checkPackets)
  6281. {
  6282. if (packToolTip.AgentData.SessionID != SessionId ||
  6283. packToolTip.AgentData.AgentID != AgentId)
  6284. return true;
  6285. }
  6286. #endregion
  6287. RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
  6288. RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily;
  6289. if (handlerRequestObjectPropertiesFamily != null)
  6290. {
  6291. handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
  6292. packObjBlock.ObjectID);
  6293. }
  6294. return true;
  6295. }
  6296. private bool HandleObjectIncludeInSearch(IClientAPI sender, Packet Pack)
  6297. {
  6298. //This lets us set objects to appear in search (stuff like DataSnapshot, etc)
  6299. ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack;
  6300. ObjectIncludeInSearch handlerObjectIncludeInSearch = null;
  6301. #region Packet Session and User Check
  6302. if (m_checkPackets)
  6303. {
  6304. if (packInSearch.AgentData.SessionID != SessionId ||
  6305. packInSearch.AgentData.AgentID != AgentId)
  6306. return true;
  6307. }
  6308. #endregion
  6309. foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData)
  6310. {
  6311. bool inSearch = objData.IncludeInSearch;
  6312. uint localID = objData.ObjectLocalID;
  6313. handlerObjectIncludeInSearch = OnObjectIncludeInSearch;
  6314. if (handlerObjectIncludeInSearch != null)
  6315. {
  6316. handlerObjectIncludeInSearch(this, inSearch, localID);
  6317. }
  6318. }
  6319. return true;
  6320. }
  6321. private bool HandleScriptAnswerYes(IClientAPI sender, Packet Pack)
  6322. {
  6323. ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack;
  6324. #region Packet Session and User Check
  6325. if (m_checkPackets)
  6326. {
  6327. if (scriptAnswer.AgentData.SessionID != SessionId ||
  6328. scriptAnswer.AgentData.AgentID != AgentId)
  6329. return true;
  6330. }
  6331. #endregion
  6332. ScriptAnswer handlerScriptAnswer = OnScriptAnswer;
  6333. if (handlerScriptAnswer != null)
  6334. {
  6335. handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions);
  6336. }
  6337. return true;
  6338. }
  6339. private bool HandleObjectClickAction(IClientAPI sender, Packet Pack)
  6340. {
  6341. ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack;
  6342. #region Packet Session and User Check
  6343. if (m_checkPackets)
  6344. {
  6345. if (ocpacket.AgentData.SessionID != SessionId ||
  6346. ocpacket.AgentData.AgentID != AgentId)
  6347. return true;
  6348. }
  6349. #endregion
  6350. GenericCall7 handlerObjectClickAction = OnObjectClickAction;
  6351. if (handlerObjectClickAction != null)
  6352. {
  6353. foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData)
  6354. {
  6355. byte action = odata.ClickAction;
  6356. uint localID = odata.ObjectLocalID;
  6357. handlerObjectClickAction(this, localID, action.ToString());
  6358. }
  6359. }
  6360. return true;
  6361. }
  6362. private bool HandleObjectMaterial(IClientAPI sender, Packet Pack)
  6363. {
  6364. ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack;
  6365. #region Packet Session and User Check
  6366. if (m_checkPackets)
  6367. {
  6368. if (ompacket.AgentData.SessionID != SessionId ||
  6369. ompacket.AgentData.AgentID != AgentId)
  6370. return true;
  6371. }
  6372. #endregion
  6373. GenericCall7 handlerObjectMaterial = OnObjectMaterial;
  6374. if (handlerObjectMaterial != null)
  6375. {
  6376. foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData)
  6377. {
  6378. byte material = odata.Material;
  6379. uint localID = odata.ObjectLocalID;
  6380. handlerObjectMaterial(this, localID, material.ToString());
  6381. }
  6382. }
  6383. return true;
  6384. }
  6385. #endregion Objects/m_sceneObjects
  6386. #region Inventory/Asset/Other related packets
  6387. private bool HandleRequestImage(IClientAPI sender, Packet Pack)
  6388. {
  6389. RequestImagePacket imageRequest = (RequestImagePacket)Pack;
  6390. //m_log.Debug("image request: " + Pack.ToString());
  6391. #region Packet Session and User Check
  6392. if (m_checkPackets)
  6393. {
  6394. if (imageRequest.AgentData.SessionID != SessionId ||
  6395. imageRequest.AgentData.AgentID != AgentId)
  6396. return true;
  6397. }
  6398. #endregion
  6399. //handlerTextureRequest = null;
  6400. for (int i = 0; i < imageRequest.RequestImage.Length; i++)
  6401. {
  6402. TextureRequestArgs args = new TextureRequestArgs();
  6403. RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i];
  6404. args.RequestedAssetID = block.Image;
  6405. args.DiscardLevel = block.DiscardLevel;
  6406. args.PacketNumber = block.Packet;
  6407. args.Priority = block.DownloadPriority;
  6408. args.requestSequence = imageRequest.Header.Sequence;
  6409. // NOTE: This is not a built in part of the LLUDP protocol, but we double the
  6410. // priority of avatar textures to get avatars rezzing in faster than the
  6411. // surrounding scene
  6412. if ((ImageType)block.Type == ImageType.Baked)
  6413. args.Priority *= 2.0f;
  6414. // in the end, we null this, so we have to check if it's null
  6415. if (m_imageManager != null)
  6416. {
  6417. m_imageManager.EnqueueReq(args);
  6418. }
  6419. }
  6420. return true;
  6421. }
  6422. /// <summary>
  6423. /// This is the entry point for the UDP route by which the client can retrieve asset data. If the request
  6424. /// is successful then a TransferInfo packet will be sent back, followed by one or more TransferPackets
  6425. /// </summary>
  6426. /// <param name="sender"></param>
  6427. /// <param name="Pack"></param>
  6428. /// <returns>This parameter may be ignored since we appear to return true whatever happens</returns>
  6429. private bool HandleTransferRequest(IClientAPI sender, Packet Pack)
  6430. {
  6431. //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
  6432. TransferRequestPacket transfer = (TransferRequestPacket)Pack;
  6433. //m_log.Debug("Transfer Request: " + transfer.ToString());
  6434. // Validate inventory transfers
  6435. // Has to be done here, because AssetCache can't do it
  6436. //
  6437. UUID taskID = UUID.Zero;
  6438. if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  6439. {
  6440. taskID = new UUID(transfer.TransferInfo.Params, 48);
  6441. UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
  6442. UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
  6443. // m_log.DebugFormat(
  6444. // "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
  6445. // requestID, itemID, taskID, Name);
  6446. if (!(((Scene)m_scene).Permissions.BypassPermissions()))
  6447. {
  6448. if (taskID != UUID.Zero) // Prim
  6449. {
  6450. SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
  6451. if (part == null)
  6452. {
  6453. m_log.WarnFormat(
  6454. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
  6455. Name, requestID, itemID, taskID);
  6456. return true;
  6457. }
  6458. TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
  6459. if (tii == null)
  6460. {
  6461. m_log.WarnFormat(
  6462. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
  6463. Name, requestID, itemID, taskID);
  6464. return true;
  6465. }
  6466. if (tii.Type == (int)AssetType.LSLText)
  6467. {
  6468. if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
  6469. return true;
  6470. }
  6471. else if (tii.Type == (int)AssetType.Notecard)
  6472. {
  6473. if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
  6474. return true;
  6475. }
  6476. else
  6477. {
  6478. // TODO: Change this code to allow items other than notecards and scripts to be successfully
  6479. // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
  6480. if (part.OwnerID != AgentId)
  6481. {
  6482. m_log.WarnFormat(
  6483. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
  6484. Name, requestID, itemID, taskID, part.OwnerID);
  6485. return true;
  6486. }
  6487. if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
  6488. {
  6489. m_log.WarnFormat(
  6490. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
  6491. Name, requestID, itemID, taskID);
  6492. return true;
  6493. }
  6494. if (tii.OwnerID != AgentId)
  6495. {
  6496. m_log.WarnFormat(
  6497. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
  6498. Name, requestID, itemID, taskID, tii.OwnerID);
  6499. return true;
  6500. }
  6501. if ((
  6502. tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6503. != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6504. {
  6505. m_log.WarnFormat(
  6506. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
  6507. Name, requestID, itemID, taskID);
  6508. return true;
  6509. }
  6510. if (tii.AssetID != requestID)
  6511. {
  6512. m_log.WarnFormat(
  6513. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
  6514. Name, requestID, itemID, taskID, tii.AssetID);
  6515. return true;
  6516. }
  6517. }
  6518. }
  6519. else // Agent
  6520. {
  6521. IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
  6522. if (invAccess != null)
  6523. {
  6524. if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID))
  6525. return false;
  6526. }
  6527. else
  6528. {
  6529. return false;
  6530. }
  6531. }
  6532. }
  6533. }
  6534. MakeAssetRequest(transfer, taskID);
  6535. return true;
  6536. }
  6537. private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack)
  6538. {
  6539. AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
  6540. // m_log.Debug("upload request " + request.ToString());
  6541. // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
  6542. UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
  6543. UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest;
  6544. if (handlerAssetUploadRequest != null)
  6545. {
  6546. handlerAssetUploadRequest(this, temp,
  6547. request.AssetBlock.TransactionID, request.AssetBlock.Type,
  6548. request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
  6549. request.AssetBlock.Tempfile);
  6550. }
  6551. return true;
  6552. }
  6553. private bool HandleRequestXfer(IClientAPI sender, Packet Pack)
  6554. {
  6555. RequestXferPacket xferReq = (RequestXferPacket)Pack;
  6556. RequestXfer handlerRequestXfer = OnRequestXfer;
  6557. if (handlerRequestXfer != null)
  6558. {
  6559. handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename));
  6560. }
  6561. return true;
  6562. }
  6563. private bool HandleSendXferPacket(IClientAPI sender, Packet Pack)
  6564. {
  6565. SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack;
  6566. XferReceive handlerXferReceive = OnXferReceive;
  6567. if (handlerXferReceive != null)
  6568. {
  6569. handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
  6570. }
  6571. return true;
  6572. }
  6573. private bool HandleConfirmXferPacket(IClientAPI sender, Packet Pack)
  6574. {
  6575. ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
  6576. ConfirmXfer handlerConfirmXfer = OnConfirmXfer;
  6577. if (handlerConfirmXfer != null)
  6578. {
  6579. handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
  6580. }
  6581. return true;
  6582. }
  6583. private bool HandleAbortXfer(IClientAPI sender, Packet Pack)
  6584. {
  6585. AbortXferPacket abortXfer = (AbortXferPacket)Pack;
  6586. AbortXfer handlerAbortXfer = OnAbortXfer;
  6587. if (handlerAbortXfer != null)
  6588. {
  6589. handlerAbortXfer(this, abortXfer.XferID.ID);
  6590. }
  6591. return true;
  6592. }
  6593. private bool HandleCreateInventoryFolder(IClientAPI sender, Packet Pack)
  6594. {
  6595. CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
  6596. #region Packet Session and User Check
  6597. if (m_checkPackets)
  6598. {
  6599. if (invFolder.AgentData.SessionID != SessionId ||
  6600. invFolder.AgentData.AgentID != AgentId)
  6601. return true;
  6602. }
  6603. #endregion
  6604. CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder;
  6605. if (handlerCreateInventoryFolder != null)
  6606. {
  6607. handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID,
  6608. (ushort)invFolder.FolderData.Type,
  6609. Util.FieldToString(invFolder.FolderData.Name),
  6610. invFolder.FolderData.ParentID);
  6611. }
  6612. return true;
  6613. }
  6614. private bool HandleUpdateInventoryFolder(IClientAPI sender, Packet Pack)
  6615. {
  6616. if (OnUpdateInventoryFolder != null)
  6617. {
  6618. UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack;
  6619. #region Packet Session and User Check
  6620. if (m_checkPackets)
  6621. {
  6622. if (invFolderx.AgentData.SessionID != SessionId ||
  6623. invFolderx.AgentData.AgentID != AgentId)
  6624. return true;
  6625. }
  6626. #endregion
  6627. UpdateInventoryFolder handlerUpdateInventoryFolder = null;
  6628. for (int i = 0; i < invFolderx.FolderData.Length; i++)
  6629. {
  6630. handlerUpdateInventoryFolder = OnUpdateInventoryFolder;
  6631. if (handlerUpdateInventoryFolder != null)
  6632. {
  6633. OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID,
  6634. (ushort)invFolderx.FolderData[i].Type,
  6635. Util.FieldToString(invFolderx.FolderData[i].Name),
  6636. invFolderx.FolderData[i].ParentID);
  6637. }
  6638. }
  6639. }
  6640. return true;
  6641. }
  6642. private bool HandleMoveInventoryFolder(IClientAPI sender, Packet Pack)
  6643. {
  6644. if (OnMoveInventoryFolder != null)
  6645. {
  6646. MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack;
  6647. #region Packet Session and User Check
  6648. if (m_checkPackets)
  6649. {
  6650. if (invFoldery.AgentData.SessionID != SessionId ||
  6651. invFoldery.AgentData.AgentID != AgentId)
  6652. return true;
  6653. }
  6654. #endregion
  6655. MoveInventoryFolder handlerMoveInventoryFolder = null;
  6656. for (int i = 0; i < invFoldery.InventoryData.Length; i++)
  6657. {
  6658. handlerMoveInventoryFolder = OnMoveInventoryFolder;
  6659. if (handlerMoveInventoryFolder != null)
  6660. {
  6661. OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID,
  6662. invFoldery.InventoryData[i].ParentID);
  6663. }
  6664. }
  6665. }
  6666. return true;
  6667. }
  6668. private bool HandleCreateInventoryItem(IClientAPI sender, Packet Pack)
  6669. {
  6670. CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
  6671. #region Packet Session and User Check
  6672. if (m_checkPackets)
  6673. {
  6674. if (createItem.AgentData.SessionID != SessionId ||
  6675. createItem.AgentData.AgentID != AgentId)
  6676. return true;
  6677. }
  6678. #endregion
  6679. CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem;
  6680. if (handlerCreateNewInventoryItem != null)
  6681. {
  6682. handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID,
  6683. createItem.InventoryBlock.FolderID,
  6684. createItem.InventoryBlock.CallbackID,
  6685. Util.FieldToString(createItem.InventoryBlock.Description),
  6686. Util.FieldToString(createItem.InventoryBlock.Name),
  6687. createItem.InventoryBlock.InvType,
  6688. createItem.InventoryBlock.Type,
  6689. createItem.InventoryBlock.WearableType,
  6690. createItem.InventoryBlock.NextOwnerMask,
  6691. Util.UnixTimeSinceEpoch());
  6692. }
  6693. return true;
  6694. }
  6695. private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack)
  6696. {
  6697. LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack;
  6698. #region Packet Session and User Check
  6699. if (m_checkPackets)
  6700. {
  6701. if (createLink.AgentData.SessionID != SessionId ||
  6702. createLink.AgentData.AgentID != AgentId)
  6703. return true;
  6704. }
  6705. #endregion
  6706. LinkInventoryItem linkInventoryItem = OnLinkInventoryItem;
  6707. if (linkInventoryItem != null)
  6708. {
  6709. linkInventoryItem(
  6710. this,
  6711. createLink.InventoryBlock.TransactionID,
  6712. createLink.InventoryBlock.FolderID,
  6713. createLink.InventoryBlock.CallbackID,
  6714. Util.FieldToString(createLink.InventoryBlock.Description),
  6715. Util.FieldToString(createLink.InventoryBlock.Name),
  6716. createLink.InventoryBlock.InvType,
  6717. createLink.InventoryBlock.Type,
  6718. createLink.InventoryBlock.OldItemID);
  6719. }
  6720. return true;
  6721. }
  6722. private bool HandleFetchInventory(IClientAPI sender, Packet Pack)
  6723. {
  6724. if (OnFetchInventory != null)
  6725. {
  6726. FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack;
  6727. #region Packet Session and User Check
  6728. if (m_checkPackets)
  6729. {
  6730. if (FetchInventoryx.AgentData.SessionID != SessionId ||
  6731. FetchInventoryx.AgentData.AgentID != AgentId)
  6732. return true;
  6733. }
  6734. #endregion
  6735. FetchInventory handlerFetchInventory = null;
  6736. for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++)
  6737. {
  6738. handlerFetchInventory = OnFetchInventory;
  6739. if (handlerFetchInventory != null)
  6740. {
  6741. OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID,
  6742. FetchInventoryx.InventoryData[i].OwnerID);
  6743. }
  6744. }
  6745. }
  6746. return true;
  6747. }
  6748. private bool HandleFetchInventoryDescendents(IClientAPI sender, Packet Pack)
  6749. {
  6750. FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
  6751. #region Packet Session and User Check
  6752. if (m_checkPackets)
  6753. {
  6754. if (Fetch.AgentData.SessionID != SessionId ||
  6755. Fetch.AgentData.AgentID != AgentId)
  6756. return true;
  6757. }
  6758. #endregion
  6759. FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents;
  6760. if (handlerFetchInventoryDescendents != null)
  6761. {
  6762. handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID,
  6763. Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems,
  6764. Fetch.InventoryData.SortOrder);
  6765. }
  6766. return true;
  6767. }
  6768. private bool HandlePurgeInventoryDescendents(IClientAPI sender, Packet Pack)
  6769. {
  6770. PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack;
  6771. #region Packet Session and User Check
  6772. if (m_checkPackets)
  6773. {
  6774. if (Purge.AgentData.SessionID != SessionId ||
  6775. Purge.AgentData.AgentID != AgentId)
  6776. return true;
  6777. }
  6778. #endregion
  6779. PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents;
  6780. if (handlerPurgeInventoryDescendents != null)
  6781. {
  6782. handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
  6783. }
  6784. return true;
  6785. }
  6786. private bool HandleUpdateInventoryItem(IClientAPI sender, Packet Pack)
  6787. {
  6788. UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack;
  6789. #region Packet Session and User Check
  6790. if (m_checkPackets)
  6791. {
  6792. if (inventoryItemUpdate.AgentData.SessionID != SessionId ||
  6793. inventoryItemUpdate.AgentData.AgentID != AgentId)
  6794. return true;
  6795. }
  6796. #endregion
  6797. if (OnUpdateInventoryItem != null)
  6798. {
  6799. UpdateInventoryItem handlerUpdateInventoryItem = null;
  6800. for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++)
  6801. {
  6802. handlerUpdateInventoryItem = OnUpdateInventoryItem;
  6803. if (handlerUpdateInventoryItem != null)
  6804. {
  6805. InventoryItemBase itemUpd = new InventoryItemBase();
  6806. itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID;
  6807. itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name);
  6808. itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description);
  6809. itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID;
  6810. itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned;
  6811. itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask;
  6812. itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask;
  6813. itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask;
  6814. itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate;
  6815. itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID;
  6816. itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType;
  6817. itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice;
  6818. itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType;
  6819. itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags;
  6820. OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID,
  6821. inventoryItemUpdate.InventoryData[i].ItemID,
  6822. itemUpd);
  6823. }
  6824. }
  6825. }
  6826. return true;
  6827. }
  6828. private bool HandleCopyInventoryItem(IClientAPI sender, Packet Pack)
  6829. {
  6830. CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack;
  6831. #region Packet Session and User Check
  6832. if (m_checkPackets)
  6833. {
  6834. if (copyitem.AgentData.SessionID != SessionId ||
  6835. copyitem.AgentData.AgentID != AgentId)
  6836. return true;
  6837. }
  6838. #endregion
  6839. CopyInventoryItem handlerCopyInventoryItem = null;
  6840. if (OnCopyInventoryItem != null)
  6841. {
  6842. foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
  6843. {
  6844. handlerCopyInventoryItem = OnCopyInventoryItem;
  6845. if (handlerCopyInventoryItem != null)
  6846. {
  6847. handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
  6848. datablock.OldItemID, datablock.NewFolderID,
  6849. Util.FieldToString(datablock.NewName));
  6850. }
  6851. }
  6852. }
  6853. return true;
  6854. }
  6855. private bool HandleMoveInventoryItem(IClientAPI sender, Packet Pack)
  6856. {
  6857. MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack;
  6858. #region Packet Session and User Check
  6859. if (m_checkPackets)
  6860. {
  6861. if (moveitem.AgentData.SessionID != SessionId ||
  6862. moveitem.AgentData.AgentID != AgentId)
  6863. return true;
  6864. }
  6865. #endregion
  6866. if (OnMoveInventoryItem != null)
  6867. {
  6868. MoveInventoryItem handlerMoveInventoryItem = null;
  6869. InventoryItemBase itm = null;
  6870. List<InventoryItemBase> items = new List<InventoryItemBase>();
  6871. foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
  6872. {
  6873. itm = new InventoryItemBase(datablock.ItemID, AgentId);
  6874. itm.Folder = datablock.FolderID;
  6875. itm.Name = Util.FieldToString(datablock.NewName);
  6876. // weird, comes out as empty string
  6877. //m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
  6878. items.Add(itm);
  6879. }
  6880. handlerMoveInventoryItem = OnMoveInventoryItem;
  6881. if (handlerMoveInventoryItem != null)
  6882. {
  6883. handlerMoveInventoryItem(this, items);
  6884. }
  6885. }
  6886. return true;
  6887. }
  6888. private bool HandleRemoveInventoryItem(IClientAPI sender, Packet Pack)
  6889. {
  6890. RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack;
  6891. #region Packet Session and User Check
  6892. if (m_checkPackets)
  6893. {
  6894. if (removeItem.AgentData.SessionID != SessionId ||
  6895. removeItem.AgentData.AgentID != AgentId)
  6896. return true;
  6897. }
  6898. #endregion
  6899. if (OnRemoveInventoryItem != null)
  6900. {
  6901. RemoveInventoryItem handlerRemoveInventoryItem = null;
  6902. List<UUID> uuids = new List<UUID>();
  6903. foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
  6904. {
  6905. uuids.Add(datablock.ItemID);
  6906. }
  6907. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  6908. if (handlerRemoveInventoryItem != null)
  6909. {
  6910. handlerRemoveInventoryItem(this, uuids);
  6911. }
  6912. }
  6913. return true;
  6914. }
  6915. private bool HandleRemoveInventoryFolder(IClientAPI sender, Packet Pack)
  6916. {
  6917. RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack;
  6918. #region Packet Session and User Check
  6919. if (m_checkPackets)
  6920. {
  6921. if (removeFolder.AgentData.SessionID != SessionId ||
  6922. removeFolder.AgentData.AgentID != AgentId)
  6923. return true;
  6924. }
  6925. #endregion
  6926. if (OnRemoveInventoryFolder != null)
  6927. {
  6928. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  6929. List<UUID> uuids = new List<UUID>();
  6930. foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
  6931. {
  6932. uuids.Add(datablock.FolderID);
  6933. }
  6934. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  6935. if (handlerRemoveInventoryFolder != null)
  6936. {
  6937. handlerRemoveInventoryFolder(this, uuids);
  6938. }
  6939. }
  6940. return true;
  6941. }
  6942. private bool HandleRemoveInventoryObjects(IClientAPI sender, Packet Pack)
  6943. {
  6944. RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack;
  6945. #region Packet Session and User Check
  6946. if (m_checkPackets)
  6947. {
  6948. if (removeObject.AgentData.SessionID != SessionId ||
  6949. removeObject.AgentData.AgentID != AgentId)
  6950. return true;
  6951. }
  6952. #endregion
  6953. if (OnRemoveInventoryFolder != null)
  6954. {
  6955. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  6956. List<UUID> uuids = new List<UUID>();
  6957. foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData)
  6958. {
  6959. uuids.Add(datablock.FolderID);
  6960. }
  6961. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  6962. if (handlerRemoveInventoryFolder != null)
  6963. {
  6964. handlerRemoveInventoryFolder(this, uuids);
  6965. }
  6966. }
  6967. if (OnRemoveInventoryItem != null)
  6968. {
  6969. RemoveInventoryItem handlerRemoveInventoryItem = null;
  6970. List<UUID> uuids = new List<UUID>();
  6971. foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
  6972. {
  6973. uuids.Add(datablock.ItemID);
  6974. }
  6975. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  6976. if (handlerRemoveInventoryItem != null)
  6977. {
  6978. handlerRemoveInventoryItem(this, uuids);
  6979. }
  6980. }
  6981. return true;
  6982. }
  6983. private bool HandleRequestTaskInventory(IClientAPI sender, Packet Pack)
  6984. {
  6985. RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
  6986. #region Packet Session and User Check
  6987. if (m_checkPackets)
  6988. {
  6989. if (requesttask.AgentData.SessionID != SessionId ||
  6990. requesttask.AgentData.AgentID != AgentId)
  6991. return true;
  6992. }
  6993. #endregion
  6994. RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory;
  6995. if (handlerRequestTaskInventory != null)
  6996. {
  6997. handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID);
  6998. }
  6999. return true;
  7000. }
  7001. private bool HandleUpdateTaskInventory(IClientAPI sender, Packet Pack)
  7002. {
  7003. UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
  7004. #region Packet Session and User Check
  7005. if (m_checkPackets)
  7006. {
  7007. if (updatetask.AgentData.SessionID != SessionId ||
  7008. updatetask.AgentData.AgentID != AgentId)
  7009. return true;
  7010. }
  7011. #endregion
  7012. if (OnUpdateTaskInventory != null)
  7013. {
  7014. if (updatetask.UpdateData.Key == 0)
  7015. {
  7016. UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory;
  7017. if (handlerUpdateTaskInventory != null)
  7018. {
  7019. TaskInventoryItem newTaskItem = new TaskInventoryItem();
  7020. newTaskItem.ItemID = updatetask.InventoryData.ItemID;
  7021. newTaskItem.ParentID = updatetask.InventoryData.FolderID;
  7022. newTaskItem.CreatorID = updatetask.InventoryData.CreatorID;
  7023. newTaskItem.OwnerID = updatetask.InventoryData.OwnerID;
  7024. newTaskItem.GroupID = updatetask.InventoryData.GroupID;
  7025. newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask;
  7026. newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask;
  7027. newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
  7028. newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
  7029. newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
  7030. // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something
  7031. // different
  7032. //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
  7033. newTaskItem.Type = updatetask.InventoryData.Type;
  7034. newTaskItem.InvType = updatetask.InventoryData.InvType;
  7035. newTaskItem.Flags = updatetask.InventoryData.Flags;
  7036. //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
  7037. //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;
  7038. newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
  7039. newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
  7040. newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
  7041. handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID,
  7042. newTaskItem, updatetask.UpdateData.LocalID);
  7043. }
  7044. }
  7045. }
  7046. return true;
  7047. }
  7048. private bool HandleRemoveTaskInventory(IClientAPI sender, Packet Pack)
  7049. {
  7050. RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
  7051. #region Packet Session and User Check
  7052. if (m_checkPackets)
  7053. {
  7054. if (removeTask.AgentData.SessionID != SessionId ||
  7055. removeTask.AgentData.AgentID != AgentId)
  7056. return true;
  7057. }
  7058. #endregion
  7059. RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem;
  7060. if (handlerRemoveTaskItem != null)
  7061. {
  7062. handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
  7063. }
  7064. return true;
  7065. }
  7066. private bool HandleMoveTaskInventory(IClientAPI sender, Packet Pack)
  7067. {
  7068. MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
  7069. #region Packet Session and User Check
  7070. if (m_checkPackets)
  7071. {
  7072. if (moveTaskInventoryPacket.AgentData.SessionID != SessionId ||
  7073. moveTaskInventoryPacket.AgentData.AgentID != AgentId)
  7074. return true;
  7075. }
  7076. #endregion
  7077. MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem;
  7078. if (handlerMoveTaskItem != null)
  7079. {
  7080. handlerMoveTaskItem(
  7081. this, moveTaskInventoryPacket.AgentData.FolderID,
  7082. moveTaskInventoryPacket.InventoryData.LocalID,
  7083. moveTaskInventoryPacket.InventoryData.ItemID);
  7084. }
  7085. return true;
  7086. }
  7087. private bool HandleRezScript(IClientAPI sender, Packet Pack)
  7088. {
  7089. //m_log.Debug(Pack.ToString());
  7090. RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
  7091. #region Packet Session and User Check
  7092. if (m_checkPackets)
  7093. {
  7094. if (rezScriptx.AgentData.SessionID != SessionId ||
  7095. rezScriptx.AgentData.AgentID != AgentId)
  7096. return true;
  7097. }
  7098. #endregion
  7099. RezScript handlerRezScript = OnRezScript;
  7100. InventoryItemBase item = new InventoryItemBase();
  7101. item.ID = rezScriptx.InventoryBlock.ItemID;
  7102. item.Folder = rezScriptx.InventoryBlock.FolderID;
  7103. item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString();
  7104. item.Owner = rezScriptx.InventoryBlock.OwnerID;
  7105. item.BasePermissions = rezScriptx.InventoryBlock.BaseMask;
  7106. item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask;
  7107. item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask;
  7108. item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask;
  7109. item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask;
  7110. item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned;
  7111. item.GroupID = rezScriptx.InventoryBlock.GroupID;
  7112. item.AssetType = rezScriptx.InventoryBlock.Type;
  7113. item.InvType = rezScriptx.InventoryBlock.InvType;
  7114. item.Flags = rezScriptx.InventoryBlock.Flags;
  7115. item.SaleType = rezScriptx.InventoryBlock.SaleType;
  7116. item.SalePrice = rezScriptx.InventoryBlock.SalePrice;
  7117. item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name);
  7118. item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description);
  7119. item.CreationDate = rezScriptx.InventoryBlock.CreationDate;
  7120. if (handlerRezScript != null)
  7121. {
  7122. handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID);
  7123. }
  7124. return true;
  7125. }
  7126. private bool HandleMapLayerRequest(IClientAPI sender, Packet Pack)
  7127. {
  7128. RequestMapLayer();
  7129. return true;
  7130. }
  7131. private bool HandleMapBlockRequest(IClientAPI sender, Packet Pack)
  7132. {
  7133. MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
  7134. #region Packet Session and User Check
  7135. if (m_checkPackets)
  7136. {
  7137. if (MapRequest.AgentData.SessionID != SessionId ||
  7138. MapRequest.AgentData.AgentID != AgentId)
  7139. return true;
  7140. }
  7141. #endregion
  7142. RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks;
  7143. if (handlerRequestMapBlocks != null)
  7144. {
  7145. handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY,
  7146. MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags);
  7147. }
  7148. return true;
  7149. }
  7150. private bool HandleMapNameRequest(IClientAPI sender, Packet Pack)
  7151. {
  7152. MapNameRequestPacket map = (MapNameRequestPacket)Pack;
  7153. #region Packet Session and User Check
  7154. if (m_checkPackets)
  7155. {
  7156. if (map.AgentData.SessionID != SessionId ||
  7157. map.AgentData.AgentID != AgentId)
  7158. return true;
  7159. }
  7160. #endregion
  7161. string mapName = Util.UTF8.GetString(map.NameData.Name, 0,
  7162. map.NameData.Name.Length - 1);
  7163. RequestMapName handlerMapNameRequest = OnMapNameRequest;
  7164. if (handlerMapNameRequest != null)
  7165. {
  7166. handlerMapNameRequest(this, mapName, map.AgentData.Flags);
  7167. }
  7168. return true;
  7169. }
  7170. private bool HandleTeleportLandmarkRequest(IClientAPI sender, Packet Pack)
  7171. {
  7172. TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
  7173. #region Packet Session and User Check
  7174. if (m_checkPackets)
  7175. {
  7176. if (tpReq.Info.SessionID != SessionId ||
  7177. tpReq.Info.AgentID != AgentId)
  7178. return true;
  7179. }
  7180. #endregion
  7181. UUID lmid = tpReq.Info.LandmarkID;
  7182. AssetLandmark lm;
  7183. if (lmid != UUID.Zero)
  7184. {
  7185. //AssetBase lma = m_assetCache.GetAsset(lmid, false);
  7186. AssetBase lma = m_assetService.Get(lmid.ToString());
  7187. if (lma == null)
  7188. {
  7189. // Failed to find landmark
  7190. // Let's try to search in the user's home asset server
  7191. lma = FindAssetInUserAssetServer(lmid.ToString());
  7192. if (lma == null)
  7193. {
  7194. // Really doesn't exist
  7195. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7196. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7197. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7198. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7199. }
  7200. }
  7201. try
  7202. {
  7203. lm = new AssetLandmark(lma);
  7204. }
  7205. catch (NullReferenceException)
  7206. {
  7207. // asset not found generates null ref inside the assetlandmark constructor.
  7208. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7209. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7210. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7211. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7212. return true;
  7213. }
  7214. }
  7215. else
  7216. {
  7217. // Teleport home request
  7218. UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest;
  7219. if (handlerTeleportHomeRequest != null)
  7220. {
  7221. handlerTeleportHomeRequest(AgentId, this);
  7222. }
  7223. return true;
  7224. }
  7225. TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
  7226. if (handlerTeleportLandmarkRequest != null)
  7227. {
  7228. handlerTeleportLandmarkRequest(this, lm);
  7229. }
  7230. else
  7231. {
  7232. //no event handler so cancel request
  7233. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7234. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7235. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7236. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7237. }
  7238. return true;
  7239. }
  7240. private AssetBase FindAssetInUserAssetServer(string id)
  7241. {
  7242. AgentCircuitData aCircuit = ((Scene)Scene).AuthenticateHandler.GetAgentCircuitData(CircuitCode);
  7243. if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
  7244. {
  7245. string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString();
  7246. return ((Scene)Scene).AssetService.Get(assetServer + "/" + id);
  7247. }
  7248. return null;
  7249. }
  7250. private bool HandleTeleportLocationRequest(IClientAPI sender, Packet Pack)
  7251. {
  7252. TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
  7253. // m_log.Debug(tpLocReq.ToString());
  7254. #region Packet Session and User Check
  7255. if (m_checkPackets)
  7256. {
  7257. if (tpLocReq.AgentData.SessionID != SessionId ||
  7258. tpLocReq.AgentData.AgentID != AgentId)
  7259. return true;
  7260. }
  7261. #endregion
  7262. TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest;
  7263. if (handlerTeleportLocationRequest != null)
  7264. {
  7265. handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position,
  7266. tpLocReq.Info.LookAt, 16);
  7267. }
  7268. else
  7269. {
  7270. //no event handler so cancel request
  7271. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7272. tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
  7273. tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
  7274. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7275. }
  7276. return true;
  7277. }
  7278. #endregion Inventory/Asset/Other related packets
  7279. private bool HandleUUIDNameRequest(IClientAPI sender, Packet Pack)
  7280. {
  7281. UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
  7282. foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
  7283. {
  7284. UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest;
  7285. if (handlerNameRequest != null)
  7286. {
  7287. handlerNameRequest(UUIDBlock.ID, this);
  7288. }
  7289. }
  7290. return true;
  7291. }
  7292. #region Parcel related packets
  7293. private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack)
  7294. {
  7295. RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
  7296. RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
  7297. if (handlerRegionHandleRequest != null)
  7298. {
  7299. handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID);
  7300. }
  7301. return true;
  7302. }
  7303. private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack)
  7304. {
  7305. ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack;
  7306. #region Packet Session and User Check
  7307. if (m_checkPackets)
  7308. {
  7309. if (pirPack.AgentData.SessionID != SessionId ||
  7310. pirPack.AgentData.AgentID != AgentId)
  7311. return true;
  7312. }
  7313. #endregion
  7314. ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest;
  7315. if (handlerParcelInfoRequest != null)
  7316. {
  7317. handlerParcelInfoRequest(this, pirPack.Data.ParcelID);
  7318. }
  7319. return true;
  7320. }
  7321. private bool HandleParcelAccessListRequest(IClientAPI sender, Packet Pack)
  7322. {
  7323. ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack;
  7324. #region Packet Session and User Check
  7325. if (m_checkPackets)
  7326. {
  7327. if (requestPacket.AgentData.SessionID != SessionId ||
  7328. requestPacket.AgentData.AgentID != AgentId)
  7329. return true;
  7330. }
  7331. #endregion
  7332. ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest;
  7333. if (handlerParcelAccessListRequest != null)
  7334. {
  7335. handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
  7336. requestPacket.Data.Flags, requestPacket.Data.SequenceID,
  7337. requestPacket.Data.LocalID, this);
  7338. }
  7339. return true;
  7340. }
  7341. private bool HandleParcelAccessListUpdate(IClientAPI sender, Packet Pack)
  7342. {
  7343. ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack;
  7344. #region Packet Session and User Check
  7345. if (m_checkPackets)
  7346. {
  7347. if (updatePacket.AgentData.SessionID != SessionId ||
  7348. updatePacket.AgentData.AgentID != AgentId)
  7349. return true;
  7350. }
  7351. #endregion
  7352. List<ParcelManager.ParcelAccessEntry> entries = new List<ParcelManager.ParcelAccessEntry>();
  7353. foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
  7354. {
  7355. ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
  7356. entry.AgentID = block.ID;
  7357. entry.Flags = (AccessList)block.Flags;
  7358. entry.Time = Util.ToDateTime(block.Time);
  7359. entries.Add(entry);
  7360. }
  7361. ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest;
  7362. if (handlerParcelAccessListUpdateRequest != null)
  7363. {
  7364. handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
  7365. updatePacket.Data.Flags,
  7366. updatePacket.Data.LocalID,
  7367. updatePacket.Data.TransactionID,
  7368. updatePacket.Data.SequenceID,
  7369. updatePacket.Data.Sections,
  7370. entries, this);
  7371. }
  7372. return true;
  7373. }
  7374. private bool HandleParcelPropertiesRequest(IClientAPI sender, Packet Pack)
  7375. {
  7376. ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
  7377. #region Packet Session and User Check
  7378. if (m_checkPackets)
  7379. {
  7380. if (propertiesRequest.AgentData.SessionID != SessionId ||
  7381. propertiesRequest.AgentData.AgentID != AgentId)
  7382. return true;
  7383. }
  7384. #endregion
  7385. ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest;
  7386. if (handlerParcelPropertiesRequest != null)
  7387. {
  7388. handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West),
  7389. (int)Math.Round(propertiesRequest.ParcelData.South),
  7390. (int)Math.Round(propertiesRequest.ParcelData.East),
  7391. (int)Math.Round(propertiesRequest.ParcelData.North),
  7392. propertiesRequest.ParcelData.SequenceID,
  7393. propertiesRequest.ParcelData.SnapSelection, this);
  7394. }
  7395. return true;
  7396. }
  7397. private bool HandleParcelDivide(IClientAPI sender, Packet Pack)
  7398. {
  7399. ParcelDividePacket landDivide = (ParcelDividePacket)Pack;
  7400. #region Packet Session and User Check
  7401. if (m_checkPackets)
  7402. {
  7403. if (landDivide.AgentData.SessionID != SessionId ||
  7404. landDivide.AgentData.AgentID != AgentId)
  7405. return true;
  7406. }
  7407. #endregion
  7408. ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest;
  7409. if (handlerParcelDivideRequest != null)
  7410. {
  7411. handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West),
  7412. (int)Math.Round(landDivide.ParcelData.South),
  7413. (int)Math.Round(landDivide.ParcelData.East),
  7414. (int)Math.Round(landDivide.ParcelData.North), this);
  7415. }
  7416. return true;
  7417. }
  7418. private bool HandleParcelJoin(IClientAPI sender, Packet Pack)
  7419. {
  7420. ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack;
  7421. #region Packet Session and User Check
  7422. if (m_checkPackets)
  7423. {
  7424. if (landJoin.AgentData.SessionID != SessionId ||
  7425. landJoin.AgentData.AgentID != AgentId)
  7426. return true;
  7427. }
  7428. #endregion
  7429. ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest;
  7430. if (handlerParcelJoinRequest != null)
  7431. {
  7432. handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West),
  7433. (int)Math.Round(landJoin.ParcelData.South),
  7434. (int)Math.Round(landJoin.ParcelData.East),
  7435. (int)Math.Round(landJoin.ParcelData.North), this);
  7436. }
  7437. return true;
  7438. }
  7439. private bool HandleParcelPropertiesUpdate(IClientAPI sender, Packet Pack)
  7440. {
  7441. ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack;
  7442. #region Packet Session and User Check
  7443. if (m_checkPackets)
  7444. {
  7445. if (parcelPropertiesPacket.AgentData.SessionID != SessionId ||
  7446. parcelPropertiesPacket.AgentData.AgentID != AgentId)
  7447. return true;
  7448. }
  7449. #endregion
  7450. ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest;
  7451. if (handlerParcelPropertiesUpdateRequest != null)
  7452. {
  7453. LandUpdateArgs args = new LandUpdateArgs();
  7454. args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID;
  7455. args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category;
  7456. args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc);
  7457. args.GroupID = parcelPropertiesPacket.ParcelData.GroupID;
  7458. args.LandingType = parcelPropertiesPacket.ParcelData.LandingType;
  7459. args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale;
  7460. args.MediaID = parcelPropertiesPacket.ParcelData.MediaID;
  7461. args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL);
  7462. args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL);
  7463. args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name);
  7464. args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags;
  7465. args.PassHours = parcelPropertiesPacket.ParcelData.PassHours;
  7466. args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice;
  7467. args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice;
  7468. args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID;
  7469. args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation;
  7470. args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt;
  7471. handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this);
  7472. }
  7473. return true;
  7474. }
  7475. private bool HandleParcelSelectObjects(IClientAPI sender, Packet Pack)
  7476. {
  7477. ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
  7478. #region Packet Session and User Check
  7479. if (m_checkPackets)
  7480. {
  7481. if (selectPacket.AgentData.SessionID != SessionId ||
  7482. selectPacket.AgentData.AgentID != AgentId)
  7483. return true;
  7484. }
  7485. #endregion
  7486. List<UUID> returnIDs = new List<UUID>();
  7487. foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in
  7488. selectPacket.ReturnIDs)
  7489. {
  7490. returnIDs.Add(rb.ReturnID);
  7491. }
  7492. ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects;
  7493. if (handlerParcelSelectObjects != null)
  7494. {
  7495. handlerParcelSelectObjects(selectPacket.ParcelData.LocalID,
  7496. Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this);
  7497. }
  7498. return true;
  7499. }
  7500. private bool HandleParcelObjectOwnersRequest(IClientAPI sender, Packet Pack)
  7501. {
  7502. ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
  7503. #region Packet Session and User Check
  7504. if (m_checkPackets)
  7505. {
  7506. if (reqPacket.AgentData.SessionID != SessionId ||
  7507. reqPacket.AgentData.AgentID != AgentId)
  7508. return true;
  7509. }
  7510. #endregion
  7511. ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest;
  7512. if (handlerParcelObjectOwnerRequest != null)
  7513. {
  7514. handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
  7515. }
  7516. return true;
  7517. }
  7518. private bool HandleParcelGodForceOwner(IClientAPI sender, Packet Pack)
  7519. {
  7520. ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack;
  7521. #region Packet Session and User Check
  7522. if (m_checkPackets)
  7523. {
  7524. if (godForceOwnerPacket.AgentData.SessionID != SessionId ||
  7525. godForceOwnerPacket.AgentData.AgentID != AgentId)
  7526. return true;
  7527. }
  7528. #endregion
  7529. ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner;
  7530. if (handlerParcelGodForceOwner != null)
  7531. {
  7532. handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this);
  7533. }
  7534. return true;
  7535. }
  7536. private bool HandleParcelRelease(IClientAPI sender, Packet Pack)
  7537. {
  7538. ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack;
  7539. #region Packet Session and User Check
  7540. if (m_checkPackets)
  7541. {
  7542. if (releasePacket.AgentData.SessionID != SessionId ||
  7543. releasePacket.AgentData.AgentID != AgentId)
  7544. return true;
  7545. }
  7546. #endregion
  7547. ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest;
  7548. if (handlerParcelAbandonRequest != null)
  7549. {
  7550. handlerParcelAbandonRequest(releasePacket.Data.LocalID, this);
  7551. }
  7552. return true;
  7553. }
  7554. private bool HandleParcelReclaim(IClientAPI sender, Packet Pack)
  7555. {
  7556. ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack;
  7557. #region Packet Session and User Check
  7558. if (m_checkPackets)
  7559. {
  7560. if (reclaimPacket.AgentData.SessionID != SessionId ||
  7561. reclaimPacket.AgentData.AgentID != AgentId)
  7562. return true;
  7563. }
  7564. #endregion
  7565. ParcelReclaim handlerParcelReclaim = OnParcelReclaim;
  7566. if (handlerParcelReclaim != null)
  7567. {
  7568. handlerParcelReclaim(reclaimPacket.Data.LocalID, this);
  7569. }
  7570. return true;
  7571. }
  7572. private bool HandleParcelReturnObjects(IClientAPI sender, Packet Pack)
  7573. {
  7574. ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack;
  7575. #region Packet Session and User Check
  7576. if (m_checkPackets)
  7577. {
  7578. if (parcelReturnObjects.AgentData.SessionID != SessionId ||
  7579. parcelReturnObjects.AgentData.AgentID != AgentId)
  7580. return true;
  7581. }
  7582. #endregion
  7583. UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length];
  7584. for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++)
  7585. puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID;
  7586. UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length];
  7587. for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++)
  7588. puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID;
  7589. ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest;
  7590. if (handlerParcelReturnObjectsRequest != null)
  7591. {
  7592. handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this);
  7593. }
  7594. return true;
  7595. }
  7596. private bool HandleParcelSetOtherCleanTime(IClientAPI sender, Packet Pack)
  7597. {
  7598. ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack;
  7599. #region Packet Session and User Check
  7600. if (m_checkPackets)
  7601. {
  7602. if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId ||
  7603. parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId)
  7604. return true;
  7605. }
  7606. #endregion
  7607. ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime;
  7608. if (handlerParcelSetOtherCleanTime != null)
  7609. {
  7610. handlerParcelSetOtherCleanTime(this,
  7611. parcelSetOtherCleanTimePacket.ParcelData.LocalID,
  7612. parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime);
  7613. }
  7614. return true;
  7615. }
  7616. private bool HandleLandStatRequest(IClientAPI sender, Packet Pack)
  7617. {
  7618. LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack;
  7619. #region Packet Session and User Check
  7620. if (m_checkPackets)
  7621. {
  7622. if (lsrp.AgentData.SessionID != SessionId ||
  7623. lsrp.AgentData.AgentID != AgentId)
  7624. return true;
  7625. }
  7626. #endregion
  7627. GodLandStatRequest handlerLandStatRequest = OnLandStatRequest;
  7628. if (handlerLandStatRequest != null)
  7629. {
  7630. handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this);
  7631. }
  7632. return true;
  7633. }
  7634. private bool HandleParcelDwellRequest(IClientAPI sender, Packet Pack)
  7635. {
  7636. ParcelDwellRequestPacket dwellrq =
  7637. (ParcelDwellRequestPacket)Pack;
  7638. #region Packet Session and User Check
  7639. if (m_checkPackets)
  7640. {
  7641. if (dwellrq.AgentData.SessionID != SessionId ||
  7642. dwellrq.AgentData.AgentID != AgentId)
  7643. return true;
  7644. }
  7645. #endregion
  7646. ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest;
  7647. if (handlerParcelDwellRequest != null)
  7648. {
  7649. handlerParcelDwellRequest(dwellrq.Data.LocalID, this);
  7650. }
  7651. return true;
  7652. }
  7653. #endregion Parcel related packets
  7654. #region Estate Packets
  7655. private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack)
  7656. {
  7657. EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
  7658. //m_log.Debug(messagePacket.ToString());
  7659. GodLandStatRequest handlerLandStatRequest;
  7660. #region Packet Session and User Check
  7661. if (m_checkPackets)
  7662. {
  7663. if (messagePacket.AgentData.SessionID != SessionId ||
  7664. messagePacket.AgentData.AgentID != AgentId)
  7665. return true;
  7666. }
  7667. #endregion
  7668. switch (Utils.BytesToString(messagePacket.MethodData.Method))
  7669. {
  7670. case "getinfo":
  7671. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7672. {
  7673. OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice);
  7674. }
  7675. return true;
  7676. case "setregioninfo":
  7677. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7678. {
  7679. OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter),
  7680. convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter),
  7681. Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)),
  7682. (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo),
  7683. Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)),
  7684. convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter));
  7685. }
  7686. return true;
  7687. // case "texturebase":
  7688. // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7689. // {
  7690. // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7691. // {
  7692. // string s = Utils.BytesToString(block.Parameter);
  7693. // string[] splitField = s.Split(' ');
  7694. // if (splitField.Length == 2)
  7695. // {
  7696. // UUID tempUUID = new UUID(splitField[1]);
  7697. // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID);
  7698. // }
  7699. // }
  7700. // }
  7701. // break;
  7702. case "texturedetail":
  7703. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7704. {
  7705. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7706. {
  7707. string s = Utils.BytesToString(block.Parameter);
  7708. string[] splitField = s.Split(' ');
  7709. if (splitField.Length == 2)
  7710. {
  7711. Int16 corner = Convert.ToInt16(splitField[0]);
  7712. UUID textureUUID = new UUID(splitField[1]);
  7713. OnSetEstateTerrainDetailTexture(this, corner, textureUUID);
  7714. }
  7715. }
  7716. }
  7717. return true;
  7718. case "textureheights":
  7719. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7720. {
  7721. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7722. {
  7723. string s = Utils.BytesToString(block.Parameter);
  7724. string[] splitField = s.Split(' ');
  7725. if (splitField.Length == 3)
  7726. {
  7727. Int16 corner = Convert.ToInt16(splitField[0]);
  7728. float lowValue = (float)Convert.ToDecimal(splitField[1], Culture.NumberFormatInfo);
  7729. float highValue = (float)Convert.ToDecimal(splitField[2], Culture.NumberFormatInfo);
  7730. OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue);
  7731. }
  7732. }
  7733. }
  7734. return true;
  7735. case "texturecommit":
  7736. OnCommitEstateTerrainTextureRequest(this);
  7737. return true;
  7738. case "setregionterrain":
  7739. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7740. {
  7741. if (messagePacket.ParamList.Length != 9)
  7742. {
  7743. m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
  7744. }
  7745. else
  7746. {
  7747. try
  7748. {
  7749. string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  7750. if (!tmp.Contains(".")) tmp += ".00";
  7751. float WaterHeight = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  7752. tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  7753. if (!tmp.Contains(".")) tmp += ".00";
  7754. float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  7755. tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter);
  7756. if (!tmp.Contains(".")) tmp += ".00";
  7757. float TerrainLowerLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  7758. bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter);
  7759. bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter);
  7760. float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo);
  7761. bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter);
  7762. bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter);
  7763. float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo);
  7764. OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour);
  7765. }
  7766. catch (Exception ex)
  7767. {
  7768. m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex);
  7769. }
  7770. }
  7771. }
  7772. return true;
  7773. case "restart":
  7774. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7775. {
  7776. // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
  7777. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7778. {
  7779. float timeSeconds;
  7780. Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds);
  7781. timeSeconds = (int)timeSeconds;
  7782. OnEstateRestartSimRequest(this, (int)timeSeconds);
  7783. }
  7784. }
  7785. return true;
  7786. case "estatechangecovenantid":
  7787. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7788. {
  7789. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7790. {
  7791. UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter));
  7792. OnEstateChangeCovenantRequest(this, newCovenantID);
  7793. }
  7794. }
  7795. return true;
  7796. case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
  7797. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7798. {
  7799. int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  7800. OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)));
  7801. }
  7802. return true;
  7803. case "simulatormessage":
  7804. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7805. {
  7806. UUID invoice = messagePacket.MethodData.Invoice;
  7807. UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  7808. string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  7809. string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  7810. UUID sessionID = messagePacket.AgentData.SessionID;
  7811. OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  7812. }
  7813. return true;
  7814. case "instantmessage":
  7815. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7816. {
  7817. if (messagePacket.ParamList.Length < 2)
  7818. return true;
  7819. UUID invoice = messagePacket.MethodData.Invoice;
  7820. UUID sessionID = messagePacket.AgentData.SessionID;
  7821. UUID SenderID;
  7822. string SenderName;
  7823. string Message;
  7824. if (messagePacket.ParamList.Length < 5)
  7825. {
  7826. SenderID = AgentId;
  7827. SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  7828. Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  7829. }
  7830. else
  7831. {
  7832. SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  7833. SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  7834. Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  7835. }
  7836. OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  7837. }
  7838. return true;
  7839. case "setregiondebug":
  7840. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7841. {
  7842. UUID invoice = messagePacket.MethodData.Invoice;
  7843. UUID SenderID = messagePacket.AgentData.AgentID;
  7844. bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter);
  7845. bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter);
  7846. bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter);
  7847. OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics);
  7848. }
  7849. return true;
  7850. case "teleporthomeuser":
  7851. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7852. {
  7853. UUID invoice = messagePacket.MethodData.Invoice;
  7854. UUID SenderID = messagePacket.AgentData.AgentID;
  7855. UUID Prey;
  7856. UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey);
  7857. OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
  7858. }
  7859. return true;
  7860. case "teleporthomeallusers":
  7861. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7862. {
  7863. UUID invoice = messagePacket.MethodData.Invoice;
  7864. UUID SenderID = messagePacket.AgentData.AgentID;
  7865. OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID);
  7866. }
  7867. return true;
  7868. case "colliders":
  7869. handlerLandStatRequest = OnLandStatRequest;
  7870. if (handlerLandStatRequest != null)
  7871. {
  7872. handlerLandStatRequest(0, 1, 0, "", this);
  7873. }
  7874. return true;
  7875. case "scripts":
  7876. handlerLandStatRequest = OnLandStatRequest;
  7877. if (handlerLandStatRequest != null)
  7878. {
  7879. handlerLandStatRequest(0, 0, 0, "", this);
  7880. }
  7881. return true;
  7882. case "terrain":
  7883. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7884. {
  7885. if (messagePacket.ParamList.Length > 0)
  7886. {
  7887. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake")
  7888. {
  7889. BakeTerrain handlerBakeTerrain = OnBakeTerrain;
  7890. if (handlerBakeTerrain != null)
  7891. {
  7892. handlerBakeTerrain(this);
  7893. }
  7894. }
  7895. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename")
  7896. {
  7897. if (messagePacket.ParamList.Length > 1)
  7898. {
  7899. RequestTerrain handlerRequestTerrain = OnRequestTerrain;
  7900. if (handlerRequestTerrain != null)
  7901. {
  7902. handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  7903. }
  7904. }
  7905. }
  7906. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename")
  7907. {
  7908. if (messagePacket.ParamList.Length > 1)
  7909. {
  7910. RequestTerrain handlerUploadTerrain = OnUploadTerrain;
  7911. if (handlerUploadTerrain != null)
  7912. {
  7913. handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  7914. }
  7915. }
  7916. }
  7917. }
  7918. }
  7919. return true;
  7920. case "estatechangeinfo":
  7921. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7922. {
  7923. UUID invoice = messagePacket.MethodData.Invoice;
  7924. UUID SenderID = messagePacket.AgentData.AgentID;
  7925. UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  7926. UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  7927. EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo;
  7928. if (handlerEstateChangeInfo != null)
  7929. {
  7930. handlerEstateChangeInfo(this, invoice, SenderID, param1, param2);
  7931. }
  7932. }
  7933. return true;
  7934. default:
  7935. m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket);
  7936. return true;
  7937. }
  7938. //int parcelID, uint reportType, uint requestflags, string filter
  7939. //lsrp.RequestData.ParcelLocalID;
  7940. //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts
  7941. //lsrp.RequestData.RequestFlags;
  7942. //lsrp.RequestData.Filter;
  7943. // return true;
  7944. }
  7945. private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack)
  7946. {
  7947. RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData;
  7948. #region Packet Session and User Check
  7949. if (m_checkPackets)
  7950. {
  7951. if (mPacket.SessionID != SessionId ||
  7952. mPacket.AgentID != AgentId)
  7953. return true;
  7954. }
  7955. #endregion
  7956. RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest;
  7957. if (handlerRegionInfoRequest != null)
  7958. {
  7959. handlerRegionInfoRequest(this);
  7960. }
  7961. return true;
  7962. }
  7963. private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack)
  7964. {
  7965. //EstateCovenantRequestPacket.AgentDataBlock epack =
  7966. // ((EstateCovenantRequestPacket)Pack).AgentData;
  7967. EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest;
  7968. if (handlerEstateCovenantRequest != null)
  7969. {
  7970. handlerEstateCovenantRequest(this);
  7971. }
  7972. return true;
  7973. }
  7974. #endregion Estate Packets
  7975. #region GodPackets
  7976. private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack)
  7977. {
  7978. RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack;
  7979. RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
  7980. UUID token = rblock.Token;
  7981. RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
  7982. RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers;
  7983. if (handlerReqGodlikePowers != null)
  7984. {
  7985. handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this);
  7986. }
  7987. return true;
  7988. }
  7989. private bool HandleGodUpdateRegionInfoUpdate(IClientAPI client, Packet Packet)
  7990. {
  7991. GodUpdateRegionInfoPacket GodUpdateRegionInfo =
  7992. (GodUpdateRegionInfoPacket)Packet;
  7993. GodUpdateRegionInfoUpdate handlerGodUpdateRegionInfo = OnGodUpdateRegionInfoUpdate;
  7994. if (handlerGodUpdateRegionInfo != null)
  7995. {
  7996. handlerGodUpdateRegionInfo(this,
  7997. GodUpdateRegionInfo.RegionInfo.BillableFactor,
  7998. GodUpdateRegionInfo.RegionInfo.EstateID,
  7999. GodUpdateRegionInfo.RegionInfo.RegionFlags,
  8000. GodUpdateRegionInfo.RegionInfo.SimName,
  8001. GodUpdateRegionInfo.RegionInfo.RedirectGridX,
  8002. GodUpdateRegionInfo.RegionInfo.RedirectGridY);
  8003. return true;
  8004. }
  8005. return false;
  8006. }
  8007. private bool HandleSimWideDeletes(IClientAPI client, Packet Packet)
  8008. {
  8009. SimWideDeletesPacket SimWideDeletesRequest =
  8010. (SimWideDeletesPacket)Packet;
  8011. SimWideDeletesDelegate handlerSimWideDeletesRequest = OnSimWideDeletes;
  8012. if (handlerSimWideDeletesRequest != null)
  8013. {
  8014. handlerSimWideDeletesRequest(this, SimWideDeletesRequest.AgentData.AgentID,(int)SimWideDeletesRequest.DataBlock.Flags,SimWideDeletesRequest.DataBlock.TargetID);
  8015. return true;
  8016. }
  8017. return false;
  8018. }
  8019. private bool HandleGodlikeMessage(IClientAPI client, Packet Packet)
  8020. {
  8021. GodlikeMessagePacket GodlikeMessage =
  8022. (GodlikeMessagePacket)Packet;
  8023. GodlikeMessage handlerGodlikeMessage = onGodlikeMessage;
  8024. if (handlerGodlikeMessage != null)
  8025. {
  8026. handlerGodlikeMessage(this,
  8027. GodlikeMessage.MethodData.Invoice,
  8028. GodlikeMessage.MethodData.Method,
  8029. GodlikeMessage.ParamList[0].Parameter);
  8030. return true;
  8031. }
  8032. return false;
  8033. }
  8034. private bool HandleSaveStatePacket(IClientAPI client, Packet Packet)
  8035. {
  8036. StateSavePacket SaveStateMessage =
  8037. (StateSavePacket)Packet;
  8038. SaveStateHandler handlerSaveStatePacket = OnSaveState;
  8039. if (handlerSaveStatePacket != null)
  8040. {
  8041. handlerSaveStatePacket(this,SaveStateMessage.AgentData.AgentID);
  8042. return true;
  8043. }
  8044. return false;
  8045. }
  8046. private bool HandleGodKickUser(IClientAPI sender, Packet Pack)
  8047. {
  8048. GodKickUserPacket gkupack = (GodKickUserPacket)Pack;
  8049. if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID)
  8050. {
  8051. GodKickUser handlerGodKickUser = OnGodKickUser;
  8052. if (handlerGodKickUser != null)
  8053. {
  8054. handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
  8055. gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason);
  8056. }
  8057. }
  8058. else
  8059. {
  8060. SendAgentAlertMessage("Kick request denied", false);
  8061. }
  8062. //KickUserPacket kupack = new KickUserPacket();
  8063. //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo;
  8064. //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID;
  8065. //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID;
  8066. //kupack.TargetBlock.TargetIP = (uint)0;
  8067. //kupack.TargetBlock.TargetPort = (ushort)0;
  8068. //kupack.UserInfo.Reason = gkupack.UserInfo.Reason;
  8069. //OutPacket(kupack, ThrottleOutPacketType.Task);
  8070. return true;
  8071. }
  8072. #endregion GodPackets
  8073. #region Economy/Transaction Packets
  8074. private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack)
  8075. {
  8076. MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
  8077. #region Packet Session and User Check
  8078. if (m_checkPackets)
  8079. {
  8080. if (moneybalancerequestpacket.AgentData.SessionID != SessionId ||
  8081. moneybalancerequestpacket.AgentData.AgentID != AgentId)
  8082. return true;
  8083. }
  8084. #endregion
  8085. MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest;
  8086. if (handlerMoneyBalanceRequest != null)
  8087. {
  8088. handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
  8089. }
  8090. return true;
  8091. }
  8092. private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack)
  8093. {
  8094. EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest;
  8095. if (handlerEconomoyDataRequest != null)
  8096. {
  8097. handlerEconomoyDataRequest(AgentId);
  8098. }
  8099. return true;
  8100. }
  8101. private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack)
  8102. {
  8103. RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack;
  8104. RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice;
  8105. if (handlerRequestPayPrice != null)
  8106. {
  8107. handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID);
  8108. }
  8109. return true;
  8110. }
  8111. private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack)
  8112. {
  8113. ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack;
  8114. #region Packet Session and User Check
  8115. if (m_checkPackets)
  8116. {
  8117. if (objectSaleInfoPacket.AgentData.SessionID != SessionId ||
  8118. objectSaleInfoPacket.AgentData.AgentID != AgentId)
  8119. return true;
  8120. }
  8121. #endregion
  8122. ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo;
  8123. if (handlerObjectSaleInfo != null)
  8124. {
  8125. foreach (ObjectSaleInfoPacket.ObjectDataBlock d
  8126. in objectSaleInfoPacket.ObjectData)
  8127. {
  8128. handlerObjectSaleInfo(this,
  8129. objectSaleInfoPacket.AgentData.AgentID,
  8130. objectSaleInfoPacket.AgentData.SessionID,
  8131. d.LocalID,
  8132. d.SaleType,
  8133. d.SalePrice);
  8134. }
  8135. }
  8136. return true;
  8137. }
  8138. private bool HandleObjectBuy(IClientAPI sender, Packet Pack)
  8139. {
  8140. ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack;
  8141. #region Packet Session and User Check
  8142. if (m_checkPackets)
  8143. {
  8144. if (objectBuyPacket.AgentData.SessionID != SessionId ||
  8145. objectBuyPacket.AgentData.AgentID != AgentId)
  8146. return true;
  8147. }
  8148. #endregion
  8149. ObjectBuy handlerObjectBuy = OnObjectBuy;
  8150. if (handlerObjectBuy != null)
  8151. {
  8152. foreach (ObjectBuyPacket.ObjectDataBlock d
  8153. in objectBuyPacket.ObjectData)
  8154. {
  8155. handlerObjectBuy(this,
  8156. objectBuyPacket.AgentData.AgentID,
  8157. objectBuyPacket.AgentData.SessionID,
  8158. objectBuyPacket.AgentData.GroupID,
  8159. objectBuyPacket.AgentData.CategoryID,
  8160. d.ObjectLocalID,
  8161. d.SaleType,
  8162. d.SalePrice);
  8163. }
  8164. }
  8165. return true;
  8166. }
  8167. #endregion Economy/Transaction Packets
  8168. #region Script Packets
  8169. private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack)
  8170. {
  8171. GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack;
  8172. GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning;
  8173. if (handlerGetScriptRunning != null)
  8174. {
  8175. handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID);
  8176. }
  8177. return true;
  8178. }
  8179. private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack)
  8180. {
  8181. SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack;
  8182. #region Packet Session and User Check
  8183. if (m_checkPackets)
  8184. {
  8185. if (setScriptRunning.AgentData.SessionID != SessionId ||
  8186. setScriptRunning.AgentData.AgentID != AgentId)
  8187. return true;
  8188. }
  8189. #endregion
  8190. SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning;
  8191. if (handlerSetScriptRunning != null)
  8192. {
  8193. handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running);
  8194. }
  8195. return true;
  8196. }
  8197. private bool HandleScriptReset(IClientAPI sender, Packet Pack)
  8198. {
  8199. ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack;
  8200. #region Packet Session and User Check
  8201. if (m_checkPackets)
  8202. {
  8203. if (scriptResetPacket.AgentData.SessionID != SessionId ||
  8204. scriptResetPacket.AgentData.AgentID != AgentId)
  8205. return true;
  8206. }
  8207. #endregion
  8208. ScriptReset handlerScriptReset = OnScriptReset;
  8209. if (handlerScriptReset != null)
  8210. {
  8211. handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID);
  8212. }
  8213. return true;
  8214. }
  8215. #endregion Script Packets
  8216. #region Gesture Managment
  8217. private bool HandleActivateGestures(IClientAPI sender, Packet Pack)
  8218. {
  8219. ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack;
  8220. #region Packet Session and User Check
  8221. if (m_checkPackets)
  8222. {
  8223. if (activateGesturePacket.AgentData.SessionID != SessionId ||
  8224. activateGesturePacket.AgentData.AgentID != AgentId)
  8225. return true;
  8226. }
  8227. #endregion
  8228. ActivateGesture handlerActivateGesture = OnActivateGesture;
  8229. if (handlerActivateGesture != null)
  8230. {
  8231. handlerActivateGesture(this,
  8232. activateGesturePacket.Data[0].AssetID,
  8233. activateGesturePacket.Data[0].ItemID);
  8234. }
  8235. else m_log.Error("Null pointer for activateGesture");
  8236. return true;
  8237. }
  8238. private bool HandleDeactivateGestures(IClientAPI sender, Packet Pack)
  8239. {
  8240. DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack;
  8241. #region Packet Session and User Check
  8242. if (m_checkPackets)
  8243. {
  8244. if (deactivateGesturePacket.AgentData.SessionID != SessionId ||
  8245. deactivateGesturePacket.AgentData.AgentID != AgentId)
  8246. return true;
  8247. }
  8248. #endregion
  8249. DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture;
  8250. if (handlerDeactivateGesture != null)
  8251. {
  8252. handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID);
  8253. }
  8254. return true;
  8255. }
  8256. private bool HandleObjectOwner(IClientAPI sender, Packet Pack)
  8257. {
  8258. ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack;
  8259. #region Packet Session and User Check
  8260. if (m_checkPackets)
  8261. {
  8262. if (objectOwnerPacket.AgentData.SessionID != SessionId ||
  8263. objectOwnerPacket.AgentData.AgentID != AgentId)
  8264. return true;
  8265. }
  8266. #endregion
  8267. List<uint> localIDs = new List<uint>();
  8268. foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData)
  8269. localIDs.Add(d.ObjectLocalID);
  8270. ObjectOwner handlerObjectOwner = OnObjectOwner;
  8271. if (handlerObjectOwner != null)
  8272. {
  8273. handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs);
  8274. }
  8275. return true;
  8276. }
  8277. #endregion Gesture Managment
  8278. private bool HandleAgentFOV(IClientAPI sender, Packet Pack)
  8279. {
  8280. AgentFOVPacket fovPacket = (AgentFOVPacket)Pack;
  8281. if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter)
  8282. {
  8283. m_agentFOVCounter = fovPacket.FOVBlock.GenCounter;
  8284. AgentFOV handlerAgentFOV = OnAgentFOV;
  8285. if (handlerAgentFOV != null)
  8286. {
  8287. handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle);
  8288. }
  8289. }
  8290. return true;
  8291. }
  8292. #region unimplemented handlers
  8293. private bool HandleViewerStats(IClientAPI sender, Packet Pack)
  8294. {
  8295. // TODO: handle this packet
  8296. //m_log.Warn("[CLIENT]: unhandled ViewerStats packet");
  8297. return true;
  8298. }
  8299. private bool HandleMapItemRequest(IClientAPI sender, Packet Pack)
  8300. {
  8301. MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack;
  8302. #region Packet Session and User Check
  8303. if (m_checkPackets)
  8304. {
  8305. if (mirpk.AgentData.SessionID != SessionId ||
  8306. mirpk.AgentData.AgentID != AgentId)
  8307. return true;
  8308. }
  8309. #endregion
  8310. //m_log.Debug(mirpk.ToString());
  8311. MapItemRequest handlerMapItemRequest = OnMapItemRequest;
  8312. if (handlerMapItemRequest != null)
  8313. {
  8314. handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID,
  8315. mirpk.AgentData.Godlike, mirpk.RequestData.ItemType,
  8316. mirpk.RequestData.RegionHandle);
  8317. }
  8318. return true;
  8319. }
  8320. private bool HandleTransferAbort(IClientAPI sender, Packet Pack)
  8321. {
  8322. return true;
  8323. }
  8324. private bool HandleMuteListRequest(IClientAPI sender, Packet Pack)
  8325. {
  8326. MuteListRequestPacket muteListRequest =
  8327. (MuteListRequestPacket)Pack;
  8328. #region Packet Session and User Check
  8329. if (m_checkPackets)
  8330. {
  8331. if (muteListRequest.AgentData.SessionID != SessionId ||
  8332. muteListRequest.AgentData.AgentID != AgentId)
  8333. return true;
  8334. }
  8335. #endregion
  8336. MuteListRequest handlerMuteListRequest = OnMuteListRequest;
  8337. if (handlerMuteListRequest != null)
  8338. {
  8339. handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC);
  8340. }
  8341. else
  8342. {
  8343. SendUseCachedMuteList();
  8344. }
  8345. return true;
  8346. }
  8347. private bool HandleUpdateMuteListEntry(IClientAPI client, Packet Packet)
  8348. {
  8349. UpdateMuteListEntryPacket UpdateMuteListEntry =
  8350. (UpdateMuteListEntryPacket)Packet;
  8351. MuteListEntryUpdate handlerUpdateMuteListEntry = OnUpdateMuteListEntry;
  8352. if (handlerUpdateMuteListEntry != null)
  8353. {
  8354. handlerUpdateMuteListEntry(this, UpdateMuteListEntry.MuteData.MuteID,
  8355. Utils.BytesToString(UpdateMuteListEntry.MuteData.MuteName),
  8356. UpdateMuteListEntry.MuteData.MuteType,
  8357. UpdateMuteListEntry.AgentData.AgentID);
  8358. return true;
  8359. }
  8360. return false;
  8361. }
  8362. private bool HandleRemoveMuteListEntry(IClientAPI client, Packet Packet)
  8363. {
  8364. RemoveMuteListEntryPacket RemoveMuteListEntry =
  8365. (RemoveMuteListEntryPacket)Packet;
  8366. MuteListEntryRemove handlerRemoveMuteListEntry = OnRemoveMuteListEntry;
  8367. if (handlerRemoveMuteListEntry != null)
  8368. {
  8369. handlerRemoveMuteListEntry(this,
  8370. RemoveMuteListEntry.MuteData.MuteID,
  8371. Utils.BytesToString(RemoveMuteListEntry.MuteData.MuteName),
  8372. RemoveMuteListEntry.AgentData.AgentID);
  8373. return true;
  8374. }
  8375. return false;
  8376. }
  8377. private bool HandleUserReport(IClientAPI client, Packet Packet)
  8378. {
  8379. UserReportPacket UserReport =
  8380. (UserReportPacket)Packet;
  8381. NewUserReport handlerUserReport = OnUserReport;
  8382. if (handlerUserReport != null)
  8383. {
  8384. handlerUserReport(this,
  8385. Utils.BytesToString(UserReport.ReportData.AbuseRegionName),
  8386. UserReport.ReportData.AbuserID,
  8387. UserReport.ReportData.Category,
  8388. UserReport.ReportData.CheckFlags,
  8389. Utils.BytesToString(UserReport.ReportData.Details),
  8390. UserReport.ReportData.ObjectID,
  8391. UserReport.ReportData.Position,
  8392. UserReport.ReportData.ReportType,
  8393. UserReport.ReportData.ScreenshotID,
  8394. Utils.BytesToString(UserReport.ReportData.Summary),
  8395. UserReport.AgentData.AgentID);
  8396. return true;
  8397. }
  8398. return false;
  8399. }
  8400. private bool HandleSendPostcard(IClientAPI client, Packet packet)
  8401. {
  8402. // SendPostcardPacket SendPostcard =
  8403. // (SendPostcardPacket)packet;
  8404. SendPostcard handlerSendPostcard = OnSendPostcard;
  8405. if (handlerSendPostcard != null)
  8406. {
  8407. handlerSendPostcard(this);
  8408. return true;
  8409. }
  8410. return false;
  8411. }
  8412. private bool HandleUseCircuitCode(IClientAPI sender, Packet Pack)
  8413. {
  8414. return true;
  8415. }
  8416. private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
  8417. {
  8418. return true;
  8419. }
  8420. private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack)
  8421. {
  8422. return true;
  8423. }
  8424. #endregion unimplemented handlers
  8425. #region Dir handlers
  8426. private bool HandleDirPlacesQuery(IClientAPI sender, Packet Pack)
  8427. {
  8428. DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack;
  8429. //m_log.Debug(dirPlacesQueryPacket.ToString());
  8430. #region Packet Session and User Check
  8431. if (m_checkPackets)
  8432. {
  8433. if (dirPlacesQueryPacket.AgentData.SessionID != SessionId ||
  8434. dirPlacesQueryPacket.AgentData.AgentID != AgentId)
  8435. return true;
  8436. }
  8437. #endregion
  8438. DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery;
  8439. if (handlerDirPlacesQuery != null)
  8440. {
  8441. handlerDirPlacesQuery(this,
  8442. dirPlacesQueryPacket.QueryData.QueryID,
  8443. Utils.BytesToString(
  8444. dirPlacesQueryPacket.QueryData.QueryText),
  8445. (int)dirPlacesQueryPacket.QueryData.QueryFlags,
  8446. (int)dirPlacesQueryPacket.QueryData.Category,
  8447. Utils.BytesToString(
  8448. dirPlacesQueryPacket.QueryData.SimName),
  8449. dirPlacesQueryPacket.QueryData.QueryStart);
  8450. }
  8451. return true;
  8452. }
  8453. private bool HandleDirFindQuery(IClientAPI sender, Packet Pack)
  8454. {
  8455. DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack;
  8456. #region Packet Session and User Check
  8457. if (m_checkPackets)
  8458. {
  8459. if (dirFindQueryPacket.AgentData.SessionID != SessionId ||
  8460. dirFindQueryPacket.AgentData.AgentID != AgentId)
  8461. return true;
  8462. }
  8463. #endregion
  8464. DirFindQuery handlerDirFindQuery = OnDirFindQuery;
  8465. if (handlerDirFindQuery != null)
  8466. {
  8467. handlerDirFindQuery(this,
  8468. dirFindQueryPacket.QueryData.QueryID,
  8469. Utils.BytesToString(
  8470. dirFindQueryPacket.QueryData.QueryText),
  8471. dirFindQueryPacket.QueryData.QueryFlags,
  8472. dirFindQueryPacket.QueryData.QueryStart);
  8473. }
  8474. return true;
  8475. }
  8476. private bool HandleDirLandQuery(IClientAPI sender, Packet Pack)
  8477. {
  8478. DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack;
  8479. #region Packet Session and User Check
  8480. if (m_checkPackets)
  8481. {
  8482. if (dirLandQueryPacket.AgentData.SessionID != SessionId ||
  8483. dirLandQueryPacket.AgentData.AgentID != AgentId)
  8484. return true;
  8485. }
  8486. #endregion
  8487. DirLandQuery handlerDirLandQuery = OnDirLandQuery;
  8488. if (handlerDirLandQuery != null)
  8489. {
  8490. handlerDirLandQuery(this,
  8491. dirLandQueryPacket.QueryData.QueryID,
  8492. dirLandQueryPacket.QueryData.QueryFlags,
  8493. dirLandQueryPacket.QueryData.SearchType,
  8494. dirLandQueryPacket.QueryData.Price,
  8495. dirLandQueryPacket.QueryData.Area,
  8496. dirLandQueryPacket.QueryData.QueryStart);
  8497. }
  8498. return true;
  8499. }
  8500. private bool HandleDirPopularQuery(IClientAPI sender, Packet Pack)
  8501. {
  8502. DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack;
  8503. #region Packet Session and User Check
  8504. if (m_checkPackets)
  8505. {
  8506. if (dirPopularQueryPacket.AgentData.SessionID != SessionId ||
  8507. dirPopularQueryPacket.AgentData.AgentID != AgentId)
  8508. return true;
  8509. }
  8510. #endregion
  8511. DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery;
  8512. if (handlerDirPopularQuery != null)
  8513. {
  8514. handlerDirPopularQuery(this,
  8515. dirPopularQueryPacket.QueryData.QueryID,
  8516. dirPopularQueryPacket.QueryData.QueryFlags);
  8517. }
  8518. return true;
  8519. }
  8520. private bool HandleDirClassifiedQuery(IClientAPI sender, Packet Pack)
  8521. {
  8522. DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack;
  8523. #region Packet Session and User Check
  8524. if (m_checkPackets)
  8525. {
  8526. if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId ||
  8527. dirClassifiedQueryPacket.AgentData.AgentID != AgentId)
  8528. return true;
  8529. }
  8530. #endregion
  8531. DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery;
  8532. if (handlerDirClassifiedQuery != null)
  8533. {
  8534. handlerDirClassifiedQuery(this,
  8535. dirClassifiedQueryPacket.QueryData.QueryID,
  8536. Utils.BytesToString(
  8537. dirClassifiedQueryPacket.QueryData.QueryText),
  8538. dirClassifiedQueryPacket.QueryData.QueryFlags,
  8539. dirClassifiedQueryPacket.QueryData.Category,
  8540. dirClassifiedQueryPacket.QueryData.QueryStart);
  8541. }
  8542. return true;
  8543. }
  8544. private bool HandleEventInfoRequest(IClientAPI sender, Packet Pack)
  8545. {
  8546. EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack;
  8547. #region Packet Session and User Check
  8548. if (m_checkPackets)
  8549. {
  8550. if (eventInfoRequestPacket.AgentData.SessionID != SessionId ||
  8551. eventInfoRequestPacket.AgentData.AgentID != AgentId)
  8552. return true;
  8553. }
  8554. #endregion
  8555. if (OnEventInfoRequest != null)
  8556. {
  8557. OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID);
  8558. }
  8559. return true;
  8560. }
  8561. #endregion
  8562. #region Calling Card
  8563. private bool HandleOfferCallingCard(IClientAPI sender, Packet Pack)
  8564. {
  8565. OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack;
  8566. #region Packet Session and User Check
  8567. if (m_checkPackets)
  8568. {
  8569. if (offerCallingCardPacket.AgentData.SessionID != SessionId ||
  8570. offerCallingCardPacket.AgentData.AgentID != AgentId)
  8571. return true;
  8572. }
  8573. #endregion
  8574. if (OnOfferCallingCard != null)
  8575. {
  8576. OnOfferCallingCard(this,
  8577. offerCallingCardPacket.AgentBlock.DestID,
  8578. offerCallingCardPacket.AgentBlock.TransactionID);
  8579. }
  8580. return true;
  8581. }
  8582. private bool HandleAcceptCallingCard(IClientAPI sender, Packet Pack)
  8583. {
  8584. AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack;
  8585. #region Packet Session and User Check
  8586. if (m_checkPackets)
  8587. {
  8588. if (acceptCallingCardPacket.AgentData.SessionID != SessionId ||
  8589. acceptCallingCardPacket.AgentData.AgentID != AgentId)
  8590. return true;
  8591. }
  8592. #endregion
  8593. // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should
  8594. // contain exactly one entry
  8595. if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0)
  8596. {
  8597. OnAcceptCallingCard(this,
  8598. acceptCallingCardPacket.TransactionBlock.TransactionID,
  8599. acceptCallingCardPacket.FolderData[0].FolderID);
  8600. }
  8601. return true;
  8602. }
  8603. private bool HandleDeclineCallingCard(IClientAPI sender, Packet Pack)
  8604. {
  8605. DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack;
  8606. #region Packet Session and User Check
  8607. if (m_checkPackets)
  8608. {
  8609. if (declineCallingCardPacket.AgentData.SessionID != SessionId ||
  8610. declineCallingCardPacket.AgentData.AgentID != AgentId)
  8611. return true;
  8612. }
  8613. #endregion
  8614. if (OnDeclineCallingCard != null)
  8615. {
  8616. OnDeclineCallingCard(this,
  8617. declineCallingCardPacket.TransactionBlock.TransactionID);
  8618. }
  8619. return true;
  8620. }
  8621. #endregion Calling Card
  8622. #region Groups
  8623. private bool HandleActivateGroup(IClientAPI sender, Packet Pack)
  8624. {
  8625. ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack;
  8626. #region Packet Session and User Check
  8627. if (m_checkPackets)
  8628. {
  8629. if (activateGroupPacket.AgentData.SessionID != SessionId ||
  8630. activateGroupPacket.AgentData.AgentID != AgentId)
  8631. return true;
  8632. }
  8633. #endregion
  8634. if (m_GroupsModule != null)
  8635. {
  8636. m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID);
  8637. m_GroupsModule.SendAgentGroupDataUpdate(this);
  8638. }
  8639. return true;
  8640. }
  8641. private bool HandleGroupVoteHistoryRequest(IClientAPI client, Packet Packet)
  8642. {
  8643. GroupVoteHistoryRequestPacket GroupVoteHistoryRequest =
  8644. (GroupVoteHistoryRequestPacket)Packet;
  8645. GroupVoteHistoryRequest handlerGroupVoteHistoryRequest = OnGroupVoteHistoryRequest;
  8646. if (handlerGroupVoteHistoryRequest != null)
  8647. {
  8648. handlerGroupVoteHistoryRequest(this, GroupVoteHistoryRequest.AgentData.AgentID,GroupVoteHistoryRequest.AgentData.SessionID,GroupVoteHistoryRequest.GroupData.GroupID,GroupVoteHistoryRequest.TransactionData.TransactionID);
  8649. return true;
  8650. }
  8651. return false;
  8652. }
  8653. private bool HandleGroupActiveProposalsRequest(IClientAPI client, Packet Packet)
  8654. {
  8655. GroupActiveProposalsRequestPacket GroupActiveProposalsRequest =
  8656. (GroupActiveProposalsRequestPacket)Packet;
  8657. GroupActiveProposalsRequest handlerGroupActiveProposalsRequest = OnGroupActiveProposalsRequest;
  8658. if (handlerGroupActiveProposalsRequest != null)
  8659. {
  8660. handlerGroupActiveProposalsRequest(this, GroupActiveProposalsRequest.AgentData.AgentID,GroupActiveProposalsRequest.AgentData.SessionID,GroupActiveProposalsRequest.GroupData.GroupID,GroupActiveProposalsRequest.TransactionData.TransactionID);
  8661. return true;
  8662. }
  8663. return false;
  8664. }
  8665. private bool HandleGroupAccountDetailsRequest(IClientAPI client, Packet Packet)
  8666. {
  8667. GroupAccountDetailsRequestPacket GroupAccountDetailsRequest =
  8668. (GroupAccountDetailsRequestPacket)Packet;
  8669. GroupAccountDetailsRequest handlerGroupAccountDetailsRequest = OnGroupAccountDetailsRequest;
  8670. if (handlerGroupAccountDetailsRequest != null)
  8671. {
  8672. handlerGroupAccountDetailsRequest(this, GroupAccountDetailsRequest.AgentData.AgentID,GroupAccountDetailsRequest.AgentData.GroupID,GroupAccountDetailsRequest.MoneyData.RequestID,GroupAccountDetailsRequest.AgentData.SessionID);
  8673. return true;
  8674. }
  8675. return false;
  8676. }
  8677. private bool HandleGroupAccountSummaryRequest(IClientAPI client, Packet Packet)
  8678. {
  8679. GroupAccountSummaryRequestPacket GroupAccountSummaryRequest =
  8680. (GroupAccountSummaryRequestPacket)Packet;
  8681. GroupAccountSummaryRequest handlerGroupAccountSummaryRequest = OnGroupAccountSummaryRequest;
  8682. if (handlerGroupAccountSummaryRequest != null)
  8683. {
  8684. handlerGroupAccountSummaryRequest(this, GroupAccountSummaryRequest.AgentData.AgentID,GroupAccountSummaryRequest.AgentData.GroupID);
  8685. return true;
  8686. }
  8687. return false;
  8688. }
  8689. private bool HandleGroupTransactionsDetailsRequest(IClientAPI client, Packet Packet)
  8690. {
  8691. GroupAccountTransactionsRequestPacket GroupAccountTransactionsRequest =
  8692. (GroupAccountTransactionsRequestPacket)Packet;
  8693. GroupAccountTransactionsRequest handlerGroupAccountTransactionsRequest = OnGroupAccountTransactionsRequest;
  8694. if (handlerGroupAccountTransactionsRequest != null)
  8695. {
  8696. handlerGroupAccountTransactionsRequest(this, GroupAccountTransactionsRequest.AgentData.AgentID,GroupAccountTransactionsRequest.AgentData.GroupID,GroupAccountTransactionsRequest.MoneyData.RequestID,GroupAccountTransactionsRequest.AgentData.SessionID);
  8697. return true;
  8698. }
  8699. return false;
  8700. }
  8701. private bool HandleGroupTitlesRequest(IClientAPI sender, Packet Pack)
  8702. {
  8703. GroupTitlesRequestPacket groupTitlesRequest =
  8704. (GroupTitlesRequestPacket)Pack;
  8705. #region Packet Session and User Check
  8706. if (m_checkPackets)
  8707. {
  8708. if (groupTitlesRequest.AgentData.SessionID != SessionId ||
  8709. groupTitlesRequest.AgentData.AgentID != AgentId)
  8710. return true;
  8711. }
  8712. #endregion
  8713. if (m_GroupsModule != null)
  8714. {
  8715. GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply);
  8716. groupTitlesReply.AgentData =
  8717. new GroupTitlesReplyPacket.AgentDataBlock();
  8718. groupTitlesReply.AgentData.AgentID = AgentId;
  8719. groupTitlesReply.AgentData.GroupID =
  8720. groupTitlesRequest.AgentData.GroupID;
  8721. groupTitlesReply.AgentData.RequestID =
  8722. groupTitlesRequest.AgentData.RequestID;
  8723. List<GroupTitlesData> titles =
  8724. m_GroupsModule.GroupTitlesRequest(this,
  8725. groupTitlesRequest.AgentData.GroupID);
  8726. groupTitlesReply.GroupData =
  8727. new GroupTitlesReplyPacket.GroupDataBlock[titles.Count];
  8728. int i = 0;
  8729. foreach (GroupTitlesData d in titles)
  8730. {
  8731. groupTitlesReply.GroupData[i] =
  8732. new GroupTitlesReplyPacket.GroupDataBlock();
  8733. groupTitlesReply.GroupData[i].Title =
  8734. Util.StringToBytes256(d.Name);
  8735. groupTitlesReply.GroupData[i].RoleID =
  8736. d.UUID;
  8737. groupTitlesReply.GroupData[i].Selected =
  8738. d.Selected;
  8739. i++;
  8740. }
  8741. OutPacket(groupTitlesReply, ThrottleOutPacketType.Task);
  8742. }
  8743. return true;
  8744. }
  8745. private bool HandleGroupProfileRequest(IClientAPI sender, Packet Pack)
  8746. {
  8747. GroupProfileRequestPacket groupProfileRequest =
  8748. (GroupProfileRequestPacket)Pack;
  8749. #region Packet Session and User Check
  8750. if (m_checkPackets)
  8751. {
  8752. if (groupProfileRequest.AgentData.SessionID != SessionId ||
  8753. groupProfileRequest.AgentData.AgentID != AgentId)
  8754. return true;
  8755. }
  8756. #endregion
  8757. if (m_GroupsModule != null)
  8758. {
  8759. GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply);
  8760. groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock();
  8761. groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock();
  8762. groupProfileReply.AgentData.AgentID = AgentId;
  8763. GroupProfileData d = m_GroupsModule.GroupProfileRequest(this,
  8764. groupProfileRequest.GroupData.GroupID);
  8765. groupProfileReply.GroupData.GroupID = d.GroupID;
  8766. groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name);
  8767. groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter);
  8768. groupProfileReply.GroupData.ShowInList = d.ShowInList;
  8769. groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle);
  8770. groupProfileReply.GroupData.PowersMask = d.PowersMask;
  8771. groupProfileReply.GroupData.InsigniaID = d.InsigniaID;
  8772. groupProfileReply.GroupData.FounderID = d.FounderID;
  8773. groupProfileReply.GroupData.MembershipFee = d.MembershipFee;
  8774. groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment;
  8775. groupProfileReply.GroupData.Money = d.Money;
  8776. groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount;
  8777. groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount;
  8778. groupProfileReply.GroupData.AllowPublish = d.AllowPublish;
  8779. groupProfileReply.GroupData.MaturePublish = d.MaturePublish;
  8780. groupProfileReply.GroupData.OwnerRole = d.OwnerRole;
  8781. OutPacket(groupProfileReply, ThrottleOutPacketType.Task);
  8782. }
  8783. return true;
  8784. }
  8785. private bool HandleGroupMembersRequest(IClientAPI sender, Packet Pack)
  8786. {
  8787. GroupMembersRequestPacket groupMembersRequestPacket =
  8788. (GroupMembersRequestPacket)Pack;
  8789. #region Packet Session and User Check
  8790. if (m_checkPackets)
  8791. {
  8792. if (groupMembersRequestPacket.AgentData.SessionID != SessionId ||
  8793. groupMembersRequestPacket.AgentData.AgentID != AgentId)
  8794. return true;
  8795. }
  8796. #endregion
  8797. if (m_GroupsModule != null)
  8798. {
  8799. List<GroupMembersData> members =
  8800. m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID);
  8801. int memberCount = members.Count;
  8802. while (true)
  8803. {
  8804. int blockCount = members.Count;
  8805. if (blockCount > 40)
  8806. blockCount = 40;
  8807. GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply);
  8808. groupMembersReply.AgentData =
  8809. new GroupMembersReplyPacket.AgentDataBlock();
  8810. groupMembersReply.GroupData =
  8811. new GroupMembersReplyPacket.GroupDataBlock();
  8812. groupMembersReply.MemberData =
  8813. new GroupMembersReplyPacket.MemberDataBlock[
  8814. blockCount];
  8815. groupMembersReply.AgentData.AgentID = AgentId;
  8816. groupMembersReply.GroupData.GroupID =
  8817. groupMembersRequestPacket.GroupData.GroupID;
  8818. groupMembersReply.GroupData.RequestID =
  8819. groupMembersRequestPacket.GroupData.RequestID;
  8820. groupMembersReply.GroupData.MemberCount = memberCount;
  8821. for (int i = 0; i < blockCount; i++)
  8822. {
  8823. GroupMembersData m = members[0];
  8824. members.RemoveAt(0);
  8825. groupMembersReply.MemberData[i] =
  8826. new GroupMembersReplyPacket.MemberDataBlock();
  8827. groupMembersReply.MemberData[i].AgentID =
  8828. m.AgentID;
  8829. groupMembersReply.MemberData[i].Contribution =
  8830. m.Contribution;
  8831. groupMembersReply.MemberData[i].OnlineStatus =
  8832. Util.StringToBytes256(m.OnlineStatus);
  8833. groupMembersReply.MemberData[i].AgentPowers =
  8834. m.AgentPowers;
  8835. groupMembersReply.MemberData[i].Title =
  8836. Util.StringToBytes256(m.Title);
  8837. groupMembersReply.MemberData[i].IsOwner =
  8838. m.IsOwner;
  8839. }
  8840. OutPacket(groupMembersReply, ThrottleOutPacketType.Task);
  8841. if (members.Count == 0)
  8842. return true;
  8843. }
  8844. }
  8845. return true;
  8846. }
  8847. private bool HandleGroupRoleDataRequest(IClientAPI sender, Packet Pack)
  8848. {
  8849. GroupRoleDataRequestPacket groupRolesRequest =
  8850. (GroupRoleDataRequestPacket)Pack;
  8851. #region Packet Session and User Check
  8852. if (m_checkPackets)
  8853. {
  8854. if (groupRolesRequest.AgentData.SessionID != SessionId ||
  8855. groupRolesRequest.AgentData.AgentID != AgentId)
  8856. return true;
  8857. }
  8858. #endregion
  8859. if (m_GroupsModule != null)
  8860. {
  8861. GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply);
  8862. groupRolesReply.AgentData =
  8863. new GroupRoleDataReplyPacket.AgentDataBlock();
  8864. groupRolesReply.AgentData.AgentID = AgentId;
  8865. groupRolesReply.GroupData =
  8866. new GroupRoleDataReplyPacket.GroupDataBlock();
  8867. groupRolesReply.GroupData.GroupID =
  8868. groupRolesRequest.GroupData.GroupID;
  8869. groupRolesReply.GroupData.RequestID =
  8870. groupRolesRequest.GroupData.RequestID;
  8871. List<GroupRolesData> titles =
  8872. m_GroupsModule.GroupRoleDataRequest(this,
  8873. groupRolesRequest.GroupData.GroupID);
  8874. groupRolesReply.GroupData.RoleCount =
  8875. titles.Count;
  8876. groupRolesReply.RoleData =
  8877. new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count];
  8878. int i = 0;
  8879. foreach (GroupRolesData d in titles)
  8880. {
  8881. groupRolesReply.RoleData[i] =
  8882. new GroupRoleDataReplyPacket.RoleDataBlock();
  8883. groupRolesReply.RoleData[i].RoleID =
  8884. d.RoleID;
  8885. groupRolesReply.RoleData[i].Name =
  8886. Util.StringToBytes256(d.Name);
  8887. groupRolesReply.RoleData[i].Title =
  8888. Util.StringToBytes256(d.Title);
  8889. groupRolesReply.RoleData[i].Description =
  8890. Util.StringToBytes1024(d.Description);
  8891. groupRolesReply.RoleData[i].Powers =
  8892. d.Powers;
  8893. groupRolesReply.RoleData[i].Members =
  8894. (uint)d.Members;
  8895. i++;
  8896. }
  8897. OutPacket(groupRolesReply, ThrottleOutPacketType.Task);
  8898. }
  8899. return true;
  8900. }
  8901. private bool HandleGroupRoleMembersRequest(IClientAPI sender, Packet Pack)
  8902. {
  8903. GroupRoleMembersRequestPacket groupRoleMembersRequest =
  8904. (GroupRoleMembersRequestPacket)Pack;
  8905. #region Packet Session and User Check
  8906. if (m_checkPackets)
  8907. {
  8908. if (groupRoleMembersRequest.AgentData.SessionID != SessionId ||
  8909. groupRoleMembersRequest.AgentData.AgentID != AgentId)
  8910. return true;
  8911. }
  8912. #endregion
  8913. if (m_GroupsModule != null)
  8914. {
  8915. List<GroupRoleMembersData> mappings =
  8916. m_GroupsModule.GroupRoleMembersRequest(this,
  8917. groupRoleMembersRequest.GroupData.GroupID);
  8918. int mappingsCount = mappings.Count;
  8919. while (mappings.Count > 0)
  8920. {
  8921. int pairs = mappings.Count;
  8922. if (pairs > 32)
  8923. pairs = 32;
  8924. GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply);
  8925. groupRoleMembersReply.AgentData =
  8926. new GroupRoleMembersReplyPacket.AgentDataBlock();
  8927. groupRoleMembersReply.AgentData.AgentID =
  8928. AgentId;
  8929. groupRoleMembersReply.AgentData.GroupID =
  8930. groupRoleMembersRequest.GroupData.GroupID;
  8931. groupRoleMembersReply.AgentData.RequestID =
  8932. groupRoleMembersRequest.GroupData.RequestID;
  8933. groupRoleMembersReply.AgentData.TotalPairs =
  8934. (uint)mappingsCount;
  8935. groupRoleMembersReply.MemberData =
  8936. new GroupRoleMembersReplyPacket.MemberDataBlock[pairs];
  8937. for (int i = 0; i < pairs; i++)
  8938. {
  8939. GroupRoleMembersData d = mappings[0];
  8940. mappings.RemoveAt(0);
  8941. groupRoleMembersReply.MemberData[i] =
  8942. new GroupRoleMembersReplyPacket.MemberDataBlock();
  8943. groupRoleMembersReply.MemberData[i].RoleID =
  8944. d.RoleID;
  8945. groupRoleMembersReply.MemberData[i].MemberID =
  8946. d.MemberID;
  8947. }
  8948. OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task);
  8949. }
  8950. }
  8951. return true;
  8952. }
  8953. private bool HandleCreateGroupRequest(IClientAPI sender, Packet Pack)
  8954. {
  8955. CreateGroupRequestPacket createGroupRequest =
  8956. (CreateGroupRequestPacket)Pack;
  8957. #region Packet Session and User Check
  8958. if (m_checkPackets)
  8959. {
  8960. if (createGroupRequest.AgentData.SessionID != SessionId ||
  8961. createGroupRequest.AgentData.AgentID != AgentId)
  8962. return true;
  8963. }
  8964. #endregion
  8965. if (m_GroupsModule != null)
  8966. {
  8967. m_GroupsModule.CreateGroup(this,
  8968. Utils.BytesToString(createGroupRequest.GroupData.Name),
  8969. Utils.BytesToString(createGroupRequest.GroupData.Charter),
  8970. createGroupRequest.GroupData.ShowInList,
  8971. createGroupRequest.GroupData.InsigniaID,
  8972. createGroupRequest.GroupData.MembershipFee,
  8973. createGroupRequest.GroupData.OpenEnrollment,
  8974. createGroupRequest.GroupData.AllowPublish,
  8975. createGroupRequest.GroupData.MaturePublish);
  8976. }
  8977. return true;
  8978. }
  8979. private bool HandleUpdateGroupInfo(IClientAPI sender, Packet Pack)
  8980. {
  8981. UpdateGroupInfoPacket updateGroupInfo =
  8982. (UpdateGroupInfoPacket)Pack;
  8983. #region Packet Session and User Check
  8984. if (m_checkPackets)
  8985. {
  8986. if (updateGroupInfo.AgentData.SessionID != SessionId ||
  8987. updateGroupInfo.AgentData.AgentID != AgentId)
  8988. return true;
  8989. }
  8990. #endregion
  8991. if (m_GroupsModule != null)
  8992. {
  8993. m_GroupsModule.UpdateGroupInfo(this,
  8994. updateGroupInfo.GroupData.GroupID,
  8995. Utils.BytesToString(updateGroupInfo.GroupData.Charter),
  8996. updateGroupInfo.GroupData.ShowInList,
  8997. updateGroupInfo.GroupData.InsigniaID,
  8998. updateGroupInfo.GroupData.MembershipFee,
  8999. updateGroupInfo.GroupData.OpenEnrollment,
  9000. updateGroupInfo.GroupData.AllowPublish,
  9001. updateGroupInfo.GroupData.MaturePublish);
  9002. }
  9003. return true;
  9004. }
  9005. private bool HandleSetGroupAcceptNotices(IClientAPI sender, Packet Pack)
  9006. {
  9007. SetGroupAcceptNoticesPacket setGroupAcceptNotices =
  9008. (SetGroupAcceptNoticesPacket)Pack;
  9009. #region Packet Session and User Check
  9010. if (m_checkPackets)
  9011. {
  9012. if (setGroupAcceptNotices.AgentData.SessionID != SessionId ||
  9013. setGroupAcceptNotices.AgentData.AgentID != AgentId)
  9014. return true;
  9015. }
  9016. #endregion
  9017. if (m_GroupsModule != null)
  9018. {
  9019. m_GroupsModule.SetGroupAcceptNotices(this,
  9020. setGroupAcceptNotices.Data.GroupID,
  9021. setGroupAcceptNotices.Data.AcceptNotices,
  9022. setGroupAcceptNotices.NewData.ListInProfile);
  9023. }
  9024. return true;
  9025. }
  9026. private bool HandleGroupTitleUpdate(IClientAPI sender, Packet Pack)
  9027. {
  9028. GroupTitleUpdatePacket groupTitleUpdate =
  9029. (GroupTitleUpdatePacket)Pack;
  9030. #region Packet Session and User Check
  9031. if (m_checkPackets)
  9032. {
  9033. if (groupTitleUpdate.AgentData.SessionID != SessionId ||
  9034. groupTitleUpdate.AgentData.AgentID != AgentId)
  9035. return true;
  9036. }
  9037. #endregion
  9038. if (m_GroupsModule != null)
  9039. {
  9040. m_GroupsModule.GroupTitleUpdate(this,
  9041. groupTitleUpdate.AgentData.GroupID,
  9042. groupTitleUpdate.AgentData.TitleRoleID);
  9043. }
  9044. return true;
  9045. }
  9046. private bool HandleParcelDeedToGroup(IClientAPI sender, Packet Pack)
  9047. {
  9048. ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack;
  9049. if (m_GroupsModule != null)
  9050. {
  9051. ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup;
  9052. if (handlerParcelDeedToGroup != null)
  9053. {
  9054. handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this);
  9055. }
  9056. }
  9057. return true;
  9058. }
  9059. private bool HandleGroupNoticesListRequest(IClientAPI sender, Packet Pack)
  9060. {
  9061. GroupNoticesListRequestPacket groupNoticesListRequest =
  9062. (GroupNoticesListRequestPacket)Pack;
  9063. #region Packet Session and User Check
  9064. if (m_checkPackets)
  9065. {
  9066. if (groupNoticesListRequest.AgentData.SessionID != SessionId ||
  9067. groupNoticesListRequest.AgentData.AgentID != AgentId)
  9068. return true;
  9069. }
  9070. #endregion
  9071. if (m_GroupsModule != null)
  9072. {
  9073. GroupNoticeData[] gn =
  9074. m_GroupsModule.GroupNoticesListRequest(this,
  9075. groupNoticesListRequest.Data.GroupID);
  9076. GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply);
  9077. groupNoticesListReply.AgentData =
  9078. new GroupNoticesListReplyPacket.AgentDataBlock();
  9079. groupNoticesListReply.AgentData.AgentID = AgentId;
  9080. groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID;
  9081. groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length];
  9082. int i = 0;
  9083. foreach (GroupNoticeData g in gn)
  9084. {
  9085. groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock();
  9086. groupNoticesListReply.Data[i].NoticeID =
  9087. g.NoticeID;
  9088. groupNoticesListReply.Data[i].Timestamp =
  9089. g.Timestamp;
  9090. groupNoticesListReply.Data[i].FromName =
  9091. Util.StringToBytes256(g.FromName);
  9092. groupNoticesListReply.Data[i].Subject =
  9093. Util.StringToBytes256(g.Subject);
  9094. groupNoticesListReply.Data[i].HasAttachment =
  9095. g.HasAttachment;
  9096. groupNoticesListReply.Data[i].AssetType =
  9097. g.AssetType;
  9098. i++;
  9099. }
  9100. OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task);
  9101. }
  9102. return true;
  9103. }
  9104. private bool HandleGroupNoticeRequest(IClientAPI sender, Packet Pack)
  9105. {
  9106. GroupNoticeRequestPacket groupNoticeRequest =
  9107. (GroupNoticeRequestPacket)Pack;
  9108. #region Packet Session and User Check
  9109. if (m_checkPackets)
  9110. {
  9111. if (groupNoticeRequest.AgentData.SessionID != SessionId ||
  9112. groupNoticeRequest.AgentData.AgentID != AgentId)
  9113. return true;
  9114. }
  9115. #endregion
  9116. if (m_GroupsModule != null)
  9117. {
  9118. m_GroupsModule.GroupNoticeRequest(this,
  9119. groupNoticeRequest.Data.GroupNoticeID);
  9120. }
  9121. return true;
  9122. }
  9123. private bool HandleGroupRoleUpdate(IClientAPI sender, Packet Pack)
  9124. {
  9125. GroupRoleUpdatePacket groupRoleUpdate =
  9126. (GroupRoleUpdatePacket)Pack;
  9127. #region Packet Session and User Check
  9128. if (m_checkPackets)
  9129. {
  9130. if (groupRoleUpdate.AgentData.SessionID != SessionId ||
  9131. groupRoleUpdate.AgentData.AgentID != AgentId)
  9132. return true;
  9133. }
  9134. #endregion
  9135. if (m_GroupsModule != null)
  9136. {
  9137. foreach (GroupRoleUpdatePacket.RoleDataBlock d in
  9138. groupRoleUpdate.RoleData)
  9139. {
  9140. m_GroupsModule.GroupRoleUpdate(this,
  9141. groupRoleUpdate.AgentData.GroupID,
  9142. d.RoleID,
  9143. Utils.BytesToString(d.Name),
  9144. Utils.BytesToString(d.Description),
  9145. Utils.BytesToString(d.Title),
  9146. d.Powers,
  9147. d.UpdateType);
  9148. }
  9149. m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID);
  9150. }
  9151. return true;
  9152. }
  9153. private bool HandleGroupRoleChanges(IClientAPI sender, Packet Pack)
  9154. {
  9155. GroupRoleChangesPacket groupRoleChanges =
  9156. (GroupRoleChangesPacket)Pack;
  9157. #region Packet Session and User Check
  9158. if (m_checkPackets)
  9159. {
  9160. if (groupRoleChanges.AgentData.SessionID != SessionId ||
  9161. groupRoleChanges.AgentData.AgentID != AgentId)
  9162. return true;
  9163. }
  9164. #endregion
  9165. if (m_GroupsModule != null)
  9166. {
  9167. foreach (GroupRoleChangesPacket.RoleChangeBlock d in
  9168. groupRoleChanges.RoleChange)
  9169. {
  9170. m_GroupsModule.GroupRoleChanges(this,
  9171. groupRoleChanges.AgentData.GroupID,
  9172. d.RoleID,
  9173. d.MemberID,
  9174. d.Change);
  9175. }
  9176. m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID);
  9177. }
  9178. return true;
  9179. }
  9180. private bool HandleJoinGroupRequest(IClientAPI sender, Packet Pack)
  9181. {
  9182. JoinGroupRequestPacket joinGroupRequest =
  9183. (JoinGroupRequestPacket)Pack;
  9184. #region Packet Session and User Check
  9185. if (m_checkPackets)
  9186. {
  9187. if (joinGroupRequest.AgentData.SessionID != SessionId ||
  9188. joinGroupRequest.AgentData.AgentID != AgentId)
  9189. return true;
  9190. }
  9191. #endregion
  9192. if (m_GroupsModule != null)
  9193. {
  9194. m_GroupsModule.JoinGroupRequest(this,
  9195. joinGroupRequest.GroupData.GroupID);
  9196. }
  9197. return true;
  9198. }
  9199. private bool HandleLeaveGroupRequest(IClientAPI sender, Packet Pack)
  9200. {
  9201. LeaveGroupRequestPacket leaveGroupRequest =
  9202. (LeaveGroupRequestPacket)Pack;
  9203. #region Packet Session and User Check
  9204. if (m_checkPackets)
  9205. {
  9206. if (leaveGroupRequest.AgentData.SessionID != SessionId ||
  9207. leaveGroupRequest.AgentData.AgentID != AgentId)
  9208. return true;
  9209. }
  9210. #endregion
  9211. if (m_GroupsModule != null)
  9212. {
  9213. m_GroupsModule.LeaveGroupRequest(this,
  9214. leaveGroupRequest.GroupData.GroupID);
  9215. }
  9216. return true;
  9217. }
  9218. private bool HandleEjectGroupMemberRequest(IClientAPI sender, Packet Pack)
  9219. {
  9220. EjectGroupMemberRequestPacket ejectGroupMemberRequest =
  9221. (EjectGroupMemberRequestPacket)Pack;
  9222. #region Packet Session and User Check
  9223. if (m_checkPackets)
  9224. {
  9225. if (ejectGroupMemberRequest.AgentData.SessionID != SessionId ||
  9226. ejectGroupMemberRequest.AgentData.AgentID != AgentId)
  9227. return true;
  9228. }
  9229. #endregion
  9230. if (m_GroupsModule != null)
  9231. {
  9232. foreach (EjectGroupMemberRequestPacket.EjectDataBlock e
  9233. in ejectGroupMemberRequest.EjectData)
  9234. {
  9235. m_GroupsModule.EjectGroupMemberRequest(this,
  9236. ejectGroupMemberRequest.GroupData.GroupID,
  9237. e.EjecteeID);
  9238. }
  9239. }
  9240. return true;
  9241. }
  9242. private bool HandleInviteGroupRequest(IClientAPI sender, Packet Pack)
  9243. {
  9244. InviteGroupRequestPacket inviteGroupRequest =
  9245. (InviteGroupRequestPacket)Pack;
  9246. #region Packet Session and User Check
  9247. if (m_checkPackets)
  9248. {
  9249. if (inviteGroupRequest.AgentData.SessionID != SessionId ||
  9250. inviteGroupRequest.AgentData.AgentID != AgentId)
  9251. return true;
  9252. }
  9253. #endregion
  9254. if (m_GroupsModule != null)
  9255. {
  9256. foreach (InviteGroupRequestPacket.InviteDataBlock b in
  9257. inviteGroupRequest.InviteData)
  9258. {
  9259. m_GroupsModule.InviteGroupRequest(this,
  9260. inviteGroupRequest.GroupData.GroupID,
  9261. b.InviteeID,
  9262. b.RoleID);
  9263. }
  9264. }
  9265. return true;
  9266. }
  9267. #endregion Groups
  9268. private bool HandleStartLure(IClientAPI sender, Packet Pack)
  9269. {
  9270. StartLurePacket startLureRequest = (StartLurePacket)Pack;
  9271. #region Packet Session and User Check
  9272. if (m_checkPackets)
  9273. {
  9274. if (startLureRequest.AgentData.SessionID != SessionId ||
  9275. startLureRequest.AgentData.AgentID != AgentId)
  9276. return true;
  9277. }
  9278. #endregion
  9279. StartLure handlerStartLure = OnStartLure;
  9280. if (handlerStartLure != null)
  9281. handlerStartLure(startLureRequest.Info.LureType,
  9282. Utils.BytesToString(
  9283. startLureRequest.Info.Message),
  9284. startLureRequest.TargetData[0].TargetID,
  9285. this);
  9286. return true;
  9287. }
  9288. private bool HandleTeleportLureRequest(IClientAPI sender, Packet Pack)
  9289. {
  9290. TeleportLureRequestPacket teleportLureRequest =
  9291. (TeleportLureRequestPacket)Pack;
  9292. #region Packet Session and User Check
  9293. if (m_checkPackets)
  9294. {
  9295. if (teleportLureRequest.Info.SessionID != SessionId ||
  9296. teleportLureRequest.Info.AgentID != AgentId)
  9297. return true;
  9298. }
  9299. #endregion
  9300. TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest;
  9301. if (handlerTeleportLureRequest != null)
  9302. handlerTeleportLureRequest(
  9303. teleportLureRequest.Info.LureID,
  9304. teleportLureRequest.Info.TeleportFlags,
  9305. this);
  9306. return true;
  9307. }
  9308. private bool HandleClassifiedInfoRequest(IClientAPI sender, Packet Pack)
  9309. {
  9310. ClassifiedInfoRequestPacket classifiedInfoRequest =
  9311. (ClassifiedInfoRequestPacket)Pack;
  9312. #region Packet Session and User Check
  9313. if (m_checkPackets)
  9314. {
  9315. if (classifiedInfoRequest.AgentData.SessionID != SessionId ||
  9316. classifiedInfoRequest.AgentData.AgentID != AgentId)
  9317. return true;
  9318. }
  9319. #endregion
  9320. ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest;
  9321. if (handlerClassifiedInfoRequest != null)
  9322. handlerClassifiedInfoRequest(
  9323. classifiedInfoRequest.Data.ClassifiedID,
  9324. this);
  9325. return true;
  9326. }
  9327. private bool HandleClassifiedInfoUpdate(IClientAPI sender, Packet Pack)
  9328. {
  9329. ClassifiedInfoUpdatePacket classifiedInfoUpdate =
  9330. (ClassifiedInfoUpdatePacket)Pack;
  9331. #region Packet Session and User Check
  9332. if (m_checkPackets)
  9333. {
  9334. if (classifiedInfoUpdate.AgentData.SessionID != SessionId ||
  9335. classifiedInfoUpdate.AgentData.AgentID != AgentId)
  9336. return true;
  9337. }
  9338. #endregion
  9339. ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate;
  9340. if (handlerClassifiedInfoUpdate != null)
  9341. handlerClassifiedInfoUpdate(
  9342. classifiedInfoUpdate.Data.ClassifiedID,
  9343. classifiedInfoUpdate.Data.Category,
  9344. Utils.BytesToString(
  9345. classifiedInfoUpdate.Data.Name),
  9346. Utils.BytesToString(
  9347. classifiedInfoUpdate.Data.Desc),
  9348. classifiedInfoUpdate.Data.ParcelID,
  9349. classifiedInfoUpdate.Data.ParentEstate,
  9350. classifiedInfoUpdate.Data.SnapshotID,
  9351. new Vector3(
  9352. classifiedInfoUpdate.Data.PosGlobal),
  9353. classifiedInfoUpdate.Data.ClassifiedFlags,
  9354. classifiedInfoUpdate.Data.PriceForListing,
  9355. this);
  9356. return true;
  9357. }
  9358. private bool HandleClassifiedDelete(IClientAPI sender, Packet Pack)
  9359. {
  9360. ClassifiedDeletePacket classifiedDelete =
  9361. (ClassifiedDeletePacket)Pack;
  9362. #region Packet Session and User Check
  9363. if (m_checkPackets)
  9364. {
  9365. if (classifiedDelete.AgentData.SessionID != SessionId ||
  9366. classifiedDelete.AgentData.AgentID != AgentId)
  9367. return true;
  9368. }
  9369. #endregion
  9370. ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete;
  9371. if (handlerClassifiedDelete != null)
  9372. handlerClassifiedDelete(
  9373. classifiedDelete.Data.ClassifiedID,
  9374. this);
  9375. return true;
  9376. }
  9377. private bool HandleClassifiedGodDelete(IClientAPI sender, Packet Pack)
  9378. {
  9379. ClassifiedGodDeletePacket classifiedGodDelete =
  9380. (ClassifiedGodDeletePacket)Pack;
  9381. #region Packet Session and User Check
  9382. if (m_checkPackets)
  9383. {
  9384. if (classifiedGodDelete.AgentData.SessionID != SessionId ||
  9385. classifiedGodDelete.AgentData.AgentID != AgentId)
  9386. return true;
  9387. }
  9388. #endregion
  9389. ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete;
  9390. if (handlerClassifiedGodDelete != null)
  9391. handlerClassifiedGodDelete(
  9392. classifiedGodDelete.Data.ClassifiedID,
  9393. this);
  9394. return true;
  9395. }
  9396. private bool HandleEventGodDelete(IClientAPI sender, Packet Pack)
  9397. {
  9398. EventGodDeletePacket eventGodDelete =
  9399. (EventGodDeletePacket)Pack;
  9400. #region Packet Session and User Check
  9401. if (m_checkPackets)
  9402. {
  9403. if (eventGodDelete.AgentData.SessionID != SessionId ||
  9404. eventGodDelete.AgentData.AgentID != AgentId)
  9405. return true;
  9406. }
  9407. #endregion
  9408. EventGodDelete handlerEventGodDelete = OnEventGodDelete;
  9409. if (handlerEventGodDelete != null)
  9410. handlerEventGodDelete(
  9411. eventGodDelete.EventData.EventID,
  9412. eventGodDelete.QueryData.QueryID,
  9413. Utils.BytesToString(
  9414. eventGodDelete.QueryData.QueryText),
  9415. eventGodDelete.QueryData.QueryFlags,
  9416. eventGodDelete.QueryData.QueryStart,
  9417. this);
  9418. return true;
  9419. }
  9420. private bool HandleEventNotificationAddRequest(IClientAPI sender, Packet Pack)
  9421. {
  9422. EventNotificationAddRequestPacket eventNotificationAdd =
  9423. (EventNotificationAddRequestPacket)Pack;
  9424. #region Packet Session and User Check
  9425. if (m_checkPackets)
  9426. {
  9427. if (eventNotificationAdd.AgentData.SessionID != SessionId ||
  9428. eventNotificationAdd.AgentData.AgentID != AgentId)
  9429. return true;
  9430. }
  9431. #endregion
  9432. EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest;
  9433. if (handlerEventNotificationAddRequest != null)
  9434. handlerEventNotificationAddRequest(
  9435. eventNotificationAdd.EventData.EventID, this);
  9436. return true;
  9437. }
  9438. private bool HandleEventNotificationRemoveRequest(IClientAPI sender, Packet Pack)
  9439. {
  9440. EventNotificationRemoveRequestPacket eventNotificationRemove =
  9441. (EventNotificationRemoveRequestPacket)Pack;
  9442. #region Packet Session and User Check
  9443. if (m_checkPackets)
  9444. {
  9445. if (eventNotificationRemove.AgentData.SessionID != SessionId ||
  9446. eventNotificationRemove.AgentData.AgentID != AgentId)
  9447. return true;
  9448. }
  9449. #endregion
  9450. EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest;
  9451. if (handlerEventNotificationRemoveRequest != null)
  9452. handlerEventNotificationRemoveRequest(
  9453. eventNotificationRemove.EventData.EventID, this);
  9454. return true;
  9455. }
  9456. private bool HandleRetrieveInstantMessages(IClientAPI sender, Packet Pack)
  9457. {
  9458. RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack;
  9459. #region Packet Session and User Check
  9460. if (m_checkPackets)
  9461. {
  9462. if (rimpInstantMessagePack.AgentData.SessionID != SessionId ||
  9463. rimpInstantMessagePack.AgentData.AgentID != AgentId)
  9464. return true;
  9465. }
  9466. #endregion
  9467. RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages;
  9468. if (handlerRetrieveInstantMessages != null)
  9469. handlerRetrieveInstantMessages(this);
  9470. return true;
  9471. }
  9472. private bool HandlePickDelete(IClientAPI sender, Packet Pack)
  9473. {
  9474. PickDeletePacket pickDelete =
  9475. (PickDeletePacket)Pack;
  9476. #region Packet Session and User Check
  9477. if (m_checkPackets)
  9478. {
  9479. if (pickDelete.AgentData.SessionID != SessionId ||
  9480. pickDelete.AgentData.AgentID != AgentId)
  9481. return true;
  9482. }
  9483. #endregion
  9484. PickDelete handlerPickDelete = OnPickDelete;
  9485. if (handlerPickDelete != null)
  9486. handlerPickDelete(this, pickDelete.Data.PickID);
  9487. return true;
  9488. }
  9489. private bool HandlePickGodDelete(IClientAPI sender, Packet Pack)
  9490. {
  9491. PickGodDeletePacket pickGodDelete =
  9492. (PickGodDeletePacket)Pack;
  9493. #region Packet Session and User Check
  9494. if (m_checkPackets)
  9495. {
  9496. if (pickGodDelete.AgentData.SessionID != SessionId ||
  9497. pickGodDelete.AgentData.AgentID != AgentId)
  9498. return true;
  9499. }
  9500. #endregion
  9501. PickGodDelete handlerPickGodDelete = OnPickGodDelete;
  9502. if (handlerPickGodDelete != null)
  9503. handlerPickGodDelete(this,
  9504. pickGodDelete.AgentData.AgentID,
  9505. pickGodDelete.Data.PickID,
  9506. pickGodDelete.Data.QueryID);
  9507. return true;
  9508. }
  9509. private bool HandlePickInfoUpdate(IClientAPI sender, Packet Pack)
  9510. {
  9511. PickInfoUpdatePacket pickInfoUpdate =
  9512. (PickInfoUpdatePacket)Pack;
  9513. #region Packet Session and User Check
  9514. if (m_checkPackets)
  9515. {
  9516. if (pickInfoUpdate.AgentData.SessionID != SessionId ||
  9517. pickInfoUpdate.AgentData.AgentID != AgentId)
  9518. return true;
  9519. }
  9520. #endregion
  9521. PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate;
  9522. if (handlerPickInfoUpdate != null)
  9523. handlerPickInfoUpdate(this,
  9524. pickInfoUpdate.Data.PickID,
  9525. pickInfoUpdate.Data.CreatorID,
  9526. pickInfoUpdate.Data.TopPick,
  9527. Utils.BytesToString(pickInfoUpdate.Data.Name),
  9528. Utils.BytesToString(pickInfoUpdate.Data.Desc),
  9529. pickInfoUpdate.Data.SnapshotID,
  9530. pickInfoUpdate.Data.SortOrder,
  9531. pickInfoUpdate.Data.Enabled);
  9532. return true;
  9533. }
  9534. private bool HandleAvatarNotesUpdate(IClientAPI sender, Packet Pack)
  9535. {
  9536. AvatarNotesUpdatePacket avatarNotesUpdate =
  9537. (AvatarNotesUpdatePacket)Pack;
  9538. #region Packet Session and User Check
  9539. if (m_checkPackets)
  9540. {
  9541. if (avatarNotesUpdate.AgentData.SessionID != SessionId ||
  9542. avatarNotesUpdate.AgentData.AgentID != AgentId)
  9543. return true;
  9544. }
  9545. #endregion
  9546. AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate;
  9547. if (handlerAvatarNotesUpdate != null)
  9548. handlerAvatarNotesUpdate(this,
  9549. avatarNotesUpdate.Data.TargetID,
  9550. Utils.BytesToString(avatarNotesUpdate.Data.Notes));
  9551. return true;
  9552. }
  9553. private bool HandleAvatarInterestsUpdate(IClientAPI sender, Packet Pack)
  9554. {
  9555. AvatarInterestsUpdatePacket avatarInterestUpdate =
  9556. (AvatarInterestsUpdatePacket)Pack;
  9557. #region Packet Session and User Check
  9558. if (m_checkPackets)
  9559. {
  9560. if (avatarInterestUpdate.AgentData.SessionID != SessionId ||
  9561. avatarInterestUpdate.AgentData.AgentID != AgentId)
  9562. return true;
  9563. }
  9564. #endregion
  9565. AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate;
  9566. if (handlerAvatarInterestUpdate != null)
  9567. handlerAvatarInterestUpdate(this,
  9568. avatarInterestUpdate.PropertiesData.WantToMask,
  9569. Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText),
  9570. avatarInterestUpdate.PropertiesData.SkillsMask,
  9571. Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText),
  9572. Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
  9573. return true;
  9574. }
  9575. private bool HandleGrantUserRights(IClientAPI sender, Packet Pack)
  9576. {
  9577. GrantUserRightsPacket GrantUserRights =
  9578. (GrantUserRightsPacket)Pack;
  9579. #region Packet Session and User Check
  9580. if (m_checkPackets)
  9581. {
  9582. if (GrantUserRights.AgentData.SessionID != SessionId ||
  9583. GrantUserRights.AgentData.AgentID != AgentId)
  9584. return true;
  9585. }
  9586. #endregion
  9587. GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights;
  9588. if (GrantUserRightsHandler != null)
  9589. GrantUserRightsHandler(this,
  9590. GrantUserRights.AgentData.AgentID,
  9591. GrantUserRights.Rights[0].AgentRelated,
  9592. GrantUserRights.Rights[0].RelatedRights);
  9593. return true;
  9594. }
  9595. private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
  9596. {
  9597. PlacesQueryPacket placesQueryPacket =
  9598. (PlacesQueryPacket)Pack;
  9599. PlacesQuery handlerPlacesQuery = OnPlacesQuery;
  9600. if (handlerPlacesQuery != null)
  9601. handlerPlacesQuery(placesQueryPacket.AgentData.QueryID,
  9602. placesQueryPacket.TransactionData.TransactionID,
  9603. Utils.BytesToString(
  9604. placesQueryPacket.QueryData.QueryText),
  9605. placesQueryPacket.QueryData.QueryFlags,
  9606. (byte)placesQueryPacket.QueryData.Category,
  9607. Utils.BytesToString(
  9608. placesQueryPacket.QueryData.SimName),
  9609. this);
  9610. return true;
  9611. }
  9612. #endregion Packet Handlers
  9613. public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
  9614. {
  9615. ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion);
  9616. scriptQuestion.Data = new ScriptQuestionPacket.DataBlock();
  9617. // TODO: don't create new blocks if recycling an old packet
  9618. scriptQuestion.Data.TaskID = taskID;
  9619. scriptQuestion.Data.ItemID = itemID;
  9620. scriptQuestion.Data.Questions = question;
  9621. scriptQuestion.Data.ObjectName = Util.StringToBytes256(taskName);
  9622. scriptQuestion.Data.ObjectOwner = Util.StringToBytes256(ownerName);
  9623. OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
  9624. }
  9625. private void InitDefaultAnimations()
  9626. {
  9627. using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"))
  9628. {
  9629. XmlDocument doc = new XmlDocument();
  9630. doc.Load(reader);
  9631. if (doc.DocumentElement != null)
  9632. foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
  9633. {
  9634. if (nod.Attributes["name"] != null)
  9635. {
  9636. string name = nod.Attributes["name"].Value.ToLower();
  9637. string id = nod.InnerText;
  9638. m_defaultAnimations.Add(name, (UUID)id);
  9639. }
  9640. }
  9641. }
  9642. }
  9643. public UUID GetDefaultAnimation(string name)
  9644. {
  9645. if (m_defaultAnimations.ContainsKey(name))
  9646. return m_defaultAnimations[name];
  9647. return UUID.Zero;
  9648. }
  9649. /// <summary>
  9650. /// Handler called when we receive a logout packet.
  9651. /// </summary>
  9652. /// <param name="client"></param>
  9653. /// <param name="packet"></param>
  9654. /// <returns></returns>
  9655. protected virtual bool HandleLogout(IClientAPI client, Packet packet)
  9656. {
  9657. if (packet.Type == PacketType.LogoutRequest)
  9658. {
  9659. if (((LogoutRequestPacket)packet).AgentData.SessionID != SessionId) return false;
  9660. }
  9661. return Logout(client);
  9662. }
  9663. /// <summary>
  9664. ///
  9665. /// </summary>
  9666. /// <param name="client"></param>
  9667. /// <returns></returns>
  9668. protected virtual bool Logout(IClientAPI client)
  9669. {
  9670. m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName);
  9671. Action<IClientAPI> handlerLogout = OnLogout;
  9672. if (handlerLogout != null)
  9673. {
  9674. handlerLogout(client);
  9675. }
  9676. return true;
  9677. }
  9678. /// <summary>
  9679. /// Send a response back to a client when it asks the asset server (via the region server) if it has
  9680. /// its appearance texture cached.
  9681. ///
  9682. /// At the moment, we always reply that there is no cached texture.
  9683. /// </summary>
  9684. /// <param name="simclient"></param>
  9685. /// <param name="packet"></param>
  9686. /// <returns></returns>
  9687. protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
  9688. {
  9689. //m_log.Debug("texture cached: " + packet.ToString());
  9690. AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
  9691. AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
  9692. if (cachedtex.AgentData.SessionID != SessionId) return false;
  9693. // TODO: don't create new blocks if recycling an old packet
  9694. cachedresp.AgentData.AgentID = AgentId;
  9695. cachedresp.AgentData.SessionID = m_sessionId;
  9696. cachedresp.AgentData.SerialNum = m_cachedTextureSerial;
  9697. m_cachedTextureSerial++;
  9698. cachedresp.WearableData =
  9699. new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
  9700. for (int i = 0; i < cachedtex.WearableData.Length; i++)
  9701. {
  9702. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  9703. cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
  9704. cachedresp.WearableData[i].TextureID = UUID.Zero;
  9705. cachedresp.WearableData[i].HostName = new byte[0];
  9706. }
  9707. cachedresp.Header.Zerocoded = true;
  9708. OutPacket(cachedresp, ThrottleOutPacketType.Task);
  9709. return true;
  9710. }
  9711. protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
  9712. {
  9713. MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
  9714. if (multipleupdate.AgentData.SessionID != SessionId)
  9715. return false;
  9716. // m_log.DebugFormat(
  9717. // "[CLIENT]: Incoming MultipleObjectUpdatePacket contained {0} blocks", multipleupdate.ObjectData.Length);
  9718. Scene tScene = (Scene)m_scene;
  9719. for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
  9720. {
  9721. MultipleObjectUpdatePacket.ObjectDataBlock block = multipleupdate.ObjectData[i];
  9722. // Can't act on Null Data
  9723. if (block.Data != null)
  9724. {
  9725. uint localId = block.ObjectLocalID;
  9726. SceneObjectPart part = tScene.GetSceneObjectPart(localId);
  9727. if (part == null)
  9728. {
  9729. // It's a ghost! tell the client to delete it from view.
  9730. simClient.SendKillObject(Scene.RegionInfo.RegionHandle,
  9731. localId);
  9732. }
  9733. else
  9734. {
  9735. // m_log.DebugFormat(
  9736. // "[CLIENT]: Processing block {0} type {1} for {2} {3}",
  9737. // i, block.Type, part.Name, part.LocalId);
  9738. // // Do this once since fetch parts creates a new array.
  9739. // SceneObjectPart[] parts = part.ParentGroup.Parts;
  9740. // for (int j = 0; j < parts.Length; j++)
  9741. // {
  9742. // part.StoreUndoState();
  9743. // parts[j].IgnoreUndoUpdate = true;
  9744. // }
  9745. UpdatePrimGroupRotation handlerUpdatePrimGroupRotation;
  9746. switch (block.Type)
  9747. {
  9748. case 1:
  9749. Vector3 pos1 = new Vector3(block.Data, 0);
  9750. UpdateVector handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  9751. if (handlerUpdatePrimSinglePosition != null)
  9752. {
  9753. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  9754. handlerUpdatePrimSinglePosition(localId, pos1, this);
  9755. }
  9756. break;
  9757. case 2:
  9758. Quaternion rot1 = new Quaternion(block.Data, 0, true);
  9759. UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation;
  9760. if (handlerUpdatePrimSingleRotation != null)
  9761. {
  9762. // m_log.Info("new tab rotation is " + rot1.X + " , " + rot1.Y + " , " + rot1.Z + " , " + rot1.W);
  9763. handlerUpdatePrimSingleRotation(localId, rot1, this);
  9764. }
  9765. break;
  9766. case 3:
  9767. Vector3 rotPos = new Vector3(block.Data, 0);
  9768. Quaternion rot2 = new Quaternion(block.Data, 12, true);
  9769. UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition;
  9770. if (handlerUpdatePrimSingleRotationPosition != null)
  9771. {
  9772. // m_log.Debug("new mouse rotation position is " + rotPos.X + " , " + rotPos.Y + " , " + rotPos.Z);
  9773. // m_log.Info("new mouse rotation is " + rot2.X + " , " + rot2.Y + " , " + rot2.Z + " , " + rot2.W);
  9774. handlerUpdatePrimSingleRotationPosition(localId, rot2, rotPos, this);
  9775. }
  9776. break;
  9777. case 4:
  9778. case 20:
  9779. Vector3 scale4 = new Vector3(block.Data, 0);
  9780. UpdateVector handlerUpdatePrimScale = OnUpdatePrimScale;
  9781. if (handlerUpdatePrimScale != null)
  9782. {
  9783. // m_log.Debug("new scale is " + scale4.X + " , " + scale4.Y + " , " + scale4.Z);
  9784. handlerUpdatePrimScale(localId, scale4, this);
  9785. }
  9786. break;
  9787. case 5:
  9788. Vector3 scale1 = new Vector3(block.Data, 12);
  9789. Vector3 pos11 = new Vector3(block.Data, 0);
  9790. handlerUpdatePrimScale = OnUpdatePrimScale;
  9791. if (handlerUpdatePrimScale != null)
  9792. {
  9793. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  9794. handlerUpdatePrimScale(localId, scale1, this);
  9795. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  9796. if (handlerUpdatePrimSinglePosition != null)
  9797. {
  9798. handlerUpdatePrimSinglePosition(localId, pos11, this);
  9799. }
  9800. }
  9801. break;
  9802. case 9:
  9803. Vector3 pos2 = new Vector3(block.Data, 0);
  9804. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  9805. if (handlerUpdateVector != null)
  9806. {
  9807. handlerUpdateVector(localId, pos2, this);
  9808. }
  9809. break;
  9810. case 10:
  9811. Quaternion rot3 = new Quaternion(block.Data, 0, true);
  9812. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  9813. if (handlerUpdatePrimRotation != null)
  9814. {
  9815. // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W);
  9816. handlerUpdatePrimRotation(localId, rot3, this);
  9817. }
  9818. break;
  9819. case 11:
  9820. Vector3 pos3 = new Vector3(block.Data, 0);
  9821. Quaternion rot4 = new Quaternion(block.Data, 12, true);
  9822. handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation;
  9823. if (handlerUpdatePrimGroupRotation != null)
  9824. {
  9825. // m_log.Debug("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  9826. // m_log.Debug("new group mouse rotation is " + rot4.X + " , " + rot4.Y + " , " + rot4.Z + " , " + rot4.W);
  9827. handlerUpdatePrimGroupRotation(localId, pos3, rot4, this);
  9828. }
  9829. break;
  9830. case 12:
  9831. case 28:
  9832. Vector3 scale7 = new Vector3(block.Data, 0);
  9833. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  9834. if (handlerUpdatePrimGroupScale != null)
  9835. {
  9836. // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z);
  9837. handlerUpdatePrimGroupScale(localId, scale7, this);
  9838. }
  9839. break;
  9840. case 13:
  9841. Vector3 scale2 = new Vector3(block.Data, 12);
  9842. Vector3 pos4 = new Vector3(block.Data, 0);
  9843. handlerUpdatePrimScale = OnUpdatePrimScale;
  9844. if (handlerUpdatePrimScale != null)
  9845. {
  9846. //m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  9847. handlerUpdatePrimScale(localId, scale2, this);
  9848. // Change the position based on scale (for bug number 246)
  9849. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  9850. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  9851. if (handlerUpdatePrimSinglePosition != null)
  9852. {
  9853. handlerUpdatePrimSinglePosition(localId, pos4, this);
  9854. }
  9855. }
  9856. break;
  9857. case 29:
  9858. Vector3 scale5 = new Vector3(block.Data, 12);
  9859. Vector3 pos5 = new Vector3(block.Data, 0);
  9860. handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  9861. if (handlerUpdatePrimGroupScale != null)
  9862. {
  9863. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  9864. part.StoreUndoState(true);
  9865. part.IgnoreUndoUpdate = true;
  9866. handlerUpdatePrimGroupScale(localId, scale5, this);
  9867. handlerUpdateVector = OnUpdatePrimGroupPosition;
  9868. if (handlerUpdateVector != null)
  9869. {
  9870. handlerUpdateVector(localId, pos5, this);
  9871. }
  9872. part.IgnoreUndoUpdate = false;
  9873. }
  9874. break;
  9875. case 21:
  9876. Vector3 scale6 = new Vector3(block.Data, 12);
  9877. Vector3 pos6 = new Vector3(block.Data, 0);
  9878. handlerUpdatePrimScale = OnUpdatePrimScale;
  9879. if (handlerUpdatePrimScale != null)
  9880. {
  9881. part.StoreUndoState(false);
  9882. part.IgnoreUndoUpdate = true;
  9883. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  9884. handlerUpdatePrimScale(localId, scale6, this);
  9885. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  9886. if (handlerUpdatePrimSinglePosition != null)
  9887. {
  9888. handlerUpdatePrimSinglePosition(localId, pos6, this);
  9889. }
  9890. part.IgnoreUndoUpdate = false;
  9891. }
  9892. break;
  9893. default:
  9894. m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
  9895. break;
  9896. }
  9897. // for (int j = 0; j < parts.Length; j++)
  9898. // parts[j].IgnoreUndoUpdate = false;
  9899. }
  9900. }
  9901. }
  9902. return true;
  9903. }
  9904. public void RequestMapLayer()
  9905. {
  9906. //should be getting the map layer from the grid server
  9907. //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
  9908. MapLayerReplyPacket mapReply = (MapLayerReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapLayerReply);
  9909. // TODO: don't create new blocks if recycling an old packet
  9910. mapReply.AgentData.AgentID = AgentId;
  9911. mapReply.AgentData.Flags = 0;
  9912. mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
  9913. mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
  9914. mapReply.LayerData[0].Bottom = 0;
  9915. mapReply.LayerData[0].Left = 0;
  9916. mapReply.LayerData[0].Top = 30000;
  9917. mapReply.LayerData[0].Right = 30000;
  9918. mapReply.LayerData[0].ImageID = new UUID("00000000-0000-1111-9999-000000000006");
  9919. mapReply.Header.Zerocoded = true;
  9920. OutPacket(mapReply, ThrottleOutPacketType.Land);
  9921. }
  9922. public void RequestMapBlocksX(int minX, int minY, int maxX, int maxY)
  9923. {
  9924. /*
  9925. IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
  9926. MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
  9927. mbReply.AgentData.AgentId = AgentId;
  9928. int len;
  9929. if (simMapProfiles == null)
  9930. len = 0;
  9931. else
  9932. len = simMapProfiles.Count;
  9933. mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
  9934. int iii;
  9935. for (iii = 0; iii < len; iii++)
  9936. {
  9937. Hashtable mp = (Hashtable)simMapProfiles[iii];
  9938. mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
  9939. mbReply.Data[iii].Name = Util.UTF8.GetBytes((string)mp["name"]);
  9940. mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
  9941. mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
  9942. mbReply.Data[iii].MapImageID = new UUID((string)mp["map-image-id"]);
  9943. mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
  9944. mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
  9945. mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
  9946. mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
  9947. }
  9948. this.OutPacket(mbReply, ThrottleOutPacketType.Land);
  9949. */
  9950. }
  9951. /// <summary>
  9952. /// Sets the throttles from values supplied by the client
  9953. /// </summary>
  9954. /// <param name="throttles"></param>
  9955. public void SetChildAgentThrottle(byte[] throttles)
  9956. {
  9957. m_udpClient.SetThrottles(throttles);
  9958. }
  9959. /// <summary>
  9960. /// Get the current throttles for this client as a packed byte array
  9961. /// </summary>
  9962. /// <param name="multiplier">Unused</param>
  9963. /// <returns></returns>
  9964. public byte[] GetThrottlesPacked(float multiplier)
  9965. {
  9966. return m_udpClient.GetThrottlesPacked(multiplier);
  9967. }
  9968. /// <summary>
  9969. /// Cruft?
  9970. /// </summary>
  9971. public virtual void InPacket(object NewPack)
  9972. {
  9973. throw new NotImplementedException();
  9974. }
  9975. /// <summary>
  9976. /// This is the starting point for sending a simulator packet out to the client
  9977. /// </summary>
  9978. /// <param name="packet">Packet to send</param>
  9979. /// <param name="throttlePacketType">Throttling category for the packet</param>
  9980. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
  9981. {
  9982. #region BinaryStats
  9983. LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length);
  9984. #endregion BinaryStats
  9985. OutPacket(packet, throttlePacketType, true);
  9986. }
  9987. /// <summary>
  9988. /// This is the starting point for sending a simulator packet out to the client
  9989. /// </summary>
  9990. /// <param name="packet">Packet to send</param>
  9991. /// <param name="throttlePacketType">Throttling category for the packet</param>
  9992. /// <param name="doAutomaticSplitting">True to automatically split oversized
  9993. /// packets (the default), or false to disable splitting if the calling code
  9994. /// handles splitting manually</param>
  9995. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
  9996. {
  9997. OutPacket(packet, throttlePacketType, doAutomaticSplitting, null);
  9998. }
  9999. /// <summary>
  10000. /// This is the starting point for sending a simulator packet out to the client
  10001. /// </summary>
  10002. /// <param name="packet">Packet to send</param>
  10003. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10004. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10005. /// packets (the default), or false to disable splitting if the calling code
  10006. /// handles splitting manually</param>
  10007. /// <param name="method">The method to be called in the event this packet is reliable
  10008. /// and unacknowledged. The server will provide normal resend capability if you do not
  10009. /// provide your own method.</param>
  10010. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting, UnackedPacketMethod method)
  10011. {
  10012. if (m_debugPacketLevel > 0)
  10013. {
  10014. bool logPacket = true;
  10015. if (m_debugPacketLevel <= 255
  10016. && (packet.Type == PacketType.SimStats || packet.Type == PacketType.SimulatorViewerTimeMessage))
  10017. logPacket = false;
  10018. if (m_debugPacketLevel <= 200
  10019. && (packet.Type == PacketType.ImagePacket
  10020. || packet.Type == PacketType.ImageData
  10021. || packet.Type == PacketType.LayerData
  10022. || packet.Type == PacketType.CoarseLocationUpdate))
  10023. logPacket = false;
  10024. if (m_debugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect))
  10025. logPacket = false;
  10026. if (m_debugPacketLevel <= 50 && packet.Type == PacketType.ImprovedTerseObjectUpdate)
  10027. logPacket = false;
  10028. if (logPacket)
  10029. m_log.DebugFormat("[CLIENT]: Packet OUT {0}", packet.Type);
  10030. }
  10031. m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting, method);
  10032. }
  10033. public bool AddMoney(int debit)
  10034. {
  10035. if (m_moneyBalance + debit >= 0)
  10036. {
  10037. m_moneyBalance += debit;
  10038. SendMoneyBalance(UUID.Zero, true, Util.StringToBytes256("Poof Poof!"), m_moneyBalance);
  10039. return true;
  10040. }
  10041. return false;
  10042. }
  10043. protected void HandleAutopilot(Object sender, string method, List<String> args)
  10044. {
  10045. float locx = 0;
  10046. float locy = 0;
  10047. float locz = 0;
  10048. uint regionX = 0;
  10049. uint regionY = 0;
  10050. Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY);
  10051. locx = Convert.ToSingle(args[0]) - (float)regionX;
  10052. locy = Convert.ToSingle(args[1]) - (float)regionY;
  10053. locz = Convert.ToSingle(args[2]);
  10054. Action<Vector3, bool> handlerAutoPilotGo = OnAutoPilotGo;
  10055. if (handlerAutoPilotGo != null)
  10056. handlerAutoPilotGo(new Vector3(locx, locy, locz), false);
  10057. }
  10058. /// <summary>
  10059. /// Entryway from the client to the simulator. All UDP packets from the client will end up here
  10060. /// </summary>
  10061. /// <param name="Pack">OpenMetaverse.packet</param>
  10062. public void ProcessInPacket(Packet packet)
  10063. {
  10064. if (m_debugPacketLevel > 0)
  10065. {
  10066. bool outputPacket = true;
  10067. if (m_debugPacketLevel <= 255 && packet.Type == PacketType.AgentUpdate)
  10068. outputPacket = false;
  10069. if (m_debugPacketLevel <= 200 && packet.Type == PacketType.RequestImage)
  10070. outputPacket = false;
  10071. if (m_debugPacketLevel <= 100 && (packet.Type == PacketType.ViewerEffect || packet.Type == PacketType.AgentAnimation))
  10072. outputPacket = false;
  10073. if (outputPacket)
  10074. m_log.DebugFormat("[CLIENT]: Packet IN {0}", packet.Type);
  10075. }
  10076. if (!ProcessPacketMethod(packet))
  10077. m_log.Warn("[CLIENT]: unhandled packet " + packet.Type);
  10078. PacketPool.Instance.ReturnPacket(packet);
  10079. }
  10080. private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
  10081. {
  10082. PrimitiveBaseShape shape = new PrimitiveBaseShape();
  10083. shape.PCode = addPacket.ObjectData.PCode;
  10084. shape.State = addPacket.ObjectData.State;
  10085. shape.PathBegin = addPacket.ObjectData.PathBegin;
  10086. shape.PathEnd = addPacket.ObjectData.PathEnd;
  10087. shape.PathScaleX = addPacket.ObjectData.PathScaleX;
  10088. shape.PathScaleY = addPacket.ObjectData.PathScaleY;
  10089. shape.PathShearX = addPacket.ObjectData.PathShearX;
  10090. shape.PathShearY = addPacket.ObjectData.PathShearY;
  10091. shape.PathSkew = addPacket.ObjectData.PathSkew;
  10092. shape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
  10093. shape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
  10094. shape.Scale = addPacket.ObjectData.Scale;
  10095. shape.PathCurve = addPacket.ObjectData.PathCurve;
  10096. shape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
  10097. shape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
  10098. shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
  10099. shape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
  10100. shape.PathTaperX = addPacket.ObjectData.PathTaperX;
  10101. shape.PathTaperY = addPacket.ObjectData.PathTaperY;
  10102. shape.PathTwist = addPacket.ObjectData.PathTwist;
  10103. shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
  10104. Primitive.TextureEntry ntex = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f"));
  10105. shape.TextureEntry = ntex.GetBytes();
  10106. //shape.Textures = ntex;
  10107. return shape;
  10108. }
  10109. public ClientInfo GetClientInfo()
  10110. {
  10111. ClientInfo info = m_udpClient.GetClientInfo();
  10112. info.userEP = m_userEndPoint;
  10113. info.proxyEP = null;
  10114. info.agentcircuit = RequestClientInfo();
  10115. return info;
  10116. }
  10117. public void SetClientInfo(ClientInfo info)
  10118. {
  10119. m_udpClient.SetClientInfo(info);
  10120. }
  10121. public EndPoint GetClientEP()
  10122. {
  10123. return m_userEndPoint;
  10124. }
  10125. #region Media Parcel Members
  10126. public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
  10127. {
  10128. ParcelMediaCommandMessagePacket commandMessagePacket = new ParcelMediaCommandMessagePacket();
  10129. commandMessagePacket.CommandBlock.Flags = flags;
  10130. commandMessagePacket.CommandBlock.Command = (uint)command;
  10131. commandMessagePacket.CommandBlock.Time = time;
  10132. OutPacket(commandMessagePacket, ThrottleOutPacketType.Task);
  10133. }
  10134. public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID,
  10135. byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight,
  10136. byte mediaLoop)
  10137. {
  10138. ParcelMediaUpdatePacket updatePacket = new ParcelMediaUpdatePacket();
  10139. updatePacket.DataBlock.MediaURL = Util.StringToBytes256(mediaUrl);
  10140. updatePacket.DataBlock.MediaID = mediaTextureID;
  10141. updatePacket.DataBlock.MediaAutoScale = autoScale;
  10142. updatePacket.DataBlockExtended.MediaType = Util.StringToBytes256(mediaType);
  10143. updatePacket.DataBlockExtended.MediaDesc = Util.StringToBytes256(mediaDesc);
  10144. updatePacket.DataBlockExtended.MediaWidth = mediaWidth;
  10145. updatePacket.DataBlockExtended.MediaHeight = mediaHeight;
  10146. updatePacket.DataBlockExtended.MediaLoop = mediaLoop;
  10147. OutPacket(updatePacket, ThrottleOutPacketType.Task);
  10148. }
  10149. #endregion
  10150. #region Camera
  10151. public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
  10152. {
  10153. SetFollowCamPropertiesPacket packet = (SetFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.SetFollowCamProperties);
  10154. packet.ObjectData.ObjectID = objectID;
  10155. SetFollowCamPropertiesPacket.CameraPropertyBlock[] camPropBlock = new SetFollowCamPropertiesPacket.CameraPropertyBlock[parameters.Count];
  10156. uint idx = 0;
  10157. foreach (KeyValuePair<int, float> pair in parameters)
  10158. {
  10159. SetFollowCamPropertiesPacket.CameraPropertyBlock block = new SetFollowCamPropertiesPacket.CameraPropertyBlock();
  10160. block.Type = pair.Key;
  10161. block.Value = pair.Value;
  10162. camPropBlock[idx++] = block;
  10163. }
  10164. packet.CameraProperty = camPropBlock;
  10165. OutPacket(packet, ThrottleOutPacketType.Task);
  10166. }
  10167. public void SendClearFollowCamProperties(UUID objectID)
  10168. {
  10169. ClearFollowCamPropertiesPacket packet = (ClearFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ClearFollowCamProperties);
  10170. packet.ObjectData.ObjectID = objectID;
  10171. OutPacket(packet, ThrottleOutPacketType.Task);
  10172. }
  10173. #endregion
  10174. public void SetClientOption(string option, string value)
  10175. {
  10176. switch (option)
  10177. {
  10178. default:
  10179. break;
  10180. }
  10181. }
  10182. public string GetClientOption(string option)
  10183. {
  10184. switch (option)
  10185. {
  10186. default:
  10187. break;
  10188. }
  10189. return string.Empty;
  10190. }
  10191. public void KillEndDone()
  10192. {
  10193. }
  10194. #region IClientCore
  10195. private readonly Dictionary<Type, object> m_clientInterfaces = new Dictionary<Type, object>();
  10196. /// <summary>
  10197. /// Register an interface on this client, should only be called in the constructor.
  10198. /// </summary>
  10199. /// <typeparam name="T"></typeparam>
  10200. /// <param name="iface"></param>
  10201. protected void RegisterInterface<T>(T iface)
  10202. {
  10203. lock (m_clientInterfaces)
  10204. {
  10205. if (!m_clientInterfaces.ContainsKey(typeof(T)))
  10206. {
  10207. m_clientInterfaces.Add(typeof(T), iface);
  10208. }
  10209. }
  10210. }
  10211. public bool TryGet<T>(out T iface)
  10212. {
  10213. if (m_clientInterfaces.ContainsKey(typeof(T)))
  10214. {
  10215. iface = (T)m_clientInterfaces[typeof(T)];
  10216. return true;
  10217. }
  10218. iface = default(T);
  10219. return false;
  10220. }
  10221. public T Get<T>()
  10222. {
  10223. return (T)m_clientInterfaces[typeof(T)];
  10224. }
  10225. public void Disconnect(string reason)
  10226. {
  10227. Kick(reason);
  10228. Thread.Sleep(1000);
  10229. Close();
  10230. }
  10231. public void Disconnect()
  10232. {
  10233. Close();
  10234. }
  10235. #endregion
  10236. public void RefreshGroupMembership()
  10237. {
  10238. if (m_GroupsModule != null)
  10239. {
  10240. GroupMembershipData[] GroupMembership =
  10241. m_GroupsModule.GetMembershipData(AgentId);
  10242. m_groupPowers.Clear();
  10243. if (GroupMembership != null)
  10244. {
  10245. for (int i = 0; i < GroupMembership.Length; i++)
  10246. {
  10247. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  10248. }
  10249. }
  10250. }
  10251. }
  10252. public string Report()
  10253. {
  10254. return m_udpClient.GetStats();
  10255. }
  10256. public string XReport(string uptime, string version)
  10257. {
  10258. return String.Empty;
  10259. }
  10260. /// <summary>
  10261. /// Make an asset request to the asset service in response to a client request.
  10262. /// </summary>
  10263. /// <param name="transferRequest"></param>
  10264. /// <param name="taskID"></param>
  10265. protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
  10266. {
  10267. UUID requestID = UUID.Zero;
  10268. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
  10269. {
  10270. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10271. }
  10272. else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  10273. {
  10274. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10275. }
  10276. // m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID);
  10277. m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
  10278. }
  10279. /// <summary>
  10280. /// When we get a reply back from the asset service in response to a client request, send back the data.
  10281. /// </summary>
  10282. /// <param name="id"></param>
  10283. /// <param name="sender"></param>
  10284. /// <param name="asset"></param>
  10285. protected void AssetReceived(string id, Object sender, AssetBase asset)
  10286. {
  10287. if (asset == null)
  10288. return;
  10289. TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
  10290. UUID requestID = UUID.Zero;
  10291. byte source = (byte)SourceType.Asset;
  10292. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
  10293. {
  10294. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10295. }
  10296. else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  10297. {
  10298. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10299. source = (byte)SourceType.SimInventoryItem;
  10300. //m_log.Debug("asset request " + requestID);
  10301. }
  10302. // Scripts cannot be retrieved by direct request
  10303. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
  10304. return;
  10305. // The asset is known to exist and is in our cache, so add it to the AssetRequests list
  10306. AssetRequestToClient req = new AssetRequestToClient();
  10307. req.AssetInf = asset;
  10308. req.AssetRequestSource = source;
  10309. req.IsTextureRequest = false;
  10310. req.NumPackets = CalculateNumPackets(asset.Data);
  10311. req.Params = transferRequest.TransferInfo.Params;
  10312. req.RequestAssetID = requestID;
  10313. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10314. SendAsset(req);
  10315. }
  10316. /// <summary>
  10317. /// Calculate the number of packets required to send the asset to the client.
  10318. /// </summary>
  10319. /// <param name="data"></param>
  10320. /// <returns></returns>
  10321. private static int CalculateNumPackets(byte[] data)
  10322. {
  10323. const uint m_maxPacketSize = 600;
  10324. int numPackets = 1;
  10325. if (data == null)
  10326. return 0;
  10327. if (data.LongLength > m_maxPacketSize)
  10328. {
  10329. // over max number of bytes so split up file
  10330. long restData = data.LongLength - m_maxPacketSize;
  10331. int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
  10332. numPackets += restPackets;
  10333. }
  10334. return numPackets;
  10335. }
  10336. #region IClientIPEndpoint Members
  10337. public IPAddress EndPoint
  10338. {
  10339. get
  10340. {
  10341. if (m_userEndPoint is IPEndPoint)
  10342. {
  10343. IPEndPoint ep = (IPEndPoint)m_userEndPoint;
  10344. return ep.Address;
  10345. }
  10346. return null;
  10347. }
  10348. }
  10349. #endregion
  10350. public void SendRebakeAvatarTextures(UUID textureID)
  10351. {
  10352. RebakeAvatarTexturesPacket pack =
  10353. (RebakeAvatarTexturesPacket)PacketPool.Instance.GetPacket(PacketType.RebakeAvatarTextures);
  10354. pack.TextureData = new RebakeAvatarTexturesPacket.TextureDataBlock();
  10355. pack.TextureData.TextureID = textureID;
  10356. OutPacket(pack, ThrottleOutPacketType.Task);
  10357. }
  10358. public struct PacketProcessor
  10359. {
  10360. public PacketMethod method;
  10361. public bool Async;
  10362. }
  10363. public class AsyncPacketProcess
  10364. {
  10365. public bool result = false;
  10366. public readonly LLClientView ClientView = null;
  10367. public readonly Packet Pack = null;
  10368. public readonly PacketMethod Method = null;
  10369. public AsyncPacketProcess(LLClientView pClientview, PacketMethod pMethod, Packet pPack)
  10370. {
  10371. ClientView = pClientview;
  10372. Method = pMethod;
  10373. Pack = pPack;
  10374. }
  10375. }
  10376. public static OSD BuildEvent(string eventName, OSD eventBody)
  10377. {
  10378. OSDMap osdEvent = new OSDMap(2);
  10379. osdEvent.Add("message", new OSDString(eventName));
  10380. osdEvent.Add("body", eventBody);
  10381. return osdEvent;
  10382. }
  10383. public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
  10384. {
  10385. AvatarInterestsReplyPacket packet = (AvatarInterestsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarInterestsReply);
  10386. packet.AgentData = new AvatarInterestsReplyPacket.AgentDataBlock();
  10387. packet.AgentData.AgentID = AgentId;
  10388. packet.AgentData.AvatarID = avatarID;
  10389. packet.PropertiesData = new AvatarInterestsReplyPacket.PropertiesDataBlock();
  10390. packet.PropertiesData.WantToMask = wantMask;
  10391. packet.PropertiesData.WantToText = Utils.StringToBytes(wantText);
  10392. packet.PropertiesData.SkillsMask = skillsMask;
  10393. packet.PropertiesData.SkillsText = Utils.StringToBytes(skillsText);
  10394. packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages);
  10395. OutPacket(packet, ThrottleOutPacketType.Task);
  10396. }
  10397. public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
  10398. {
  10399. ChangeUserRightsPacket packet = (ChangeUserRightsPacket)PacketPool.Instance.GetPacket(PacketType.ChangeUserRights);
  10400. packet.AgentData = new ChangeUserRightsPacket.AgentDataBlock();
  10401. packet.AgentData.AgentID = agentID;
  10402. packet.Rights = new ChangeUserRightsPacket.RightsBlock[1];
  10403. packet.Rights[0] = new ChangeUserRightsPacket.RightsBlock();
  10404. packet.Rights[0].AgentRelated = friendID;
  10405. packet.Rights[0].RelatedRights = rights;
  10406. OutPacket(packet, ThrottleOutPacketType.Task);
  10407. }
  10408. public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
  10409. {
  10410. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  10411. dialog.Data.ObjectID = objectId;
  10412. dialog.Data.ChatChannel = chatChannel;
  10413. dialog.Data.ImageID = UUID.Zero;
  10414. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  10415. // this is the username of the *owner*
  10416. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  10417. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  10418. dialog.Data.Message = Util.StringToBytes256(message);
  10419. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[1];
  10420. buttons[0] = new ScriptDialogPacket.ButtonsBlock();
  10421. buttons[0].ButtonLabel = Util.StringToBytes256("!!llTextBox!!");
  10422. dialog.Buttons = buttons;
  10423. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  10424. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  10425. dialog.OwnerData[0].OwnerID = ownerID;
  10426. OutPacket(dialog, ThrottleOutPacketType.Task);
  10427. }
  10428. public void StopFlying(ISceneEntity p)
  10429. {
  10430. if (p is ScenePresence)
  10431. {
  10432. ScenePresence presence = p as ScenePresence;
  10433. // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
  10434. // There's no explicit message to send the client to tell it to stop flying.. it relies on the
  10435. // velocity, collision plane and avatar height
  10436. // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
  10437. // when the avatar stands up
  10438. Vector3 pos = presence.AbsolutePosition;
  10439. if (presence.Appearance.AvatarHeight != 127.0f)
  10440. pos += new Vector3(0f, 0f, (presence.Appearance.AvatarHeight/6f));
  10441. else
  10442. pos += new Vector3(0f, 0f, (1.56f/6f));
  10443. presence.AbsolutePosition = pos;
  10444. // attach a suitable collision plane regardless of the actual situation to force the LLClient to land.
  10445. // Collision plane below the avatar's position a 6th of the avatar's height is suitable.
  10446. // Mind you, that this method doesn't get called if the avatar's velocity magnitude is greater then a
  10447. // certain amount.. because the LLClient wouldn't land in that situation anyway.
  10448. // why are we still testing for this really old height value default???
  10449. if (presence.Appearance.AvatarHeight != 127.0f)
  10450. presence.CollisionPlane = new Vector4(0, 0, 0, pos.Z - presence.Appearance.AvatarHeight/6f);
  10451. else
  10452. presence.CollisionPlane = new Vector4(0, 0, 0, pos.Z - (1.56f/6f));
  10453. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block =
  10454. CreateImprovedTerseBlock(p, false);
  10455. const float TIME_DILATION = 1.0f;
  10456. ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f);
  10457. ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket();
  10458. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  10459. packet.RegionData.TimeDilation = timeDilation;
  10460. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  10461. packet.ObjectData[0] = block;
  10462. OutPacket(packet, ThrottleOutPacketType.Task, true);
  10463. }
  10464. //ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
  10465. // AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient)));
  10466. }
  10467. public void SendPlacesReply(UUID queryID, UUID transactionID,
  10468. PlacesReplyData[] data)
  10469. {
  10470. PlacesReplyPacket reply = null;
  10471. PlacesReplyPacket.QueryDataBlock[] dataBlocks =
  10472. new PlacesReplyPacket.QueryDataBlock[0];
  10473. for (int i = 0 ; i < data.Length ; i++)
  10474. {
  10475. PlacesReplyPacket.QueryDataBlock block =
  10476. new PlacesReplyPacket.QueryDataBlock();
  10477. block.OwnerID = data[i].OwnerID;
  10478. block.Name = Util.StringToBytes256(data[i].Name);
  10479. block.Desc = Util.StringToBytes1024(data[i].Desc);
  10480. block.ActualArea = data[i].ActualArea;
  10481. block.BillableArea = data[i].BillableArea;
  10482. block.Flags = data[i].Flags;
  10483. block.GlobalX = data[i].GlobalX;
  10484. block.GlobalY = data[i].GlobalY;
  10485. block.GlobalZ = data[i].GlobalZ;
  10486. block.SimName = Util.StringToBytes256(data[i].SimName);
  10487. block.SnapshotID = data[i].SnapshotID;
  10488. block.Dwell = data[i].Dwell;
  10489. block.Price = data[i].Price;
  10490. if (reply != null && reply.Length + block.Length > 1400)
  10491. {
  10492. OutPacket(reply, ThrottleOutPacketType.Task);
  10493. reply = null;
  10494. dataBlocks = new PlacesReplyPacket.QueryDataBlock[0];
  10495. }
  10496. if (reply == null)
  10497. {
  10498. reply = (PlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.PlacesReply);
  10499. reply.AgentData = new PlacesReplyPacket.AgentDataBlock();
  10500. reply.AgentData.AgentID = AgentId;
  10501. reply.AgentData.QueryID = queryID;
  10502. reply.TransactionData = new PlacesReplyPacket.TransactionDataBlock();
  10503. reply.TransactionData.TransactionID = transactionID;
  10504. reply.QueryData = dataBlocks;
  10505. }
  10506. Array.Resize(ref dataBlocks, dataBlocks.Length + 1);
  10507. dataBlocks[dataBlocks.Length - 1] = block;
  10508. reply.QueryData = dataBlocks;
  10509. }
  10510. if (reply != null)
  10511. OutPacket(reply, ThrottleOutPacketType.Task);
  10512. }
  10513. }
  10514. }